发布功能
This commit is contained in:
parent
d990adb50c
commit
949018b359
|
|
@ -21,6 +21,7 @@ import com.nflg.product.bomnew.pojo.vo.*;
|
|||
import com.nflg.product.bomnew.service.*;
|
||||
import com.nflg.product.bomnew.service.aggreg.AggregOptionConfigService;
|
||||
import com.nflg.product.bomnew.service.aggreg.OptionalExcelService;
|
||||
import com.nflg.product.bomnew.service.aggreg.PublishMaterialService;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
|
|
@ -70,7 +71,7 @@ public class OptionalEbomApi extends BaseApi {
|
|||
|
||||
|
||||
@Resource
|
||||
MaterialService materialService;
|
||||
PublishMaterialService publishMaterialService;
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
|
|
@ -317,18 +318,20 @@ public class OptionalEbomApi extends BaseApi {
|
|||
*/
|
||||
@PostMapping("publish")
|
||||
@ApiOperation("发布生成")
|
||||
public ResultVO<Boolean> publish(@RequestBody OptionalEbomPublishAddDTO dto) {
|
||||
|
||||
|
||||
try {
|
||||
String data = materialService.addMaterial("1111", "afafafa", "1234");
|
||||
System.out.println(data);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
public ResultVO<String> publish(@RequestBody OptionalEbomPublishAddDTO dto) {
|
||||
if(StrUtil.isEmpty(dto.getGoodsDesc())){
|
||||
return ResultVO.error("输入制作/发货包信息");
|
||||
}
|
||||
if(StrUtil.isEmpty(dto.getMachineDesc())){
|
||||
return ResultVO.error("输入机械部分信息");
|
||||
}
|
||||
if(StrUtil.isEmpty(dto.getElectricDesc())){
|
||||
return ResultVO.error("输入电控制作/发货信息");
|
||||
}
|
||||
|
||||
return ResultVO.success(true);
|
||||
return publishMaterialService.publishWork(dto);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.nflg.product.bomnew.constant;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
public class OptionalBomConstant {
|
||||
public class OptionalBomConstant {
|
||||
|
||||
|
||||
//部件类型(1 单选 2 多选)
|
||||
|
|
@ -16,6 +16,7 @@ public class OptionalBomConstant {
|
|||
private final String description;
|
||||
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ChooseStatusEnum implements ValueEnum<Integer> {
|
||||
|
|
@ -30,7 +31,7 @@ public class OptionalBomConstant {
|
|||
//数据来源 (0 :excel 1:手动录入)
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum SourceTypeEnum implements ValueEnum<Integer> {
|
||||
public enum SourceTypeEnum implements ValueEnum<Integer> {
|
||||
SOURCE_EXCEL(0, "template"),
|
||||
SOURCE_INPUT(1, "手动录入");
|
||||
private final Integer value;
|
||||
|
|
@ -40,7 +41,7 @@ public class OptionalBomConstant {
|
|||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EnableEnum implements ValueEnum<Integer> {
|
||||
public enum EnableEnum implements ValueEnum<Integer> {
|
||||
HIDDEN(0, "隐藏"),
|
||||
SHOW(1, "显示");
|
||||
private final Integer value;
|
||||
|
|
@ -50,7 +51,7 @@ public class OptionalBomConstant {
|
|||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PublishEnum implements ValueEnum<Integer> {
|
||||
public enum PublishEnum implements ValueEnum<Integer> {
|
||||
TMP(0, "暂存"),
|
||||
PUBLISH(1, "发布");
|
||||
private final Integer value;
|
||||
|
|
@ -60,17 +61,30 @@ public class OptionalBomConstant {
|
|||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ExcelErrorTagEnum implements ValueEnum<Integer> {
|
||||
public enum ExcelErrorTagEnum implements ValueEnum<Integer> {
|
||||
NO(0, "无错误"),
|
||||
REPEAT (1, "重复的标配"),
|
||||
MATERIA_NO_UNKOWN (2, "无物料号"),
|
||||
ALL (3, "同时满足(重复标配、无物料号)");
|
||||
REPEAT(1, "重复的标配"),
|
||||
MATERIA_NO_UNKOWN(2, "无物料号"),
|
||||
ALL(3, "同时满足(重复标配、无物料号)");
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PublishMaterialEnum {
|
||||
//机械部分
|
||||
MACHINE("201201", "L", "PC"),
|
||||
OTHER("201101", "L", "PC");
|
||||
|
||||
private final String category;
|
||||
private final String projectType;
|
||||
private final String materialUnit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class MaterialMainDTO implements Serializable {
|
|||
private Integer opEnum=1;
|
||||
|
||||
|
||||
private Integer commonZeroFile;
|
||||
|
||||
/**
|
||||
* 项目类别:F、Q、L
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import lombok.experimental.Accessors;
|
|||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("com.nflg.product.bomnew.pojo.dto.OptionalEbomPublishAddDTO")
|
||||
@ApiModel("com.nflg.product.bomnew.pojo.dto.OptionalEbomPublishAddDTO发布")
|
||||
@Accessors(chain = true)
|
||||
public class OptionalEbomPublishAddDTO implements Serializable {
|
||||
/**
|
||||
|
|
@ -18,9 +18,15 @@ public class OptionalEbomPublishAddDTO implements Serializable {
|
|||
@ApiModelProperty(value = "发布数据id")
|
||||
private Long rowId;
|
||||
|
||||
@ApiModelProperty(value = "制作/发货包")
|
||||
private String goodsDesc;
|
||||
|
||||
@ApiModelProperty(value = "机械部分")
|
||||
private String machineDesc;
|
||||
|
||||
@ApiModelProperty(value = "电控制作/发货")
|
||||
private String electricDesc;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String desc;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nflg.product.bomnew.service;
|
|||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.client.MaterialMainClient;
|
||||
|
|
@ -47,6 +48,26 @@ public class MaterialService {
|
|||
String s = httpUtils.doPost(NacosConfig.getNacosConfig().getAddMaterialUrl(),JSON.toJSONString(materialMainDTO),token);
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
public String addMaterialPublish(String drawingNo, String materialName, String materialCategoryCode) throws IOException {
|
||||
MaterialMainDTO materialMainDTO=new MaterialMainDTO();
|
||||
materialMainDTO.setMaterialName(materialName);
|
||||
materialMainDTO.setDrawingNo(drawingNo);
|
||||
materialMainDTO.setMaterialDesc(materialName);
|
||||
materialMainDTO.setMaterialCategoryCode(materialCategoryCode);
|
||||
materialMainDTO.setOpEnum(1);
|
||||
// materialMainDTO.setRowId(IdWorker.getId());
|
||||
|
||||
materialMainDTO.setApplyDeptName(SessionUtil.getDepartName());
|
||||
|
||||
String token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySW5mbyI6IntcImRlcGFydE5hbWVcIjpcIuemj-W7uuWNl-aWuei3r-mdouacuuaisOaciemZkOWFrOWPuFwiLFwiZGVwYXJ0Um93SWRcIjoxNTg1MTk1Njk0ODcyNzg0ODk3LFwiZnVsbERlcHROYW1lXCI6XCJPVT3npo_lu7rljZfmlrnot6_pnaLmnLrmorDmnInpmZDlhazlj7gsREM9bmZsZ1wiLFwicXVlcnlEYXRhXCI6MixcInJlYWxOYW1lXCI6XCJhZG1pblwiLFwicm93SWRcIjoxNTQ3NTEyOTc4MDE2OTE5NTUzLFwidXNlckNvZGVcIjpcImFkbWluXCIsXCJ1c2VyTmFtZVwiOlwiYWRtaW5cIn0iLCJleHAiOjE3MDIwNTI1MzEsImp0aSI6Ijc5NmU2MjZhLWJjYzUtNDY3ZS1iNjFjLWRmOGViNGY0MDYyOSJ9.iq2dyYKpGd7Z60Mmm9ef59CF1YrkG9KLaTGr9CrGsHI";
|
||||
// String token=SessionUtil.getsessionKey();
|
||||
HttpUtils httpUtils=new HttpUtils();
|
||||
|
||||
String s = httpUtils.doPost(NacosConfig.getNacosConfig().getAddMaterialUrl(),JSON.toJSONString(materialMainDTO),token);
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,23 +19,29 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* mbom发布生成的物料信息(OptionalMbomMaterial)表服务实现类
|
||||
*
|
||||
|
||||
*/
|
||||
@Service
|
||||
public class OptionalMbomMaterialService extends ServiceImpl<OptionalMbomMaterialMapper, OptionalMbomMaterialEntity > {
|
||||
public class OptionalMbomMaterialService extends ServiceImpl<OptionalMbomMaterialMapper, OptionalMbomMaterialEntity> {
|
||||
|
||||
|
||||
public IPage<OptionalMbomMaterialVO> getListPage(OptionalMbomMaterialListQuery query) {
|
||||
|
||||
IPage<OptionalMbomMaterialVO> list = this.getBaseMapper().getListPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<OptionalMbomMaterialVO> getChild(Long rowId) {
|
||||
return this.getBaseMapper().getChild(rowId);
|
||||
}
|
||||
public List<OptionalMbomMaterialVO> getChild(Long rowId) {
|
||||
return this.getBaseMapper().getChild(rowId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,384 @@
|
|||
package com.nflg.product.bomnew.service.aggreg;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.base.Objects;
|
||||
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.OptionalEbomPublishAddDTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.*;
|
||||
import com.nflg.product.bomnew.pojo.vo.OptionalEbomImportChildVO;
|
||||
import com.nflg.product.bomnew.service.MaterialService;
|
||||
import com.nflg.product.bomnew.service.OptionalEbomConfigService;
|
||||
import com.nflg.product.bomnew.service.OptionalMbomCompareService;
|
||||
import com.nflg.product.bomnew.service.OptionalMbomMaterialService;
|
||||
import nflg.product.common.constant.STATE;
|
||||
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.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class PublishMaterialService {
|
||||
@Resource
|
||||
private OptionalMbomCompareService optionalMbomCompareService;
|
||||
|
||||
@Resource
|
||||
private OptionalEbomConfigService optionalEbomConfigService;
|
||||
|
||||
@Resource
|
||||
private OptionalMbomMaterialService optionalMbomMaterialService;
|
||||
@Resource
|
||||
MaterialService materialService;
|
||||
|
||||
/**
|
||||
* 发布
|
||||
* 1.获取物料信息
|
||||
* 2.更改状态
|
||||
* 3.上传sap
|
||||
*
|
||||
* @param rowId
|
||||
*/
|
||||
|
||||
public void publish(Long rowId) {
|
||||
|
||||
List<OptionalEbomImportChildVO> previewOptionList = optionalEbomConfigService.getPreviewOptionList(rowId);
|
||||
List<String> materialNoList = previewOptionList.stream().map(OptionalEbomImportChildVO::getMaterialNo).collect(Collectors.toList());
|
||||
|
||||
Collections.sort(materialNoList);
|
||||
|
||||
String result = materialNoList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
|
||||
String signMd5 = MD5.create().digestHex(result);
|
||||
|
||||
QueryWrapper<OptionalMbomCompareEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OptionalMbomCompareEntity::getSignMd5, signMd5);
|
||||
|
||||
OptionalMbomCompareEntity optionalMbomCompareEntity = optionalMbomCompareService.getOne(queryWrapper);
|
||||
|
||||
System.out.println(result);
|
||||
System.out.println(signMd5);
|
||||
}
|
||||
|
||||
|
||||
public ResultVO<String> publishWork(OptionalEbomPublishAddDTO optionalEbomPublishAddDTO) {
|
||||
|
||||
List<OptionalEbomImportChildVO> optionList = optionalEbomConfigService.getPreviewOptionList(optionalEbomPublishAddDTO.getRowId());
|
||||
if (CollectionUtil.isEmpty(optionList)) {
|
||||
return ResultVO.error("发布未查询到物料数据");
|
||||
}
|
||||
|
||||
List<OptionalMbomMaterialEntity> materialList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
//第一层级 机型发货 和制作
|
||||
Long parentId = genVirtualPackLevel1(materialList, optionalEbomPublishAddDTO.getRowId(), optionalEbomPublishAddDTO.getGoodsDesc());
|
||||
//电控部分
|
||||
genVirtualPackElectricLevel2(materialList, optionalEbomPublishAddDTO.getRowId(), parentId, optionalEbomPublishAddDTO.getElectricDesc());
|
||||
//机械部分申请
|
||||
genVirtualPackMachineLevel2(materialList, optionList, optionalEbomPublishAddDTO.getRowId(), parentId, optionalEbomPublishAddDTO.getMachineDesc());
|
||||
|
||||
boolean ok = optionalMbomMaterialService.saveOrUpdateBatch(materialList);
|
||||
|
||||
if (ok) {
|
||||
//物料数据保存更改状态
|
||||
OptionalEbomConfigEntity optionalEbomConfigEntity = new OptionalEbomConfigEntity();
|
||||
optionalEbomConfigEntity.setRowId(optionalEbomPublishAddDTO.getRowId());
|
||||
optionalEbomConfigEntity.setUpdatedTime(new Date());
|
||||
optionalEbomConfigEntity.setEditStatus(OptionalBomConstant.PublishEnum.PUBLISH.getValue());
|
||||
optionalEbomConfigService.updateById(optionalEbomConfigEntity);
|
||||
}
|
||||
|
||||
} catch (NflgBusinessException e) {
|
||||
return ResultVO.error(e.getMsg());
|
||||
}
|
||||
|
||||
return ResultVO.success("发布成功");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成21虚拟物件
|
||||
* <p>
|
||||
* 21机型发货:
|
||||
* 物料名称和物料描述=物料名称+(发货)
|
||||
* 物料类别=201101
|
||||
* 项目类别:L
|
||||
* 基本计量单位:PC
|
||||
* 流程类型:自制
|
||||
* <p>
|
||||
* 21机型制作:
|
||||
* 物料名称和物料描述=物料名称+(制作)
|
||||
*
|
||||
* @param materialList 返回 parent id
|
||||
*/
|
||||
private Long genVirtualPackLevel1(List<OptionalMbomMaterialEntity> materialList, Long rootRowId, String goodsDesc) throws NflgBusinessException {
|
||||
//21机型发货
|
||||
OptionalMbomMaterialEntity sendPack = new OptionalMbomMaterialEntity();
|
||||
String sendMaterialName = goodsDesc.concat("(发货)");
|
||||
sendPack.setRowId(IdWorker.getId());
|
||||
sendPack.setCreatedBy(SessionUtil.getUserCode());
|
||||
sendPack.setCreatedTime(new Date());
|
||||
sendPack.setMaterialName(sendMaterialName);
|
||||
sendPack.setMaterialDesc(sendMaterialName);
|
||||
sendPack.setRootRowId(rootRowId);
|
||||
sendPack.setMaterialNo("");//申请物料号
|
||||
|
||||
try {
|
||||
String data= materialService.addMaterialPublish("", sendPack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
|
||||
ResultVO<String> resultVO = JSON.parseObject(data, new 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(resultVO.getData());
|
||||
}catch (Exception e){
|
||||
throw new NflgBusinessException(STATE.Error, "机型发货物料编码申请失败,"+e.getMessage());
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(sendPack.getMaterialNo())) {
|
||||
throw new NflgBusinessException(STATE.Error, "机型发货物料编码申请失败");
|
||||
}
|
||||
|
||||
//21机型制作
|
||||
OptionalMbomMaterialEntity makePack = new OptionalMbomMaterialEntity();
|
||||
String makeMaterialName = goodsDesc.concat("(制作)");
|
||||
makePack.setRowId(IdWorker.getId());
|
||||
makePack.setCreatedBy(SessionUtil.getUserCode());
|
||||
makePack.setCreatedTime(new Date());
|
||||
makePack.setMaterialName(makeMaterialName);
|
||||
makePack.setMaterialDesc(makeMaterialName);
|
||||
makePack.setParentRowId(sendPack.getRowId()); //父级
|
||||
makePack.setRootRowId(rootRowId);
|
||||
makePack.setMaterialNo("");//申请物料号
|
||||
|
||||
|
||||
try {
|
||||
String data= materialService.addMaterialPublish("", makePack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
|
||||
ResultVO<String> resultVO = JSON.parseObject(data, new 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(resultVO.getData());
|
||||
}catch (Exception e){
|
||||
throw new NflgBusinessException(STATE.Error, "机型制作物料编码申请失败,"+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (StrUtil.isEmpty(makePack.getMaterialNo())) {
|
||||
throw new NflgBusinessException(STATE.Error, "机型制作物料编码申请失败");
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(materialList)) {
|
||||
materialList.add(sendPack);
|
||||
materialList.add(makePack);
|
||||
}
|
||||
return makePack.getRowId();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1.机械部分:用户输入图号+“ ”+物料名称+“(机械内容)” 自动生成机械部分的物料
|
||||
* 需要控制,只能输入40个字符,输入框后面的字符个数随着用户的输入进行变化,超过40个字符,不能继续输入,不允许中文括号输入,只能输入英文的括号
|
||||
* 2. 后端要对用户输入的信息进行拆分
|
||||
* 物料名称和物料描述=用户输入的内容
|
||||
* 图号=用户输入的内容截取第一个空格前的内容
|
||||
* 物料类别=201201
|
||||
* 项目类别:L
|
||||
* 基本计量单位:PC
|
||||
* 流程类型:自制
|
||||
*
|
||||
* @param materialList
|
||||
* @param rootRowId
|
||||
* @param parentId
|
||||
* @param desc
|
||||
* @return
|
||||
*/
|
||||
private void genVirtualPackMachineLevel2(List<OptionalMbomMaterialEntity> materialList, List<OptionalEbomImportChildVO> optionList, Long rootRowId, Long parentId, String desc) throws NflgBusinessException {
|
||||
|
||||
List<Long> materialNoList = optionList.stream().map(OptionalEbomImportChildVO::getMaterialNo).map(Long::parseLong).collect(Collectors.toList());
|
||||
Collections.sort(materialNoList);
|
||||
String result = materialNoList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
|
||||
String signMd5 = MD5.create().digestHex(result);
|
||||
QueryWrapper<OptionalMbomCompareEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OptionalMbomCompareEntity::getSignMd5, signMd5);
|
||||
OptionalMbomCompareEntity optionalMbomCompareEntity = optionalMbomCompareService.getOne(queryWrapper);
|
||||
OptionalMbomMaterialEntity material;
|
||||
if (optionalMbomCompareEntity == null) {
|
||||
material = new OptionalMbomMaterialEntity();
|
||||
//第一个空格位置图号
|
||||
String drawingNo = StrUtil.sub(desc,0,desc.indexOf(" ") );
|
||||
material.setRowId(IdWorker.getId());
|
||||
material.setDrawingNo(drawingNo);
|
||||
material.setParentRowId(parentId);
|
||||
material.setRootRowId(rootRowId);
|
||||
material.setCreatedBy(SessionUtil.getUserCode());
|
||||
material.setCreatedTime(new Date());
|
||||
material.setMaterialName(desc);
|
||||
material.setMaterialDesc(desc);
|
||||
material.setMaterialNo("");//申请物料号
|
||||
|
||||
try {
|
||||
String data= materialService.addMaterialPublish(material.getDrawingNo(), material.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.MACHINE.getCategory());
|
||||
ResultVO<String> resultVO = JSON.parseObject(data, new 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());
|
||||
}
|
||||
material.setMaterialNo(resultVO.getData());
|
||||
}catch (Exception e){
|
||||
throw new NflgBusinessException(STATE.Error, "机械部分物料编码申请失败,"+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
//数据不存在保存
|
||||
if (StrUtil.isNotEmpty(material.getMaterialNo())) {
|
||||
optionalMbomCompareEntity = Convert.convert(new TypeReference<OptionalMbomCompareEntity>() {
|
||||
}, material);
|
||||
optionalMbomCompareEntity.setParentRowId(rootRowId);
|
||||
optionalMbomCompareEntity.setSignMd5(signMd5);
|
||||
optionalMbomCompareEntity.setCreatedTime(new Date());
|
||||
optionalMbomCompareEntity.setChildRowIds(result);
|
||||
optionalMbomCompareService.save(optionalMbomCompareEntity);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else {
|
||||
material = Convert.convert(new TypeReference<OptionalMbomMaterialEntity>() {
|
||||
}, optionalMbomCompareEntity);
|
||||
material.setRowId(IdWorker.getId());
|
||||
material.setParentRowId(parentId);
|
||||
material.setRootRowId(rootRowId);
|
||||
material.setCreatedBy(SessionUtil.getUserCode());
|
||||
material.setCreatedTime(new Date());
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(material.getMaterialNo())) {
|
||||
throw new NflgBusinessException(STATE.Error, "机械部分物料编码申请失败");
|
||||
}
|
||||
|
||||
|
||||
List<OptionalMbomMaterialEntity> optionConvertList = Convert.toList(OptionalMbomMaterialEntity.class, optionList);
|
||||
optionConvertList.forEach(item -> {
|
||||
item.setCreatedBy(SessionUtil.getUserCode());
|
||||
item.setCreatedTime(new Date());
|
||||
item.setRootRowId(rootRowId);
|
||||
item.setParentRowId(material.getRowId());
|
||||
materialList.add(item);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 电控部分
|
||||
* <p>
|
||||
* <p>
|
||||
* 1. 电控制作:
|
||||
* 物料名称和物料描述=(图号)+(电控系统)+(制作)
|
||||
* 物料类别=201101
|
||||
* 3. 项目类别:L
|
||||
* 基本计量单位:PC
|
||||
* 流程类型:自制
|
||||
* 电控发货:
|
||||
* 2. 物料名称和物料描述=(图号)+(电控系统)+(发货)
|
||||
*
|
||||
* @param materialList
|
||||
* @param rootRowId
|
||||
* @param desc
|
||||
* @return
|
||||
*/
|
||||
private void genVirtualPackElectricLevel2(List<OptionalMbomMaterialEntity> materialList, Long rootRowId, Long parentId, String desc) throws NflgBusinessException {
|
||||
OptionalMbomMaterialEntity makePack = new OptionalMbomMaterialEntity();
|
||||
String makeMaterialName = StrUtil.format("({})", desc).concat("(电控系统)").concat("(制作)");
|
||||
makePack.setRowId(IdWorker.getId());
|
||||
makePack.setParentRowId(parentId);
|
||||
makePack.setCreatedBy(SessionUtil.getUserCode());
|
||||
makePack.setCreatedTime(new Date());
|
||||
makePack.setMaterialName(makeMaterialName);
|
||||
makePack.setMaterialDesc(makeMaterialName);
|
||||
makePack.setRootRowId(rootRowId);
|
||||
makePack.setMaterialNo("");//申请物料号
|
||||
|
||||
|
||||
try {
|
||||
String data= materialService.addMaterialPublish("", makePack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
|
||||
ResultVO<String> resultVO = JSON.parseObject(data, new 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(resultVO.getData());
|
||||
}catch (Exception e){
|
||||
throw new NflgBusinessException(STATE.Error, "电控制作物料编码申请失败,"+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.isEmpty(makePack.getMaterialNo())) {
|
||||
throw new NflgBusinessException(STATE.Error, "电控制作物料编码申请失败");
|
||||
}
|
||||
|
||||
|
||||
OptionalMbomMaterialEntity sendPack = new OptionalMbomMaterialEntity();
|
||||
String sendMaterialName = StrUtil.format("({})", desc).concat("(电控系统)").concat("(发货)");
|
||||
sendPack.setRowId(IdWorker.getId());
|
||||
sendPack.setParentRowId(makePack.getRowId());
|
||||
sendPack.setCreatedBy(SessionUtil.getUserCode());
|
||||
sendPack.setCreatedTime(new Date());
|
||||
sendPack.setMaterialName(sendMaterialName);
|
||||
sendPack.setMaterialDesc(sendMaterialName);
|
||||
sendPack.setRootRowId(rootRowId);
|
||||
sendPack.setMaterialNo("");//申请物料号
|
||||
try {
|
||||
String data= materialService.addMaterialPublish("", sendPack.getMaterialName(), OptionalBomConstant.PublishMaterialEnum.OTHER.getCategory());
|
||||
ResultVO<String> resultVO = JSON.parseObject(data, new 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(resultVO.getData());
|
||||
}catch (Exception e){
|
||||
throw new NflgBusinessException(STATE.Error, "电控发货物料编码申请失败,"+e.getMessage());
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(sendPack.getMaterialNo())) {
|
||||
throw new NflgBusinessException(STATE.Error, "电控发货物料编码申请失败");
|
||||
}
|
||||
materialList.add(makePack);
|
||||
materialList.add(sendPack);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
package com.nflg.product.bomnew.service.aggreg;
|
||||
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.OptionalMbomCompareEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.OptionalEbomImportChildVO;
|
||||
import com.nflg.product.bomnew.service.OptionalEbomConfigService;
|
||||
import com.nflg.product.bomnew.service.OptionalMbomCompareService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class PublishService {
|
||||
@Resource
|
||||
private OptionalMbomCompareService optionalMbomCompareService;
|
||||
|
||||
|
||||
@Resource
|
||||
private OptionalEbomConfigService optionalEbomConfigService;
|
||||
|
||||
|
||||
/**
|
||||
* 发布
|
||||
* 1.获取物料信息
|
||||
* 2.更改状态
|
||||
* 3.上传sap
|
||||
* @param rowId
|
||||
*/
|
||||
|
||||
public void publish(Long rowId) {
|
||||
|
||||
List<OptionalEbomImportChildVO> previewOptionList= optionalEbomConfigService.getPreviewOptionList(rowId);
|
||||
List<String> materialNoList = previewOptionList.stream().map(OptionalEbomImportChildVO::getMaterialNo).collect(Collectors.toList());
|
||||
|
||||
Collections.sort(materialNoList);
|
||||
|
||||
String result = materialNoList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
|
||||
String signMd5= MD5.create().digestHex(result);
|
||||
|
||||
QueryWrapper<OptionalMbomCompareEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OptionalMbomCompareEntity::getSignMd5, signMd5);
|
||||
|
||||
OptionalMbomCompareEntity optionalMbomCompareEntity = optionalMbomCompareService.getOne(queryWrapper);
|
||||
|
||||
System.out.println(result);
|
||||
System.out.println(signMd5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue