|
|
|
@ -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 { |
|
|
|
|