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:
commit
d8542fee07
|
|
@ -61,7 +61,7 @@ public class PBomApi extends BaseApi {
|
||||||
@PostMapping("releaseListByPage")
|
@PostMapping("releaseListByPage")
|
||||||
@ApiOperation("PBom已发布工作列表")
|
@ApiOperation("PBom已发布工作列表")
|
||||||
public ResultVO<IPage<BomNewPbomParentVO>> releaseListByPage(@RequestBody BomNewPbomParentQuery query) {
|
public ResultVO<IPage<BomNewPbomParentVO>> releaseListByPage(@RequestBody BomNewPbomParentQuery query) {
|
||||||
return ResultVO.success();
|
return ResultVO.success(bomNewPbomParentService.releaseListByPage(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("getChild")
|
@GetMapping("getChild")
|
||||||
|
|
@ -125,7 +125,7 @@ public class PBomApi extends BaseApi {
|
||||||
|
|
||||||
@PostMapping("createTechnologyPackage")
|
@PostMapping("createTechnologyPackage")
|
||||||
@ApiOperation("编辑-创建虚拟包")
|
@ApiOperation("编辑-创建虚拟包")
|
||||||
public ResultVO<BaseMaterialVO> createTechnologyPackage(TechnologyPackageParam packageParam) throws IOException {
|
public ResultVO<BaseMaterialVO> createTechnologyPackage(@Valid @RequestBody TechnologyPackageParam packageParam) throws IOException {
|
||||||
|
|
||||||
return ResultVO.success( bomNewPbomParentService.createTechnologyPackage(packageParam));
|
return ResultVO.success( bomNewPbomParentService.createTechnologyPackage(packageParam));
|
||||||
|
|
||||||
|
|
@ -178,9 +178,6 @@ public class PBomApi extends BaseApi {
|
||||||
VUtils.isTure(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus())).throwMessage("只有已发布的BOM才能生成MBom");
|
VUtils.isTure(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus())).throwMessage("只有已发布的BOM才能生成MBom");
|
||||||
//
|
//
|
||||||
VUtils.isTure(!parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)).throwMessage("只有1010工厂BOM才能进行分工厂");
|
VUtils.isTure(!parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)).throwMessage("只有1010工厂BOM才能进行分工厂");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ResultVO.success(bomNewPbomParentService.convertToMBom(bomRowId));
|
return ResultVO.success(bomNewPbomParentService.convertToMBom(bomRowId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,27 @@ public class NacosConfig {
|
||||||
@Value("${material.add.url}")
|
@Value("${material.add.url}")
|
||||||
private String addMaterialUrl;
|
private String addMaterialUrl;
|
||||||
|
|
||||||
|
@Value("${crm.token.url}")
|
||||||
|
private String crmTokenUrl;
|
||||||
|
|
||||||
|
@Value("${crm.order.url}")
|
||||||
|
private String crmOrderUrl;
|
||||||
|
|
||||||
|
@Value("${crm.grant_type}")
|
||||||
|
private String crmGrantType;
|
||||||
|
|
||||||
|
@Value("${crm.client_id}")
|
||||||
|
private String crmClientId;
|
||||||
|
|
||||||
|
@Value("${crm.client_secret}")
|
||||||
|
private String crmClientSecret;
|
||||||
|
|
||||||
|
@Value("${crm.username}")
|
||||||
|
private String crmUsername;
|
||||||
|
|
||||||
|
@Value("${crm.password}")
|
||||||
|
private String crmPassword;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,13 @@ public interface BomNewPbomParentMapper extends BaseMapper<BomNewPbomParentEntit
|
||||||
|
|
||||||
Page<BomNewPbomParentVO> workDetailsListByPage(Page<BomNewPbomParentQuery> page, @Param("query") BomNewPbomParentQuery query , @Param("userFac") String userFac);
|
Page<BomNewPbomParentVO> workDetailsListByPage(Page<BomNewPbomParentQuery> page, @Param("query") BomNewPbomParentQuery query , @Param("userFac") String userFac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已发布列表
|
||||||
|
* @author 大米
|
||||||
|
* @date 2024/1/6 17:26
|
||||||
|
*/
|
||||||
|
Page<BomNewPbomParentVO> releaseListByPage(Page<BomNewPbomParentQuery> page, @Param("query") BomNewPbomParentQuery query);
|
||||||
List<BomNewPbomParentVO> getParentChild(@Param("parentRowId") Long parentRowId);
|
List<BomNewPbomParentVO> getParentChild(@Param("parentRowId") Long parentRowId);
|
||||||
|
|
||||||
|
void bomRelease(@Param("releaseUserName")String releaseUserName, @Param("rowIds") List<Long> rowIds );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* crm 获取TONKEN 结果
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CrmGetTokenResultDTO {
|
||||||
|
|
||||||
|
private String access_token;
|
||||||
|
|
||||||
|
private String token_type;
|
||||||
|
|
||||||
|
private String signature;
|
||||||
|
|
||||||
|
private String instance_url;
|
||||||
|
}
|
||||||
|
|
@ -55,6 +55,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -115,7 +116,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(materialNo)) {
|
if (StrUtil.isNotBlank(materialNo)) {
|
||||||
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician());
|
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
||||||
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo);
|
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo);
|
||||||
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo);
|
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo);
|
||||||
|
|
@ -132,7 +133,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
returnResult = result;
|
returnResult = result;
|
||||||
}
|
}
|
||||||
//动态判断异常
|
//动态判断异常
|
||||||
CheckEBomExceptoinDynamic.check(returnResult.getRecords());
|
// CheckEBomExceptoinDynamic.check(returnResult.getRecords());
|
||||||
return returnResult;
|
return returnResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,12 +148,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
resutlData.setPages(1);
|
resutlData.setPages(1);
|
||||||
resutlData.setCurrent(1L);
|
resutlData.setCurrent(1L);
|
||||||
List<BomNewEbomParentVO> all = new ArrayList<>();
|
List<BomNewEbomParentVO> all = new ArrayList<>();
|
||||||
all.addAll(resultParents);
|
// all.addAll(resultParents);
|
||||||
all.addAll(childs);
|
all.addAll(childs);
|
||||||
List<BomNewEbomParentVO> result = new ArrayList<>();
|
List<BomNewEbomParentVO> result = new ArrayList<>();
|
||||||
for (BomNewEbomParentVO vo : resultParents) {
|
for (BomNewEbomParentVO vo : resultParents) {
|
||||||
vo.setParentRowId(0L);
|
//vo.setParentRowId(0L);
|
||||||
result.addAll(CTreeUtils.toTree(0L, all, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId));
|
List<BomNewEbomParentVO> da=new ArrayList<>();
|
||||||
|
da.addAll(childs);
|
||||||
|
da.add(vo);
|
||||||
|
result.addAll(CTreeUtils.toTree(0L, da, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId));
|
||||||
}
|
}
|
||||||
resutlData.setRecords(result);
|
resutlData.setRecords(result);
|
||||||
return resutlData;
|
return resutlData;
|
||||||
|
|
@ -165,9 +169,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
* @param materialNo
|
* @param materialNo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) {
|
public Set<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) {
|
||||||
BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one();
|
BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one();
|
||||||
List<String> result = new ArrayList<>();
|
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)) {
|
if (selfIs && CollUtil.isNotEmpty(relSkuNo)) {
|
||||||
|
|
@ -319,7 +323,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//动态判断异常
|
//动态判断异常
|
||||||
CheckEBomExceptoinDynamic.check(parentChild);
|
//CheckEBomExceptoinDynamic.check(parentChild);
|
||||||
return parentChild;
|
return parentChild;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -531,7 +535,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
*/
|
*/
|
||||||
public void generateVirtualPackage(VirtualPackageParamDto paramDto) {
|
public void generateVirtualPackage(VirtualPackageParamDto paramDto) {
|
||||||
try {
|
try {
|
||||||
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(paramDto.getBomRowId()));
|
BomNewEbomParentEntity root= this.getById(paramDto.getBomRowId());
|
||||||
|
Boolean flag=true;
|
||||||
|
for (Integer f :paramDto.getVirtualPackageValue()) {
|
||||||
|
flag=flag & ( (root.getVirtrualPackageEnum() & f)==f);
|
||||||
|
}
|
||||||
|
VUtils.isTure(flag).throwMessage("已生成虚拟包,无需重复生成");
|
||||||
|
|
||||||
|
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, root);
|
||||||
materialMainService.intiMaterialInfo(ImmutableList.of(parent), BomNewEbomParentVO::getMaterialNo);
|
materialMainService.intiMaterialInfo(ImmutableList.of(parent), BomNewEbomParentVO::getMaterialNo);
|
||||||
if (parent.getMaterialCategoryCode().startsWith("30") || parent.getMaterialCategoryCode().equals("200401")) {
|
if (parent.getMaterialCategoryCode().startsWith("30") || parent.getMaterialCategoryCode().equals("200401")) {
|
||||||
VirtualPackageBase generate;
|
VirtualPackageBase generate;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import com.nflg.product.bomnew.constant.*;
|
import com.nflg.product.bomnew.constant.*;
|
||||||
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
||||||
|
|
@ -73,6 +75,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BomNewMbomDetailService mBomDetailService;
|
private BomNewMbomDetailService mBomDetailService;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmService crmService;
|
||||||
/**
|
/**
|
||||||
* pbom-工作列表
|
* pbom-工作列表
|
||||||
*
|
*
|
||||||
|
|
@ -80,9 +86,76 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IPage<BomNewPbomParentVO> workDetailsListByPage(BomNewPbomParentQuery query) {
|
public IPage<BomNewPbomParentVO> workDetailsListByPage(BomNewPbomParentQuery query) {
|
||||||
|
//物料编码搜索或图号搜索
|
||||||
|
// if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
||||||
|
// String materialNo = query.getMaterialNo();
|
||||||
|
// if (StrUtil.isBlank(materialNo)) {
|
||||||
|
// List<MaterialMainEntity> materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
|
||||||
|
// if (CollUtil.isNotEmpty(materialList)) {
|
||||||
|
// materialNo = materialList.get(0).getMaterialNo();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (StrUtil.isNotBlank(materialNo)) {
|
||||||
|
// List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList());
|
||||||
|
// if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
||||||
|
// List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo);
|
||||||
|
// List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo);
|
||||||
|
// List<BomNewEbomParentVO> data = new ArrayList<>();
|
||||||
|
// data.addAll(parents);
|
||||||
|
// data.addAll(childs);
|
||||||
|
// materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
||||||
|
// returnResult = handSeachToTree(parents, childs);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
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);
|
||||||
|
return result;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取物料所有子级
|
||||||
|
* @param materialNo
|
||||||
|
* @param selfIs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
// public Set<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) {
|
||||||
|
// BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one();
|
||||||
|
// Set<String> result = new HashSet<>();
|
||||||
|
// if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(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);
|
||||||
|
// List<BomNewEbomMaterialUseEntity> relSkuList = bomNewEbomMaterialUseService.lambdaQuery().in(BomNewEbomMaterialUseEntity::getMaterialNo, relSkuNo).list();
|
||||||
|
// relSkuNo.clear();
|
||||||
|
// Set<String> finalRelSkuNo = relSkuNo;
|
||||||
|
// relSkuList.forEach(k -> {
|
||||||
|
// if (StrUtil.isNotBlank(k.getParentMaterialNo())) {
|
||||||
|
// finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")));
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// relSkuNo = finalRelSkuNo;
|
||||||
|
// if (CollUtil.isNotEmpty(relSkuNo) && selfIs) {
|
||||||
|
// relSkuNo = getSelfMaterialNo(relSkuNo);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory());
|
/**
|
||||||
|
* 已
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IPage<BomNewPbomParentVO> releaseListByPage(BomNewPbomParentQuery query) {
|
||||||
|
Page<BomNewPbomParentVO> result = this.getBaseMapper().releaseListByPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
@ -432,6 +505,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException {
|
public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||||
|
//获取CRM订单号
|
||||||
|
|
||||||
BomNewPbomParentEntity rootParent = this.getById(bomRowId);
|
BomNewPbomParentEntity rootParent = this.getById(bomRowId);
|
||||||
List<BomNewPbomParentVO> allChild = getAllBom(bomRowId, 0);
|
List<BomNewPbomParentVO> allChild = getAllBom(bomRowId, 0);
|
||||||
|
|
||||||
|
|
@ -443,7 +518,27 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
if(CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())){
|
if(CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())){
|
||||||
mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult());
|
mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult());
|
||||||
}
|
}
|
||||||
|
//将PBOM改为已发布
|
||||||
|
List<Long> bomRowIds = allChild.stream().filter(u -> u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
||||||
|
rootParent.setOrderNo("订单号");
|
||||||
|
rootParent.setStatus(PBomStatusEnum.PUBLISH.getValue());
|
||||||
|
this.updateById(rootParent);
|
||||||
|
if(CollUtil.isNotEmpty(bomRowIds)){
|
||||||
|
this.getBaseMapper().bomRelease(SessionUtil.getRealName(),bomRowIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取CRM 订单号
|
||||||
|
* @param materialNo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCrmOrderNo(String materialNo){
|
||||||
|
return crmService.getOrderNo(materialNo);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import cn.hutool.cache.CacheUtil;
|
||||||
|
import cn.hutool.cache.impl.TimedCache;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.nflg.product.bomnew.config.NacosConfig;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.CrmGetTokenResultDTO;
|
||||||
|
import com.nflg.product.bomnew.util.HttpUtils;
|
||||||
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import springfox.documentation.spring.web.json.Json;
|
||||||
|
|
||||||
|
import javax.print.attribute.standard.MediaSize;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CRM 服务
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CrmService {
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer expire =2* 60 * 60 * 1000;
|
||||||
|
private final String tokenCacheKey="CRM-TOKEN-CATCH-KEY";
|
||||||
|
|
||||||
|
TimedCache<String, String> crmTokenCache = CacheUtil.newTimedCache(expire);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取token
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public String getToken() throws IOException {
|
||||||
|
try {
|
||||||
|
if (StrUtil.isBlank(crmTokenCache.get(tokenCacheKey))) {
|
||||||
|
HttpUtils httpUtils = new HttpUtils();
|
||||||
|
Map<String, String> paramMp = new HashMap<>();
|
||||||
|
paramMp.put("grant_type", NacosConfig.getNacosConfig().getCrmGrantType());
|
||||||
|
paramMp.put("client_id", NacosConfig.getNacosConfig().getCrmClientId());
|
||||||
|
paramMp.put("username", NacosConfig.getNacosConfig().getCrmUsername());
|
||||||
|
paramMp.put("password", NacosConfig.getNacosConfig().getCrmPassword());
|
||||||
|
paramMp.put("client_secret", NacosConfig.getNacosConfig().getCrmClientSecret());
|
||||||
|
String s = httpUtils.doformPost(NacosConfig.getNacosConfig().getCrmTokenUrl(), paramMp);
|
||||||
|
CrmGetTokenResultDTO result = JSONObject.parseObject(s, CrmGetTokenResultDTO.class);
|
||||||
|
if (Objects.nonNull(result) && StrUtil.isNotBlank(result.getAccess_token())) {
|
||||||
|
|
||||||
|
crmTokenCache.put(tokenCacheKey, result.getAccess_token());
|
||||||
|
} else {
|
||||||
|
VUtils.isTure(true).throwMessage("获取CRM-token 失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crmTokenCache.get(tokenCacheKey);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
VUtils.isTure(true).throwMessage("获取CRM-token 失败:"+e.getMessage());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订单号
|
||||||
|
* @param materialNo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getOrderNo(String materialNo) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
HttpUtils httpUtils = new HttpUtils();
|
||||||
|
Map<String, String> paramMp = new HashMap<>();
|
||||||
|
List<Map<String, String>> reBody = new ArrayList<>();
|
||||||
|
reBody.add(ImmutableMap.of("matnr", materialNo));
|
||||||
|
String token = StrUtil.join(" ", "Bearer", getToken());
|
||||||
|
String orderResult = httpUtils.doPost(NacosConfig.getNacosConfig().getCrmOrderUrl(), JSON.toJSONString(reBody), token);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(orderResult);
|
||||||
|
String code = jsonObject.getString("code");
|
||||||
|
if (code == "0") {
|
||||||
|
String orderMap = jsonObject.getString("orderMap");
|
||||||
|
if (StrUtil.isNotBlank(orderMap)) {
|
||||||
|
JSONObject order = JSONObject.parseObject(orderMap);
|
||||||
|
return Objects.nonNull(order) ? order.getString(materialNo) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
catch (Exception ex){
|
||||||
|
VUtils.isTure(true).throwMessage("获取订单号失败:"+ex.getMessage());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -372,10 +372,22 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void supplementMaterialInfoForNoMaterialNoByRel(List<BomOriginalListVO> data){
|
||||||
|
List<BomOriginalListVO> noMateralList = data.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||||
|
for ( BomOriginalListVO item: noMateralList) {
|
||||||
|
handlerCommonMaterialForReplace(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合并相同物料
|
* 合并相同物料
|
||||||
*/
|
*/
|
||||||
private List<BomOriginalListVO> mergeBOM(List<BomOriginalListVO> list) {
|
private List<BomOriginalListVO> mergeBOM(List<BomOriginalListVO> list) {
|
||||||
|
//合并补充物料信息
|
||||||
|
supplementMaterialInfoForNoMaterialNoByRel(list);
|
||||||
|
|
||||||
List<BomOriginalListVO> result = new ArrayList();
|
List<BomOriginalListVO> result = new ArrayList();
|
||||||
result.addAll(list.stream().filter(u->StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()));
|
result.addAll(list.stream().filter(u->StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()));
|
||||||
list = list.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).collect(Collectors.toList());
|
list = list.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import com.nflg.product.bomnew.util.VUtils;
|
||||||
import com.nflg.product.bomnew.util.VersionUtil;
|
import com.nflg.product.bomnew.util.VersionUtil;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -44,6 +45,10 @@ public class ConvertToMBom {
|
||||||
|
|
||||||
private List<ConvertToMBomDTO> allChild_1010;
|
private List<ConvertToMBomDTO> allChild_1010;
|
||||||
|
|
||||||
|
private List<ConvertToMBomDTO> allChildTreeList_1020 = new ArrayList<>();
|
||||||
|
|
||||||
|
private List<ConvertToMBomDTO> allChildTreeList_1010 = new ArrayList();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
List<BomNewMbomParentEntity> mBomParentResult = new ArrayList<>();
|
List<BomNewMbomParentEntity> mBomParentResult = new ArrayList<>();
|
||||||
|
|
||||||
|
|
@ -51,10 +56,13 @@ public class ConvertToMBom {
|
||||||
List<BomNewMbomDetailEntity> mBomDetailResult = new ArrayList<>();
|
List<BomNewMbomDetailEntity> mBomDetailResult = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ConvertToMBom(BomNewPbomParentEntity inRootParent, List<BomNewPbomParentVO> inAllChild) {
|
public ConvertToMBom(BomNewPbomParentEntity inRootParent, List<BomNewPbomParentVO> inAllChild) {
|
||||||
this.parent = inRootParent;
|
this.parent = inRootParent;
|
||||||
this.allChild_1010 = Convert.toList(ConvertToMBomDTO.class, inAllChild);
|
this.allChild_1010 = Convert.toList(ConvertToMBomDTO.class, inAllChild);
|
||||||
Collections.copy(allChild_1010, allChild_1020);
|
|
||||||
|
allChild_1020 = (List<ConvertToMBomDTO>) ((ArrayList<ConvertToMBomDTO>) allChild_1010).clone();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,7 +85,7 @@ public class ConvertToMBom {
|
||||||
BomNewMbomParentEntity mBomParent = new BomNewMbomParentEntity();
|
BomNewMbomParentEntity mBomParent = new BomNewMbomParentEntity();
|
||||||
BeanUtil.copyProperties(parent, mBomParent);
|
BeanUtil.copyProperties(parent, mBomParent);
|
||||||
BomNewMbomParentEntity oldParent = SpringUtil.getBean(BomNewMbomParentService.class).lambdaQuery().eq(BomNewMbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
BomNewMbomParentEntity oldParent = SpringUtil.getBean(BomNewMbomParentService.class).lambdaQuery().eq(BomNewMbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||||
.eq(BomNewMbomParentEntity::getLastVersionIs, 1).eq(BomNewMbomParentEntity::getFacCode,facCode).one();
|
.eq(BomNewMbomParentEntity::getLastVersionIs, 1).eq(BomNewMbomParentEntity::getFacCode, facCode).one();
|
||||||
if (Objects.nonNull(oldParent)) {
|
if (Objects.nonNull(oldParent)) {
|
||||||
mBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
mBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
||||||
oldParent.setLastVersionIs(0);
|
oldParent.setLastVersionIs(0);
|
||||||
|
|
@ -92,37 +100,35 @@ public class ConvertToMBom {
|
||||||
mBomParent.setModifyTime(LocalDateTime.now());
|
mBomParent.setModifyTime(LocalDateTime.now());
|
||||||
this.mBomParentResult.add(mBomParent);
|
this.mBomParentResult.add(mBomParent);
|
||||||
|
|
||||||
buildChild(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode)? allChild_1010:allChild_1020,mBomParent.getRowId());
|
buildChild(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode) ? allChildTreeList_1010 : allChildTreeList_1020, mBomParent.getRowId());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建子级
|
* 构建子级
|
||||||
*
|
*
|
||||||
* @param allChild
|
* @param allChild
|
||||||
*/
|
*/
|
||||||
private void buildChild(List<ConvertToMBomDTO> allChild, Long bomRowId) {
|
private void buildChild(List<ConvertToMBomDTO> allChild, Long bomRowId) {
|
||||||
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChild_1010, ConvertToMBomDTO::getRelParentRowId, ConvertToMBomDTO::getBomRowId);
|
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChild, ConvertToMBomDTO::getRelParentRowId, ConvertToMBomDTO::getBomRowId);
|
||||||
|
; for (ConvertToMBomDTO item : childBomTree) {
|
||||||
List<ConvertToMBomDTO> parentChildren;
|
|
||||||
Long parentRowId = 0L;
|
|
||||||
for (ConvertToMBomDTO item : childBomTree) {
|
|
||||||
//构建子级
|
//构建子级
|
||||||
if (item.getDelIs().equals(0)) {
|
if (item.getDelIs().equals(0)) {
|
||||||
parentRowId = buildChildDo(item, bomRowId, 0L);
|
buildMBomChildDo(item, 0L,bomRowId);
|
||||||
}
|
|
||||||
parentChildren = item.getChildNodes();
|
|
||||||
while (CollUtil.isNotEmpty(parentChildren)) {
|
|
||||||
for (ConvertToMBomDTO itemChild : parentChildren) {
|
|
||||||
if (item.getDelIs().equals(0)) {
|
|
||||||
parentRowId = buildChildDo(itemChild, bomRowId, parentRowId);
|
|
||||||
}
|
|
||||||
parentChildren = itemChild.getChildNodes();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildMBomChildDo(ConvertToMBomDTO item , Long parentRowId ,Long bomRowId){
|
||||||
|
if (item.getDelIs().equals(0)) {
|
||||||
|
parentRowId = buildChildDo(item, bomRowId, parentRowId);
|
||||||
|
}
|
||||||
|
for (ConvertToMBomDTO itemChild : item.getChildNodes()) {
|
||||||
|
buildMBomChildDo(itemChild, parentRowId,bomRowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -130,16 +136,17 @@ public class ConvertToMBom {
|
||||||
/**
|
/**
|
||||||
* 处理制作下为空的虚拟包
|
* 处理制作下为空的虚拟包
|
||||||
* 当制作下子级为空时--删除该发货,制作,和直发
|
* 当制作下子级为空时--删除该发货,制作,和直发
|
||||||
* @param allChildTree
|
*
|
||||||
|
* @param
|
||||||
*/
|
*/
|
||||||
private void handEmptyMakePackage(List<ConvertToMBomDTO> allChildTree){
|
private void handEmptyMakePackage() {
|
||||||
|
|
||||||
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChild_1020, ConvertToMBomDTO::getRelParentRowId, ConvertToMBomDTO::getBomRowId);
|
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChildTreeList_1020, ConvertToMBomDTO::getRelParentRowId, ConvertToMBomDTO::getBomRowId);
|
||||||
for (ConvertToMBomDTO item : allChildTree) {
|
for (ConvertToMBomDTO item : childBomTree) {
|
||||||
if(VirtualPackageTypeEnum.DELIVERY_PACKAGE.equalsValue(item.getVirtualPartType()) ){
|
if (VirtualPackageTypeEnum.DELIVERY_PACKAGE.equalsValue(item.getVirtualPartType())) {
|
||||||
List<ConvertToMBomDTO> makeChild = item.getChildNodes().stream().filter(u -> VirtualPackageTypeEnum.MAKING_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList());
|
List<ConvertToMBomDTO> makeChild = item.getChildNodes().stream().filter(u -> VirtualPackageTypeEnum.MAKING_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList());
|
||||||
|
|
||||||
if(CollUtil.isEmpty(makeChild) || CollUtil.isEmpty(makeChild.get(0).getChildNodes().stream().filter(u->u.getDelIs().equals(0)).collect(Collectors.toList()))){
|
if (CollUtil.isEmpty(makeChild) || CollUtil.isEmpty(makeChild.get(0).getChildNodes().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList()))) {
|
||||||
item.setRelParentRowId(0L);
|
item.setRelParentRowId(0L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,105 +164,107 @@ public class ConvertToMBom {
|
||||||
child.setCreatedBy(SessionUtil.getUserCode());
|
child.setCreatedBy(SessionUtil.getUserCode());
|
||||||
child.setCreatedTime(LocalDateTime.now());
|
child.setCreatedTime(LocalDateTime.now());
|
||||||
child.setModifyTime(LocalDateTime.now());
|
child.setModifyTime(LocalDateTime.now());
|
||||||
|
child.setSourceRowId(dto.getRowId());
|
||||||
this.mBomDetailResult.add(child);
|
this.mBomDetailResult.add(child);
|
||||||
return child.getRowId();
|
return child.getRowId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handler1010() {
|
private void handler1010() {
|
||||||
|
|
||||||
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChild_1010, ConvertToMBomDTO::getParentRowId, ConvertToMBomDTO::getBomRowId);
|
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChild_1010, ConvertToMBomDTO::getParentRowId, ConvertToMBomDTO::getBomRowId);
|
||||||
|
|
||||||
List<ConvertToMBomDTO> parentChildren;
|
|
||||||
|
|
||||||
for (ConvertToMBomDTO item : childBomTree) {
|
for (ConvertToMBomDTO item : childBomTree) {
|
||||||
//默认
|
//默认
|
||||||
item.setRelParentRowId(item.getParentRowId());
|
recursionHandlerChild1010(item);
|
||||||
setDel(item, EBomConstant.MAIN_FACTORY_CODE_1010);
|
|
||||||
parentChildren = item.getChildNodes();
|
|
||||||
|
|
||||||
while (CollUtil.isNotEmpty(parentChildren)) {
|
|
||||||
for (ConvertToMBomDTO childItem : parentChildren) {
|
|
||||||
//默认
|
|
||||||
childItem.setRelParentRowId(childItem.getParentRowId());
|
|
||||||
setDel(childItem, EBomConstant.MAIN_FACTORY_CODE_1010);
|
|
||||||
|
|
||||||
handlerMaterial(childItem, EBomConstant.MAIN_FACTORY_CODE_1010);
|
|
||||||
parentChildren = childItem.getChildNodes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void recursionHandlerChild1010(ConvertToMBomDTO item) {
|
||||||
* 处理1020
|
|
||||||
*/
|
item.setRelParentRowId(item.getParentRowId());
|
||||||
|
setDel(item, EBomConstant.MAIN_FACTORY_CODE_1010);
|
||||||
|
handlerMaterial(item, EBomConstant.MAIN_FACTORY_CODE_1010);
|
||||||
|
|
||||||
|
this.allChildTreeList_1010.add(item);
|
||||||
|
for (ConvertToMBomDTO itemChild : item.getChildNodes()) {
|
||||||
|
recursionHandlerChild1010(itemChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handler1020() {
|
private void handler1020() {
|
||||||
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChild_1020, ConvertToMBomDTO::getParentRowId, ConvertToMBomDTO::getBomRowId);
|
List<ConvertToMBomDTO> childBomTree = ConvertToMbomUtil.toTree(parent.getRowId(), allChild_1020, ConvertToMBomDTO::getParentRowId, ConvertToMBomDTO::getBomRowId);
|
||||||
//虚拟包名称加仙桃
|
//虚拟包名称加仙桃
|
||||||
initFac1020Info(childBomTree);
|
initFac1020Info(childBomTree);
|
||||||
|
|
||||||
List<ConvertToMBomDTO> parentChildren;
|
|
||||||
|
|
||||||
//31下直发包
|
|
||||||
ConvertToMBomDTO directDeliveryPackage;
|
|
||||||
|
|
||||||
ConvertToMBomDTO parentNode = Convert.convert(ConvertToMBomDTO.class, parent);
|
|
||||||
for (ConvertToMBomDTO item : childBomTree) {
|
for (ConvertToMBomDTO item : childBomTree) {
|
||||||
//默认
|
|
||||||
item.setRelParentRowId(item.getParentRowId());
|
|
||||||
setDel(item, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
|
||||||
parentChildren = item.getChildNodes();
|
|
||||||
directDeliveryPackage = item.getChildNodes().stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList()).get(0);
|
|
||||||
VUtils.isTure(Objects.isNull(directDeliveryPackage)).throwMessage("发货包下,没有直发包");
|
|
||||||
while (CollUtil.isNotEmpty(parentChildren)) {
|
|
||||||
parentNode = item;
|
|
||||||
for (ConvertToMBomDTO childItem : parentChildren) {
|
|
||||||
|
|
||||||
//默认
|
ConvertToMBomDTO directDeliveryPackage = item.getChildNodes().stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList()).get(0);
|
||||||
childItem.setRelParentRowId(childItem.getParentRowId());
|
VUtils.isTure(Objects.isNull(directDeliveryPackage)).throwMessage("发货包下,没有直发包");
|
||||||
setDel(childItem, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
|
||||||
//非31下的直发包
|
recursionHandlerChild1020(item, directDeliveryPackage);
|
||||||
if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(parentNode.getVirtualPartType()) && parentNode.getRowId() != directDeliveryPackage.getRowId()) {
|
|
||||||
handlerDirectDeliveryPackage(childItem, EBomConstant.XIAN_TAO_FACTORY_CODE_1020, directDeliveryPackage);
|
|
||||||
} else {
|
|
||||||
handlerMaterial(childItem, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
|
||||||
}
|
|
||||||
parentChildren = childItem.getChildNodes();
|
|
||||||
parentNode = childItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//处理制作包无下级的情况
|
//处理制作包无下级的情况
|
||||||
handEmptyMakePackage(childBomTree);
|
handEmptyMakePackage();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void recursionHandlerChild1020(ConvertToMBomDTO item, ConvertToMBomDTO directDeliveryPackage) {
|
||||||
|
|
||||||
|
|
||||||
|
item.setRelParentRowId(item.getParentRowId());
|
||||||
|
setDel(item, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
||||||
|
//非31下的直发包
|
||||||
|
if(!item.getParentRowId().equals(parent.getRowId())) {
|
||||||
|
ConvertToMBomDTO parentNode = getParent(item.getParentRowId(), EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
||||||
|
if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(parentNode.getVirtualPartType()) && parentNode.getRowId() != directDeliveryPackage.getRowId()) {
|
||||||
|
handlerDirectDeliveryPackage(item, EBomConstant.XIAN_TAO_FACTORY_CODE_1020, directDeliveryPackage);
|
||||||
|
} else {
|
||||||
|
handlerMaterial(item, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.allChildTreeList_1020.add(item);
|
||||||
|
for (ConvertToMBomDTO itemChild : item.getChildNodes()) {
|
||||||
|
recursionHandlerChild1020(itemChild, directDeliveryPackage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理直发包下的物料
|
* 处理直发包下的物料
|
||||||
* 所有直发包,归到31下的直发包
|
* 所有直发包,归到31下的直发包
|
||||||
*/
|
*/
|
||||||
private void handlerDirectDeliveryPackage(ConvertToMBomDTO childItem, String facCode, ConvertToMBomDTO directDeliveryPackage) {
|
private void handlerDirectDeliveryPackage(ConvertToMBomDTO childItem, String facCode, ConvertToMBomDTO directDeliveryPackage) {
|
||||||
ConvertToMBomDTO relParent = getParent(childItem.getParentRowId(), facCode);
|
if (!childItem.getParentRowId().equals(parent.getRowId())) {
|
||||||
while (Objects.nonNull(relParent) && !VirtualPackageTypeEnum.MAKING_PACKAGE.equalsValue(relParent.getVirtualPartType())) {
|
ConvertToMBomDTO relParent = getParent(childItem.getParentRowId(), facCode);
|
||||||
childItem.setNum(NumberUtil.mul(childItem.getNum(), relParent.getNum()));
|
while (Objects.nonNull(relParent) && !VirtualPackageTypeEnum.MAKING_PACKAGE.equalsValue(relParent.getVirtualPartType())) {
|
||||||
relParent = getParent(relParent.getParentRowId(), facCode);
|
childItem.setNum(NumberUtil.mul(childItem.getNum(), relParent.getNum()));
|
||||||
|
relParent = getParent(relParent.getParentRowId(), facCode);
|
||||||
|
}
|
||||||
|
childItem.setRelParentRowId(directDeliveryPackage.getBomRowId());
|
||||||
}
|
}
|
||||||
childItem.setRelParentRowId(directDeliveryPackage.getBomRowId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理一般材料
|
* 处理一般材料(提层)
|
||||||
*
|
*
|
||||||
* @param childItem
|
* @param childItem
|
||||||
* @param facCode
|
* @param facCode
|
||||||
*/
|
*/
|
||||||
private void handlerMaterial(ConvertToMBomDTO childItem, String facCode) {
|
private void handlerMaterial(ConvertToMBomDTO childItem, String facCode) {
|
||||||
ConvertToMBomDTO relParent = getParent(childItem.getParentRowId(), facCode);
|
if (!childItem.getParentRowId().equals(parent.getRowId())) {
|
||||||
while (Objects.nonNull(relParent) && relParent.getDelIs().equals(1)) {
|
ConvertToMBomDTO relParent = getParent(childItem.getParentRowId(), facCode);
|
||||||
childItem.setNum(NumberUtil.mul(childItem.getNum(), relParent.getNum()));
|
while (Objects.nonNull(relParent) && relParent.getDelIs().equals(1)) {
|
||||||
relParent = getParent(relParent.getParentRowId(), facCode);
|
childItem.setNum(NumberUtil.mul(childItem.getNum(), relParent.getNum()));
|
||||||
|
relParent = getParent(relParent.getParentRowId(), facCode);
|
||||||
|
}
|
||||||
|
childItem.setRelParentRowId(relParent.getBomRowId());
|
||||||
}
|
}
|
||||||
childItem.setRelParentRowId(relParent.getBomRowId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDel(ConvertToMBomDTO item, String facCode) {
|
private void setDel(ConvertToMBomDTO item, String facCode) {
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
<!--获取工作列表-->
|
<!--获取工作列表-->
|
||||||
<select id="workDetailsListByPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
|
<select id="workDetailsListByPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
|
||||||
select * , row_id as bomRowId
|
select * , row_id as bomRowId
|
||||||
from t_bom_new_pbom_parent where root_is=1
|
from t_bom_new_pbom_parent where root_is=1 and status < 4
|
||||||
<if test="userFac!=null and userFac!=''">
|
<if test="userFac!=null and userFac!=''">
|
||||||
and fac_code=#{userFac}
|
and fac_code=#{userFac}
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -82,9 +82,36 @@
|
||||||
order by created_time desc
|
order by created_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!--获取已发布列表-->
|
||||||
|
<select id="releaseListByPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
|
||||||
|
select * , row_id as bomRowId
|
||||||
|
from t_bom_new_pbom_parent where root_is=1 and status = 4
|
||||||
|
<if test="query.startDate== null">
|
||||||
|
and release_time > DATE_SUB(release_time, INTERVAL 3 DAY)
|
||||||
|
</if>
|
||||||
|
<if test="query.facCode!= null and query.facCode!=''">
|
||||||
|
and fac_code = #{query.facCode}
|
||||||
|
</if>
|
||||||
|
<if test="query.materialNo!= null and query.materialNo!=''">
|
||||||
|
and material_no = #{query.materialNo}
|
||||||
|
</if>
|
||||||
|
<if test="query.drawingNo!= null and query.drawingNo!=''">
|
||||||
|
and drawing_no = #{query.drawingNo}
|
||||||
|
</if>
|
||||||
|
order by release_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
|
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
|
||||||
select * from t_bom_new_pbom_child where parent_row_id=#{parentRowId}
|
select * from t_bom_new_pbom_child where parent_row_id=#{parentRowId}
|
||||||
</select>
|
</select>
|
||||||
|
<!--bom发布-->
|
||||||
|
<update id="bomRelease">
|
||||||
|
update t_bom_new_pbom_parent set status=4 , release_user_name=#{releaseUserName} , release_time=now()
|
||||||
|
where row_id in
|
||||||
|
<foreach collection="rowIds" item="rowId" open="(" close=")" separator=",">
|
||||||
|
#{rowId}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue