Merge branch 'refs/heads/feature/DM/nflg-bom' into feature/DM/nflg-bom-transition
This commit is contained in:
commit
1da8f1f7bb
|
|
@ -40,4 +40,6 @@ public interface BomNewOriginalChildMapper extends BaseMapper<BomNewOriginalChil
|
|||
* @param rowIds
|
||||
*/
|
||||
void syncOriginalBomToFormal(@Param("rowIds") List<Long> rowIds);
|
||||
|
||||
void deleteChildByParentRowIds(@Param("parentRowIds") List<Long> parentRowIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
|
@ -14,6 +15,7 @@ import com.nflg.product.bomnew.constant.BomConstant;
|
|||
import com.nflg.product.bomnew.constant.DQBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.UserJobEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.MaterialMainMapper;
|
||||
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
|
||||
|
|
@ -240,18 +242,48 @@ public class DQBomImportService {
|
|||
);
|
||||
}
|
||||
|
||||
List<String> materialNos = datas.stream().map(DQbomExcelVO::getMaterialNo).distinct().collect(Collectors.toList());
|
||||
errorMsg.addAll(datas.stream()
|
||||
.filter(d -> StrUtil.isBlank(d.getMaterialNo()) && StrUtil.isBlank(d.getDrawingNo()))
|
||||
.map(d -> OperationErrorMsgVO.create("第" + d.getRowNum() + "行", "编号和图号都为空"))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
//如果编号不为空,则图号使用主物料图号
|
||||
List<String> materialNos = datas.stream()
|
||||
.map(DQbomExcelVO::getMaterialNo)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
|
||||
datas.forEach(d -> {
|
||||
for (DQbomExcelVO d : datas) {
|
||||
BaseMaterialVO vo = materialBaseInfos.stream()
|
||||
.filter(m -> m.getMaterialNo().equals(d.getMaterialNo()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (!Objects.isNull(vo)) {
|
||||
if (Objects.nonNull(vo)) {
|
||||
d.setDrawingNo(vo.getDrawingNo());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//如果编号为空,图号不为空,则编号使用主物料编号
|
||||
List<String> drawingNos = datas.stream()
|
||||
.filter(d -> StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo()))
|
||||
.map(DQbomExcelVO::getDrawingNo)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos);
|
||||
for (DQbomExcelVO d : datas) {
|
||||
if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) {
|
||||
BaseMaterialVO vo = materialBaseInfos.stream()
|
||||
.filter(m -> m.getDrawingNo().equals(d.getDrawingNo()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.nonNull(vo)) {
|
||||
d.setMaterialNo(vo.getMaterialNo());
|
||||
} else {
|
||||
errorMsg.add(OperationErrorMsgVO.create("第" + d.getRowNum() + "行", "图号不存在"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
|
|
@ -266,27 +298,7 @@ public class DQBomImportService {
|
|||
BomNewDQbomParentEntity parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getMaterialNo()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
//if (parent == null && (count - 1 != index || datas.get(index + 1).getLevel() > data.getLevel())) {
|
||||
if (parent == null && count - 1 > index && datas.get(index + 1).getLevel() > data.getLevel()) {
|
||||
// if (index == 0) {
|
||||
// BomNewDQbomParentEntity old = dQBomParentService.lambdaQuery()
|
||||
// .eq(data.getProjectType().equals("L"), BomNewDQbomParentEntity::getMaterialNo, data.getMaterialNo())
|
||||
// .eq(data.getProjectType().equals("T"), BomNewDQbomParentEntity::getMaterialName, data.getMaterialName())
|
||||
// .orderByDesc(BomNewDQbomParentEntity::getRowId)
|
||||
// .last(" limit 1")
|
||||
// .one();
|
||||
// if (!Objects.isNull(old)) {
|
||||
// VUtils.isTure(Objects.equals(data.getMaterialUnit(), old.getMaterialUnit())
|
||||
// || Objects.equals(data.getNum(), old.getNum())
|
||||
// || Objects.equals(data.getMaterialTexture(), old.getMaterialTexture()))
|
||||
// .throwMessage("导入的数据已存在,请勿重复导入");
|
||||
// if (Objects.equals(old.getStatus(), DQBomStatusEnum.WAIT_CONVERT.getValue())) {
|
||||
// VUtils.isTure(!Objects.equals(old.getCreatedBy(), SessionUtil.getUserCode()))
|
||||
// .throwMessage(StrUtil.format("此物料已由{}导入过,不能再次导入", old.getCreatedName()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
parent = new BomNewDQbomParentEntity();
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setLevel(data.getLevel());
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
parentEntity.setMaterialTexture(baseMaterialVO.getMaterialTexture());
|
||||
parentEntity.setMaterialUnit("KG");
|
||||
parentEntity.setNum(parentEntity.getTotalWeight());
|
||||
parentEntity.setProjectType("L");
|
||||
} else {
|
||||
parentEntity.setMaterialDesc(parentEntity.getMaterialName());
|
||||
}
|
||||
|
|
@ -340,6 +341,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
childEntity.setNum(parent.getUnitWeight());
|
||||
childEntity.setCreatedBy(SessionUtil.getUserCode());
|
||||
childEntity.setMaterialUnit("KG");
|
||||
childEntity.setProjectType("L");
|
||||
|
||||
// this.eBomChildResult.add(childEntity);
|
||||
return childEntity;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class PlmBomToOriginalConvertV2 extends BaseConvert {
|
|||
originalParentService.getBaseMapper().deleteByMap(ImmutableMap.of("drawing_no", parent.getChartNo()));
|
||||
List<Long> oldParentRowIds = oldOriginalParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(oldParentRowIds)) {
|
||||
originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldOriginalParents));
|
||||
originalChildService.getBaseMapper().deleteChildByParentRowIds(oldParentRowIds);
|
||||
}
|
||||
//有子级(原始BOM-直接覆盖)
|
||||
if (CollUtil.isNotEmpty(childs)) {
|
||||
|
|
@ -198,6 +198,7 @@ public class PlmBomToOriginalConvertV2 extends BaseConvert {
|
|||
parentEntity.setMaterialName(baseMaterialVO.getMaterialName());
|
||||
parentEntity.setMaterialDesc(baseMaterialVO.getMaterialDesc());
|
||||
parentEntity.setMaterialTexture(baseMaterialVO.getMaterialTexture());
|
||||
parentEntity.setProjectType("L");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,4 +86,11 @@
|
|||
#{rowId}
|
||||
</foreach>;
|
||||
</insert>
|
||||
|
||||
<delete id="deleteChildByParentRowIds">
|
||||
delete from t_bom_new_original_child where parent_row_id in
|
||||
<foreach collection="parentRowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue