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/TaskTimer.java | 318 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 216 insertions(+), 102 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 4b78bed..3d5c5dc 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
@@ -69,78 +69,15 @@
for (Task task : list) {
//鍚屾鏁版嵁
- Long hostId = task.getHostId();
switch (task.getTaskType().intValue()) {
case 1://鍏ュ簱
- Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
- if (loc == null) {
- throw new CoolException("搴撲綅涓嶅瓨鍦�");
- }
-
- if (loc.getLocStsId() != LocStsType.S.val()) {
- throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
- }
-
- loc.setLocStsId(LocStsType.F.val());
- loc.setUpdateTime(new Date());
- loc.setBarcode(task.getBarcode());
- if (!locService.updateById(loc)) {
- throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
- }
-
-
- List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
- if (taskDetls.isEmpty()) {
- throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
- }
-
- //娣诲姞搴撳瓨鏄庣粏
- for (TaskDetl taskDetl : taskDetls) {
- 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(taskDetl.getAnfme());
- locDetl.setHostId(hostId);
- if (!locDetlService.save(locDetl)) {
- throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
- }
-
- //娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
- 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());
- locDetlField.setFieldId(detlField.getFieldId());
- locDetlField.setName(detlField.getName());
- locDetlField.setValue(detlField.getValue());
- locDetlField.setHostId(hostId);
- if (!locDetlFieldService.save(locDetlField)) {
- throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
- }
- }
- }
-
- //缁勬墭閫氱煡妗h浆鍘嗗彶妗�
- List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
- if (waitPakins.isEmpty()) {
- throw new CoolException("缁勬墭閫氱煡妗d笉瀛樺湪");
- }
- for (WaitPakin waitPakin : waitPakins) {
- WaitPakinLog waitPakinLog = new WaitPakinLog();
- waitPakinLog.sync(waitPakin);
- if (!waitPakinLogService.save(waitPakinLog)) {
- throw new CoolException("缁勬墭閫氱煡妗h浆鍘嗗彶妗eけ璐�");
- }
-
- //鍒犻櫎缁勬墭閫氱煡妗�
- waitPakinService.removeById(waitPakin.getId());
- }
-
+ executeTask1(task);
break;
+ case 53://鎷f枡鍐嶅叆搴�
+ executeTask53(task);
+ break;
+ default:
+ throw new CoolException("鏈煡浠诲姟绫诲瀷");
}
task.setTaskSts(100L);//100.搴撳瓨鏇存柊瀹屾垚
@@ -169,41 +106,15 @@
}
for (Task task : list) {
//鍚屾鏁版嵁
- Long hostId = task.getHostId();
- Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId));
- if (loc == null) {
- throw new CoolException("搴撲綅涓嶅瓨鍦�");
- }
- if (loc.getLocStsId() != LocStsType.R.val()) {
- throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
- }
- List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
- if (taskDetls.isEmpty()) {
- throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
- }
switch (task.getTaskType().intValue()) {
- //鍑哄簱
- case 101:
- loc.setLocStsId(LocStsType.O.val());
- loc.setBarcode("");
- if (!locService.updateById(loc)) {
- throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
- }
- List<LocDetl> detlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, loc.getId()).eq(LocDetl::getHostId, hostId));
- //鍒犻櫎搴撳瓨鏄庣粏
- for (LocDetl locDetl : detlList) {
- if (!locDetlService.removeById(locDetl)) {
- throw new CoolException("鍒犻櫎搴撳瓨鏄庣粏澶辫触");
- }
- List<LocDetlField> detlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId()).eq(LocDetlField::getHostId, hostId));
- for (LocDetlField detlField : detlFields) {
- if (!locDetlFieldService.removeById(detlField)) {
- throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍瀛楁澶辫触");
- }
- }
- }
+ case 101://鍑哄簱
+ executeTask101(task);
break;
-
+ case 103://鎷f枡
+ executeTask103(task);
+ break;
+ default:
+ throw new CoolException("鏈煡浠诲姟绫诲瀷");
}
task.setTaskSts(200L);//200.搴撳瓨鏇存柊瀹屾垚
@@ -220,4 +131,207 @@
}
}
+ //鍏ュ簱
+ private void executeTask1(Task task) {
+ Long hostId = task.getHostId();
+
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
+ if (loc == null) {
+ throw new CoolException("搴撲綅涓嶅瓨鍦�");
+ }
+
+ if (loc.getLocStsId() != LocStsType.S.val()) {
+ throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
+ }
+
+ loc.setLocStsId(LocStsType.F.val());
+ loc.setUpdateTime(new Date());
+ loc.setBarcode(task.getBarcode());
+ if (!locService.updateById(loc)) {
+ throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+ }
+
+ List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+ if (taskDetls.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+ }
+
+ //娣诲姞搴撳瓨鏄庣粏
+ for (TaskDetl taskDetl : taskDetls) {
+ 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(taskDetl.getAnfme());
+ locDetl.setHostId(hostId);
+ if (!locDetlService.save(locDetl)) {
+ throw new CoolException("鎻掑叆搴撳瓨鏄庣粏澶辫触");
+ }
+
+ //娣诲姞搴撳瓨鏄庣粏鎵╁睍瀛楁
+ 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());
+ locDetlField.setFieldId(detlField.getFieldId());
+ locDetlField.setName(detlField.getName());
+ locDetlField.setValue(detlField.getValue());
+ locDetlField.setHostId(hostId);
+ if (!locDetlFieldService.save(locDetlField)) {
+ throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
+ }
+ }
+ }
+
+ //缁勬墭閫氱煡妗h浆鍘嗗彶妗�
+ List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
+ if (waitPakins.isEmpty()) {
+ throw new CoolException("缁勬墭閫氱煡妗d笉瀛樺湪");
+ }
+ for (WaitPakin waitPakin : waitPakins) {
+ WaitPakinLog waitPakinLog = new WaitPakinLog();
+ waitPakinLog.sync(waitPakin);
+ if (!waitPakinLogService.save(waitPakinLog)) {
+ throw new CoolException("缁勬墭閫氱煡妗h浆鍘嗗彶妗eけ璐�");
+ }
+
+ //鍒犻櫎缁勬墭閫氱煡妗�
+ waitPakinService.removeById(waitPakin.getId());
+ }
+ }
+
+ //鎷f枡鍐嶅叆搴�
+ private void executeTask53(Task task) {
+ Long hostId = task.getHostId();
+
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
+ if (loc == null) {
+ throw new CoolException("搴撲綅涓嶅瓨鍦�");
+ }
+
+ if (loc.getLocStsId() != LocStsType.S.val()) {
+ throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
+ }
+
+ loc.setLocStsId(LocStsType.F.val());
+ loc.setUpdateTime(new Date());
+ loc.setBarcode(task.getBarcode());
+ if (!locService.updateById(loc)) {
+ throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+ }
+
+ List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+ if (taskDetls.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+ }
+
+ //娣诲姞搴撳瓨鏄庣粏
+ for (TaskDetl taskDetl : taskDetls) {
+ double anfme = taskDetl.getStock() - taskDetl.getAnfme();
+ if (anfme <= 0) {
+ continue;
+ }
+
+ 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<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());
+ locDetlField.setFieldId(detlField.getFieldId());
+ locDetlField.setName(detlField.getName());
+ locDetlField.setValue(detlField.getValue());
+ locDetlField.setHostId(hostId);
+ if (!locDetlFieldService.save(locDetlField)) {
+ throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
+ }
+ }
+ }
+ }
+
+ //鍑哄簱
+ private void executeTask101(Task task) {
+ Long hostId = task.getHostId();
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId));
+ if (loc == null) {
+ throw new CoolException("搴撲綅涓嶅瓨鍦�");
+ }
+ if (loc.getLocStsId() != LocStsType.R.val()) {
+ throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
+ }
+ List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+ if (taskDetls.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+ }
+
+ loc.setLocStsId(LocStsType.O.val());
+ loc.setBarcode("");
+ if (!locService.updateById(loc)) {
+ throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+ }
+ List<LocDetl> detlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId()).eq(LocDetl::getHostId, hostId));
+ //鍒犻櫎搴撳瓨鏄庣粏
+ for (LocDetl locDetl : detlList) {
+ if (!locDetlService.removeById(locDetl)) {
+ throw new CoolException("鍒犻櫎搴撳瓨鏄庣粏澶辫触");
+ }
+ List<LocDetlField> detlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId()).eq(LocDetlField::getHostId, hostId));
+ for (LocDetlField detlField : detlFields) {
+ if (!locDetlFieldService.removeById(detlField)) {
+ throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍瀛楁澶辫触");
+ }
+ }
+ }
+ }
+
+ //鎷f枡鍑哄簱
+ private void executeTask103(Task task) {
+ Long hostId = task.getHostId();
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId));
+ if (loc == null) {
+ throw new CoolException("搴撲綅涓嶅瓨鍦�");
+ }
+ if (loc.getLocStsId() != LocStsType.R.val()) {
+ throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
+ }
+ List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+ if (taskDetls.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+ }
+
+ loc.setLocStsId(LocStsType.O.val());
+ loc.setBarcode("");
+ if (!locService.updateById(loc)) {
+ throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+ }
+ List<LocDetl> detlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId()).eq(LocDetl::getHostId, hostId));
+ //鍒犻櫎搴撳瓨鏄庣粏
+ for (LocDetl locDetl : detlList) {
+ if (!locDetlService.removeById(locDetl)) {
+ throw new CoolException("鍒犻櫎搴撳瓨鏄庣粏澶辫触");
+ }
+ List<LocDetlField> detlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId()).eq(LocDetlField::getHostId, hostId));
+ for (LocDetlField detlField : detlFields) {
+ if (!locDetlFieldService.removeById(detlField)) {
+ throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍瀛楁澶辫触");
+ }
+ }
+ }
+ }
+
}
--
Gitblit v1.9.1