From 2f8e173048d22c5b40612c3538b9c1aa5a5397f6 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期五, 27 三月 2026 13:38:05 +0800
Subject: [PATCH] #乐观锁
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 382 ++++++++++++++++++++++++++++--------------------------
1 files changed, 198 insertions(+), 184 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
index 06c2c73..875e6d4 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -169,10 +169,7 @@
if (!this.save(task)) {
throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
}
- if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
- throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
- }
+ updateLocByCode(task.getTargLoc(), LocStsType.LOC_STS_TYPE_S.type, pakin.getBarcode(), null, "搴撲綅棰勭害澶辫触锛侊紒", true);
/**鑾峰彇缁勬嫋鏄庣粏**/
List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
if (waitPakinItems.isEmpty()) {
@@ -212,13 +209,7 @@
});
});
- if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
- .in(WaitPakin::getId, pakins.getId())
- .set(WaitPakin::getUpdateBy, loginUserId)
- .set(WaitPakin::getCreateBy, loginUserId)
- .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
- throw new CoolException("缁勬墭鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateWaitPakinsStatus(waitPakins, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val, loginUserId, true, "缁勬墭鐘舵�佷慨鏀瑰け璐ワ紒锛�");
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
}
@@ -261,14 +252,7 @@
if (!this.save(task)) {
throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
}
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
- .set(Loc::getUpdateBy, loginUserId)
- .set(Loc::getUpdateTime, new Date())
- .set(Loc::getBarcode, pakin.getBarcode()))) {
- throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
- }
+ updateLocByCode(task.getTargLoc(), LocStsType.LOC_STS_TYPE_S.type, pakin.getBarcode(), loginUserId, "搴撲綅棰勭害澶辫触锛侊紒", true);
/**鑾峰彇缁勬嫋鏄庣粏**/
List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
if (waitPakinItems.isEmpty()) {
@@ -303,13 +287,7 @@
});
});
- if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
- .in(WaitPakin::getId, pakins.getId())
- .set(WaitPakin::getUpdateBy, loginUserId)
- .set(WaitPakin::getCreateBy, loginUserId)
- .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
- throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateWaitPakinsStatus(waitPakins, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val, loginUserId, true, "缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
}
@@ -415,10 +393,7 @@
}
- if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
- throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
- }
+ updateLocByCode(task.getTargLoc(), LocStsType.LOC_STS_TYPE_S.type, pakin.getBarcode(), null, "搴撲綅棰勭害澶辫触锛侊紒", true);
/**鑾峰彇缁勬嫋鏄庣粏**/
List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
if (waitPakinItems.isEmpty()) {
@@ -461,13 +436,7 @@
});
});
- if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
- .in(WaitPakin::getId, ids)
- .set(WaitPakin::getUpdateBy, loginUserId)
- .set(WaitPakin::getCreateBy, loginUserId)
- .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
- throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateWaitPakinsStatus(waitPakins, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val, loginUserId, true, "缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
}
@@ -691,10 +660,7 @@
throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
}
- if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
- throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
- }
+ updateLocByCode(task.getTargLoc(), LocStsType.LOC_STS_TYPE_S.type, pakin.getBarcode(), null, "搴撲綅棰勭害澶辫触锛侊紒", true);
/**鑾峰彇缁勬嫋鏄庣粏**/
List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
if (waitPakinItems.isEmpty()) {
@@ -736,13 +702,7 @@
continue;
}
- if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
- .in(WaitPakin::getId, ids)
- .set(WaitPakin::getUpdateBy, loginUserId)
- .set(WaitPakin::getCreateBy, loginUserId)
- .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
- throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateWaitPakinsStatus(waitPakins, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val, loginUserId, true, "缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
}
String msg = "鏈壘搴撲綅" + Arrays.toString(errMsg);
@@ -1060,30 +1020,11 @@
}
/**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .set(Loc::getBarcode, task.getBarcode())
- .set(Loc::getUseStatus, type)
- .set(Loc::getUpdateBy, loginUserId)
- .set(Loc::getUpdateTime, new Date())
- .eq(Loc::getCode, task.getTargLoc()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocByCode(task.getTargLoc(), type, task.getBarcode(), loginUserId, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", true);
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .set(Loc::getBarcode, null)
- .set(Loc::getUpdateBy, loginUserId)
- .set(Loc::getUpdateTime, new Date())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
- .eq(Loc::getCode, task.getOrgLoc()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocByCode(task.getOrgLoc(), LocStsType.LOC_STS_TYPE_O.type, null, loginUserId, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", true);
- if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId())
- .set(Task::getUpdateBy, loginUserId)
- .set(Task::getUpdateTime, new Date())
- .set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateTaskSnapshot(task, TaskStsType.UPDATED_IN.id, loginUserId, "浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
@@ -1324,16 +1265,8 @@
for (Task task : tasks) {
//鍙栨秷绉诲簱浠诲姟
if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type) && task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id)) {
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .eq(Loc::getCode, task.getOrgLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) {
- throw new CoolException("婧愬簱浣嶇姸鎬佷慨鏀瑰け璐ワ紒锛�");
- }
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type))) {
- throw new CoolException("绉诲簱鐩爣搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocByCode(task.getOrgLoc(), LocStsType.LOC_STS_TYPE_F.type, null, null, "婧愬簱浣嶇姸鎬佷慨鏀瑰け璐ワ紒锛�", false);
+ updateLocByCode(task.getTargLoc(), LocStsType.LOC_STS_TYPE_O.type, null, null, "绉诲簱鐩爣搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", false);
Task outTask = this.getById(task.getParentId());
if (!Objects.isNull(outTask)) {
@@ -1360,11 +1293,7 @@
throw new CoolException("鏄庣粏鏁伴噺淇敼澶辫触锛侊紒");
}
- if (!checkOrderService.update(new LambdaUpdateWrapper<WkOrder>()
- .eq(WkOrder::getId, taskItem.getOrderId())
- .setSql("work_qty = work_qty - " + taskItem.getAnfme()))) {
- throw new CoolException("鐩樼偣鍗曟墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
- }
+ updateWkOrderWorkQty(taskItem.getOrderId(), -taskItem.getAnfme(), null, "鐩樼偣鍗曟墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
CheckDiffItem serviceOne = checkDiffItemService.getOne(new LambdaQueryWrapper<CheckDiffItem>().eq(CheckDiffItem::getTaskItemId, taskItem.getId()));
@@ -1383,17 +1312,11 @@
.distinct()
.collect(Collectors.toList());
for (Long orderId : orderIds) {
- checkOrderService.update(new LambdaUpdateWrapper<WkOrder>()
- .eq(WkOrder::getId, orderId)
- .set(WkOrder::getExceStatus, CheckExceStatus.CHECK_ORDER_STATUS_UN_EXCE.val));
+ updateWkOrderExceStatus(orderId, CheckExceStatus.CHECK_ORDER_STATUS_UN_EXCE.val, null, "鐩樼偣鍗曠姸鎬佷慨鏀瑰け璐ワ紒锛�");
}
}
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .eq(Loc::getCode, task.getOrgLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) {
- throw new CoolException("婧愬簱浣嶇姸鎬佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocByCode(task.getOrgLoc(), LocStsType.LOC_STS_TYPE_F.type, null, null, "婧愬簱浣嶇姸鎬佷慨鏀瑰け璐ワ紒锛�", false);
}
// 鍑哄簱绫讳换鍔″彇娑堟椂锛屽洖閫�璺緞瑙勫垝闃舵鍗犵敤鐨勭洰鏍囩珯鐐癸紙S鈫扥锛�
@@ -1804,22 +1727,9 @@
}
/**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
- .set(Loc::getBarcode, null)
- .set(Loc::getUpdateBy, loginUserId)
- .set(Loc::getUpdateTime, new Date())
- .eq(Loc::getId, loc.getId()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocSnapshot(loc, LocStsType.LOC_STS_TYPE_O.type, null, loginUserId, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", true);
- if (!this.update(new LambdaUpdateWrapper<Task>()
- .eq(Task::getId, task.getId())
- .set(Task::getUpdateBy, loginUserId)
- .set(Task::getUpdateTime, new Date())
- .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
- throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
- }
+ updateTaskSnapshot(task, TaskStsType.WAVE_SEED.id, loginUserId, "搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
// if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
// if (!this.update(new LambdaUpdateWrapper<Task>()
@@ -1952,22 +1862,9 @@
}
/**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
- .set(Loc::getBarcode, null)
- .set(Loc::getUpdateBy, loginUserId)
- .set(Loc::getUpdateTime, new Date())
- .eq(Loc::getId, loc.getId()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocSnapshot(loc, LocStsType.LOC_STS_TYPE_O.type, null, loginUserId, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", true);
- if (!this.update(new LambdaUpdateWrapper<Task>()
- .eq(Task::getId, task.getId())
- .set(Task::getUpdateBy, loginUserId)
- .set(Task::getUpdateTime, new Date())
- .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
- throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
- }
+ updateTaskSnapshot(task, TaskStsType.UPDATED_OUT.id, loginUserId, "搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
// if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
// if (!this.update(new LambdaUpdateWrapper<Task>()
@@ -2068,22 +1965,24 @@
}
/**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
- .set(Loc::getBarcode, loc.getBarcode())
- .set(Loc::getUpdateBy, loginUserId)
- .set(Loc::getUpdateTime, new Date())
- .eq(Loc::getId, loc.getId()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocSnapshot(loc, LocStsType.LOC_STS_TYPE_S.type, loc.getBarcode(), loginUserId, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", true);
- if (!this.update(new LambdaUpdateWrapper<Task>()
- .eq(Task::getId, task.getId())
- .set(Task::getUpdateBy, loginUserId)
- .set(Task::getUpdateTime, new Date())
- .set(Task::getTargLoc, task.getOrgLoc())
- .set(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id))) {
+ Task update = new Task();
+ update.setId(task.getId());
+ update.setVersion(task.getVersion());
+ update.setUpdateBy(loginUserId);
+ update.setUpdateTime(new Date());
+ update.setTargLoc(task.getOrgLoc());
+ update.setTaskStatus(TaskStsType.COMPLETE_IN.id);
+ if (!this.updateById(update)) {
throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+ }
+ task.setUpdateBy(loginUserId);
+ task.setUpdateTime(update.getUpdateTime());
+ task.setTargLoc(task.getOrgLoc());
+ task.setTaskStatus(TaskStsType.COMPLETE_IN.id);
+ if (update.getVersion() != null) {
+ task.setVersion(update.getVersion());
}
}
@@ -2108,22 +2007,9 @@
}
/**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>()
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
- .set(Loc::getBarcode, null)
- .set(Loc::getUpdateBy, loginUserId)
- .set(Loc::getUpdateTime, new Date())
- .eq(Loc::getId, loc.getId()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocSnapshot(loc, LocStsType.LOC_STS_TYPE_O.type, null, loginUserId, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", true);
- if (!this.update(new LambdaUpdateWrapper<Task>()
- .eq(Task::getId, task.getId())
- .set(Task::getUpdateBy, loginUserId)
- .set(Task::getUpdateTime, new Date())
- .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
- throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
- }
+ updateTaskSnapshot(task, TaskStsType.UPDATED_OUT.id, loginUserId, "搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
}
/**
@@ -2357,10 +2243,7 @@
throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
}
- if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
- .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_IN.id))) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateTaskSnapshot(task, TaskStsType.WCS_EXECUTE_IN.id, null, "浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
/**鎺掗櫎绉诲簱鍔熻兘*/
if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
/**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍑哄簱棰勭害*/
@@ -2381,10 +2264,7 @@
throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
}
- if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
- .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_OUT.id))) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateTaskSnapshot(task, TaskStsType.WCS_EXECUTE_OUT.id, null, "浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
/**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍏ュ簱棰勭害*/
if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
curSta.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
@@ -2462,12 +2342,8 @@
removeReceiptStock(pakinItem, loginUserId);
});
/**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
- if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocByCode(task.getTargLoc(), LocStsType.LOC_STS_TYPE_F.type, null, null, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", false);
+ updateTaskSnapshot(task, TaskStsType.UPDATED_IN.id, null, "浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
/**
@@ -2492,12 +2368,8 @@
}
/**淇敼搴撲綅鐘舵�佷负"D", "绌烘澘"*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type).eq(Loc::getCode, task.getTargLoc()))) {
- throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
- if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateLocByCode(task.getTargLoc(), LocStsType.LOC_STS_TYPE_D.type, null, null, "搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�", false);
+ updateTaskSnapshot(task, TaskStsType.UPDATED_IN.id, null, "浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
/**
@@ -2511,12 +2383,7 @@
@Transactional(rollbackFor = Exception.class)
public synchronized void removeReceiptStock(WaitPakinItem pakinItem, Long loginUserId) {
if (pakinItem.getType().equals(OrderType.ORDER_PRE.type)){
- if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
- .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
- .set(WaitPakin::getUpdateBy, loginUserId)
- .eq(WaitPakin::getId, pakinItem.getPakinId()))) {
- throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateWaitPakinById(pakinItem.getPakinId(), PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val, loginUserId, "缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}else {
WarehouseAreasItem itemServiceOne = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>()
.eq(WarehouseAreasItem::getId, pakinItem.getSource()));
@@ -2530,12 +2397,7 @@
Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 1000000) / 1000000.0;
itemServiceOne.setWorkQty(workQty).setQty(qty);
- if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
- .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
- .set(WaitPakin::getUpdateBy, loginUserId)
- .eq(WaitPakin::getId, pakinItem.getPakinId()))) {
- throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
+ updateWaitPakinById(pakinItem.getPakinId(), PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val, loginUserId, "缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
if (qty.compareTo(itemServiceOne.getAnfme()) == 0.00) {
if (!warehouseAreasItemService.removeById(itemServiceOne.getId())) {
@@ -2665,4 +2527,156 @@
}
}
}
+
+ private void updateLocByCode(String locCode, String useStatus, String barcode, Long loginUserId, String errorMessage, boolean updateBarcode) {
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, locCode), false);
+ if (Objects.isNull(loc)) {
+ throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
+ }
+ updateLocSnapshot(loc, useStatus, barcode, loginUserId, errorMessage, updateBarcode);
+ }
+
+ private void updateLocSnapshot(Loc loc, String useStatus, String barcode, Long loginUserId, String errorMessage, boolean updateBarcode) {
+ Loc update = new Loc();
+ update.setId(loc.getId());
+ update.setVersion(loc.getVersion());
+ update.setUseStatus(useStatus);
+ if (updateBarcode) {
+ update.setBarcode(barcode);
+ }
+ if (loginUserId != null) {
+ update.setUpdateBy(loginUserId);
+ update.setUpdateTime(new Date());
+ }
+ if (!locService.updateById(update)) {
+ throw new CoolException(errorMessage);
+ }
+ loc.setUseStatus(useStatus);
+ if (updateBarcode) {
+ loc.setBarcode(barcode);
+ }
+ if (loginUserId != null) {
+ loc.setUpdateBy(loginUserId);
+ loc.setUpdateTime(update.getUpdateTime());
+ }
+ if (update.getVersion() != null) {
+ loc.setVersion(update.getVersion());
+ }
+ }
+
+ private void updateWaitPakinById(Long pakinId, Short ioStatus, Long loginUserId, String errorMessage) {
+ WaitPakin waitPakin = waitPakinService.getById(pakinId);
+ if (Objects.isNull(waitPakin)) {
+ throw new CoolException("缁勬嫋涓嶅瓨鍦紒锛�");
+ }
+ updateWaitPakinSnapshot(waitPakin, ioStatus, loginUserId, false, errorMessage);
+ }
+
+ private void updateWaitPakinsStatus(List<WaitPakin> waitPakins, Short ioStatus, Long loginUserId, boolean updateCreateBy, String errorMessage) {
+ for (WaitPakin waitPakin : waitPakins) {
+ updateWaitPakinSnapshot(waitPakin, ioStatus, loginUserId, updateCreateBy, errorMessage);
+ }
+ }
+
+ private void updateWaitPakinSnapshot(WaitPakin waitPakin, Short ioStatus, Long loginUserId, boolean updateCreateBy, String errorMessage) {
+ WaitPakin update = new WaitPakin();
+ update.setId(waitPakin.getId());
+ update.setVersion(waitPakin.getVersion());
+ update.setIoStatus(ioStatus);
+ if (updateCreateBy && loginUserId != null) {
+ update.setCreateBy(loginUserId);
+ }
+ if (loginUserId != null) {
+ update.setUpdateBy(loginUserId);
+ update.setUpdateTime(new Date());
+ }
+ if (!waitPakinService.updateById(update)) {
+ throw new CoolException(errorMessage);
+ }
+ waitPakin.setIoStatus(ioStatus);
+ if (loginUserId != null) {
+ waitPakin.setUpdateBy(loginUserId);
+ waitPakin.setUpdateTime(update.getUpdateTime());
+ }
+ if (update.getVersion() != null) {
+ waitPakin.setVersion(update.getVersion());
+ }
+ }
+
+ private void updateWkOrderExceStatus(Long orderId, Short exceStatus, Long loginUserId, String errorMessage) {
+ WkOrder order = checkOrderService.getById(orderId);
+ if (Objects.isNull(order)) {
+ return;
+ }
+ WkOrder update = new WkOrder();
+ update.setId(order.getId());
+ update.setVersion(order.getVersion());
+ update.setExceStatus(exceStatus);
+ if (loginUserId != null) {
+ update.setUpdateBy(loginUserId);
+ update.setUpdateTime(new Date());
+ }
+ if (!checkOrderService.updateById(update)) {
+ throw new CoolException(errorMessage);
+ }
+ order.setExceStatus(exceStatus);
+ if (loginUserId != null) {
+ order.setUpdateBy(loginUserId);
+ order.setUpdateTime(update.getUpdateTime());
+ }
+ if (update.getVersion() != null) {
+ order.setVersion(update.getVersion());
+ }
+ }
+
+ private void updateWkOrderWorkQty(Long orderId, Double delta, Long loginUserId, String errorMessage) {
+ WkOrder order = checkOrderService.getById(orderId);
+ if (Objects.isNull(order)) {
+ throw new CoolException("鐩樼偣鍗曚笉瀛樺湪锛侊紒");
+ }
+ double currentWorkQty = Objects.isNull(order.getWorkQty()) ? 0.0 : order.getWorkQty();
+ double nextWorkQty = Math.round((currentWorkQty + delta) * 10000) / 10000.0;
+
+ WkOrder update = new WkOrder();
+ update.setId(order.getId());
+ update.setVersion(order.getVersion());
+ update.setWorkQty(nextWorkQty);
+ if (loginUserId != null) {
+ update.setUpdateBy(loginUserId);
+ update.setUpdateTime(new Date());
+ }
+ if (!checkOrderService.updateById(update)) {
+ throw new CoolException(errorMessage);
+ }
+ order.setWorkQty(nextWorkQty);
+ if (loginUserId != null) {
+ order.setUpdateBy(loginUserId);
+ order.setUpdateTime(update.getUpdateTime());
+ }
+ if (update.getVersion() != null) {
+ order.setVersion(update.getVersion());
+ }
+ }
+
+ private void updateTaskSnapshot(Task task, Integer taskStatus, Long loginUserId, String errorMessage) {
+ Task update = new Task();
+ update.setId(task.getId());
+ update.setVersion(task.getVersion());
+ update.setTaskStatus(taskStatus);
+ if (loginUserId != null) {
+ update.setUpdateBy(loginUserId);
+ update.setUpdateTime(new Date());
+ }
+ if (!this.updateById(update)) {
+ throw new CoolException(errorMessage);
+ }
+ task.setTaskStatus(taskStatus);
+ if (loginUserId != null) {
+ task.setUpdateBy(loginUserId);
+ task.setUpdateTime(update.getUpdateTime());
+ }
+ if (update.getVersion() != null) {
+ task.setVersion(update.getVersion());
+ }
+ }
}
--
Gitblit v1.9.1