From 758158d262e0abfa5bae21453080667c6feec613 Mon Sep 17 00:00:00 2001 From: jing's Date: Thu, 25 Jan 2024 22:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/OptionalEBom/PublisMaterial.java | 254 +++++++++++++++++- 1 file changed, 251 insertions(+), 3 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OptionalEBom/PublisMaterial.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OptionalEBom/PublisMaterial.java index a93b6fd6..fe11e6a0 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OptionalEBom/PublisMaterial.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OptionalEBom/PublisMaterial.java @@ -1,29 +1,277 @@ package com.nflg.product.bomnew.service.domain.OptionalEBom; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.TypeReference; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.digest.MD5; +import cn.hutool.extra.spring.SpringUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +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.OptionalEbomMainEntity; +import com.nflg.product.bomnew.pojo.entity.OptionalMbomCompareEntity; import com.nflg.product.bomnew.pojo.entity.OptionalMbomMaterialEntity; import com.nflg.product.bomnew.pojo.vo.OptionalEbomImportChildVO; +import com.nflg.product.bomnew.service.OptionalEbomMainService; +import com.nflg.product.bomnew.service.OptionalMbomCompareService; +import com.nflg.product.bomnew.util.OrderNoUtil; +import lombok.Getter; +import nflg.product.common.constant.STATE; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; public class PublisMaterial { private OptionalEbomPublishAddDTO publishAddDTO; - public PublisMaterial(OptionalEbomPublishAddDTO dto){ +@Getter + private List materialList ; + +private Long deviceRowId; + public PublisMaterial(OptionalEbomPublishAddDTO dto,Long deviceRowId){ this.publishAddDTO=dto; + materialList = new ArrayList<>(); + this.deviceRowId=deviceRowId; + } + + + OptionalMbomMaterialEntity genVirtualPackLevelSend1( List oaList){ + //21机型发货 + OptionalMbomMaterialEntity sendPack = new OptionalMbomMaterialEntity(); + String sendMaterialName = publishAddDTO.getGoodsDesc().concat("(发货)"); + sendPack.setRowId(IdWorker.getId()); + sendPack.setCreatedBy(SessionUtil.getUserCode()); + sendPack.setRealName(SessionUtil.getRealName()); + sendPack.setDeptName(SessionUtil.getDepartName()); + sendPack.setCreatedTime(DateUtil.now()); + sendPack.setMaterialName(sendMaterialName); + sendPack.setMaterialDesc(sendMaterialName); + sendPack.setDrawingNo(sendMaterialName); + sendPack.setRootRowId(publishAddDTO.getRowId()); + sendPack.setMaterialNo("");//申请物料号 + sendPack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_1.getValue()); + + + + AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO(); + String key=String.valueOf(sendPack.getRowId()); + 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()); + + oaList.add(toM); + + return sendPack; + + } + OptionalMbomMaterialEntity genVirtualPackLevelMake1(Long parentRowId,List oaList){ + //21机型制作 + OptionalMbomMaterialEntity makePack = new OptionalMbomMaterialEntity(); + String makeMaterialName = publishAddDTO.getGoodsDesc().concat("(制作)"); + makePack.setRowId(IdWorker.getId()); + makePack.setCreatedBy(SessionUtil.getUserCode()); + makePack.setRealName(SessionUtil.getRealName()); + makePack.setDeptName(SessionUtil.getDepartName()); + makePack.setMaterialName(makeMaterialName); + makePack.setMaterialDesc(makeMaterialName); + makePack.setDrawingNo(makeMaterialName); + makePack.setParentRowId(parentRowId); //父级 + makePack.setRootRowId(publishAddDTO.getRowId()); + makePack.setCreatedTime(DateUtil.now()); + makePack.setMaterialNo("");//申请物料号 + makePack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_2.getValue()); + + AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO(); + String key=String.valueOf(makePack.getRowId()) ; + 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()); + oaList.add(toM); + return makePack; + } + + /** + * 电控制作 + */ + void genVirtualPackElectricLevelMake2(Long parentRowId,List oaList){ + OptionalMbomMaterialEntity makePack = new OptionalMbomMaterialEntity(); + String makeMaterialName = StrUtil.format("({})", publishAddDTO.getElectricDesc()).concat("(电控系统)").concat("(制作)"); + makePack.setRowId(IdWorker.getId()); + makePack.setParentRowId(parentRowId); + makePack.setCreatedBy(SessionUtil.getUserCode()); + makePack .setRealName(SessionUtil.getRealName()); + makePack .setDeptName(SessionUtil.getDepartName()); + makePack.setCreatedTime(DateUtil.now()); + makePack.setMaterialName(makeMaterialName); + makePack.setMaterialDesc(makeMaterialName); + makePack.setDrawingNo(makeMaterialName); + makePack.setRootRowId(publishAddDTO.getRowId()); + makePack.setMaterialNo("");//申请物料号 + makePack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_4.getValue()); + + AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO(); + String key=String.valueOf(makePack.getRowId()) ; + 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()); + + oaList.add(toM); + } + + + /** + * 电控发货 + */ + void genVirtualPackElectricLevelSend2(Long parentRowId,List oaList){ + + OptionalMbomMaterialEntity sendPack = new OptionalMbomMaterialEntity(); + String sendMaterialName = StrUtil.format("({})", publishAddDTO.getElectricDesc()).concat("(电控系统)").concat("(发货)"); + sendPack.setRowId(IdWorker.getId()); + sendPack.setParentRowId(parentRowId); + sendPack.setCreatedBy(SessionUtil.getUserCode()); + sendPack .setRealName(SessionUtil.getRealName()); + sendPack.setDeptName(SessionUtil.getDepartName()); + sendPack.setCreatedTime(DateUtil.now()); + sendPack.setMaterialName(sendMaterialName); + sendPack.setMaterialDesc(sendMaterialName); + sendPack.setDrawingNo(sendMaterialName); + sendPack.setRootRowId(publishAddDTO.getRowId()); + sendPack.setMaterialNo("");//申请物料号 + sendPack.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_3.getValue()); + + AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO(); + String key=String.valueOf(sendPack.getRowId()) ; + 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()); + oaList.add(toM); + + } + + + + + + + void genVirtualPackMachineLevel2(Long parentRowId , List optionList,List oaList){ +// List materialNoList = optionList.stream().filter(u-> u.getPartType().equals(OptionalBomConstant.PartTypeEnum.PART_TYPE_RADIO.getValue()) ).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 queryWrapper = new QueryWrapper<>(); +// queryWrapper.lambda().eq(OptionalMbomCompareEntity::getSignMd5, signMd5); +// OptionalMbomCompareEntity optionalMbomCompareEntity= SpringUtil.getBean(OptionalMbomCompareService.class).getOne(queryWrapper); +// OptionalMbomMaterialEntity material; +// if (optionalMbomCompareEntity == null) { +// material = new OptionalMbomMaterialEntity(); +// OptionalEbomMainEntity desc= SpringUtil.getBean(OptionalEbomMainService.class).getById(deviceRowId); +// +// //物料名称和物料描述=机型+流水号+NF(机械部分) +// //图号=机型+流水号+NF +// String drawingNo =StrUtil.format("{}-{}",desc.getDeviceNo(), OrderNoUtil.orderNo2Str(desc.getSerialNo())).concat("-NF"); +// String materialName=drawingNo.concat("(机械部分)"); +// material.setRowId(IdWorker.getId()); +// +// material.setParentRowId(parentRowId); +// material.setRootRowId(publishAddDTO.getRowId()); +// material.setCreatedBy(SessionUtil.getUserCode()); +// material.setRealName(SessionUtil.getRealName()); +// material.setDeptName(SessionUtil.getDepartName()); +// material.setCreatedTime(DateUtil.now()); +// material.setMaterialName(materialName); +// material.setMaterialDesc(materialName); +// material.setDrawingNo(drawingNo); +// material.setMaterialNo("");//申请物料号 +// material.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_5.getValue()); +// +// +// AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO(); +// String key=String.valueOf(material.getRowId()) ; +// 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()); +// oaList.add(toM); +// +// +// +// try { +// //数据不存在保存 +// if (StrUtil.isNotEmpty(material.getMaterialNo())) { +// optionalMbomCompareEntity = Convert.convert(new TypeReference() { +// }, material); +// optionalMbomCompareEntity.setParentRowId(rootRowId); +// optionalMbomCompareEntity.setSignMd5(signMd5); +// optionalMbomCompareEntity.setCreatedTime(DateUtil.now()); +// optionalMbomCompareEntity.setChildRowIds(result); +// optionalMbomCompareService.save(optionalMbomCompareEntity); +// +// //更新序列号 +// OptionalEbomMainEntity updateDevice=new OptionalEbomMainEntity(); +// updateDevice.setRowId(desc.getRowId()); +// updateDevice.setSerialNo(desc.getSerialNo()+1); +// SpringUtil.getBean(OptionalEbomMainService.class).updateById(updateDevice); +// +// } +// +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// +// +// } else { //同物料号 +// material = Convert.convert(new TypeReference() { +// }, optionalMbomCompareEntity); +// material.setRowId(IdWorker.getId()); +// material.setParentRowId(parentRowId); +// material.setRootRowId(publishAddDTO.getRowId()); +// material.setCreatedBy(SessionUtil.getUserCode()); +// material.setRealName(SessionUtil.getRealName()); +// material.setDeptName(SessionUtil.getDepartName()); +// material.setCategoryType(OptionalBomConstant.CategoryTypeEnum.TYPE_5.getValue()); +// material.setCreatedTime(DateUtil.now()); +// } +// + + + } public List buildMaterialList( List optionList ){ - List materialList = new ArrayList<>(); + List oaList=new ArrayList<>(); -return null; + return null; }