Merge remote-tracking branch 'origin/feature/DM/nflg-bom' into feature/DM/nflg-bom

This commit is contained in:
luoliming 2023-12-24 15:26:53 +08:00
commit 8c65e78750
14 changed files with 300 additions and 240 deletions

View File

@ -208,11 +208,12 @@ public class EbomApi extends BaseApi {
@PostMapping("revertDesign")
@ApiOperation("退回到设计")
public ResultVO<Boolean> revertDesign(@RequestBody BomNewEBomRevertDTO dto) {
public ResultVO<Boolean> revertDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isEmpty(dto.getRowIdList())) {
return ResultVO.error(STATE.ParamErr, "请选择要退回的数据");
}
dto.setRevertUserName(SessionUtil.getUserName());
dto.setUserCode(SessionUtil.getUserCode());
bomNewEbomParentService.revertDesign(dto);
return ResultVO.success(true);
@ -221,14 +222,15 @@ public class EbomApi extends BaseApi {
@PostMapping("reviewDesign")
@ApiOperation("设计复核")
public ResultVO<Boolean> reviewDesign(@RequestBody BomNewEBomRevertDTO dto) {
public ResultVO<Boolean> reviewDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isEmpty(dto.getRowIdList())) {
return ResultVO.error(STATE.ParamErr, "请选择要复核的数据");
}
dto.setRevertUserName(SessionUtil.getUserName());
return bomNewEbomParentService.designReview(dto);
dto.setUserCode(SessionUtil.getUserCode());
bomNewEbomParentService.designReview(dto);
return ResultVO.success(true);
}
@ -270,8 +272,8 @@ public class EbomApi extends BaseApi {
@GetMapping("delete")
@ApiOperation("删除物料")
public ResultVO<Boolean> deleteMaterial(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
bomNewEbomParentService.deleteMaterial(bomRowId);
public ResultVO<Boolean> deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
bomNewEbomParentService.deleteBom(bomRowId);
bomNewEbomParentService.computeLevelNumAndRootState();
return ResultVO.success(true);
}
@ -291,7 +293,7 @@ public class EbomApi extends BaseApi {
@PostMapping("submit")
@ApiOperation("提交")
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) {
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
return ResultVO.success(bomNewEbomParentService.submit(dto));
}

View File

@ -47,7 +47,7 @@ import java.util.concurrent.ExecutionException;
@Api(tags = "原始BOM")
@RestController
@RequestMapping("bom/new/bomOriginal")
public class OriginalBomApi extends BaseApi {
public class OriginalBomApi extends BaseApi {
@Resource
BomNewOriginalParentService originalParentService;
@ -78,15 +78,16 @@ public class OriginalBomApi extends BaseApi {
public ResultVO<List<TreeNode<BomOriginalListVO>>> getChildTree(@RequestParam("rowId") Long rowId) throws ExecutionException, InterruptedException {
return ResultVO.success(originalParentService.getChildTree(rowId));
}
@PostMapping("saveBom")
@ApiOperation("编辑时-暂存")
public ResultVO<Boolean> saveBom(@Valid @RequestBody OriginalSaveBomDTO bom) {
return ResultVO.success(originalParentService.saveBom(bom,false));
return ResultVO.success(originalParentService.saveBom(bom, false));
}
@PostMapping("saveSubmit")
@ApiOperation("编辑时-提交")
public ResultVO<Boolean> saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) {
public ResultVO<Boolean> saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) {
return ResultVO.success(originalParentService.saveSubmit(bom));
}
@ -120,6 +121,7 @@ public class OriginalBomApi extends BaseApi {
/**
* 原始BOM转EBom
*
* @return
*/
@PostMapping("convertToEBom")
@ -128,7 +130,7 @@ public class OriginalBomApi extends BaseApi {
public ResultVO<Boolean> convertToEBom(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM");
VUtils.isTure(bomRowIds.size()>20).throwMessage("你选择的BOM数据大于20");
VUtils.isTure(bomRowIds.size() > 20).throwMessage("你选择的BOM数据大于20");
originalParentService.convertToEBom(bomRowIds);
//更新物料使用
bomNewEbomChildMapper.updateEBomMaterialUse();
@ -152,7 +154,7 @@ public class OriginalBomApi extends BaseApi {
@ApiOperation("导入")
@PostMapping("importBom")
@Transactional(rollbackFor = Exception.class)
public ResultVO<Boolean> importBom(@RequestParam(value = "file")MultipartFile file) throws IOException {
public ResultVO<Boolean> importBom(@RequestParam(value = "file") MultipartFile file) throws IOException {
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) {
return ResultVO.error("请上传Excel文件");
}
@ -160,12 +162,7 @@ public class OriginalBomApi extends BaseApi {
//计算层级
originalParentService.computeLevelNumAndRootState();
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
// @Override
// public void afterCommit() {
// originalParentService.computeLevelNumAndRootState();
// }
// });
return ResultVO.success(true);
}
@ -174,18 +171,18 @@ public class OriginalBomApi extends BaseApi {
@ApiOperation("新增物料")
@GetMapping("testaddMaterial")
@Transactional(rollbackFor = Exception.class)
public ResultVO<String> testaddMaterial(@RequestParam(value = "drawingNo" ,required = false)String drawingNo,
@RequestParam(value = "materialName" ,required = false)String materialName,
@RequestParam("materialCategoryCode")String materialCategoryCode) throws IOException {
public ResultVO<String> testaddMaterial(@RequestParam(value = "drawingNo", required = false) String drawingNo,
@RequestParam(value = "materialName", required = false) String materialName,
@RequestParam("materialCategoryCode") String materialCategoryCode) throws IOException {
materialService.addMaterial(drawingNo, materialName,materialCategoryCode);
materialService.addMaterial(drawingNo, materialName, materialCategoryCode);
return ResultVO.success("true");
}
@ApiOperation("获取sessionKey")
@GetMapping("getSessionKey")
public ResultVO<String> getSessionKey() {
public ResultVO<String> getSessionKey() {
return ResultVO.success(SessionUtil.getSessionKey());
@ -196,19 +193,16 @@ public class OriginalBomApi extends BaseApi {
@PostMapping("testImportBom")
@Transactional(rollbackFor = Exception.class)
public ResultVO<Boolean> testImportBom() throws IOException {
InputStream inputStream=new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx");
InputStream inputStream = new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx");
originalParentService.importBomTest(inputStream);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
originalParentService.computeLevelNumAndRootState();
}
});
// originalParentService.computeLevelNumAndRootState();
originalParentService.computeLevelNumAndRootState();
return ResultVO.success(true);
}
}

View File

@ -39,4 +39,20 @@ public enum EBomExceptionStatusEnum implements ValueEnum<Integer> {
private final Integer value;
private final String description;
public static EBomExceptionStatusEnum findEnumByCode(Integer code) {
for (EBomExceptionStatusEnum statusEnum : EBomExceptionStatusEnum.values()) {
if (statusEnum.getValue().equals(code)) {
return statusEnum;
}
}
throw new IllegalArgumentException("code is invalid");
}
public static String code2description(Integer code) {
return findEnumByCode(code).getDescription();
}
}

View File

@ -32,7 +32,9 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum<Integer> {
@AllArgsConstructor
public enum ProjectTypeEnum implements ValueEnum<String> {
TYPE_Q("Q", "Q"),
TYPE_F("F", "F");
TYPE_F("F", "F"),
TYPE_Z("Z", "Z"),
TYPE_L("L", "L");
private final String value;
private final String description;

View File

@ -33,5 +33,8 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
/**
* 更新是否根节点状态
*/
void updateRootState();
void updateRootState_1();
void updateRootState_2();
void updateRootState_3();
}

View File

@ -15,9 +15,12 @@ public class BomNewEBomRevertDTO {
//退回人
@ApiModelProperty("忽略不是必填")
private String revertUserName;
@ApiModelProperty("忽略不是必填")
private String userCode;
@ApiModelProperty("行id列表")
@ApiModelProperty("必填,行id列表")
private List<Long> rowIdList;
}

View File

@ -295,8 +295,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public List<BomNewEbomParentVO> buildBomTree(Long rowId) throws Exception {
return getBomTree(rowId);
public List<BomNewEbomParentVO> buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> list= getBomTree(rowId);
BomNewEbomParentVO parentVO=Convert.convert(BomNewEbomParentVO.class,this.getById(rowId));
if(parentVO!=null) {
parentVO.setBomRowId(rowId);
parentVO.setParentRowId(0L);
list.add(parentVO);
}
return list;
}
@ -583,7 +591,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Transactional(rollbackFor = Exception.class)
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException {
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
@ -597,7 +604,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
bomNewEBomParentEditDTO.setParent(dto.getParent());
bomNewEBomParentEditDTO.setDatas(datas);
eBomEdit.temporary(bomNewEBomParentEditDTO);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
}
@ -669,51 +682,75 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 退回设计
*/
// @Transactional(rollbackFor = Exception.class)
public void revertDesign(BomNewEBomRevertDTO dto) {
public void revertDesign(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
List<Long> rowIds = dto.getRowIdList();
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
// List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回");
// throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回");
VUtils.isTure(true).throwMessage("下级BOM无法进行退回");
}
if (rowIds.size() != bomNewEbomParentEntityList.size()) {
throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回");
// throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回");
VUtils.isTure(true).throwMessage("选择数据中包含有下级BOM无法进行退回");
}
List<BomNewEbomParentEntity> waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList());
List<BomNewEbomParentEntity> revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList());
List<BomNewEbomParentEntity> pbomList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(waitList)) {
List<String> materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
List<Long> revertList=new ArrayList<>();
for (Long bomRowId:
rowIds) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList)));
}
if (CollUtil.isNotEmpty(revertList)) {
List<String> materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
List<BomNewEbomParentVO> bomTreeList= buildBomTreeContainSelf(bomRowId);
//
//
//
// List<BomNewEbomParentEntity> waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList());
// List<BomNewEbomParentEntity> revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList());
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList)));
}
if (pbomList.size() > 0) {
List<String> materialNoList = pbomList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
List<BomNewEbomParentVO> pbomList = bomTreeList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList());
// if (CollUtil.isNotEmpty(waitList)) {
// List<String> materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
//
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList)));
// }
// if (CollUtil.isNotEmpty(revertList)) {
// List<String> materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
//
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList)));
// }
if (pbomList.size() > 0) {
List<String> materialNoList = pbomList.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList());
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM无法退回设计", StrUtil.join(",", materialNoList)));
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM无法退回设计", StrUtil.join(",", materialNoList)));
}
//忽略叶子节点
revertList.addAll(bomTreeList.stream()
.filter(u->u.getBomRowId()>0)
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
}
//重新创建保存list 避免污染
List<BomNewEbomParentEntity> updateList = new ArrayList<>();
bomNewEbomParentEntityList.forEach(item -> {
for (Long rowId : revertList) {
BomNewEbomParentEntity entity = new BomNewEbomParentEntity();
entity.setRowId(item.getRowId());
entity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
entity.setRowId(rowId);
entity.setEditStatus(EBomStatusEnum.RETURNED.getValue());
entity.setRevertTime(LocalDateTime.now());
entity.setRevertUserName(dto.getRevertUserName());
updateList.add(entity);
});
}
if (!this.updateBatchById(updateList)) {
throw new NflgBusinessException(STATE.Error, "退回设计失败");
@ -731,144 +768,63 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 6. 是否存在已冻结/永久禁用的物料
*/
// @Transactional(rollbackFor = Exception.class)
public ResultVO<Boolean> designReview(BomNewEBomRevertDTO dto) {
public Boolean designReview(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
List<Long> rowIds = dto.getRowIdList();
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
return ResultVO.error("下级BOM无法进行复核");
// return ResultVO.error("下级BOM无法进行复核");
VUtils.isTure(true).throwMessage("下级BOM无法进行复核");
}
if (rowIds.size() != bomNewEbomParentEntityList.size()) {
return ResultVO.error("选择数据中包含有下级BOM无法进行复核");
}
for (BomNewEbomParentEntity item :
bomNewEbomParentEntityList) {
if (item.getStatus().equals(EBomStatusEnum.CHECKED.getValue())) {
return ResultVO.error(StrUtil.format("{} 已复核过,不需重复复核", item.getMaterialNo()));
}
if (item.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) {
return ResultVO.error("请调整数据后进行复核");
}
if (item.getNum().equals(EbomEditStatusEnum.HANDLER_CREATED.getValue())) {
return ResultVO.error("请先提交确认后进行复核");
}
if (StrUtil.isEmpty(item.getMaterialNo()) || (item.getNum() == null || item.getNum().floatValue() == 0)) {
return ResultVO.error(EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription());
}
MaterialMainEntity entity = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, item.getMaterialNo()).one();
if (entity == null) {
return ResultVO.error("物料编码[" + item.getMaterialNo() + "]物料不存在");
}
if (Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_4)
|| Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_5)) {
return ResultVO.error("物料编码[" + item.getMaterialNo() + "]冻结/完全弃用异常");
}
VUtils.isTure(true).throwMessage("数据中包含有下级BOM无法进行复核");
// return ResultVO.error("数据中包含有下级BOM无法进行复核");
}
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_6.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_7.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_8.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_9.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()
});
List<Long> updateReviewIdList = new ArrayList<>();
//子bom检查
for (BomNewEbomParentEntity item :
bomNewEbomParentEntityList) {
List<BomNewEbomParentVO> childBomList;
try {
childBomList = buildBomTree(item.getRowId());
} catch (Exception e) {
return ResultVO.error("获取Bom数据失败");
}
if (CollUtil.isNotEmpty(childBomList)) {
for (BomNewEbomParentVO childBomItem :
childBomList) {
if (childBomItem.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) {
return ResultVO.error("请调整数据后进行复核");
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_2.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_3.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_6.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_6.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_8.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_9.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_10.getDescription()));
}
}
}
updateReviewIdList.addAll(childBomList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
for (Long bomRowId:
rowIds) {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId);
//错误状态包含在checkStatus内有异常抛出
checkEBomException.checkContainExcept(checkStatus);
//筛选bomRowId()>0 说明有bom更新只到parent这层无bom不需要更新
//设计人员只可以复核自己的物料如果存在引用其他用户创建的物料时不可以改变被引用物料的审核状态
updateReviewIdList.addAll( checkEBomException.getAllBomDetail().stream()
.filter(u->u.getBomRowId()>0
&& u.getCreatedBy().equals(dto.getUserCode()))
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
}
//改变复核状态
List<BomNewEbomParentEntity> updateReviewList = new ArrayList<>();
for (Long id : updateReviewIdList) {
BomNewEbomParentEntity entity = new BomNewEbomParentEntity();
entity.setRowId(id);
entity.setAuditTime(LocalDateTime.now());
entity.setAuditUserName(dto.getRevertUserName());
entity.setStatus(EBomStatusEnum.CHECKED.getValue());
updateReviewList.add(entity);
}
if (!this.updateBatchById(updateReviewList)) {
throw new NflgBusinessException(STATE.Error, "复核失败");
}
return ResultVO.success(true);
return true;
}
@ -902,6 +858,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class,parent);
parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l);
// List<BomNewEbomParentVO> parentList = new ArrayList<>();
// parentList.add(parentVO);
// materialMainService.intiMaterialInfo(parentList);
@ -950,12 +907,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public Boolean deleteMaterial(Long bomRowId) throws ExecutionException, InterruptedException {
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
VUtils.isTure(Objects.isNull(parentEntity)).throwMessage("该节点不存在,请检查参数是否正确");
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
@ -980,6 +938,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
return true;
}
@ -1016,18 +976,46 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/**
* 提交物料
*
* 1.
*/
public Boolean submit(BomNewEBomParentEditDTO dto) {
public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto);
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_6.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_7.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_8.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_9.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()
});
List<BomNewEbomParentVO> allBom =Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
},eBomEdit.childEntities);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){
allBom.add(Convert.convert(BomNewEbomParentVO.class,eBomEdit.parentEntities.get(0)));
}
CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.checkContainExcept(checkStatus);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
if (dto.getParent() != null) {
if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.base.core.config.SpringContextUtils;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.OriginalConstant;
import com.nflg.product.bomnew.constant.OriginalEditStatusEnum;
import com.nflg.product.bomnew.constant.OriginalSourceEnum;
@ -99,22 +100,22 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
* @param bom
* @return
*/
public Boolean saveBom(OriginalSaveBomDTO bom ,Boolean submitIs) {
public Boolean saveBom(OriginalSaveBomDTO bom, Boolean submitIs) {
List<BomOriginalListVO> saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList());
List<BomNewOriginalChildEntity> childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts);
// originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId()));
childEntities.forEach(u -> {
u.setParentRowId(bom.getParentRowId());
if(submitIs){
if (submitIs) {
u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
}
});
if (CollUtil.isNotEmpty(childEntities)) {
//删除行
List<Long> delRowIds = bom.getBomList().stream().filter(u->u.getRowId()>0).map(u-> u.getRowId()).collect(Collectors.toList());
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds,bom.getParentRowId());
List<Long> delRowIds = bom.getBomList().stream().filter(u -> u.getRowId() > 0).map(u -> u.getRowId()).collect(Collectors.toList());
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId());
originalChildService.saveOrUpdateBatch(childEntities);
}
return true;
@ -128,7 +129,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
* @return
*/
public Boolean saveSubmit(OriginalSaveBomDTO bom) {
saveBom(bom,true);
saveBom(bom, true);
//将状态变为已处理
BomNewOriginalParentEntity parentEntity = new BomNewOriginalParentEntity();
parentEntity.setRowId(bom.getParentRowId());
@ -161,13 +162,13 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
child.setStatus(parentEntity.getStatus());
child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode());
// child.setCreatedBy(parentEntity.getCreatedBy());
// child.setCreatedTime(parentEntity.getCreatedTime());
// child.setCreatedBy(parentEntity.getCreatedBy());
// child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId());
child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName());
child.setSource(parentEntity.getSource());
if(parentEntity.getStatus().equals(OriginalStatusEnum.OVER_CONVERT)){
if (parentEntity.getStatus().equals(OriginalStatusEnum.OVER_CONVERT)) {
child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue());
}
//非本人则为借用件
@ -233,7 +234,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
if (CollUtil.isNotEmpty(list)) {
for (BomNewOriginalParentEntity bom : list) {
bom.setRootIs(1);
// bom.setRootIs(1);
List<BomOriginalListVO> bomDetail = this.getBaseMapper().getParentChild(bom.getRowId());
OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail);
detailTask.setLevelNum(1);
@ -284,16 +285,18 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
* 计算层级数和根节点状态
*/
public void computeLevelNumAndRootState() {
//计算树的层级数
// CompletableFuture.runAsync(() -> {
try {
this.getBaseMapper().updateRootState();
this.compucteLevelNum();
} catch (Exception e) {
log.info("计算层级出错:"+e.getMessage());
}
// });
try {
this.getBaseMapper().updateRootState_1();
this.getBaseMapper().updateRootState_2();
this.getBaseMapper().updateRootState_3();
this.compucteLevelNum();
} catch (Exception e) {
log.info("计算层级出错:" + e.getMessage());
}
}
@ -310,8 +313,8 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
List<BomOriginalListVO> bomTree = getBomTree(bomRowId);
//需删除的BOM
List<BomOriginalListVO> delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList());
List<Long> delParentRowId=new ArrayList<>();
for ( BomOriginalListVO bom: delBom) {
List<Long> delParentRowId = new ArrayList<>();
for (BomOriginalListVO bom : delBom) {
delParentRowId.add(bom.getBomRowId());
}
delParentRowId.add(bomRowId);
@ -333,7 +336,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
List<BomNewOriginalParentEntity> bomNewOriginalParentEntities = this.getBaseMapper().selectBatchIds(bomRowIds);
List<BomNewOriginalParentEntity> convertedBom = bomNewOriginalParentEntities.stream().filter(u -> OriginalStatusEnum.OVER_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList());
// VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM");
// VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM");
//开始转换
for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) {
@ -385,17 +388,16 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
/**
* 原始BOM导入
*/
@Transactional(rollbackFor = Exception.class)
public void importBom(MultipartFile file) throws IOException {
rowNum.set(1);
excelContextTL.set(new ArrayList<>());
String uuid = IdUtil.simpleUUID();
EecExcelUtil.handlerExcel(file.getInputStream(), BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow);
List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get();
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空");
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空");
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空");
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空");
// List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList());
// VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空");
@ -410,7 +412,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert();
List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(chileds)) {
int i=1;
int i = 1;
for (BomNewOriginalExcelDTO ch : chileds) {
ch.setOrderNo(i);
i++;
@ -430,8 +432,8 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
public static void handlerExcelRow(BomNewOriginalExcelDTO data) {
data.setRowNum(rowNum.get());
// data.setOrderNo(data.getLevelNo());
data.setChartNo(StrUtil.trim(data.getChartNo()).replace("","(").replace("",")").replace(" ",""));
// data.setOrderNo(data.getLevelNo());
data.setChartNo(StrUtil.trim(data.getChartNo()).replace("", "(").replace("", ")").replace(" ", ""));
rowNum.set(rowNum.get() + 1);
excelContextTL.get().add(data);
@ -446,12 +448,12 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
String uuid = IdUtil.simpleUUID();
EecExcelUtil.handlerExcel(file, BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow);
List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get();
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空");
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空");
List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空");
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空");
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空");
List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage(StrUtil.join(",", noNum) + "数量为空");
for (BomNewOriginalExcelDTO data : excelContext) {
List<BomNewOriginalExcelDTO> parentData = excelContext.stream().filter(u -> u.getLevelNo().equals(data.getLevelNo() - 1) && u.getRowNum() < data.getRowNum())
@ -464,7 +466,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert();
List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(chileds)) {
int i=1;
int i = 1;
for (BomNewOriginalExcelDTO ch : chileds) {
ch.setOrderNo(i);
i++;

View File

@ -1,18 +1,25 @@
package com.nflg.product.bomnew.service.domain.EBom;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.MaterialGetEnum;
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.service.BomNewEbomParentService;
import com.nflg.product.bomnew.service.MaterialMainService;
import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.TreeUtils;
import com.nflg.product.bomnew.util.VUtils;
import lombok.Getter;
import nflg.product.common.constant.STATE;
import java.math.BigDecimal;
import java.util.ArrayList;
@ -31,12 +38,16 @@ public class CheckEBomException {
List<BomNewEbomParentVO> allBomDetail ;
public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId);
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent);
convert.setBomRowId(convert.getRowId());
convert.setParentRowId(0L);
allBomDetail.add(convert);
// allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId);
// BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
// BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent);
// convert.setBomRowId(convert.getRowId());
// convert.setParentRowId(0L);
// allBomDetail.add(convert);
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId);
}
/**
@ -58,9 +69,14 @@ public class CheckEBomException {
if(Objects.isNull(vo.getExceptionStatus())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
}
if (StrUtil.isNotBlank(vo.getMaterialNo()) && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState()) || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) {
if (StrUtil.isNotBlank(vo.getMaterialNo())
&& (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState())
|| MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else if (StrUtil.isBlank(vo.getMaterialNo()) || Objects.isNull(vo.getNum()) || (Objects.nonNull(vo.getNum()) && BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) {
} else if (StrUtil.isBlank(vo.getMaterialNo())
|| Objects.isNull(vo.getNum())
|| (Objects.nonNull(vo.getNum())
&& BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue());
} else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
@ -106,15 +122,15 @@ public class CheckEBomException {
}
}
if ("Q".equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> "Q".equals(u.getProjectType())).collect(Collectors.toList());
if (ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.equals(u.getProjectType())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(qList)) {
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue()));
}
}
if ("F".equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> "F".equals(u.getProjectType())).collect(Collectors.toList());
if (ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.equals(u.getProjectType())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(qList)) {
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()));
@ -138,4 +154,32 @@ public class CheckEBomException {
}
}
public void checkContainExcept(List<Integer> codeList) throws NflgBusinessException {
if(CollUtil.isEmpty(codeList))return;
for (BomNewEbomParentVO item:
allBomDetail) {
//并集 寻找相同
List<Integer> list=CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList());;
if(CollUtil.isNotEmpty(list)){
throw new NflgBusinessException(STATE.BusinessError, EBomExceptionStatusEnum.code2description(list.get(0)));
}
}
}
}

View File

@ -45,8 +45,6 @@ public class EBomEdit {
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent, vo);
@ -73,6 +71,7 @@ public class EBomEdit {
parent.setBomExist(1);
parent.setLastVersionIs(1);
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
if(StrUtil.isEmpty(parent.getProjectType())){
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
}
@ -96,7 +95,6 @@ public class EBomEdit {
List<String> materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
//检查物料编码是否在主数据中存在
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
@ -143,7 +141,10 @@ public class EBomEdit {
child.setCreatedTime(LocalDateTime.now());
child.setCreatedBy(SessionUtil.getUserCode());
child.setSourceRowId(0l);
}
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
}
parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));

View File

@ -133,7 +133,7 @@ public class EbomInitProjectType {
sameLevelChild = getChilds(child.getParentRowId());
sResult = sameLevelChild.stream().filter(u -> u.getMaterialCategoryCode().startsWith("2005") || u.getMaterialCategoryCode().startsWith("2006")).collect(Collectors.toList());
if (CollUtil.isNotEmpty(sResult)) {
List<String> projectType = sResult.stream().map(u -> u.getProjectType()).distinct().collect(Collectors.toList());
List<String> projectType = sResult.stream().filter(u->StrUtil.isNotBlank(u.getProjectType())).map(u -> u.getProjectType()).distinct().collect(Collectors.toList());
if (projectType.size() == 1 && projectType.get(0).equals("Q")) {
child.setProjectType("Q");
}

View File

@ -231,6 +231,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
eBomParent.setConvertToEbomTime(LocalDateTime.now());
eBomParent.setSourceRowId(parentEnt.getBomRowId());
eBomParent.setLastVersionIs(1);
eBomParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
eBomParent.setModifyTime(LocalDateTime.now());
eBomParent.setBomExist(parentEnt.getBomRowId()>0?1:0);
//工艺岗直接到已复核

View File

@ -82,12 +82,12 @@
<!--Ebom工作列表-->
<select id="getEBomListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
<if test="job==0">
select * ,row_id as bomRowId from t_bom_new_ebom_parent where status=1 and created_by=#{createdBy} and user_root_is=1 and
select * ,row_id as bomRowId from t_bom_new_ebom_parent where created_by=#{createdBy} and user_root_is=1 and
(status=1 or status=3)
<include refid="whr"/>
</if>
<if test="job==1">
select * ,row_id as bomRowId from t_bom_new_ebom_parent where status=2 and user_root_is=1 and ( status=2 or status=4 )
select * ,row_id as bomRowId from t_bom_new_ebom_parent where user_root_is=1 and ( status=2 or status=4 )
<include refid="whr"/>
</if>
</select>
@ -119,7 +119,7 @@
<!--BOM-正式工作表-->
<select id="formalWorksheet" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
select row_id as bomRowId, * from t_bom_new_ebom_parent where status=4
select * , row_id as bomRowId from t_bom_new_ebom_parent where status=4
<include refid="whr"/>
</select>

View File

@ -48,7 +48,7 @@
and status=2
<if test="query.startDate==null or query.startDate==''">
and created_time> DATE_ADD(now(), INTERVAL -3 DAY)
and convert_to_ebom_time> DATE_ADD(now(), INTERVAL -3 DAY)
</if>
</if>
<if test="query.status==1">
@ -111,7 +111,7 @@
</delete>
<update id="updateBomState">
update t_bom_new_original_parent set status = #{status} where
update t_bom_new_original_parent set status = #{status},convert_to_ebom_time=now() where
row_id in
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
#{rowId}
@ -124,23 +124,27 @@
</foreach>;
</update>
<update id="updateRootState">
<update id="updateRootState_1">
update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1;
update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1
</update>
<update id="updateRootState_2">
update t_bom_new_original_parent a join (
select a.row_id from t_bom_new_original_parent a
left join t_bom_new_original_child b
on a.drawing_no=b.drawing_no
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1;
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1
</update>
<update id="updateRootState_3">
update t_bom_new_original_parent a join (
select a.row_id from t_bom_new_original_parent a
left join t_bom_new_original_child b
on a.drawing_no=b.drawing_no and a.created_by=b.created_by
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1;
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1
</update>
</mapper>