fix: 电气专用bom

This commit is contained in:
曹鹏飞 2024-04-24 18:09:11 +08:00
parent 78e10a798f
commit fc738cd40f
4 changed files with 41 additions and 33 deletions

View File

@ -22,6 +22,12 @@ public class BomExceptionVO implements Serializable {
@ApiModelProperty(value = "bom行编号") @ApiModelProperty(value = "bom行编号")
public Long bomRowId; public Long bomRowId;
/**
* rowId
*/
@ApiModelProperty(value = "rowId")
public Long rowId;
/** /**
* 物料编码 * 物料编码
*/ */

View File

@ -1,7 +1,6 @@
package com.nflg.product.bomnew.pojo.vo; package com.nflg.product.bomnew.pojo.vo;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.nflg.product.bomnew.constant.BomConstant;
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;
@ -116,7 +115,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
private String drawingNoDesc; private String drawingNoDesc;
public String getDrawingNoDesc() { public String getDrawingNoDesc() {
if (StrUtil.isNotBlank(getDrawingNo()) && getDrawingNo().startsWith(BomConstant.NO_TEMPORARY_PREFIX)) { if (StrUtil.equals(getProjectType(), "T")) {
return ""; return "";
} }
return getDrawingNo(); return getDrawingNo();
@ -129,7 +128,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
private String materialNoDesc; private String materialNoDesc;
public String getMaterialNoDesc() { public String getMaterialNoDesc() {
if (StrUtil.isNotBlank(getMaterialNo()) && getMaterialNo().startsWith(BomConstant.NO_TEMPORARY_PREFIX)) { if (StrUtil.equals(getProjectType(), "T")) {
return ""; return "";
} }
return getMaterialNo(); return getMaterialNo();

View File

@ -1,6 +1,5 @@
package com.nflg.product.bomnew.service; package com.nflg.product.bomnew.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
@ -221,18 +220,18 @@ public class DQBomService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public BomNewDQbomSaveQuery save(BomNewDQbomSaveQuery query) { public BomNewDQbomSaveQuery save(BomNewDQbomSaveQuery query) {
BomNewDQbomParentEntity parent = new BomNewDQbomParentEntity(); BomNewDQbomParentEntity parent;
BeanUtil.copyProperties(query.getParent(), parent);
if (Objects.isNull(parent.getRowId()) || parent.getRowId() == 0) { if (Objects.isNull(query.getParent()) || query.getParent().getBomRowId() == 0) {
//新增父级节点 //新增父级节点
BomNewDQbomParentEntity oldParent = dQBomParentService.lambdaQuery().eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo()) BomNewDQbomParentEntity oldParent = dQBomParentService.lambdaQuery().eq(BomNewDQbomParentEntity::getMaterialNo, query.getParent().getMaterialNo())
.eq(BomNewDQbomParentEntity::getLastVersionIs, 1) .eq(BomNewDQbomParentEntity::getLastVersionIs, 1)
.one(); .one();
VUtils.isTure(oldParent != null && !oldParent.getCreatedBy().equals(SessionUtil.getUserCode())) VUtils.isTure(oldParent != null && !oldParent.getCreatedBy().equals(SessionUtil.getUserCode()))
.throwMessage("父级已被其他人创建"); .throwMessage("父级已被其他人创建");
VUtils.isTure(CollUtil.isEmpty(query.getChildren())).throwMessage("新添加的bom必须有子级"); VUtils.isTure(CollUtil.isEmpty(query.getChildren())).throwMessage("新添加的bom必须有子级");
parent = Convert.convert(BomNewDQbomParentEntity.class, query.getParent());
parent.setRowId(IdWorker.getId()); parent.setRowId(IdWorker.getId());
parent.setLevel(1); parent.setLevel(1);
parent.setBomExist(1); parent.setBomExist(1);
@ -245,16 +244,13 @@ public class DQBomService {
parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
parent.setSource(2); parent.setSource(2);
dQBomParentService.save(parent); dQBomParentService.save(parent);
query.getParent().setRowId(parent.getRowId()); query.getParent().setBomRowId(parent.getRowId());
} else { } else {
//修改数据 //删除所有子级关系
// VUtils.isTure(!SessionUtil.getUserCode().equals(parent.getCreatedBy())).throwMessage("不能修改他人的数据"); dQBomChildService.deleteAllChildren(query.getParent().getBomRowId());
parent = dQBomParentService.getById(query.getParent().getBomRowId());
//删除
dQBomChildService.deleteAllChildren(parent.getRowId());
parent.setModifyTime(LocalDateTime.now()); parent.setModifyTime(LocalDateTime.now());
if (CollUtil.isEmpty(query.getChildren())) { if (CollUtil.isEmpty(query.getChildren())) {
//dQBomChildService.deleteAllChildren(parent.getRowId());
parent.setBomExist(0); parent.setBomExist(0);
dQBomParentService.saveOrUpdate(parent); dQBomParentService.saveOrUpdate(parent);
return query; return query;
@ -270,18 +266,20 @@ public class DQBomService {
c.setRowId(IdWorker.getId()); c.setRowId(IdWorker.getId());
c.setCreatedBy(SessionUtil.getUserCode()); c.setCreatedBy(SessionUtil.getUserCode());
c.setCreatedName(SessionUtil.getRealName()); c.setCreatedName(SessionUtil.getRealName());
String id = RandomUtil.randomNumbers(9); if (StrUtil.equals(c.getProjectType(), "T")) {
c.setMaterialNo(BomConstant.NO_TEMPORARY_PREFIX + id); String id = RandomUtil.randomNumbers(9);
c.setDrawingNo(BomConstant.NO_TEMPORARY_PREFIX + id); c.setMaterialNo(BomConstant.NO_TEMPORARY_PREFIX + id);
c.setDrawingNo(BomConstant.NO_TEMPORARY_PREFIX + id);
if (Objects.isNull(c.getNum()) || NumberUtil.equals(c.getNum(), BigDecimal.ZERO)) {
c.setNum(BigDecimal.ONE);
}
if (StrUtil.isBlank(c.getMaterialUnit())) {
c.setMaterialUnit("PC");
}
}
} else { } else {
c.setModifyTime(LocalDateTime.now()); c.setModifyTime(LocalDateTime.now());
} }
if (StrUtil.isBlank(c.getMaterialUnit())) {
c.setMaterialUnit("PC");
}
if (Objects.isNull(c.getNum()) || NumberUtil.equals(c.getNum(), BigDecimal.ZERO)) {
c.setNum(BigDecimal.ONE);
}
c.setLevel(parent.getLevel() + 1); c.setLevel(parent.getLevel() + 1);
c.setParentRowId(parent.getRowId()); c.setParentRowId(parent.getRowId());
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId()); c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
@ -488,6 +486,7 @@ public class DQBomService {
pchildren.forEach(c -> { pchildren.forEach(c -> {
c.setCreatedTime(LocalDateTime.now()); c.setCreatedTime(LocalDateTime.now());
c.setModifyTime(null); c.setModifyTime(null);
c.setFacCode(FactoryCodeEnum.FACTORY_1010.getValue());
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId()); c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
if (CollUtil.isNotEmpty(materialBaseInfos)) { if (CollUtil.isNotEmpty(materialBaseInfos)) {
BaseMaterialVO materialVO = materialBaseInfos.stream() BaseMaterialVO materialVO = materialBaseInfos.stream()
@ -529,6 +528,7 @@ public class DQBomService {
parent.setStatus(2); parent.setStatus(2);
parent.setConvertToPbomTime(LocalDateTime.now()); parent.setConvertToPbomTime(LocalDateTime.now());
parent.setModifyTime(LocalDateTime.now()); parent.setModifyTime(LocalDateTime.now());
parent.setEditStatus(2);
parents.add(parent); parents.add(parent);
LambdaQueryWrapper<BomNewDQbomParentEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BomNewDQbomParentEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo()); wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo());
@ -537,6 +537,7 @@ public class DQBomService {
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId()); List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
cc.forEach(c -> { cc.forEach(c -> {
c.setStatus(2); c.setStatus(2);
c.setEditStatus(2);
c.setModifyTime(LocalDateTime.now()); c.setModifyTime(LocalDateTime.now());
}); });
children.addAll(cc); children.addAll(cc);
@ -572,6 +573,8 @@ public class DQBomService {
.eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId())); .eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId()));
} }
} }
} else {
parent.setCurrentVersion(VersionUtil.getNextVersion(""));
} }
//处理子级 //处理子级
dQBomParentService.lambdaQuery() dQBomParentService.lambdaQuery()
@ -591,18 +594,14 @@ public class DQBomService {
List<BomExceptionVO> datas = new ArrayList<>(); List<BomExceptionVO> datas = new ArrayList<>();
for (int index = 0, count = query.size(); index < count; index++) { for (int index = 0, count = query.size(); index < count; index++) {
BomExceptionQuery bom = query.get(index); BomExceptionQuery bom = query.get(index);
BomExceptionVO vo = new BomExceptionVO();
if (index == 0) { if (index == 0) {
checkException(bom.getBomRowId()); checkException(bom.getBomRowId());
BomNewDQbomParentEntity parent = dQBomParentService.getById(bom.getBomRowId()); BomNewDQbomParentEntity parent = dQBomParentService.getById(bom.getBomRowId());
BomExceptionVO vo = new BomExceptionVO();
vo.setBomRowId(bom.getBomRowId());
vo.setMaterialNo(parent.getMaterialNo()); vo.setMaterialNo(parent.getMaterialNo());
vo.setExceptionStatus(parent.getExceptionStatus()); vo.setExceptionStatus(parent.getExceptionStatus());
datas.add(vo);
} else { } else {
BomExceptionVO vo = new BomExceptionVO();
vo.setBomRowId(bom.getBomRowId());
BomNewDQbomChildEntity child = dQBomChildService.getById(bom.getRowId()); BomNewDQbomChildEntity child = dQBomChildService.getById(bom.getRowId());
vo.setMaterialNo(child.getMaterialNo()); vo.setMaterialNo(child.getMaterialNo());
if (Objects.equals(child.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())) { if (Objects.equals(child.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())) {
@ -612,6 +611,9 @@ public class DQBomService {
vo.setExceptionStatus(child.getExceptionStatus()); vo.setExceptionStatus(child.getExceptionStatus());
} }
} }
vo.setBomRowId(bom.getBomRowId());
vo.setRowId(bom.getRowId());
datas.add(vo);
} }
return datas; return datas;
} }

View File

@ -30,7 +30,7 @@
<!--分页获取数据--> <!--分页获取数据-->
<select id="getPageList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO"> <select id="getPageList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
SELECT SELECT
ifnull(c.row_id,0) row_id, ifnull(c.row_id,p.row_id) row_id,
p.row_id bomRowId, p.row_id bomRowId,
p.created_by bomCreateBy, p.created_by bomCreateBy,
p.* p.*
@ -67,9 +67,10 @@
ifnull(p.bom_exist, 0) bom_exist, ifnull(p.bom_exist, 0) bom_exist,
ifnull(p.sap_state, 1) sap_state, ifnull(p.sap_state, 1) sap_state,
c.* c.*
FROM t_bom_new_dqbom_parent p FROM t_bom_new_dqbom_child c
RIGHT JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no INNER JOIN t_bom_new_dqbom_parent p2 ON p2.row_id = c.parent_row_id
WHERE c.parent_row_id = #{bomRowId} LEFT JOIN t_bom_new_dqbom_parent p ON p.material_no = c.material_no AND p.status = p2.status
WHERE p2.row_id = #{bomRowId}
ORDER BY c.order_number ORDER BY c.order_number
</select> </select>