Commit 2aa0a7a966f80b2f0a9fa7e809e2ceb041d18bef

Authored by 周峰
1 parent bae87f17

添加库年预警定时任务

ant-design-vue-jeecg/src/views/system/inventory/InventoryAgeAlarmList.vue
... ... @@ -68,7 +68,7 @@
68 68 </span>
69 69  
70 70 <span slot="days" slot-scope="text, record">
71   - <a-tag :key="record" :color="daysColor(record)">
  71 + <a-tag :key="record" :color="daysColor(record)" style="font-size: 14px;font-weight: normal">
72 72 {{ record.days}}
73 73 </a-tag>
74 74 </span>
... ... @@ -129,16 +129,16 @@ export default {
129 129 ],
130 130 // 表头
131 131 columns: [
132   - {
133   - title: '#',
134   - dataIndex: '',
135   - key: 'rowIndex',
136   - width: 60,
137   - align: "center",
138   - customRender: function (t, r, index) {
139   - return parseInt(index) + 1;
140   - }
141   - },
  132 + // {
  133 + // title: '#',
  134 + // dataIndex: '',
  135 + // key: 'rowIndex',
  136 + // width: 60,
  137 + // align: "center",
  138 + // customRender: function (t, r, index) {
  139 + // return parseInt(index) + 1;
  140 + // }
  141 + // },
142 142 {
143 143 title: '库位编码',
144 144 align: "center",
... ... @@ -186,12 +186,12 @@ export default {
186 186 scopedSlots: {customRender: 'days'}
187 187 },
188 188 {
189   - title: '预警期',
  189 + title: '预警期(天)',
190 190 align: "center",
191 191 dataIndex: 'expiringdays',
192 192 scopedSlots: {customRender: 'expiringdays'}
193 193 }, {
194   - title: '保质期',
  194 + title: '保质期(天)',
195 195 align: "center",
196 196 dataIndex: 'daystoexpire',
197 197 scopedSlots: {customRender: 'daystoexpire'}
... ...
ant-design-vue-jeecg/src/views/system/inventory/InventoryLevelAlarmList.vue
... ... @@ -142,16 +142,16 @@ export default {
142 142 {'name':'下限预警', 'code':'lowerAlarm'}],
143 143 // 表头
144 144 columns: [
145   - {
146   - title: '#',
147   - dataIndex: '',
148   - key: 'rowIndex',
149   - width: 60,
150   - align: "center",
151   - customRender: function (t, r, index) {
152   - return parseInt(index) + 1;
153   - }
154   - },
  145 + // {
  146 + // title: '#',
  147 + // dataIndex: '',
  148 + // key: 'rowIndex',
  149 + // width: 60,
  150 + // align: "center",
  151 + // customRender: function (t, r, index) {
  152 + // return parseInt(index) + 1;
  153 + // }
  154 + // },
155 155 {
156 156 title: '物料编码',
157 157 align: "center",
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryAge/entity/InventoryAgeAlarm.java
... ... @@ -15,19 +15,24 @@ public class InventoryAgeAlarm extends InventoryDetail {
15 15  
16 16 }
17 17  
  18 + /**库龄到达预警期,但未过保质期**/
  19 + public boolean inExpiring(){
  20 + return days >= expiringdays && days <daystoexpire;
  21 + }
  22 +
  23 + /**库龄超过保质期**/
  24 + public boolean inExpired(){
  25 + return days >= daystoexpire;
  26 + }
18 27  
19 28 @Override
20 29 public String toString() {
21 30 String str = "<ul>";
22   -// if (inLower()) {
23   -// str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;低于下限预警值<b> " + getLower() + "</b></li>";
24   -// } else if (inUpper()) {
25   -// str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;高于上限预警值<b> " + getUpper() + "</b></li>";
26   -// } else if (inMin()) {
27   -// str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;低于最低值<b> " + getMin() + "</b></li>";
28   -// } else if (inMax()) {
29   -// str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;超过最高值<b> " + getMax() + "</b></li>";
30   -// }
  31 + if (inExpiring()) {
  32 + str = str + "<li><b>" + getLocationCode() + " - " + getContainerCode() + ": " + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQty() + "</b>&nbsp;&nbsp;即将过期<b> </b></li>";
  33 + } else if (inExpired()) {
  34 + str = str + "<li><b>" + getLocationCode() + " - " + getContainerCode() + ": " + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQty() + "</b>&nbsp;&nbsp;已经过期<b> </b></li>";
  35 + }
31 36 return str + "</ul>";
32 37 }
33 38 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryAgeAlarmTask.java 0 → 100644
  1 +package org.jeecg.modules.wms.monitor.job;
  2 +
  3 +import cn.hutool.core.date.DateUtil;
  4 +import cn.hutool.core.text.StrSpliter;
  5 +import cn.hutool.core.util.StrUtil;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.apache.ibatis.session.SqlSession;
  8 +import org.jeecg.common.util.DateUtils;
  9 +import org.jeecg.modules.message.websocket.WebSocket;
  10 +import org.jeecg.modules.system.entity.SysUser;
  11 +import org.jeecg.modules.system.service.impl.SysAnnouncementServiceImpl;
  12 +import org.jeecg.modules.system.service.impl.SysRoleServiceImpl;
  13 +import org.jeecg.modules.system.service.impl.SysUserServiceImpl;
  14 +import org.jeecg.modules.wms.inventory.inventoryAge.entity.InventoryAgeAlarm;
  15 +import org.jeecg.modules.wms.inventory.inventoryAge.service.impl.InventoryAgeAlarmServiceImpl;
  16 +import org.quartz.*;
  17 +import org.springframework.util.CollectionUtils;
  18 +
  19 +import javax.annotation.Resource;
  20 +import java.util.Date;
  21 +import java.util.List;
  22 +import java.util.stream.Collectors;
  23 +
  24 +/**
  25 + * 库龄预警通知
  26 + * @author 游杰
  27 + */
  28 +
  29 +@Slf4j
  30 +@PersistJobDataAfterExecution
  31 +@DisallowConcurrentExecution
  32 +public class InventoryAgeAlarmTask implements Job {
  33 + private String parameter;
  34 +
  35 + @Resource
  36 + private WebSocket webSocket;
  37 +
  38 + @Resource
  39 + private SysUserServiceImpl sysUserService;
  40 +
  41 + @Resource
  42 + private SysRoleServiceImpl sysRoleService;
  43 +
  44 + @Resource
  45 + private SqlSession sqlSession;
  46 +
  47 + @Resource
  48 + private SysAnnouncementServiceImpl sysAnnouncementService;
  49 +
  50 + @Resource
  51 + private InventoryAgeAlarmServiceImpl inventoryAgeAlarmService;
  52 +
  53 + public void setParameter(String parameter) {
  54 + this.parameter = parameter;
  55 + }
  56 +
  57 + @Override
  58 + public void execute(JobExecutionContext context) throws JobExecutionException {
  59 + log.info(StrUtil.format("定时任务 InventoryAgeAlarmTask 参数:{},执行时间:{}", this.parameter, DateUtils.getTimestamp()));
  60 +
  61 + List<InventoryAgeAlarm> alarmList = inventoryAgeAlarmService.getAgeAlarm(null);
  62 + if (CollectionUtils.isEmpty(alarmList)) {
  63 + return;
  64 + }
  65 +
  66 + List<String> list = alarmList.stream().map(InventoryAgeAlarm::toString).collect(Collectors.toList());
  67 + String msg = String.join("\n", list);
  68 + msg = msg + "<a href='/wms/index.html#/system/inventory/inventoryAge'>点击查看详情</a>";
  69 +// "&nbsp;&nbsp;&nbsp;&nbsp;<a href='/wms/index.html#/system/config/MaterialWarningList'>预警配置</a>";
  70 +
  71 + List<SysUser> userList;
  72 + try {
  73 + List<String> userOrRoleArr = StrSpliter.split(this.parameter, ",", true, true);
  74 + userList = sysUserService.getUserByRoleNameArray(userOrRoleArr);
  75 + if (userList.size() == 0) {
  76 + userList = null;
  77 + }
  78 + sysAnnouncementService.quickAnnouncementToUser(userList, "库龄预警", msg, DateUtil.offsetDay(new Date(), 1), "H");
  79 + } catch (Exception e) {
  80 + log.error("获取预警通知用户出错", e);
  81 + }
  82 + }
  83 +}
... ...