parent
31b25008e0
commit
a4966b897a
|
|
@ -616,7 +616,7 @@ public class EbomApi extends BaseApi {
|
|||
@ApiOperation("BOM删除")
|
||||
@LogRecord(success = "Ebom-BOM删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM删除")
|
||||
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId,
|
||||
@RequestParam("childBomRowId") Long childBomRowId) {
|
||||
@RequestParam(value = "childBomRowId",required = false) Long childBomRowId) {
|
||||
return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId,childBomRowId));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ public class PBomApi extends BaseApi {
|
|||
@ApiOperation("BOM删除")
|
||||
@LogRecord(success = "PBom删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "BOM删除")
|
||||
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId,
|
||||
@RequestParam("childBomRowId") Long childBomRowId) {
|
||||
@RequestParam(value = "childBomRowId",required = false) Long childBomRowId) {
|
||||
bomNewPbomParentService.bomDelete(bomRowId,childBomRowId);
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
@ -1495,6 +1496,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
public Boolean bomDelete(Long bomRowId,Long childBomRowId){
|
||||
BomNewEbomParentEntity parent = this.getById(bomRowId);
|
||||
VUtils.isTure(parent == null).throwMessage(StrUtil.join(",", bomRowId, "不存在~"));
|
||||
//检查物料是否冻结中,冻结中无法删除
|
||||
List<MaterialMainEntity> mList = materialMainService.list(Wrappers.<MaterialMainEntity>lambdaQuery()
|
||||
.eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo())
|
||||
.eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue()));
|
||||
if(CollUtil.isNotEmpty(mList)){
|
||||
VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0))
|
||||
.map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~"));
|
||||
}
|
||||
|
||||
//检查是否存在发布前的版本,有则不能发起 BOM删除
|
||||
List<BomNewEbomParentEntity> existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
|
||||
|
|
@ -1523,8 +1533,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
newParent.setRemark("");
|
||||
newParent.setSource(EBomSourceEnum.FROM_DELETE.getValue());
|
||||
newParent.setConvertToEbomTime(null);
|
||||
newParent.setReleaseUserName(null);
|
||||
newParent.setReleaseTime(null);
|
||||
newParent.setRevertDesc(null);
|
||||
newParent.setRevertTime(null);
|
||||
newParent.setRevertUserName(null);
|
||||
|
|
@ -1532,25 +1540,34 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
newParent.setAuditTime(null);
|
||||
newParent.setRootIs(1);
|
||||
newParent.setUserRootIs(1);
|
||||
newParent.setSapState(1);
|
||||
newParent.setSapState(SapStatusEnum.PUB_SUCCESS.getValue());
|
||||
newParent.setSapTime(null);
|
||||
newParent.setModifyTime(null);
|
||||
newParent.setCreatedTime(LocalDateTime.now());
|
||||
newParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
newParent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
newParent.setReleaseTime(LocalDateTime.now());
|
||||
newParent.setReleaseUserName(SessionUtil.getUserName());
|
||||
newParent.setExpireEndTime(DateUtil.parseLocalDateTime("9999-12-31 23:59:59","yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
parent.setLastVersionIs(0);
|
||||
parentResult.add(newParent);
|
||||
parentResult.add(parent);
|
||||
//将新增的newParent,替换到旧bom的子表上
|
||||
List<BomNewEbomChildEntity> childEntityList = Lists.newArrayList();
|
||||
BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId);
|
||||
BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity();
|
||||
BeanUtil.copyProperties(oldBomChild, newBomChild);
|
||||
newBomChild.setRowId(IdWorker.getId());
|
||||
newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId());
|
||||
newBomChild.setBomVersionRowId(newParent.getRowId());
|
||||
newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue());
|
||||
childEntityList.add(newBomChild);
|
||||
if(childBomRowId != null){
|
||||
BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId);
|
||||
if(oldBomChild != null){
|
||||
BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity();
|
||||
BeanUtil.copyProperties(oldBomChild, newBomChild);
|
||||
newBomChild.setRowId(IdWorker.getId());
|
||||
newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId());
|
||||
newBomChild.setBomVersionRowId(newParent.getRowId());
|
||||
newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue());
|
||||
childEntityList.add(newBomChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//2、子表增加一行项目类别为K,标识删除
|
||||
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
|
||||
|
|
@ -1595,8 +1612,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
this.saveOrUpdateBatch(parentResult);
|
||||
ebomChildService.saveBatch(childEntityList);
|
||||
ebomChildService.removeById(childBomRowId);
|
||||
|
||||
if(childBomRowId != null){
|
||||
ebomChildService.removeById(childBomRowId);
|
||||
}
|
||||
//将历史已发布版-转移到正式历史表
|
||||
List<Long> addRowIds = com.google.common.collect.Lists.newArrayList(newParent.getRowId());
|
||||
List<Long> delRowIds = com.google.common.collect.Lists.newArrayList(bomRowId);
|
||||
|
|
|
|||
|
|
@ -284,14 +284,14 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
result = this.getBaseMapper().releaseListByPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||
}
|
||||
//添加仓库地点 by 10002327 0830
|
||||
if(!result.getRecords().isEmpty()){
|
||||
List<Map<String,Object>> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()),
|
||||
result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList()));
|
||||
Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m-> {
|
||||
return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"));
|
||||
},m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
|
||||
result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode())));
|
||||
}
|
||||
// if(!result.getRecords().isEmpty()){
|
||||
// List<Map<String,Object>> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()),
|
||||
// result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList()));
|
||||
// Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m-> {
|
||||
// return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"));
|
||||
// },m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
|
||||
// result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode())));
|
||||
// }
|
||||
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1447,6 +1447,14 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
public void bomDelete(Long bomRowId,Long childBomRowId){
|
||||
BomNewPbomParentEntity parent = this.getById(bomRowId);
|
||||
VUtils.isTure(Objects.isNull(parent)).throwMessage("该BOM版本不存在");
|
||||
//检查物料是否冻结中,冻结中无法删除
|
||||
List<MaterialMainEntity> mList = materialMainService.list(Wrappers.<MaterialMainEntity>lambdaQuery()
|
||||
.eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo())
|
||||
.eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue()));
|
||||
if(CollUtil.isNotEmpty(mList)){
|
||||
VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0))
|
||||
.map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~"));
|
||||
}
|
||||
VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能删除");
|
||||
//检查当前用户是否有该工厂权限
|
||||
if(!userRoleService.getUserOfFactory().contains(parent.getFacCode())){
|
||||
|
|
@ -1484,9 +1492,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
pbomParent.setTechnologyUserCode(SessionUtil.getUserCode());
|
||||
pbomParent.setRemark("");
|
||||
pbomParent.setSource(PbomSourceEnum.FROM_DELETE.getValue());
|
||||
pbomParent.setReleaseTime(null);
|
||||
pbomParent.setReleaseUserName(null);
|
||||
pbomParent.setSapState(1);
|
||||
pbomParent.setSapState(SapStatusEnum.PUB_SUCCESS.getValue());
|
||||
pbomParent.setSapTime(null);
|
||||
pbomParent.setModifyTime(null);
|
||||
pbomParent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
|
|
@ -1495,20 +1501,26 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
pbomParent.setLastVersionIs(1);
|
||||
pbomParent.setEbomVersion(null);
|
||||
pbomParent.setBomExist(1);
|
||||
pbomParent.setReleaseTime(LocalDateTime.now());
|
||||
pbomParent.setReleaseUserName(SessionUtil.getUserName());
|
||||
pbomParent.setExpireEndTime(DateUtil.parseLocalDateTime("9999-12-31 23:59:59","yyyy-MM-dd HH:mm:ss"));
|
||||
//设置旧版本
|
||||
parent.setLastVersionIs(0);
|
||||
parentList.add(pbomParent);
|
||||
parentList.add(parent);
|
||||
|
||||
|
||||
List<BomNewPbomChildEntity> newChildEntityList = Lists.newArrayList();
|
||||
BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId);
|
||||
BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(oldBomChild, newBomChild);
|
||||
newBomChild.setRowId(IdWorker.getId());
|
||||
newBomChild.setBomVersionRowId(pbomParent.getRowId());
|
||||
newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue());
|
||||
newChildEntityList.add(newBomChild);
|
||||
if(childBomRowId != null){
|
||||
BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId);
|
||||
if(oldBomChild!= null){
|
||||
BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(oldBomChild, newBomChild);
|
||||
newBomChild.setRowId(IdWorker.getId());
|
||||
newBomChild.setBomVersionRowId(pbomParent.getRowId());
|
||||
newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue());
|
||||
newChildEntityList.add(newBomChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//2、子表新增一行项目类别为K的标识行
|
||||
|
|
@ -1555,8 +1567,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
}
|
||||
this.saveOrUpdateBatch(parentList);
|
||||
pbomChildService.saveBatch(newChildEntityList);
|
||||
pbomChildService.removeById(childBomRowId);
|
||||
|
||||
if(childBomRowId != null){
|
||||
pbomChildService.removeById(childBomRowId);
|
||||
}
|
||||
List<Long> exceptRowIds = Lists.newArrayList(pbomParent.getRowId());
|
||||
List<String> parentMaterialNos =Lists.newArrayList(pbomParent.getMaterialNo());
|
||||
//历史版本转移到formal正式工作表
|
||||
|
|
|
|||
Loading…
Reference in New Issue