mbom sap导入
This commit is contained in:
parent
3ad6f0c785
commit
70d65268d7
|
|
@ -220,6 +220,27 @@ public class MBomApi extends BaseApi {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("importSap")
|
||||
@ApiOperation("导入sap")
|
||||
@LogRecord(success = "Mbom-导入sap,操作结果:{{#_ret}}", bizNo = "",
|
||||
extra = "{{#rowId}}" ,type = "Mbom-导入sap")
|
||||
public ResultVO<Boolean > importSap(@ApiParam("行Id") @RequestParam("rowId") Long rowId) {
|
||||
|
||||
if(Objects.isNull(rowId)){
|
||||
throw new NflgBusinessException(STATE.Error, "选择行操作" );
|
||||
|
||||
}
|
||||
return bomNewMbomParentService.importSap(rowId) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
RedisService redisService;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,38 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.BomConstant;
|
||||
import com.nflg.product.bomnew.constant.EBomConstant;
|
||||
import com.nflg.product.bomnew.constant.MBomConstantEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewMbomParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewMBomChildDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewMbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
|
||||
import com.nflg.product.bomnew.service.domain.MBom.IndexListTree;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.nflg.product.bomnew.constant.EBomConstant.MAIN_FACTORY_CODE_1010;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -134,4 +147,117 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
|
||||
List<BomNewMbomMiddleVO> queryDetail( Long rowId, Long bomRowId) {
|
||||
|
||||
|
||||
List<Long> rowIdList = new ArrayList<>( Arrays.asList(rowId) );
|
||||
List<BomNewMbomMiddleVO> voList = new ArrayList<>();
|
||||
|
||||
while (!rowIdList.isEmpty()) {
|
||||
List<BomNewMbomMiddleVO> childList = SpringUtil.getBean(BomNewMbomParentService.class).getBaseMapper().getParentChild(rowIdList, bomRowId);
|
||||
rowIdList.clear();
|
||||
if (CollUtil.isNotEmpty(childList)) {
|
||||
for (BomNewMbomMiddleVO item:
|
||||
childList) {
|
||||
//Long bomRowIdTmp=item.getBomRowId();
|
||||
// item.setBomRowId(item.getBomVersionRowId());
|
||||
if (item.getParentRowId().longValue() == 0l) {
|
||||
item.setParentRowId(bomRowId);
|
||||
// item.setBomVersionRowId(item.getBomRowId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
voList.addAll(childList);
|
||||
|
||||
List<Long> nextBomId = childList.stream().filter(u -> u.getBomVersionRowId() != null && u.getBomVersionRowId() > 0).map(BomNewMbomMiddleVO::getBomVersionRowId).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(nextBomId)) {
|
||||
rowIdList.addAll(nextBomId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return voList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ResultVO<Boolean> importSap(Long rowId){
|
||||
|
||||
|
||||
BomNewMbomMiddleVO parentVO= getParentById(rowId);
|
||||
|
||||
VUtils.isTure(parentVO==null).throwMessage("选择顶层节点导入");
|
||||
parentVO.setParentRowId(0l);
|
||||
parentVO.setBomRowId(parentVO.getRowId());
|
||||
parentVO.setBomExist(1);
|
||||
|
||||
List<BomNewMbomMiddleVO> list=queryDetail(0l,parentVO.getRowId());
|
||||
|
||||
list.add(0,parentVO);
|
||||
ImportSapParamDTO result=new ImportSapParamDTO();
|
||||
result.setT1(new ArrayList<>());
|
||||
result.setZID(RandomUtil.randomNumbers(5));
|
||||
if(parentVO.getFacCode().equals(MAIN_FACTORY_CODE_1010)){
|
||||
result.setI_WERKS("1");
|
||||
}else{
|
||||
result.setI_WERKS("2");
|
||||
}
|
||||
|
||||
result.setI_STLAN(BomConstant.SAP_MBOM);
|
||||
String dateYMD= DateUtil.format(new Date(),"yyyyMMdd");
|
||||
|
||||
List<BomNewMbomMiddleVO> parentList=list.stream().filter(u -> u.getBomExist().intValue()>0).collect(Collectors.toList());
|
||||
|
||||
|
||||
for (BomNewMbomMiddleVO parent:
|
||||
parentList) {
|
||||
List<BomNewMbomMiddleVO> childList=list.stream().filter(u -> u.getParentRowId().equals(parent.getRowId())).collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(childList)){
|
||||
continue;
|
||||
}
|
||||
for (BomNewMbomMiddleVO child:
|
||||
childList) {
|
||||
|
||||
T1DTO t1=new T1DTO();
|
||||
t1.setID(RandomUtil.randomNumbers(5));
|
||||
t1.setMATNR(parent.getMaterialNo());
|
||||
t1.setIDNRK(child.getMaterialNo());
|
||||
t1.setMEINS(child.getMaterialUnit());
|
||||
t1.setMENGE("1");
|
||||
t1.setPOSTP(child.getProjectType());
|
||||
t1.setDATUM(dateYMD);
|
||||
t1.setMAKTX(parent.getMaterialDesc());
|
||||
t1.setMAKTX1(child.getMaterialDesc());
|
||||
result.getT1().add(t1);
|
||||
}
|
||||
|
||||
}
|
||||
ResultVO<Boolean> resultVO= SpringUtil.getBean(SapOpUtilService.class).importToSapV2(result,null);
|
||||
|
||||
//上传成功更新状态
|
||||
if(resultVO.getState().equals( STATE.Success.getState())){
|
||||
BomNewMbomParentEntity parentEntity=new BomNewMbomParentEntity();
|
||||
parentEntity.setRowId(parentVO.getRowId());
|
||||
parentEntity.setStatus(MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue());
|
||||
parentEntity.setSysnSapUserName(SessionUtil.getUserName());
|
||||
parentEntity.setSysnSapTime(LocalDateTimeUtil.now());
|
||||
parentEntity.setModifyTime(LocalDateTimeUtil.now());
|
||||
this.updateById(parentEntity);
|
||||
}
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public class SapOpUtilService {
|
|||
list) {
|
||||
|
||||
|
||||
if(CollectionUtil.isNotEmpty(backList)){
|
||||
if( backList !=null){
|
||||
backList.add(item);
|
||||
}
|
||||
//"FLAG": "1" -- 0 失败;1 成功
|
||||
|
|
|
|||
Loading…
Reference in New Issue