fix: 电气bom调整
This commit is contained in:
parent
150649ed65
commit
6e2fe973e0
|
|
@ -90,6 +90,11 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
|||
*/
|
||||
private String parentMaterialNo;
|
||||
|
||||
public String getParentMaterialNo() {
|
||||
if (StrUtil.isBlank(parentMaterialNo)) return "";
|
||||
return parentMaterialNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有子节点: 0-否 1-是
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class BomNewDQbomExceptionCheckService {
|
|||
private void checkParent(BomNewDQbomParentEntity parent) {
|
||||
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
|
||||
if (parent.getRootIs() == 1 || parent.getUserRootIs() == 1) {
|
||||
if ("T".equals(parent.getProjectType())) {
|
||||
if ("T".equals(parent.getProjectType()) || "Q".equals(parent.getProjectType())) {
|
||||
if (StrUtil.isBlank(parent.getMaterialName())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ public class BomNewDQbomExceptionCheckService {
|
|||
|
||||
private void checkChild(BomNewDQbomChildEntity child) {
|
||||
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
|
||||
if ("T".equals(child.getProjectType())) {
|
||||
if ("T".equals(child.getProjectType()) || "Q".equals(child.getProjectType())) {
|
||||
if (StrUtil.isBlank(child.getMaterialName())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.nflg.product.bomnew.constant.UserJobEnum;
|
|||
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
||||
|
|
@ -46,7 +47,7 @@ public class DQBomImportService {
|
|||
|
||||
public static final ThreadLocal<List<DQbomExcelVO>> excelContextTL = new ThreadLocal<>();
|
||||
|
||||
private static final List<String> TYPES = Arrays.asList("T", "L");
|
||||
// private static final List<String> TYPES = Arrays.asList("T", "L");
|
||||
|
||||
private static final Map<String, Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>>> BOMMAP = new HashMap<>();
|
||||
|
||||
|
|
@ -59,8 +60,8 @@ public class DQBomImportService {
|
|||
@Resource
|
||||
UserRoleService userRoleService;
|
||||
|
||||
// @Resource
|
||||
// MaterialMainService materialMainService;
|
||||
@Resource
|
||||
MaterialMainService materialMainService;
|
||||
|
||||
@Resource
|
||||
DQBomService dQBomService;
|
||||
|
|
@ -108,17 +109,31 @@ public class DQBomImportService {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
||||
Set<String> materialNos = parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toSet());
|
||||
List<BomNewDQbomParentEntity> oldParents = dQBomParentService.getLatestByMaterialNo(materialNos);
|
||||
//将导入图号重设为主物料图号
|
||||
Set<String> pMaterialNos = parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toSet());
|
||||
List<BomNewDQbomParentEntity> oldParents = dQBomParentService.getLatestByMaterialNo(pMaterialNos);
|
||||
Set<String> cMaterialNos = children.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet());
|
||||
cMaterialNos.addAll(pMaterialNos);
|
||||
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(new ArrayList<>(cMaterialNos));
|
||||
parents.forEach(p -> {
|
||||
BomNewDQbomParentEntity oldParent = oldParents.stream().filter(op -> op.getMaterialNo().equals(p.getMaterialNo())).findFirst().orElse(null);
|
||||
if (!Objects.isNull(oldParent) && Objects.equals(oldParent.getStatus(), DQBomStatusEnum.WAIT_CONVERT.getValue())) {
|
||||
dQBomParentService.getBaseMapper().deleteById(oldParent.getRowId());
|
||||
dQBomChildService.deleteAllChildren(oldParent.getRowId());
|
||||
}
|
||||
BaseMaterialVO vo = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(p.getMaterialNo())).findFirst().orElse(null);
|
||||
if (!Objects.isNull(vo)) {
|
||||
p.setDrawingNo(vo.getDrawingNo());
|
||||
}
|
||||
});
|
||||
dQBomParentService.setLastVersionIs0(materialNos);
|
||||
dQBomParentService.setLastVersionIs0(pMaterialNos);
|
||||
dQBomParentService.saveBatch(parents);
|
||||
children.forEach(c -> {
|
||||
BaseMaterialVO vo = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(c.getMaterialNo())).findFirst().orElse(null);
|
||||
if (!Objects.isNull(vo)) {
|
||||
c.setDrawingNo(vo.getDrawingNo());
|
||||
}
|
||||
});
|
||||
dQBomChildService.saveBatch(children);
|
||||
BomNewDQbomParentEntity root = parents.stream().filter(p -> p.getRootIs() == 1).findFirst().orElseThrow(() -> new NflgBusinessException(STATE.BusinessError, "根节点不存在"));
|
||||
dQBomService.checkException(root.getRowId());
|
||||
|
|
@ -234,14 +249,14 @@ public class DQBomImportService {
|
|||
);
|
||||
}
|
||||
|
||||
List<Integer> noProjectType = datas.stream().filter(u -> !TYPES.contains(u.getProjectType()))
|
||||
.map(BaseImportExcelDTO::getRowNum)
|
||||
.collect(Collectors.toList());
|
||||
if (!noProjectType.isEmpty()) {
|
||||
errorMsg.addAll(noProjectType.stream().map(n -> OperationErrorMsgVO.create("第" + n + "行", "项目类别不正确"))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
// List<Integer> noProjectType = datas.stream().filter(u -> !TYPES.contains(u.getProjectType()))
|
||||
// .map(BaseImportExcelDTO::getRowNum)
|
||||
// .collect(Collectors.toList());
|
||||
// if (!noProjectType.isEmpty()) {
|
||||
// errorMsg.addAll(noProjectType.stream().map(n -> OperationErrorMsgVO.create("第" + n + "行", "项目类别不正确"))
|
||||
// .collect(Collectors.toList())
|
||||
// );
|
||||
// }
|
||||
|
||||
List<Integer> remarkTooLong = datas.stream().filter(u -> StringUtil.CountForMysql(u.getRemark()) > 200)
|
||||
.map(BaseImportExcelDTO::getRowNum)
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@
|
|||
ifnull(p.exception_tag, c.exception_tag) exception_tag,
|
||||
ifnull(p.bom_exist, 0) bom_exist,
|
||||
ifnull(p.sap_state, 1) sap_state,
|
||||
ifnull(p.current_version, if(c.status = 1, 'A00', p2.current_version)) current_version,
|
||||
c.*
|
||||
FROM t_bom_new_dqbom_child c
|
||||
INNER JOIN t_bom_new_dqbom_parent p2 ON p2.row_id = c.parent_row_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue