feat(Mtjywpm): enhance DTOs and service for unified commodity name processing and bidding time parsing

This commit is contained in:
2025-09-22 23:48:22 +08:00
parent 3b6932647c
commit e462c92ef8
5 changed files with 507 additions and 3 deletions

View File

@@ -4,5 +4,143 @@ import cn.lihongjie.coal.base.dto.CommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
public class CreateMtjywpmDto extends CommonDto {}
public class CreateMtjywpmDto extends CommonDto {
@Comment("品种名称")
private String pinzmc;
@Comment("行号")
private Integer rownum_;
@Comment("发布状态名称")
private String postatusname;
@Comment("结束时间")
private LocalDateTime totime;
@Comment("商品名称")
private String commodityname;
@Comment("统一商品名称")
private String unifiedcommodityname;
@Comment("供货煤矿")
private String gonghmk;
@Comment("交易结果地址")
private String dealurl;
@Comment("发布状态")
private String postatus;
@Comment("煤种名称")
private String meizmc;
@Comment("竞价时间")
private String jjtime;
@Comment("发热量下限")
private String frl1;
@Comment("发热量上限")
private String frl2;
@Comment("品种名称")
private String varietyname;
@Comment("系统ID")
private Long sysid;
@Comment("发布价格")
private BigDecimal poprice;
@Comment("交易代码")
private String tradercode;
@Comment("竞价结束时间")
private LocalDateTime bidendtime;
@Comment("发布交易商名称")
private String potradername;
@Comment("竞价开始时间")
private LocalDateTime bidstarttime;
@Comment("字段1-地区")
private String field1;
@Comment("成交价格")
private BigDecimal toprice;
@Comment("挥发分下限")
private String hf1;
@Comment("商品质量")
private String commodityquality;
@Comment("内水下限")
private String nj1;
@Comment("挥发分上限")
private String hf2;
@Comment("公告地址")
private String gonggdz;
@Comment("全硫上限")
private String ql2;
@Comment("全硫下限")
private String ql1;
@Comment("内水上限")
private String nj2;
@Comment("粒度下限")
private String ld1;
@Comment("灰熔点下限")
private String hff1;
@Comment("灰熔点上限")
private String hff2;
@Comment("交易模式ID")
private Integer trademodeid;
@Comment("粒度上限")
private String ld2;
@Comment("发布数量")
private BigDecimal poquantity;
@Comment("字段3")
private String field3;
@Comment("发布时间")
private LocalDateTime potime;
@Comment("字段2")
private String field2;
@Comment("水分上限")
private String sf2;
@Comment("交易方向名称")
private String directionname;
@Comment("水分下限")
private String sf1;
private LocalDate jjdate;
private LocalTime jjstarttime;
private LocalTime jjendtime;
}

View File

@@ -4,5 +4,143 @@ import cn.lihongjie.coal.base.dto.CommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
public class MtjywpmDto extends CommonDto {}
public class MtjywpmDto extends CommonDto {
@Comment("品种名称")
private String pinzmc;
@Comment("行号")
private Integer rownum_;
@Comment("发布状态名称")
private String postatusname;
@Comment("结束时间")
private LocalDateTime totime;
@Comment("商品名称")
private String commodityname;
@Comment("统一商品名称")
private String unifiedcommodityname;
@Comment("供货煤矿")
private String gonghmk;
@Comment("交易结果地址")
private String dealurl;
@Comment("发布状态")
private String postatus;
@Comment("煤种名称")
private String meizmc;
@Comment("竞价时间")
private String jjtime;
@Comment("发热量下限")
private String frl1;
@Comment("发热量上限")
private String frl2;
@Comment("品种名称")
private String varietyname;
@Comment("系统ID")
private Long sysid;
@Comment("发布价格")
private BigDecimal poprice;
@Comment("交易代码")
private String tradercode;
@Comment("竞价结束时间")
private LocalDateTime bidendtime;
@Comment("发布交易商名称")
private String potradername;
@Comment("竞价开始时间")
private LocalDateTime bidstarttime;
@Comment("字段1-地区")
private String field1;
@Comment("成交价格")
private BigDecimal toprice;
@Comment("挥发分下限")
private String hf1;
@Comment("商品质量")
private String commodityquality;
@Comment("内水下限")
private String nj1;
@Comment("挥发分上限")
private String hf2;
@Comment("公告地址")
private String gonggdz;
@Comment("全硫上限")
private String ql2;
@Comment("全硫下限")
private String ql1;
@Comment("内水上限")
private String nj2;
@Comment("粒度下限")
private String ld1;
@Comment("灰熔点下限")
private String hff1;
@Comment("灰熔点上限")
private String hff2;
@Comment("交易模式ID")
private Integer trademodeid;
@Comment("粒度上限")
private String ld2;
@Comment("发布数量")
private BigDecimal poquantity;
@Comment("字段3")
private String field3;
@Comment("发布时间")
private LocalDateTime potime;
@Comment("字段2")
private String field2;
@Comment("水分上限")
private String sf2;
@Comment("交易方向名称")
private String directionname;
@Comment("水分下限")
private String sf1;
private LocalDate jjdate;
private LocalTime jjstarttime;
private LocalTime jjendtime;
}

View File

@@ -4,5 +4,144 @@ import cn.lihongjie.coal.base.dto.CommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
public class UpdateMtjywpmDto extends CommonDto {}
public class UpdateMtjywpmDto extends CommonDto {
@Comment("品种名称")
private String pinzmc;
@Comment("行号")
private Integer rownum_;
@Comment("发布状态名称")
private String postatusname;
@Comment("结束时间")
private LocalDateTime totime;
@Comment("商品名称")
private String commodityname;
@Comment("统一商品名称")
private String unifiedcommodityname;
@Comment("供货煤矿")
private String gonghmk;
@Comment("交易结果地址")
private String dealurl;
@Comment("发布状态")
private String postatus;
@Comment("煤种名称")
private String meizmc;
@Comment("竞价时间")
private String jjtime;
@Comment("发热量下限")
private String frl1;
@Comment("发热量上限")
private String frl2;
@Comment("品种名称")
private String varietyname;
@Comment("系统ID")
private Long sysid;
@Comment("发布价格")
private BigDecimal poprice;
@Comment("交易代码")
private String tradercode;
@Comment("竞价结束时间")
private LocalDateTime bidendtime;
@Comment("发布交易商名称")
private String potradername;
@Comment("竞价开始时间")
private LocalDateTime bidstarttime;
@Comment("字段1-地区")
private String field1;
@Comment("成交价格")
private BigDecimal toprice;
@Comment("挥发分下限")
private String hf1;
@Comment("商品质量")
private String commodityquality;
@Comment("内水下限")
private String nj1;
@Comment("挥发分上限")
private String hf2;
@Comment("公告地址")
private String gonggdz;
@Comment("全硫上限")
private String ql2;
@Comment("全硫下限")
private String ql1;
@Comment("内水上限")
private String nj2;
@Comment("粒度下限")
private String ld1;
@Comment("灰熔点下限")
private String hff1;
@Comment("灰熔点上限")
private String hff2;
@Comment("交易模式ID")
private Integer trademodeid;
@Comment("粒度上限")
private String ld2;
@Comment("发布数量")
private BigDecimal poquantity;
@Comment("字段3")
private String field3;
@Comment("发布时间")
private LocalDateTime potime;
@Comment("字段2")
private String field2;
@Comment("水分上限")
private String sf2;
@Comment("交易方向名称")
private String directionname;
@Comment("水分下限")
private String sf1;
private LocalDate jjdate;
private LocalTime jjstarttime;
private LocalTime jjendtime;
}

View File

@@ -10,7 +10,9 @@ import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
@EqualsAndHashCode(callSuper = false)
@@ -31,6 +33,9 @@ public class MtjywpmEntity extends CommonEntity {
@Comment("商品名称")
private String commodityname;
@Comment("统一商品名称")
private String unifiedcommodityname;
@Comment("供货煤矿")
private String gonghmk;
@@ -139,4 +144,9 @@ public class MtjywpmEntity extends CommonEntity {
@Comment("水分下限")
private String sf1;
private LocalDate jjdate;
private LocalTime jjstarttime;
private LocalTime jjendtime;
}

View File

@@ -29,7 +29,9 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
@@ -294,11 +296,22 @@ public class MtjywpmService extends BaseService<MtjywpmEntity, MtjywpmRepository
entity.setRownum_(getIntegerValue(dataMap, "rownum_"));
entity.setPostatusname(getStringValue(dataMap, "postatusname"));
entity.setCommodityname(getStringValue(dataMap, "commodityname"));
// 处理统一商品名称,去除"-X标段"后缀
String commodityName = getStringValue(dataMap, "commodityname");
String unifiedName = processUnifiedCommodityName(commodityName);
entity.setUnifiedcommodityname(unifiedName);
entity.setGonghmk(getStringValue(dataMap, "gonghmk"));
entity.setDealurl(getStringValue(dataMap, "dealurl"));
entity.setPostatus(getStringValue(dataMap, "postatus"));
entity.setMeizmc(getStringValue(dataMap, "meizmc"));
entity.setJjtime(getStringValue(dataMap, "jjtime"));
// 处理竞价时间相关字段
String jjtime = getStringValue(dataMap, "jjtime");
parseAndSetJjtimeFields(entity, jjtime);
entity.setFrl1(getStringValue(dataMap, "frl1"));
entity.setFrl2(getStringValue(dataMap, "frl2"));
entity.setVarietyname(getStringValue(dataMap, "varietyname"));
@@ -348,6 +361,16 @@ public class MtjywpmService extends BaseService<MtjywpmEntity, MtjywpmRepository
entity.setTotime(getLocalDateTimeValue(dataMap, "totime"));
entity.setDealurl(getStringValue(dataMap, "dealurl"));
// 更新商品名称和统一商品名称
String commodityName = getStringValue(dataMap, "commodityname");
entity.setCommodityname(commodityName);
entity.setUnifiedcommodityname(processUnifiedCommodityName(commodityName));
// 更新竞价时间相关字段
String jjtime = getStringValue(dataMap, "jjtime");
entity.setJjtime(jjtime);
parseAndSetJjtimeFields(entity, jjtime);
// 其他字段根据需要更新
entity.setCommodityquality(getStringValue(dataMap, "commodityquality"));
}
@@ -398,4 +421,60 @@ public class MtjywpmService extends BaseService<MtjywpmEntity, MtjywpmRepository
return null;
}
}
/**
* 处理统一商品名称,去除"-X标段"后缀
*/
private String processUnifiedCommodityName(String commodityName) {
if (commodityName == null || commodityName.trim().isEmpty()) {
return commodityName;
}
// 使用正则表达式去除"-X标段"、"-D标段"等模式
return commodityName.replaceAll("-[A-Za-z0-9]+标段$", "").trim();
}
/**
* 解析竞价时间字符串并设置相关字段
* 例如: "09-23 14:40至09-23 15:10" -> 日期: 当前年-09-23, 开始时间: 14:40, 结束时间: 15:10
*/
private void parseAndSetJjtimeFields(MtjywpmEntity entity, String jjtime) {
if (jjtime == null || jjtime.trim().isEmpty()) {
return;
}
try {
// 解析格式如: "09-23 14:40至09-23 15:10"
String trimmedTime = jjtime.trim();
if (trimmedTime.contains("")) {
String[] timeParts = trimmedTime.split("");
if (timeParts.length == 2) {
String startPart = timeParts[0].trim(); // "09-23 14:40"
String endPart = timeParts[1].trim(); // "09-23 15:10"
// 解析开始时间部分
String[] startSegments = startPart.split(" ");
if (startSegments.length == 2) {
String startDatePart = startSegments[0]; // "09-23"
String startTimePart = startSegments[1]; // "14:40"
// 构建完整日期(使用当前年份)
int currentYear = LocalDate.now().getYear();
String fullStartDate = currentYear + "-" + startDatePart;
entity.setJjdate(LocalDate.parse(fullStartDate));
entity.setJjstarttime(LocalTime.parse(startTimePart));
}
// 解析结束时间部分
String[] endSegments = endPart.split(" ");
if (endSegments.length == 2) {
String endTimePart = endSegments[1]; // "15:10"
entity.setJjendtime(LocalTime.parse(endTimePart));
}
}
}
} catch (Exception e) {
log.warn("解析竞价时间失败: {}", jjtime, e);
}
}
}