fix: 电气专用bom
This commit is contained in:
parent
78e10a798f
commit
fc738cd40f
|
|
@ -22,6 +22,12 @@ public class BomExceptionVO implements Serializable {
|
|||
@ApiModelProperty(value = "bom行编号")
|
||||
public Long bomRowId;
|
||||
|
||||
/**
|
||||
* rowId
|
||||
*/
|
||||
@ApiModelProperty(value = "rowId")
|
||||
public Long rowId;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.nflg.product.bomnew.pojo.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.product.bomnew.constant.BomConstant;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -116,7 +115,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
|||
private String drawingNoDesc;
|
||||
|
||||
public String getDrawingNoDesc() {
|
||||
if (StrUtil.isNotBlank(getDrawingNo()) && getDrawingNo().startsWith(BomConstant.NO_TEMPORARY_PREFIX)) {
|
||||
if (StrUtil.equals(getProjectType(), "T")) {
|
||||
return "";
|
||||
}
|
||||
return getDrawingNo();
|
||||
|
|
@ -129,7 +128,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
|||
private String materialNoDesc;
|
||||
|
||||
public String getMaterialNoDesc() {
|
||||
if (StrUtil.isNotBlank(getMaterialNo()) && getMaterialNo().startsWith(BomConstant.NO_TEMPORARY_PREFIX)) {
|
||||
if (StrUtil.equals(getProjectType(), "T")) {
|
||||
return "";
|
||||
}
|
||||
return getMaterialNo();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
|
|
@ -221,18 +220,18 @@ public class DQBomService {
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public BomNewDQbomSaveQuery save(BomNewDQbomSaveQuery query) {
|
||||
BomNewDQbomParentEntity parent = new BomNewDQbomParentEntity();
|
||||
BeanUtil.copyProperties(query.getParent(), parent);
|
||||
BomNewDQbomParentEntity 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)
|
||||
.one();
|
||||
VUtils.isTure(oldParent != null && !oldParent.getCreatedBy().equals(SessionUtil.getUserCode()))
|
||||
.throwMessage("父级已被其他人创建");
|
||||
VUtils.isTure(CollUtil.isEmpty(query.getChildren())).throwMessage("新添加的bom必须有子级");
|
||||
|
||||
parent = Convert.convert(BomNewDQbomParentEntity.class, query.getParent());
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setLevel(1);
|
||||
parent.setBomExist(1);
|
||||
|
|
@ -245,16 +244,13 @@ public class DQBomService {
|
|||
parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
parent.setSource(2);
|
||||
dQBomParentService.save(parent);
|
||||
query.getParent().setRowId(parent.getRowId());
|
||||
query.getParent().setBomRowId(parent.getRowId());
|
||||
} else {
|
||||
//修改数据
|
||||
// VUtils.isTure(!SessionUtil.getUserCode().equals(parent.getCreatedBy())).throwMessage("不能修改他人的数据");
|
||||
|
||||
//删除
|
||||
dQBomChildService.deleteAllChildren(parent.getRowId());
|
||||
//删除所有子级关系
|
||||
dQBomChildService.deleteAllChildren(query.getParent().getBomRowId());
|
||||
parent = dQBomParentService.getById(query.getParent().getBomRowId());
|
||||
parent.setModifyTime(LocalDateTime.now());
|
||||
if (CollUtil.isEmpty(query.getChildren())) {
|
||||
//dQBomChildService.deleteAllChildren(parent.getRowId());
|
||||
parent.setBomExist(0);
|
||||
dQBomParentService.saveOrUpdate(parent);
|
||||
return query;
|
||||
|
|
@ -270,18 +266,20 @@ public class DQBomService {
|
|||
c.setRowId(IdWorker.getId());
|
||||
c.setCreatedBy(SessionUtil.getUserCode());
|
||||
c.setCreatedName(SessionUtil.getRealName());
|
||||
String id = RandomUtil.randomNumbers(9);
|
||||
c.setMaterialNo(BomConstant.NO_TEMPORARY_PREFIX + id);
|
||||
c.setDrawingNo(BomConstant.NO_TEMPORARY_PREFIX + id);
|
||||
if (StrUtil.equals(c.getProjectType(), "T")) {
|
||||
String id = RandomUtil.randomNumbers(9);
|
||||
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 {
|
||||
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.setParentRowId(parent.getRowId());
|
||||
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
|
||||
|
|
@ -488,6 +486,7 @@ public class DQBomService {
|
|||
pchildren.forEach(c -> {
|
||||
c.setCreatedTime(LocalDateTime.now());
|
||||
c.setModifyTime(null);
|
||||
c.setFacCode(FactoryCodeEnum.FACTORY_1010.getValue());
|
||||
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
|
||||
if (CollUtil.isNotEmpty(materialBaseInfos)) {
|
||||
BaseMaterialVO materialVO = materialBaseInfos.stream()
|
||||
|
|
@ -529,6 +528,7 @@ public class DQBomService {
|
|||
parent.setStatus(2);
|
||||
parent.setConvertToPbomTime(LocalDateTime.now());
|
||||
parent.setModifyTime(LocalDateTime.now());
|
||||
parent.setEditStatus(2);
|
||||
parents.add(parent);
|
||||
LambdaQueryWrapper<BomNewDQbomParentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo());
|
||||
|
|
@ -537,6 +537,7 @@ public class DQBomService {
|
|||
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
|
||||
cc.forEach(c -> {
|
||||
c.setStatus(2);
|
||||
c.setEditStatus(2);
|
||||
c.setModifyTime(LocalDateTime.now());
|
||||
});
|
||||
children.addAll(cc);
|
||||
|
|
@ -572,6 +573,8 @@ public class DQBomService {
|
|||
.eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
parent.setCurrentVersion(VersionUtil.getNextVersion(""));
|
||||
}
|
||||
//处理子级
|
||||
dQBomParentService.lambdaQuery()
|
||||
|
|
@ -591,18 +594,14 @@ public class DQBomService {
|
|||
List<BomExceptionVO> datas = new ArrayList<>();
|
||||
for (int index = 0, count = query.size(); index < count; index++) {
|
||||
BomExceptionQuery bom = query.get(index);
|
||||
BomExceptionVO vo = new BomExceptionVO();
|
||||
if (index == 0) {
|
||||
checkException(bom.getBomRowId());
|
||||
|
||||
BomNewDQbomParentEntity parent = dQBomParentService.getById(bom.getBomRowId());
|
||||
BomExceptionVO vo = new BomExceptionVO();
|
||||
vo.setBomRowId(bom.getBomRowId());
|
||||
vo.setMaterialNo(parent.getMaterialNo());
|
||||
vo.setExceptionStatus(parent.getExceptionStatus());
|
||||
datas.add(vo);
|
||||
} else {
|
||||
BomExceptionVO vo = new BomExceptionVO();
|
||||
vo.setBomRowId(bom.getBomRowId());
|
||||
BomNewDQbomChildEntity child = dQBomChildService.getById(bom.getRowId());
|
||||
vo.setMaterialNo(child.getMaterialNo());
|
||||
if (Objects.equals(child.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())) {
|
||||
|
|
@ -612,6 +611,9 @@ public class DQBomService {
|
|||
vo.setExceptionStatus(child.getExceptionStatus());
|
||||
}
|
||||
}
|
||||
vo.setBomRowId(bom.getBomRowId());
|
||||
vo.setRowId(bom.getRowId());
|
||||
datas.add(vo);
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<!--分页获取数据-->
|
||||
<select id="getPageList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
|
||||
SELECT
|
||||
ifnull(c.row_id,0) row_id,
|
||||
ifnull(c.row_id,p.row_id) row_id,
|
||||
p.row_id bomRowId,
|
||||
p.created_by bomCreateBy,
|
||||
p.*
|
||||
|
|
@ -67,9 +67,10 @@
|
|||
ifnull(p.bom_exist, 0) bom_exist,
|
||||
ifnull(p.sap_state, 1) sap_state,
|
||||
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.parent_row_id = #{bomRowId}
|
||||
FROM t_bom_new_dqbom_child c
|
||||
INNER JOIN t_bom_new_dqbom_parent p2 ON p2.row_id = c.parent_row_id
|
||||
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
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue