feat: 电气专用bom功能

This commit is contained in:
曹鹏飞 2024-04-21 10:45:33 +08:00
parent d4075470f6
commit 140d1b80e9
15 changed files with 506 additions and 108 deletions

View File

@ -7,6 +7,7 @@ import com.mzt.logapi.starter.annotation.LogRecord;
import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery; import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery;
import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery; import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery;
import com.nflg.product.bomnew.pojo.vo.BomDQbomEditDetailVO;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO; import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO; import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO; import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
@ -84,7 +85,7 @@ public class DQBomApi extends BaseApi {
@PostMapping("importBomSave") @PostMapping("importBomSave")
@LogRecord(success = "电气BOM-确认导入,操作结果:{{#_ret}}", bizNo = "", type = "电气BOM导入") @LogRecord(success = "电气BOM-确认导入,操作结果:{{#_ret}}", bizNo = "", type = "电气BOM导入")
public ResultVO importBomSave() { public ResultVO importBomSave() {
dqBomImportService.save(); dQBomService.checkException(dqBomImportService.save());
return ResultVO.success(); return ResultVO.success();
} }
@ -115,7 +116,7 @@ public class DQBomApi extends BaseApi {
* @param query 保存的数据 * @param query 保存的数据
* @return * @return
*/ */
@GetMapping("temporary") @PostMapping("temporary")
@ApiOperation("暂存") @ApiOperation("暂存")
public ResultVO<String> temporary(@Valid @RequestBody @NotNull BomNewDQbomSaveQuery query) { public ResultVO<String> temporary(@Valid @RequestBody @NotNull BomNewDQbomSaveQuery query) {
dQBomService.save(query); dQBomService.save(query);
@ -140,7 +141,7 @@ public class DQBomApi extends BaseApi {
* @return * @return
*/ */
@PostMapping("deleteBom") @PostMapping("deleteBom")
@ApiOperation("批量删除") @ApiOperation("删除bom")
public ResultVO<String> deleteBom(@Valid @RequestBody @NotNull Long rowId) { public ResultVO<String> deleteBom(@Valid @RequestBody @NotNull Long rowId) {
dQBomService.deleteBom(rowId); dQBomService.deleteBom(rowId);
return ResultVO.success(); return ResultVO.success();
@ -178,8 +179,8 @@ public class DQBomApi extends BaseApi {
*/ */
@PostMapping("submit") @PostMapping("submit")
@ApiOperation("提交") @ApiOperation("提交")
public ResultVO submit(@Valid @RequestBody @NotNull Long bomRowId) { public ResultVO submit(@Valid @RequestBody @NotNull BomNewDQbomSaveQuery query) {
dQBomService.submit(bomRowId); dQBomService.submit(query);
return ResultVO.success(); return ResultVO.success();
} }
@ -206,4 +207,16 @@ public class DQBomApi extends BaseApi {
dQBomService.importToSAP(rootBomRowId); dQBomService.importToSAP(rootBomRowId);
return ResultVO.success(); return ResultVO.success();
} }
/**
* 编辑物料列表
* @param rowId rowId
* @param bomRowId bom的rowId
* @return
*/
@GetMapping("editDetail")
@ApiOperation("编辑物料列表")
public ResultVO<BomDQbomEditDetailVO> editDetail(@Valid @RequestParam("rowId") @NotNull Long rowId, @Valid @RequestParam("bomRowId") @NotNull Long bomRowId) {
return ResultVO.success(dQBomService.editDetail(rowId, bomRowId));
}
} }

View File

@ -9,4 +9,6 @@ public class BomConstant {
public static final String SAP_YDBOM="1"; public static final String SAP_YDBOM="1";
public static final String MATERIAL_NO_TEMPORARY_PREFIX = "TN";
public static final String DRAWING_NO_TEMPORARY_PREFIX = "TD";
} }

View File

@ -20,8 +20,17 @@ public enum EBomExceptionStatusEnum implements ValueEnum<Integer> {
//11=未填写变更原因和技术通知单 //11=未填写变更原因和技术通知单
//12=数量需要用户确认 //12=数量需要用户确认
//13=项目类型需要用户确认 //13=项目类型需要用户确认
/*
* 初始状态
*/
INIT(-1, ""), INIT(-1, ""),
/*
* 正常
*/
OK(1, "正常"), OK(1, "正常"),
/*
* 冻结/完全弃用异常(物料的状态冻结或者完全弃用)
*/
EXCEPT_NO_2(2, "冻结/完全弃用异常(物料的状态冻结或者完全弃用)"), EXCEPT_NO_2(2, "冻结/完全弃用异常(物料的状态冻结或者完全弃用)"),
EXCEPT_NO_3(3, "递归异常(出现子级包含父级的异常情况)"), EXCEPT_NO_3(3, "递归异常(出现子级包含父级的异常情况)"),
EXCEPT_NO_4(4, "数据不完整异常(物料编号或数量没有填写)"), EXCEPT_NO_4(4, "数据不完整异常(物料编号或数量没有填写)"),

View File

@ -23,4 +23,8 @@ public interface BomNewDQbomParentMapper extends BaseMapper<BomNewDQbomParentEnt
BomNewDQbomVO getRootBomByRowId(Long rootBomRowId); BomNewDQbomVO getRootBomByRowId(Long rootBomRowId);
List<BomNewDQbomVO> getChildren(Long bomRowId); List<BomNewDQbomVO> getChildren(Long bomRowId);
List<BomNewDQbomVO> getBom(String materialNo, String drawingNo, String materialName);
List<BomNewDQbomVO> getVOById(Long parentRowId);
} }

View File

@ -121,6 +121,20 @@ public class BomNewDQbomChildEntity implements Serializable {
@ApiModelProperty(value = "总重") @ApiModelProperty(value = "总重")
private BigDecimal totalWeight; private BigDecimal totalWeight;
/**
* 处理状态1=待处理2=已处理
*/
@TableField(value = "edit_status")
@ApiModelProperty(value = "处理状态")
private Integer editStatus = 1;
/**
* 转换状态1=待转换2=已转换已发布PBOM
*/
@TableField(value = "status")
@ApiModelProperty(value = "转换状态")
private Integer status = 1;
/** /**
* 异常状态 * 异常状态
* @see com.nflg.product.bomnew.constant.EBomExceptionStatusEnum * @see com.nflg.product.bomnew.constant.EBomExceptionStatusEnum
@ -177,4 +191,11 @@ public class BomNewDQbomChildEntity implements Serializable {
@TableField(value = "modify_time") @TableField(value = "modify_time")
@ApiModelProperty(value = "修改时间") @ApiModelProperty(value = "修改时间")
private LocalDateTime modifyTime; private LocalDateTime modifyTime;
/**
* 来源 1-EXCE导入 2-MDM创建
*/
@TableField(value = "source")
@ApiModelProperty(value = "来源")
private Integer source;
} }

View File

@ -79,6 +79,20 @@ public class BomNewDQbomParentEntity implements Serializable {
@ApiModelProperty(value = "单重") @ApiModelProperty(value = "单重")
private BigDecimal unitWeight; private BigDecimal unitWeight;
/**
* 数量
*/
@TableField(value = "num")
@ApiModelProperty(value = "数量")
private BigDecimal num;
/**
* 总重
*/
@TableField(value = "total_weight")
@ApiModelProperty(value = "总重")
private BigDecimal totalWeight;
/** /**
* 版本号 * 版本号
*/ */
@ -86,6 +100,13 @@ public class BomNewDQbomParentEntity implements Serializable {
@ApiModelProperty(value = "版本号") @ApiModelProperty(value = "版本号")
private String currentVersion; private String currentVersion;
/**
* 项目类别
*/
@TableField(value = "project_type")
@ApiModelProperty(value = "项目类别")
private String projectType;
/** /**
* 是否跟节点 0- 1- * 是否跟节点 0- 1-
*/ */
@ -156,6 +177,21 @@ public class BomNewDQbomParentEntity implements Serializable {
@ApiModelProperty(value = "创建人员所属岗位") @ApiModelProperty(value = "创建人员所属岗位")
private Integer createdJob; private Integer createdJob;
/**
* 异常状态
* @see com.nflg.product.bomnew.constant.EBomExceptionStatusEnum
*/
@TableField(value = "exception_status")
@ApiModelProperty(value = "异常状态")
private Integer exceptionStatus = -1;
/**
* 异常标记
*/
@TableField(value = "exception_tag")
@ApiModelProperty(value = "异常标记")
private String exceptionTag;
/** /**
* 版本过期时间(下个版本的创建时间) * 版本过期时间(下个版本的创建时间)
*/ */
@ -197,4 +233,11 @@ public class BomNewDQbomParentEntity implements Serializable {
@TableField(value = "sap_time") @TableField(value = "sap_time")
@ApiModelProperty(value = "导入SAP时间") @ApiModelProperty(value = "导入SAP时间")
private LocalDateTime sapTime; private LocalDateTime sapTime;
/**
* 备注
*/
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
private String remark;
} }

View File

@ -0,0 +1,24 @@
package com.nflg.product.bomnew.pojo.vo;
/**
* @author 曹鹏飞
* @date 2024/4/19 10:55:57
*/
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@Accessors(chain = true)
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-vo-BomDQbomEditDetailVO")
public class BomDQbomEditDetailVO implements Serializable {
private BomNewDQbomVO parent;
private List<BomNewDQbomVO> datas = new ArrayList<>();
}

View File

@ -1,5 +1,6 @@
package com.nflg.product.bomnew.pojo.vo; package com.nflg.product.bomnew.pojo.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -7,6 +8,7 @@ import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* @author 曹鹏飞 * @author 曹鹏飞
@ -47,8 +49,35 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
@ApiModelProperty(value = "物料状态") @ApiModelProperty(value = "物料状态")
private Integer systemMaterialState; private Integer systemMaterialState;
/**
* 是否跟节点 0- 1-
*/
@TableField(value = "root_is")
@ApiModelProperty(value = "是否跟节点")
private Integer rootIs;
/**
* 子级bom
*/
@ApiModelProperty(value = "子级bom")
private List<BomNewDQbomVO> childNodes;
/** /**
* 父级物料编码 * 父级物料编码
*/ */
private String parentMaterialNo; private String parentMaterialNo;
/**
* 是否有子节点: 0- 1-
*/
@TableField(value = "bom_exist")
@ApiModelProperty(value = "是否有子节点")
private Integer bomExist;
/**
* 是否最新版0- 1-
*/
@TableField(value = "last_version_is")
@ApiModelProperty(value = "是否最新版")
private Integer lastVersionIs = 1;
} }

View File

@ -3,6 +3,7 @@ package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.nflg.product.bomnew.constant.BomConstant;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum; import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.MaterialGetEnum; import com.nflg.product.bomnew.constant.MaterialGetEnum;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
@ -10,60 +11,58 @@ import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/**
* @author 曹鹏飞
* @date 2024/4/11 15:30:16
*/
@Service
@Slf4j @Slf4j
public class BomNewDQbomExceptionCheckService { public class BomNewDQbomExceptionCheckService {
@Resource
MaterialMainService materialMainService; MaterialMainService materialMainService;
@Resource
DQBomParentService dQBomParentService; DQBomParentService dQBomParentService;
@Resource
DQBomChildService dQBomChildService; DQBomChildService dQBomChildService;
private List<BomNewDQbomParentEntity> parents = new ArrayList<>(); private List<BomNewDQbomParentEntity> parents = new ArrayList<>();
private List<BomNewDQbomChildEntity> children = new ArrayList<>(); private List<BomNewDQbomChildEntity> children = new ArrayList<>();
private List<BaseMaterialVO> materialVOS; private List<BaseMaterialVO> materialVOS = new ArrayList<>();
public void check(Long parentRowId) { public BomNewDQbomExceptionCheckService(DQBomParentService dQBomParentService, DQBomChildService dQBomChildService, MaterialMainService materialMainService) {
VUtils.isTure(ObjectUtil.isNull(parentRowId) || parentRowId == 0L).throwMessage("无效的参数:" + parentRowId); this.dQBomParentService = dQBomParentService;
this.dQBomChildService = dQBomChildService;
this.materialMainService = materialMainService;
}
public void check(Long bomRowId) {
VUtils.isTure(ObjectUtil.isNull(bomRowId) || bomRowId == 0L).throwMessage("无效的参数:" + bomRowId);
parents.clear(); parents.clear();
children.clear(); children.clear();
BomNewDQbomParentEntity parent = dQBomParentService.getById(parentRowId); BomNewDQbomParentEntity parent = dQBomParentService.getById(bomRowId);
VUtils.isTure(ObjectUtil.isNull(parent)).throwMessage("未找到数据:" + parentRowId); VUtils.isTure(ObjectUtil.isNull(parent)).throwMessage("未找到数据:" + bomRowId);
parents.add(parent);
buildData(parent); buildData(parent);
check(); check();
} }
private void buildData(BomNewDQbomParentEntity parent) { private void buildData(BomNewDQbomParentEntity parent) {
parents.add(parent);
BomNewDQbomChildEntity child = dQBomChildService.getRoot(parent.getMaterialNo());
children.add(child);
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId()); List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
if (CollUtil.isNotEmpty(cc)) { if (CollUtil.isNotEmpty(cc)) {
children.addAll(cc); children.addAll(cc);
List<BomNewDQbomParentEntity> pp = dQBomParentService.getLatestByMaterialNo(cc.stream() List<BomNewDQbomParentEntity> pp = dQBomParentService.getLatestByMaterialNo(cc.stream()
.map(BomNewDQbomChildEntity::getMaterialNo) .map(BomNewDQbomChildEntity::getMaterialNo)
.collect(Collectors.toList())); .collect(Collectors.toList()));
pp.removeIf(p -> p.getRootIs() == 1 || p.getUserRootIs() == 1
|| parents.stream().anyMatch(pi -> StrUtil.equals(pi.getMaterialNo(), p.getMaterialNo())));
parents.addAll(pp); parents.addAll(pp);
pp.forEach(this::buildData); pp.forEach(this::buildData);
} }
@ -78,48 +77,111 @@ public class BomNewDQbomExceptionCheckService {
private void check() { private void check() {
List<String> materialNos = children.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList()); List<String> materialNos = children.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList());
materialVOS = materialMainService.getMaterialBaseInfo(materialNos); materialNos.add(parents.get(0).getMaterialNo());
check(children.get(0)); materialNos = materialNos.stream().filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
materialVOS = materialMainService.getMaterialBaseInfo(materialNos);
}
children.forEach(this::checkChild);
parents.forEach(this::checkParent);
checkTree(parents.get(0));
save();
} }
private EBomExceptionStatusEnum check(BomNewDQbomChildEntity child) { @Transactional(rollbackFor = Exception.class)
BomNewDQbomParentEntity parent = parents.stream().filter(p -> p.getMaterialNo().equals(child.getMaterialNo())) public void save() {
.findFirst() if (CollUtil.isNotEmpty(parents)) {
.orElse(null); dQBomParentService.updateBatchById(parents);
VUtils.isTure(ObjectUtil.isNull(parent)).throwMessage(StrUtil.format("编号为{}的数据不完整", child.getMaterialNo())); }
if (CollUtil.isNotEmpty(children)) {
dQBomChildService.updateBatchById(children);
}
}
private boolean checkTree(BomNewDQbomParentEntity parent) {
List<BomNewDQbomChildEntity> cc = children.stream()
.filter(c -> Objects.equals(c.getParentRowId(), parent.getRowId()))
.collect(Collectors.toList());
Set<String> cm = cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).distinct().collect(Collectors.toSet());
List<BomNewDQbomParentEntity> pp = parents.stream().filter(p -> cm.contains(p.getMaterialNo())).collect(Collectors.toList());
boolean hasError;
if (CollUtil.isEmpty(pp)) {
hasError = cc.stream().anyMatch(c -> !Objects.equals(c.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue()));
} else {
hasError = pp.stream().anyMatch(this::checkTree);
}
if (Objects.equals(parent.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue()) && hasError) {
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}
return !Objects.equals(parent.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue());
}
private void checkParent(BomNewDQbomParentEntity parent) {
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK; EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
assert parent != null; if ("T".equals(parent.getProjectType())) {
if ("T".equals(child.getProjectType())) { parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); } else if (parent.getMaterialNo().startsWith(BomConstant.MATERIAL_NO_TEMPORARY_PREFIX)) {
} else if (child.getMaterialNo().startsWith("M")) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4; status = EBomExceptionStatusEnum.EXCEPT_NO_4;
} else { } else {
BaseMaterialVO materialVO = materialVOS.stream().filter(v -> v.getMaterialNo().equals(child.getMaterialNo())).findFirst().orElse(null); BaseMaterialVO materialVO = materialVOS.stream().filter(v -> v.getMaterialNo().equals(parent.getMaterialNo()))
.findFirst()
.orElse(null);
if (materialVO == null) { if (materialVO == null) {
status = EBomExceptionStatusEnum.EXCEPT_NO_7; status = EBomExceptionStatusEnum.EXCEPT_NO_7;
} else if (materialVO.getMaterialState().equals(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())) { } else if (materialVO.getMaterialState().equals(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_2; status = EBomExceptionStatusEnum.EXCEPT_NO_2;
} else if (!materialVO.getMaterialName().equals(parent.getMaterialName())) { } else if (!materialVO.getMaterialName().equals(parent.getMaterialName())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_15; status = EBomExceptionStatusEnum.EXCEPT_NO_15;
} else if (Objects.isNull(child.getNum()) || child.getNum().equals(BigDecimal.ZERO)) { } else if (Objects.isNull(parent.getNum()) || parent.getNum().equals(BigDecimal.ZERO)) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4; status = EBomExceptionStatusEnum.EXCEPT_NO_4;
} else if (Objects.equals(materialVO.getMaterialUnit(), parent.getMaterialUnit())) { } else if (!Objects.equals(materialVO.getMaterialUnit(), parent.getMaterialUnit())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_16; status = EBomExceptionStatusEnum.EXCEPT_NO_16;
} }
} }
//检查下级节点 //检查下级节点
List<BomNewDQbomChildEntity> cc = children.stream().filter(c -> c.getParentRowId().equals(parent.getRowId())) boolean hasError = children.stream().anyMatch(c -> c.getParentRowId().equals(parent.getRowId())
.collect(Collectors.toList()); && !Objects.equals(c.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue()));
boolean hasError = cc.stream().map(this::check)
.collect(Collectors.toList())
.stream().anyMatch(e -> !e.equals(EBomExceptionStatusEnum.OK));
if (status == EBomExceptionStatusEnum.OK && hasError) { if (status == EBomExceptionStatusEnum.OK && hasError) {
status = EBomExceptionStatusEnum.EXCEPT_NO_14; status = EBomExceptionStatusEnum.EXCEPT_NO_14;
} }
parent.setExceptionStatus(status.getValue());
}
// private boolean checkChildren() {
// return children.stream().map(this::checkChild)
// .collect(Collectors.toList())
// .stream().anyMatch(e -> e);
// }
private void checkChild(BomNewDQbomChildEntity child) {
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
if ("T".equals(child.getProjectType())) {
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
} else if (child.getMaterialNo().startsWith(BomConstant.MATERIAL_NO_TEMPORARY_PREFIX)) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
} else {
BaseMaterialVO materialVO = materialVOS.stream().filter(v -> v.getMaterialNo().equals(child.getMaterialNo()))
.findFirst()
.orElse(null);
if (materialVO == null) {
status = EBomExceptionStatusEnum.EXCEPT_NO_7;
} else if (materialVO.getMaterialState().equals(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_2;
} else if (!materialVO.getMaterialName().equals(child.getMaterialName())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_15;
} else if (Objects.isNull(child.getNum()) || child.getNum().equals(BigDecimal.ZERO)) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
} else if (!Objects.equals(materialVO.getMaterialUnit(), child.getMaterialUnit())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_16;
}
}
child.setExceptionStatus(status.getValue()); child.setExceptionStatus(status.getValue());
return status;
} }
} }

View File

@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.BomConstant;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.OriginalConstant;
import com.nflg.product.bomnew.constant.UserJobEnum; import com.nflg.product.bomnew.constant.UserJobEnum;
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO; import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
@ -22,6 +25,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -83,25 +87,27 @@ public class DQBomImportService {
} }
} }
public void save() { public Long save() {
Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>> pcs = BOMMAP.get(SessionUtil.getUserCode()); Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>> pcs = BOMMAP.get(SessionUtil.getUserCode());
VUtils.isTure(pcs == null).throwMessage("数据已丢失,请重新导入"); VUtils.isTure(pcs == null).throwMessage("数据已丢失,请重新导入");
save(pcs.getLeft(), pcs.getRight());
BOMMAP.remove(SessionUtil.getUserCode()); BOMMAP.remove(SessionUtil.getUserCode());
return save(pcs.getLeft(), pcs.getRight());
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) { public Long save(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
checkExceptionStatus(parents, children); // checkExceptionStatus(parents, children);
dQBomParentService.setLastVersionIs0(parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList())); dQBomParentService.setLastVersionIs0(parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList()));
dQBomParentService.saveBatch(parents); dQBomParentService.saveBatch(parents);
dQBomChildService.saveBatch(children); dQBomChildService.saveBatch(children);
BomNewDQbomParentEntity root = parents.stream().filter(p -> p.getRootIs() == 1).findFirst().orElseThrow(() -> new NflgBusinessException(STATE.BusinessError, "根节点不存在"));
return root.getRowId();
} }
private void checkExceptionStatus(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) { // private void checkExceptionStatus(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
BomNewDQbomExceptionCheckService checkService = new BomNewDQbomExceptionCheckService(); // BomNewDQbomExceptionCheckService checkService = new BomNewDQbomExceptionCheckService(dQBomParentService, dQBomChildService, materialMainService);
checkService.check(parents, children); // checkService.check(parents, children);
} // }
private void checkInconsistentData(BomNewDQbomParentEntity parent, List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) throws JsonProcessingException { private void checkInconsistentData(BomNewDQbomParentEntity parent, List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) throws JsonProcessingException {
log.debug("checkInconsistentDataparent" + JsonUtil.toJson(parent)); log.debug("checkInconsistentDataparent" + JsonUtil.toJson(parent));
@ -187,20 +193,28 @@ public class DQBomImportService {
parent.setDrawingNo(data.getDrawingNo()); parent.setDrawingNo(data.getDrawingNo());
parent.setMaterialNo(data.getMaterialNo()); parent.setMaterialNo(data.getMaterialNo());
parent.setMaterialName(data.getMaterialName()); parent.setMaterialName(data.getMaterialName());
parent.setMaterialTexture(data.getMaterialTexture());
parent.setMaterialUnit(data.getMaterial_unit()); parent.setMaterialUnit(data.getMaterial_unit());
parent.setUnitWeight(data.getUnitWeight()); parent.setUnitWeight(data.getUnitWeight());
parent.setNum(Objects.isNull(data.getNum()) ? BigDecimal.ZERO : data.getNum());
parent.setTotalWeight(BomUtil.calculateTotalWeight(data.getNum(), data.getUnitWeight()));
parent.setProjectType(data.getProjectType());
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
parent.setRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1); parent.setRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1);
parent.setUserRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1); parent.setUserRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1);
parent.setLastVersionIs(1); parent.setLastVersionIs(1);
parent.setEditStatus(1);
parent.setStatus(1);
parent.setExceptionStatus(EBomExceptionStatusEnum.INIT.getValue());
parent.setCreatedBy(SessionUtil.getUserCode()); parent.setCreatedBy(SessionUtil.getUserCode());
parent.setCreatedName(SessionUtil.getRealName()); parent.setCreatedName(SessionUtil.getRealName());
parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
//parent.setRemark(data.getRemark()); parent.setRemark(data.getRemark());
// if (index == datas.size() - 1 || datas.get(index + 1).getLevel() <= data.getLevel()) { if (index == datas.size() - 1 || datas.get(index + 1).getLevel() <= data.getLevel()) {
// parent.setBomExist(0); parent.setBomExist(0);
// } else { } else {
parent.setBomExist(1); parent.setBomExist(1);
// } }
parent.setSource(1); parent.setSource(1);
parents.add(parent); parents.add(parent);
} }
@ -208,25 +222,39 @@ public class DQBomImportService {
parentRowIdMap.put(data.getLevel(), parent.getRowId()); parentRowIdMap.put(data.getLevel(), parent.getRowId());
} }
BomNewDQbomChildEntity child = new BomNewDQbomChildEntity();
child.setRowId(IdWorker.getId());
child.setParentRowId(parentRowIdMap.getOrDefault(data.getLevel() - 1, 0L));
child.setIdentityNo(child.getParentRowId() + "_" + child.getRowId());
if (index == 0) { if (index == 0) {
orderMap.put(data.getLevel(), 1); orderMap.put(data.getLevel(), 1);
} else { } else {
orderMap.put(data.getLevel(), orderMap.getOrDefault(data.getLevel(), 0) + 1); orderMap.put(data.getLevel(), orderMap.getOrDefault(data.getLevel(), 0) + 1);
} }
child.setOrderNumber(StrUtil.padPre(String.valueOf(orderMap.get(data.getLevel())), 3, '0'));
child.setDrawingNo(data.getDrawingNo()); if (index > 0) {
child.setMaterialNo(data.getMaterialNo()); BomNewDQbomChildEntity child = new BomNewDQbomChildEntity();
child.setNum(data.getNum()); child.setRowId(IdWorker.getId());
child.setTotalWeight(BomUtil.calculateTotalWeight(data.getNum(), data.getUnitWeight())); child.setParentRowId(parentRowIdMap.getOrDefault(data.getLevel() - 1, 0L));
child.setCreatedName(SessionUtil.getRealName()); child.setIdentityNo(child.getParentRowId() + "_" + child.getRowId());
child.setCreatedBy(SessionUtil.getUserCode()); child.setLevel(data.getLevel());
child.setProjectType(data.getProjectType()); child.setMaterialName(data.getMaterialName());
child.setRemark(data.getRemark()); child.setMaterialTexture(data.getMaterialTexture());
children.add(child); child.setMaterialUnit(data.getMaterial_unit());
child.setUnitWeight(data.getUnitWeight());
child.setTotalWeight(BomUtil.calculateTotalWeight(data.getNum(), data.getUnitWeight()));
child.setOrderNumber(StrUtil.padPre(String.valueOf(orderMap.get(data.getLevel())), 3, '0'));
child.setDrawingNo(data.getDrawingNo());
child.setCurrentVersion(parent == null ? OriginalConstant.DEFAULT_BOM_VERSION : parent.getCurrentVersion());
child.setMaterialNo(data.getMaterialNo());
child.setExceptionStatus(EBomExceptionStatusEnum.INIT.getValue());
child.setNum(Objects.isNull(data.getNum()) ? BigDecimal.ZERO : data.getNum());
child.setTotalWeight(BomUtil.calculateTotalWeight(data.getNum(), data.getUnitWeight()));
child.setCreatedName(SessionUtil.getRealName());
child.setCreatedBy(SessionUtil.getUserCode());
child.setProjectType(data.getProjectType());
child.setRemark(data.getRemark());
child.setEditStatus(1);
child.setStatus(1);
child.setSource(1);
children.add(child);
}
} }
return Pair.of(parents, children); return Pair.of(parents, children);
} }
@ -245,7 +273,7 @@ public class DQBomImportService {
if (p != null) { if (p != null) {
dQbomExcelVO.setMaterialNo(p.getMaterialNo()); dQbomExcelVO.setMaterialNo(p.getMaterialNo());
} else { } else {
dQbomExcelVO.setMaterialNo("T" + IdWorker.getIdStr()); dQbomExcelVO.setMaterialNo(BomConstant.DRAWING_NO_TEMPORARY_PREFIX + IdWorker.getIdStr());
} }
} }

View File

@ -3,6 +3,7 @@ package com.nflg.product.bomnew.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.bomnew.mapper.master.BomNewDQbomParentMapper; import com.nflg.product.bomnew.mapper.master.BomNewDQbomParentMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -46,4 +47,12 @@ public class DQBomParentService extends ServiceImpl<BomNewDQbomParentMapper, Bom
.eq(BomNewDQbomParentEntity::getLastVersionIs, 1) .eq(BomNewDQbomParentEntity::getLastVersionIs, 1)
.list(); .list();
} }
public List<BomNewDQbomVO> getBom(String materialNo, String drawingNo, String materialName) {
return this.getBaseMapper().getBom(materialNo, drawingNo, materialName);
}
public List<BomNewDQbomVO> getVOById(Long parentRowId) {
return this.getBaseMapper().getVOById(parentRowId);
}
} }

View File

@ -19,10 +19,7 @@ import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery; import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery;
import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery; import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomSaveVO;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
import com.nflg.product.bomnew.util.BomUtil; import com.nflg.product.bomnew.util.BomUtil;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -33,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -60,9 +54,91 @@ public class DQBomService {
UserRoleService userRoleService; UserRoleService userRoleService;
public Page<BomNewDQbomVO> getPageList(BomNewDQbomPageQuery query) { public Page<BomNewDQbomVO> getPageList(BomNewDQbomPageQuery query) {
Page<BomNewDQbomVO> ret = dQBomParentService.getBaseMapper().getPageList(new Page<>(query.getPage(), query.getPageSize()), query, SessionUtil.getUserCode()); Page<BomNewDQbomVO> result = dQBomParentService.getBaseMapper().getPageList(new Page<>(query.getPage(), query.getPageSize()), query, SessionUtil.getUserCode());
initMaterialInfo(ret.getRecords()); initMaterialInfo(result.getRecords());
return ret; if (StrUtil.isBlank(query.getMaterialNo()) && StrUtil.isBlank(query.getDrawingNo()) && StrUtil.isBlank(query.getMaterialName())) {
//列表搜索
return result;
}
//根据编号或图号搜索
//从顶级开始查找
List<BomNewDQbomVO> roots = result.getRecords().stream()
.filter(r -> StrUtil.equals(r.getMaterialNo(), query.getMaterialNo())
|| StrUtil.equals(r.getDrawingNo(), query.getDrawingNo())
|| r.getMaterialName().contains(query.getMaterialName()))
.collect(Collectors.toList());
roots.forEach(this::buildChildren);
//从子级开始查找
List<BomNewDQbomVO> boms = dQBomParentService.getBom(query.getMaterialNo(), query.getDrawingNo(), query.getMaterialName());
boms.removeIf(c -> Objects.equals(c.getLastVersionIs(), 0));
boms.forEach(this::buildChildren);
roots.addAll(boms.stream().filter(b -> b.getRootIs() == 0).map(this::buildParent).flatMap(List::stream).collect(Collectors.toList()));
Map<String, List<BomNewDQbomVO>> map = roots.stream().collect(Collectors.groupingBy(BomNewDQbomVO::getMaterialNo));
List<BomNewDQbomVO> results = new ArrayList<>();
map.forEach((k, v) -> {
if (v.size() == 1) {
results.add(v.get(0));
} else {
BomNewDQbomVO f1 = v.get(0);
for (int i = 1; i < v.size(); i++) {
merge(f1, v.get(i));
}
results.add(f1);
}
});
results.sort((r1, r2) -> r1.getBomRowId() >= r2.getBomRowId() ? r1.getBomRowId() > r2.getBomRowId() ? 1 : 0 : -1);
Page<BomNewDQbomVO> pageResult = new Page<>();
pageResult.setPages(1);
pageResult.setCurrent(1);
pageResult.setTotal(results.size());
pageResult.setRecords(results);
return pageResult;
}
private void merge(BomNewDQbomVO v1, BomNewDQbomVO v2) {
v1.getChildNodes().addAll(v2.getChildNodes());
}
private List<BomNewDQbomVO> buildParent(BomNewDQbomVO vo) {
List<BomNewDQbomVO> parents = dQBomParentService.getVOById(vo.getParentRowId());
parents.removeIf(c -> 0 == c.getLastVersionIs());
if (parents.isEmpty()) {
return CollUtil.toList(vo);
} else {
List<BomNewDQbomVO> datas = new ArrayList<>();
parents.forEach(p -> {
if (Objects.isNull(vo.getStatus())) {
vo.setStatus(p.getStatus());
// vo.setCurrentVersion("A00");
}
// if (Objects.equals(vo.getBomExist(), 0) && Objects.equals(vo.getShouldBomExist(), 1)) {
// vo.setCurrentVersion("A-1");
// }
p.setChildNodes(CollUtil.toList(vo));
datas.addAll(buildParent(p));
});
return datas;
}
}
private void buildChildren(BomNewDQbomVO vo) {
List<BomNewDQbomVO> children = getChild(vo.getBomRowId());
//children.removeIf(c -> c.getLastVersionIs() != 1);
vo.setChildNodes(children);
children.forEach(c -> {
if (Objects.isNull(c.getStatus())) {
c.setStatus(vo.getStatus());
}
if (c.getBomRowId() != 0) {
List<BomNewDQbomVO> cc = getChild(c.getBomRowId());
//cc.removeIf(ci -> ci.getLastVersionIs() != 1);
c.setChildNodes(cc);
cc.forEach(this::buildChildren);
}
});
} }
public List<BomNewDQbomVO> getChild(Long bomRowId) { public List<BomNewDQbomVO> getChild(Long bomRowId) {
@ -74,6 +150,7 @@ public class DQBomService {
private void initMaterialInfo(List<BomNewDQbomVO> data) { private void initMaterialInfo(List<BomNewDQbomVO> data) {
List<String> materialNos = data.stream().map(BomNewDQbomVO::getMaterialNo).collect(Collectors.toList()); List<String> materialNos = data.stream().map(BomNewDQbomVO::getMaterialNo).collect(Collectors.toList());
if (CollUtil.isEmpty(materialNos)) return;
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos); List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
data.forEach(d -> { data.forEach(d -> {
BaseMaterialVO bm = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(d.getMaterialNo())).findFirst().orElse(null); BaseMaterialVO bm = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(d.getMaterialNo())).findFirst().orElse(null);
@ -85,12 +162,20 @@ public class DQBomService {
}); });
} }
/**
* 异常检查
* @param rootRowId 根节点id
*/
public void checkException(Long rootRowId) {
checkException(CollUtil.toList(rootRowId));
}
/** /**
* 异常检查 * 异常检查
* @param rootRowIds 根节点id列表 * @param rootRowIds 根节点id列表
*/ */
public void checkException(List<Long> rootRowIds) { public void checkException(List<Long> rootRowIds) {
BomNewDQbomExceptionCheckService checkService = new BomNewDQbomExceptionCheckService(); BomNewDQbomExceptionCheckService checkService = new BomNewDQbomExceptionCheckService(dQBomParentService, dQBomChildService, materialMainService);
rootRowIds.forEach(checkService::check); rootRowIds.forEach(checkService::check);
} }
@ -215,13 +300,15 @@ public class DQBomService {
} }
} }
public void submit(Long bomRowId) { public void submit(BomNewDQbomSaveQuery query) {
save(query);
dQBomParentService.lambdaUpdate() dQBomParentService.lambdaUpdate()
.eq(BomNewDQbomParentEntity::getRowId, bomRowId) .eq(BomNewDQbomParentEntity::getRowId, query.getParent().getRowId())
.set(BomNewDQbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue()) .set(BomNewDQbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
.set(BomNewDQbomParentEntity::getModifyTime, LocalDateTime.now()) .set(BomNewDQbomParentEntity::getModifyTime, LocalDateTime.now())
.update(); .update();
checkException(CollUtil.toList(bomRowId)); //checkException(CollUtil.toList(query.getParent().getRowId()));
} }
public List<DQbomExcelVO> exportBom(Long rootBomRowId) { public List<DQbomExcelVO> exportBom(Long rootBomRowId) {
@ -277,4 +364,18 @@ public class DQBomService {
dQBomParentService.updateById(parentEntity); dQBomParentService.updateById(parentEntity);
} }
} }
public BomDQbomEditDetailVO editDetail(Long rowId, Long bomRowId) {
BomDQbomEditDetailVO vo = new BomDQbomEditDetailVO();
BomNewDQbomParentEntity parent = dQBomParentService.getById(bomRowId);
BomNewDQbomChildEntity child = dQBomChildService.getById(rowId);
VUtils.isTure(Objects.isNull(parent) && Objects.isNull(child)).throwMessage("无效的数据");
if (!Objects.isNull(parent)) {
vo.setParent(Convert.convert(BomNewDQbomVO.class, parent));
vo.setDatas(getChild(bomRowId));
} else if (!Objects.isNull(child)) {
vo.setParent(Convert.convert(BomNewDQbomVO.class, child));
}
return vo;
}
} }

View File

@ -29,36 +29,45 @@
</resultMap> </resultMap>
<!--分页获取数据--> <!--分页获取数据-->
<select id="getPageList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO"> <select id="getPageList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
SELECT p.* SELECT
ifnull(c.row_id,p.row_id) row_id,
p.row_id bomRowId,
p.created_by bomCreateBy,
p.*
FROM t_bom_new_dqbom_parent p FROM t_bom_new_dqbom_parent p
INNER JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no LEFT JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no
WHERE (root_is | user_root_is = 1) AND p.status = #{query.status} WHERE (root_is | user_root_is = 1) AND p.status = #{query.status}
<if test="query.showMySelfOnly == 1"> <if test="query.showMySelfOnly == 1">
AND p.created_by = '#{userCode}' AND p.created_by = #{userCode}
</if> </if>
<if test="query.drawingNo != null"> <if test="query.drawingNo != null and query.drawingNo!=''">
AND p.drawing_no = '#{query.drawingNo}' AND p.drawing_no = #{query.drawingNo}
</if> </if>
<if test="query.materialNo != null"> <if test="query.materialNo != null and query.materialNo!=''">
AND p.material_no = '#{query.materialNo}' AND p.material_no = #{query.materialNo}
</if> </if>
<if test="query.materialName != null"> <if test="query.materialName != null and query.materialName!=''">
AND p.material_name like concat('%', '${query.materialName}', '%') AND p.material_name like concat('%', ${query.materialName}, '%')
</if> </if>
<if test="query.startDate != null"> <if test="query.startDate != null and query.startDate!=''">
AND p.created_time <![CDATA[ >= ]]> #{query.startDate} AND p.created_time <![CDATA[ >= ]]> #{query.startDate}
</if> </if>
<if test="query.endDate != null"> <if test="query.endDate != null and query.endDate!=''">
AND p.created_time <![CDATA[ <= ]]> #{query.endDate} AND p.created_time <![CDATA[ <= ]]> #{query.endDate}
</if> </if>
ORDER BY user_root_is DESC, row_id DESC ORDER BY user_root_is DESC, p.row_id DESC
</select> </select>
<!--获取子级数据--> <!--获取子级数据-->
<select id="getChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO"> <select id="getChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
SELECT p.*, c.order_number SELECT ifnull(p.row_id, 0) bomRowId,
ifnull(p.created_by, c.created_by) bomCreateBy,
ifnull(p.exception_status, c.exception_status) exception_status,
ifnull(p.exception_tag, c.exception_tag) exception_tag,
ifnull(p.bom_exist, 0) bom_exist,
c.*
FROM t_bom_new_dqbom_parent p FROM t_bom_new_dqbom_parent p
INNER JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no RIGHT JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no
WHERE c.parent_row_id = #{bomRowId} WHERE c.parent_row_id = #{bomRowId}
ORDER BY c.order_number ORDER BY c.order_number
</select> </select>
@ -86,7 +95,7 @@
</select> </select>
<select id="getChildren" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO"> <select id="getChildren" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
SELECT ifnull(p.row_id, 0) AS bomRowId, SELECT if(p.bom_exist = 1, p.row_id, 0) AS bomRowId,
c.row_id, c.row_id,
c.level, c.level,
c.material_no, c.material_no,
@ -102,6 +111,50 @@
FROM t_bom_new_dqbom_child c FROM t_bom_new_dqbom_child c
LEFT JOIN t_bom_new_dqbom_parent p ON c.material_no = p.material_no AND p.last_version_is = 1 LEFT JOIN t_bom_new_dqbom_parent p ON c.material_no = p.material_no AND p.last_version_is = 1
WHERE c.parent_row_id = #{rootBomRowId} WHERE c.parent_row_id = #{rootBomRowId}
order by c.level order by c.order_number
</select>
<select id="getBom" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
SELECT
ifnull(p.row_id,0) bomRowId,
ifnull(p.created_by,c.created_by) bomCreateBy,
ifnull(p.last_version_is,1) last_version_is,
ifnull(p.root_is,0) root_is,
c.*
FROM t_bom_new_dqbom_parent p
RIGHT JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no
WHERE c.status = #{query.status}
<if test="query.drawingNo != null and query.drawingNo!=''">
AND c.drawing_no = #{query.drawingNo}
</if>
<if test="query.materialNo != null and query.materialNo!=''">
AND c.material_no = #{query.materialNo}
</if>
<if test="query.materialName != null and query.materialName!=''">
AND c.material_name like concat('%', ${query.materialName}, '%')
</if>
<if test="query.startDate != null and query.startDate!=''">
AND c.created_time <![CDATA[ >= ]]> #{query.startDate}
</if>
<if test="query.endDate != null and query.endDate!=''">
AND c.created_time <![CDATA[ <= ]]> #{query.endDate}
</if>
</select>
<select id="getVOById" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
SELECT IFNULL(b.exception_status, a.exception_status) exception_status
, IFNULL(b.created_by, a.created_by) created_by
, IFNULL(b.edit_status, a.edit_status) edit_status
, IFNULL(b.created_time, a.created_time) created_time
, b.exception_tag
, b.project_type
, IFNULL(b.num, a.num) num
, IFNULL(b.modify_time, a.modify_time) modify_time
, IFNULL(b.parent_row_id, 0) parent_row_id
, a.row_id bomRowId
, a.*
FROM t_bom_new_dqbom_parent a
LEFT JOIN t_bom_new_dqbom_child b ON a.material_no = b.material_no
WHERE a.row_id = #{parentRowId}
</select> </select>
</mapper> </mapper>

View File

@ -109,7 +109,7 @@ public class OtherTest {
} }
@Test @Test
public void test10() { public void test13() {
BigDecimal num = BigDecimal.valueOf(1.2); BigDecimal num = BigDecimal.valueOf(1.2);
BigDecimal unitWeight = BigDecimal.valueOf(23.5656224); BigDecimal unitWeight = BigDecimal.valueOf(23.5656224);
BigDecimal totalWeight = BigDecimal.valueOf(28.27874688); BigDecimal totalWeight = BigDecimal.valueOf(28.27874688);
@ -118,7 +118,7 @@ public class OtherTest {
} }
@Test @Test
public void test11() { public void test14() {
BigDecimal num = BigDecimal.valueOf(3); BigDecimal num = BigDecimal.valueOf(3);
BigDecimal unitWeight = BigDecimal.valueOf(23.5000); BigDecimal unitWeight = BigDecimal.valueOf(23.5000);
BigDecimal totalWeight = BomUtil.calculateTotalWeight(num, unitWeight); BigDecimal totalWeight = BomUtil.calculateTotalWeight(num, unitWeight);
@ -128,7 +128,7 @@ public class OtherTest {
} }
@Test @Test
public void test12() { public void test15() {
BigDecimal num = BigDecimal.valueOf(3); BigDecimal num = BigDecimal.valueOf(3);
BigDecimal unitWeight = BigDecimal.valueOf(23.552560); BigDecimal unitWeight = BigDecimal.valueOf(23.552560);
BigDecimal totalWeight = BomUtil.calculateTotalWeight(num, unitWeight); BigDecimal totalWeight = BomUtil.calculateTotalWeight(num, unitWeight);

View File

@ -105,7 +105,7 @@ public class BaseGlobalExceptionHandle {
public ResultVO<String> handleDataIntegrityViolationException(DataIntegrityViolationException e) { public ResultVO<String> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
// return ResultVO.error("字段太长,超出数据库字段的长度"); // return ResultVO.error("字段太长,超出数据库字段的长度");
return ResultVO.error("字段太长,超出数据库字段的长度"); return ResultVO.error("数据不完整");
} }
@ExceptionHandler(value = SQLException.class) @ExceptionHandler(value = SQLException.class)