diff --git a/src/main/java/com/gaotao/modules/schedule/controller/ShiftAbnormalRollReportController.java b/src/main/java/com/gaotao/modules/schedule/controller/ShiftAbnormalRollReportController.java index e48c507..9114ba5 100644 --- a/src/main/java/com/gaotao/modules/schedule/controller/ShiftAbnormalRollReportController.java +++ b/src/main/java/com/gaotao/modules/schedule/controller/ShiftAbnormalRollReportController.java @@ -163,18 +163,36 @@ public class ShiftAbnormalRollReportController { } /** - * 异常续卷(更新数据) + * 异常续卷(更新数据 + 调用存储过程 + 返回打印数据) + * 流程: + * 1. 调用存储过程 updateWorkbenchCreateslittingrollAction + * 2. 保存 ProductionReport 和 SFDC_DefectHist(同产量报告) + * 3. 更新缓存数据为已处理 + * 4. 返回打印数据 */ @PostMapping("/continueRoll") public R continueRoll(@RequestBody Map params) { try { + // 基础参数 + String site = (String) params.get("site"); + String orderNo = (String) params.get("orderNo"); + Float itemNo = params.get("itemNo") != null ? Float.valueOf(params.get("itemNo").toString()) : 0f; + Integer seqNo = params.get("seqNo") != null ? Integer.valueOf(params.get("seqNo").toString()) : 0; + + // 存储过程参数 + String batchRollNo = (String) params.get("batchRollNo"); // 主卷号 + String rollNo = (String) params.get("rollNo"); // 分卷卷号 + Double rollQty = params.get("rollQty") != null ? Double.valueOf(params.get("rollQty").toString()) : 0.0; + String userid = (String) params.get("userid"); + String remark = (String) params.get("remark"); + String processedBy = (String) params.get("processedBy"); // 获取行数据列表 @SuppressWarnings("unchecked") List> rowDataList = (List>) params.get("rowDataList"); - // 构建实体列表 + // 构建实体列表(用于更新缓存数据) List entityList = new ArrayList<>(); if (rowDataList != null) { for (Map rowData : rowDataList) { @@ -189,12 +207,18 @@ public class ShiftAbnormalRollReportController { } } - // 更新数据 + // 1. 调用存储过程 + 2. 保存ProductionReport和SFDC_DefectHist + List> printList = shiftAbnormalRollReportService.executeAbnormalContinueRoll( + site, orderNo, itemNo, seqNo, batchRollNo, rollNo, rollQty, userid, remark, rowDataList); + + // 3. 更新缓存数据为已处理(设置 is_processed = 1) shiftAbnormalRollReportService.continueRoll(entityList, processedBy); + // 4. 返回打印数据 return R.ok() .put("code", 0) - .put("msg", "异常续卷数据更新成功"); + .put("msg", "异常续卷成功") + .put("printList", printList); } catch (Exception e) { return R.error(500, "操作失败:" + e.getMessage()); } diff --git a/src/main/java/com/gaotao/modules/schedule/mapper/ShiftAbnormalRollReportMapper.java b/src/main/java/com/gaotao/modules/schedule/mapper/ShiftAbnormalRollReportMapper.java index 1065e9e..b3c5a0d 100644 --- a/src/main/java/com/gaotao/modules/schedule/mapper/ShiftAbnormalRollReportMapper.java +++ b/src/main/java/com/gaotao/modules/schedule/mapper/ShiftAbnormalRollReportMapper.java @@ -85,13 +85,23 @@ public interface ShiftAbnormalRollReportMapper extends BaseMapper list, + int updateSingleRow( + @Param("id") Long id, + @Param("goodQty") java.math.BigDecimal goodQty, + @Param("defectQty") java.math.BigDecimal defectQty, + @Param("surfaceLossQty") java.math.BigDecimal surfaceLossQty, + @Param("poorPerformanceQty") java.math.BigDecimal poorPerformanceQty, + @Param("remark") String remark, @Param("processedBy") String processedBy); } diff --git a/src/main/java/com/gaotao/modules/schedule/service/ShiftAbnormalRollReportService.java b/src/main/java/com/gaotao/modules/schedule/service/ShiftAbnormalRollReportService.java index 4aa9ff8..edbecea 100644 --- a/src/main/java/com/gaotao/modules/schedule/service/ShiftAbnormalRollReportService.java +++ b/src/main/java/com/gaotao/modules/schedule/service/ShiftAbnormalRollReportService.java @@ -70,5 +70,24 @@ public interface ShiftAbnormalRollReportService extends IService dataList, String processedBy); + + /** + * 执行异常续卷存储过程(调用updateWorkbenchCreateslittingrollAction) + * @param site 工厂 + * @param orderNo 工单号 + * @param itemNo 工序号 + * @param seqNo 派工单号 + * @param batchRollNo 主卷号 + * @param rollNo 分卷卷号 + * @param rollQty 续卷数量 + * @param userid 操作用户 + * @param remark 备注 + * @param rowDataList 排数据列表 + * @return 打印数据列表 + */ + List> executeAbnormalContinueRoll(String site, String orderNo, Float itemNo, Integer seqNo, + String batchRollNo, String rollNo, + Double rollQty, String userid, String remark, + List> rowDataList); } diff --git a/src/main/java/com/gaotao/modules/schedule/service/impl/ShiftAbnormalRollReportServiceImpl.java b/src/main/java/com/gaotao/modules/schedule/service/impl/ShiftAbnormalRollReportServiceImpl.java index 4954103..fcaf804 100644 --- a/src/main/java/com/gaotao/modules/schedule/service/impl/ShiftAbnormalRollReportServiceImpl.java +++ b/src/main/java/com/gaotao/modules/schedule/service/impl/ShiftAbnormalRollReportServiceImpl.java @@ -1,14 +1,20 @@ package com.gaotao.modules.schedule.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gaotao.modules.schedule.entity.ProductionReportData; import com.gaotao.modules.schedule.entity.ShiftAbnormalRollReportEntity; +import com.gaotao.modules.schedule.mapper.ProcedureMapper; import com.gaotao.modules.schedule.mapper.ShiftAbnormalRollReportMapper; +import com.gaotao.modules.schedule.service.SchedulingService; import com.gaotao.modules.schedule.service.ShiftAbnormalRollReportService; 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; /** * 异常截卷未完成产量记录Service实现 @@ -21,6 +27,12 @@ public class ShiftAbnormalRollReportServiceImpl @Autowired private ShiftAbnormalRollReportMapper shiftAbnormalRollReportMapper; + @Autowired + private ProcedureMapper procedureMapper; + + @Autowired + private SchedulingService schedulingService; + @Override public List getUnprocessedData(String site, String orderNo, Integer seqNo) { return shiftAbnormalRollReportMapper.selectUnprocessedData(site, orderNo, seqNo); @@ -64,8 +76,79 @@ public class ShiftAbnormalRollReportServiceImpl @Transactional public void continueRoll(List dataList, String processedBy) { if (dataList != null && !dataList.isEmpty()) { - shiftAbnormalRollReportMapper.batchUpdateByRollNos(dataList, processedBy); + // 逐条更新,避免多语句SQL注入问题 + for (ShiftAbnormalRollReportEntity entity : dataList) { + shiftAbnormalRollReportMapper.updateSingleRow( + entity.getId(), + entity.getGoodQty(), + entity.getDefectQty(), + entity.getSurfaceLossQty(), + entity.getPoorPerformanceQty(), + entity.getRemark(), + processedBy + ); + } } } + + @Override + @Transactional + public List> executeAbnormalContinueRoll(String site, String orderNo, Float itemNo, Integer seqNo, + String batchRollNo, String rollNo, + Double rollQty, String userid, String remark, + List> rowDataList) { + // 1. 调用存储过程 updateWorkbenchCreateslittingrollAction + List params = new ArrayList<>(); + params.add(site); + params.add(batchRollNo); // 主卷号 + params.add(rollNo); // 分卷卷号 + params.add(rollQty); // 续卷数量 + params.add(userid); // 操作用户 + params.add(remark); // 备注 + + // 调用存储过程 + List> resultList = procedureMapper.getProcedureData("updateWorkbenchCreateslittingrollAction", params); + + // 2. 保存ProductionReport和SFDC_DefectHist(同产量报告) + if (rowDataList != null && !rowDataList.isEmpty()) { + List reportList = new ArrayList<>(); + for (Map rowData : rowDataList) { + ProductionReportData report = new ProductionReportData(); + report.setRowNumber(rowData.get("rowBumber") != null ? Integer.valueOf(rowData.get("rowBumber").toString()) : 0); + report.setGoodQty(rowData.get("goodQty") != null ? Float.valueOf(rowData.get("goodQty").toString()) : 0f); + report.setDefectQty(rowData.get("defectQty") != null ? Float.valueOf(rowData.get("defectQty").toString()) : 0f); + report.setSurfaceLossQty(rowData.get("surfaceLossQty") != null ? Float.valueOf(rowData.get("surfaceLossQty").toString()) : 0f); + report.setPoorPerformanceQty(rowData.get("poorPerformanceQty") != null ? Float.valueOf(rowData.get("poorPerformanceQty").toString()) : 0f); + report.setTotalQty(rowData.get("totalQty") != null ? Float.valueOf(rowData.get("totalQty").toString()) : 0f); + report.setRemark(rowData.get("remark") != null ? rowData.get("remark").toString() : ""); + reportList.add(report); + } + + // 调用保存方法 + schedulingService.saveProductionReportAndDefect(site, orderNo, itemNo, seqNo, rollNo, userid, reportList, batchRollNo); + } + + // 3. 构建打印数据 + List> printList = new ArrayList<>(); + if (resultList != null && !resultList.isEmpty()) { + for (Map result : resultList) { + Map printData = new HashMap<>(); + printData.put("rollNo", rollNo); + printData.put("rollQty", rollQty); + // 从存储过程返回结果中获取其他打印需要的数据 + printData.putAll(result); + printList.add(printData); + } + } else { + // 如果存储过程没有返回数据,构建基本的打印数据 + Map printData = new HashMap<>(); + printData.put("rollNo", rollNo); + printData.put("rollQty", rollQty); + printData.put("batchRollNo", batchRollNo); + printList.add(printData); + } + + return printList; + } } diff --git a/src/main/resources/mapper/schedule/SchedulingMapper.xml b/src/main/resources/mapper/schedule/SchedulingMapper.xml index 9bab4e8..4bd15d4 100644 --- a/src/main/resources/mapper/schedule/SchedulingMapper.xml +++ b/src/main/resources/mapper/schedule/SchedulingMapper.xml @@ -467,7 +467,7 @@ LEFT JOIN Site st ON st.SiteID = pt.Site AND sfr.Site = so.Site AND sfr.OrderNo = so.OrderNo - AND so.Site = pt.Site AND so.PartNo = pt.PartNo AND sfr.Site = #{site} AND sfr.OrderNo = #{orderNo} + AND so.Site = pt.Site AND so.PartNo = pt.PartNo AND sfr.Site = #{site} AND sfr.RollNo = #{rollNo} AND sfr.VirtualRollFlag = 'N' diff --git a/src/main/resources/mapper/schedule/ShiftAbnormalRollReportMapper.xml b/src/main/resources/mapper/schedule/ShiftAbnormalRollReportMapper.xml index f25f35c..9e63c8d 100644 --- a/src/main/resources/mapper/schedule/ShiftAbnormalRollReportMapper.xml +++ b/src/main/resources/mapper/schedule/ShiftAbnormalRollReportMapper.xml @@ -145,19 +145,18 @@ ORDER BY row_bumber ASC - - - - UPDATE shift_abnormal_roll_report - SET good_qty = #{item.goodQty}, - defect_qty = #{item.defectQty}, - surface_loss_qty = #{item.surfaceLossQty}, - poor_performance_qty = #{item.poorPerformanceQty}, - remark = #{item.remark}, - processed_by = #{processedBy}, - processed_time = GETDATE() - WHERE id = #{item.id} - + + + UPDATE shift_abnormal_roll_report + SET good_qty = #{goodQty}, + defect_qty = #{defectQty}, + surface_loss_qty = #{surfaceLossQty}, + poor_performance_qty = #{poorPerformanceQty}, + remark = #{remark}, + is_processed = 1, + processed_by = #{processedBy}, + processed_time = GETDATE() + WHERE id = #{id}