fix: 一些细节优化

1.删除接口和保存数据接口重新计算是否有bom;
2.getChild接口currentVersion和bomRowId逻辑调整
This commit is contained in:
曹鹏飞 2024-04-11 13:44:39 +08:00
parent 743191a5be
commit ee8ee6b486
9 changed files with 86 additions and 48 deletions

View File

@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.*; import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO;
import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO;
import com.nflg.product.bomnew.pojo.vo.ReverseReportVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -69,4 +71,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
Integer getCountForWaitReviewByMaterialNo(@Param("materialNo") String materialNo); Integer getCountForWaitReviewByMaterialNo(@Param("materialNo") String materialNo);
void updateRootForWaitReview(); void updateRootForWaitReview();
void resetBomExist(Long rowId);
} }

View File

@ -62,5 +62,5 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
List<BomOriginalListVO> getChildForDrawingNoSeach(@Param("drawingNos") List<String> drawingNos,@Param("state") Integer state); List<BomOriginalListVO> getChildForDrawingNoSeach(@Param("drawingNos") List<String> drawingNos,@Param("state") Integer state);
void resetBomExist(Long rowId);
} }

View File

@ -51,4 +51,6 @@ public interface BomNewPbomParentMapper extends BaseMapper<BomNewPbomParentEntit
Integer checkIsUserRoot(@Param("materialNo") String materialNo, @Param("jobNo") String jobNo); Integer checkIsUserRoot(@Param("materialNo") String materialNo, @Param("jobNo") String jobNo);
List<BomNewPbomWorkExcelVO> exportExcel(List<Long> bomRowIds); List<BomNewPbomWorkExcelVO> exportExcel(List<Long> bomRowIds);
void resetBomExist(Long rowId);
} }

View File

@ -318,14 +318,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (bomListMap.containsKey(child.getMaterialNo())) { if (bomListMap.containsKey(child.getMaterialNo())) {
BomNewEbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo()); BomNewEbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) {
child.setCurrentVersion(parentEntity.getCurrentVersion()); child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(parentEntity.getCurrentVersion());
}
child.setStatus(parentEntity.getStatus()); child.setStatus(parentEntity.getStatus());
child.setDeviseName(parentEntity.getDeviseName()); child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode()); child.setDeviseUserCode(parentEntity.getDeviseUserCode());
child.setCreatedTime(parentEntity.getCreatedTime()); child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId()); if (parentEntity.getBomExist() == 1) {
child.setBomRowId(parentEntity.getRowId());
}
child.setLevelNum(parentEntity.getLevelNum()); child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName()); child.setDeptName(parentEntity.getDeptName());
// child.setSource(parentEntity.getSource()); // child.setSource(parentEntity.getSource());
@ -357,11 +362,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setSuperMaterialStatus(parent.getSuperMaterialStatus()); child.setSuperMaterialStatus(parent.getSuperMaterialStatus());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) { if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(parent.getStatus()); } else {
// child.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue()); child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
} }
} }
} }
} }
@ -1726,7 +1729,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (eBomEdit.isRootForWaitReview()) { if (eBomEdit.isRootForWaitReview()) {
this.getBaseMapper().updateRootForWaitReview(); this.getBaseMapper().updateRootForWaitReview();
} }
resetBomExist(dto.getParent().getRowId());
return true; return true;
} }
@ -1941,5 +1944,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
LogRecordContext.putVariable("bom", ent); LogRecordContext.putVariable("bom", ent);
} }
private void resetBomExist(Long rowId) {
this.getBaseMapper().resetBomExist(rowId);
}
} }

View File

@ -206,18 +206,19 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
List<BomOriginalListVO> saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList()); List<BomOriginalListVO> saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList());
List<BomNewOriginalChildEntity> childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts); List<BomNewOriginalChildEntity> childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts);
// originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId())); // originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId()));
childEntities.forEach(u -> {
u.setParentRowId(bom.getParentRowId());
if (submitIs) {
u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
}
});
if (CollUtil.isNotEmpty(childEntities)) { if (CollUtil.isNotEmpty(childEntities)) {
childEntities.forEach(u -> {
u.setParentRowId(bom.getParentRowId());
if (submitIs) {
u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
}
});
//删除行 //删除行
List<Long> delRowIds = bom.getBomList().stream().map(BomOriginalListVO::getRowId).filter(rowId -> rowId > 0).collect(Collectors.toList()); List<Long> delRowIds = bom.getBomList().stream().map(BomOriginalListVO::getRowId).filter(rowId -> rowId > 0).collect(Collectors.toList());
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId()); originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId());
originalChildService.saveOrUpdateBatch(childEntities); originalChildService.saveOrUpdateBatch(childEntities);
resetBomExist(bom.getParentRowId());
} }
return true; return true;
@ -268,13 +269,19 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
for (BomOriginalListVO child : parentChild) { for (BomOriginalListVO child : parentChild) {
if (bomListMap.containsKey(child.getDrawingNo())) { if (bomListMap.containsKey(child.getDrawingNo())) {
BomNewOriginalParentEntity parentEntity = bomListMap.get(child.getDrawingNo()); BomNewOriginalParentEntity parentEntity = bomListMap.get(child.getDrawingNo());
child.setCurrentVersion(parentEntity.getCurrentVersion()); if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(parentEntity.getCurrentVersion());
}
child.setStatus(parentEntity.getStatus()); child.setStatus(parentEntity.getStatus());
child.setDeviseName(parentEntity.getDeviseName()); child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode()); child.setDeviseUserCode(parentEntity.getDeviseUserCode());
// child.setCreatedBy(parentEntity.getCreatedBy()); // child.setCreatedBy(parentEntity.getCreatedBy());
// child.setCreatedTime(parentEntity.getCreatedTime()); // child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId()); if (parentEntity.getBomExist() == 1) {
child.setBomRowId(parentEntity.getRowId());
}
child.setLevelNum(parentEntity.getLevelNum()); child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName()); child.setDeptName(parentEntity.getDeptName());
child.setSource(parentEntity.getSource()); child.setSource(parentEntity.getSource());
@ -298,17 +305,11 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
child.setBomRowId(0L); child.setBomRowId(0L);
} }
} }
try { if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) { child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); } else {
//child.setStatus(OriginalStatusEnum.UN_CONVERT.getValue()); child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
// child.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue());
}
} catch (Exception e) {
e.getMessage();
} }
} }
} }
} }
@ -356,11 +357,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
BomNewOriginalParentEntity parentEntity = this.getBaseMapper().selectById(rowId); BomNewOriginalParentEntity parentEntity = this.getBaseMapper().selectById(rowId);
OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail); OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail);
ForkJoinTask<List<BomOriginalListVO>> submit = bomDetailPool.submit(detailTask); ForkJoinTask<List<BomOriginalListVO>> submit = bomDetailPool.submit(detailTask);
return submit.get();
List<BomOriginalListVO> result = submit.get();
return result;
} }
/** /**
@ -724,5 +721,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
excelContextTL.remove(); excelContextTL.remove();
} }
private void resetBomExist(Long rowId) {
this.getBaseMapper().resetBomExist(rowId);
}
} }

View File

@ -244,6 +244,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
public List<BomNewPbomParentVO> getChild(Long rowId) { public List<BomNewPbomParentVO> getChild(Long rowId) {
VUtils.isTure(rowId == 0).throwMessage("参数不正确");
return getChild(this.getById(rowId)); return getChild(this.getById(rowId));
} }
public List<BomNewPbomParentVO> getChild(BomNewPbomParentEntity parent) { public List<BomNewPbomParentVO> getChild(BomNewPbomParentEntity parent) {
@ -269,14 +270,20 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
for (BomNewPbomParentVO child : parentChild) { for (BomNewPbomParentVO child : parentChild) {
if (bomListMap.containsKey(child.getMaterialNo())) { if (bomListMap.containsKey(child.getMaterialNo())) {
BomNewPbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo()); BomNewPbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
child.setCurrentVersion(parentEntity.getCurrentVersion()); if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(parentEntity.getCurrentVersion());
}
child.setStatus(parentEntity.getStatus()); child.setStatus(parentEntity.getStatus());
child.setEditStatus(parentEntity.getEditStatus()); child.setEditStatus(parentEntity.getEditStatus());
child.setDeviseName(parentEntity.getDeviseName()); child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode()); child.setDeviseUserCode(parentEntity.getDeviseUserCode());
child.setCreatedTime(parentEntity.getCreatedTime()); child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId()); if (parentEntity.getBomExist() == 1) {
child.setBomRowId(parentEntity.getRowId());
}
child.setLevelNum(parentEntity.getLevelNum()); child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName()); child.setDeptName(parentEntity.getDeptName());
child.setChangeDesc(parentEntity.getChangeDesc()); child.setChangeDesc(parentEntity.getChangeDesc());
@ -290,9 +297,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
if (parent.getStatus() < PBomStatusEnum.PUBLISH.getValue() && parentEntity.getStatus().equals(PBomStatusEnum.PUBLISH.getValue())) { if (parent.getStatus() < PBomStatusEnum.PUBLISH.getValue() && parentEntity.getStatus().equals(PBomStatusEnum.PUBLISH.getValue())) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue()); child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
} }
} else { //无BOM-版本时 确定版本号 } else { //无BOM-版本时 确定版本号
//child.setSource(Objects.nonNull(parent) ? parent.getSource() : EBomSourceEnum.FROM_BOM.getValue()); //child.setSource(Objects.nonNull(parent) ? parent.getSource() : EBomSourceEnum.FROM_BOM.getValue());
child.setDeviseUserCode(parent.getDeviseUserCode()); child.setDeviseUserCode(parent.getDeviseUserCode());
child.setDeviseName(parent.getDeviseName()); child.setDeviseName(parent.getDeviseName());
@ -304,11 +309,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
child.setTechnologyUserName(parent.getTechnologyUserName()); child.setTechnologyUserName(parent.getTechnologyUserName());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) { if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(parent.getStatus()); } else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
} }
} }
} }
} }
@ -328,16 +331,20 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId()); BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId());
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误该BOM不存在"); VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误该BOM不存在");
LogRecordContext.putVariable("bom",parent); LogRecordContext.putVariable("bom",parent);
parent.setEditStatus(editStatus.getValue());
parent.setModifyTime(LocalDateTime.now());
this.updateById(parent);
if (CollUtil.isNotEmpty(paramDTO.getChildList())) { if (CollUtil.isNotEmpty(paramDTO.getChildList())) {
List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList()); List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList());
childList.forEach(u -> u.setParentRowId(paramDTO.getBomRowId())); childList.forEach(u -> u.setParentRowId(paramDTO.getBomRowId()));
pbomChildService.saveOrUpdateBatch(childList); pbomChildService.saveOrUpdateBatch(childList);
parent.setBomExist(1);
} else {
parent.setBomExist(0);
} }
parent.setEditStatus(editStatus.getValue());
parent.setModifyTime(LocalDateTime.now());
this.updateById(parent);
if (editStatus == PBomEditStatusEnum.HANDLER_TEMP) { if (editStatus == PBomEditStatusEnum.HANDLER_TEMP) {
return getChild(parent); return getChild(parent);
} else { } else {
@ -406,16 +413,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
// 机加工件 的子级可直接删除 // 机加工件 的子级可直接删除
if (parentVO.getMaterialCategoryCode().startsWith("200301")) { if (parentVO.getMaterialCategoryCode().startsWith("200301")) {
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList()); pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
resetBomExist(parent.getRowId());
return hasTechnologypackage; return hasTechnologypackage;
} }
//删除辅助物料 //删除辅助物料
List<BomNewPbomParentVO> noDelList = childListVO.stream() List<BomNewPbomParentVO> noDelList = childListVO.stream()
.filter(u -> !u.getMaterialCategoryCode().startsWith("1003") && !u.getMaterialCategoryCode().startsWith("1020") && !u.getMaterialCategoryCode().startsWith("1021")) .filter(u -> !u.getMaterialCategoryCode().startsWith("1003") && !u.getMaterialCategoryCode().startsWith("1020") && !u.getMaterialCategoryCode().startsWith("1021"))
.collect(Collectors.toList()); .collect(Collectors.toList());
noDelList.removeAll(technologypackages);
VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料"); VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料");
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList()); pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
resetBomExist(parent.getRowId());
return hasTechnologypackage; return hasTechnologypackage;
} }
@ -1036,4 +1044,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
private void resetBomExist(Long rowId) {
this.getBaseMapper().resetBomExist(rowId);
}
} }

View File

@ -282,4 +282,10 @@
<select id="getCountForWaitReviewByMaterialNo" resultType="java.lang.Integer"> <select id="getCountForWaitReviewByMaterialNo" resultType="java.lang.Integer">
select COUNT(1) from t_bom_new_ebom_child where material_no=#{materialNo} and edit_status=1 select COUNT(1) from t_bom_new_ebom_child where material_no=#{materialNo} and edit_status=1
</select> </select>
<select id="resetBomExist">
UPDATE t_bom_new_ebom_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_ebom_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.row_id = #{rowId};
</select>
</mapper> </mapper>

View File

@ -226,6 +226,11 @@
<foreach collection="drawingNos" item="item" open="(" separator="," close=")"> <foreach collection="drawingNos" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</select>
<select id="resetBomExist">
UPDATE t_bom_new_original_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_original_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.row_id = #{rowId};
</select> </select>
</mapper> </mapper>

View File

@ -222,4 +222,10 @@
</foreach> </foreach>
order by created_time desc order by created_time desc
</select> </select>
<select id="resetBomExist">
UPDATE t_bom_new_pbom_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_pbom_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.row_id = #{rowId};
</select>
</mapper> </mapper>