Browse Source

2025-12-03

1、增加"换班结转"按钮:产量报告、换班结转、关闭
        1.1   只保存到shift_change_production_report,不走之前的保存逻辑
2、每次点击创建分卷时,根据site+order_no + seq_no查询出is_processed = 0的,将对应数据并赋值到前台界面
3、保存前校验这些数据填写的数据必须大于等于shift_change_production_report表中的数据
4、保存通过后,根据条件更新shift_change_production_report表中is_processed = 1
master
fengyuan_yang 1 month ago
parent
commit
7bd28b0983
  1. 154
      src/main/java/com/gaotao/modules/schedule/controller/ShiftChangeProductionReportController.java
  2. 126
      src/main/java/com/gaotao/modules/schedule/entity/ShiftChangeProductionReportEntity.java
  3. 63
      src/main/java/com/gaotao/modules/schedule/mapper/ShiftChangeProductionReportMapper.java
  4. 49
      src/main/java/com/gaotao/modules/schedule/service/ShiftChangeProductionReportService.java
  5. 53
      src/main/java/com/gaotao/modules/schedule/service/impl/ShiftChangeProductionReportServiceImpl.java
  6. 91
      src/main/resources/mapper/schedule/ShiftChangeProductionReportMapper.xml

154
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<String, Object> params) {
String site = (String) params.get("site");
String orderNo = (String) params.get("orderNo");
Integer seqNo = (Integer) params.get("seqNo");
List<ShiftChangeProductionReportEntity> 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<String, Object> 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<Map<String, Object>> rowDataList = (List<Map<String, Object>>) 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<ShiftChangeProductionReportEntity> entityList = new ArrayList<>();
if (rowDataList != null) {
for (Map<String, Object> 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<String, Object> 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<String, Object> 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());
}
}
}

126
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;
}

63
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<ShiftChangeProductionReportEntity> {
/**
* 查询未处理的换班结转数据
* @param site 工厂
* @param orderNo 工单号
* @param seqNo 派工单号
* @return 未处理的换班结转数据列表
*/
List<ShiftChangeProductionReportEntity> 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<ShiftChangeProductionReportEntity> 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);
}

49
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<ShiftChangeProductionReportEntity> {
/**
* 查询未处理的换班结转数据
* @param site 工厂
* @param orderNo 工单号
* @param seqNo 派工单号
* @return 未处理的换班结转数据列表
*/
List<ShiftChangeProductionReportEntity> getUnprocessedData(String site, String orderNo, Integer seqNo);
/**
* 保存换班结转数据先删除旧数据再插入新数据
* @param dataList 换班结转数据列表
* @param site 工厂
* @param orderNo 工单号
* @param seqNo 派工单号
*/
void saveShiftChangeData(List<ShiftChangeProductionReportEntity> 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);
}

53
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<ShiftChangeProductionReportMapper, ShiftChangeProductionReportEntity>
implements ShiftChangeProductionReportService {
@Autowired
private ShiftChangeProductionReportMapper shiftChangeProductionReportMapper;
@Override
public List<ShiftChangeProductionReportEntity> getUnprocessedData(String site, String orderNo, Integer seqNo) {
return shiftChangeProductionReportMapper.selectUnprocessedData(site, orderNo, seqNo);
}
@Override
@Transactional
public void saveShiftChangeData(List<ShiftChangeProductionReportEntity> 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<ShiftChangeProductionReportEntity> list = shiftChangeProductionReportMapper.selectUnprocessedData(site, orderNo, seqNo);
return list != null ? list.size() : 0;
}
}

91
src/main/resources/mapper/schedule/ShiftChangeProductionReportMapper.xml

@ -0,0 +1,91 @@
<?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.schedule.mapper.ShiftChangeProductionReportMapper">
<!-- 查询未处理的换班结转数据 -->
<select id="selectUnprocessedData" resultType="com.gaotao.modules.schedule.entity.ShiftChangeProductionReportEntity">
SELECT
id,
site,
bu_no AS buNo,
order_no AS orderNo,
seq_no AS seqNo,
fixture_no AS fixtureNo,
shift_from AS shiftFrom,
shift_to AS shiftTo,
row_count,
roll_count AS rollCount,
row_bumber AS rowBumber,
good_qty AS goodQty,
defect_qty AS defectQty,
surface_loss_qty AS surfaceLossQty,
poor_performance_qty AS poorPerformanceQty,
remark,
created_by AS createdBy,
created_time AS createdTime,
is_processed AS isProcessed,
processed_by AS processedBy,
processed_time AS processedTime
FROM shift_change_production_report
WHERE site = #{site}
AND order_no = #{orderNo}
AND seq_no = #{seqNo}
AND is_processed = 0
ORDER BY row_bumber ASC
</select>
<!-- 删除未处理的换班结转数据 -->
<delete id="deleteUnprocessedData">
DELETE FROM shift_change_production_report
WHERE site = #{site}
AND order_no = #{orderNo}
AND seq_no = #{seqNo}
AND is_processed = 0
</delete>
<!-- 批量插入换班结转数据 -->
<insert id="batchInsert">
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
<foreach collection="list" item="item" separator=",">
(
#{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
)
</foreach>
</insert>
<!-- 更新换班结转数据为已处理 -->
<update id="updateToProcessed">
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
</update>
</mapper>
Loading…
Cancel
Save