申请物料更换

This commit is contained in:
jing's 2024-01-25 14:30:34 +08:00
parent 9998d74ffb
commit bb0723666d
4 changed files with 111 additions and 53 deletions

View File

@ -157,7 +157,7 @@ public class OptionalMbomApi extends BaseApi {
}
return ResultVO.success( true);
return optionalMbomMaterialService.importSap(rowId);
}

View File

@ -41,7 +41,9 @@ import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
import com.nflg.product.bomnew.pojo.vo.OptionalMbomMaterialListVO;
import com.nflg.product.bomnew.pojo.vo.OptionalMbomMaterialVO;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -54,6 +56,7 @@ import java.util.stream.Collectors;
* mbom发布生成的物料信息(OptionalMbomMaterial)表服务实现类
*/
@Service
@Slf4j
public class OptionalMbomMaterialService extends ServiceImpl<OptionalMbomMaterialMapper, OptionalMbomMaterialEntity> {
@ -131,7 +134,7 @@ public class OptionalMbomMaterialService extends ServiceImpl<OptionalMbomMateria
public Boolean importSap(Long rowId){
public ResultVO<Boolean> importSap(Long rowId){
OptionalMbomMaterialEntity entity= getById(rowId);
List<OptionalMbomMaterialListVO> list=this.baseMapper.getByRootIdList(entity.getRootRowId());
@ -141,7 +144,7 @@ public Boolean importSap(Long rowId){
ImportSapParamDTO result=new ImportSapParamDTO();
result.setT1(new ArrayList<>());
//
result.setZID(RandomUtil.randomNumbers(8));
result.setZID(RandomUtil.randomNumbers(5));
result.setI_WERKS("1");
result.setI_STLAN(BomConstant.SAP_YDBOM);
@ -157,7 +160,7 @@ public Boolean importSap(Long rowId){
childList) {
T1DTO t1=new T1DTO();
t1.setID(RandomUtil.randomNumbers(8));
t1.setID(RandomUtil.randomNumbers(5));
t1.setMATNR(parent.getMaterialNo());
t1.setIDNRK(child.getMaterialNo());
t1.setMEINS(child.getMaterialUnit());
@ -171,9 +174,13 @@ public Boolean importSap(Long rowId){
}
System.out.println(JSON.toJSONString(result));
log.info(JSON.toJSONString(result));
return SpringUtil.getBean(SapOpUtilService.class).importToSap(result);
return true;
}

View File

@ -119,6 +119,7 @@ public class SapOpUtilService {
}
log.info("PBOM导入到SAP--返回值:" + JSON.toJSONString(exportMap));
String eErrmsg = String.valueOf(exportMap.get("E_ERRMSG"));
if (StrUtil.isNotEmpty(eErrmsg) && eErrmsg!="null") {
return ResultVO.error(STATE.Error, eErrmsg);

View File

@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.OptionalBomConstant;
import com.nflg.product.bomnew.pojo.dto.AddVirtrualMaterialDTO;
import com.nflg.product.bomnew.pojo.dto.OptionalEbomPublishAddDTO;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.vo.OptionalEbomImportChildVO;
@ -26,10 +27,7 @@ import nflg.product.common.vo.ResultVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@ -166,20 +164,26 @@ public class PublishMaterialService {
sendPack.setCreatedTime(DateUtil.now());
sendPack.setMaterialName(sendMaterialName);
sendPack.setMaterialDesc(sendMaterialName);
sendPack.setDrawingNo(sendMaterialName);
sendPack.setRootRowId(rootRowId);
sendPack.setMaterialNo("");//申请物料号
sendPack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_1.getValue());
try {
String data = materialService.addMaterial("", sendPack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
// ResultVO<String> resultVO = JSON.parseObject(data, new com.alibaba.fastjson.TypeReference<ResultVO<String>>(){});
// if (resultVO == null) {
// throw new NflgBusinessException(STATE.Error, "机型发货物料编码申请失败,联系管理员," + data);
// }
// if (!Objects.equal(resultVO.getState(), STATE.Success.getState())) {
// throw new NflgBusinessException(STATE.Error, resultVO.getMsg());
// }
sendPack.setMaterialNo(data);
sendPack.setDrawingNo(sendMaterialName);
// String data = materialService.addMaterial("", sendPack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
//
// sendPack.setMaterialNo(data);
AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO();
String key=String.valueOf(IdWorker.getId()) ;
toM.setKey(key);
toM.setMaterialName(sendPack.getMaterialName() );
toM.setDrawingNo(sendPack.getMaterialName() );
toM.setMaterialDesc(sendPack.getMaterialName() );
toM.setMaterialCategoryCode(OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
toM.setProjectType(OptionalBomConstant.PublishMaterialEnum.OTHER.getProjectType());
Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM));
String materialNo=mMap.get(key).getMaterialNo();
sendPack.setMaterialNo(materialNo);
} catch (Exception e) {
throw new NflgBusinessException(STATE.Error, "机型发货," + e.getMessage());
}
@ -197,6 +201,7 @@ public class PublishMaterialService {
makePack.setDeptName(SessionUtil.getDepartName());
makePack.setMaterialName(makeMaterialName);
makePack.setMaterialDesc(makeMaterialName);
makePack.setDrawingNo(makeMaterialName);
makePack.setParentRowId(sendPack.getRowId()); //父级
makePack.setRootRowId(rootRowId);
makePack.setCreatedTime(DateUtil.now());
@ -204,16 +209,27 @@ public class PublishMaterialService {
makePack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_2.getValue());
try {
String data = materialService.addMaterial("", makePack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
// ResultVO<String> resultVO = JSON.parseObject(data, new com.alibaba.fastjson.TypeReference<ResultVO<String>>(){});
// if (resultVO == null) {
// throw new NflgBusinessException(STATE.Error, "机型制作物料编码申请失败,联系管理员," + data);
// }
// if (!Objects.equal(resultVO.getState(), STATE.Success.getState())) {
// throw new NflgBusinessException(STATE.Error, resultVO.getMsg());
// }
makePack.setMaterialNo(data);
makePack.setDrawingNo(makeMaterialName);
// String data = materialService.addMaterial("", makePack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
//
// makePack.setMaterialNo(data);
AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO();
String key=String.valueOf(IdWorker.getId()) ;
toM.setKey(key);
toM.setMaterialName(makePack.getMaterialName());
toM.setDrawingNo(makePack.getMaterialName());
toM.setMaterialDesc(makePack.getMaterialName());
toM.setMaterialCategoryCode(OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
toM.setProjectType(OptionalBomConstant.PublishMaterialEnum.OTHER.getProjectType());
Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM));
String materialNo=mMap.get(key).getMaterialNo();
makePack.setMaterialNo(materialNo);
} catch (Exception e) {
throw new NflgBusinessException(STATE.Error, "机型制作," + e.getMessage());
}
@ -268,7 +284,7 @@ public class PublishMaterialService {
String drawingNo =StrUtil.format("{}-{}",desc.getDeviceNo(), OrderNoUtil.orderNo2Str(desc.getSerialNo())).concat("-NF");
String materialName=drawingNo.concat("(机械部分)");
material.setRowId(IdWorker.getId());
material.setDrawingNo(drawingNo);
material.setParentRowId(parentId);
material.setRootRowId(rootRowId);
material.setCreatedBy(SessionUtil.getUserCode());
@ -277,12 +293,25 @@ public class PublishMaterialService {
material.setCreatedTime(DateUtil.now());
material.setMaterialName(materialName);
material.setMaterialDesc(materialName);
material.setDrawingNo(drawingNo);
material.setMaterialNo("");//申请物料号
material.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_5.getValue());
try {
String data = materialService.addMaterial(material.getDrawingNo(), material.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.MACHINE.getCategory());
material.setMaterialNo(data);
AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO();
String key=String.valueOf(IdWorker.getId()) ;
toM.setKey(key);
toM.setMaterialName(material.getMaterialName());
toM.setDrawingNo(drawingNo);
toM.setMaterialDesc(material.getMaterialName());
toM.setMaterialCategoryCode(OptionalBomConstant.PublishMaterialEnum.MACHINE.getCategory());
toM.setProjectType(OptionalBomConstant.PublishMaterialEnum.MACHINE.getProjectType());
Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM));
String materialNo=mMap.get(key).getMaterialNo();
material.setMaterialNo(materialNo);
// String data = materialService.addMaterial(material.getDrawingNo(), material.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.MACHINE.getCategory());
// material.setMaterialNo(data);
} catch (Exception e) {
throw new NflgBusinessException(STATE.Error, "机械部分," + e.getMessage());
}
@ -379,21 +408,32 @@ public class PublishMaterialService {
makePack.setCreatedTime(DateUtil.now());
makePack.setMaterialName(makeMaterialName);
makePack.setMaterialDesc(makeMaterialName);
makePack.setDrawingNo(makeMaterialName);
makePack.setRootRowId(rootRowId);
makePack.setMaterialNo("");//申请物料号
makePack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_4.getValue());
try {
String data = materialService.addMaterial("", makePack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
// ResultVO<String> resultVO = JSON.parseObject(data, new com.alibaba.fastjson.TypeReference<ResultVO<String>>(){});
// if (resultVO == null) {
// throw new NflgBusinessException(STATE.Error, "电控制作物料编码申请失败,联系管理员," + data);
// }
// if (!Objects.equal(resultVO.getState(), STATE.Success.getState())) {
// throw new NflgBusinessException(STATE.Error, resultVO.getMsg());
// }
makePack.setMaterialNo(data);
makePack.setDrawingNo(makeMaterialName);
// String data = materialService.addMaterial("", makePack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
//
// makePack.setMaterialNo(data);
AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO();
String key=String.valueOf(IdWorker.getId()) ;
toM.setKey(key);
toM.setMaterialName(makePack.getMaterialName());
toM.setDrawingNo(makePack.getMaterialName());
toM.setMaterialDesc(makePack.getMaterialName());
toM.setMaterialCategoryCode(OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
toM.setProjectType(OptionalBomConstant.PublishMaterialEnum.OTHER.getProjectType());
Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM));
String materialNo=mMap.get(key).getMaterialNo();
makePack.setMaterialNo(materialNo);
} catch (Exception e) {
throw new NflgBusinessException(STATE.Error, "电控制作," + e.getMessage());
}
@ -414,20 +454,30 @@ public class PublishMaterialService {
sendPack.setCreatedTime(DateUtil.now());
sendPack.setMaterialName(sendMaterialName);
sendPack.setMaterialDesc(sendMaterialName);
sendPack.setDrawingNo(sendMaterialName);
sendPack.setRootRowId(rootRowId);
sendPack.setMaterialNo("");//申请物料号
sendPack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_3.getValue());
try {
String data = materialService.addMaterial("", sendPack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
// ResultVO<String> resultVO = JSON.parseObject(data, new com.alibaba.fastjson.TypeReference<ResultVO<String>>(){});
// if (resultVO == null) {
// throw new NflgBusinessException(STATE.Error, "电控发货物料编码申请失败,联系管理员," + data);
// }
// if (!Objects.equal(resultVO.getState(), STATE.Success.getState())) {
// throw new NflgBusinessException(STATE.Error, resultVO.getMsg());
// }
sendPack.setMaterialNo(data);
sendPack.setDrawingNo(sendMaterialName);
// String data = materialService.addMaterial("", sendPack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
//
// sendPack.setMaterialNo(data);
AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO();
String key=String.valueOf(IdWorker.getId()) ;
toM.setKey(key);
toM.setMaterialName(sendPack.getMaterialName());
toM.setDrawingNo(sendPack.getMaterialName());
toM.setMaterialDesc(sendPack.getMaterialName());
toM.setMaterialCategoryCode(OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
toM.setProjectType(OptionalBomConstant.PublishMaterialEnum.OTHER.getProjectType());
Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM));
String materialNo=mMap.get(key).getMaterialNo();
sendPack.setMaterialNo(materialNo);
} catch (Exception e) {
throw new NflgBusinessException(STATE.Error, "电控发货,"+e.getMessage());
}