From 3743cba51af30aef646e620531509d7ba350b08e Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期二, 10 九月 2024 09:13:33 +0800
Subject: [PATCH] #
---
zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java | 126 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 119 insertions(+), 7 deletions(-)
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java
index 86a640f..cde400b 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java
@@ -11,6 +11,7 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.Date;
import java.util.List;
@@ -52,6 +53,7 @@
//淇濆瓨浠诲姟鍘嗗彶妗�
TaskLog taskLog = new TaskLog();
taskLog.sync(task);
+ taskLog.setId(null);
if (!taskLogService.save(taskLog)) {
throw new CoolException("淇濆瓨浠诲姟鍘嗗彶妗eけ璐�");
}
@@ -63,12 +65,14 @@
//淇濆瓨浠诲姟鏄庣粏鍘嗗彶妗�
List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
- if(taskDetls.isEmpty()) {
+ if (taskDetls.isEmpty()) {
throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
}
for (TaskDetl taskDetl : taskDetls) {
TaskDetlLog taskDetlLog = new TaskDetlLog();
taskDetlLog.sync(taskDetl);
+ taskDetlLog.setId(null);
+ taskDetlLog.setTaskId(taskLog.getId());
if (!taskDetlLogService.save(taskDetlLog)) {
throw new CoolException("淇濆瓨浠诲姟鏄庣粏鍘嗗彶妗eけ璐�");
}
@@ -79,26 +83,32 @@
//鏄庣粏鎵╁睍瀛楁鏁版嵁淇濆瓨鑷冲巻鍙叉。
TaskDetlFieldLog taskDetlFieldLog = new TaskDetlFieldLog();
taskDetlFieldLog.sync(detlField);
+ taskDetlFieldLog.setId(null);
+ taskDetlFieldLog.setDetlId(taskDetlLog.getId());
if (!taskDetlFieldLogService.save(taskDetlFieldLog)) {
throw new CoolException("鏄庣粏鎵╁睍瀛楁杞巻鍙叉。妗堝け璐�");
}
//鍒犻櫎鏄庣粏鎵╁睍
boolean removeField = taskDetlFieldService.removeById(detlField.getId());
- if(!removeField){
+ if (!removeField) {
throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍澶辫触");
}
}
//鍒犻櫎鏄庣粏
boolean removeDetl = taskDetlService.removeById(taskDetl.getId());
- if(!removeDetl){
+ if (!removeDetl) {
throw new CoolException("鏄庣粏鍒犻櫎澶辫触");
}
}
//鏇存柊璁㈠崟淇℃伅
for (TaskDetl taskDetl : taskDetls) {
+ if (taskDetl.getDetlId() == null) {
+ continue;
+ }
+
OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
if (orderDetl == null) {
throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
@@ -116,13 +126,13 @@
if (checkOrderComplete) {
//璁㈠崟宸茬粡瀹屾垚
Order order = orderService.getById(orderDetl.getOrderId());
- if(order == null) {
+ if (order == null) {
throw new CoolException("璁㈠崟涓嶅瓨鍦�");
}
order.setOrderSettle(OrderSettleType.COMPLETE.val());
order.setUpdateTime(new Date());
- if (!orderService.save(order)) {
+ if (!orderService.updateById(order)) {
throw new CoolException("璁㈠崟鏇存柊澶辫触");
}
}
@@ -133,7 +143,8 @@
} catch (Exception e) {
e.printStackTrace();
- }finally {
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ } finally {
InterceptorIgnoreHelper.clearIgnoreStrategy();
}
}
@@ -143,10 +154,111 @@
public void outExecute() {
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
try {
+ //鑾峰彇鍏ュ簱瀹屾垚浠诲姟
+ List<Task> list = taskService.list(new LambdaQueryWrapper<Task>()
+ .eq(Task::getTaskSts, 200)
+ .in(Task::getTaskType, 101, 53, 57));
+ if (list.isEmpty()) {
+ return;
+ }
+ for (Task task : list) {
+ Long hostId = task.getHostId();
+
+ //淇濆瓨浠诲姟鍘嗗彶妗�
+ TaskLog taskLog = new TaskLog();
+ taskLog.sync(task);
+ taskLog.setId(null);
+ if (!taskLogService.save(taskLog)) {
+ throw new CoolException("淇濆瓨浠诲姟鍘嗗彶妗eけ璐�");
+ }
+
+ //鍒犻櫎浠诲姟鍘嗗彶妗f
+ if (!taskService.removeById(task.getId())) {
+ throw new CoolException("鍒犻櫎浠诲姟妗eけ璐�");
+ }
+
+ //淇濆瓨浠诲姟鏄庣粏鍘嗗彶妗�
+ List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+ if (taskDetls.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+ }
+ for (TaskDetl taskDetl : taskDetls) {
+ TaskDetlLog taskDetlLog = new TaskDetlLog();
+ taskDetlLog.sync(taskDetl);
+ taskDetlLog.setId(null);
+ taskDetlLog.setTaskId(taskLog.getId());
+ if (!taskDetlLogService.save(taskDetlLog)) {
+ throw new CoolException("淇濆瓨浠诲姟鏄庣粏鍘嗗彶妗eけ璐�");
+ }
+
+ //淇濆瓨鏄庣粏鎵╁睍瀛楁鍘嗗彶妗�
+ List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
+ for (TaskDetlField detlField : detlFields) {
+ //鏄庣粏鎵╁睍瀛楁鏁版嵁淇濆瓨鑷冲巻鍙叉。
+ TaskDetlFieldLog taskDetlFieldLog = new TaskDetlFieldLog();
+ taskDetlFieldLog.sync(detlField);
+ taskDetlFieldLog.setId(null);
+ taskDetlFieldLog.setDetlId(taskDetlLog.getId());
+ if (!taskDetlFieldLogService.save(taskDetlFieldLog)) {
+ throw new CoolException("鏄庣粏鎵╁睍瀛楁杞巻鍙叉。妗堝け璐�");
+ }
+
+ //鍒犻櫎鏄庣粏鎵╁睍
+ boolean removeField = taskDetlFieldService.removeById(detlField.getId());
+ if (!removeField) {
+ throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍澶辫触");
+ }
+ }
+
+ //鍒犻櫎鏄庣粏
+ boolean removeDetl = taskDetlService.removeById(taskDetl.getId());
+ if (!removeDetl) {
+ throw new CoolException("鏄庣粏鍒犻櫎澶辫触");
+ }
+ }
+
+ //鏇存柊璁㈠崟淇℃伅
+ for (TaskDetl taskDetl : taskDetls) {
+ if (taskDetl.getDetlId() == null) {
+ continue;
+ }
+
+ OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
+ if (orderDetl == null) {
+ throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
+ }
+
+ orderDetl.setWorkQty(orderDetl.getWorkQty() - taskDetl.getAnfme());//宸ヤ綔涓暟閲忓噺灏�
+ orderDetl.setQty(orderDetl.getQty() + taskDetl.getAnfme());//宸插畬鎴愭暟閲忓鍔�
+ orderDetl.setUpdateTime(new Date());
+ if (!orderDetlService.updateById(orderDetl)) {
+ throw new CoolException("鏇存柊璁㈠崟鏄庣粏澶辫触");
+ }
+
+ //妫�娴嬭鍗曟槸鍚﹀畬鎴�
+ boolean checkOrderComplete = orderService.checkOrderComplete(orderDetl.getOrderId());
+ if (checkOrderComplete) {
+ //璁㈠崟宸茬粡瀹屾垚
+ Order order = orderService.getById(orderDetl.getOrderId());
+ if (order == null) {
+ throw new CoolException("璁㈠崟涓嶅瓨鍦�");
+ }
+
+ order.setOrderSettle(OrderSettleType.COMPLETE.val());
+ order.setUpdateTime(new Date());
+ if (!orderService.updateById(order)) {
+ throw new CoolException("璁㈠崟鏇存柊澶辫触");
+ }
+ }
+ }
+
+
+ }
} catch (Exception e) {
e.printStackTrace();
- }finally {
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ } finally {
InterceptorIgnoreHelper.clearIgnoreStrategy();
}
}
--
Gitblit v1.9.1