From a3cb768d958e64625786857e0db69335875f5d8e Mon Sep 17 00:00:00 2001 From: hyingbo <1363390067@qq.com> Date: 星期五, 06 六月 2025 13:43:55 +0800 Subject: [PATCH] 消息类型更新 --- lxzn-module-eam/src/main/java/org/jeecg/modules/spare/service/impl/SparePartOutboundDetailServiceImpl.java | 82 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 74 insertions(+), 8 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/service/impl/SparePartOutboundDetailServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/service/impl/SparePartOutboundDetailServiceImpl.java index 3126659..fd4d7f0 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/service/impl/SparePartOutboundDetailServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/service/impl/SparePartOutboundDetailServiceImpl.java @@ -1,14 +1,24 @@ package org.jeecg.modules.spare.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.system.api.ISysBaseAPI; +import org.jeecg.common.system.vo.DictModel; import org.jeecg.modules.spare.entity.*; import org.jeecg.modules.spare.mapper.SparePartOutboundDetailMapper; import org.jeecg.modules.spare.service.ISparePartOutboundDetailService; import org.jeecg.modules.spare.service.ISparePartOutboundService; import org.jeecg.modules.spare.service.ISparePartService; import org.jeecg.modules.spare.service.ISparesPartInventoryService; +import org.jeecg.modules.system.entity.SysRole; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.ISysDictService; +import org.jeecg.modules.system.service.ISysRoleService; +import org.jeecg.modules.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -17,6 +27,9 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -40,6 +53,22 @@ @Autowired @Lazy private ISparePartOutboundService sparePartOutboundService; + + @Autowired + @Lazy + private ISysDictService sysDictService; + + @Autowired + @Lazy + private ISysRoleService sysRoleService; + + @Autowired + @Lazy + private ISysUserService sysUserService; + + @Autowired + @Lazy + private ISysBaseAPI sysBaseAPI; @Override public List<Map<String, Object>> getSparePartOutboundDeatilList(String sparePartOutboundId) { @@ -69,27 +98,27 @@ //3.鑾峰彇涓� 杈呭崟浣嶈浆鎹㈡瘮渚� SparePart sparePart = sparePartService.getById(sparePartId); - String conversionRatio = sparePart.getConversionRatio(); +/* String conversionRatio = sparePart.getConversionRatio(); double conversionRatioD = 0; if(StringUtils.isBlank(conversionRatio)){ conversionRatioD = Double.parseDouble("0"); }else{ conversionRatioD = Double.parseDouble(conversionRatio); } - BigDecimal conversionRatioB = new BigDecimal(conversionRatioD); + BigDecimal conversionRatioB = new BigDecimal(conversionRatioD);*/ //4.璁$畻鍑哄簱鏁伴噺鏇存柊搴撳瓨鏁伴噺(搴撳瓨) Double mainQuantity = sparesPartInventory.getMainQuantity(); BigDecimal mainQuantityB = new BigDecimal(mainQuantity); - Double auxiliaryQuantity = sparesPartInventory.getAuxiliaryQuantity(); - BigDecimal auxiliaryQuantityB = new BigDecimal(auxiliaryQuantity); + /* Double auxiliaryQuantity = sparesPartInventory.getAuxiliaryQuantity();*/ + /* BigDecimal auxiliaryQuantityB = new BigDecimal(auxiliaryQuantity);*/ BigDecimal mainQuantitySubtract = mainQuantityB.subtract(outboundMainQuantityB);//鍑忓畬鍚庣殑搴撳瓨涓绘暟閲� - BigDecimal outboundAuxiliaryQuantity = outboundMainQuantityB.multiply(conversionRatioB);//鍑哄簱杈呮暟閲� - BigDecimal auxiliaryQuantitySubtract = auxiliaryQuantityB.subtract(outboundAuxiliaryQuantity);//鍑忓畬鍚庣殑搴撳瓨杈呮暟閲� + /* BigDecimal outboundAuxiliaryQuantity = outboundMainQuantityB.multiply(conversionRatioB);//鍑哄簱杈呮暟閲�*/ + /* BigDecimal auxiliaryQuantitySubtract = auxiliaryQuantityB.subtract(outboundAuxiliaryQuantity);//鍑忓畬鍚庣殑搴撳瓨杈呮暟閲�*/ sparesPartInventory.setMainQuantity(mainQuantitySubtract.doubleValue()); - sparesPartInventory.setAuxiliaryQuantity(auxiliaryQuantitySubtract.doubleValue()); + /* sparesPartInventory.setAuxiliaryQuantity(auxiliaryQuantitySubtract.doubleValue());*/ boolean b = sparesPartInventoryService.updateById(sparesPartInventory); if(!b){ return b; @@ -107,8 +136,45 @@ sparePartOutbound.setStatus("4"); sparePartOutboundService.updateById(sparePartOutbound); } + + //6.鍒ゆ柇鍑哄簱鍚庡簱瀛樻槸鍚︿綆浜庡畨鍏ㄥ簱瀛樻垨鍑虹幇绉帇鎯呭喌 + List roleList = new ArrayList<>(); + List<DictModel> dictModelList = sysDictService.getDictItems("warehouse_message"); + for(DictModel dictModel : dictModelList){ + roleList.add(dictModel.getText()); + } + QueryWrapper<SysRole> queryWrapper = Wrappers.query(); + queryWrapper.in("role_code", roleList); + List<SysRole> sysRoleList = sysRoleService.list(queryWrapper); + List<SysUser> sysUsers = new ArrayList<>(); + for (SysRole sysRole : sysRoleList) { + sysUsers.addAll(sysUserService.getAllUsersByRoleId(sysRole.getId())); + } + double quantity = 0.0; + List<SparesPartInventory> sparesPartInventoryList = sparesPartInventoryService.lambdaQuery().eq(SparesPartInventory::getSparePartId,sparesPartInventory.getSparePartId()).eq(SparesPartInventory::getDelFlag, CommonConstant.DEL_FLAG_0).list(); + for(SparesPartInventory sparesPartInventory1 : sparesPartInventoryList){ + quantity = quantity + sparesPartInventory1.getMainQuantity(); + } + if(quantity < sparePart.getInventoryLowerLimit()){ + String messageTitle; + String messageContent; + String sysTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + messageTitle = "绯荤粺娑堟伅锛氬浠剁紪鐮佷负 " + sparePart.getNum() + " 鐨勫浠跺簱瀛橀噺涓嶈冻锛岃鍙婃椂澶勭悊!"; + messageContent = "绯荤粺娑堟伅锛氬浠剁紪鐮侊細" + sparePart.getNum() + " 鐨勫浠跺簱瀛橀噺宸蹭綆浜庡畨鍏ㄥ簱瀛�!" + "\n" + "娑堟伅鏃堕棿:" + sysTime + "\n"; + for (SysUser sysUser : sysUsers) { + sysBaseAPI.sendAnnouncement("admin", sysUser.getUsername(), messageTitle, messageContent, "澶囦欢搴撳瓨閲忎笉瓒�"); + } + }else if(quantity > sparePart.getInventoryUpperLimit()){ + String messageTitle; + String messageContent; + String sysTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + messageTitle = "绯荤粺娑堟伅锛氬浠剁紪鐮佷负 " + sparePart.getNum() + " 鐨勫浠跺嚭鐜扮Н鍘嬫儏鍐碉紝璇峰強鏃跺鐞�!"; + messageContent = "绯荤粺娑堟伅锛氬浠剁紪鐮佷负 " + sparePart.getNum() + " 鐨勫浠跺簱瀛橀噺宸查珮浜庡簱瀛樹笂闄愬�硷紝鍑虹幇绉帇鎯呭喌!" + "\n" + "娑堟伅鏃堕棿:" + sysTime + "\n"; + for (SysUser sysUser : sysUsers) { + sysBaseAPI.sendAnnouncement("admin", sysUser.getUsername(), messageTitle, messageContent, "澶囦欢绉帇"); + } + } return true; } - } -- Gitblit v1.9.3