Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

This commit is contained in:
jing's 2024-03-21 13:15:55 +08:00
commit 3637302695
3 changed files with 34 additions and 16 deletions

View File

@ -157,16 +157,16 @@ public class OriginalBomApi extends BaseApi {
@LogRecord(success = "删除BOM-图号:{{#bom.drawingNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}",
bizNo = "{{#bomRowIds.toString()}}" ,type = "原始BOM转Ebom")
@Transactional(rollbackFor = Exception.class)
public ResultVO<Boolean> convertToEBom(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException {
public ResultVO<List<ImportOriginalBomVO>> convertToEBom(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM");
VUtils.isTure(bomRowIds.size() > 20).throwMessage("你选择的BOM数据大于20");
originalParentService.convertToEBom(bomRowIds);
List<ImportOriginalBomVO> result = originalParentService.convertToEBom(bomRowIds);
//更新物料使用
bomNewEbomChildMapper.updateEBomMaterialUse();
//更新-原始BOM跟节点
CompletableFuture.runAsync(()->{
CompletableFuture.runAsync(() -> {
originalParentService.getBaseMapper().updateRootState_2(OriginalStatusEnum.OVER_CONVERT.getValue());
originalParentService.getBaseMapper().updateRootState_3(OriginalStatusEnum.OVER_CONVERT.getValue());
});
@ -174,9 +174,7 @@ public class OriginalBomApi extends BaseApi {
//跟新EBom 根节点
ebomParentService.getBaseMapper().updateRootState();
return ResultVO.success(true);
return ResultVO.success(result);
}
@GetMapping("getOriginalBomExcelTemplate")

View File

@ -10,6 +10,7 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@ -23,10 +24,7 @@ import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomMaterialUseEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.*;
@ -256,7 +254,21 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public Page<BomNewEbomParentVO> formalWorksheet(BomNewEbomParentQuery query) {
Page<BomNewEbomParentVO> result = this.getBaseMapper().formalWorksheet(new Page<>(query.getPage(), query.getPageSize()), query);
materialMainService.intiMaterialInfo(result.getRecords());
if (CollUtil.isNotEmpty(result.getRecords())) {
materialMainService.intiMaterialInfo(result.getRecords());
} else {
//查bom是否存在
LambdaQueryWrapper<BomNewEbomChildEntity> wrapper = new LambdaQueryWrapper<>();
if (StrUtil.isNotBlank(query.getDrawingNo())) {
wrapper.eq(BomNewEbomChildEntity::getDrawingNo, query.getDrawingNo());
} else if (StrUtil.isNotBlank(query.getMaterialNo())) {
wrapper.eq(BomNewEbomChildEntity::getMaterialNo, query.getMaterialNo());
}
if (wrapper.nonEmptyOfWhere() && ebomChildService.getBaseMapper().selectCount(wrapper) > 0) {
VUtils.isTure(true).throwMessage("不存在此BOM物料");
}
}
return result;
}
@ -1141,6 +1153,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
throw new NflgBusinessException(STATE.Error, "退回设计失败");
}
ebomChildService.update(childWrapper);
} else {
VUtils.isTure(true).throwMessage("没有需要退回设计的物料");
}
//重新创建保存list 避免污染

View File

@ -472,32 +472,38 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
*
* @return
*/
public Boolean convertToEBom(List<Long> bomRowIds) throws ExecutionException, InterruptedException {
public List<ImportOriginalBomVO> convertToEBom(List<Long> bomRowIds) throws ExecutionException, InterruptedException {
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");
//检查有子级的物料编码不能为空
List<ImportOriginalBomVO> importOriginalBomVOList = new ArrayList<>();
//开始转换
for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) {
if (!Objects.equals(parent.getCreatedBy(), SessionUtil.getUserCode())){
importOriginalBomVOList.add(new ImportOriginalBomVO(parent.getDrawingNo(),"非本人创建"));
log.warn(SessionUtil.getRealName()+"("+SessionUtil.getUserCode()+")转换原始bom("+parent.getRowId().toString()+")到ebom的操作被阻止");
continue;
}
LogRecordContext.putVariable("bom",parent);
Long ebomRowId = IdWorker.getId();
convertToEBomDo(parent, ebomRowId);
try {
convertToEBomDo(parent, ebomRowId);
} catch (Exception e) {
importOriginalBomVOList.add(new ImportOriginalBomVO(parent.getDrawingNo(), "操作失败:" + e.getMessage()));
throw e;
}
//更新并保存异常信息
ebomParentService.checkAndSaveEBomException(ebomRowId);
}
return true;
return importOriginalBomVOList;
}
/**