From 8943a4e9f5ee1455c56ac4af60d941fa23731051 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期一, 13 四月 2026 13:20:38 +0800
Subject: [PATCH] 重量
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java | 14 ++
rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java | 5 +
rsf-server/src/main/java/com/vincent/rsf/server/api/service/WcsService.java | 4
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Stock.java | 4 +
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/WcsController.java | 21 +++++
rsf-open-api/pom.xml | 5 +
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java | 75 ++++++++++++++----
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 68 ++++++++++++++--
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java | 4 +
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java | 4 +
rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocationAllocateParams.java | 4 +
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/RcsTestServiceImpl.java | 2
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/TaskInParam.java | 5 +
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockItem.java | 4 +
14 files changed, 185 insertions(+), 34 deletions(-)
diff --git a/rsf-open-api/pom.xml b/rsf-open-api/pom.xml
index cb6f4a3..5eb898d 100644
--- a/rsf-open-api/pom.xml
+++ b/rsf-open-api/pom.xml
@@ -59,6 +59,11 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
</dependency>
+ <!-- 鐢佃鏈烘姤璀︼細RCS 鍥炶皟鍐欏叆涓� zy-monitor-admin 鐩稿悓鐨� Redis 閿� -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-redis</artifactId>
+ </dependency>
</dependencies>
<build>
<finalName>rsf-open-api</finalName>
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocationAllocateParams.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocationAllocateParams.java
index c5c2bf3..91a6aac 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocationAllocateParams.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocationAllocateParams.java
@@ -6,6 +6,7 @@
import lombok.experimental.Accessors;
import java.io.Serializable;
+import java.math.BigDecimal;
@Data
@Accessors(chain = true)
@@ -24,4 +25,7 @@
@ApiModelProperty(value = "鍏ュ簱绫诲瀷", required = true)
private Integer type;
+
+ @ApiModelProperty(value = "閲嶉噺锛�4浣嶅皬鏁�")
+ private BigDecimal weight;
}
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java
index 5154b7d..2c68826 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java
@@ -426,7 +426,7 @@
@Transactional(rollbackFor = Exception.class)
public R allocateLocation(LocationAllocateParams params) {
log.info("========== 寮�濮嬬敵璇峰叆搴撲换鍔★紝鍒嗛厤搴撲綅 ==========");
- log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}", params.getBarcode(), params.getStaNo(), params.getType());
+ log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}锛岄噸閲忥細{}", params.getBarcode(), params.getStaNo(), params.getType(), params.getWeight());
// 璋冪敤WMS server鍐呴儴鎺ュ彛杩涜搴撲綅鍒嗛厤
String wmsUrl = getWmsBaseUrl() + "/rsf-server/wcs/allocate/location";
@@ -438,6 +438,9 @@
requestParams.put("staNo", params.getStaNo());
requestParams.put("type", params.getType());
requestParams.put("full", params.getFull());
+ if (params.getWeight() != null) {
+ requestParams.put("weight", params.getWeight());
+ }
log.info("璇锋眰鍙傛暟锛歿}", requestParams.toJSONString());
HttpHeaders headers = new HttpHeaders();
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/WcsController.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/WcsController.java
index 446ae60..3e204dd 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/WcsController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/WcsController.java
@@ -28,6 +28,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.math.BigDecimal;
import java.util.Map;
@RestController
@@ -172,6 +173,7 @@
full = Boolean.parseBoolean(params.get("full").toString());
}
}
+ BigDecimal weight = parseAllocateWeight(params.get("weight"));
if (Cools.isEmpty(barcode)) {
return R.error("鏂欑鐮佷笉鑳戒负绌猴紒锛�");
}
@@ -181,7 +183,24 @@
if (type == null) {
return R.error("鍏ュ簱绫诲瀷涓嶈兘涓虹┖锛侊紒");
}
- return wcsService.allocateLocation(barcode, staNo, type, full);
+ return wcsService.allocateLocation(barcode, staNo, type, full, weight);
+ }
+
+ private static BigDecimal parseAllocateWeight(Object raw) {
+ if (raw == null) {
+ return null;
+ }
+ if (raw instanceof BigDecimal) {
+ return (BigDecimal) raw;
+ }
+ if (raw instanceof Number) {
+ return new BigDecimal(raw.toString());
+ }
+ String s = raw.toString().trim();
+ if (s.isEmpty()) {
+ return null;
+ }
+ return new BigDecimal(s);
}
@ApiOperation("绌烘澘鍑哄簱锛氫粠鎸囧畾绌烘澘搴撲綅鐢熸垚鍑哄簱浠诲姟鑷崇洰鏍囩珯鐐�")
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/TaskInParam.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/TaskInParam.java
index 4f689f4..80c4c5b 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/TaskInParam.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/TaskInParam.java
@@ -5,6 +5,8 @@
import lombok.Data;
import lombok.experimental.Accessors;
+import java.math.BigDecimal;
+
@Data
@Accessors(chain = true)
@ApiModel(value = "TaskInParam", description = "WCS璋冨害鍙傛暟")
@@ -31,6 +33,9 @@
private Long user;
private String orgLoc;
+
+ @ApiModelProperty("閲嶉噺锛�4浣嶅皬鏁�")
+ private BigDecimal weight;
// private Integer locType2; //搴撲綅绫诲瀷
// private Integer locType3; //搴撲綅绫诲瀷
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/WcsService.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/WcsService.java
index 707562d..257d754 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/WcsService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/WcsService.java
@@ -3,6 +3,8 @@
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.api.entity.dto.InTaskMsgDto;
import com.vincent.rsf.server.api.controller.erp.params.TaskInParam;
+
+import java.math.BigDecimal;
import com.vincent.rsf.server.api.entity.params.ExMsgParams;
import com.vincent.rsf.server.api.entity.params.WcsTaskParams;
@@ -19,5 +21,5 @@
R pubWcsTask(WcsTaskParams params);
- R allocateLocation(String barcode, String staNo, Integer type, Boolean full);
+ R allocateLocation(String barcode, String staNo, Integer type, Boolean full, BigDecimal weight);
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
index ab2a30a..96611bd 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -51,6 +51,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -143,7 +145,7 @@
// 绌烘澘鍏ュ簱锛氫笌闈炵┖鏉垮悓涓�鍏ュ彛锛屼粎涓嶆牎楠岀粍鎵橈紝鍙仛鍒嗛厤搴撲綅銆佸缓浠诲姟銆佹洿鏂板簱浣�
if (param.getIoType() != null && param.getIoType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
- return createInTaskForEmptyPallet(param.getBarcode(), param.getSourceStaNo(), param.getLocType1());
+ return createInTaskForEmptyPallet(param);
}
// 鎻愬墠瀹氫箟 waitPakin / waitPakinItems锛屼緵鍚庣画鍏朵粬鍏ュ簱閫昏緫浣跨敤
@@ -262,6 +264,12 @@
log.warn("鏇存柊鎷f枡鍏ュ簱浠诲姟鐨勫叆搴撶珯鐐瑰け璐� - 浠诲姟缂栫爜锛歿}", pickInTask.getTaskCode());
}
}
+ if (param.getWeight() != null) {
+ pickInTask.setWeight(param.getWeight());
+ if (!taskService.updateById(pickInTask)) {
+ log.warn("鏇存柊鎷f枡鍏ュ簱浠诲姟閲嶉噺澶辫触 - 浠诲姟缂栫爜锛歿}", pickInTask.getTaskCode());
+ }
+ }
// 杩斿洖鎷f枡鍏ュ簱浠诲姟鐨勪俊鎭�
InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -313,6 +321,12 @@
checkInTask.setOrgSite(param.getSourceStaNo());
if (!taskService.updateById(checkInTask)) {
log.warn("鏇存柊鐩樼偣鍏ュ簱浠诲姟鐨勫叆搴撶珯鐐瑰け璐� - 浠诲姟缂栫爜锛歿}", checkInTask.getTaskCode());
+ }
+ }
+ if (param.getWeight() != null) {
+ checkInTask.setWeight(param.getWeight());
+ if (!taskService.updateById(checkInTask)) {
+ log.warn("鏇存柊鐩樼偣鍏ュ簱浠诲姟閲嶉噺澶辫触 - 浠诲姟缂栫爜锛歿}", checkInTask.getTaskCode());
}
}
@@ -395,6 +409,12 @@
log.warn("鏇存柊鍏ュ簱浠诲姟鐨勫叆搴撶珯鐐瑰け璐� - 浠诲姟缂栫爜锛歿}", existingInTask.getTaskCode());
}
}
+ if (param.getWeight() != null) {
+ existingInTask.setWeight(param.getWeight());
+ if (!taskService.updateById(existingInTask)) {
+ log.warn("鏇存柊鍏ュ簱浠诲姟閲嶉噺澶辫触 - 浠诲姟缂栫爜锛歿}", existingInTask.getTaskCode());
+ }
+ }
// 鐩存帴杩斿洖宸叉湁浠诲姟淇℃伅锛屼笉鍐嶆柊寤轰换鍔�
InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -424,10 +444,11 @@
}
// 鍒涘缓骞朵繚瀛樹换鍔�
Task task = createTask(ruleCode, locNo.getLocNo(), waitPakin.getBarcode(),
- deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser());
+ deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser(),
+ TaskType.TASK_TYPE_IN.type, param.getWeight());
// 鏇存柊搴撲綅鐘舵��
- updateLocStatus(task.getTargLoc(), waitPakin.getBarcode());
+ updateLocStatus(task.getTargLoc(), waitPakin.getBarcode(), param.getWeight());
// 鑾峰彇骞堕獙璇佺粍鎷栨槑缁�
waitPakinItems = getWaitPakinItems(waitPakin.getId());
@@ -584,16 +605,16 @@
/**
* 鍒涘缓骞朵繚瀛樹换鍔�
*/
- private Task createTask(String ruleCode, String targetLoc, String barcode,
- String targetSite, String sourceSiteNo, Long loginUserId) {
- return createTask(ruleCode, targetLoc, barcode, targetSite, sourceSiteNo, loginUserId, TaskType.TASK_TYPE_IN.type);
- }
+// private Task createTask(String ruleCode, String targetLoc, String barcode,
+// String targetSite, String sourceSiteNo, Long loginUserId) {
+// return createTask(ruleCode, targetLoc, barcode, targetSite, sourceSiteNo, loginUserId, TaskType.TASK_TYPE_IN.type, null);
+// }
/**
* 鍒涘缓骞朵繚瀛樹换鍔★紙鏀寔鎸囧畾浠诲姟绫诲瀷锛屽绌烘澘鍏ュ簱锛�
*/
private Task createTask(String ruleCode, String targetLoc, String barcode,
- String targetSite, String sourceSiteNo, Long loginUserId, Integer taskType) {
+ String targetSite, String sourceSiteNo, Long loginUserId, Integer taskType, BigDecimal weight) {
Task task = new Task();
task.setTaskCode(ruleCode)
.setTaskStatus(TaskStsType.GENERATE_IN.id)
@@ -605,6 +626,9 @@
.setCreateBy(loginUserId)
.setUpdateBy(loginUserId)
.setOrgSite(sourceSiteNo);
+ if (weight != null) {
+ task.setWeight(weight);
+ }
if (!taskService.save(task)) {
throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
@@ -615,11 +639,13 @@
/**
* 鏇存柊搴撲綅鐘舵��
*/
- private void updateLocStatus(String locCode, String barcode) {
- boolean updated = locService.update(new LambdaUpdateWrapper<Loc>()
+ private void updateLocStatus(String locCode, String barcode, BigDecimal weight) {
+ LambdaUpdateWrapper<Loc> uw = new LambdaUpdateWrapper<Loc>()
.eq(Loc::getCode, locCode)
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
- .set(Loc::getBarcode, barcode));
+ .set(Loc::getBarcode, barcode)
+ .set(Loc::getWeight, weight);
+ boolean updated = locService.update(uw);
if (!updated) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
@@ -629,13 +655,16 @@
* 绌烘澘鍏ュ簱锛氫笌闈炵┖鏉垮悓涓�娴佺▼锛堟牎楠岀珯鐐广�佸垎閰嶅簱浣嶃�佸缓浠诲姟銆佹洿鏂板簱浣嶏級锛屼粎涓嶆牎楠岀粍鎵樸�佷笉鍐欎换鍔℃槑缁嗐�佷笉鏇存柊缁勬墭鐘舵�併��
* 鐢� createInTask 鍦� ioType=绌烘澘鏃惰皟鐢紱闇�鍦ㄨ澶囩珯鐐逛腑閰嶇疆 type=10锛堢┖鏉垮叆搴擄級鐨勭珯鐐硅矾寰勩��
*/
- private InTaskMsgDto createInTaskForEmptyPallet(String barcode, String staNo, Integer type) {
+ private InTaskMsgDto createInTaskForEmptyPallet(TaskInParam sourceParam) {
TaskInParam param = new TaskInParam();
+ String barcode = sourceParam.getBarcode();
+ String staNo = sourceParam.getSourceStaNo();
param.setBarcode(barcode);
param.setSourceStaNo(staNo);
- param.setLocType1(type != null ? type : 1);
+ param.setLocType1(sourceParam.getLocType1() != null ? sourceParam.getLocType1() : 1);
param.setIoType(TaskType.TASK_TYPE_EMPITY_IN.type);
- param.setUser(1L);
+ param.setUser(sourceParam.getUser() != null ? sourceParam.getUser() : 1L);
+ param.setWeight(sourceParam.getWeight());
// 鏍¢獙璁惧绔欑偣锛堥渶閰嶇疆 type=10 绌烘澘鍏ュ簱鐨勭珯鐐癸級
DeviceSite deviceSite = validateDeviceSite(param);
@@ -650,6 +679,10 @@
log.info("鎵惧埌璇ユ墭鐩樺彿宸叉湁绌烘澘鍏ュ簱浠诲姟锛屽鐢� - 浠诲姟缂栫爜锛歿}锛岀鍙凤細{}", existingInTask.getTaskCode(), barcode);
if (StringUtils.isNotBlank(staNo) && !staNo.equals(existingInTask.getOrgSite())) {
existingInTask.setOrgSite(staNo);
+ taskService.updateById(existingInTask);
+ }
+ if (param.getWeight() != null) {
+ existingInTask.setWeight(param.getWeight());
taskService.updateById(existingInTask);
}
InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -686,8 +719,8 @@
}
String ruleCode = generateTaskCode();
String targetSite = StringUtils.isNotBlank(deviceSite.getDeviceSite()) ? deviceSite.getDeviceSite() : staNo;
- Task task = createTask(ruleCode, locNo.getLocNo(), barcode, targetSite, staNo, param.getUser(), TaskType.TASK_TYPE_EMPITY_IN.type);
- updateLocStatus(task.getTargLoc(), barcode);
+ Task task = createTask(ruleCode, locNo.getLocNo(), barcode, targetSite, staNo, param.getUser(), TaskType.TASK_TYPE_EMPITY_IN.type, param.getWeight());
+ updateLocStatus(task.getTargLoc(), barcode, param.getWeight());
locNo.setWorkNo(ruleCode);
locNo.setTaskId(task.getId());
log.info("[绌烘澘鍏ュ簱] 宸插垱寤轰换鍔�: {}, 搴撲綅: {}, 鏂欑: {}", ruleCode, locNo.getLocNo(), barcode);
@@ -1561,9 +1594,14 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public R allocateLocation(String barcode, String staNo, Integer type, Boolean full) {
+ public R allocateLocation(String barcode, String staNo, Integer type, Boolean full, BigDecimal weight) {
log.info("========== 寮�濮嬬敵璇峰叆搴撲换鍔★紝鍒嗛厤搴撲綅 ==========");
- log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}锛岀┖鏉匡細{}", barcode, staNo, type, full);
+ log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}锛岀┖鏉匡細{}锛岄噸閲忥細{}", barcode, staNo, type, full, weight);
+
+ BigDecimal weightScaled = null;
+ if (weight != null) {
+ weightScaled = weight.setScale(4, RoundingMode.HALF_UP);
+ }
// 缁熶竴璧� createInTask锛氱┖鏉�(full=true)浠呬笉鏍¢獙缁勬墭锛屼粛鏍¢獙绔欑偣銆佸垎閰嶅簱浣嶃�佸缓浠诲姟锛涢潪绌烘澘闇�缁勬墭
TaskInParam param = new TaskInParam();
@@ -1572,6 +1610,7 @@
param.setLocType1(type != null ? type : 1);
param.setUser(1L);
param.setIoType(Boolean.TRUE.equals(full) ? TaskType.TASK_TYPE_EMPITY_IN.type : TaskType.TASK_TYPE_IN.type);
+ param.setWeight(weightScaled);
InTaskMsgDto msgDto = createInTask(param);
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java
index 9850333..f4f65b7 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java
@@ -18,6 +18,7 @@
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
@@ -86,6 +87,9 @@
@ApiModelProperty(value= "瀹瑰櫒缂栫爜")
private String barcode;
+ @ApiModelProperty(value= "閲嶉噺")
+ private BigDecimal weight;
+
/**
* 瀛樻斁鍗曚綅
*/
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Stock.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Stock.java
index e2f3a8d..93b810e 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Stock.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Stock.java
@@ -28,6 +28,7 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
+import java.math.BigDecimal;
import java.util.Date;
@Data
@@ -79,6 +80,9 @@
@ApiModelProperty(value= "搴撳瓨鏁伴噺")
private Double anfme;
+ @ApiModelProperty(value= "閲嶉噺")
+ private BigDecimal weight;
+
@ApiModelProperty(value= "鏉″舰鐮�")
private String barcode;
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockItem.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockItem.java
index 06544b1..bb2b1e2 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockItem.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/StockItem.java
@@ -22,6 +22,7 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
+import java.math.BigDecimal;
import java.util.Map;
@Data
@@ -80,6 +81,9 @@
@ApiModelProperty(value= "閫佽揣鏁伴噺")
private Double anfme;
+ @ApiModelProperty(value= "閲嶉噺")
+ private BigDecimal weight;
+
/**
* 搴撳瓨鍗曚綅
*/
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java
index dd29650..cbbf3de 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java
@@ -32,6 +32,7 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
+import java.math.BigDecimal;
import java.util.Date;
import java.util.stream.Collectors;
@@ -107,6 +108,9 @@
@ApiModelProperty(value= "鏂欑鐮�")
private String barcode;
+ @ApiModelProperty(value= "閲嶉噺")
+ private BigDecimal weight;
+
/**
* 鏈哄櫒浜虹紪鐮�
*/
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
index 5088b9b..0a6add5 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -207,8 +207,15 @@
if (barcodeToUse == null && !existTasks.isEmpty()) {
barcodeToUse = existTasks.get(0).getBarcode();
if (StringUtils.isNotBlank(barcodeToUse)) {
- locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getId, loc.getId())
- .set(Loc::getBarcode, barcodeToUse).set(Loc::getUpdateBy, loginUserId).set(Loc::getUpdateTime, new Date()));
+ Task refTask = existTasks.get(0);
+ LambdaUpdateWrapper<Loc> locUw = new LambdaUpdateWrapper<Loc>().eq(Loc::getId, loc.getId())
+ .set(Loc::getBarcode, barcodeToUse)
+ .set(Loc::getUpdateBy, loginUserId)
+ .set(Loc::getUpdateTime, new Date());
+ if (refTask.getWeight() != null) {
+ locUw.set(Loc::getWeight, refTask.getWeight());
+ }
+ locService.update(locUw);
}
}
if (barcodeToUse == null) {
@@ -456,7 +463,8 @@
throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦紒锛�");
}
- targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+ targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
+ .setWeight(orgLoc.getWeight());
if (!locService.updateById(targetLoc)) {
throw new CoolException("鐩爣搴撲綅棰勭害澶辫触锛侊紒");
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/RcsTestServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/RcsTestServiceImpl.java
index 3afff4b..bb02568 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/RcsTestServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/RcsTestServiceImpl.java
@@ -222,7 +222,7 @@
if ("location_allocate".equals(params.getInboundApiType())) {
// 浣跨敤 location_allocate 鎺ュ彛锛堝唴閮ㄨ皟鐢╟reateInTask锛夛紱full=null 琛ㄧず鏅�氬叆搴�
- R allocateResult = wcsService.allocateLocation(barcode, inboundStation, 1, null);
+ R allocateResult = wcsService.allocateLocation(barcode, inboundStation, 1, null, null);
if (allocateResult != null) {
Object dataObj = allocateResult.get("data");
if (dataObj != null) {
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..581c448 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,6 +1205,7 @@
}
loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
.setBarcode(task.getBarcode())
+ .setWeight(task.getWeight())
.setUpdateBy(loginUserId)
.setUpdateTime(new Date());
if (!locService.updateById(loc)) {
@@ -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("绌烘澘鍑哄簱搴撲綅鐘舵�佹洿鏂板け璐ワ紒锛�");
@@ -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()))) {
@@ -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))) {
@@ -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