fix: 变更新增材料逻辑

This commit is contained in:
han0
2024-09-09 09:24:48 +08:00
parent f6cdb1b44d
commit a6f795a23d
19 changed files with 63 additions and 68 deletions

View File

@@ -23,6 +23,7 @@ public enum HttpErrorResponseEnum implements NcHttpErrorResponseInterface {
MATERIAL_PARENT_ID_INVALID("材料 parent_id 无效", 1005, HttpStatus.SC_NOT_FOUND), MATERIAL_PARENT_ID_INVALID("材料 parent_id 无效", 1005, HttpStatus.SC_NOT_FOUND),
MATERIAL_TASK_NOT_FOUND("找不到指定材料采集任务", 1006, HttpStatus.SC_NOT_FOUND), MATERIAL_TASK_NOT_FOUND("找不到指定材料采集任务", 1006, HttpStatus.SC_NOT_FOUND),
MATERIAL_RESULT_NOT_FOUND("找不到指定材料采集结果", 1007, HttpStatus.SC_NOT_FOUND), MATERIAL_RESULT_NOT_FOUND("找不到指定材料采集结果", 1007, HttpStatus.SC_NOT_FOUND),
MATERIAL_CATEGORY_INVALID("材料分类无效", 1007, HttpStatus.SC_NOT_FOUND),
PRICE_RESULT_YEAR_MONTH_NEEDED("缺少年份或月份", 1101, HttpStatus.SC_NOT_FOUND), PRICE_RESULT_YEAR_MONTH_NEEDED("缺少年份或月份", 1101, HttpStatus.SC_NOT_FOUND),
PRICE_RESULT_NOT_FOUND("未找到对应数据", 1102, HttpStatus.SC_NOT_FOUND), PRICE_RESULT_NOT_FOUND("未找到对应数据", 1102, HttpStatus.SC_NOT_FOUND),

View File

@@ -154,5 +154,14 @@ public class BudgetController {
return FuHttpResponse.Builder().dataResponse(budgetItemList).build(); return FuHttpResponse.Builder().dataResponse(budgetItemList).build();
} }
// todo-2 在价格发布创建时补全材料id // todo-1 新增材料 编码替换
// todo-1 发布编码替换
// todo-1 公众网站数据
// todo-1 公众网站历史数据
// todo-1 料场位置管理
// todo-1 地图里程数据
// todo-1 价格权重调整
// todo-1 外省数据上传
// todo-1 外省数据价格对比
// todo-1 趋势表加入调查表数据
} }

View File

@@ -38,6 +38,7 @@ public class MaterialController {
@Resource @Resource
MaterialService materialService; MaterialService materialService;
@Deprecated
@ApiOperation("获取材料树") @ApiOperation("获取材料树")
@GetMapping("/tree") @GetMapping("/tree")
public HttpResponse getTree ( public HttpResponse getTree (
@@ -66,21 +67,16 @@ public class MaterialController {
@ApiOperation("获取材料列表") @ApiOperation("获取材料列表")
@GetMapping("/") @GetMapping("/")
public HttpResponse list ( public HttpResponse list (
@ApiParam(value = "关键字") @RequestParam(value="key_word", required=false) String keyWord, @ApiParam(value = "关键字") @RequestParam(value="key_word", required=false) String keyWord
@ApiParam(value = "父节点id") @RequestParam("parent_id") String parentId // @ApiParam(value = "父节点id") @RequestParam("parent_id") String parentId
) { ) {
LambdaQueryWrapper<Material> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Material> query = new LambdaQueryWrapper<>();
query.eq(Material::getIsTree, 0); // query.eq(Material::getIsTree, 0);
if (parentId != null) { // if (parentId != null) {
query.eq(Material::getParentId, parentId); // query.eq(Material::getParentId, parentId);
} // }
if (keyWord != null && ObjectUtil.isNotEmpty(keyWord)) { if (keyWord != null && ObjectUtil.isNotEmpty(keyWord)) {
query.and(q -> q query.like(Material::getName, keyWord);
.like(Material::getCategory1, keyWord).or()
.like(Material::getCategory2, keyWord).or()
.like(Material::getCategory3, keyWord).or()
.like(Material::getCategory4, keyWord)
);
} }
var result = materialService.list(query); var result = materialService.list(query);
@@ -114,7 +110,8 @@ public class MaterialController {
params.check(); params.check();
var user = StpLoginUserUtil.getLoginUser(); var user = StpLoginUserUtil.getLoginUser();
var data = materialService.getById(params.getId()); var id = params.buildId();
var data = materialService.getById(id);
if (data != null) { if (data != null) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_ID_REPEAT); throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_ID_REPEAT);
} }
@@ -145,6 +142,7 @@ public class MaterialController {
return FuHttpResponse.Builder().dataResponse(data).build(); return FuHttpResponse.Builder().dataResponse(data).build();
} }
@Deprecated
@ApiOperation("生成编号") @ApiOperation("生成编号")
@PostMapping("/id") @PostMapping("/id")
public HttpResponse createId ( public HttpResponse createId (

View File

@@ -138,18 +138,16 @@ public class Material extends Model<Material> {
public Material() {} public Material() {}
public Material(MaterialCreateRequest params, SaBaseLoginUser user) { public Material(MaterialCreateRequest params, SaBaseLoginUser user) {
this.id = params.getId(); this.id = params.buildId();
this.parentId = params.getParentId(); this.category1 = params.getCategory1();
// this.category1 = params.getCategory1(); this.category2 = params.getCategory2();
// this.category2 = params.getCategory2(); this.category3 = params.getCategory3();
// this.category3 = params.getCategory3(); this.category4 = params.getCategory4();
// this.category4 = params.getCategory4();
this.name = params.getName(); this.name = params.getName();
this.unit = params.getUnit(); this.unit = params.getUnit();
this.spec = params.getSpec(); this.spec = params.getSpec();
this.tax = params.getTax(); this.tax = params.getTax();
this.type = params.getType(); this.type = params.getType();
this.isTree = params.getIsTree();
this.updateTime = LocalDateTime.now(); this.updateTime = LocalDateTime.now();
this.createTime = LocalDateTime.now(); this.createTime = LocalDateTime.now();
this.createUserName = user.getName(); this.createUserName = user.getName();

View File

@@ -1,8 +1,6 @@
package mjkf.xinke.main.model.vo; package mjkf.xinke.main.model.vo;
import com.baomidou.mybatisplus.annotation.IdType; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.jgy.xxs.core.http.exp.NcHttpException; import com.jgy.xxs.core.http.exp.NcHttpException;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -11,24 +9,17 @@ import mjkf.xinke.main.constant.HttpErrorResponseEnum;
@Data @Data
public class MaterialCreateRequest { public class MaterialCreateRequest {
@TableId(value = "ID", type = IdType.AUTO) @ApiModelProperty("分类1")
private String id; private String category1;
@ApiModelProperty("父级id") @ApiModelProperty("分类2")
@JsonProperty(value = "parent_id") private String category2;
private String parentId;
// @ApiModelProperty("分类1") @ApiModelProperty("分类3")
// private String category1; private String category3;
//
// @ApiModelProperty("分类2") @ApiModelProperty("分类4")
// private String category2; private String category4;
//
// @ApiModelProperty("分类3")
// private String category3;
//
// @ApiModelProperty("分类4")
// private String category4;
@ApiModelProperty("名称") @ApiModelProperty("名称")
private String name; private String name;
@@ -45,24 +36,36 @@ public class MaterialCreateRequest {
@ApiModelProperty("类型") @ApiModelProperty("类型")
private Integer type; private Integer type;
@ApiModelProperty("是否树") public void check() throws Exception {
@JsonProperty(value = "is_tree") if (ObjectUtil.isEmpty(category1) || category1.chars().count() != 2) {
private Integer isTree; throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
public void check() throws Exception{
String flag = this.parentId.replace(".00", "");
if (!this.id.contains(flag)) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_ID_INVALID);
} }
if ((int) this.id.chars().filter(c -> c == '.').count() != 3) { if (ObjectUtil.isEmpty(category2) || category2.chars().count() != 2) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_ID_INVALID); throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
} }
if ((int) this.parentId.chars().filter(c -> c == '.').count() != 3) { if (ObjectUtil.isEmpty(category3) || category3.chars().count() != 3) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_PARENT_ID_INVALID); throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
} }
if (this.parentId.chars().filter(c -> c == '0').count() < this.id.chars().filter(c -> c == '0').count()) { if (ObjectUtil.isNotEmpty(category4) && category4.chars().count() != 3) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_ID_INVALID); throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
}
if (ObjectUtil.isEmpty(spec)) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
}
if (ObjectUtil.isEmpty(tax)) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
}
if (ObjectUtil.isEmpty(type)) {
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
} }
} }
public String buildId() {
var id = category1 + category2 + category3;
if (ObjectUtil.isNotEmpty(category4)) {
id = id + category4;
}
return id;
}
} }

View File

@@ -50,7 +50,6 @@ public class AsphaltDomesticService extends DataService<BaseMapper<AsphaltDomest
query.like(AsphaltDomestic::getName, name); query.like(AsphaltDomestic::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -50,7 +50,6 @@ public class AsphaltImportedService extends DataService<BaseMapper<AsphaltImport
query.like(AsphaltImported::getName, name); query.like(AsphaltImported::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -59,7 +59,6 @@ public class CementService extends DataService<BaseMapper<Cement>, Cement> {
query.like(Cement::getName, name); query.like(Cement::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -27,7 +27,6 @@ public class DataFujianService extends DataService<BaseMapper<DataFujian>, DataF
query.like(DataFujian::getName, name); query.like(DataFujian::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -28,7 +28,6 @@ public class DataGuangdongService extends DataService<BaseMapper<DataGuangdong>,
query.like(DataGuangdong::getName, name); query.like(DataGuangdong::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -108,7 +108,6 @@ public abstract class DataService<M extends BaseMapper<T>, T> extends ServiceImp
List group = groupMap.get(groupKey); List group = groupMap.get(groupKey);
result.add(this.statisticItemFromGroup(group)); result.add(this.statisticItemFromGroup(group));
} }
// todo 排序
return result; return result;
} }

View File

@@ -30,7 +30,6 @@ public class DataZhejiangService extends DataService<BaseMapper<DataZhejiang>,
query.like(DataZhejiang::getName, name); query.like(DataZhejiang::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -91,7 +91,6 @@ public class MaterialTaskService extends ServiceImpl<BaseMapper<MaterialTask>, M
list = fuzhouHighwayBureauService.saveOrUpdateByIndexBatch(rows, data); list = fuzhouHighwayBureauService.saveOrUpdateByIndexBatch(rows, data);
} else { } else {
System.out.println("MaterialTaskService.importData | 未识别的任务类型"); System.out.println("MaterialTaskService.importData | 未识别的任务类型");
// todo-3 异常处理:未识别的类型
return false; return false;
} }
// 保存数据副本 // 保存数据副本

View File

@@ -47,7 +47,6 @@ public class OilService extends DataService<BaseMapper<Oil>, Oil> {
query.like(Oil::getName, name); query.like(Oil::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -54,7 +54,6 @@ public class SanmingSteelService extends DataService<BaseMapper<SanmingSteel>, S
query.like(SanmingSteel::getName, name); query.like(SanmingSteel::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -63,7 +63,6 @@ public class SteelPlateService extends DataService<BaseMapper<SteelPlate>, Steel
query.like(SteelPlate::getName, name); query.like(SteelPlate::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -59,7 +59,6 @@ public class SteelRebarService extends DataService<BaseMapper<SteelRebar>, Steel
query.like(SteelRebar::getName, name); query.like(SteelRebar::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelRebar::getMaterialId, materialId); // query.eq(SteelRebar::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -60,7 +60,6 @@ public class SteelSectionService extends DataService<BaseMapper<SteelSection>, S
query.like(SteelSection::getName, name); query.like(SteelSection::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;

View File

@@ -60,7 +60,6 @@ public class SteelStrandService extends DataService<BaseMapper<SteelStrand>, Ste
query.like(SteelStrand::getName, name); query.like(SteelStrand::getName, name);
} }
if (materialId != null) { if (materialId != null) {
// todo
// query.eq(SteelSection::getMaterialId, materialId); // query.eq(SteelSection::getMaterialId, materialId);
} }
return query; return query;