7 changed files with 1108 additions and 1 deletions
-
182src/main/java/com/gaotao/modules/production/controller/ProductionIssueReturnController.java
-
93src/main/java/com/gaotao/modules/production/dao/ProductionIssueReturnMapper.java
-
34src/main/java/com/gaotao/modules/production/service/ProductionIssueReturnService.java
-
307src/main/java/com/gaotao/modules/production/service/impl/ProductionIssueReturnServiceImpl.java
-
195src/main/java/com/gaotao/modules/production/vo/IssueReturnVO.java
-
18src/main/java/com/gaotao/modules/wms/service/impl/WmsPrintServiceImpl.java
-
280src/main/resources/mapper/production/ProductionIssueReturnMapper.xml
@ -0,0 +1,182 @@ |
|||||
|
package com.gaotao.modules.production.controller; |
||||
|
|
||||
|
import com.gaotao.common.utils.R; |
||||
|
import com.gaotao.modules.production.service.ProductionIssueReturnService; |
||||
|
import com.gaotao.modules.production.vo.IssueReturnVO; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 生产领退料Controller |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/production/issueReturn") |
||||
|
public class ProductionIssueReturnController { |
||||
|
|
||||
|
private static final Logger logger = LoggerFactory.getLogger(ProductionIssueReturnController.class); |
||||
|
|
||||
|
@Autowired |
||||
|
private ProductionIssueReturnService productionIssueReturnService; |
||||
|
|
||||
|
/** |
||||
|
* 搜索领料工单(模糊查询,top3) |
||||
|
*/ |
||||
|
@PostMapping("/searchOrders") |
||||
|
public R searchOrders(@RequestBody Map<String, Object> params) { |
||||
|
logger.info("搜索领料工单,参数: {}", params); |
||||
|
|
||||
|
try { |
||||
|
String site = (String) params.get("site"); |
||||
|
String buNo = (String) params.get("buNo"); |
||||
|
String searchKey = (String) params.get("searchKey"); |
||||
|
Integer limit = params.get("limit") != null ? (Integer) params.get("limit") : 3; |
||||
|
|
||||
|
if (site == null || site.isEmpty()) { |
||||
|
return R.error("站点不能为空"); |
||||
|
} |
||||
|
if (buNo == null || buNo.isEmpty()) { |
||||
|
return R.error("BU编码不能为空"); |
||||
|
} |
||||
|
if (searchKey == null || searchKey.isEmpty()) { |
||||
|
return R.error("搜索关键词不能为空"); |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> orders = productionIssueReturnService.searchIssueOrders(site, buNo, searchKey, limit); |
||||
|
|
||||
|
return R.ok() |
||||
|
.put("code", 0) |
||||
|
.put("msg", "查询成功") |
||||
|
.put("orders", orders); |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
logger.error("搜索领料工单失败", e); |
||||
|
return R.error("搜索失败: " + e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取工单详情 |
||||
|
*/ |
||||
|
@PostMapping("/getOrderDetail") |
||||
|
public R getOrderDetail(@RequestBody Map<String, Object> params) { |
||||
|
logger.info("获取工单详情,参数: {}", params); |
||||
|
|
||||
|
try { |
||||
|
String site = (String) params.get("site"); |
||||
|
String buNo = (String) params.get("buNo"); |
||||
|
String orderNo = (String) params.get("orderNo"); |
||||
|
|
||||
|
if (site == null || site.isEmpty()) { |
||||
|
return R.error("站点不能为空"); |
||||
|
} |
||||
|
if (buNo == null || buNo.isEmpty()) { |
||||
|
return R.error("BU编码不能为空"); |
||||
|
} |
||||
|
if (orderNo == null || orderNo.isEmpty()) { |
||||
|
return R.error("工单号不能为空"); |
||||
|
} |
||||
|
|
||||
|
Map<String, Object> orderDetail = productionIssueReturnService.getOrderDetail(site, buNo, orderNo); |
||||
|
|
||||
|
return R.ok() |
||||
|
.put("code", 0) |
||||
|
.put("msg", "查询成功") |
||||
|
.put("orderDetail", orderDetail); |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
logger.error("获取工单详情失败", e); |
||||
|
return R.error("查询失败: " + e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 扫描标签获取信息 |
||||
|
*/ |
||||
|
@PostMapping("/scanLabel") |
||||
|
public R scanLabel(@RequestBody Map<String, Object> params) { |
||||
|
logger.info("扫描标签,参数: {}", params); |
||||
|
|
||||
|
try { |
||||
|
String site = (String) params.get("site"); |
||||
|
String buNo = (String) params.get("buNo"); |
||||
|
String warehouseId = (String) params.get("warehouseId"); |
||||
|
String labelCode = (String) params.get("labelCode"); |
||||
|
|
||||
|
if (site == null || site.isEmpty()) { |
||||
|
return R.error("站点不能为空"); |
||||
|
} |
||||
|
if (buNo == null || buNo.isEmpty()) { |
||||
|
return R.error("BU编码不能为空"); |
||||
|
} |
||||
|
if (warehouseId == null || warehouseId.isEmpty()) { |
||||
|
return R.error("仓库不能为空"); |
||||
|
} |
||||
|
if (labelCode == null || labelCode.isEmpty()) { |
||||
|
return R.error("标签条码不能为空"); |
||||
|
} |
||||
|
|
||||
|
Map<String, Object> labelInfo = productionIssueReturnService.getLabelInfo(site, buNo, warehouseId, labelCode); |
||||
|
|
||||
|
return R.ok() |
||||
|
.put("code", 0) |
||||
|
.put("msg", "查询成功") |
||||
|
.put("labelInfo", labelInfo); |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
logger.error("扫描标签失败", e); |
||||
|
return R.error("扫描失败: " + e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 提交生产领退料 |
||||
|
* 包含:退仓+领料申请+过账+回传ERP |
||||
|
*/ |
||||
|
@PostMapping("/submit") |
||||
|
public R submit(@RequestBody IssueReturnVO issueReturnVO) { |
||||
|
logger.info("提交生产领退料,参数: {}", issueReturnVO); |
||||
|
|
||||
|
try { |
||||
|
// 参数验证 |
||||
|
if (issueReturnVO.getSite() == null || issueReturnVO.getSite().isEmpty()) { |
||||
|
return R.error("站点不能为空"); |
||||
|
} |
||||
|
if (issueReturnVO.getBuNo() == null || issueReturnVO.getBuNo().isEmpty()) { |
||||
|
return R.error("BU编码不能为空"); |
||||
|
} |
||||
|
if (issueReturnVO.getWarehouseId() == null || issueReturnVO.getWarehouseId().isEmpty()) { |
||||
|
return R.error("仓库不能为空"); |
||||
|
} |
||||
|
if (issueReturnVO.getUserName() == null || issueReturnVO.getUserName().isEmpty()) { |
||||
|
return R.error("用户名不能为空"); |
||||
|
} |
||||
|
if (issueReturnVO.getReturnOrderNo() == null || issueReturnVO.getReturnOrderNo().isEmpty()) { |
||||
|
return R.error("退库工单号不能为空"); |
||||
|
} |
||||
|
if (issueReturnVO.getIssueOrderNo() == null || issueReturnVO.getIssueOrderNo().isEmpty()) { |
||||
|
return R.error("领料工单号不能为空"); |
||||
|
} |
||||
|
if (issueReturnVO.getLabelList() == null || issueReturnVO.getLabelList().isEmpty()) { |
||||
|
return R.error("标签列表不能为空"); |
||||
|
} |
||||
|
|
||||
|
// 提交领退料 |
||||
|
String notifyNo = productionIssueReturnService.submitIssueReturn(issueReturnVO); |
||||
|
|
||||
|
return R.ok() |
||||
|
.put("code", 0) |
||||
|
.put("msg", "提交成功") |
||||
|
.put("notifyNo", notifyNo); |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
logger.error("提交生产领退料失败", e); |
||||
|
return R.error("提交失败: " + e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,93 @@ |
|||||
|
package com.gaotao.modules.production.dao; |
||||
|
|
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 生产领退料Mapper |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface ProductionIssueReturnMapper { |
||||
|
|
||||
|
/** |
||||
|
* 搜索领料工单(模糊查询,top3) |
||||
|
*/ |
||||
|
List<Map<String, Object>> searchIssueOrders(@Param("site") String site, |
||||
|
@Param("buNo") String buNo, |
||||
|
@Param("searchKey") String searchKey, |
||||
|
@Param("limit") Integer limit); |
||||
|
|
||||
|
/** |
||||
|
* 获取工单详情 |
||||
|
*/ |
||||
|
Map<String, Object> getOrderDetail(@Param("site") String site, |
||||
|
@Param("buNo") String buNo, |
||||
|
@Param("orderNo") String orderNo); |
||||
|
|
||||
|
/** |
||||
|
* 获取工单的工序列表 |
||||
|
*/ |
||||
|
List<Map<String, Object>> getOrderOperations(@Param("site") String site, |
||||
|
@Param("orderNo") String orderNo); |
||||
|
|
||||
|
/** |
||||
|
* 根据标签条码查询库存信息 |
||||
|
*/ |
||||
|
Map<String, Object> getLabelInfo(@Param("site") String site, |
||||
|
@Param("buNo") String buNo, |
||||
|
@Param("warehouseId") String warehouseId, |
||||
|
@Param("labelCode") String labelCode); |
||||
|
|
||||
|
/** |
||||
|
* 生成申请单号 |
||||
|
*/ |
||||
|
String generateNotifyNo(@Param("site") String site, |
||||
|
@Param("buNo") String buNo, |
||||
|
@Param("type") String type); |
||||
|
|
||||
|
/** |
||||
|
* 生成过账单号 |
||||
|
*/ |
||||
|
String generateTransId(@Param("site") String site, |
||||
|
@Param("buNo") String buNo, |
||||
|
@Param("type") String type); |
||||
|
|
||||
|
/** |
||||
|
* 保存领料申请单主表 |
||||
|
*/ |
||||
|
int saveNotifyHeader(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 保存领料申请单明细 |
||||
|
*/ |
||||
|
int saveNotifyOrderList(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 保存领料申请材料明细 |
||||
|
*/ |
||||
|
int saveNotifyMaterialList(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 保存过账单主表 |
||||
|
*/ |
||||
|
int saveTransHeader(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 保存过账单明细 |
||||
|
*/ |
||||
|
int saveTransDetail(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 保存过账单子明细 |
||||
|
*/ |
||||
|
int saveTransDetailSub(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 保存库存事务日志 |
||||
|
*/ |
||||
|
int saveStockTransactionLog(Map<String, Object> params); |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,34 @@ |
|||||
|
package com.gaotao.modules.production.service; |
||||
|
|
||||
|
import com.gaotao.modules.production.vo.IssueReturnVO; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 生产领退料Service |
||||
|
*/ |
||||
|
public interface ProductionIssueReturnService { |
||||
|
|
||||
|
/** |
||||
|
* 搜索领料工单(模糊查询,top3) |
||||
|
*/ |
||||
|
List<Map<String, Object>> searchIssueOrders(String site, String buNo, String searchKey, Integer limit); |
||||
|
|
||||
|
/** |
||||
|
* 获取工单详情 |
||||
|
*/ |
||||
|
Map<String, Object> getOrderDetail(String site, String buNo, String orderNo); |
||||
|
|
||||
|
/** |
||||
|
* 根据标签条码查询库存信息 |
||||
|
*/ |
||||
|
Map<String, Object> getLabelInfo(String site, String buNo, String warehouseId, String labelCode); |
||||
|
|
||||
|
/** |
||||
|
* 提交生产领退料 |
||||
|
* 包含:退仓+领料申请+过账+回传ERP |
||||
|
*/ |
||||
|
String submitIssueReturn(IssueReturnVO issueReturnVO) throws Exception; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,307 @@ |
|||||
|
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 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.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 生产领退料Service实现类 |
||||
|
*/ |
||||
|
@Service("productionIssueReturnService") |
||||
|
public class ProductionIssueReturnServiceImpl implements ProductionIssueReturnService { |
||||
|
|
||||
|
private static final Logger logger = LoggerFactory.getLogger(ProductionIssueReturnServiceImpl.class); |
||||
|
|
||||
|
@Autowired |
||||
|
private ProductionIssueReturnMapper productionIssueReturnMapper; |
||||
|
|
||||
|
@Override |
||||
|
public List<Map<String, Object>> searchIssueOrders(String site, String buNo, String searchKey, Integer limit) { |
||||
|
logger.info("搜索领料工单,站点: {}, BU: {}, 搜索关键词: {}, 限制数量: {}", site, buNo, searchKey, limit); |
||||
|
try { |
||||
|
List<Map<String, Object>> orders = productionIssueReturnMapper.searchIssueOrders(site, buNo, searchKey, limit); |
||||
|
logger.info("搜索到工单数量: {}", orders != null ? orders.size() : 0); |
||||
|
return orders; |
||||
|
} catch (Exception e) { |
||||
|
logger.error("搜索领料工单失败,错误信息: {}", e.getMessage(), e); |
||||
|
throw new RuntimeException("搜索领料工单失败: " + e.getMessage(), e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> getOrderDetail(String site, String buNo, String orderNo) { |
||||
|
logger.info("获取工单详情,站点: {}, BU: {}, 工单号: {}", site, buNo, orderNo); |
||||
|
try { |
||||
|
Map<String, Object> orderDetail = productionIssueReturnMapper.getOrderDetail(site, buNo, orderNo); |
||||
|
if (orderDetail == null) { |
||||
|
logger.warn("未找到工单详情"); |
||||
|
throw new RuntimeException("未找到工单详情"); |
||||
|
} |
||||
|
|
||||
|
// 获取工序列表 |
||||
|
List<Map<String, Object>> operations = productionIssueReturnMapper.getOrderOperations(site, orderNo); |
||||
|
orderDetail.put("operations", operations); |
||||
|
|
||||
|
logger.info("获取工单详情成功,工序数量: {}", operations != null ? operations.size() : 0); |
||||
|
return orderDetail; |
||||
|
} catch (Exception e) { |
||||
|
logger.error("获取工单详情失败,错误信息: {}", e.getMessage(), e); |
||||
|
throw new RuntimeException("获取工单详情失败: " + e.getMessage(), e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> getLabelInfo(String site, String buNo, String warehouseId, String labelCode) { |
||||
|
logger.info("查询标签信息,站点: {}, BU: {}, 仓库: {}, 标签条码: {}", site, buNo, warehouseId, labelCode); |
||||
|
try { |
||||
|
Map<String, Object> labelInfo = productionIssueReturnMapper.getLabelInfo(site, buNo, warehouseId, labelCode); |
||||
|
if (labelInfo == null) { |
||||
|
logger.warn("未找到标签信息"); |
||||
|
throw new RuntimeException("未找到标签信息"); |
||||
|
} |
||||
|
logger.info("查询标签信息成功"); |
||||
|
return labelInfo; |
||||
|
} 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 { |
||||
|
logger.info("开始提交生产领退料,退库工单: {}, 领料工单: {}", |
||||
|
issueReturnVO.getReturnOrderNo(), issueReturnVO.getIssueOrderNo()); |
||||
|
|
||||
|
try { |
||||
|
// 步骤0: 执行退仓逻辑 |
||||
|
// TODO: 调用生产退仓的退仓逻辑 |
||||
|
logger.info("执行退仓逻辑..."); |
||||
|
// processReturn(issueReturnVO); |
||||
|
|
||||
|
// 步骤1: 生成领料申请记录 |
||||
|
String notifyNo = generateIssueNotify(issueReturnVO); |
||||
|
logger.info("生成领料申请单号: {}", notifyNo); |
||||
|
|
||||
|
// 步骤2: 生成过账记录 |
||||
|
String transId = generateTransaction(issueReturnVO, notifyNo); |
||||
|
logger.info("生成过账单号: {}", transId); |
||||
|
|
||||
|
// 步骤3: 生成库存事务日志 |
||||
|
generateStockTransactionLog(issueReturnVO, notifyNo, transId); |
||||
|
logger.info("生成库存事务日志成功"); |
||||
|
|
||||
|
// 步骤4: 回传ERP(用户说不用写) |
||||
|
// sendToERP(notifyNo); |
||||
|
|
||||
|
logger.info("提交生产领退料成功,申请单号: {}", notifyNo); |
||||
|
return notifyNo; |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
logger.error("提交生产领退料失败,错误信息: {}", e.getMessage(), e); |
||||
|
throw new Exception("提交生产领退料失败: " + e.getMessage(), e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成领料申请记录 |
||||
|
*/ |
||||
|
private String generateIssueNotify(IssueReturnVO issueReturnVO) { |
||||
|
logger.info("生成领料申请记录..."); |
||||
|
|
||||
|
// 1. 生成申请单号 |
||||
|
String notifyNo = productionIssueReturnMapper.generateNotifyNo( |
||||
|
issueReturnVO.getSite(), |
||||
|
issueReturnVO.getBuNo(), |
||||
|
"LT" |
||||
|
); |
||||
|
|
||||
|
if (notifyNo == null || notifyNo.isEmpty()) { |
||||
|
throw new RuntimeException("生成申请单号失败"); |
||||
|
} |
||||
|
|
||||
|
// 2. 保存申请单主表 |
||||
|
Map<String, Object> headerParams = new HashMap<>(); |
||||
|
headerParams.put("site", issueReturnVO.getSite()); |
||||
|
headerParams.put("buNo", issueReturnVO.getBuNo()); |
||||
|
headerParams.put("notifyNo", notifyNo); |
||||
|
headerParams.put("userName", issueReturnVO.getUserName()); |
||||
|
headerParams.put("remark", issueReturnVO.getRemark()); |
||||
|
|
||||
|
int headerResult = productionIssueReturnMapper.saveNotifyHeader(headerParams); |
||||
|
if (headerResult <= 0) { |
||||
|
throw new RuntimeException("保存申请单主表失败"); |
||||
|
} |
||||
|
logger.info("保存申请单主表成功"); |
||||
|
|
||||
|
// 3. 获取工单详情 |
||||
|
Map<String, Object> orderDetail = productionIssueReturnMapper.getOrderDetail( |
||||
|
issueReturnVO.getSite(), |
||||
|
issueReturnVO.getBuNo(), |
||||
|
issueReturnVO.getIssueOrderNo() |
||||
|
); |
||||
|
|
||||
|
if (orderDetail == null) { |
||||
|
throw new RuntimeException("获取工单详情失败"); |
||||
|
} |
||||
|
|
||||
|
// 4. 计算申请总数量 |
||||
|
float totalQty = 0f; |
||||
|
for (IssueReturnVO.LabelInfo label : issueReturnVO.getLabelList()) { |
||||
|
totalQty += label.getQuantity(); |
||||
|
} |
||||
|
|
||||
|
// 5. 保存申请单明细 |
||||
|
Map<String, Object> orderListParams = new HashMap<>(); |
||||
|
orderListParams.put("notifyNo", notifyNo); |
||||
|
orderListParams.put("site", issueReturnVO.getSite()); |
||||
|
orderListParams.put("itemNo", 1); |
||||
|
orderListParams.put("fgPartNo", orderDetail.get("partNo")); |
||||
|
orderListParams.put("soOrderNo", issueReturnVO.getIssueOrderNo()); |
||||
|
orderListParams.put("opsItemNo", orderDetail.get("operationNo")); |
||||
|
orderListParams.put("seqNo", orderDetail.get("seqNo")); |
||||
|
orderListParams.put("issureQty", totalQty); |
||||
|
orderListParams.put("locationNo", issueReturnVO.getLabelList().get(0).getLocationId()); |
||||
|
orderListParams.put("resourceId", ""); |
||||
|
|
||||
|
int orderListResult = productionIssueReturnMapper.saveNotifyOrderList(orderListParams); |
||||
|
if (orderListResult <= 0) { |
||||
|
throw new RuntimeException("保存申请单明细失败"); |
||||
|
} |
||||
|
logger.info("保存申请单明细成功"); |
||||
|
|
||||
|
// 6. 保存材料明细(为每个标签生成一条记录) |
||||
|
int materialItemNo = 1; |
||||
|
for (IssueReturnVO.LabelInfo label : issueReturnVO.getLabelList()) { |
||||
|
Map<String, Object> materialParams = new HashMap<>(); |
||||
|
materialParams.put("notifyNo", notifyNo); |
||||
|
materialParams.put("site", issueReturnVO.getSite()); |
||||
|
materialParams.put("itemNo", materialItemNo++); |
||||
|
materialParams.put("componentPartNo", label.getPartNo()); |
||||
|
materialParams.put("partDesc", label.getPartDesc()); |
||||
|
materialParams.put("qtyToIssue", label.getQuantity()); |
||||
|
materialParams.put("rollNo", label.getRollNo()); |
||||
|
materialParams.put("warehouseId", label.getWarehouseId()); |
||||
|
materialParams.put("locationId", label.getLocationId()); |
||||
|
|
||||
|
int materialResult = productionIssueReturnMapper.saveNotifyMaterialList(materialParams); |
||||
|
if (materialResult <= 0) { |
||||
|
throw new RuntimeException("保存材料明细失败"); |
||||
|
} |
||||
|
} |
||||
|
logger.info("保存材料明细成功,共 {} 条", issueReturnVO.getLabelList().size()); |
||||
|
|
||||
|
return notifyNo; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成过账记录 |
||||
|
*/ |
||||
|
private String generateTransaction(IssueReturnVO issueReturnVO, String notifyNo) { |
||||
|
logger.info("生成过账记录..."); |
||||
|
|
||||
|
// 1. 生成过账单号 |
||||
|
String transId = productionIssueReturnMapper.generateTransId( |
||||
|
issueReturnVO.getSite(), |
||||
|
issueReturnVO.getBuNo(), |
||||
|
"TR" |
||||
|
); |
||||
|
|
||||
|
if (transId == null || transId.isEmpty()) { |
||||
|
throw new RuntimeException("生成过账单号失败"); |
||||
|
} |
||||
|
|
||||
|
// 2. 保存过账单主表 |
||||
|
Map<String, Object> headerParams = new HashMap<>(); |
||||
|
headerParams.put("site", issueReturnVO.getSite()); |
||||
|
headerParams.put("buNo", issueReturnVO.getBuNo()); |
||||
|
headerParams.put("transId", transId); |
||||
|
headerParams.put("notifyNo", notifyNo); |
||||
|
headerParams.put("orderNo", issueReturnVO.getIssueOrderNo()); |
||||
|
headerParams.put("userName", issueReturnVO.getUserName()); |
||||
|
|
||||
|
int headerResult = productionIssueReturnMapper.saveTransHeader(headerParams); |
||||
|
if (headerResult <= 0) { |
||||
|
throw new RuntimeException("保存过账单主表失败"); |
||||
|
} |
||||
|
logger.info("保存过账单主表成功"); |
||||
|
|
||||
|
// 3. 保存过账单明细和子明细 |
||||
|
int detailItemNo = 1; |
||||
|
for (IssueReturnVO.LabelInfo label : issueReturnVO.getLabelList()) { |
||||
|
// 保存过账单明细 |
||||
|
Map<String, Object> detailParams = new HashMap<>(); |
||||
|
detailParams.put("site", issueReturnVO.getSite()); |
||||
|
detailParams.put("transId", transId); |
||||
|
detailParams.put("itemNo", detailItemNo); |
||||
|
detailParams.put("partNo", label.getPartNo()); |
||||
|
detailParams.put("quantity", label.getQuantity()); |
||||
|
detailParams.put("warehouseId", label.getWarehouseId()); |
||||
|
detailParams.put("locationId", label.getLocationId()); |
||||
|
detailParams.put("rollNo", label.getRollNo()); |
||||
|
|
||||
|
int detailResult = productionIssueReturnMapper.saveTransDetail(detailParams); |
||||
|
if (detailResult <= 0) { |
||||
|
throw new RuntimeException("保存过账单明细失败"); |
||||
|
} |
||||
|
|
||||
|
// 保存过账单子明细 |
||||
|
Map<String, Object> subParams = new HashMap<>(); |
||||
|
subParams.put("site", issueReturnVO.getSite()); |
||||
|
subParams.put("transId", transId); |
||||
|
subParams.put("itemNo", detailItemNo); |
||||
|
subParams.put("subItemNo", 1); |
||||
|
subParams.put("partNo", label.getPartNo()); |
||||
|
subParams.put("quantity", label.getQuantity()); |
||||
|
subParams.put("rollNo", label.getRollNo()); |
||||
|
|
||||
|
int subResult = productionIssueReturnMapper.saveTransDetailSub(subParams); |
||||
|
if (subResult <= 0) { |
||||
|
throw new RuntimeException("保存过账单子明细失败"); |
||||
|
} |
||||
|
|
||||
|
detailItemNo++; |
||||
|
} |
||||
|
logger.info("保存过账单明细和子明细成功,共 {} 条", issueReturnVO.getLabelList().size()); |
||||
|
|
||||
|
return transId; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成库存事务日志 |
||||
|
*/ |
||||
|
private void generateStockTransactionLog(IssueReturnVO issueReturnVO, String notifyNo, String transId) { |
||||
|
logger.info("生成库存事务日志..."); |
||||
|
|
||||
|
for (IssueReturnVO.LabelInfo label : issueReturnVO.getLabelList()) { |
||||
|
Map<String, Object> logParams = new HashMap<>(); |
||||
|
logParams.put("site", issueReturnVO.getSite()); |
||||
|
logParams.put("buNo", issueReturnVO.getBuNo()); |
||||
|
logParams.put("transId", transId); |
||||
|
logParams.put("partNo", label.getPartNo()); |
||||
|
logParams.put("quantity", label.getQuantity()); |
||||
|
logParams.put("warehouseId", label.getWarehouseId()); |
||||
|
logParams.put("locationId", label.getLocationId()); |
||||
|
logParams.put("rollNo", label.getRollNo()); |
||||
|
logParams.put("orderNo", issueReturnVO.getIssueOrderNo()); |
||||
|
logParams.put("notifyNo", notifyNo); |
||||
|
logParams.put("userName", issueReturnVO.getUserName()); |
||||
|
|
||||
|
int logResult = productionIssueReturnMapper.saveStockTransactionLog(logParams); |
||||
|
if (logResult <= 0) { |
||||
|
throw new RuntimeException("保存库存事务日志失败"); |
||||
|
} |
||||
|
} |
||||
|
logger.info("保存库存事务日志成功,共 {} 条", issueReturnVO.getLabelList().size()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,195 @@ |
|||||
|
package com.gaotao.modules.production.vo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 生产领退料VO |
||||
|
*/ |
||||
|
public class IssueReturnVO { |
||||
|
|
||||
|
/** |
||||
|
* 站点 |
||||
|
*/ |
||||
|
private String site; |
||||
|
|
||||
|
/** |
||||
|
* BU编码 |
||||
|
*/ |
||||
|
private String buNo; |
||||
|
|
||||
|
/** |
||||
|
* 仓库ID |
||||
|
*/ |
||||
|
private String warehouseId; |
||||
|
|
||||
|
/** |
||||
|
* 用户名 |
||||
|
*/ |
||||
|
private String userName; |
||||
|
|
||||
|
/** |
||||
|
* 退库工单号 |
||||
|
*/ |
||||
|
private String returnOrderNo; |
||||
|
|
||||
|
/** |
||||
|
* 领料工单号 |
||||
|
*/ |
||||
|
private String issueOrderNo; |
||||
|
|
||||
|
/** |
||||
|
* 工序名称 |
||||
|
*/ |
||||
|
private String operationName; |
||||
|
|
||||
|
/** |
||||
|
* 备注说明 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 标签列表 |
||||
|
*/ |
||||
|
private List<LabelInfo> labelList; |
||||
|
|
||||
|
public static class LabelInfo { |
||||
|
private String labelCode; |
||||
|
private String rollNo; |
||||
|
private String partNo; |
||||
|
private String partDesc; |
||||
|
private Float quantity; |
||||
|
private String warehouseId; |
||||
|
private String locationId; |
||||
|
|
||||
|
// Getters and Setters |
||||
|
public String getLabelCode() { |
||||
|
return labelCode; |
||||
|
} |
||||
|
|
||||
|
public void setLabelCode(String labelCode) { |
||||
|
this.labelCode = labelCode; |
||||
|
} |
||||
|
|
||||
|
public String getRollNo() { |
||||
|
return rollNo; |
||||
|
} |
||||
|
|
||||
|
public void setRollNo(String rollNo) { |
||||
|
this.rollNo = rollNo; |
||||
|
} |
||||
|
|
||||
|
public String getPartNo() { |
||||
|
return partNo; |
||||
|
} |
||||
|
|
||||
|
public void setPartNo(String partNo) { |
||||
|
this.partNo = partNo; |
||||
|
} |
||||
|
|
||||
|
public String getPartDesc() { |
||||
|
return partDesc; |
||||
|
} |
||||
|
|
||||
|
public void setPartDesc(String partDesc) { |
||||
|
this.partDesc = partDesc; |
||||
|
} |
||||
|
|
||||
|
public Float getQuantity() { |
||||
|
return quantity; |
||||
|
} |
||||
|
|
||||
|
public void setQuantity(Float quantity) { |
||||
|
this.quantity = quantity; |
||||
|
} |
||||
|
|
||||
|
public String getWarehouseId() { |
||||
|
return warehouseId; |
||||
|
} |
||||
|
|
||||
|
public void setWarehouseId(String warehouseId) { |
||||
|
this.warehouseId = warehouseId; |
||||
|
} |
||||
|
|
||||
|
public String getLocationId() { |
||||
|
return locationId; |
||||
|
} |
||||
|
|
||||
|
public void setLocationId(String locationId) { |
||||
|
this.locationId = locationId; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Getters and Setters |
||||
|
public String getSite() { |
||||
|
return site; |
||||
|
} |
||||
|
|
||||
|
public void setSite(String site) { |
||||
|
this.site = site; |
||||
|
} |
||||
|
|
||||
|
public String getBuNo() { |
||||
|
return buNo; |
||||
|
} |
||||
|
|
||||
|
public void setBuNo(String buNo) { |
||||
|
this.buNo = buNo; |
||||
|
} |
||||
|
|
||||
|
public String getWarehouseId() { |
||||
|
return warehouseId; |
||||
|
} |
||||
|
|
||||
|
public void setWarehouseId(String warehouseId) { |
||||
|
this.warehouseId = warehouseId; |
||||
|
} |
||||
|
|
||||
|
public String getUserName() { |
||||
|
return userName; |
||||
|
} |
||||
|
|
||||
|
public void setUserName(String userName) { |
||||
|
this.userName = userName; |
||||
|
} |
||||
|
|
||||
|
public String getReturnOrderNo() { |
||||
|
return returnOrderNo; |
||||
|
} |
||||
|
|
||||
|
public void setReturnOrderNo(String returnOrderNo) { |
||||
|
this.returnOrderNo = returnOrderNo; |
||||
|
} |
||||
|
|
||||
|
public String getIssueOrderNo() { |
||||
|
return issueOrderNo; |
||||
|
} |
||||
|
|
||||
|
public void setIssueOrderNo(String issueOrderNo) { |
||||
|
this.issueOrderNo = issueOrderNo; |
||||
|
} |
||||
|
|
||||
|
public String getOperationName() { |
||||
|
return operationName; |
||||
|
} |
||||
|
|
||||
|
public void setOperationName(String operationName) { |
||||
|
this.operationName = operationName; |
||||
|
} |
||||
|
|
||||
|
public String getRemark() { |
||||
|
return remark; |
||||
|
} |
||||
|
|
||||
|
public void setRemark(String remark) { |
||||
|
this.remark = remark; |
||||
|
} |
||||
|
|
||||
|
public List<LabelInfo> getLabelList() { |
||||
|
return labelList; |
||||
|
} |
||||
|
|
||||
|
public void setLabelList(List<LabelInfo> labelList) { |
||||
|
this.labelList = labelList; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,280 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.gaotao.modules.production.dao.ProductionIssueReturnMapper"> |
||||
|
|
||||
|
<!-- 搜索领料工单(模糊查询,top3) --> |
||||
|
<select id="searchIssueOrders" resultType="map"> |
||||
|
SELECT TOP ${limit} |
||||
|
so.site, |
||||
|
so.bu_no AS buNo, |
||||
|
so.order_no AS orderNo, |
||||
|
so.part_no AS partNo, |
||||
|
p.PartDescription AS partDesc, |
||||
|
sor.operation_no AS operationNo, |
||||
|
sor.seq_no AS seqNo, |
||||
|
sor.operation_desc AS operationName |
||||
|
FROM shop_order AS so |
||||
|
LEFT JOIN part AS p ON so.site = p.site AND so.part_no = p.partNo |
||||
|
LEFT JOIN shop_order_routing AS sor ON so.site = sor.site AND so.order_no = sor.order_no |
||||
|
WHERE so.site = #{site} |
||||
|
AND so.bu_no = #{buNo} |
||||
|
AND so.order_no LIKE '%' + #{searchKey} + '%' |
||||
|
AND so.status IN ('Released', 'Active') |
||||
|
ORDER BY so.order_no DESC |
||||
|
</select> |
||||
|
|
||||
|
<!-- 获取工单详情 --> |
||||
|
<select id="getOrderDetail" resultType="map"> |
||||
|
SELECT |
||||
|
so.site, |
||||
|
so.bu_no AS buNo, |
||||
|
so.order_no AS orderNo, |
||||
|
so.part_no AS partNo, |
||||
|
p.PartDescription AS partDesc |
||||
|
FROM shop_order AS so |
||||
|
LEFT JOIN part AS p ON so.site = p.site AND so.part_no = p.partNo |
||||
|
WHERE so.site = #{site} |
||||
|
AND so.bu_no = #{buNo} |
||||
|
AND so.order_no = #{orderNo} |
||||
|
</select> |
||||
|
|
||||
|
<!-- 获取工单的工序列表 --> |
||||
|
<select id="getOrderOperations" resultType="map"> |
||||
|
SELECT |
||||
|
sor.site, |
||||
|
sor.order_no AS orderNo, |
||||
|
sor.operation_no AS operationNo, |
||||
|
sor.seq_no AS seqNo, |
||||
|
sor.operation_desc AS operationName, |
||||
|
sor.item_no AS itemNo |
||||
|
FROM shop_order_routing AS sor |
||||
|
WHERE sor.site = #{site} |
||||
|
AND sor.order_no = #{orderNo} |
||||
|
ORDER BY sor.seq_no |
||||
|
</select> |
||||
|
|
||||
|
<!-- 根据标签条码查询库存信息 --> |
||||
|
<select id="getLabelInfo" resultType="map"> |
||||
|
SELECT |
||||
|
ist.site, |
||||
|
ist.bu_no AS buNo, |
||||
|
ist.roll_no AS rollNo, |
||||
|
ist.roll_no AS labelCode, |
||||
|
ist.part_no AS partNo, |
||||
|
p.PartDescription AS partDesc, |
||||
|
ist.qty_on_hand AS quantity, |
||||
|
ist.warehouse_id AS warehouseId, |
||||
|
ist.location_id AS locationId, |
||||
|
ist.label_type AS labelType |
||||
|
FROM inventory_stock AS ist |
||||
|
LEFT JOIN part AS p ON ist.site = p.site AND ist.part_no = p.partNo |
||||
|
WHERE ist.site = #{site} |
||||
|
AND ist.bu_no = #{buNo} |
||||
|
AND ist.warehouse_id = #{warehouseId} |
||||
|
AND ist.roll_no = #{labelCode} |
||||
|
</select> |
||||
|
|
||||
|
<!-- 生成申请单号 --> |
||||
|
<select id="generateNotifyNo" resultType="string" statementType="CALLABLE"> |
||||
|
{call getSerialNo(#{site, mode=IN, jdbcType=VARCHAR}, |
||||
|
#{buNo, mode=IN, jdbcType=VARCHAR}, |
||||
|
#{type, mode=IN, jdbcType=VARCHAR})} |
||||
|
</select> |
||||
|
|
||||
|
<!-- 生成过账单号 --> |
||||
|
<select id="generateTransId" resultType="string" statementType="CALLABLE"> |
||||
|
{call getSerialNo(#{site, mode=IN, jdbcType=VARCHAR}, |
||||
|
#{buNo, mode=IN, jdbcType=VARCHAR}, |
||||
|
#{type, mode=IN, jdbcType=VARCHAR})} |
||||
|
</select> |
||||
|
|
||||
|
<!-- 保存领料申请单主表 --> |
||||
|
<insert id="saveNotifyHeader"> |
||||
|
INSERT INTO SOIssueNotifyHeader ( |
||||
|
site, |
||||
|
bu_no, |
||||
|
notify_no, |
||||
|
notify_date, |
||||
|
entered_date, |
||||
|
user_name, |
||||
|
user_display, |
||||
|
remark, |
||||
|
plan_issue_date, |
||||
|
status |
||||
|
) VALUES ( |
||||
|
#{site}, |
||||
|
#{buNo}, |
||||
|
#{notifyNo}, |
||||
|
GETDATE(), |
||||
|
GETDATE(), |
||||
|
#{userName}, |
||||
|
#{userName}, |
||||
|
#{remark}, |
||||
|
GETDATE(), |
||||
|
'已完成' |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<!-- 保存领料申请单明细 --> |
||||
|
<insert id="saveNotifyOrderList"> |
||||
|
INSERT INTO SOIssueNotifyOrderList ( |
||||
|
notify_no, |
||||
|
site, |
||||
|
item_no, |
||||
|
fg_part_no, |
||||
|
so_order_no, |
||||
|
ops_item_no, |
||||
|
seq_no, |
||||
|
issure_qty, |
||||
|
out_work_order_flag, |
||||
|
need_date, |
||||
|
location_no, |
||||
|
resource_id |
||||
|
) VALUES ( |
||||
|
#{notifyNo}, |
||||
|
#{site}, |
||||
|
#{itemNo}, |
||||
|
#{fgPartNo}, |
||||
|
#{soOrderNo}, |
||||
|
#{opsItemNo}, |
||||
|
#{seqNo}, |
||||
|
#{issureQty}, |
||||
|
'N', |
||||
|
GETDATE(), |
||||
|
#{locationNo}, |
||||
|
#{resourceId} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<!-- 保存领料申请材料明细 --> |
||||
|
<insert id="saveNotifyMaterialList"> |
||||
|
INSERT INTO SOIssueNotifyOrderMaterialList ( |
||||
|
notify_no, |
||||
|
site, |
||||
|
item_no, |
||||
|
component_part_no, |
||||
|
part_desc, |
||||
|
qty_to_issue, |
||||
|
roll_no, |
||||
|
warehouse_id, |
||||
|
location_id, |
||||
|
issue_type |
||||
|
) VALUES ( |
||||
|
#{notifyNo}, |
||||
|
#{site}, |
||||
|
#{itemNo}, |
||||
|
#{componentPartNo}, |
||||
|
#{partDesc}, |
||||
|
#{qtyToIssue}, |
||||
|
#{rollNo}, |
||||
|
#{warehouseId}, |
||||
|
#{locationId}, |
||||
|
'正常' |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<!-- 保存过账单主表 --> |
||||
|
<insert id="saveTransHeader"> |
||||
|
INSERT INTO TransHeader ( |
||||
|
site, |
||||
|
bu_no, |
||||
|
trans_id, |
||||
|
trans_type, |
||||
|
trans_date, |
||||
|
status, |
||||
|
notify_no, |
||||
|
order_no, |
||||
|
user_name |
||||
|
) VALUES ( |
||||
|
#{site}, |
||||
|
#{buNo}, |
||||
|
#{transId}, |
||||
|
'ISSUE', |
||||
|
GETDATE(), |
||||
|
'已完成', |
||||
|
#{notifyNo}, |
||||
|
#{orderNo}, |
||||
|
#{userName} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<!-- 保存过账单明细 --> |
||||
|
<insert id="saveTransDetail"> |
||||
|
INSERT INTO TransDetail ( |
||||
|
site, |
||||
|
trans_id, |
||||
|
item_no, |
||||
|
part_no, |
||||
|
quantity, |
||||
|
warehouse_id, |
||||
|
location_id, |
||||
|
roll_no |
||||
|
) VALUES ( |
||||
|
#{site}, |
||||
|
#{transId}, |
||||
|
#{itemNo}, |
||||
|
#{partNo}, |
||||
|
#{quantity}, |
||||
|
#{warehouseId}, |
||||
|
#{locationId}, |
||||
|
#{rollNo} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<!-- 保存过账单子明细 --> |
||||
|
<insert id="saveTransDetailSub"> |
||||
|
INSERT INTO TransDetailSub ( |
||||
|
site, |
||||
|
trans_id, |
||||
|
item_no, |
||||
|
sub_item_no, |
||||
|
part_no, |
||||
|
quantity, |
||||
|
roll_no |
||||
|
) VALUES ( |
||||
|
#{site}, |
||||
|
#{transId}, |
||||
|
#{itemNo}, |
||||
|
#{subItemNo}, |
||||
|
#{partNo}, |
||||
|
#{quantity}, |
||||
|
#{rollNo} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<!-- 保存库存事务日志 --> |
||||
|
<insert id="saveStockTransactionLog"> |
||||
|
INSERT INTO StockTransactionLog ( |
||||
|
site, |
||||
|
bu_no, |
||||
|
trans_id, |
||||
|
trans_type, |
||||
|
trans_date, |
||||
|
part_no, |
||||
|
quantity, |
||||
|
warehouse_id, |
||||
|
location_id, |
||||
|
roll_no, |
||||
|
order_no, |
||||
|
notify_no, |
||||
|
user_name |
||||
|
) VALUES ( |
||||
|
#{site}, |
||||
|
#{buNo}, |
||||
|
#{transId}, |
||||
|
'ISSUE', |
||||
|
GETDATE(), |
||||
|
#{partNo}, |
||||
|
#{quantity}, |
||||
|
#{warehouseId}, |
||||
|
#{locationId}, |
||||
|
#{rollNo}, |
||||
|
#{orderNo}, |
||||
|
#{notifyNo}, |
||||
|
#{userName} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
</mapper> |
||||
|
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue