Merge remote-tracking branch 'origin/feature/DM/nflg-bom' into feature/DM/nflg-bom
This commit is contained in:
commit
de3320b4f1
|
|
@ -13,10 +13,7 @@ import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
|||
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomEditDetailVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
|
|
@ -163,6 +160,7 @@ public class EbomApi extends BaseApi {
|
|||
return ResultVO.error("请上传Excel文件");
|
||||
}
|
||||
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(file.getInputStream(), BomNewEBomImportExcelDTO.class);
|
||||
|
||||
materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo);
|
||||
return ResultVO.success(result);
|
||||
}
|
||||
|
|
@ -180,18 +178,6 @@ public class EbomApi extends BaseApi {
|
|||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("createParentBom")
|
||||
@ApiOperation("创建根节点BOM")
|
||||
public ResultVO<Boolean> createParentBom(@RequestBody BomNewEBomCreateDTO createDTO) {
|
||||
VUtils.isTure(StrUtil.isBlank(createDTO.getMaterialNo())).throwMessage("物料编码不能为空");
|
||||
//子级物料编码不能为空
|
||||
VUtils.isTure(CollUtil.isEmpty(createDTO.getDatas())).throwMessage("子级不能为空");
|
||||
List<BomNewEBomImportExcelDTO> noMaterialList = createDTO.getDatas().stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noMaterialList)).throwMessage("子级存在物料编码为空的数据");
|
||||
bomNewEbomParentService.createBom(createDTO);
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("revertDesign")
|
||||
@ApiOperation("退回到设计")
|
||||
|
|
@ -231,7 +217,7 @@ public class EbomApi extends BaseApi {
|
|||
|
||||
@PostMapping("queryMaterial")
|
||||
@ApiOperation("查询物料信息")
|
||||
public ResultVO<BaseMaterialVO> queryMaterial(@RequestBody BomNewEbomMaterialQuery query) {
|
||||
public ResultVO<BomNewEbomParentVO> queryMaterial(@RequestBody BomNewEbomMaterialQuery query) {
|
||||
if (StringUtils.isEmpty(query.getDrawingNo()) && StringUtils.isEmpty(query.getMaterialNo())) {
|
||||
return ResultVO.error(STATE.Error, "图号或物料编码不能为空");
|
||||
}
|
||||
|
|
@ -242,6 +228,33 @@ public class EbomApi extends BaseApi {
|
|||
|
||||
|
||||
|
||||
@GetMapping("delete")
|
||||
@ApiOperation("删除物料")
|
||||
public ResultVO<Boolean> deleteMaterial(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
|
||||
bomNewEbomParentService.deleteMaterial(bomRowId);
|
||||
bomNewEbomParentService.computeLevelNumAndRootState();
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//temporary
|
||||
|
||||
|
||||
@PostMapping("temporary")
|
||||
@ApiOperation("暂存")
|
||||
public ResultVO<Boolean> temporary(@RequestBody BomNewEBomParentEditDTO dto) {
|
||||
return ResultVO.success(bomNewEbomParentService.temporary(dto));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("submit")
|
||||
@ApiOperation("提交")
|
||||
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) {
|
||||
return ResultVO.success(bomNewEbomParentService.submit(dto));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,4 +56,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
|
|||
List<BomNewEbomParentVO> getChildForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList,@Param("materialNo") String materialNo);
|
||||
|
||||
void updateRootState();
|
||||
|
||||
void delBatch(@Param("rowIds") List<Long> rowIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.product.bomnew.pojo.dto;
|
||||
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -11,7 +12,9 @@ public class BomNewEBomParentCreateDTO {
|
|||
@ApiModelProperty("操作类型 1-暂存 2-提交")
|
||||
private Integer opType=1;
|
||||
@ApiModelProperty("列表数据")
|
||||
private List<BomNewEbomParentDTO> datas;
|
||||
private List<BomNewEbomParentVO> datas;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.product.bomnew.pojo.dto;
|
||||
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -8,16 +9,9 @@ import java.util.List;
|
|||
@Data
|
||||
public class BomNewEBomParentEditDTO extends BomNewEBomParentCreateDTO{
|
||||
@ApiModelProperty("上层")
|
||||
private BomNewEbomParentDTO parent;
|
||||
|
||||
|
||||
private BomNewEbomParentVO parent;
|
||||
|
||||
@ApiModelProperty("删除的列表")
|
||||
private List<BomNewEbomParentDTO> delDatas;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private List<BomNewEbomParentVO> delDatas;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.product.bomnew.service;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
|
|
@ -18,22 +19,15 @@ import com.nflg.product.base.core.conmon.util.SessionUtil;
|
|||
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.BomNewEBomCreateDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewEBomRevertDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.EBomToPBomParamDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.VirtualPackageParamDto;
|
||||
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.dto.*;
|
||||
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.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomEditDetailVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.EbomExcelVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.*;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomDetailTask;
|
||||
import com.nflg.product.bomnew.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -62,6 +56,7 @@ import java.util.stream.Collectors;
|
|||
* @since 2023-11-17 16:55:11
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper, BomNewEbomParentEntity> {
|
||||
|
||||
|
||||
|
|
@ -517,6 +512,49 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
};
|
||||
EecExcelUtil.eecExcel("bom列表", listSheet, response);
|
||||
}
|
||||
/**
|
||||
* 计算BOM树高度
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public boolean compucteLevelNum() throws ExecutionException, InterruptedException {
|
||||
List<BomNewEbomParentEntity> list = this.lambdaQuery().le(BomNewEbomParentEntity ::getLevelNum, 0).list();
|
||||
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
for (BomNewEbomParentEntity bom : list) {
|
||||
bom.setRootIs(1);
|
||||
List<BomNewEbomParentVO> bomDetail = this.getBaseMapper().getParentChild(bom.getRowId());
|
||||
EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
|
||||
detailTask.setLevelNum(1);
|
||||
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
|
||||
submit.get();
|
||||
bom.setLevelNum(detailTask.getLevelNum());
|
||||
}
|
||||
this.saveOrUpdateBatch(list);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算层级数和根节点状态
|
||||
*/
|
||||
public void computeLevelNumAndRootState() {
|
||||
//计算树的层级数
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
this.getBaseMapper().updateRootState();
|
||||
this.compucteLevelNum();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("计算层级出错:"+e.getMessage());
|
||||
}
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 手工创建EBOM
|
||||
|
|
@ -803,7 +841,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
public BaseMaterialVO queryMaterial(BomNewEbomMaterialQuery query) {
|
||||
public BomNewEbomParentVO queryMaterial(BomNewEbomMaterialQuery query) {
|
||||
List<MaterialMainEntity> materialMainList=null;
|
||||
if (StringUtils.isNotEmpty(query.getMaterialNo())) {
|
||||
materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, query.getMaterialNo()).list();
|
||||
|
|
@ -827,8 +865,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
if(CollUtil.isNotEmpty(materialMainList)){
|
||||
MaterialMainEntity materialMainEntity = materialMainList.get(0);
|
||||
BaseMaterialVO baseMaterialVO = new BaseMaterialVO();
|
||||
BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO();
|
||||
BeanUtil.copyProperties(materialMainEntity, baseMaterialVO);
|
||||
baseMaterialVO.setExceptionStatus(materialMainEntity.getMaterialState());
|
||||
|
||||
return baseMaterialVO;
|
||||
}
|
||||
|
||||
|
|
@ -841,4 +881,98 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
|
||||
|
||||
public Boolean deleteMaterial(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("该节点不属于你,你无权删除");
|
||||
|
||||
|
||||
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
|
||||
List<BomNewEbomParentVO> delBom=null;
|
||||
if (userRoleService.designer()) {
|
||||
delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0
|
||||
&& u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|
||||
&& EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if(CollUtil.isNotEmpty(delBom)) {
|
||||
|
||||
List<Long> delParentRowId = new ArrayList<>();
|
||||
for (BomNewEbomParentVO bom : delBom) {
|
||||
delParentRowId.add(bom.getBomRowId());
|
||||
}
|
||||
delParentRowId.add(bomRowId);
|
||||
if (CollUtil.isNotEmpty(delParentRowId)) {
|
||||
this.getBaseMapper().delBatch(delParentRowId);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 暂存
|
||||
*
|
||||
* 用户临时处理数据,数据的处理状态为“待处理”,当用户单击暂存的时候,所有的数据都不需要校验,直接保存即可。
|
||||
*/
|
||||
|
||||
public Boolean temporary(BomNewEBomParentEditDTO dto){
|
||||
|
||||
EBomEdit eBomEdit=new EBomEdit();
|
||||
eBomEdit.temporary(dto);
|
||||
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities );
|
||||
}
|
||||
|
||||
if(CollUtil.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())){
|
||||
if(CollUtil.isNotEmpty(dto.getDelDatas())) {
|
||||
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
ebomChildService.removeByIds(rowIdList);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交物料
|
||||
*/
|
||||
public Boolean submit(BomNewEBomParentEditDTO dto){
|
||||
|
||||
EBomEdit eBomEdit=new EBomEdit();
|
||||
eBomEdit.temporary(dto);
|
||||
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities );
|
||||
}
|
||||
|
||||
if(CollUtil.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())){
|
||||
|
||||
if(CollUtil.isNotEmpty(dto.getDelDatas())) {
|
||||
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
ebomChildService.removeByIds(rowIdList);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,146 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
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.toolkit.IdWorker;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
||||
import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.EbomEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewEBomParentEditDTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigVO;
|
||||
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.VUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EBomEdit {
|
||||
|
||||
public List<BomNewEbomParentEntity> parentEntities;
|
||||
|
||||
public List<BomNewEbomChildEntity> childEntities;
|
||||
|
||||
|
||||
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
|
||||
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
|
||||
BeanUtil.copyProperties(parent, vo);
|
||||
|
||||
// BaseMaterialVO material = materialVOMap.get(vo.getMaterialNo());
|
||||
String batchNo = IdUtil.simpleUUID();
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setBatchNo(batchNo);
|
||||
// parent.setDrawingNo(material.getDrawingNo());
|
||||
// parent.setMaterialNo(material.getMaterialNo());
|
||||
// parent.setMaterialName(material.getMaterialName());
|
||||
// parent.setMaterialDesc(material.getMaterialDesc());
|
||||
// parent.setMaterialTexture(material.getMaterial());
|
||||
parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum());
|
||||
|
||||
parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
|
||||
parent.setDeviseUserCode(SessionUtil.getUserCode());
|
||||
parent.setCurrentVersion("A00");
|
||||
parent.setDeviseName(SessionUtil.getRealName());
|
||||
parent.setDeptName(SessionUtil.getDepartName());
|
||||
|
||||
parent.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||
parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
|
||||
parent.setBomExist(1);
|
||||
parent.setLastVersionIs(1);
|
||||
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void temporary(BomNewEBomParentEditDTO dto) {
|
||||
|
||||
|
||||
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());
|
||||
|
||||
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
|
||||
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
|
||||
// Map<String, BaseMaterialVO> materialVOMap = ListCommonUtil.listToMap(materialBaseInfo, BaseMaterialVO::getMaterialNo);
|
||||
parentEntities = new ArrayList<>();
|
||||
childEntities = new ArrayList<>();
|
||||
//添加数据
|
||||
if (dto.getParent() == null) {
|
||||
for (BomNewEbomParentVO vo : dto.getDatas()) {
|
||||
parentEntities.add(createParentBomInfo (vo));
|
||||
}
|
||||
|
||||
} else {
|
||||
BomNewEbomParentEntity parent;
|
||||
//缺bom
|
||||
if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) {
|
||||
parent = createParentBomInfo(dto.getParent());
|
||||
parentEntities.add(parent);
|
||||
}else {
|
||||
parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
|
||||
}
|
||||
|
||||
SpringUtil.getBean(BomNewEbomParentService.class).initBomException(dto.getDatas());
|
||||
childEntities=Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() {
|
||||
}, dto.getDatas());
|
||||
|
||||
for (BomNewEbomChildEntity child :
|
||||
childEntities) {
|
||||
child.setRowId(IdWorker.getId());
|
||||
|
||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
||||
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
|
||||
|
||||
//新增数据
|
||||
if(child.getRowId()==null || child.getRowId().longValue()==0){
|
||||
child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId()));
|
||||
|
||||
child.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||
child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
child.setCreatedTime(LocalDateTime.now());
|
||||
child.setCreatedBy(SessionUtil.getUserCode());
|
||||
}
|
||||
|
||||
|
||||
child.setParentRowId(parent.getRowId());
|
||||
VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -172,4 +172,20 @@
|
|||
on a.material_no=b.material_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;
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<delete id="delBatch">
|
||||
delete from t_bom_new_ebom_parent where row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>;
|
||||
delete from t_bom_new_ebom_child where parent_row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>;
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue