From 0b3cdb1e0c2f495edb971c585bd6b4b0456bf93a Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期二, 14 四月 2026 14:55:34 +0800
Subject: [PATCH] 字段变更 增加类型
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 84 +++++++++++++++++++++++++++++++++--------
1 files changed, 67 insertions(+), 17 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 d61e7ff..1c5e211 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
@@ -58,6 +58,8 @@
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@@ -175,7 +177,9 @@
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()))) {
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
+ .set(Loc::getBarcode, pakin.getBarcode())
+ .set(Loc::getWeight, task.getWeight()))) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
/**鑾峰彇缁勬嫋鏄庣粏**/
@@ -264,7 +268,8 @@
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
- .set(Loc::getBarcode, pakin.getBarcode()))) {
+ .set(Loc::getBarcode, pakin.getBarcode())
+ .set(Loc::getWeight, task.getWeight()))) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
/**鑾峰彇缁勬嫋鏄庣粏**/
@@ -406,7 +411,9 @@
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()))) {
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
+ .set(Loc::getBarcode, pakin.getBarcode())
+ .set(Loc::getWeight, task.getWeight()))) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
/**鑾峰彇缁勬嫋鏄庣粏**/
@@ -643,6 +650,7 @@
// 灏嗗簱浣嶇姸鎬佽涓虹┖锛圤鐘舵�侊級
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
@@ -802,6 +810,7 @@
/**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getBarcode, task.getBarcode())
+ .set(Loc::getWeight, task.getWeight())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
@@ -811,6 +820,7 @@
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
@@ -873,6 +883,7 @@
// }
loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
.setBarcode(task.getBarcode())
+ .setWeight(task.getWeight())
.setUpdateBy(loginUserId).setUpdateTime(new Date());
if (!locService.updateById(loc)) {
@@ -1104,7 +1115,9 @@
}
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type))) {
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+ .set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null))) {
throw new CoolException("绉诲簱鐩爣搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
@@ -1192,13 +1205,14 @@
}
loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
.setBarcode(task.getBarcode())
+ .setWeight(task.getWeight())
.setUpdateBy(loginUserId)
.setUpdateTime(new Date());
if (!locService.updateById(loc)) {
throw new CoolException("搴撲綅淇℃伅淇敼澶辫触锛侊紒");
}
//鍑哄簱
- if (item.getWkType().equals(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type))) {
+ if (Objects.equals(item.getWkType(), OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)) {
//搴撳瓨鍑哄簱
} else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) {
WaveItem waveItem = waveItemService.getById(item.getSource());
@@ -1220,7 +1234,7 @@
throw new CoolException("娉㈡鏇存柊澶辫触锛侊紒");
}
- } else if (item.getWkType().equals(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER.type))) {
+ } else if (Objects.equals(item.getWkType(), OrderWorkType.ORDER_WORK_TYPE_OTHER.type)) {
//鍏跺畠鍑哄簱
} else {
@@ -1266,7 +1280,9 @@
Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTaskType() < TaskStsType.UPDATED_IN.id ? task.getTargLoc() : task.getOrgLoc()));
if (null != loc && (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)
|| loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type))) {
- loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
+ loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type)
+ .setBarcode(null)
+ .setWeight(null);
if (!locService.updateById(loc)) {
throw new CoolException("鏇存柊搴撲綅鐘舵�佸け璐ワ紒锛�");
}
@@ -1505,7 +1521,8 @@
throw new CoolException("涓存椂搴撳瓨鏇存柊澶辫触锛侊紒");
}
}
- loc1.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+ loc1.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
+ .setWeight(task.getWeight());
locService.updateById(loc1);
// if (!locService.updateById(loc1)) {
// throw new CoolException("搴撲綅棰勭害鍏ュ簱澶辫触锛侊紒");
@@ -1630,11 +1647,13 @@
if (!workings.isEmpty()) {
locItemWorkingService.saveBatch(workings);
}
- loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+ loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
+ .setWeight(first.getWeight());
locService.updateById(loc);
} else {
loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
loc.setBarcode(null);
+ loc.setWeight(null);
loc.setUpdateBy(loginUserId);
loc.setUpdateTime(new Date());
locService.updateById(loc);
@@ -1673,6 +1692,7 @@
.eq(Loc::getId, loc.getId())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date()))) {
throw new CoolException("绌烘澘鍑哄簱搴撲綅鐘舵�佹洿鏂板け璐ワ紒锛�");
@@ -1752,12 +1772,12 @@
}
//娣诲姞鍑哄叆搴撹褰曚俊鎭�
- Map<Short, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getWkType));
+ Map<String, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getWkType));
/***鑾峰彇搴撳瓨鍑哄簱鍊硷紝濡傛灉涓虹┖琛ㄧず姝e父鍗曟嵁鍑哄簱锛岄潪绌鸿〃鏄庢槸搴撳瓨鍑哄簱
* 1. 搴撳瓨鍑哄簱娌℃湁鍗曟嵁淇℃伅锛屽崟鎹俊鎭粯璁や负绌�
* 2. 鍗曟嵁搴撳瓨闇�閫氳繃娉㈡鏌ヨ鍘熷鍗曟嵁淇℃伅锛屽皢鍗曟嵁淇℃伅濉叆stock涓�
* */
- List<TaskItem> list = listMap.get(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type));
+ List<TaskItem> list = listMap.get(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type);
if (Objects.isNull(list) || list.isEmpty()) {
Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource));
maps.keySet().forEach(key -> {
@@ -1815,6 +1835,7 @@
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
.eq(Loc::getId, loc.getId()))) {
@@ -1928,13 +1949,13 @@
if (!asnOrderService.updateById(wkOrder)) {
throw new CoolException("鍑哄簱鍗曟洿鏂板け璐ワ紒锛�");
}
- stock.setWkType(Short.parseShort(wkOrder.getWkType()))
+ stock.setWkType(wkOrder.getWkType())
.setType(OrderType.ORDER_OUT.type);
} else if (!Objects.isNull(diffItem)) {
- stock.setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_CHECK.type))
+ stock.setWkType(OrderWorkType.ORDER_WORK_TYPE_STOCK_CHECK.type)
.setType(OrderType.ORDER_CHECK.type);
} else {
- stock.setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type))
+ stock.setWkType(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)
.setMemo("搴撳瓨鍑哄簱锛屾棤鍗曟嵁淇℃伅锛侊紒")
.setType(OrderType.ORDER_OUT.type);
}
@@ -2459,6 +2480,7 @@
if (TaskType.TASK_TYPE_EMPITY_IN.type.equals(task.getTaskType())) {
if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type)
+ .set(Loc::getWeight, task.getWeight())
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date()))) {
throw new CoolException("绌烘澘鍏ュ簱搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
@@ -2545,7 +2567,10 @@
}
/**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) {
+ if (!locService.update(new LambdaUpdateWrapper<Loc>()
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
+ .set(Loc::getWeight, task.getWeight())
+ .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))) {
@@ -2666,7 +2691,7 @@
* @return
*/
@Transactional(rollbackFor = Exception.class)
- public synchronized void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type, Long loginUserId) {
+ public synchronized void saveStockItems(List<TaskItem> items, Task task, Long id, String code, String wkType, String type, Long loginUserId) {
Stock stock = new Stock();
String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
if (StringUtils.isBlank(ruleCode)) {
@@ -2690,12 +2715,27 @@
} else {
stock.setLocCode(task.getOrgLoc());
}
+ BigDecimal trayWeight = task.getWeight();
+ BigDecimal groupWeight = null;
+ if (trayWeight != null && sum > 0) {
+ List<TaskItem> allLines = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+ double totalQty = allLines.stream().mapToDouble(t -> t.getAnfme() != null ? t.getAnfme() : 0.0).sum();
+ if (totalQty > 0) {
+ groupWeight = trayWeight.multiply(BigDecimal.valueOf(sum)).divide(BigDecimal.valueOf(totalQty), 4, RoundingMode.HALF_UP);
+ } else {
+ groupWeight = trayWeight;
+ }
+ stock.setWeight(groupWeight);
+ }
if (!stockService.save(stock)) {
throw new CoolException("搴撳瓨淇濆瓨澶辫触锛侊紒");
}
List<StockItem> stockItems = new ArrayList<>();
- for (TaskItem item : items) {
+ BigDecimal allocatedWeight = BigDecimal.ZERO;
+ BigDecimal sumBd = sum > 0 ? BigDecimal.valueOf(sum) : null;
+ for (int i = 0; i < items.size(); i++) {
+ TaskItem item = items.get(i);
/**閫氳繃浠诲姟鏄庣粏涓殑taskId鏌ヨ,鑾峰彇TASK鐨勭洰鏍囧簱浣嶄俊鎭�*/
StockItem stockItem = new StockItem();
BeanUtils.copyProperties(item, stockItem);
@@ -2706,6 +2746,16 @@
.setUpdateBy(loginUserId)
.setId(null)
.setStockId(stock.getId());
+ if (groupWeight != null && sumBd != null) {
+ if (i == items.size() - 1) {
+ stockItem.setWeight(groupWeight.subtract(allocatedWeight));
+ } else {
+ double lineQty = item.getAnfme() != null ? item.getAnfme() : 0.0;
+ BigDecimal lineW = groupWeight.multiply(BigDecimal.valueOf(lineQty)).divide(sumBd, 4, RoundingMode.HALF_UP);
+ stockItem.setWeight(lineW);
+ allocatedWeight = allocatedWeight.add(lineW);
+ }
+ }
stockItems.add(stockItem);
}
if (!stockItemService.saveBatch(stockItems)) {
--
Gitblit v1.9.1