From 79f3dad67b917ddee36763819f92315ccfcdf2f1 Mon Sep 17 00:00:00 2001 From: yinq Date: Mon, 16 Dec 2024 19:47:38 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E7=94=9F=E4=BA=A7=E6=B4=BE?= =?UTF-8?q?=E5=B7=A5=E9=80=89=E6=8B=A9BOM=E4=B8=8A=E4=BC=A0=E7=9A=84?= =?UTF-8?q?=E5=9B=BE=E7=BA=B8=E3=80=81SOP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MesMaterialBomController.java | 9 ++ .../mes/service/IMesMaterialBomService.java | 10 ++ .../impl/MesMaterialBomServiceImpl.java | 43 ++++++ hw-ui/src/api/mes/materialBom.js | 8 + .../views/mes/productplan/editProductPlan.vue | 142 ++++++++++++++++-- 5 files changed, 203 insertions(+), 9 deletions(-) diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMaterialBomController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMaterialBomController.java index 9672e469..fad596dd 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMaterialBomController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMaterialBomController.java @@ -126,4 +126,13 @@ public class MesMaterialBomController extends BaseController return toAjax(mesMaterialBomService.updateBomAttachInfo(mesMaterialBom)); } + /** + * 获取物料BOM附件信息 + */ + @GetMapping("getBomAttachInfo/{attachType}/{materialBomIds}") + public AjaxResult getBomAttachInfo(@PathVariable String attachType, @PathVariable Long[] materialBomIds) + { + return success(mesMaterialBomService.getBomAttachInfo(attachType, materialBomIds)); + } + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesMaterialBomService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesMaterialBomService.java index fb8a29ed..577a710d 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesMaterialBomService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesMaterialBomService.java @@ -1,6 +1,8 @@ package com.hw.mes.service; import java.util.List; + +import com.hw.mes.domain.MesBaseAttachInfo; import com.hw.mes.domain.MesMaterialBom; /** @@ -89,4 +91,12 @@ public interface IMesMaterialBomService * @return */ public int updateBomAttachInfo(MesMaterialBom mesMaterialBom); + + /** + * 获取物料BOM附件信息 + * @param attachType + * @param materialBomIds + * @return + */ + public List getBomAttachInfo(String attachType, Long[] materialBomIds); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java index df417327..05784537 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java @@ -1,6 +1,7 @@ package com.hw.mes.service.impl; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -11,6 +12,8 @@ import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.MailUtils; import com.hw.common.core.utils.StringUtils; +import com.hw.mes.domain.MesBaseAttachInfo; +import com.hw.mes.service.IMesBaseAttachInfoService; import com.hw.system.api.RemoteUserService; import com.hw.system.api.domain.SysUser; import com.hw.system.api.model.LoginUser; @@ -35,6 +38,9 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { @Autowired private RemoteUserService remoteUserService; + @Autowired + private IMesBaseAttachInfoService mesBaseAttachInfoService; + /** * 查询物料BOM信息 * @@ -260,4 +266,41 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { return mesMaterialBomMapper.updateMesMaterialBom(mesMaterialBom); } + /** + * 获取物料BOM附件信息 + * @param attachType + * @param materialBomIds + * @return + */ + @Override + public List getBomAttachInfo(String attachType, Long[] materialBomIds) { + List attachIdList = new ArrayList<>(); + for (Long materialBomId : materialBomIds) { + if (attachType.equals("1")){ + MesMaterialBom materialBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(materialBomId); + if (StringUtils.isNotEmpty(materialBom.getAttachId())){ + String[] split = materialBom.getAttachId().split(","); + List longList = Arrays.stream(split) + .map(Long::valueOf) // 转换每个字符串为 Long + .collect(Collectors.toList()); + attachIdList.addAll(longList); + } + } else { + MesMaterialBom materialBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(materialBomId); + if (StringUtils.isNotEmpty(materialBom.getSopId())){ + String[] split = materialBom.getSopId().split(","); + List longList = Arrays.stream(split) + .map(Long::valueOf) // 转换每个字符串为 Long + .collect(Collectors.toList()); + attachIdList.addAll(longList); + } + } + } + if (attachIdList.size() > 0){ + Long[] attachIds = attachIdList.toArray(new Long[0]); + return mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(attachIds); + } + return null; + } + } diff --git a/hw-ui/src/api/mes/materialBom.js b/hw-ui/src/api/mes/materialBom.js index 68eb5100..6885f8ad 100644 --- a/hw-ui/src/api/mes/materialBom.js +++ b/hw-ui/src/api/mes/materialBom.js @@ -74,3 +74,11 @@ export function updateBomAttachInfo(data) { data: data }) } + +// 查询物料BOM版本列表 +export function getBomAttachInfo(attachType, materialBomIds) { + return request({ + url: '/mes/materialBom/getBomAttachInfo/' + attachType + '/' + materialBomIds, + method: 'get' + }) +} diff --git a/hw-ui/src/views/mes/productplan/editProductPlan.vue b/hw-ui/src/views/mes/productplan/editProductPlan.vue index b846a366..348d50a4 100644 --- a/hw-ui/src/views/mes/productplan/editProductPlan.vue +++ b/hw-ui/src/views/mes/productplan/editProductPlan.vue @@ -241,6 +241,18 @@ title="上传图纸" width="30%" @before-close="blueprintModel = false"> + + + + + + + + + + + + + + { @@ -579,9 +605,21 @@ export default { }, id: 1, - processUsers: [] + processUsers: [], + //物料BOMList + attachInfoList: [], + //选中的BOMList + materialBomAttachIdList: [], }; }, + watch: { + 'materialBomAttachIdList': { + handler(newVal, oldVal) { + console.log("val:",newVal,oldVal) + this.updateAttachInfoByBom(newVal, oldVal); + }, + } + }, created() { const productOrderId = this.$route.params && this.$route.params.productOrderId; if (productOrderId) { @@ -592,6 +630,7 @@ export default { }); } + this.getConfigValues(); }, methods: { @@ -616,7 +655,7 @@ export default { }); getConfigKey("mes.sop.maxSize").then(res => { - if(res.msg){ + if (res.msg) { this.sopFileSize = res.msg; } }); @@ -1160,6 +1199,16 @@ export default { } this.addProductPlanObject = row; + this.materialBomAttachIdList = []; + getBomAttachInfo("1", this.addProductPlanObject.materialBomId).then(response => { + this.attachInfoList = response.data; + for (let e of this.fileList) { + let attachInfo = this.attachInfoList.find(item => item.attachPath === e.url); + if (attachInfo != null){ + this.materialBomAttachIdList.push(attachInfo.attachId); + } + } + }); this.blueprintModel = true; }, @@ -1215,9 +1264,10 @@ export default { handleRemoveDrawing(file) { let arrPic = this.$refs.drawingUpload.uploadFiles; let index = arrPic.indexOf(file); + console.log("index",index) this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); // this.uploadAttachList.splice(index, 1); - // this.fileList.splice(index, 1); + this.fileList.splice(index, 1); this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); let num = 0; arrPic.map((item) => { @@ -1226,6 +1276,10 @@ export default { } num++; }); + let attachInfo = this.attachInfoList.find(item => item.attachPath === file.url); + if (attachInfo != null){ + this.materialBomAttachIdList = this.materialBomAttachIdList.filter(item => item !== attachInfo.attachId); + } }, @@ -1282,6 +1336,16 @@ export default { } this.addProductPlanObject = row; + this.materialBomAttachIdList = []; + getBomAttachInfo("2", this.addProductPlanObject.materialBomId).then(response => { + this.attachInfoList = response.data; + for (let e of this.fileList) { + let attachInfo = this.attachInfoList.find(item => item.attachPath === e.url); + if (attachInfo != null){ + this.materialBomAttachIdList.push(attachInfo.attachId); + } + } + }); this.sopViewModel = true; }, @@ -1339,6 +1403,7 @@ export default { let index = arrPic.indexOf(file); this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); + this.fileList.splice(index, 1); let num = 0; arrPic.map((item) => { if (item.uid === file.uid) { @@ -1346,19 +1411,20 @@ export default { } num++; }); + let attachInfo = this.attachInfoList.find(item => item.attachPath === file.url); + if (attachInfo != null){ + this.materialBomAttachIdList = this.materialBomAttachIdList.filter(item => item !== attachInfo.attachId); + } }, - - - // 上传前loading加载 handleBeforeUpload(file) { - let fileType,fileSize; - if(this.sopViewModel){ + let fileType, fileSize; + if (this.sopViewModel) { fileType = this.sopFileType; fileSize = this.sopFileSize; - }else if(this.blueprintModel){ + } else if (this.blueprintModel) { fileType = this.drawingFileType; fileSize = this.drawingFileSize; } @@ -1421,6 +1487,60 @@ export default { closeRawOutstockDialog() { this.applyRawOutstockOpen = false; }, + //根据BOM更新图纸或SOP + updateAttachInfoByBom(newVal, oldVal) { + if (newVal.length === 0) { + return + } + let result = []; + let targetAttachIds = newVal.filter(item => !oldVal.includes(item)); + for (let targetAttachId of targetAttachIds) { + result.push(this.attachInfoList.find(item => item.attachId === targetAttachId)); + } + console.log("result:",result); + let isDrawing = this.blueprintModel; + //图纸 + if (isDrawing) { + for (let e of result) { + let previewFile = {}; + previewFile.url = e.attachPath; + previewFile.name = e.attachName; + this.fileList.push(previewFile); + let groupAttachFile = {}; + groupAttachFile.dispatchCode = this.addProductPlanObject.dispatchCode; + groupAttachFile.processId = this.addProductPlanObject.processId; + groupAttachFile.attachId = e.attachId; + groupAttachFile.attachPath = e.attachPath; + groupAttachFile.attachName = e.attachName; + let groupAttachFileList = this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupAttachFileList ? this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupAttachFile); + let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(e.attachId); + } + } else { + //SOP + for (let e of result) { + let previewFile = {}; + previewFile.url = e.attachPath; + previewFile.name = e.attachName; + this.fileList.push(previewFile); + let groupSopFile = {}; + groupSopFile.dispatchCode = this.addProductPlanObject.dispatchCode; + groupSopFile.processId = this.addProductPlanObject.processId; + groupSopFile.attachId = e.attachId; + groupSopFile.attachPath = e.attachPath; + groupSopFile.attachName = e.attachName; + let groupSopFileList = this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupSopFileList ? this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupSopFile); + let uploadSopList = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(e.attachId); + } + } + } }, @@ -1431,3 +1551,7 @@ export default { } ; + +