PBOM-列表搜索

This commit is contained in:
大米 2024-01-09 17:21:29 +08:00
parent 12fd066d0c
commit fc72eebcf0
10 changed files with 302 additions and 124 deletions

View File

@ -68,6 +68,9 @@ public class EbomApi extends BaseApi {
@Resource @Resource
private BomNewEbomUpgradeChangeService upgradeChangeService; private BomNewEbomUpgradeChangeService upgradeChangeService;
@Resource
private BomNewPbomParentService bomNewPbomParentService;
@PostMapping("workDetailsListByPage") @PostMapping("workDetailsListByPage")
@ApiOperation("Ebom-工作明细列表") @ApiOperation("Ebom-工作明细列表")
@ -143,6 +146,8 @@ public class EbomApi extends BaseApi {
VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂"); VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂");
bomNewEbomParentService.convertToPBom(paramDto); bomNewEbomParentService.convertToPBom(paramDto);
//更新PBomUse 数据
bomNewPbomParentService.getBaseMapper().updatePBomMaterialUse();
return ResultVO.success(true); return ResultVO.success(true);

View File

@ -0,0 +1,13 @@
package com.nflg.product.bomnew.mapper.master;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomMaterialUseEntity;
/**
* t_bom_new_pbom_material_use 表数据库访问层
*
* @author makejava
* @since 2024-01-09 16:17:50
*/
public interface BomNewPbomMaterialUseMapper extends BaseMapper<BomNewPbomMaterialUseEntity> {
}

View File

@ -33,4 +33,10 @@ public interface BomNewPbomParentMapper extends BaseMapper<BomNewPbomParentEntit
void toMBom(@Param("status") Integer status, @Param("toMBomUserName")String toMBomUserName, @Param("rowIds") List<Long> rowIds ); void toMBom(@Param("status") Integer status, @Param("toMBomUserName")String toMBomUserName, @Param("rowIds") List<Long> rowIds );
void updatePBomMaterialUse();
List<BomNewPbomParentVO> getParentForMaterialNoSeach(@Param("userFac") String userFac,@Param("materialNoList") List<String> materialNoList);
List<BomNewPbomParentVO> getChildForMaterialNoSeach(@Param("userFac") String userFac,@Param("materialNoList") List<String> materialNoList,@Param("materialNo")String materialNo);
} }

View File

@ -0,0 +1,50 @@
package com.nflg.product.bomnew.pojo.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.time.LocalDate;
/**
* t_bom_new_pbom_material_use
*
* @author makejava
* @since 2024-01-09 16:17:50
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewPbomMaterialUseEntity")
@TableName(value = "t_bom_new_pbom_material_use")
public class BomNewPbomMaterialUseEntity implements Serializable {
/**
* 主键-雪花
*/
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键-雪花")
private Long rowId;
/**
* 物料编码
*/
@TableField(value = "material_no")
@ApiModelProperty(value = "物料编码")
private String materialNo;
/**
* 父级物料编码多个用逗号隔开
*/
@TableField(value = "parent_material_no")
@ApiModelProperty(value = "父级物料编码,多个用逗号隔开")
private String parentMaterialNo;
private static final long serialVersionUID = -73503794405112500L;
}

View File

@ -3,6 +3,7 @@ package com.nflg.product.bomnew.pojo.vo;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -210,8 +211,8 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间") @ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
private LocalDateTime expireEndTime; private LocalDateTime expireEndTime;
public String getExpireEndTime() { public LocalDateTime getExpireEndTime() {
return expireEndTime==null? LocalDateTimeUtil.format(LocalDateTime.MAX,"yy-MM-dd HH:mm:ss"):LocalDateTimeUtil.format(expireEndTime,"yyyy-MM-dd HH:mm:ss"); return expireEndTime==null? LocalDateTime.of(9999,12,31,23,59,59):expireEndTime;
} }
/** /**

View File

@ -0,0 +1,19 @@
package com.nflg.product.bomnew.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.bomnew.mapper.master.BomNewPbomMaterialUseMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomMaterialUseEntity;
import org.springframework.stereotype.Service;
/**
* t_bom_new_pbom_material_use 表服务实现类
*
*
* @author makejava
* @since 2024-01-09 16:17:50
*/
@Service
public class BomNewPbomMaterialUseService extends ServiceImpl<BomNewPbomMaterialUseMapper, BomNewPbomMaterialUseEntity> {
}

View File

@ -85,6 +85,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Resource @Resource
private CrmService crmService; private CrmService crmService;
@Resource
BomNewPbomMaterialUseService pbomMaterialUseService;
/** /**
* pbom-工作列表 * pbom-工作列表
* *
@ -93,70 +97,92 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
*/ */
public IPage<BomNewPbomParentVO> workDetailsListByPage(BomNewPbomParentQuery query) { public IPage<BomNewPbomParentVO> workDetailsListByPage(BomNewPbomParentQuery query) {
//物料编码搜索或图号搜索 //物料编码搜索或图号搜索
// if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) { if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
// String materialNo = query.getMaterialNo(); String materialNo = query.getMaterialNo();
// if (StrUtil.isBlank(materialNo)) { if (StrUtil.isBlank(materialNo)) {
// List<MaterialMainEntity> materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list(); List<MaterialMainEntity> materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
// if (CollUtil.isNotEmpty(materialList)) { if (CollUtil.isNotEmpty(materialList)) {
// materialNo = materialList.get(0).getMaterialNo(); materialNo = materialList.get(0).getMaterialNo();
// } }
// } }
// if (StrUtil.isNotBlank(materialNo)) { if (StrUtil.isNotBlank(materialNo)) {
// List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList()); List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList());
// if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
// List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo); List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(userRoleService.getUserFactory(),parentMaterialByMaterialNo );
// List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo); List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(userRoleService.getUserFactory(),parentMaterialByMaterialNo, materialNo);
// List<BomNewEbomParentVO> data = new ArrayList<>(); List<BomNewPbomParentVO> data = new ArrayList<>();
// data.addAll(parents); data.addAll(parents);
// data.addAll(childs); data.addAll(childs);
// materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
// returnResult = handSeachToTree(parents, childs); return handSeachToTree(parents, childs);
// } }
// } }
// return null; return null;
// } } else {
// else {
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory()); Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory());
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return result; return result;
// } }
}
private Page<BomNewPbomParentVO> handSeachToTree(List<BomNewPbomParentVO> parents, List<BomNewPbomParentVO> childs) {
Page<BomNewPbomParentVO> resutlData = new Page<>();
Set<String> parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
Set<String> childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
Set<String> difference = Sets.difference(parentSet, childSet);
List<BomNewPbomParentVO> resultParents = parents.stream().filter(u -> difference.contains(u.getMaterialNo())).collect(Collectors.toList());
resutlData.setTotal(difference.size());
resutlData.setSize(difference.size());
resutlData.setPages(1);
resutlData.setCurrent(1L);
List<BomNewPbomParentVO> all = new ArrayList<>();
// all.addAll(resultParents);
all.addAll(childs);
List<BomNewPbomParentVO> result = new ArrayList<>();
for (BomNewPbomParentVO vo : resultParents) {
//vo.setParentRowId(0L);
List<BomNewPbomParentVO> da = new ArrayList<>();
da.addAll(childs);
da.add(vo);
result.addAll(CTreePBomUtils.toTree(0L, da, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId));
}
resutlData.setRecords(result);
return resutlData;
} }
/** /**
* 获取物料所有子级 * 获取物料所有子级
* @param materialNo * @param materialNo
* @param selfIs * @param
* @return * @return
*/ */
// public Set<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) { public Set<String> getParentMaterialByMaterialNo(String materialNo) {
// BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one(); BomNewPbomMaterialUseEntity materialBom = pbomMaterialUseService.lambdaQuery().eq(BomNewPbomMaterialUseEntity::getMaterialNo, materialNo).one();
// Set<String> result = new HashSet<>(); Set<String> result = new HashSet<>();
// if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) { if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) {
// Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ",")); Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ","));
// if (selfIs && CollUtil.isNotEmpty(relSkuNo)) {
// relSkuNo = getSelfMaterialNo(relSkuNo); while (CollUtil.isNotEmpty(relSkuNo)) {
// } result.addAll(relSkuNo);
// while (CollUtil.isNotEmpty(relSkuNo)) { List<BomNewPbomMaterialUseEntity> relSkuList = pbomMaterialUseService.lambdaQuery().in(BomNewPbomMaterialUseEntity::getMaterialNo, relSkuNo).list();
// result.addAll(relSkuNo); relSkuNo.clear();
// List<BomNewEbomMaterialUseEntity> relSkuList = bomNewEbomMaterialUseService.lambdaQuery().in(BomNewEbomMaterialUseEntity::getMaterialNo, relSkuNo).list(); Set<String> finalRelSkuNo = relSkuNo;
// relSkuNo.clear(); relSkuList.forEach(k -> {
// Set<String> finalRelSkuNo = relSkuNo; if (StrUtil.isNotBlank(k.getParentMaterialNo())) {
// relSkuList.forEach(k -> { finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")));
// if (StrUtil.isNotBlank(k.getParentMaterialNo())) { }
// finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ","))); });
// } relSkuNo = finalRelSkuNo;
// }); }
// relSkuNo = finalRelSkuNo; }
// if (CollUtil.isNotEmpty(relSkuNo) && selfIs) { return result;
// relSkuNo = getSelfMaterialNo(relSkuNo); }
// }
// }
// }
// return result;
// }
/** /**
* *
*
* @param query * @param query
* @return * @return
*/ */
@ -166,16 +192,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
return result; return result;
} }
public void exportWorkDetailsListByPage(BomNewPbomParentQuery query,HttpServletResponse response) throws IOException { public void exportWorkDetailsListByPage(BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表"); EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
new Workbook().addSheet(new ListSheet<BomNewPbomParentVO>() { new Workbook().addSheet(new ListSheet<BomNewPbomParentVO>() {
Long n = 1L; Long n = 1L;
@Override @Override
protected List<BomNewPbomParentVO> more() { protected List<BomNewPbomParentVO> more() {
query.setPage(n); query.setPage(n);
n++; n++;
List<BomNewPbomParentVO> result=workDetailsListByPage(query).getRecords(); List<BomNewPbomParentVO> result = workDetailsListByPage(query).getRecords();
return CollUtil.isNotEmpty(result)?result:null; return CollUtil.isNotEmpty(result) ? result : null;
} }
}).writeTo(response.getOutputStream()); }).writeTo(response.getOutputStream());
} }
@ -322,7 +349,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
/** /**
* 创建工艺包 * 创建工艺包
* *
@ -382,7 +408,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
private void checkCopyBomParam(Long sourceBomRowId , String targetFacCode){ private void checkCopyBomParam(Long sourceBomRowId, String targetFacCode) {
BomNewPbomParentEntity parent = this.getById(sourceBomRowId); BomNewPbomParentEntity parent = this.getById(sourceBomRowId);
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误复制源BOM不存在"); VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误复制源BOM不存在");
VUtils.isTure(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus())).throwMessage("只有已发布版本,才能复制"); VUtils.isTure(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus())).throwMessage("只有已发布版本,才能复制");
@ -393,28 +419,29 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
/** /**
* 复制前检查 * 复制前检查
*
* @param sourceBomRowId * @param sourceBomRowId
* @param targetFacCode * @param targetFacCode
* @return * @return
*/ */
public List<BomCopyCheckResultVO> copyBomCheck(Long sourceBomRowId, String targetFacCode) throws ExecutionException, InterruptedException { public List<BomCopyCheckResultVO> copyBomCheck(Long sourceBomRowId, String targetFacCode) throws ExecutionException, InterruptedException {
checkCopyBomParam(sourceBomRowId,targetFacCode); checkCopyBomParam(sourceBomRowId, targetFacCode);
BomCopy bomCopy=new BomCopy(sourceBomRowId,targetFacCode,getAllBom(sourceBomRowId,0)); BomCopy bomCopy = new BomCopy(sourceBomRowId, targetFacCode, getAllBom(sourceBomRowId, 0));
bomCopy.check(); bomCopy.check();
return Convert.toList(BomCopyCheckResultVO.class,bomCopy.getCheckList() ) ; return Convert.toList(BomCopyCheckResultVO.class, bomCopy.getCheckList());
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void copyFrom(CopyPBomParam param) throws ExecutionException, InterruptedException { public void copyFrom(CopyPBomParam param) throws ExecutionException, InterruptedException {
checkCopyBomParam(param.getSourceBomRowId(),param.getTargetFacCode()); checkCopyBomParam(param.getSourceBomRowId(), param.getTargetFacCode());
BomCopy bomCopy=new BomCopy(param.getSourceBomRowId(),param.getTargetFacCode(),getAllBom(param.getSourceBomRowId(),0)); BomCopy bomCopy = new BomCopy(param.getSourceBomRowId(), param.getTargetFacCode(), getAllBom(param.getSourceBomRowId(), 0));
bomCopy.copy(param.getCheckResult()); bomCopy.copy(param.getCheckResult());
if(CollUtil.isNotEmpty(bomCopy.getParentResult())){ if (CollUtil.isNotEmpty(bomCopy.getParentResult())) {
this.saveOrUpdateBatch(bomCopy.getParentResult()); this.saveOrUpdateBatch(bomCopy.getParentResult());
} }
if(CollUtil.isNotEmpty(bomCopy.getChildResult())){ if (CollUtil.isNotEmpty(bomCopy.getChildResult())) {
pbomChildService.saveBatch(bomCopy.getChildResult()); pbomChildService.saveBatch(bomCopy.getChildResult());
} }
@ -422,8 +449,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
/** /**
* 获取整颗树的BOM明细 * 获取整颗树的BOM明细
*
* @param * @param
* @param countLevelNum 是否标记层级 0- 1- * @param countLevelNum 是否标记层级 0- 1-
* @return * @return
* @throws ExecutionException * @throws ExecutionException
* @throws InterruptedException * @throws InterruptedException
@ -431,7 +459,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException { public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId); List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
AtomicInteger levelNum = new AtomicInteger(1); AtomicInteger levelNum = new AtomicInteger(1);
PBomDetailTask detailTask = new PBomDetailTask(bomDetail,countLevelNum,levelNum); PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum);
ForkJoinTask<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask); ForkJoinTask<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewPbomParentVO> result = submit.join(); List<BomNewPbomParentVO> result = submit.join();
@ -439,29 +467,29 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
public List<BomNewPbomParentVO> getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException { public List<BomNewPbomParentVO> getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0); List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId); return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
} }
public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException { public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1); List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId); return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean saveAllocationFactory(List<SaveAllocationFactoryDTO> params){ public Boolean saveAllocationFactory(List<SaveAllocationFactoryDTO> params) {
VUtils.isTure(CollUtil.isEmpty(params)).throwMessage("分配工厂数据为空"); VUtils.isTure(CollUtil.isEmpty(params)).throwMessage("分配工厂数据为空");
//按分配的工厂分组 //按分配的工厂分组
Map<String, List<SaveAllocationFactoryDTO>> stringListMap = ListCommonUtil.listGroupMap(params, SaveAllocationFactoryDTO::getProductionFactoryCode); Map<String, List<SaveAllocationFactoryDTO>> stringListMap = ListCommonUtil.listGroupMap(params, SaveAllocationFactoryDTO::getProductionFactoryCode);
for (Map.Entry<String, List<SaveAllocationFactoryDTO>> entry : stringListMap.entrySet()) { for (Map.Entry<String, List<SaveAllocationFactoryDTO>> entry : stringListMap.entrySet()) {
List<SaveAllocationFactoryDTO> saveList = entry.getValue(); List<SaveAllocationFactoryDTO> saveList = entry.getValue();
List<Long> rowIds = saveList.stream().map(u -> u.getRowId()).collect(Collectors.toList()); List<Long> rowIds = saveList.stream().map(u -> u.getRowId()).collect(Collectors.toList());
pbomChildService.getBaseMapper().setProductionFactoryCode(entry.getKey(),rowIds); pbomChildService.getBaseMapper().setProductionFactoryCode(entry.getKey(), rowIds);
} }
return true; return true;
} }
@ -470,43 +498,43 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空"); VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId() ,0); List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 0);
materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list(); List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
StringBuilder relPattern=new StringBuilder(); StringBuilder relPattern = new StringBuilder();
List<BomNewPbomChildEntity> result=new ArrayList<>(); List<BomNewPbomChildEntity> result = new ArrayList<>();
Boolean match=true; Boolean match = true;
for (BomNewPbomParentVO child : childrenVO) { for (BomNewPbomParentVO child : childrenVO) {
if(StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType()) ){ if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) {
continue; continue;
} }
for (BomFactorySplitRuleEntity role : relList) { for (BomFactorySplitRuleEntity role : relList) {
if(StrUtil.isNotBlank(role.getMaterialCategoryCode())){ if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) {
match=match & (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && role.getMaterialCategoryCode().equals(child.getMaterialCategoryCode())); match = match & (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && role.getMaterialCategoryCode().equals(child.getMaterialCategoryCode()));
} }
if(StrUtil.isNotBlank(role.getDrawingPrefix())){ if (StrUtil.isNotBlank(role.getDrawingPrefix())) {
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().startsWith(role.getDrawingPrefix())); match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().startsWith(role.getDrawingPrefix()));
} }
if(StrUtil.isNotBlank(role.getDrawingContain())){ 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.getDrawingPrefix()));
} }
if(StrUtil.isNotBlank(role.getDrawingSuffix())){ if (StrUtil.isNotBlank(role.getDrawingSuffix())) {
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().endsWith(role.getDrawingSuffix())); match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().endsWith(role.getDrawingSuffix()));
} }
if(StrUtil.isNotBlank(role.getMaterialNameContain())){ if (StrUtil.isNotBlank(role.getMaterialNameContain())) {
match=match & (StrUtil.isNotBlank(child.getMaterialName()) && child.getMaterialName().contains(role.getMaterialNameContain())); match = match & (StrUtil.isNotBlank(child.getMaterialName()) && child.getMaterialName().contains(role.getMaterialNameContain()));
} }
if(StrUtil.isNotBlank(role.getMaterialTexture())){ if (StrUtil.isNotBlank(role.getMaterialTexture())) {
match=match & (StrUtil.isNotBlank(child.getMaterialTexture()) && child.getMaterialName().equals(role.getMaterialTexture())); match = match & (StrUtil.isNotBlank(child.getMaterialTexture()) && child.getMaterialName().equals(role.getMaterialTexture()));
} }
if(StrUtil.isNotBlank(role.getNextMaterialCategoryCode())){ if (StrUtil.isNotBlank(role.getNextMaterialCategoryCode())) {
List<BomNewPbomParentVO> childSubNodes=childrenVO.stream().filter(u->u.getParentRowId().equals(child.getBomRowId())).collect(Collectors.toList()); List<BomNewPbomParentVO> childSubNodes = childrenVO.stream().filter(u -> u.getParentRowId().equals(child.getBomRowId())).collect(Collectors.toList());
List<BomNewPbomParentVO> relChild = childSubNodes.stream().filter(u -> u.getMaterialCategoryCode().equals(role.getNextMaterialCategoryCode())).collect(Collectors.toList()); List<BomNewPbomParentVO> relChild = childSubNodes.stream().filter(u -> u.getMaterialCategoryCode().equals(role.getNextMaterialCategoryCode())).collect(Collectors.toList());
match=match & (relChild.size()>0); match = match & (relChild.size() > 0);
} }
if(match){ if (match) {
BomNewPbomChildEntity ent = new BomNewPbomChildEntity(); BomNewPbomChildEntity ent = new BomNewPbomChildEntity();
ent.setRowId(child.getRowId()); ent.setRowId(child.getRowId());
ent.setFacCode(role.getFactoryCode()); ent.setFacCode(role.getFactoryCode());
@ -517,51 +545,49 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
} }
} }
if(CollUtil.isNotEmpty(result)){ if (CollUtil.isNotEmpty(result)) {
pbomChildService.saveOrUpdateBatch(result); pbomChildService.saveOrUpdateBatch(result);
} }
return true; return true;
} }
public void reConvertToMBom(Long bomRowId,List<Long> backRowId){ public void reConvertToMBom(Long bomRowId, List<Long> backRowId) {
UpdateWrapper<BomNewPbomChildEntity > updateWrapper=new UpdateWrapper<>(); UpdateWrapper<BomNewPbomChildEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode,backRowId); updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode, backRowId);
updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId,backRowId); updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId, backRowId);
} }
/** /**
* 发布MBOM * 发布MBOM
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException { public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewPbomParentEntity rootParent = this.getById(bomRowId); BomNewPbomParentEntity rootParent = this.getById(bomRowId);
List<BomNewPbomParentVO> allChild = getAllBom(bomRowId, 0); List<BomNewPbomParentVO> allChild = getAllBom(bomRowId, 0);
if(StrUtil.isBlank(rootParent.getOrderNo())){ if (StrUtil.isBlank(rootParent.getOrderNo())) {
String orderNo = crmService.getOrderNo(rootParent.getMaterialNo()); String orderNo = crmService.getOrderNo(rootParent.getMaterialNo());
rootParent.setOrderNo(orderNo); rootParent.setOrderNo(orderNo);
} }
VUtils.isTure(StrUtil.isBlank(rootParent.getOrderNo())).throwMessage("没有获取到订单号"); VUtils.isTure(StrUtil.isBlank(rootParent.getOrderNo())).throwMessage("没有获取到订单号");
List<String> noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); List<String> noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList)+"物料暂未分工厂,请分完工厂再进行发布"); VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList) + "物料暂未分工厂,请分完工厂再进行发布");
ConvertToMBom convertToMBom=new ConvertToMBom(rootParent ,allChild); ConvertToMBom convertToMBom = new ConvertToMBom(rootParent, allChild);
convertToMBom.convertToMBom(); convertToMBom.convertToMBom();
if(CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())){ if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) {
mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult()); mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult());
} }
if(CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())){ if (CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())) {
mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult()); mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult());
} }
//将PBOM改为已发布 //将PBOM改为已发布
@ -569,25 +595,24 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
rootParent.setStatus(PBomStatusEnum.PUBLISH.getValue()); rootParent.setStatus(PBomStatusEnum.PUBLISH.getValue());
this.updateById(rootParent); this.updateById(rootParent);
if(CollUtil.isNotEmpty(bomRowIds)){ if (CollUtil.isNotEmpty(bomRowIds)) {
this.getBaseMapper().toMBom(PBomStatusEnum.PUBLISH.getValue(), SessionUtil.getRealName(),bomRowIds); this.getBaseMapper().toMBom(PBomStatusEnum.PUBLISH.getValue(), SessionUtil.getRealName(), bomRowIds);
} }
return true; return true;
} }
/** /**
* 发布Pbom * 发布Pbom
*
* @param bomRowId * @param bomRowId
*/ */
public boolean realesePbom(Long bomRowId){ public boolean realesePbom(Long bomRowId) {
BomNewPbomParentEntity parent = this.getById(bomRowId); BomNewPbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(Objects.isNull(parent)).throwMessage("所选BOM-不存在"); VUtils.isTure(Objects.isNull(parent)).throwMessage("所选BOM-不存在");
if(parent.getMaterialNo().startsWith("31")){ if (parent.getMaterialNo().startsWith("31")) {
String orderNo = crmService.getOrderNo(parent.getMaterialNo()); String orderNo = crmService.getOrderNo(parent.getMaterialNo());
parent.setOrderNo(orderNo); parent.setOrderNo(orderNo);
@ -595,25 +620,25 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
try { try {
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0); 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()); 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") ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
bomRowIds.add(bomRowId); bomRowIds.add(bomRowId);
this.getBaseMapper().bomRelease(state,SessionUtil.getUserName(),bomRowIds); this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds);
//保存订单号 //保存订单号
this.updateById(parent); this.updateById(parent);
} catch (Exception ex) {
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败" + ex.getMessage());
} }
catch (Exception ex){ return true;
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败"+ex.getMessage());
}
return true;
} }
/** /**
* 获取CRM 订单号 * 获取CRM 订单号
*
* @param materialNo * @param materialNo
* @return * @return
*/ */
public String getCrmOrderNo(String materialNo){ public String getCrmOrderNo(String materialNo) {
return crmService.getOrderNo(materialNo); return crmService.getOrderNo(materialNo);
} }

View File

@ -76,9 +76,9 @@ public class UserRoleService {
public List<String> getUserOfFactory(){ public List<String> getUserOfFactory(){
Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId()); Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId());
if(userMultiplantFacRoleCount>0){ if(userMultiplantFacRoleCount>0){
return ImmutableList.of("1010","1020"); return ImmutableList.of(EBomConstant.MAIN_FACTORY_CODE_1010,EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
}else { }else {
return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of("1020") : ImmutableList.of("1010") ; return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of(EBomConstant.XIAN_TAO_FACTORY_CODE_1020) : ImmutableList.of(EBomConstant.MAIN_FACTORY_CODE_1010) ;
} }
} }
} }

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nflg.product.bomnew.mapper.master.BomNewPbomMaterialUseMapper">
<resultMap id="BaseResultMap" type="com.nflg.product.bomnew.pojo.entity.BomNewPbomMaterialUseEntity">
<!--@mbg.generated-->
<!--@Table t_bom_new_pbom_material_use -->
<id column="row_id" property="rowId" jdbcType="BIGINT"/>
<result column="material_no" property="materialNo" jdbcType="VARCHAR"/>
<result column="parent_material_no" property="parentMaterialNo" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
row_id, material_no, parent_material_no </sql>
</mapper>

View File

@ -124,6 +124,48 @@
</foreach> </foreach>
</update> </update>
<update id="updatePBomMaterialUse">
SET @@global.group_concat_max_len=804800;
truncate table t_bom_new_pbom_material_use;
INSERT INTO `t_bom_new_pbom_material_use` (`row_id`, `material_no`, `parent_material_no`)
select min(b.row_id) rowId, b.material_no, GROUP_CONCAt( distinct a.material_no) as value_list
from t_bom_new_pbom_parent a
join t_bom_new_pbom_child b on a.row_id=b.parent_row_id and a.last_version_is=1
group by b.material_no ;
</update>
<!--物料编码搜索-父级-->
<select id="getParentForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
SELECT created_by as bomCreatedBy , row_id as bomRowId, row_id as childBomRowId, a.*
FROM t_bom_new_pbom_parent a where a.last_version_is=1
<if test="userFac!=null and userFac!=''">
and fac_code=#{userFac}
</if> and material_no in
<foreach collection="materialNoList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!--物料编码搜索-子级-->
<select id="getChildForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
select if(c.status=4,2,c.status) as status ,c.current_version , c.created_by as bomCreatedBy
,c.devise_name,c.devise_user_code,c.dept_name ,
c.row_id as bomRowId, c.row_id as childBomRowId, b.*
from t_bom_new_pbom_parent a
join t_bom_new_pbom_child b on a.row_id =b.parent_row_id
left join t_bom_new_pbom_parent c on b.material_no=c.material_no and c.last_version_is=1
where a.last_version_is=1
<if test="userFac!=null and userFac!=''">
and a.fac_code=#{userFac}
</if>
and ( b.material_no in
<foreach collection="materialNoList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
or b.material_no=#{materialNo})
</select>