|
|
|
@ -6,6 +6,7 @@ import com.gaotao.modules.productionPicking.service.ProductionPickingService; |
|
|
|
import com.gaotao.modules.inventoryStock.entity.InventoryStock; |
|
|
|
import com.gaotao.modules.inventoryStock.service.InventoryStockService; |
|
|
|
import com.gaotao.modules.productionPicking.service.StockTransactionLogService; |
|
|
|
import com.gaotao.modules.schedule.mapper.ProcedureMapper; |
|
|
|
import com.gaotao.modules.sys.entity.SysUserEntity; |
|
|
|
import com.gaotao.modules.trans.entity.TransDetail; |
|
|
|
import com.gaotao.modules.trans.entity.TransDetailDto; |
|
|
|
@ -50,6 +51,8 @@ public class ProductionPickingServiceImpl implements ProductionPickingService { |
|
|
|
@Autowired |
|
|
|
private StockTransactionLogService stockTransactionLogService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ProcedureMapper procedureMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> getOutboundList(String site, String warehouseId, String searchCode, String status) { |
|
|
|
@ -65,48 +68,120 @@ public class ProductionPickingServiceImpl implements ProductionPickingService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> validateLabelWithOutbound(String labelCode, String outboundNo, String warehouseId, String site, String buNo, String relatedNo) { |
|
|
|
logger.info("验证标签与出库单匹配,标签码: {}, 出库单号: {}, 仓库: {}, 站点: {}, 业务单元: {}", labelCode, outboundNo, warehouseId, site, buNo); |
|
|
|
// 1. 验证标签与出库单物料是否匹配 |
|
|
|
List<Map<String, Object>> labelInfos = pickingMapper.validateLabelWithOutbound(labelCode, outboundNo, site, buNo, warehouseId, relatedNo); |
|
|
|
if (labelInfos == null || labelInfos.isEmpty()) { |
|
|
|
throw new RuntimeException("该标签与出库单不符,请检查"); |
|
|
|
public Map<String, Object> validateLabelWithOutbound(String site, String buNo, String outboundNo, |
|
|
|
String relatedNo, String labelCode, |
|
|
|
String operationType, String userName) { |
|
|
|
logger.info("验证生产领料标签,site: {}, buNo: {}, 出库单号: {}, 关联单号: {}, 标签: {}, 操作类型: {}", |
|
|
|
site, buNo, outboundNo, relatedNo, labelCode, operationType); |
|
|
|
|
|
|
|
try { |
|
|
|
// 调用存储过程 GetScanLabelVerification |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
params.add(site); // 参数1: site |
|
|
|
params.add(buNo); // 参数2: buNo |
|
|
|
params.add(outboundNo); // 参数3: 出库单号 |
|
|
|
params.add(relatedNo); // 参数4: 关联单号 |
|
|
|
params.add(""); // 参数5: 空字符串 |
|
|
|
params.add(""); // 参数6: 空字符串 |
|
|
|
params.add(""); // 参数7: 空字符串 |
|
|
|
params.add(labelCode); // 参数8: 扫描的标签条码 |
|
|
|
params.add(""); // 参数9: 空字符串 |
|
|
|
params.add("生产领料"); // 参数10: 生产领料 |
|
|
|
params.add(operationType); // 参数11: 操作类型 I或D |
|
|
|
params.add(userName); // 参数12: 当前登陆人 |
|
|
|
|
|
|
|
List<Map<String, Object>> resultList = procedureMapper.getProcedureData("GetScanLabelVerification", params); |
|
|
|
|
|
|
|
// 判断返回结果 |
|
|
|
if (resultList == null || resultList.isEmpty()) { |
|
|
|
throw new RuntimeException("存储过程调用失败"); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> result = resultList.get(0); |
|
|
|
String code = String.valueOf(result.get("code")); |
|
|
|
|
|
|
|
if (!"200".equals(code)) { |
|
|
|
String msg = String.valueOf(result.get("message")); |
|
|
|
throw new RuntimeException(msg); |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("标签验证成功,标签: {}, 操作类型: {}", labelCode, operationType); |
|
|
|
return result; |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("标签验证失败,标签: {}, 错误: {}", labelCode, e.getMessage(), e); |
|
|
|
throw new RuntimeException(e.getMessage(), e); |
|
|
|
} |
|
|
|
return labelInfos; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public boolean confirmProductionPicking(String site, String buNo, String outboundNo, String warehouseId, List<Map<String, Object>> labels, String relatedNo) { |
|
|
|
logger.info("开始确认生产领料,出库单号: {}, 业务单元: {}, 仓库: {}, 标签数量: {}", outboundNo, buNo, warehouseId, labels.size()); |
|
|
|
SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
String userName = sysUserEntity.getUsername(); |
|
|
|
public boolean confirmProductionPicking(String site, String buNo, String outboundNo, |
|
|
|
String relatedNo, String locationCode, String userName) { |
|
|
|
logger.info("开始确认生产领料,site: {}, buNo: {}, 出库单号: {}, 关联单号: {}, 库位: {}", |
|
|
|
site, buNo, outboundNo, relatedNo, locationCode); |
|
|
|
|
|
|
|
try { |
|
|
|
// 1. 提取标签条码列表 |
|
|
|
List<String> labelCodes = labels.stream() |
|
|
|
.map(label -> (String) label.get("labelCode")) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 2. 更新WMS库存表中的标签状态(生产领料直接操作库存) |
|
|
|
updateInventoryStockStatus(labels, site, buNo, warehouseId, outboundNo); |
|
|
|
|
|
|
|
// // 3. 更新出库单状态 |
|
|
|
// int updatedHead = pickingMapper.updateOutboundStatus(outboundNo, buNo, "已出库", site); |
|
|
|
// if (updatedHead == 0) { |
|
|
|
// throw new RuntimeException("出库单状态更新失败"); |
|
|
|
// } |
|
|
|
// 调用存储过程 GetSaveLabelVerification |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
params.add(site); // 参数1: site |
|
|
|
params.add(buNo); // 参数2: buNo |
|
|
|
params.add(outboundNo); // 参数3: 出库单号 |
|
|
|
params.add(relatedNo); // 参数4: 关联单号 |
|
|
|
params.add(""); // 参数5: 空字符串 |
|
|
|
params.add(""); // 参数6: 空字符串 |
|
|
|
params.add(""); // 参数7: 空字符串 |
|
|
|
params.add(locationCode); // 参数8: 库位 |
|
|
|
params.add("生产领料"); // 参数9: 生产领料 |
|
|
|
params.add(userName); // 参数10: 当前登陆人 |
|
|
|
|
|
|
|
List<Map<String, Object>> resultList = procedureMapper.getProcedureData("GetSaveLabelVerification", params); |
|
|
|
|
|
|
|
// 判断返回结果 |
|
|
|
if (resultList == null || resultList.isEmpty()) { |
|
|
|
throw new RuntimeException("存储过程调用失败"); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> result = resultList.get(0); |
|
|
|
String code = String.valueOf(result.get("code")); |
|
|
|
|
|
|
|
// 4. 生成WMS出库记录 |
|
|
|
generateOutboundTransaction(outboundNo, warehouseId, labels, site, buNo, relatedNo, userName); |
|
|
|
logger.info("生产领料确认完成,出库单号: {}, 处理标签数: {}", outboundNo, labels.size()); |
|
|
|
if (!"200".equals(code)) { |
|
|
|
String msg = String.valueOf(result.get("message")); |
|
|
|
throw new RuntimeException(msg); |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("生产领料确认成功,出库单号: {}", outboundNo); |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("生产领料确认失败,出库单号: {}, 错误信息: {}", outboundNo, e.getMessage(), e); |
|
|
|
logger.error("生产领料确认失败,出库单号: {}, 错误: {}", outboundNo, e.getMessage(), e); |
|
|
|
throw new RuntimeException(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 保留原有的实现方法作为注释,以防需要 |
|
|
|
// private boolean confirmProductionPickingOld(String site, String buNo, String outboundNo, String warehouseId, List<Map<String, Object>> labels, String relatedNo) { |
|
|
|
// logger.info("开始确认生产领料(旧方法),出库单号: {}, 业务单元: {}, 仓库: {}, 标签数量: {}", outboundNo, buNo, warehouseId, labels.size()); |
|
|
|
// SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
// String userName = sysUserEntity.getUsername(); |
|
|
|
// |
|
|
|
// try { |
|
|
|
// // 1. 提取标签条码列表 |
|
|
|
// List<String> labelCodes = labels.stream() |
|
|
|
// .map(label -> (String) label.get("labelCode")) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// |
|
|
|
// // 2. 更新WMS库存表中的标签状态(生产领料直接操作库存) |
|
|
|
// updateInventoryStockStatus(labels, site, buNo, warehouseId, outboundNo); |
|
|
|
// |
|
|
|
// // 3. 生成WMS出库记录 |
|
|
|
// generateOutboundTransaction(outboundNo, warehouseId, labels, site, buNo, relatedNo, userName); |
|
|
|
// logger.info("生产领料确认完成,出库单号: {}, 处理标签数: {}", outboundNo, labels.size()); |
|
|
|
// return true; |
|
|
|
// } catch (Exception e) { |
|
|
|
// logger.error("生产领料确认失败,出库单号: {}, 错误信息: {}", outboundNo, e.getMessage(), e); |
|
|
|
// throw new RuntimeException(e.getMessage(), e); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> getMaterialList(String site, String buNo, String outboundNo, String warehouseId, String relatedNo) { |
|
|
|
logger.info("获取出库单物料清单,站点: {}, 业务单元: {}, 出库单号: {}", site, buNo, outboundNo); |
|
|
|
@ -385,4 +460,25 @@ public class ProductionPickingServiceImpl implements ProductionPickingService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> getScannedLabelList(String site, String buNo, String outboundNo, String relatedNo) { |
|
|
|
logger.info("获取已扫描标签列表,site: {}, buNo: {}, 出库单号: {}, 关联单号: {}", |
|
|
|
site, buNo, outboundNo, relatedNo); |
|
|
|
|
|
|
|
try { |
|
|
|
List<Map<String, Object>> labelList = pickingMapper.getScannedLabelList( |
|
|
|
site, buNo, outboundNo, relatedNo); |
|
|
|
|
|
|
|
if (labelList == null) { |
|
|
|
labelList = new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("获取已扫描标签列表成功,共 {} 条记录", labelList.size()); |
|
|
|
return labelList; |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("获取已扫描标签列表失败,错误: {}", e.getMessage(), e); |
|
|
|
throw new RuntimeException("获取已扫描标签列表失败: " + e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |