BUG修复
This commit is contained in:
parent
9cebd0f021
commit
591ed8b390
|
|
@ -213,6 +213,18 @@ public class PBomApi extends BaseApi {
|
|||
}
|
||||
|
||||
|
||||
@GetMapping("upgrade")
|
||||
@ApiOperation("发起变更")
|
||||
public ResultVO<Boolean> upgrade(@RequestParam("bomRowId") Long bomRowId) {
|
||||
try {
|
||||
bomNewPbomParentService.upgrade(bomRowId);
|
||||
return ResultVO.success(true);
|
||||
}catch (Exception ex){
|
||||
return ResultVO.error("变更失败"+ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -820,9 +820,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
|
||||
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
|
||||
}
|
||||
|
||||
|
||||
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
//不要异步
|
||||
computeLevelNumAndRootState();
|
||||
// ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1272,7 +1272,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
childList.add(dto.getParent());
|
||||
}
|
||||
checkAndSaveEBomException(childList);
|
||||
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
//不要异步
|
||||
ebomChildService.getBaseMapper().updateEBomMaterialUse();
|
||||
// ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1343,8 +1345,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
checkAndSaveEBomException(childList);
|
||||
// ebomChildService.getBaseMapper().updateEBomMaterialUse();
|
||||
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
// ebomChildService.getBaseMapper().updateEBomMaterialUse();
|
||||
// ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
|
||||
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.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
|
@ -19,10 +21,7 @@ import com.nflg.product.bomnew.pojo.dto.*;
|
|||
import com.nflg.product.bomnew.pojo.entity.*;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
import com.nflg.product.bomnew.service.domain.PBom.BomCopy;
|
||||
import com.nflg.product.bomnew.service.domain.PBom.ConvertToMBom;
|
||||
import com.nflg.product.bomnew.service.domain.PBom.PBomDetailTask;
|
||||
import com.nflg.product.bomnew.service.domain.PBom.TechnologyPackageParamBuilder;
|
||||
import com.nflg.product.bomnew.service.domain.PBom.*;
|
||||
import com.nflg.product.bomnew.util.*;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
|
@ -36,6 +35,7 @@ import javax.annotation.Resource;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
|
@ -107,6 +107,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
}
|
||||
if (StrUtil.isNotBlank(materialNo)) {
|
||||
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList());
|
||||
parentMaterialByMaterialNo.add(materialNo);
|
||||
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
||||
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory())?userRoleService.getUserFactory():query.getFacCode(),parentMaterialByMaterialNo );
|
||||
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory())?userRoleService.getUserFactory():query.getFacCode(),parentMaterialByMaterialNo, materialNo);
|
||||
|
|
@ -514,12 +515,13 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
|
||||
StringBuilder relPattern = new StringBuilder();
|
||||
List<BomNewPbomChildEntity> result = new ArrayList<>();
|
||||
Boolean match = true;
|
||||
|
||||
for (BomNewPbomParentVO child : childrenVO) {
|
||||
if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) {
|
||||
continue;
|
||||
}
|
||||
for (BomFactorySplitRuleEntity role : relList) {
|
||||
Boolean match = true;
|
||||
if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) {
|
||||
match = match & (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && role.getMaterialCategoryCode().equals(child.getMaterialCategoryCode()));
|
||||
}
|
||||
|
|
@ -528,7 +530,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
}
|
||||
|
||||
if (StrUtil.isNotBlank(role.getDrawingContain())) {
|
||||
match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().contains(role.getDrawingPrefix()));
|
||||
match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().contains(role.getDrawingContain()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(role.getDrawingSuffix())) {
|
||||
match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().endsWith(role.getDrawingSuffix()));
|
||||
|
|
@ -548,8 +550,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
if (match) {
|
||||
BomNewPbomChildEntity ent = new BomNewPbomChildEntity();
|
||||
ent.setRowId(child.getRowId());
|
||||
ent.setFacCode(role.getFactoryCode());
|
||||
|
||||
ent.setProductionFactoryCode(role.getFactoryCode());
|
||||
ent.setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue());
|
||||
result.add(ent);
|
||||
|
||||
break;
|
||||
|
|
@ -625,7 +627,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
try {
|
||||
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
|
||||
List<Long> bomRowIds = allBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
||||
Integer state = parent.getMaterialNo().startsWith("31") ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
|
||||
Integer state = (parent.getMaterialNo().startsWith("31") && parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
|
||||
bomRowIds.add(bomRowId);
|
||||
this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds);
|
||||
//保存订单号
|
||||
|
|
@ -647,4 +649,25 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
return crmService.getOrderNo(materialNo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起变更
|
||||
* @param bomRowId
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void upgrade(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
BomNewPbomParentEntity parent = this.getById(bomRowId);
|
||||
VUtils.isTure(parent.getStatus()< PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能发起变更");
|
||||
PBomUpgrade upgrade=new PBomUpgrade(parent,getAllBom(bomRowId,0));
|
||||
upgrade.upgrade();
|
||||
if(CollUtil.isNotEmpty(upgrade.getParentResult())){
|
||||
this.saveOrUpdateBatch(upgrade.getParentResult());
|
||||
}
|
||||
if(CollUtil.isNotEmpty(upgrade.getChildResult())){
|
||||
pbomChildService.saveOrUpdateBatch(upgrade.getChildResult());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ public class UserRoleService {
|
|||
*/
|
||||
public String getUserFactory(){
|
||||
Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId());
|
||||
return "";
|
||||
// if(userMultiplantFacRoleCount>0){
|
||||
// return "";
|
||||
// }else {
|
||||
// return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010;
|
||||
// }
|
||||
// return "";
|
||||
if(userMultiplantFacRoleCount>0){
|
||||
return "";
|
||||
}else {
|
||||
return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -82,4 +82,6 @@ public class UserRoleService {
|
|||
return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of(EBomConstant.XIAN_TAO_FACTORY_CODE_1020) : ImmutableList.of(EBomConstant.MAIN_FACTORY_CODE_1010) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,8 @@ public class CheckEBomException {
|
|||
// });
|
||||
// }
|
||||
//是否存在重复物料
|
||||
Map<String, List<BomNewEbomParentVO>> childMaterialMap = ListCommonUtil.listGroupMap(child, BomNewEbomParentVO::getMaterialNo);
|
||||
List<BomNewEbomParentVO> hasMaterialNoList = child.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
Map<String, List<BomNewEbomParentVO>> childMaterialMap = ListCommonUtil.listGroupMap(hasMaterialNoList, BomNewEbomParentVO::getMaterialNo);
|
||||
for (String key : childMaterialMap.keySet()) {
|
||||
List<BomNewEbomParentVO> materialGroupList = childMaterialMap.get(key);
|
||||
if (materialGroupList.size() > 1) {
|
||||
|
|
@ -196,25 +197,29 @@ public class CheckEBomException {
|
|||
if (CollUtil.isEmpty(exceptionList)) {
|
||||
return;
|
||||
}
|
||||
for (BomNewEbomParentVO exItem : list) {
|
||||
List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> u.getBomRowId() > 0 && u.getLevelNumber().compareTo(exItem.getLevelNumber().setScale(0, RoundingMode.FLOOR))>=0 && u.getRowId()!=exItem.getRowId() && u.getLevelNumber().compareTo(exItem.getLevelNumber()) < 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
|
||||
warnList.forEach(k -> {
|
||||
for (BomNewEbomParentVO exItem : exceptionList) {
|
||||
List<String> parentByLevel = getParentByLevel(exItem.getLevelNo());
|
||||
List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> u.getBomRowId() > 0 && parentByLevel.contains(u.getLevelNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO k :warnList) {
|
||||
k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
List<BomNewEbomParentVO> root = allBomDetail.stream().filter(u -> u.getLevelNumber().compareTo(BigDecimal.ZERO) == 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
|
||||
root.forEach(k->{
|
||||
k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// List<String> allErrorParent = SpringUtil.getBean(BomNewEbomParentService.class).getBatchParentMaterialByMaterialNo(exceptionMaterialNos);
|
||||
// List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> allErrorParent.contains(u.getMaterialNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
|
||||
// warnList.forEach(k->{
|
||||
// k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
|
||||
// });
|
||||
private List<String> getParentByLevel(String levelNo){
|
||||
List<String> result=new ArrayList<>();
|
||||
String[] parts = levelNo.split("-");
|
||||
|
||||
for (int i=parts.length;i<parts.length;i--) {
|
||||
result.add( String.join("-", Arrays.copyOfRange(parts, 0, i-1)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ public class EBomDetailTask extends RecursiveTask<List<BomNewEbomParentVO>> {
|
|||
detailVO.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
|
||||
detailVO.setDeptName(ebomParentEntity.getDeptName());
|
||||
detailVO.setDeviseName(ebomParentEntity.getDeviseName());
|
||||
detailVO.setBomExist(ebomParentEntity.getBomExist());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,6 +252,9 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
parentEntity.setMaterialUnit("KG");
|
||||
parentEntity.setNum(parentEntity.getTotalWeight());
|
||||
}
|
||||
else {
|
||||
parentEntity.setMaterialDesc(parentEntity.getMaterialName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
package com.nflg.product.bomnew.service.domain.PBom;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.PBomStatusEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 升级变更
|
||||
*/
|
||||
public class PBomUpgrade {
|
||||
|
||||
private BomNewPbomParentEntity root;
|
||||
|
||||
private List<BomNewPbomParentVO> allBom;
|
||||
|
||||
@Getter
|
||||
private List<BomNewPbomParentEntity> parentResult;
|
||||
|
||||
@Getter
|
||||
private List<BomNewPbomChildEntity> childResult;
|
||||
|
||||
|
||||
public PBomUpgrade (BomNewPbomParentEntity root,List<BomNewPbomParentVO> allBom) {
|
||||
this.root = root;
|
||||
this.allBom = allBom;
|
||||
BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, root);
|
||||
rootVo.setBomRowId(rootVo.getRowId());
|
||||
allBom.add(rootVo);
|
||||
|
||||
}
|
||||
|
||||
public void upgrade(){
|
||||
//
|
||||
for (BomNewPbomParentVO parentEnt :allBom) {
|
||||
if( parentEnt.getStatus()>=PBomStatusEnum.PUBLISH.getValue()) {
|
||||
buildParent(parentEnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildParent(BomNewPbomParentVO parentVO){
|
||||
BomNewPbomParentEntity pbomParent=new BomNewPbomParentEntity();
|
||||
BeanUtil.copyProperties(parentVO,pbomParent);
|
||||
pbomParent.setRowId(IdWorker.getId());
|
||||
pbomParent.setCreatedTime(LocalDateTime.now());
|
||||
pbomParent.setCreatedBy(SessionUtil.getRealName());
|
||||
pbomParent.setModifyTime(LocalDateTime.now());
|
||||
pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||
pbomParent.setCurrentVersion(VersionUtil.getNextVersion(parentVO.getCurrentVersion()));
|
||||
this.parentResult.add(pbomParent);
|
||||
|
||||
buildChild(parentVO,pbomParent);
|
||||
}
|
||||
|
||||
private void buildChild(BomNewPbomParentVO oldParent, BomNewPbomParentEntity newParent){
|
||||
|
||||
List<BomNewPbomParentVO> chilren = allBom.stream().filter(u -> u.getParentRowId().equals(oldParent.getBomRowId())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO childVO : chilren) {
|
||||
BomNewPbomChildEntity child=new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(childVO,child);
|
||||
child.setRowId(IdWorker.getId());
|
||||
child.setParentRowId(newParent.getRowId());
|
||||
child.setCreatedTime(LocalDateTime.now());
|
||||
child.setCreatedBy(SessionUtil.getRealName());
|
||||
child.setModifyTime(LocalDateTime.now());
|
||||
|
||||
this.childResult.add(child);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -117,7 +117,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 and ( root_is= 1 or user_root_is=1)
|
||||
select * , row_id as bomRowId from t_bom_new_ebom_parent where status=4
|
||||
<include refid="whr"/>
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue