Browse Source

2025-11-04

pda调整扫描、查询、确认逻辑(生产领退料)
master
fengyuan_yang 2 months ago
parent
commit
1740c57da8
  1. 143
      src/main/java/com/gaotao/modules/production/controller/ProductionIssueReturnController.java
  2. 8
      src/main/java/com/gaotao/modules/production/dao/ProductionIssueReturnMapper.java
  3. 23
      src/main/java/com/gaotao/modules/production/service/ProductionIssueReturnService.java
  4. 119
      src/main/java/com/gaotao/modules/production/service/impl/ProductionIssueReturnServiceImpl.java
  5. 17
      src/main/resources/mapper/production/ProductionIssueReturnMapper.xml

143
src/main/java/com/gaotao/modules/production/controller/ProductionIssueReturnController.java

@ -133,6 +133,149 @@ public class ProductionIssueReturnController {
}
}
/**
* 验证标签添加或移除
*/
@PostMapping("/validateLabel")
public R validateLabel(@RequestBody Map<String, Object> params) {
logger.info("验证标签,参数: {}", params);
try {
String site = (String) params.get("site");
String buNo = (String) params.get("buNo");
String returnOrderNo = (String) params.get("returnOrderNo");
String issueOrderNo = (String) params.get("issueOrderNo");
String operationSeq = (String) params.get("operationSeq");
String labelCode = (String) params.get("labelCode");
String operationType = (String) params.get("operationType");
String userName = (String) params.get("userName");
String warehouseId = (String) params.get("warehouseId");
logger.info("验证标签参数 - site: {}, buNo: {}, returnOrderNo: {}, issueOrderNo: {}, operationSeq: {}, labelCode: {}, operationType: {}, userName: {}, warehouseId: {}",
site, buNo, returnOrderNo, issueOrderNo, operationSeq, labelCode, operationType, userName, warehouseId);
if (site == null || site.isEmpty()) {
return R.error("站点不能为空");
}
if (buNo == null || buNo.isEmpty()) {
return R.error("BU编码不能为空");
}
if (returnOrderNo == null || returnOrderNo.isEmpty()) {
return R.error("退库工单号不能为空");
}
if (labelCode == null || labelCode.isEmpty()) {
return R.error("标签条码不能为空");
}
if (operationType == null || operationType.isEmpty()) {
return R.error("操作类型不能为空");
}
if (userName == null || userName.isEmpty()) {
return R.error("用户名不能为空");
}
if (warehouseId == null || warehouseId.isEmpty()) {
return R.error("仓库不能为空");
}
Map<String, Object> result = productionIssueReturnService.validateLabel(
site, buNo, returnOrderNo, issueOrderNo, operationSeq,
labelCode, operationType, userName, warehouseId);
return R.ok()
.put("code", 0)
.put("msg", "操作成功")
.put("data", result);
} catch (Exception e) {
logger.error("验证标签失败", e);
return R.error("操作失败: " + e.getMessage());
}
}
/**
* 获取已扫描标签列表
*/
@PostMapping("/getScannedLabelList")
public R getScannedLabelList(@RequestBody Map<String, Object> params) {
logger.info("获取已扫描标签列表,参数: {}", params);
try {
String site = (String) params.get("site");
String buNo = (String) params.get("buNo");
String returnOrderNo = (String) params.get("returnOrderNo");
if (site == null || site.isEmpty()) {
return R.error("站点不能为空");
}
if (buNo == null || buNo.isEmpty()) {
return R.error("BU编码不能为空");
}
if (returnOrderNo == null || returnOrderNo.isEmpty()) {
return R.error("退库工单号不能为空");
}
List<Map<String, Object>> labelList = productionIssueReturnService.getScannedLabelList(site, buNo, returnOrderNo);
return R.ok()
.put("code", 0)
.put("msg", "查询成功")
.put("labelList", labelList);
} catch (Exception e) {
logger.error("获取已扫描标签列表失败", e);
return R.error("查询失败: " + e.getMessage());
}
}
/**
* 确认保存生产领退料
*/
@PostMapping("/confirmSave")
public R confirmSave(@RequestBody Map<String, Object> params) {
logger.info("确认保存生产领退料,参数: {}", params);
try {
String site = (String) params.get("site");
String buNo = (String) params.get("buNo");
String returnOrderNo = (String) params.get("returnOrderNo");
String issueOrderNo = (String) params.get("issueOrderNo");
String operationSeq = (String) params.get("operationSeq");
String locationCode = (String) params.get("locationCode");
String userName = (String) params.get("userName");
logger.info("确认保存参数 - site: {}, buNo: {}, returnOrderNo: {}, issueOrderNo: {}, operationSeq: {}, locationCode: {}, userName: {}",
site, buNo, returnOrderNo, issueOrderNo, operationSeq, locationCode, userName);
if (site == null || site.isEmpty()) {
return R.error("站点不能为空");
}
if (buNo == null || buNo.isEmpty()) {
return R.error("BU编码不能为空");
}
if (returnOrderNo == null || returnOrderNo.isEmpty()) {
return R.error("退库工单号不能为空");
}
if (userName == null || userName.isEmpty()) {
return R.error("用户名不能为空");
}
boolean success = productionIssueReturnService.confirmSave(
site, buNo, returnOrderNo, issueOrderNo, operationSeq,
locationCode, userName);
if (success) {
return R.ok()
.put("code", 0)
.put("msg", "保存成功");
} else {
return R.error("保存失败");
}
} catch (Exception e) {
logger.error("确认保存失败", e);
return R.error("保存失败: " + e.getMessage());
}
}
/**
* 提交生产领退料
* 包含退仓+领料申请+过账+回传ERP

8
src/main/java/com/gaotao/modules/production/dao/ProductionIssueReturnMapper.java

@ -41,6 +41,14 @@ public interface ProductionIssueReturnMapper {
@Param("warehouseId") String warehouseId,
@Param("labelCode") String labelCode);
/**
* 获取已扫描标签列表
* 从ScannedRollTempTable查询
*/
List<Map<String, Object>> getScannedLabelList(@Param("site") String site,
@Param("buNo") String buNo,
@Param("returnOrderNo") String returnOrderNo);
/**
* 生成申请单号
*/

23
src/main/java/com/gaotao/modules/production/service/ProductionIssueReturnService.java

@ -25,6 +25,29 @@ public interface ProductionIssueReturnService {
*/
Map<String, Object> getLabelInfo(String site, String buNo, String warehouseId, String labelCode);
/**
* 验证标签添加或移除
* 调用存储过程 GetScanLabelVerification
*/
Map<String, Object> validateLabel(String site, String buNo, String returnOrderNo,
String issueOrderNo, String operationSeq,
String labelCode, String operationType,
String userName, String warehouseId);
/**
* 获取已扫描标签列表
* 从ScannedRollTempTable查询
*/
List<Map<String, Object>> getScannedLabelList(String site, String buNo, String returnOrderNo);
/**
* 确认保存生产领退料
* 调用存储过程 GetSaveLabelVerification
*/
boolean confirmSave(String site, String buNo, String returnOrderNo,
String issueOrderNo, String operationSeq,
String locationCode, String userName);
/**
* 提交生产领退料
* 包含退仓+领料申请+过账+回传ERP

119
src/main/java/com/gaotao/modules/production/service/impl/ProductionIssueReturnServiceImpl.java

@ -3,12 +3,14 @@ package com.gaotao.modules.production.service.impl;
import com.gaotao.modules.production.dao.ProductionIssueReturnMapper;
import com.gaotao.modules.production.service.ProductionIssueReturnService;
import com.gaotao.modules.production.vo.IssueReturnVO;
import com.gaotao.modules.schedule.mapper.ProcedureMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -24,6 +26,9 @@ public class ProductionIssueReturnServiceImpl implements ProductionIssueReturnSe
@Autowired
private ProductionIssueReturnMapper productionIssueReturnMapper;
@Autowired
private ProcedureMapper procedureMapper;
@Override
public List<Map<String, Object>> searchIssueOrders(String site, String buNo, String searchKey, Integer limit) {
logger.info("搜索领料工单,站点: {}, BU: {}, 搜索关键词: {}, 限制数量: {}", site, buNo, searchKey, limit);
@ -76,6 +81,120 @@ public class ProductionIssueReturnServiceImpl implements ProductionIssueReturnSe
}
}
@Override
public Map<String, Object> validateLabel(String site, String buNo, String returnOrderNo,
String issueOrderNo, String operationSeq,
String labelCode, String operationType,
String userName, String warehouseId) {
logger.info("验证标签,站点: {}, BU: {}, 退库工单: {}, 领料工单: {}, 工序: {}, 标签: {}, 操作类型: {}, 用户: {}, 仓库: {}",
site, buNo, returnOrderNo, issueOrderNo, operationSeq, labelCode, operationType, userName, warehouseId);
try {
// 调用存储过程 GetScanLabelVerification
// EXEC GetScanLabelVerification site, buNo, '', 退库工单, '', 领料工单, 工序号, 扫描的标签条码, '', '生产领退料', 'I''D', 当前登陆人, 当前仓库
List<Object> params = new ArrayList<>();
params.add(site); // param1: site
params.add(buNo); // param2: buNo
params.add(""); // param3:
params.add(returnOrderNo); // param4: 退库工单
params.add(""); // param5:
params.add(issueOrderNo != null ? issueOrderNo : ""); // param6: 领料工单
params.add(operationSeq != null ? operationSeq : ""); // param7: 工序号
params.add(labelCode); // param8: 标签条码
params.add(""); // param9:
params.add("生产领退料"); // param10: 操作类型
params.add(operationType); // param11: I或D
params.add(userName); // param12: 当前登陆人
params.add(warehouseId); // param13: 当前仓库
List<Map<String, Object>> resultList = procedureMapper.getProcedureData("GetScanLabelVerification", params);
// 取第一条结果
Map<String, Object> result = new HashMap<>();
if (resultList != null && !resultList.isEmpty()) {
result = resultList.get(0);
}
// 检查返回的code如果不是200则抛出异常
Object code = result.get("code");
if (code == null || !"200".equals(code.toString())) {
String msg = result.get("msg") != null ? result.get("msg").toString() : "验证失败";
logger.error("存储过程返回错误: {}", msg);
throw new RuntimeException(msg);
}
logger.info("验证标签成功");
return result;
} catch (Exception e) {
logger.error("验证标签失败,错误信息: {}", e.getMessage(), e);
throw new RuntimeException("验证标签失败: " + e.getMessage(), e);
}
}
@Override
public List<Map<String, Object>> getScannedLabelList(String site, String buNo, String returnOrderNo) {
logger.info("获取已扫描标签列表,站点: {}, BU: {}, 退库工单: {}", site, buNo, returnOrderNo);
try {
List<Map<String, Object>> labelList = productionIssueReturnMapper.getScannedLabelList(site, buNo, returnOrderNo);
logger.info("获取已扫描标签列表成功,数量: {}", labelList != null ? labelList.size() : 0);
return labelList;
} catch (Exception e) {
logger.error("获取已扫描标签列表失败,错误信息: {}", e.getMessage(), e);
throw new RuntimeException("获取已扫描标签列表失败: " + e.getMessage(), e);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean confirmSave(String site, String buNo, String returnOrderNo,
String issueOrderNo, String operationSeq,
String locationCode, String userName) {
logger.info("确认保存生产领退料,站点: {}, BU: {}, 退库工单: {}, 领料工单: {}, 工序: {}, 库位: {}, 用户: {}",
site, buNo, returnOrderNo, issueOrderNo, operationSeq, locationCode, userName);
try {
// 调用存储过程 GetSaveLabelVerification
// EXEC GetSaveLabelVerification site, buNo, '', 退库工单, '', 领料工单, 工序号, 库位, '生产领退料', 当前登陆人
List<Object> params = new ArrayList<>();
params.add(site); // param1: site
params.add(buNo); // param2: buNo
params.add(""); // param3:
params.add(returnOrderNo); // param4: 退库工单
params.add(""); // param5:
params.add(issueOrderNo != null ? issueOrderNo : ""); // param6: 领料工单
params.add(operationSeq != null ? operationSeq : ""); // param7: 工序号
params.add(locationCode != null ? locationCode : ""); // param8: 库位
params.add("生产领退料"); // param9: 操作类型
params.add(userName); // param10: 当前登陆人
List<Map<String, Object>> resultList = procedureMapper.getProcedureData("GetSaveLabelVerification", params);
// 取第一条结果
Map<String, Object> result = new HashMap<>();
if (resultList != null && !resultList.isEmpty()) {
result = resultList.get(0);
}
// 检查返回的code如果不是200则抛出异常
Object code = result.get("code");
if (code == null || !"200".equals(code.toString())) {
String msg = result.get("msg") != null ? result.get("msg").toString() : "保存失败";
logger.error("存储过程返回错误: {}", msg);
throw new RuntimeException(msg);
}
logger.info("确认保存成功");
return true;
} catch (Exception e) {
logger.error("确认保存失败,错误信息: {}", e.getMessage(), e);
throw new RuntimeException("确认保存失败: " + e.getMessage(), e);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public String submitIssueReturn(IssueReturnVO issueReturnVO) throws Exception {

17
src/main/resources/mapper/production/ProductionIssueReturnMapper.xml

@ -74,6 +74,23 @@
AND ist.roll_no = #{labelCode}
</select>
<!-- 获取已扫描标签列表 -->
<select id="getScannedLabelList" resultType="map">
SELECT
site,
bu_no AS buNo,
part_no AS partNo,
RollNo AS labelCode,
RollNo AS rollNo,
RollQty AS quantity,
RollQty AS rollQty
FROM ScannedRollTempTable
WHERE site = #{site}
AND bu_no = #{buNo}
AND OrderNo = #{returnOrderNo}
ORDER BY RollNo DESC
</select>
<!-- 生成申请单号 -->
<select id="generateNotifyNo" resultType="string" statementType="CALLABLE">
{call getSerialNo(#{site, mode=IN, jdbcType=VARCHAR},

Loading…
Cancel
Save