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 9a3cd795..9672e469 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 @@ -113,4 +113,17 @@ public class MesMaterialBomController extends BaseController return success(mesMaterialBomService.getMaterialVisionList(materialId)); } + /** + * 更新附件信息并通知用户 + * @param mesMaterialBom + * @return + */ + @PostMapping("updateBomAttachInfo") + @RequiresPermissions("mes:materialBom:edit") + @Log(title = "物料BOM信息", businessType = BusinessType.UPDATE) + public AjaxResult updateBomAttachInfo(@RequestBody MesMaterialBom mesMaterialBom) + { + return toAjax(mesMaterialBomService.updateBomAttachInfo(mesMaterialBom)); + } + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java index 12c7c558..ebd14763 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java @@ -1,6 +1,7 @@ package com.hw.mes.domain; import java.math.BigDecimal; +import java.util.List; import java.util.Objects; import com.hw.common.core.utils.StringUtils; @@ -116,6 +117,29 @@ public class MesMaterialBom extends TreeEntity { /** sop附件ID,关联附件信息主键;多个用,隔开 */ private String sopId; + /** + * 附件类别:1-加工图纸;2-SOP + */ + private String attachType; + + private List userNameList; + + public String getAttachType() { + return attachType; + } + + public void setAttachType(String attachType) { + this.attachType = attachType; + } + + public List getUserNameList() { + return userNameList; + } + + public void setUserNameList(List userNameList) { + this.userNameList = userNameList; + } + public String getAttachId() { return attachId; } 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 66b9532b..fb8a29ed 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 @@ -82,4 +82,11 @@ public interface IMesMaterialBomService * @return 物料BOM信息 */ public MesMaterialBom selectTopMaterialBomByMaterialBomId(Long materialBomId); + + /** + * 更新附件信息并通知用户 + * @param mesMaterialBom + * @return + */ + public int updateBomAttachInfo(MesMaterialBom mesMaterialBom); } 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 27feb328..df417327 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 @@ -5,13 +5,21 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.hw.common.core.constant.SecurityConstants; +import com.hw.common.core.domain.R; +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.system.api.RemoteUserService; +import com.hw.system.api.domain.SysUser; +import com.hw.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.mes.mapper.MesMaterialBomMapper; import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.service.IMesMaterialBomService; +import org.springframework.transaction.annotation.Transactional; /** * 物料BOM信息Service业务层处理 @@ -24,6 +32,9 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { @Autowired private MesMaterialBomMapper mesMaterialBomMapper; + @Autowired + private RemoteUserService remoteUserService; + /** * 查询物料BOM信息 * @@ -214,4 +225,39 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { } } + /** + * 更新附件信息并通知用户 + * @param mesMaterialBom + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateBomAttachInfo(MesMaterialBom mesMaterialBom) { + List sysUserList = new ArrayList<>(); + StringBuilder sendMsg = new StringBuilder(); + sendMsg.append("BOM名称:").append(mesMaterialBom.getMaterialName()); + if (mesMaterialBom.getUserNameList().size() == 0){ + throw new ServiceException("请选择通知用户!"); + } + for (String userName : mesMaterialBom.getUserNameList()) { + R userInfo = remoteUserService.getUserInfo(userName, SecurityConstants.INNER); + SysUser sysUser = userInfo.getData().getSysUser(); + if (StringUtils.isEmpty(sysUser.getEmail())){ + throw new ServiceException(sysUser.getNickName() + "用户未维护邮箱!"); + } + sysUserList.add(sysUser); + } + if (mesMaterialBom.getAttachType().equals("1")){ + sendMsg.append(",图纸已维护成功!"); + } else { + sendMsg.append(",SOP已维护成功!"); + } + for (SysUser sysUser : sysUserList) { + String email = sysUser.getEmail(); + MailUtils.processSendEmail(email, "通知", sendMsg.toString()); + } + mesMaterialBom.setUpdateTime(DateUtils.getNowDate()); + return mesMaterialBomMapper.updateMesMaterialBom(mesMaterialBom); + } + } diff --git a/hw-ui/src/api/mes/materialBom.js b/hw-ui/src/api/mes/materialBom.js index 51c7f615..68eb5100 100644 --- a/hw-ui/src/api/mes/materialBom.js +++ b/hw-ui/src/api/mes/materialBom.js @@ -65,3 +65,12 @@ export function changeBomStatus(materialBomId, activeFlag) { data: data }) } + +// 更新附件信息并通知用户 +export function updateBomAttachInfo(data) { + return request({ + url: '/mes/materialBom/updateBomAttachInfo', + method: 'post', + data: data + }) +} diff --git a/hw-ui/src/views/mes/materialBom/index.vue b/hw-ui/src/views/mes/materialBom/index.vue index 990b154e..2e097802 100644 --- a/hw-ui/src/views/mes/materialBom/index.vue +++ b/hw-ui/src/views/mes/materialBom/index.vue @@ -298,6 +298,18 @@ title="上传图纸" width="30%" @before-close="blueprintModel = false"> + + + + + + + + + + + + + + { + this.userList = response.data; + }); listMaterialBom(this.queryParams).then(response => { this.materialBomList = this.handleTree(response.data, "materialBomId", "parentId"); this.loading = false; @@ -888,6 +920,7 @@ export default { /** 查看图纸 */ handleDrawing(row) { this.fileList = []; + this.userNoticeList = []; if (row.attachId != null && row.attachId !== "") { selectByAttachIds(row.attachId).then(res => { let attachList = res.data; @@ -913,14 +946,19 @@ export default { this.uploadAttachList = []; let updateData = { materialBomId: this.addProductPlanObject.materialBomId, - parentId: this.addProductPlanObject.parentId, + materialName: this.addProductPlanObject.materialName, + userNameList: this.userNoticeList, + attachType: "1", attachId: this.addProductPlanObject.attachId } - updateMaterialBom(updateData).then(response => { + updateBomAttachInfo(updateData).then(response => { this.$modal.msgSuccess("更新图纸成功"); this.addProductPlanObject = null; this.blueprintModel = false; this.getList(); + }).catch(() => { + this.addProductPlanObject = null; + this.sopViewModel = false; }); }, //图纸图片上传 @@ -960,6 +998,7 @@ export default { /** 查看sop */ handleSop(row) { this.fileList = []; + this.userNoticeList = []; if (row.sopId != null && row.sopId !== "") { selectByAttachIds(row.sopId).then(res => { let attachList = res.data; @@ -985,14 +1024,19 @@ export default { this.uploadSopList = []; let updateData = { materialBomId: this.addProductPlanObject.materialBomId, - parentId: this.addProductPlanObject.parentId, + materialName: this.addProductPlanObject.materialName, + userNameList: this.userNoticeList, + attachType: "2", sopId: this.addProductPlanObject.sopId } - updateMaterialBom(updateData).then(response => { + updateBomAttachInfo(updateData).then(response => { this.$modal.msgSuccess("更新SOP成功"); this.addProductPlanObject = null; this.sopViewModel = false; this.getList(); + }).catch(() => { + this.addProductPlanObject = null; + this.sopViewModel = false; }); }, //Sop图片上传