From 7bd28b09838b312365e0b2a799a3b5c9ef53d1fa Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Wed, 3 Dec 2025 09:55:21 +0800 Subject: [PATCH] =?UTF-8?q?2025-12-03=201=E3=80=81=E5=A2=9E=E5=8A=A0"?= =?UTF-8?q?=E6=8D=A2=E7=8F=AD=E7=BB=93=E8=BD=AC"=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=9A=E4=BA=A7=E9=87=8F=E6=8A=A5=E5=91=8A=E3=80=81=E6=8D=A2?= =?UTF-8?q?=E7=8F=AD=E7=BB=93=E8=BD=AC=E3=80=81=E5=85=B3=E9=97=AD=20=20=20?= =?UTF-8?q?=20=20=20=20=20=201.1=20=20=20=E5=8F=AA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=88=B0shift=5Fchange=5Fproduction=5Freport=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E8=B5=B0=E4=B9=8B=E5=89=8D=E7=9A=84=E4=BF=9D=E5=AD=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91=202=E3=80=81=E6=AF=8F=E6=AC=A1=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=88=86=E5=8D=B7=E6=97=B6=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AEsite+order=5Fno=20+=20seq=5Fno=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=87=BAis=5Fprocessed=20=3D=200=E7=9A=84=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E6=95=B0=E6=8D=AE=E5=B9=B6=E8=B5=8B=E5=80=BC?= =?UTF-8?q?=E5=88=B0=E5=89=8D=E5=8F=B0=E7=95=8C=E9=9D=A2=203=E3=80=81?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=89=8D=E6=A0=A1=E9=AA=8C=E8=BF=99=E4=BA=9B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A1=AB=E5=86=99=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E5=A4=A7=E4=BA=8E=E7=AD=89=E4=BA=8Eshift=5Fc?= =?UTF-8?q?hange=5Fproduction=5Freport=E8=A1=A8=E4=B8=AD=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=204=E3=80=81=E4=BF=9D=E5=AD=98=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=A0=B9=E6=8D=AE=E6=9D=A1=E4=BB=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0shift=5Fchange=5Fproduction=5Freport=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?is=5Fprocessed=20=3D=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ShiftChangeProductionReportController.java | 154 ++++++++++++++++++ .../ShiftChangeProductionReportEntity.java | 126 ++++++++++++++ .../ShiftChangeProductionReportMapper.java | 63 +++++++ .../ShiftChangeProductionReportService.java | 49 ++++++ ...hiftChangeProductionReportServiceImpl.java | 53 ++++++ .../ShiftChangeProductionReportMapper.xml | 91 +++++++++++ 6 files changed, 536 insertions(+) create mode 100644 src/main/java/com/gaotao/modules/schedule/controller/ShiftChangeProductionReportController.java create mode 100644 src/main/java/com/gaotao/modules/schedule/entity/ShiftChangeProductionReportEntity.java create mode 100644 src/main/java/com/gaotao/modules/schedule/mapper/ShiftChangeProductionReportMapper.java create mode 100644 src/main/java/com/gaotao/modules/schedule/service/ShiftChangeProductionReportService.java create mode 100644 src/main/java/com/gaotao/modules/schedule/service/impl/ShiftChangeProductionReportServiceImpl.java create mode 100644 src/main/resources/mapper/schedule/ShiftChangeProductionReportMapper.xml diff --git a/src/main/java/com/gaotao/modules/schedule/controller/ShiftChangeProductionReportController.java b/src/main/java/com/gaotao/modules/schedule/controller/ShiftChangeProductionReportController.java new file mode 100644 index 0000000..adae052 --- /dev/null +++ b/src/main/java/com/gaotao/modules/schedule/controller/ShiftChangeProductionReportController.java @@ -0,0 +1,154 @@ +package com.gaotao.modules.schedule.controller; + +import com.gaotao.common.utils.R; +import com.gaotao.modules.schedule.entity.ShiftChangeProductionReportEntity; +import com.gaotao.modules.schedule.service.ShiftChangeProductionReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 换班结转未完成产量记录Controller + */ +@RestController +@RequestMapping("/schedule/shiftChange") +public class ShiftChangeProductionReportController { + + @Autowired + private ShiftChangeProductionReportService shiftChangeProductionReportService; + + /** + * 查询未处理的换班结转数据 + */ + @PostMapping("/getUnprocessedData") + public R getUnprocessedData(@RequestBody Map params) { + String site = (String) params.get("site"); + String orderNo = (String) params.get("orderNo"); + Integer seqNo = (Integer) params.get("seqNo"); + + List list = shiftChangeProductionReportService.getUnprocessedData(site, orderNo, seqNo); + + return R.ok() + .put("code", 0) + .put("data", list) + .put("count", list != null ? list.size() : 0); + } + + /** + * 保存换班结转数据 + */ + @PostMapping("/saveShiftChangeData") + public R saveShiftChangeData(@RequestBody Map params) { + try { + String site = (String) params.get("site"); + String buNo = (String) params.get("buNo"); + String orderNo = (String) params.get("orderNo"); + Integer seqNo = params.get("seqNo") != null ? Integer.valueOf(params.get("seqNo").toString()) : null; + String fixtureNo = (String) params.get("fixtureNo"); + String shiftFrom = (String) params.get("shiftFrom"); + String createdBy = (String) params.get("createdBy"); + Integer rowCount = params.get("rowCount") != null ? Integer.valueOf(params.get("rowCount").toString()) : 0; + Integer rollCount = params.get("rollCount") != null ? Integer.valueOf(params.get("rollCount").toString()) : 0; + + // 获取行数据列表 + @SuppressWarnings("unchecked") + List> rowDataList = (List>) params.get("rowDataList"); + + // 检查是否有缓存数据 + int cachedCount = shiftChangeProductionReportService.getCachedDataCount(site, orderNo, seqNo); + + // 如果有缓存数据,校验本次数据条数必须大于等于之前的数据 + if (cachedCount > 0 && rowDataList != null && rowDataList.size() < cachedCount) { + return R.error(400, "数据条数不能减少!当前缓存数据" + cachedCount + "条,本次提交" + rowDataList.size() + "条"); + } + + // 构建实体列表 + List entityList = new ArrayList<>(); + if (rowDataList != null) { + for (Map rowData : rowDataList) { + ShiftChangeProductionReportEntity entity = new ShiftChangeProductionReportEntity(); + entity.setSite(site); + entity.setBuNo(buNo); + entity.setOrderNo(orderNo); + entity.setSeqNo(seqNo); + entity.setFixtureNo(fixtureNo); + entity.setShiftFrom(shiftFrom); + entity.setRowCount(rowCount); + entity.setRollCount(rollCount); + entity.setRowBumber(rowData.get("rowNumber") != null ? Integer.valueOf(rowData.get("rowNumber").toString()) : 0); + entity.setGoodQty(rowData.get("goodQty") != null ? new BigDecimal(rowData.get("goodQty").toString()) : BigDecimal.ZERO); + entity.setDefectQty(rowData.get("defectQty") != null ? new BigDecimal(rowData.get("defectQty").toString()) : BigDecimal.ZERO); + entity.setSurfaceLossQty(rowData.get("surfaceLossQty") != null ? new BigDecimal(rowData.get("surfaceLossQty").toString()) : BigDecimal.ZERO); + entity.setPoorPerformanceQty(rowData.get("poorPerformanceQty") != null ? new BigDecimal(rowData.get("poorPerformanceQty").toString()) : BigDecimal.ZERO); + entity.setRemark(rowData.get("remark") != null ? rowData.get("remark").toString() : ""); + entity.setCreatedBy(createdBy); + entity.setIsProcessed(0); + + entityList.add(entity); + } + } + + // 保存数据 + shiftChangeProductionReportService.saveShiftChangeData(entityList, site, orderNo, seqNo); + + return R.ok() + .put("code", 0) + .put("msg", "换班结转数据保存成功"); + } catch (Exception e) { + return R.error(500, "保存失败:" + e.getMessage()); + } + } + + /** + * 更新换班结转数据为已处理(产量报告成功后调用) + */ + @PostMapping("/markAsProcessed") + public R markAsProcessed(@RequestBody Map params) { + try { + String site = (String) params.get("site"); + String orderNo = (String) params.get("orderNo"); + Integer seqNo = params.get("seqNo") != null ? Integer.valueOf(params.get("seqNo").toString()) : null; + String processedBy = (String) params.get("processedBy"); + + shiftChangeProductionReportService.markAsProcessed(site, orderNo, seqNo, processedBy); + + return R.ok() + .put("code", 0) + .put("msg", "数据已标记为已处理"); + } catch (Exception e) { + return R.error(500, "操作失败:" + e.getMessage()); + } + } + + /** + * 校验数据条数(用于产量报告前的校验) + */ + @PostMapping("/validateDataCount") + public R validateDataCount(@RequestBody Map params) { + try { + String site = (String) params.get("site"); + String orderNo = (String) params.get("orderNo"); + Integer seqNo = params.get("seqNo") != null ? Integer.valueOf(params.get("seqNo").toString()) : null; + Integer currentCount = params.get("currentCount") != null ? Integer.valueOf(params.get("currentCount").toString()) : 0; + + int cachedCount = shiftChangeProductionReportService.getCachedDataCount(site, orderNo, seqNo); + + // 如果有缓存数据,校验本次数据条数必须大于等于之前的数据 + if (cachedCount > 0 && currentCount < cachedCount) { + return R.error(400, "数据条数不能减少!当前缓存数据" + cachedCount + "条,本次提交" + currentCount + "条"); + } + + return R.ok() + .put("code", 0) + .put("cachedCount", cachedCount) + .put("hasCachedData", cachedCount > 0); + } catch (Exception e) { + return R.error(500, "校验失败:" + e.getMessage()); + } + } +} + diff --git a/src/main/java/com/gaotao/modules/schedule/entity/ShiftChangeProductionReportEntity.java b/src/main/java/com/gaotao/modules/schedule/entity/ShiftChangeProductionReportEntity.java new file mode 100644 index 0000000..6116c38 --- /dev/null +++ b/src/main/java/com/gaotao/modules/schedule/entity/ShiftChangeProductionReportEntity.java @@ -0,0 +1,126 @@ +package com.gaotao.modules.schedule.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 换班结转未完成产量记录表 + */ +@Data +@TableName("shift_change_production_report") +public class ShiftChangeProductionReportEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 工厂 + */ + private String site; + + /** + * 事业部 + */ + private String buNo; + + /** + * 工单号 + */ + private String orderNo; + + /** + * 派工单号 + */ + private Integer seqNo; + + /** + * 固定载具 + */ + private String fixtureNo; + + /** + * 来源班次(A/B/C) + */ + private String shiftFrom; + + /** + * 交接班次(系统自动计算) + */ + private String shiftTo; + + /** + * 排数 + */ + private Integer rowCount; + + /** + * 分切卷数 + */ + private Integer rollCount; + + /** + * NO.(行号) + */ + private Integer rowBumber; + + /** + * 良品数量 + */ + private BigDecimal goodQty; + + /** + * 不良数量(总计) + */ + private BigDecimal defectQty; + + /** + * 面损数量 + */ + private BigDecimal surfaceLossQty; + + /** + * 性能不良数量 + */ + private BigDecimal poorPerformanceQty; + + /** + * 备注信息 + */ + private String remark; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 处理状态:0未处理,1已处理 + */ + private Integer isProcessed; + + /** + * 处理人 + */ + private String processedBy; + + /** + * 处理时间 + */ + private Date processedTime; +} + diff --git a/src/main/java/com/gaotao/modules/schedule/mapper/ShiftChangeProductionReportMapper.java b/src/main/java/com/gaotao/modules/schedule/mapper/ShiftChangeProductionReportMapper.java new file mode 100644 index 0000000..f36b59b --- /dev/null +++ b/src/main/java/com/gaotao/modules/schedule/mapper/ShiftChangeProductionReportMapper.java @@ -0,0 +1,63 @@ +package com.gaotao.modules.schedule.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gaotao.modules.schedule.entity.ShiftChangeProductionReportEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 换班结转未完成产量记录Mapper + */ +@Mapper +@Repository +public interface ShiftChangeProductionReportMapper extends BaseMapper { + + /** + * 查询未处理的换班结转数据 + * @param site 工厂 + * @param orderNo 工单号 + * @param seqNo 派工单号 + * @return 未处理的换班结转数据列表 + */ + List selectUnprocessedData( + @Param("site") String site, + @Param("orderNo") String orderNo, + @Param("seqNo") Integer seqNo); + + /** + * 删除未处理的换班结转数据 + * @param site 工厂 + * @param orderNo 工单号 + * @param seqNo 派工单号 + * @return 删除的行数 + */ + int deleteUnprocessedData( + @Param("site") String site, + @Param("orderNo") String orderNo, + @Param("seqNo") Integer seqNo); + + /** + * 批量插入换班结转数据 + * @param list 换班结转数据列表 + * @return 插入的行数 + */ + int batchInsert(@Param("list") List list); + + /** + * 更新换班结转数据为已处理 + * @param site 工厂 + * @param orderNo 工单号 + * @param seqNo 派工单号 + * @param processedBy 处理人 + * @return 更新的行数 + */ + int updateToProcessed( + @Param("site") String site, + @Param("orderNo") String orderNo, + @Param("seqNo") Integer seqNo, + @Param("processedBy") String processedBy); +} + diff --git a/src/main/java/com/gaotao/modules/schedule/service/ShiftChangeProductionReportService.java b/src/main/java/com/gaotao/modules/schedule/service/ShiftChangeProductionReportService.java new file mode 100644 index 0000000..c6d3e17 --- /dev/null +++ b/src/main/java/com/gaotao/modules/schedule/service/ShiftChangeProductionReportService.java @@ -0,0 +1,49 @@ +package com.gaotao.modules.schedule.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gaotao.modules.schedule.entity.ShiftChangeProductionReportEntity; + +import java.util.List; + +/** + * 换班结转未完成产量记录Service + */ +public interface ShiftChangeProductionReportService extends IService { + + /** + * 查询未处理的换班结转数据 + * @param site 工厂 + * @param orderNo 工单号 + * @param seqNo 派工单号 + * @return 未处理的换班结转数据列表 + */ + List getUnprocessedData(String site, String orderNo, Integer seqNo); + + /** + * 保存换班结转数据(先删除旧数据,再插入新数据) + * @param dataList 换班结转数据列表 + * @param site 工厂 + * @param orderNo 工单号 + * @param seqNo 派工单号 + */ + void saveShiftChangeData(List dataList, String site, String orderNo, Integer seqNo); + + /** + * 更新换班结转数据为已处理 + * @param site 工厂 + * @param orderNo 工单号 + * @param seqNo 派工单号 + * @param processedBy 处理人 + */ + void markAsProcessed(String site, String orderNo, Integer seqNo, String processedBy); + + /** + * 检查是否有缓存数据 + * @param site 工厂 + * @param orderNo 工单号 + * @param seqNo 派工单号 + * @return 缓存数据条数 + */ + int getCachedDataCount(String site, String orderNo, Integer seqNo); +} + diff --git a/src/main/java/com/gaotao/modules/schedule/service/impl/ShiftChangeProductionReportServiceImpl.java b/src/main/java/com/gaotao/modules/schedule/service/impl/ShiftChangeProductionReportServiceImpl.java new file mode 100644 index 0000000..6873f6e --- /dev/null +++ b/src/main/java/com/gaotao/modules/schedule/service/impl/ShiftChangeProductionReportServiceImpl.java @@ -0,0 +1,53 @@ +package com.gaotao.modules.schedule.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gaotao.modules.schedule.entity.ShiftChangeProductionReportEntity; +import com.gaotao.modules.schedule.mapper.ShiftChangeProductionReportMapper; +import com.gaotao.modules.schedule.service.ShiftChangeProductionReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 换班结转未完成产量记录Service实现 + */ +@Service +public class ShiftChangeProductionReportServiceImpl + extends ServiceImpl + implements ShiftChangeProductionReportService { + + @Autowired + private ShiftChangeProductionReportMapper shiftChangeProductionReportMapper; + + @Override + public List getUnprocessedData(String site, String orderNo, Integer seqNo) { + return shiftChangeProductionReportMapper.selectUnprocessedData(site, orderNo, seqNo); + } + + @Override + @Transactional + public void saveShiftChangeData(List dataList, String site, String orderNo, Integer seqNo) { + // 先删除旧的未处理数据 + shiftChangeProductionReportMapper.deleteUnprocessedData(site, orderNo, seqNo); + + // 再批量插入新数据 + if (dataList != null && !dataList.isEmpty()) { + shiftChangeProductionReportMapper.batchInsert(dataList); + } + } + + @Override + @Transactional + public void markAsProcessed(String site, String orderNo, Integer seqNo, String processedBy) { + shiftChangeProductionReportMapper.updateToProcessed(site, orderNo, seqNo, processedBy); + } + + @Override + public int getCachedDataCount(String site, String orderNo, Integer seqNo) { + List list = shiftChangeProductionReportMapper.selectUnprocessedData(site, orderNo, seqNo); + return list != null ? list.size() : 0; + } +} + diff --git a/src/main/resources/mapper/schedule/ShiftChangeProductionReportMapper.xml b/src/main/resources/mapper/schedule/ShiftChangeProductionReportMapper.xml new file mode 100644 index 0000000..befd4a6 --- /dev/null +++ b/src/main/resources/mapper/schedule/ShiftChangeProductionReportMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + DELETE FROM shift_change_production_report + WHERE site = #{site} + AND order_no = #{orderNo} + AND seq_no = #{seqNo} + AND is_processed = 0 + + + + + INSERT INTO shift_change_production_report ( + site, bu_no, order_no, seq_no, fixture_no, shift_from, shift_to, + row_count, roll_count, row_bumber, good_qty, defect_qty, + surface_loss_qty, poor_performance_qty, remark, created_by, + created_time, is_processed + ) VALUES + + ( + #{item.site}, + #{item.buNo}, + #{item.orderNo}, + #{item.seqNo}, + #{item.fixtureNo}, + #{item.shiftFrom}, + #{item.shiftTo}, + #{item.rowCount}, + #{item.rollCount}, + #{item.rowBumber}, + #{item.goodQty}, + #{item.defectQty}, + #{item.surfaceLossQty}, + #{item.poorPerformanceQty}, + #{item.remark}, + #{item.createdBy}, + GETDATE(), + 0 + ) + + + + + + UPDATE shift_change_production_report + SET is_processed = 1, + processed_by = #{processedBy}, + processed_time = GETDATE() + WHERE site = #{site} + AND order_no = #{orderNo} + AND seq_no = #{seqNo} + AND is_processed = 0 + + + +