diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java index 9cb524f..e8c5d55 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java @@ -32,7 +32,6 @@ import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; -import java.util.concurrent.*; /** * @author hx @@ -86,7 +85,7 @@ public class LimitRemindAspect { basicList = (List) basicListField.get(args[0]); warehouseId = (Long) warehouseIdField.get(args[0]); if (CollectionUtil.isNotEmpty(basicList) && ObjectUtil.isNotEmpty(warehouseId)) { - this.pushWarehouseWarningV2(warehouseId, basicList); + this.pushWarehouseThread(warehouseId, basicList); } } catch (IllegalAccessException e) { e.printStackTrace(); @@ -101,11 +100,37 @@ public class LimitRemindAspect { * @param spRecordEntityList 出入库备品备件列表 * @param warehouseId 仓库ID */ - final static ExecutorService executorService = new ThreadPoolExecutor(5, 5, 1, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); +// final static ExecutorService executorService = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + public void pushWarehouseThread(Long warehouseId, List spRecordEntityList) { + try { + Runnable runnable = new Runnable() { + @Override + public void run() { + //异步任务 + pushWarehouseWarningV2(warehouseId, spRecordEntityList); + } + }; + Thread thread = new Thread(runnable); + thread.start(); +// Callable c1 = new Callable() { +// +// @Override +// public Object call() throws Exception { +// //异步任务 +// pushWarehouseWarningV2(warehouseId, spRecordEntityList); +// return "success"; +// } +// }; +// Future f = new FutureTask(c1); +// System.out.println(f.get()); + } catch (Exception e) { + log.error(e.getMessage(), e.toString()); + } + } +// ExecutorService executorService = new ThreadPoolExecutor(1,1,1, TimeUnit.SECONDS,new LinkedBlockingDeque<>()); private void pushWarehouseWarningV2(Long warehouseId, List spRecordEntityList) { - //开启线程池推送消息 - executorService.execute(() -> spRecordEntityList.forEach(spRecordEntity -> { + spRecordEntityList.forEach(spRecordEntity -> { //查询该仓库是否有备品备件超出上下限 WtSpWarehouseEntity wtSpWarehouseEntity = wtSpWarehouseService.selectById(warehouseId); WtSpTotalEntity wtSpTotalEntity = wtSpTotalService.getOne(Wrappers.lambdaQuery() @@ -139,13 +164,9 @@ public class LimitRemindAspect { ); } //推送消息 - CompletableFuture.supplyAsync(() -> { - this.warningPush(alert, pusher,warehouseId); - return "推送成功"; - }); + this.warningPush(alert, pusher,warehouseId); } - })); - executorService.shutdown(); + }); } private void warningPush(String alert, User pusher,Long warehouseId) { @@ -177,56 +198,56 @@ public class LimitRemindAspect { } //此接口已经弃用20230608 - @Deprecated - private void pushWarehouseWarning(Long warehouseId, List spRecordEntityList) { - //开启线程池推送消息 - executorService.execute(() -> spRecordEntityList.forEach(spRecordEntity -> { - //查询该仓库是否有备品备件超出上下限 - WtSpWarehouseEntity wtSpWarehouseEntity = wtSpWarehouseService.selectById(warehouseId); - WtSpTotalEntity wtSpTotalEntity = wtSpTotalService.getOne(Wrappers.lambdaQuery() - .eq(WtSpTotalEntity::getSpBasicId, spRecordEntity.getSpBasicId()) - .eq(WtSpTotalEntity::getWarehouseId, warehouseId) - .last("limit 1;") - ); - WtSpBasicEntity basicEntity = wtSpBasicService.getById(spRecordEntity.getSpBasicId()); - //超出上限/下限发送消息提醒 - log.info("仓库id为:{},库存为:{},上限为:{},下限为:{}", warehouseId, wtSpTotalEntity.getStock(), basicEntity.getUpperLimit(), basicEntity.getLowerLimit()); - if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit() || wtSpTotalEntity.getStock() < basicEntity.getLowerLimit()) { - User pusher = UserCache.getUser(wtSpWarehouseEntity.getManager()); - if (ObjectUtil.isEmpty(pusher)) { - return; - } - //完善推送信息 - String alert; - if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit()) { - alert = String.format("%s内的(%s)已达到上限,目前仓库内的库存为:%s,上限值为:%s。请及时处理!", - wtSpWarehouseEntity.getName(), - basicEntity.getName(), - wtSpTotalEntity.getStock(), - basicEntity.getUpperLimit() - ); - } else { - alert = String.format("%s内的(%s)已达到下限,目前仓库内的库存为:%s,下限值为:%s。请及时处理!", - wtSpWarehouseEntity.getName(), - basicEntity.getName(), - wtSpTotalEntity.getStock(), - basicEntity.getLowerLimit() - ); - } - //推送web消息 - CompletableFuture.supplyAsync(() -> { - this.warningPushWeb(alert, pusher); - return "推送成功"; - }); - //推送App消息 - CompletableFuture.supplyAsync(() -> { - this.warningPushApp(alert, pusher); - return "推送成功"; - }); - } - })); - executorService.shutdown(); - } +// @Deprecated +// private void pushWarehouseWarning(Long warehouseId, List spRecordEntityList) { +// //开启线程池推送消息 +// executorService.execute(() -> spRecordEntityList.forEach(spRecordEntity -> { +// //查询该仓库是否有备品备件超出上下限 +// WtSpWarehouseEntity wtSpWarehouseEntity = wtSpWarehouseService.selectById(warehouseId); +// WtSpTotalEntity wtSpTotalEntity = wtSpTotalService.getOne(Wrappers.lambdaQuery() +// .eq(WtSpTotalEntity::getSpBasicId, spRecordEntity.getSpBasicId()) +// .eq(WtSpTotalEntity::getWarehouseId, warehouseId) +// .last("limit 1;") +// ); +// WtSpBasicEntity basicEntity = wtSpBasicService.getById(spRecordEntity.getSpBasicId()); +// //超出上限/下限发送消息提醒 +// log.info("仓库id为:{},库存为:{},上限为:{},下限为:{}", warehouseId, wtSpTotalEntity.getStock(), basicEntity.getUpperLimit(), basicEntity.getLowerLimit()); +// if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit() || wtSpTotalEntity.getStock() < basicEntity.getLowerLimit()) { +// User pusher = UserCache.getUser(wtSpWarehouseEntity.getManager()); +// if (ObjectUtil.isEmpty(pusher)) { +// return; +// } +// //完善推送信息 +// String alert; +// if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit()) { +// alert = String.format("%s内的(%s)已达到上限,目前仓库内的库存为:%s,上限值为:%s。请及时处理!", +// wtSpWarehouseEntity.getName(), +// basicEntity.getName(), +// wtSpTotalEntity.getStock(), +// basicEntity.getUpperLimit() +// ); +// } else { +// alert = String.format("%s内的(%s)已达到下限,目前仓库内的库存为:%s,下限值为:%s。请及时处理!", +// wtSpWarehouseEntity.getName(), +// basicEntity.getName(), +// wtSpTotalEntity.getStock(), +// basicEntity.getLowerLimit() +// ); +// } +// //推送web消息 +// CompletableFuture.supplyAsync(() -> { +// this.warningPushWeb(alert, pusher); +// return "推送成功"; +// }); +// //推送App消息 +// CompletableFuture.supplyAsync(() -> { +// this.warningPushApp(alert, pusher); +// return "推送成功"; +// }); +// } +// })); +// executorService.shutdown(); +// } /** * 备品备件-预警app推送 diff --git a/hzims-service/hzims-middle/src/main/resources/db/1.0.1.sql b/hzims-service/hzims-middle/src/main/resources/db/1.0.1.sql index 2e351c5..31cd566 100644 --- a/hzims-service/hzims-middle/src/main/resources/db/1.0.1.sql +++ b/hzims-service/hzims-middle/src/main/resources/db/1.0.1.sql @@ -42,3 +42,13 @@ values ('集中监控', 1), ('移动端配置', 32), ('水电站设置', 33), ('告警配置', 34); + + +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (1, 0, 'networking', 'workTicketFlow', '工作票', '两票管理', 'Y', 0, null, '2023-06-05 09:43:47.0', '2023-06-12 10:04:30.0', '第一种工作票 第二种工作票'); +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (2, 0, 'moreActionBankDirect', 'standardTicketFlow', '操作票', '两票管理', 'Y', 0, null, '2023-06-06 14:15:39.0', '2023-06-06 14:15:52.0', '操作票'); +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (3, 0, 'machinery', 'workTicketFlowmachinery', '机械工作票', '两票管理', 'Y', 0, null, '2023-06-12 10:04:56.0', '2023-06-12 10:07:52.0', '水力机械工作票'); +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (4, 0, 'maintenance', 'maintenance_test', '日常维护流程', '日常维护', 'Y', 0, null, '2023-06-14 15:06:39.0', '2023-06-14 15:06:41.0', '日常维护'); +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (5, 0, 'defectCheck', 'defectCheck', '消缺流程', '', 'Y', 0, null, '2023-06-16 17:01:01.0', '2023-06-26 11:36:54.0', '消缺流程'); +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (6, 6, 'overhaul_plan', 'overhaul_plan', '检修计划v4', '检修计划', 'Y', 0, null, '2023-06-16 17:01:01.0', '2023-06-16 17:04:01.0', '检修计划流程'); +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (7, 7, 'overhaul_task', 'overhaul_task', '检修任务v4', '检修任务', 'Y', 0, null, '2023-06-16 17:01:01.0', '2023-06-16 17:04:01.0', '检修任务流程'); +INSERT INTO dev_hzims_middle.process_dict (dict_code, dict_sort, dict_key, dict_value, dict_label, dict_type, is_default, status, create_dept, create_time, update_time, remark) VALUES (8, 8, 'duty_rec', 'duty_rec', '交接班v4', '交接班', 'Y', 0, null, '2023-07-25 18:35:01.0', '2023-07-25 18:35:01.0', '交接班流程');