diff --git a/src/main/java/mjkf/xinke/main/common/generator/DataDbMpGenerator.java b/src/main/java/mjkf/xinke/main/common/generator/DataDbMpGenerator.java index 7ab588e..ce7fa78 100644 --- a/src/main/java/mjkf/xinke/main/common/generator/DataDbMpGenerator.java +++ b/src/main/java/mjkf/xinke/main/common/generator/DataDbMpGenerator.java @@ -21,7 +21,7 @@ public class DataDbMpGenerator { private static String password = "Xxs123456"; private static String schema = "material_manage"; private static String[] tableList = { - "ASPHALT_MODIFIER", + "DATA_NETWORK", }; diff --git a/src/main/java/mjkf/xinke/main/constant/MaterialTaskType.java b/src/main/java/mjkf/xinke/main/constant/MaterialTaskType.java index a7f1132..f4ee98e 100644 --- a/src/main/java/mjkf/xinke/main/constant/MaterialTaskType.java +++ b/src/main/java/mjkf/xinke/main/constant/MaterialTaskType.java @@ -19,41 +19,41 @@ public class MaterialTaskType { // 三明钢铁 public static final Integer SANMING_STEEL = 301; // 交通局 - public static final Integer FUZHOU_TRANSPORTATION_BUREAU = 40101; // todo-1 福州交通局 - public static final Integer LONGYAN_TRANSPORTATION_BUREAU = 40102; // todo-1 龙岩交通局 - public static final Integer NANPING_TRANSPORTATION_BUREAU = 40103; // todo-1 南平交通局 - public static final Integer NINGDE_TRANSPORTATION_BUREAU = 40104; // todo-1 宁德交通局 - public static final Integer PINTAN_TRANSPORTATION_BUREAU = 40105; // todo-1 平潭交通局 - public static final Integer PUTIAN_TRANSPORTATION_BUREAU = 40106; // todo-1 莆田交通局 - public static final Integer QUANZHOU_TRANSPORTATION_BUREAU = 40107; // todo-1 泉州交通局 - public static final Integer SANMING_TRANSPORTATION_BUREAU = 40108; // todo-1 三明交通局 - public static final Integer XIAMEN_TRANSPORTATION_BUREAU = 40109; // todo-1 厦门交通局 - public static final Integer ZHANGZHOU_TRANSPORTATION_BUREAU = 40110; // todo-1 漳州交通局 - public static final Integer ZHANGZHOUKFQ_TRANSPORTATION_BUREAU = 40111; // todo-1 漳州开发区交通局 + public static final Integer FUZHOU_TRANSPORTATION_BUREAU = 40101; // 福州交通局 + public static final Integer LONGYAN_TRANSPORTATION_BUREAU = 40102; // 龙岩交通局 + public static final Integer NANPING_TRANSPORTATION_BUREAU = 40103; // 南平交通局 + public static final Integer NINGDE_TRANSPORTATION_BUREAU = 40104; // 宁德交通局 + public static final Integer PINTAN_TRANSPORTATION_BUREAU = 40105; // 平潭交通局 + public static final Integer PUTIAN_TRANSPORTATION_BUREAU = 40106; // 莆田交通局 + public static final Integer QUANZHOU_TRANSPORTATION_BUREAU = 40107; // 泉州交通局 + public static final Integer SANMING_TRANSPORTATION_BUREAU = 40108; // 三明交通局 + public static final Integer XIAMEN_TRANSPORTATION_BUREAU = 40109; // 厦门交通局 + public static final Integer ZHANGZHOU_TRANSPORTATION_BUREAU = 40110; // 漳州交通局 + public static final Integer ZHANGZHOUKFQ_TRANSPORTATION_BUREAU = 40111; // 漳州开发区交通局 // 公路局 - public static final Integer FUZHOU_HIGHWAY_BUREAU = 40201; // todo-1 福州公路局 - public static final Integer LONGYAN_HIGHWAY_BUREAU = 40202; // todo-1 龙岩公路局 - public static final Integer NANPING_HIGHWAY_BUREAU = 40203; // todo-1 南平公路局 - public static final Integer NINGDE_HIGHWAY_BUREAU = 40204; // todo-1 宁德公路局 - public static final Integer PINTAN_HIGHWAY_BUREAU = 40205; // todo-1 平潭公路局 - public static final Integer PUTIAN_HIGHWAY_BUREAU = 40206; // todo-1 莆田公路局 - public static final Integer QUANZHOU_HIGHWAY_BUREAU = 40207; // todo-1 泉州公路局 - public static final Integer SANMING_HIGHWAY_BUREAU = 40208; // todo-1 三明公路局 - public static final Integer XIAMEN_HIGHWAY_BUREAU = 40209; // todo-1 厦门公路局 - public static final Integer ZHANGZHOU_HIGHWAY_BUREAU = 40210; // todo-1 漳州公路局 - public static final Integer ZHANGZHOUKFQ_HIGHWAY_BUREAU = 40211; // todo-1 漳州开发区公路局 + public static final Integer FUZHOU_HIGHWAY_BUREAU = 40201; // 福州公路局 + public static final Integer LONGYAN_HIGHWAY_BUREAU = 40202; // 龙岩公路局 + public static final Integer NANPING_HIGHWAY_BUREAU = 40203; // 南平公路局 + public static final Integer NINGDE_HIGHWAY_BUREAU = 40204; // 宁德公路局 + public static final Integer PINTAN_HIGHWAY_BUREAU = 40205; // 平潭公路局 + public static final Integer PUTIAN_HIGHWAY_BUREAU = 40206; // 莆田公路局 + public static final Integer QUANZHOU_HIGHWAY_BUREAU = 40207; // 泉州公路局 + public static final Integer SANMING_HIGHWAY_BUREAU = 40208; // 三明公路局 + public static final Integer XIAMEN_HIGHWAY_BUREAU = 40209; // 厦门公路局 + public static final Integer ZHANGZHOU_HIGHWAY_BUREAU = 40210; // 漳州公路局 + public static final Integer ZHANGZHOUKFQ_HIGHWAY_BUREAU = 40211; // 漳州开发区公路局 // 地市调查表 - public static final Integer FUZHOU_SURVEY = 501; // todo-1 福州调查表 - public static final Integer LONGYAN_SURVEY = 502; // todo-1 龙岩调查表 - public static final Integer NANPING_SURVEY = 503; // todo-1 南平调查表 - public static final Integer NINGDE_SURVEY = 504; // todo-1 宁德调查表 - public static final Integer PINTAN_SURVEY = 505; // todo-1 平潭调查表 - public static final Integer PUTIAN_SURVEY = 506; // todo-1 莆田调查表 - public static final Integer QUANZHOU_SURVEY = 507; // todo-1 泉州调查表 - public static final Integer SANMING_SURVEY = 508; // todo-1 三明调查表 - public static final Integer XIAMEN_SURVEY = 509; // todo-1 厦门调查表 - public static final Integer ZHANGZHOU_SURVEY = 510; // todo-1 漳州调查表 - public static final Integer ZHANGZHOUKFQ_SURVEY = 511; // todo-1 漳州开发区调查表 + public static final Integer FUZHOU_SURVEY = 501; // 福州调查表 + public static final Integer LONGYAN_SURVEY = 502; // 龙岩调查表 + public static final Integer NANPING_SURVEY = 503; // 南平调查表 + public static final Integer NINGDE_SURVEY = 504; // 宁德调查表 + public static final Integer PINTAN_SURVEY = 505; // 平潭调查表 + public static final Integer PUTIAN_SURVEY = 506; // 莆田调查表 + public static final Integer QUANZHOU_SURVEY = 507; // 泉州调查表 + public static final Integer SANMING_SURVEY = 508; // 三明调查表 + public static final Integer XIAMEN_SURVEY = 509; // 厦门调查表 + public static final Integer ZHANGZHOU_SURVEY = 510; // 漳州调查表 + public static final Integer ZHANGZHOUKFQ_SURVEY = 511; // 漳州开发区调查表 // 其他省份 public static final Integer OTHER_ZHEJIANG = 601; // 浙江 public static final Integer OTHER_GIANLZHOU = 602; // 广州 @@ -290,9 +290,6 @@ public class MaterialTaskType { /** * todo-1 数据展示模块 地市暂不切换 - * todo-1 十一个地市接口 - * todo-1 采集结果“产地”改成“品牌产商” - * todo-0 传采集数据网络价格计算 * todo-1 趋势图一年每月打点 * todo-1 项目材料价格预算“最高(低)总金额”携带上价格的月份 * todo-1 项目材料价格预算计算数值没有小数点 diff --git a/src/main/java/mjkf/xinke/main/model/db/AsphaltDomestic.java b/src/main/java/mjkf/xinke/main/model/db/AsphaltDomestic.java index 2ef6389..5a5255d 100644 --- a/src/main/java/mjkf/xinke/main/model/db/AsphaltDomestic.java +++ b/src/main/java/mjkf/xinke/main/model/db/AsphaltDomestic.java @@ -56,7 +56,7 @@ public class AsphaltDomestic extends Model { public AsphaltDomestic () {} - public AsphaltDomestic (Row row) { + public AsphaltDomestic (Row row, MaterialTask data) { var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK; this.setName(row.getCell(0, policy).getStringCellValue()); this.setPrice(BigDecimal.valueOf(row.getCell(1, policy).getNumericCellValue())); diff --git a/src/main/java/mjkf/xinke/main/model/db/AsphaltImported.java b/src/main/java/mjkf/xinke/main/model/db/AsphaltImported.java index 95849f0..487c0f2 100644 --- a/src/main/java/mjkf/xinke/main/model/db/AsphaltImported.java +++ b/src/main/java/mjkf/xinke/main/model/db/AsphaltImported.java @@ -52,7 +52,7 @@ public class AsphaltImported extends Model { public AsphaltImported () {} - public AsphaltImported (Row row) { + public AsphaltImported (Row row, MaterialTask data) { var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK; this.setName(row.getCell(0, policy).getStringCellValue()); this.setPrice(BigDecimal.valueOf(row.getCell(1, policy).getNumericCellValue())); diff --git a/src/main/java/mjkf/xinke/main/model/db/AsphaltModifier.java b/src/main/java/mjkf/xinke/main/model/db/AsphaltModifier.java index 77718b4..81ff0f8 100644 --- a/src/main/java/mjkf/xinke/main/model/db/AsphaltModifier.java +++ b/src/main/java/mjkf/xinke/main/model/db/AsphaltModifier.java @@ -56,7 +56,7 @@ public class AsphaltModifier extends Model { public AsphaltModifier() {} - public AsphaltModifier (Row row) { + public AsphaltModifier (Row row, MaterialTask data) { this.setName(row.getCell(0).getStringCellValue()); this.setSpec(""); this.setPrice(BigDecimal.valueOf(row.getCell(1).getNumericCellValue())); diff --git a/src/main/java/mjkf/xinke/main/model/db/Cement.java b/src/main/java/mjkf/xinke/main/model/db/Cement.java index 086f3f7..70d6656 100644 --- a/src/main/java/mjkf/xinke/main/model/db/Cement.java +++ b/src/main/java/mjkf/xinke/main/model/db/Cement.java @@ -68,7 +68,7 @@ public class Cement extends Model { public Cement () {} - public Cement (Row row) { + public Cement (Row row, MaterialTask data) { this.setName(row.getCell(0).getStringCellValue()); this.setSpec(row.getCell(1).getStringCellValue()); this.setPack(row.getCell(2).getStringCellValue()); diff --git a/src/main/java/mjkf/xinke/main/model/db/DataNetwork.java b/src/main/java/mjkf/xinke/main/model/db/DataNetwork.java index daf1ee2..f88a75c 100644 --- a/src/main/java/mjkf/xinke/main/model/db/DataNetwork.java +++ b/src/main/java/mjkf/xinke/main/model/db/DataNetwork.java @@ -94,8 +94,14 @@ public class DataNetwork extends Model { this.setPrice(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue())); this.setSource(row.getCell(6, policy).getStringCellValue()); this.setRemark(row.getCell(7, policy).getStringCellValue()); - this.setDate(LocalDate.of(task.getYear(), task.getMonth(), 1)); // 日期从任务获取 + this.setDate(LocalDate.of(task.getYear(), task.getMonth(), 1)); // 从任务获取日期 this.setRegion(MaterialTaskType.getRegion(task.getType())); + if (this.getName().isEmpty()) { + throw new IllegalArgumentException("名称为空"); + } + if (ObjectUtil.isEmpty(this.getPrice())) { + throw new IllegalArgumentException("缺少价格"); + } } public DataNetwork update(DataNetwork item) { diff --git a/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java b/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java index cdc1fbc..d2fb879 100644 --- a/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java +++ b/src/main/java/mjkf/xinke/main/model/db/FujianSurvey.java @@ -13,6 +13,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import mjkf.xinke.main.constant.MaterialTaskType; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; @@ -67,6 +68,10 @@ public class FujianSurvey extends Model { @TableField("`TAX`") private Integer tax; + @ApiModelProperty("地区") + @TableField("`REGION`") + private String region; + @Override public Serializable pkVal() { return this.id; @@ -74,17 +79,18 @@ public class FujianSurvey extends Model { public FujianSurvey () {} - public FujianSurvey (Row row) { + public FujianSurvey (Row row, MaterialTask task) { var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK; - row.getCell(0).setCellType(CellType.STRING); + row.getCell(0, policy).setCellType(CellType.STRING); this.setMaterialId(row.getCell(0, policy).getStringCellValue()); - this.setName(row.getCell(1, policy).getStringCellValue()); - this.setSpec(row.getCell(2, policy).getStringCellValue()); + this.setName(row.getCell(1, policy).getStringCellValue().replace(" ", "")); + this.setSpec(row.getCell(2, policy).getStringCellValue().replace(" ", "")); this.setUnit(row.getCell(3, policy).getStringCellValue()); this.setBrand(row.getCell(4, policy).getStringCellValue()); this.setPrice(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue())); this.setTax(((Double) row.getCell(6, policy).getNumericCellValue()).intValue()); - this.setDate(row.getCell(7, policy).getLocalDateTimeCellValue().toLocalDate()); + this.setDate(LocalDate.of(task.getYear(), task.getMonth(), 1)); // 从任务获取日期 + this.setRegion(MaterialTaskType.getRegion(task.getType())); if (this.getName().isEmpty()) { throw new IllegalArgumentException("名称为空"); } diff --git a/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java b/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java index be98992..a415cf3 100644 --- a/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java +++ b/src/main/java/mjkf/xinke/main/model/db/FuzhouHighwayBureau.java @@ -1,5 +1,6 @@ package mjkf.xinke.main.model.db; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -12,6 +13,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import mjkf.xinke.main.constant.MaterialTaskType; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; @@ -62,6 +64,10 @@ public class FuzhouHighwayBureau extends Model { @TableField("`BRAND`") private String brand; + @ApiModelProperty("地区") + @TableField("`REGION`") + private String region; + @Override public Serializable pkVal() { return this.id; @@ -69,20 +75,21 @@ public class FuzhouHighwayBureau extends Model { public FuzhouHighwayBureau () {} - public FuzhouHighwayBureau (Row row) { + public FuzhouHighwayBureau (Row row, MaterialTask task) { var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK; row.getCell(0, policy).setCellType(CellType.STRING); this.setMaterialId(row.getCell(0, policy).getStringCellValue()); - this.setName(row.getCell(1, policy).getStringCellValue()); - this.setSpec(row.getCell(2, policy).getStringCellValue()); + this.setName(row.getCell(1, policy).getStringCellValue().replace(" ", "")); + this.setSpec(row.getCell(2, policy).getStringCellValue().replace(" ", "")); this.setUnit(row.getCell(3, policy).getStringCellValue()); this.setBrand(row.getCell(4, policy).getStringCellValue()); this.setPrice(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue())); - this.setDate(row.getCell(6, policy).getLocalDateTimeCellValue().toLocalDate()); + this.setDate(LocalDate.of(task.getYear(), task.getMonth(), 1)); // 从任务获取日期 + this.setRegion(MaterialTaskType.getRegion(task.getType())); if (this.getName().isEmpty()) { throw new IllegalArgumentException("名称为空"); } - if (((Integer) this.getPrice().intValue()).equals(0)) { + if (ObjectUtil.isEmpty(this.getPrice())) { throw new IllegalArgumentException("缺少价格"); } } diff --git a/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java b/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java index 8133752..78c781c 100644 --- a/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java +++ b/src/main/java/mjkf/xinke/main/model/db/FuzhouTransportationBureau.java @@ -1,5 +1,6 @@ package mjkf.xinke.main.model.db; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -12,6 +13,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import mjkf.xinke.main.constant.MaterialTaskType; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; @@ -62,6 +64,10 @@ public class FuzhouTransportationBureau extends Model { public LocalMaterial() {} - public LocalMaterial (Row row) { + public LocalMaterial (Row row, MaterialTask data) { var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK; this.setDate(row.getCell(0, policy).getLocalDateTimeCellValue().toLocalDate()); this.setCity(row.getCell(1, policy).getStringCellValue()); diff --git a/src/main/java/mjkf/xinke/main/model/db/SanmingSteel.java b/src/main/java/mjkf/xinke/main/model/db/SanmingSteel.java index c642b17..414fbcf 100644 --- a/src/main/java/mjkf/xinke/main/model/db/SanmingSteel.java +++ b/src/main/java/mjkf/xinke/main/model/db/SanmingSteel.java @@ -65,7 +65,7 @@ public class SanmingSteel extends Model { public SanmingSteel () {} - public SanmingSteel (Row row) { + public SanmingSteel (Row row, MaterialTask data) { var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK; row.getCell(1).setCellType(CellType.STRING); this.setName(row.getCell(0, policy).getStringCellValue()); diff --git a/src/main/java/mjkf/xinke/main/model/db/SteelEntity.java b/src/main/java/mjkf/xinke/main/model/db/SteelEntity.java index 48b1d7c..349b490 100644 --- a/src/main/java/mjkf/xinke/main/model/db/SteelEntity.java +++ b/src/main/java/mjkf/xinke/main/model/db/SteelEntity.java @@ -44,7 +44,7 @@ public class SteelEntity> extends Model { public SteelEntity() {} - public SteelEntity(Row row) { + public SteelEntity(Row row, MaterialTask data) { this.fromRow(row); } } diff --git a/src/main/java/mjkf/xinke/main/model/db/SteelPlate.java b/src/main/java/mjkf/xinke/main/model/db/SteelPlate.java index fcce084..54c5655 100644 --- a/src/main/java/mjkf/xinke/main/model/db/SteelPlate.java +++ b/src/main/java/mjkf/xinke/main/model/db/SteelPlate.java @@ -68,7 +68,7 @@ public class SteelPlate extends SteelEntity { public SteelPlate() {} - public SteelPlate(Row row) { + public SteelPlate(Row row, MaterialTask data) { this.fromRow(row); } diff --git a/src/main/java/mjkf/xinke/main/model/db/SteelRebar.java b/src/main/java/mjkf/xinke/main/model/db/SteelRebar.java index 8048f24..98261b9 100644 --- a/src/main/java/mjkf/xinke/main/model/db/SteelRebar.java +++ b/src/main/java/mjkf/xinke/main/model/db/SteelRebar.java @@ -65,7 +65,7 @@ public class SteelRebar extends SteelEntity { public SteelRebar() {} - public SteelRebar(Row row) { + public SteelRebar(Row row, MaterialTask data) { this.fromRow(row); } diff --git a/src/main/java/mjkf/xinke/main/model/db/SteelSection.java b/src/main/java/mjkf/xinke/main/model/db/SteelSection.java index 1a49037..70369c2 100644 --- a/src/main/java/mjkf/xinke/main/model/db/SteelSection.java +++ b/src/main/java/mjkf/xinke/main/model/db/SteelSection.java @@ -67,7 +67,7 @@ public class SteelSection extends SteelEntity{ public SteelSection() {} - public SteelSection(Row row) { + public SteelSection(Row row, MaterialTask data) { this.fromRow(row); } diff --git a/src/main/java/mjkf/xinke/main/model/db/SteelStrand.java b/src/main/java/mjkf/xinke/main/model/db/SteelStrand.java index 0f808a9..4283a5e 100644 --- a/src/main/java/mjkf/xinke/main/model/db/SteelStrand.java +++ b/src/main/java/mjkf/xinke/main/model/db/SteelStrand.java @@ -68,7 +68,7 @@ public class SteelStrand extends SteelEntity { public SteelStrand() {} - public SteelStrand(Row row) { + public SteelStrand(Row row, MaterialTask data) { this.fromRow(row); } diff --git a/src/main/java/mjkf/xinke/main/service/FujianSurveyService.java b/src/main/java/mjkf/xinke/main/service/FujianSurveyService.java index bb8dd7a..1bddc7f 100644 --- a/src/main/java/mjkf/xinke/main/service/FujianSurveyService.java +++ b/src/main/java/mjkf/xinke/main/service/FujianSurveyService.java @@ -1,6 +1,8 @@ package mjkf.xinke.main.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import mjkf.xinke.main.constant.MaterialTaskType; +import mjkf.xinke.main.model.db.DataNetwork; import mjkf.xinke.main.model.db.FujianSurvey; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Service; @@ -15,6 +17,7 @@ public class FujianSurveyService extends DataService, F query.eq(FujianSurvey::getName, data.getName()); query.eq(FujianSurvey::getSpec, data.getSpec()); query.eq(FujianSurvey::getDate, data.getDate()); + query.eq(FujianSurvey::getRegion, data.getRegion()); return query; } @@ -50,8 +53,10 @@ public class FujianSurveyService extends DataService, F query.like(FujianSurvey::getName, name); } if (materialId != null) { - // todo - // query.eq(SteelSection::getMaterialId, materialId); + query.eq(FujianSurvey::getMaterialId, materialId); + } + if (type != null) { + query.eq(FujianSurvey::getRegion, MaterialTaskType.getRegion(type)); } return query; } diff --git a/src/main/java/mjkf/xinke/main/service/FuzhouHighwayBureauService.java b/src/main/java/mjkf/xinke/main/service/FuzhouHighwayBureauService.java index 5b8c5e0..96f239a 100644 --- a/src/main/java/mjkf/xinke/main/service/FuzhouHighwayBureauService.java +++ b/src/main/java/mjkf/xinke/main/service/FuzhouHighwayBureauService.java @@ -1,6 +1,8 @@ package mjkf.xinke.main.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import mjkf.xinke.main.constant.MaterialTaskType; +import mjkf.xinke.main.model.db.FujianSurvey; import mjkf.xinke.main.model.db.FuzhouHighwayBureau; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Service; @@ -16,6 +18,7 @@ public class FuzhouHighwayBureauService extends DataService, M @Resource DevFileService devFileService; @Resource - SteelRebarService steelRebarService; - @Resource - SteelSectionService steelSectionService; - @Resource - SteelStrandService steelStrandService; - @Resource - SteelPlateService steelPlateService; - @Resource - AsphaltDomesticService asphaltDomesticService; - @Resource - AsphaltImportedService asphaltImportedService; - @Resource - CementService cementService; - @Resource SanmingSteelService sanmingSteelService; @Resource FuzhouTransportationBureauService fuzhouTransportationBureauService; @@ -89,34 +75,20 @@ public class MaterialTaskService extends ServiceImpl, M List rows = this.getTableRows(file); // 导入 List list; - if (data.getType().equals(MaterialTaskType.MY_STEEL_REBAR)) { - list = steelRebarService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.MY_STEEL_SECTION)) { - list = steelSectionService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.MY_STEEL_STRAND)) { - list = steelStrandService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.MY_STEEL_PLATE)) { - list = steelPlateService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.BAIINFO_ASPHALT_DOMESTIC)) { - list = asphaltDomesticService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.BAIINFO_ASPHALT_IMPORTED)) { - list = asphaltImportedService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.BAIINFO_CEMENT)) { - list = cementService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.SANMING_STEEL)) { + if (data.getType().equals(MaterialTaskType.SANMING_STEEL)) { list = sanmingSteelService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.FUZHOU_TRANSPORTATION_BUREAU)) { - list = fuzhouTransportationBureauService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.FUZHOU_HIGHWAY_BUREAU)) { - list = fuzhouHighwayBureauService.saveOrUpdateByIndexBatch(rows, data); - } else if (data.getType().equals(MaterialTaskType.FUZHOU_SURVEY)) { - list = fujianSurveyService.saveOrUpdateByIndexBatch(rows, data); - } else if (MaterialTaskType.isLocalMaterial(data.getType())) { + }else if (MaterialTaskType.isLocalMaterial(data.getType())) { list = localMaterialService.saveOrUpdateByIndexBatch(rows, data); } else if (data.getType().equals(MaterialTaskType.ASPHALT_MODIFIER)) { list = asphaltModifierService.saveOrUpdateByIndexBatch(rows, data); } else if (MaterialTaskType.isNetworkPrice(data.getType())) { list = dataNetworkService.saveOrUpdateByIndexBatch(rows, data); + } else if (MaterialTaskType.isSurvey(data.getType())) { + list = fujianSurveyService.saveOrUpdateByIndexBatch(rows, data); + } else if (MaterialTaskType.isTransportationBureau(data.getType())) { + list = fuzhouTransportationBureauService.saveOrUpdateByIndexBatch(rows, data); + } else if (MaterialTaskType.isHighwayBureau(data.getType())) { + list = fuzhouHighwayBureauService.saveOrUpdateByIndexBatch(rows, data); } else { System.out.println("MaterialTaskService.importData | 未识别的任务类型"); // todo-3 异常处理:未识别的类型 diff --git a/src/main/resources/_sql/init/mysql/v0.1.sql b/src/main/resources/_sql/init/mysql/v0.1.sql index d8b8b0a..0dad685 100644 --- a/src/main/resources/_sql/init/mysql/v0.1.sql +++ b/src/main/resources/_sql/init/mysql/v0.1.sql @@ -15,4 +15,15 @@ create table DATA_NETWORK ( DATE date null comment '日期' ) comment '网络价格'; -ALTER TABLE DATA_NETWORK ADD REGION varchar(64) NULL COMMENT '地区'; \ No newline at end of file +ALTER TABLE DATA_NETWORK ADD REGION varchar(64) NULL COMMENT '地区'; +ALTER TABLE FUJIAN_SURVEY ADD REGION varchar(64) NULL COMMENT '地区'; + +ALTER TABLE FUZHOU_HIGHWAY_BUREAU ADD REGION varchar(64) NULL COMMENT '地区'; +ALTER TABLE FUZHOU_TRANSPORTATION_BUREAU ADD REGION varchar(64) NULL COMMENT '地区'; + +DROP INDEX Idx_key ON FUJIAN_SURVEY; +CREATE UNIQUE INDEX Idx_key ON FUJIAN_SURVEY (NAME, SPEC, DATE, REGION); +DROP INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU; +CREATE UNIQUE INDEX Idx_key ON FUZHOU_HIGHWAY_BUREAU (NAME, SPEC, DATE, REGION); +DROP INDEX Idx_key ON FUZHOU_TRANSPORTATION_BUREAU; +CREATE UNIQUE INDEX Idx_key ON FUZHOU_TRANSPORTATION_BUREAU (NAME, SPEC, DATE, REGION); \ No newline at end of file diff --git a/src/test/java/mjkf/xinke/UploadFileTest.java b/src/test/java/mjkf/xinke/UploadFileTest.java index 0c90379..08ea1ae 100644 --- a/src/test/java/mjkf/xinke/UploadFileTest.java +++ b/src/test/java/mjkf/xinke/UploadFileTest.java @@ -1,6 +1,5 @@ package mjkf.xinke; -import cn.hutool.core.util.ZipUtil; import mjkf.xinke.dev.modular.file.enums.DevFileEngineTypeEnum; import mjkf.xinke.dev.modular.file.service.DevFileService; import org.junit.Test; @@ -14,7 +13,6 @@ import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.text.MessageFormat; @SpringBootTest(classes = Application.class) @RunWith(SpringJUnit4ClassRunner.class) @@ -24,13 +22,20 @@ public class UploadFileTest { @Test public void test() throws Exception { - var filePath = "C:\\Users\\Administrator\\Desktop\\材料管理系统模版\\主材\\网络价格.xlsx"; + var filePath = "C:\\Users\\Administrator\\Desktop\\材料管理系统模版\\主材\\交通局.xlsx"; var file = new File(filePath); var multipartFile = this.mockMultipartFile(file, "网络价格.xlsx", "application/x-zip-compressed"); var fileId = devFileService.uploadReturnId(DevFileEngineTypeEnum.LOCAL.getValue(), multipartFile); System.out.println("UploadFileTest.test | fileId " + fileId); } + /** + * 1810213380969066497 网络价格.xlsx 1201 + * 1810481654990442497 调查表.xlsx 501 + * 1810481965629005826 公路局.xlsx 40201 + * 1810482216079302658 交通局.xlsx 40101 + */ + private MultipartFile mockMultipartFile(File file, String fileName, String contentType) { try { // 使用文件内容和文件名创建MockMultipartFile