Browse Source

2025-12-12

过站采集-》车间工作平台->创建分卷-》异常截卷功能
master
fengyuan_yang 1 month ago
parent
commit
0e0f5abe2b
  1. 131
      src/main/java/com/gaotao/modules/schedule/controller/ShiftAbnormalRollReportController.java
  2. 148
      src/main/java/com/gaotao/modules/schedule/entity/ShiftAbnormalRollReportEntity.java
  3. 63
      src/main/java/com/gaotao/modules/schedule/mapper/ShiftAbnormalRollReportMapper.java
  4. 49
      src/main/java/com/gaotao/modules/schedule/service/ShiftAbnormalRollReportService.java
  5. 53
      src/main/java/com/gaotao/modules/schedule/service/impl/ShiftAbnormalRollReportServiceImpl.java
  6. 100
      src/main/resources/mapper/schedule/ShiftAbnormalRollReportMapper.xml

131
src/main/java/com/gaotao/modules/schedule/controller/ShiftAbnormalRollReportController.java

@ -0,0 +1,131 @@
package com.gaotao.modules.schedule.controller;
import com.gaotao.common.utils.R;
import com.gaotao.modules.schedule.entity.ShiftAbnormalRollReportEntity;
import com.gaotao.modules.schedule.service.ShiftAbnormalRollReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 异常截卷未完成产量记录Controller
*/
@RestController
@RequestMapping("/schedule/abnormalRoll")
public class ShiftAbnormalRollReportController {
@Autowired
private ShiftAbnormalRollReportService shiftAbnormalRollReportService;
/**
* 查询未处理的异常截卷数据
*/
@PostMapping("/getUnprocessedData")
public R getUnprocessedData(@RequestBody Map<String, Object> params) {
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;
List<ShiftAbnormalRollReportEntity> list = shiftAbnormalRollReportService.getUnprocessedData(site, orderNo, seqNo);
return R.ok()
.put("code", 0)
.put("data", list)
.put("count", list != null ? list.size() : 0);
}
/**
* 保存异常截卷数据
*/
@PostMapping("/saveAbnormalRollData")
public R saveAbnormalRollData(@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;
// 新增字段
String currentRollNo = (String) params.get("currentRollNo");
String newRollNo = (String) params.get("newRollNo");
String operatorId = (String) params.get("operatorId");
// 获取行数据列表
@SuppressWarnings("unchecked")
List<Map<String, Object>> rowDataList = (List<Map<String, Object>>) params.get("rowDataList");
// 构建实体列表
List<ShiftAbnormalRollReportEntity> entityList = new ArrayList<>();
if (rowDataList != null) {
for (Map<String, Object> rowData : rowDataList) {
ShiftAbnormalRollReportEntity entity = new ShiftAbnormalRollReportEntity();
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);
// 新增字段
entity.setCurrentRollNo(currentRollNo);
entity.setNewRollNo(newRollNo);
entity.setOperatorId(operatorId);
entity.setOperationTime(new Date());
entityList.add(entity);
}
}
// 保存数据
shiftAbnormalRollReportService.saveAbnormalRollData(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");
shiftAbnormalRollReportService.markAsProcessed(site, orderNo, seqNo, processedBy);
return R.ok()
.put("code", 0)
.put("msg", "数据已标记为已处理");
} catch (Exception e) {
return R.error(500, "操作失败:" + e.getMessage());
}
}
}

148
src/main/java/com/gaotao/modules/schedule/entity/ShiftAbnormalRollReportEntity.java

@ -0,0 +1,148 @@
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_abnormal_roll_report")
public class ShiftAbnormalRollReportEntity 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;
// ========== 新增字段 ==========
/**
* 当前卷号机台工作台的当前卷号
*/
private String currentRollNo;
/**
* 新卷号产量报告返回的卷号
*/
private String newRollNo;
/**
* 操作人
*/
private String operatorId;
/**
* 操作时间
*/
private Date operationTime;
}

63
src/main/java/com/gaotao/modules/schedule/mapper/ShiftAbnormalRollReportMapper.java

@ -0,0 +1,63 @@
package com.gaotao.modules.schedule.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gaotao.modules.schedule.entity.ShiftAbnormalRollReportEntity;
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 ShiftAbnormalRollReportMapper extends BaseMapper<ShiftAbnormalRollReportEntity> {
/**
* 查询未处理的异常截卷数据
* @param site 工厂
* @param orderNo 工单号
* @param seqNo 派工单号
* @return 未处理的异常截卷数据列表
*/
List<ShiftAbnormalRollReportEntity> 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<ShiftAbnormalRollReportEntity> 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/ShiftAbnormalRollReportService.java

@ -0,0 +1,49 @@
package com.gaotao.modules.schedule.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gaotao.modules.schedule.entity.ShiftAbnormalRollReportEntity;
import java.util.List;
/**
* 异常截卷未完成产量记录Service
*/
public interface ShiftAbnormalRollReportService extends IService<ShiftAbnormalRollReportEntity> {
/**
* 查询未处理的异常截卷数据
* @param site 工厂
* @param orderNo 工单号
* @param seqNo 派工单号
* @return 未处理的异常截卷数据列表
*/
List<ShiftAbnormalRollReportEntity> getUnprocessedData(String site, String orderNo, Integer seqNo);
/**
* 保存异常截卷数据先删除旧数据再插入新数据
* @param dataList 异常截卷数据列表
* @param site 工厂
* @param orderNo 工单号
* @param seqNo 派工单号
*/
void saveAbnormalRollData(List<ShiftAbnormalRollReportEntity> 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/ShiftAbnormalRollReportServiceImpl.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.ShiftAbnormalRollReportEntity;
import com.gaotao.modules.schedule.mapper.ShiftAbnormalRollReportMapper;
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.List;
/**
* 异常截卷未完成产量记录Service实现
*/
@Service
public class ShiftAbnormalRollReportServiceImpl
extends ServiceImpl<ShiftAbnormalRollReportMapper, ShiftAbnormalRollReportEntity>
implements ShiftAbnormalRollReportService {
@Autowired
private ShiftAbnormalRollReportMapper shiftAbnormalRollReportMapper;
@Override
public List<ShiftAbnormalRollReportEntity> getUnprocessedData(String site, String orderNo, Integer seqNo) {
return shiftAbnormalRollReportMapper.selectUnprocessedData(site, orderNo, seqNo);
}
@Override
@Transactional
public void saveAbnormalRollData(List<ShiftAbnormalRollReportEntity> dataList, String site, String orderNo, Integer seqNo) {
// 先删除旧的未处理数据
shiftAbnormalRollReportMapper.deleteUnprocessedData(site, orderNo, seqNo);
// 再批量插入新数据
if (dataList != null && !dataList.isEmpty()) {
shiftAbnormalRollReportMapper.batchInsert(dataList);
}
}
@Override
@Transactional
public void markAsProcessed(String site, String orderNo, Integer seqNo, String processedBy) {
shiftAbnormalRollReportMapper.updateToProcessed(site, orderNo, seqNo, processedBy);
}
@Override
public int getCachedDataCount(String site, String orderNo, Integer seqNo) {
List<ShiftAbnormalRollReportEntity> list = shiftAbnormalRollReportMapper.selectUnprocessedData(site, orderNo, seqNo);
return list != null ? list.size() : 0;
}
}

100
src/main/resources/mapper/schedule/ShiftAbnormalRollReportMapper.xml

@ -0,0 +1,100 @@
<?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.ShiftAbnormalRollReportMapper">
<!-- 查询未处理的异常截卷数据 -->
<select id="selectUnprocessedData" resultType="com.gaotao.modules.schedule.entity.ShiftAbnormalRollReportEntity">
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,
current_roll_no AS currentRollNo,
new_roll_no AS newRollNo,
operator_id AS operatorId,
operation_time AS operationTime
FROM shift_abnormal_roll_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_abnormal_roll_report
WHERE site = #{site}
AND order_no = #{orderNo}
AND seq_no = #{seqNo}
AND is_processed = 0
</delete>
<!-- 批量插入异常截卷数据 -->
<insert id="batchInsert">
INSERT INTO shift_abnormal_roll_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,
current_roll_no, new_roll_no, operator_id, operation_time
) 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,
#{item.currentRollNo},
#{item.newRollNo},
#{item.operatorId},
GETDATE()
)
</foreach>
</insert>
<!-- 更新异常截卷数据为已处理 -->
<update id="updateToProcessed">
UPDATE shift_abnormal_roll_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