PBOM库存地点、ebom排序问题
This commit is contained in:
parent
7e6aafd545
commit
5fdbceff47
|
|
@ -1,7 +1,9 @@
|
||||||
package com.nflg.product.bomnew.api.user;
|
package com.nflg.product.bomnew.api.user;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.EnumUtil;
|
import cn.hutool.core.util.EnumUtil;
|
||||||
|
|
@ -10,6 +12,7 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||||
import com.nflg.product.base.core.api.BaseApi;
|
import com.nflg.product.base.core.api.BaseApi;
|
||||||
|
|
@ -411,6 +414,16 @@ public class EbomApi extends BaseApi {
|
||||||
|
|
||||||
checkDeleteRule(dto);
|
checkDeleteRule(dto);
|
||||||
bomNewEbomParentService.deleteBomChild(dto.getDelDatas(), dto.getParent());
|
bomNewEbomParentService.deleteBomChild(dto.getDelDatas(), dto.getParent());
|
||||||
|
//修改排序号的值,按照物料编码升序 by 10002327 0830
|
||||||
|
if(CollectionUtil.isNotEmpty(dto.getDatas())){
|
||||||
|
List<BomNewEbomParentVO> copyList = ListUtil.toCopyOnWriteArrayList(dto.getDatas());
|
||||||
|
List<BomNewEbomParentVO> sortedList = copyList.stream().sorted(Comparator.comparing(BaseMaterialVO::getMaterialNo)).collect(Collectors.toList());
|
||||||
|
Map<String,String> materialMap = sortedList.stream().collect(Collectors.toMap(BaseMaterialVO::getMaterialNo,bom -> {
|
||||||
|
int idx = sortedList.indexOf(bom);
|
||||||
|
return StrUtil.padPre(String.valueOf(idx + 1),3,'0');
|
||||||
|
},(k1,k2)->k1));
|
||||||
|
dto.getDatas().forEach(bom -> bom.setOrderNumber(materialMap.getOrDefault(bom.getMaterialNo(),bom.getOrderNumber())));
|
||||||
|
}
|
||||||
BomNewEbomParentVO temporary = bomNewEbomParentService.temporary(dto);
|
BomNewEbomParentVO temporary = bomNewEbomParentService.temporary(dto);
|
||||||
|
|
||||||
return ResultVO.success(temporary);
|
return ResultVO.success(temporary);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.product.bomnew.api.user;
|
package com.nflg.product.bomnew.api.user;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
@ -25,6 +26,7 @@ import com.nflg.product.bomnew.util.VUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import nflg.product.common.vo.ResultVO;
|
import nflg.product.common.vo.ResultVO;
|
||||||
|
import org.apache.commons.compress.utils.Lists;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -38,6 +40,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* t_bom_new_pbom_parent 表控制层
|
* t_bom_new_pbom_parent 表控制层
|
||||||
|
|
@ -67,13 +71,61 @@ public class PBomApi extends BaseApi {
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialMainService materialMainService;
|
private MaterialMainService materialMainService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SapService sapService;
|
||||||
|
|
||||||
@PostMapping("workDetailsListByPage")
|
@PostMapping("workDetailsListByPage")
|
||||||
@ApiOperation("PBom工作列表")
|
@ApiOperation("PBom工作列表")
|
||||||
public ResultVO<IPage<BomNewPbomParentVO>> workDetailsListByPage(@RequestBody BomNewPbomParentQuery query) {
|
public ResultVO<IPage<BomNewPbomParentVO>> workDetailsListByPage(@RequestBody BomNewPbomParentQuery query) {
|
||||||
return ResultVO.success(bomNewPbomParentService.workDetailsListByPage(query));
|
IPage<BomNewPbomParentVO> r = bomNewPbomParentService.workDetailsListByPage(query);
|
||||||
|
//添加仓库地点 by 10002327 0830
|
||||||
|
if(!r.getRecords().isEmpty()){
|
||||||
|
List<String> materialNoList = Lists.newArrayList();
|
||||||
|
List<String> facList = Lists.newArrayList();
|
||||||
|
|
||||||
|
// r.getRecords().forEach(bom -> {
|
||||||
|
// materialNoList.add(bom.getMaterialNo());
|
||||||
|
// facList.add(bom.getFacCode());
|
||||||
|
// if(CollectionUtil.isNotEmpty(bom.getChildNodes())){
|
||||||
|
// materialNoList.addAll(bom.getChildNodes().stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList()));
|
||||||
|
// facList.addAll(bom.getChildNodes().stream().map(BomNewPbomParentVO::getFacCode).collect(Collectors.toList()));
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
this.get(r.getRecords(),materialNoList,facList);
|
||||||
|
List<Map<String,Object>> lgproList = sapService.lgproByList(materialNoList,facList);
|
||||||
|
Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m-> {
|
||||||
|
return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"));
|
||||||
|
},m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
|
||||||
|
this.set(r.getRecords(),lgproMap);
|
||||||
|
// r.getRecords().forEach(re -> {
|
||||||
|
// re.setLgpro(lgproMap.get(StrUtil.padPre(re.getMaterialNo(),18,"0") +re.getFacCode()));
|
||||||
|
// if(CollectionUtil.isNotEmpty(re.getChildNodes())){
|
||||||
|
// re.getChildNodes().forEach(cn -> cn.setLgpro(lgproMap.get(StrUtil.padPre(cn.getMaterialNo(),18,"0") +cn.getFacCode())));
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
}
|
||||||
|
return ResultVO.success(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void get(List<BomNewPbomParentVO> list,List<String> materialNoList,List<String> facList){
|
||||||
|
list.forEach(l -> {
|
||||||
|
if(CollectionUtil.isNotEmpty(l.getChildNodes())){
|
||||||
|
get(l.getChildNodes(),materialNoList,facList);
|
||||||
|
}
|
||||||
|
materialNoList.add(l.getMaterialNo());
|
||||||
|
facList.add(l.getFacCode());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set(List<BomNewPbomParentVO> list,Map<String,String> lgproMap){
|
||||||
|
list.forEach(l -> {
|
||||||
|
if(CollectionUtil.isNotEmpty(l.getChildNodes())){
|
||||||
|
set(l.getChildNodes(),lgproMap);
|
||||||
|
}
|
||||||
|
l.setLgpro(lgproMap.get(StrUtil.padPre(l.getMaterialNo(),18,"0") + l.getFacCode()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("releaseListByPage")
|
@PostMapping("releaseListByPage")
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,8 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
||||||
@ApiModelProperty("原始项目类别")
|
@ApiModelProperty("原始项目类别")
|
||||||
private String originalProjectType;
|
private String originalProjectType;
|
||||||
|
|
||||||
|
@ApiModelProperty("生产仓储地点")
|
||||||
|
private String lgpro;
|
||||||
|
|
||||||
private String materialNoAndProjectType;
|
private String materialNoAndProjectType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
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.client.MaterialMainClient;
|
import com.nflg.product.bomnew.client.MaterialMainClient;
|
||||||
|
|
@ -190,6 +192,19 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
private void save() {
|
private void save() {
|
||||||
TransactionDefinition def = new DefaultTransactionDefinition();
|
TransactionDefinition def = new DefaultTransactionDefinition();
|
||||||
TransactionStatus status = transactionManager.getTransaction(def);
|
TransactionStatus status = transactionManager.getTransaction(def);
|
||||||
|
if(CollUtil.isNotEmpty(childrenForAdd)){
|
||||||
|
//按 "(发货)","(制作)","(直发)","(发货前装配)" 放在同一个组内排序 by 10002327 0830
|
||||||
|
Map<String,List<BomNewEbomChildEntity>> chMap = childrenForAdd.stream().collect(Collectors.groupingBy(c -> {
|
||||||
|
return c.getDrawingNo().replaceAll("\\(发货\\)|\\(制作\\)|\\(直发\\)|\\(发货前装配\\)","");
|
||||||
|
}));
|
||||||
|
//对map的值,进行排序
|
||||||
|
List<Map.Entry<String,List<BomNewEbomChildEntity>>> mpList = new ArrayList<>(chMap.entrySet());
|
||||||
|
mpList.sort(Map.Entry.comparingByValue((c1,c2) -> Optional.ofNullable(c1).map(l->l.get(0)).map(BomNewEbomChildEntity::getOrderNumber).orElse("")
|
||||||
|
.compareTo(Optional.of(c2).map(l->l.get(0)).map(BomNewEbomChildEntity::getOrderNumber).orElse(""))));
|
||||||
|
childrenForAdd.removeAll(childrenForAdd);
|
||||||
|
mpList.forEach(m -> childrenForAdd.addAll(m.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getMaterialNoForAdd();
|
getMaterialNoForAdd();
|
||||||
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
@Resource
|
@Resource
|
||||||
private BomNewNoticeNumDetail2Service bomNewNoticeNumDetail2Service;
|
private BomNewNoticeNumDetail2Service bomNewNoticeNumDetail2Service;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SapService sapService;
|
||||||
/**
|
/**
|
||||||
* pbom-工作列表
|
* pbom-工作列表
|
||||||
*
|
*
|
||||||
|
|
@ -273,6 +275,15 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
} else {
|
} else {
|
||||||
result = this.getBaseMapper().releaseListByPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
result = this.getBaseMapper().releaseListByPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||||
}
|
}
|
||||||
|
//添加仓库地点 by 10002327 0830
|
||||||
|
if(!result.getRecords().isEmpty()){
|
||||||
|
List<Map<String,Object>> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()),
|
||||||
|
result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList()));
|
||||||
|
Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m-> {
|
||||||
|
return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"));
|
||||||
|
},m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
|
||||||
|
result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode())));
|
||||||
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
@ -400,6 +411,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
|
|
||||||
|
|
||||||
BomNewSortUtil.orderNumPbomSort(parentChild,0);
|
BomNewSortUtil.orderNumPbomSort(parentChild,0);
|
||||||
|
|
||||||
|
//添加仓库地点 by 10002327 0830
|
||||||
|
if(!parentChild.isEmpty()){
|
||||||
|
List<Map<String,Object>> lgproList = sapService.lgproByList(parentChild.stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()),
|
||||||
|
parentChild.stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList()));
|
||||||
|
Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m-> {
|
||||||
|
return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"));
|
||||||
|
},m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
|
||||||
|
parentChild.forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode())));
|
||||||
|
}
|
||||||
|
|
||||||
//主数据初始化
|
//主数据初始化
|
||||||
materialMainService.intiMaterialInfo(parentChild, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT3);
|
materialMainService.intiMaterialInfo(parentChild, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT3);
|
||||||
return parentChild;
|
return parentChild;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.nflg.product.bomnew.service;
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
|
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
|
import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
|
||||||
import com.sap.conn.jco.*;
|
import com.sap.conn.jco.*;
|
||||||
|
|
@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sap服務
|
* sap服務
|
||||||
|
|
@ -300,4 +303,33 @@ public class SapService implements ApplicationContextAware {
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
initProperties();
|
initProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取物料库存地点
|
||||||
|
* @param materialNoList 物料编码集合
|
||||||
|
* @param facList 工厂集合
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Map<String,Object>> lgproByList(List<String> materialNoList,List<String> facList){
|
||||||
|
SapReqParams params = new SapReqParams();
|
||||||
|
// 接口名
|
||||||
|
params.setFunName("ZMDM_MM_MAT_LOCTION_SYNC");
|
||||||
|
Map<String, List<Map<String, String>>> inputTables = Maps.newHashMap();
|
||||||
|
List<Map<String, String>> materList = materialNoList.stream().map(m -> {
|
||||||
|
Map<String, String> mp = Maps.newHashMap();
|
||||||
|
mp.put("MATNR",m);
|
||||||
|
return mp;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
List<Map<String, String>> werksList = facList.stream().map(m -> {
|
||||||
|
Map<String, String> mp = Maps.newHashMap();
|
||||||
|
mp.put("WERKS",m);
|
||||||
|
return mp;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
inputTables.put("IT_MATNR",materList);
|
||||||
|
inputTables.put("IT_WERKS",werksList);
|
||||||
|
params.setInputTables(inputTables);
|
||||||
|
SapResult sapResult = doSapFun(params);
|
||||||
|
Map<String, List<Map<String, Object>>> outTablesMap = sapResult.getOutTablesMap();
|
||||||
|
return outTablesMap.get("OUTPUT");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue