Merge remote-tracking branch 'origin/master-xiantao-lhj0830'
This commit is contained in:
commit
fc13cf3700
|
|
@ -8,12 +8,12 @@ import com.nflg.product.bomnew.service.BomNewLogService;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* t_bom_new_log 表控制层
|
||||
|
|
@ -27,6 +27,8 @@ import javax.annotation.Resource;
|
|||
@RequestMapping("bomNewLogEntity")
|
||||
public class BomNewLogApi extends BaseApi {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
|
|
@ -44,7 +46,15 @@ public class BomNewLogApi extends BaseApi {
|
|||
public ResultVO<IPage<BomNewLogEntity>> selectBomNewLogEntityPageByCondition(@RequestBody BomNewLogQuery query) {
|
||||
return ResultVO.success(bomNewLogService.getListByPage(query));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("delRedisKey")
|
||||
public ResultVO<Long> delRedisKey(@RequestParam(name = "key") @Length(min = 4, message = "长度不能少于4个字符") String key){
|
||||
Set<String> keys = redisTemplate.keys(key);
|
||||
if(!keys.isEmpty()){
|
||||
return ResultVO.success(redisTemplate.delete(keys));
|
||||
}
|
||||
return ResultVO.success(0l);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.nflg.product.bomnew.api.user;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import com.nflg.product.base.core.api.BaseApi;
|
||||
|
|
@ -412,7 +415,6 @@ public class EbomApi extends BaseApi {
|
|||
checkDeleteRule(dto);
|
||||
bomNewEbomParentService.deleteBomChild(dto.getDelDatas(), dto.getParent());
|
||||
BomNewEbomParentVO temporary = bomNewEbomParentService.temporary(dto);
|
||||
|
||||
return ResultVO.success(temporary);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.product.bomnew.api.user;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.ApiOperation;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -38,6 +40,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* t_bom_new_pbom_parent 表控制层
|
||||
|
|
@ -67,14 +71,47 @@ public class PBomApi extends BaseApi {
|
|||
@Resource
|
||||
private MaterialMainService materialMainService;
|
||||
|
||||
@Resource
|
||||
SapService sapService;
|
||||
|
||||
@PostMapping("workDetailsListByPage")
|
||||
@ApiOperation("PBom工作列表")
|
||||
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();
|
||||
|
||||
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->
|
||||
String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"))
|
||||
,m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
|
||||
this.set(r.getRecords(),lgproMap);
|
||||
|
||||
}
|
||||
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")
|
||||
@ApiOperation("PBom已发布工作列表")
|
||||
|
|
|
|||
|
|
@ -314,7 +314,8 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty("原始项目类别")
|
||||
private String originalProjectType;
|
||||
|
||||
|
||||
@ApiModelProperty("生产仓储地点")
|
||||
private String lgpro;
|
||||
|
||||
private String materialNoAndProjectType;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.client.MaterialMainClient;
|
||||
|
|
@ -37,6 +39,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -190,6 +193,37 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|||
private void save() {
|
||||
TransactionDefinition def = new DefaultTransactionDefinition();
|
||||
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(""))));
|
||||
//对map值的集合按照 按发货-直发-制作的顺序排序
|
||||
Function<BomNewEbomChildEntity,String> sortFn = (ent) -> {
|
||||
String num = "1";
|
||||
String desc = Optional.ofNullable(ent).map(BomNewEbomChildEntity::getMaterialDesc).orElse("");
|
||||
if(desc.contains("(发货)")){
|
||||
num = "1";
|
||||
}
|
||||
if(desc.contains("(直发)")){
|
||||
num = "2";
|
||||
}
|
||||
if(desc.contains("(制作)")){
|
||||
num = "3";
|
||||
}
|
||||
if(desc.contains("(发货前装配)")){
|
||||
num = "4";
|
||||
}
|
||||
return num;
|
||||
};
|
||||
childrenForAdd.removeAll(childrenForAdd);
|
||||
mpList.forEach(m -> childrenForAdd.addAll(m.getValue().stream().sorted(Comparator.comparing(sortFn::apply)).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
try {
|
||||
getMaterialNoForAdd();
|
||||
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
||||
|
|
@ -404,27 +438,38 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按发货-直发-制作的顺序 by 10002327 240903
|
||||
* @param root
|
||||
* @param child
|
||||
*/
|
||||
private void build1010VirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child) {
|
||||
//发货包
|
||||
BomNewEbomChildEntity qc1 = buildVirtualPackage(false, root.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||
BomNewEbomParentEntity qp1 = buildVirtualPackage(root, qc1);
|
||||
//制作包
|
||||
BomNewEbomChildEntity qc2 = buildVirtualPackage(false, qp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
||||
BomNewEbomChildEntity qc2 = buildVirtualPackage(false, qp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.MAKING_PACKAGE, "002");
|
||||
BomNewEbomParentEntity qp2 = buildVirtualPackage(qp1, qc2);
|
||||
child.setParentRowId(qp2.getRowId());
|
||||
child.setModifyTime(LocalDateTime.now());
|
||||
childrenForUpdate.add(child);
|
||||
//直发包
|
||||
BomNewEbomChildEntity qc3 = buildVirtualPackage(false, qp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
||||
BomNewEbomChildEntity qc3 = buildVirtualPackage(false, qp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "001");
|
||||
buildVirtualPackage(qp1, qc3);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按发货-直发-制作的顺序 by 10002327 240903
|
||||
* @param root
|
||||
* @param mount
|
||||
* @param child
|
||||
*/
|
||||
private void build1020VirtualPackage(BomNewEbomParentEntity root, boolean mount, BomNewEbomChildEntity child) {
|
||||
//发货包
|
||||
BomNewEbomChildEntity xc1 = buildVirtualPackage(true, root.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||
BomNewEbomParentEntity xp1 = buildVirtualPackage(root, xc1);
|
||||
//制作包
|
||||
BomNewEbomChildEntity xc2 = buildVirtualPackage(true, xp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
||||
BomNewEbomChildEntity xc2 = buildVirtualPackage(true, xp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.MAKING_PACKAGE, "002");
|
||||
BomNewEbomParentEntity xp2 = buildVirtualPackage(xp1, xc2);
|
||||
if (mount) {
|
||||
child.setParentRowId(xp2.getRowId());
|
||||
|
|
@ -432,7 +477,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|||
childrenForUpdate.add(child);
|
||||
}
|
||||
//直发包
|
||||
BomNewEbomChildEntity xc3 = buildVirtualPackage(true, xp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
||||
BomNewEbomChildEntity xc3 = buildVirtualPackage(true, xp1.getRowId(), root, child.getMaterialName(), child.getDrawingNo(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "001");
|
||||
buildVirtualPackage(xp1, xc3);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
@Resource
|
||||
private BomNewNoticeNumDetail2Service bomNewNoticeNumDetail2Service;
|
||||
|
||||
@Resource
|
||||
SapService sapService;
|
||||
/**
|
||||
* pbom-工作列表
|
||||
*
|
||||
|
|
@ -273,6 +275,15 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
} else {
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -400,6 +411,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
|
||||
|
||||
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);
|
||||
return parentChild;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
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.SapResult;
|
||||
import com.sap.conn.jco.*;
|
||||
|
|
@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* sap服務
|
||||
|
|
@ -300,4 +303,33 @@ public class SapService implements ApplicationContextAware {
|
|||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
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