Commit f90d60a8 authored by chew's avatar chew

调整理货为数组参入 并讲错误返回

parent 5c99c47d
...@@ -6,14 +6,19 @@ import com.ekingwin.tms_app.module.cargo.outbound.dto.ManualTallyUpdateResp; ...@@ -6,14 +6,19 @@ import com.ekingwin.tms_app.module.cargo.outbound.dto.ManualTallyUpdateResp;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteReq; import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteReq;
import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteResp; import com.ekingwin.tms_app.module.cargo.outbound.dto.ScanExecuteResp;
import com.ekingwin.tms_app.module.cargo.outbound.service.ScanService; import com.ekingwin.tms_app.module.cargo.outbound.service.ScanService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
@Log4j2
@RestController @RestController
@RequestMapping("/cargo/outbound/scan") @RequestMapping("/cargo/outbound/scan")
public class ScanController { public class ScanController {
...@@ -28,9 +33,32 @@ public class ScanController { ...@@ -28,9 +33,32 @@ public class ScanController {
@PostMapping("/manual/update") @PostMapping("/manual/update")
public Result<ManualTallyUpdateResp> manualTallyUpdate(@RequestBody @Valid ManualTallyUpdateReq req) { public Result<List<ManualTallyUpdateResp>> manualTallyUpdate(@RequestBody @Valid List<ManualTallyUpdateReq> reqList) {
if (CollectionUtils.isEmpty(reqList)) {
return Result.success(Collections.emptyList());
}
List<ManualTallyUpdateResp> resultList = new ArrayList<>();
for (ManualTallyUpdateReq req : reqList) {
ManualTallyUpdateResp resp = new ManualTallyUpdateResp();
resp.setOrderNo(req.getOrderNo().toString()); // 假设 req 有 orderNo 字段
try {
ManualTallyUpdateResp serviceResp = scanService.manualTallyUpdate(req);
// 如果 service 返回了结果,直接使用
if ( StringUtils.isNotBlank(serviceResp.getResult())) {
resp.setOrderNo(serviceResp.getOrderNo());
resp.setResult(serviceResp.getResult());
resp.setSuccess("500");
}
} catch (Exception e) {
log.error("人工理货更新失败, orderNo: {}", req.getOrderNo(), e);
resp.setResult("系统异常: " + e.getMessage());
resp.setSuccess("500");
}
resultList.add(resp);
}
ManualTallyUpdateResp resp = scanService.manualTallyUpdate(req); return Result.success(resultList);
return Result.success(resp);
} }
} }
\ No newline at end of file
...@@ -5,4 +5,6 @@ import lombok.Data; ...@@ -5,4 +5,6 @@ import lombok.Data;
@Data @Data
public class ManualTallyUpdateResp { public class ManualTallyUpdateResp {
private String result; // 存储过程返回的 p_out_result 信息 private String result; // 存储过程返回的 p_out_result 信息
private String orderNo; //
private String success; //
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment