From c6c9b7d3baa822765768c110304d27623f946286 Mon Sep 17 00:00:00 2001
From: pjb <123456>
Date: 星期二, 15 七月 2025 14:29:09 +0800
Subject: [PATCH] `1`
---
zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java | 139 +++++++++++++++++++++++++++-------------------
1 files changed, 82 insertions(+), 57 deletions(-)
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
index 57d59bb..daf22cf 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
@@ -9,23 +9,22 @@
import com.zy.asrs.wms.asrs.entity.enums.LocStsType;
import com.zy.asrs.wms.asrs.entity.enums.TaskStsType;
import com.zy.asrs.wms.asrs.service.*;
-import io.jsonwebtoken.lang.Collections;
import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.Collection;
import java.util.Date;
import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
@Slf4j
@Component
public class TaskTimer {
+ public static Logger logger = LoggerFactory.getLogger(TaskTimer.class);
@Autowired
private TaskService taskService;
@@ -67,6 +66,9 @@
private CacheSiteService cacheSiteService;
+ /**
+ * 鍏ュ簱鎵ц浠诲姟
+ */
@Scheduled(cron = "0/3 * * * * ? ")
@Transactional(rollbackFor = Exception.class)
public void inExecute() {
@@ -88,6 +90,7 @@
executeTask11(task);
break;
case 53://鎷f枡鍐嶅叆搴�
+ case 57:
executeTask53(task);
break;
default:
@@ -108,6 +111,29 @@
}
}
+
+ /**
+ * // fixme 鑸嶅純
+ * 1. 瀹氭椂鎷夊彇闇�瑕佹墽琛屽洖搴撲换鍔″垪琛ㄦ暟鎹紝
+ * 2. 鍒犻櫎鍘熷搴撲綅鏄庣粏锛屽師濮嬪簱浣嶇姸鎬佺疆鎴怬.绌哄簱
+ * 3.
+ */
+// @Scheduled(cron = "0/3 * * * * ? ")
+ @Transactional(rollbackFor = Exception.class)
+ public void rollbackStock() {
+ //鑾峰彇闇�瑕佹墽琛屽洖搴撶殑浠诲姟锛屾洿鏂板簱瀛樹俊鎭�
+ List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskType, 53).eq(Task::getTaskSts, TaskStsType.WCS_CONVEYOR_START.id));
+ if (tasks.isEmpty()) {
+ return;
+ }
+ tasks.forEach(task -> {
+ //鍒犻櫎鍘熷搴撲綅鏄庣粏锛岀姸鎬佺疆涓篛.绌哄簱
+ executeTask103(task);
+ });
+ //todo 闇�娣诲姞涓�涓换鍔$姸鎬佹垨涓存椂鐘舵�侊紝鍚﹀垯浼氫竴鐩磋疆寰紝绋嬪簭鎶ラ敊锛堝簱浣嶇姸鎬佷笉澶勪簬R.鍑哄簱棰勭害锛�
+ }
+
+
@Scheduled(cron = "0/10 * * * * ? ")
@Transactional(rollbackFor = Exception.class)
public void outExecute() {
@@ -125,6 +151,7 @@
executeTask101(task);
break;
case 103://鎷f枡
+ case 107:
executeTask103(task);
break;
default:
@@ -133,19 +160,6 @@
task.setTaskSts(TaskStsType.UPDATED_OUT.id);//200.搴撳瓨鏇存柊瀹屾垚
if (!taskService.updateById(task)) {
throw new CoolException("搴撳瓨鏇存柊澶辫触");
- } else {
- //CacheSite 閲婃斁宸茶鍗犵敤鐨勯�氶亾 //fixme 鎾鍔熻兘瀹屾垚鍚庯紝闇�瑕佸皢杩欓噷娉ㄩ噴鎺�
- List<TaskDetl> detls = taskDetlService.list(new LambdaQueryWrapper<TaskDetl>().eq(TaskDetl::getTaskId, task.getId()));
- if (!Collections.isEmpty(detls)) {
- List<Long> waveIds = detls.stream().map(TaskDetl::getWaveId).collect(Collectors.toList());
- List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getWaveId, waveIds));
- List<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList());
- cacheSiteService.update(new LambdaUpdateWrapper<CacheSite>()
- .in(CacheSite::getOrderId, orderIds)
- .set(CacheSite::getSiteStatus, 0)
- .set(CacheSite::getOrderId, null)
- .set(CacheSite::getOrderNo, null));
- }
}
}
} catch (Exception e) {
@@ -159,9 +173,7 @@
//鍏ュ簱
private void executeTask1(Task task) {
Long hostId = task.getHostId();
- //fixme 鏆傛椂鍏抽棴HOSTID
Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
-// Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()));
if (loc == null) {
throw new CoolException("搴撲綅涓嶅瓨鍦�");
}
@@ -196,10 +208,9 @@
if (!locDetlService.save(locDetl)) {
throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
}
- //fixme 鏆傛椂鍏抽棴HOSTID,鍚庣画鎵撳紑鏈烘瀯ID
+
//娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
-// List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
- List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()));
+ List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
for (TaskDetlField detlField : detlFields) {
LocDetlField locDetlField = new LocDetlField();
locDetlField.setDetlId(locDetl.getId());
@@ -212,10 +223,8 @@
}
}
}
- //fixme 鏆傛椂鍏抽棴HOSTID,鍚庣画鎵撳紑鏈烘瀯ID
//缁勬墭閫氱煡妗h浆鍘嗗彶妗�
-// List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
- List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()));
+ List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
if (waitPakins.isEmpty()) {
throw new CoolException("缁勬墭閫氱煡妗d笉瀛樺湪");
}
@@ -314,12 +323,15 @@
}
+ /**
+ * 鎷f枡鍐嶅叆搴擄紝鏍规嵁浠诲姟鐩爣搴撲綅锛岀敓鎴愭柊搴撳瓨淇℃伅
+ * @param task
+ */
//鎷f枡鍐嶅叆搴�
- private void executeTask53(Task task) {
+ @Transactional(rollbackFor = Exception.class)
+ public void executeTask53(Task task) {
Long hostId = task.getHostId();
- //fixme
-// Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
- Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()));
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
if (loc == null) {
throw new CoolException("搴撲綅涓嶅瓨鍦�");
}
@@ -331,6 +343,7 @@
loc.setLocStsId(LocStsType.F.val());
loc.setUpdateTime(new Date());
loc.setBarcode(task.getBarcode());
+
if (!locService.updateById(loc)) {
throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
}
@@ -340,44 +353,45 @@
throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
}
- //娣诲姞搴撳瓨鏄庣粏
+ //淇敼搴撳瓨鏄庣粏
for (TaskDetl taskDetl : taskDetls) {
double anfme = taskDetl.getStock() - taskDetl.getAnfme();
if (anfme <= 0) {
- continue;
- }
+ LocDetl locdetl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>()
+ .eq(LocDetl::getLocId, loc.getId())
+ .eq(LocDetl::getBatch, taskDetl.getBatch())
+ .eq(LocDetl::getMatId, taskDetl.getMatId()));
- LocDetl locDetl = new LocDetl();
- locDetl.setLocId(loc.getId());
- locDetl.setLocNo(loc.getLocNo());
- locDetl.setMatId(taskDetl.getMatId());
- locDetl.setMatnr(taskDetl.getMat$().getMatnr());
- locDetl.setOrderNo(taskDetl.getOrderNo());
- locDetl.setBatch(taskDetl.getBatch());
- locDetl.setAnfme(anfme);
- locDetl.setHostId(hostId);
- if (!locDetlService.save(locDetl)) {
- throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
- }
+ List<LocDetlField> detlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locdetl.getId()).eq(LocDetlField::getHostId, hostId));
+ if (!detlFields.isEmpty()) {
+ if (!locDetlFieldService.removeBatchByIds(detlFields)) {
+ throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍瀛楁澶辫触");
+ }
+ }
- //娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
- //fixme 娉ㄩ噴
-// List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId));
- List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()));
- for (TaskDetlField detlField : detlFields) {
- LocDetlField locDetlField = new LocDetlField();
- locDetlField.setDetlId(locDetl.getId());
- locDetlField.setFieldId(detlField.getFieldId());
- locDetlField.setName(detlField.getName());
- locDetlField.setValue(detlField.getValue());
- locDetlField.setHostId(hostId);
- if (!locDetlFieldService.save(locDetlField)) {
- throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
+ if (!locDetlService.removeById(locdetl)) {
+ throw new CoolException("搴撳瓨鏄庣粏鍒犻櫎澶辫触!!");
+ }
+ } else {
+ LocDetl locdetl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>()
+ .eq(LocDetl::getLocId, loc.getId())
+ .eq(LocDetl::getBatch, taskDetl.getBatch())
+ .eq(LocDetl::getMatId, taskDetl.getMatId()));
+ locdetl.setWorkQty(0.0);
+ locdetl.setAnfme(anfme);
+
+ if (!locDetlService.updateById(locdetl)) {
+ throw new CoolException("搴撳瓨鏄庣粏鏇存柊澶辫触锛侊紒");
}
}
}
}
+
+ /**
+ * 鏇存柊浠诲姟鏄庣粏锛屾洿鏂板簱瀛樻槑缁�
+ * @param task
+ */
//鍑哄簱
private void executeTask101(Task task) {
Long hostId = task.getHostId();
@@ -387,6 +401,7 @@
throw new CoolException("搴撲綅涓嶅瓨鍦�");
}
if (loc.getLocStsId() != LocStsType.R.val()) {
+ logger.error("搴撲綅锛�" + loc.getLocNo() + "锛岀姸鎬佷笉澶勪簬R.鍑哄簱棰勭害");
throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
}
List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
@@ -412,8 +427,18 @@
}
}
}
+
+
+
+
+
}
+ /**
+ * 灏嗗師鏈夊簱瀛樻槑缁嗗垹闄�
+ * 搴撳瓨鐘舵�佽缃负绌哄簱鐘舵��
+ * @param task
+ */
//鎷f枡鍑哄簱
private void executeTask103(Task task) {
Long hostId = task.getHostId();
--
Gitblit v1.9.1