diff --git a/ant-design-vue-jeecg/src/views/system/inventory/InventoryAgeAlarmList.vue b/ant-design-vue-jeecg/src/views/system/inventory/InventoryAgeAlarmList.vue index 6bcf160..22131c2 100644 --- a/ant-design-vue-jeecg/src/views/system/inventory/InventoryAgeAlarmList.vue +++ b/ant-design-vue-jeecg/src/views/system/inventory/InventoryAgeAlarmList.vue @@ -68,7 +68,7 @@ </span> <span slot="days" slot-scope="text, record"> - <a-tag :key="record" :color="daysColor(record)"> + <a-tag :key="record" :color="daysColor(record)" style="font-size: 14px;font-weight: normal"> {{ record.days}} </a-tag> </span> @@ -129,16 +129,16 @@ export default { ], // 表头 columns: [ - { - title: '#', - dataIndex: '', - key: 'rowIndex', - width: 60, - align: "center", - customRender: function (t, r, index) { - return parseInt(index) + 1; - } - }, + // { + // title: '#', + // dataIndex: '', + // key: 'rowIndex', + // width: 60, + // align: "center", + // customRender: function (t, r, index) { + // return parseInt(index) + 1; + // } + // }, { title: '库位编码', align: "center", @@ -186,12 +186,12 @@ export default { scopedSlots: {customRender: 'days'} }, { - title: '预警期', + title: '预警期(天)', align: "center", dataIndex: 'expiringdays', scopedSlots: {customRender: 'expiringdays'} }, { - title: '保质期', + title: '保质期(天)', align: "center", dataIndex: 'daystoexpire', scopedSlots: {customRender: 'daystoexpire'} diff --git a/ant-design-vue-jeecg/src/views/system/inventory/InventoryLevelAlarmList.vue b/ant-design-vue-jeecg/src/views/system/inventory/InventoryLevelAlarmList.vue index 043726e..339aeaa 100644 --- a/ant-design-vue-jeecg/src/views/system/inventory/InventoryLevelAlarmList.vue +++ b/ant-design-vue-jeecg/src/views/system/inventory/InventoryLevelAlarmList.vue @@ -142,16 +142,16 @@ export default { {'name':'下限预警', 'code':'lowerAlarm'}], // 表头 columns: [ - { - title: '#', - dataIndex: '', - key: 'rowIndex', - width: 60, - align: "center", - customRender: function (t, r, index) { - return parseInt(index) + 1; - } - }, + // { + // title: '#', + // dataIndex: '', + // key: 'rowIndex', + // width: 60, + // align: "center", + // customRender: function (t, r, index) { + // return parseInt(index) + 1; + // } + // }, { title: '物料编码', align: "center", diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryAge/entity/InventoryAgeAlarm.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryAge/entity/InventoryAgeAlarm.java index a017425..ccffde5 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryAge/entity/InventoryAgeAlarm.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryAge/entity/InventoryAgeAlarm.java @@ -15,19 +15,24 @@ public class InventoryAgeAlarm extends InventoryDetail { } + /**库龄到达预警期,但未过保质期**/ + public boolean inExpiring(){ + return days >= expiringdays && days <daystoexpire; + } + + /**库龄超过保质期**/ + public boolean inExpired(){ + return days >= daystoexpire; + } @Override public String toString() { String str = "<ul>"; -// if (inLower()) { -// str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 低于下限预警值<b> " + getLower() + "</b></li>"; -// } else if (inUpper()) { -// str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 高于上限预警值<b> " + getUpper() + "</b></li>"; -// } else if (inMin()) { -// str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 低于最低值<b> " + getMin() + "</b></li>"; -// } else if (inMax()) { -// str = str + "<li><b>" + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b> 超过最高值<b> " + getMax() + "</b></li>"; -// } + if (inExpiring()) { + str = str + "<li><b>" + getLocationCode() + " - " + getContainerCode() + ": " + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQty() + "</b> 即将过期<b> </b></li>"; + } else if (inExpired()) { + str = str + "<li><b>" + getLocationCode() + " - " + getContainerCode() + ": " + getMaterialName() + "</b> " + getMaterialCode() + " 库存数 <b>" + getQty() + "</b> 已经过期<b> </b></li>"; + } return str + "</ul>"; } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryAgeAlarmTask.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryAgeAlarmTask.java new file mode 100644 index 0000000..8f77a07 --- /dev/null +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryAgeAlarmTask.java @@ -0,0 +1,83 @@ +package org.jeecg.modules.wms.monitor.job; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.text.StrSpliter; +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.session.SqlSession; +import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.message.websocket.WebSocket; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.impl.SysAnnouncementServiceImpl; +import org.jeecg.modules.system.service.impl.SysRoleServiceImpl; +import org.jeecg.modules.system.service.impl.SysUserServiceImpl; +import org.jeecg.modules.wms.inventory.inventoryAge.entity.InventoryAgeAlarm; +import org.jeecg.modules.wms.inventory.inventoryAge.service.impl.InventoryAgeAlarmServiceImpl; +import org.quartz.*; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 库龄预警通知 + * @author 游杰 + */ + +@Slf4j +@PersistJobDataAfterExecution +@DisallowConcurrentExecution +public class InventoryAgeAlarmTask implements Job { + private String parameter; + + @Resource + private WebSocket webSocket; + + @Resource + private SysUserServiceImpl sysUserService; + + @Resource + private SysRoleServiceImpl sysRoleService; + + @Resource + private SqlSession sqlSession; + + @Resource + private SysAnnouncementServiceImpl sysAnnouncementService; + + @Resource + private InventoryAgeAlarmServiceImpl inventoryAgeAlarmService; + + public void setParameter(String parameter) { + this.parameter = parameter; + } + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + log.info(StrUtil.format("定时任务 InventoryAgeAlarmTask 参数:{},执行时间:{}", this.parameter, DateUtils.getTimestamp())); + + List<InventoryAgeAlarm> alarmList = inventoryAgeAlarmService.getAgeAlarm(null); + if (CollectionUtils.isEmpty(alarmList)) { + return; + } + + List<String> list = alarmList.stream().map(InventoryAgeAlarm::toString).collect(Collectors.toList()); + String msg = String.join("\n", list); + msg = msg + "<a href='/wms/index.html#/system/inventory/inventoryAge'>点击查看详情</a>"; +// " <a href='/wms/index.html#/system/config/MaterialWarningList'>预警配置</a>"; + + List<SysUser> userList; + try { + List<String> userOrRoleArr = StrSpliter.split(this.parameter, ",", true, true); + userList = sysUserService.getUserByRoleNameArray(userOrRoleArr); + if (userList.size() == 0) { + userList = null; + } + sysAnnouncementService.quickAnnouncementToUser(userList, "库龄预警", msg, DateUtil.offsetDay(new Date(), 1), "H"); + } catch (Exception e) { + log.error("获取预警通知用户出错", e); + } + } +}