2026-4-30:

1.后端代码2次更新
This commit is contained in:
朱春声99
2026-05-18 16:19:28 +08:00
parent 2e9928725b
commit 6bce31c559
14 changed files with 516 additions and 103 deletions

View File

@@ -333,5 +333,4 @@ public class PlcController {
return Result.success(aBoolean);
}
}

View File

@@ -0,0 +1,89 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.RecordDeal;
import com.rczn.rcznautoplc.service.RecordDealService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/recordDeal")
@Tag(name = "异常处理记录管理", description = "异常处理记录增删改查+分页接口")
public class RecordDealController {
@Autowired
private RecordDealService recordDealService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询异常处理记录", description = "支持异常名称、类型、关联异常ID查询")
@Parameters({
@Parameter(name = "pageNum", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "recordId", description = "关联异常ID", required = false, in = ParameterIn.QUERY),
@Parameter(name = "recordName", description = "异常名称(模糊)", required = false, in = ParameterIn.QUERY),
@Parameter(name = "recordType", description = "类型 1设备2样品3操作", required = false, in = ParameterIn.QUERY)
})
public Result listPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer recordId,
@RequestParam(required = false) String recordName,
@RequestParam(required = false) Integer recordType) {
RecordDeal param = new RecordDeal();
param.setRecordId(recordId);
param.setRecordName(recordName);
param.setRecordType(recordType);
PageInfo<RecordDeal> page = recordDealService.selectPage(pageNum, pageSize, param);
return Result.success(page);
}
@GetMapping("/listByRecordId/{recordId}")
@Operation(summary = "根据异常ID查询处理记录")
public Result listByRecordId(@PathVariable Integer recordId) {
return Result.success(recordDealService.selectByRecordId(recordId));
}
@GetMapping("/getById/{id}")
@Operation(summary = "根据ID查询详情")
public Result getById(@PathVariable Long id) {
RecordDeal deal = recordDealService.selectById(id);
return deal != null ? Result.success(deal) : Result.error("记录不存在");
}
@PostMapping("/add")
@Operation(summary = "新增异常处理记录")
public Result add(@RequestBody RecordDeal recordDeal) {
try {
return Result.success(recordDealService.insert(recordDeal));
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping("/update")
@Operation(summary = "修改异常处理记录")
public Result update(@RequestBody RecordDeal recordDeal) {
try {
return Result.success(recordDealService.update(recordDeal));
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping("/del/{id}")
@Operation(summary = "删除处理记录(逻辑删除)")
public Result delete(@PathVariable Long id) {
try {
return Result.success(recordDealService.deleteById(id));
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -29,7 +29,7 @@ public class DevInfo extends BaseBean {
private String company;
private Integer status; // 0-空闲1-运行4-故障
private Integer status; //1:在线空闲 0:离线 2:忙碌 5故障
private Integer runModel;//0-手动模式1-自动模式

View File

@@ -15,6 +15,9 @@ public class IslandInfo extends BaseBean {
private String islandLogo;
//1:在线空闲 0:离线 2:忙碌 5故障
private Integer status;
private String desc;
public IslandInfo() {

View File

@@ -0,0 +1,60 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
/**
* 异常处理记录表
*/
public class RecordDeal extends BaseBean {
private Integer recordId; // 异常记录表ID
private String dealContent; // 处理内容
private String recordName; // 异常名称
private Integer recordType; // 异常类型 1-设备异常 2-样品异常 3-操作异常
public RecordDeal() {
}
public RecordDeal(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime,
boolean delSign, String remark, Integer recordId, String dealContent,
String recordName, Integer recordType) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
this.recordId = recordId;
this.dealContent = dealContent;
this.recordName = recordName;
this.recordType = recordType;
}
public Integer getRecordId() {
return recordId;
}
public void setRecordId(Integer recordId) {
this.recordId = recordId;
}
public String getDealContent() {
return dealContent;
}
public void setDealContent(String dealContent) {
this.dealContent = dealContent;
}
public String getRecordName() {
return recordName;
}
public void setRecordName(String recordName) {
this.recordName = recordName;
}
public Integer getRecordType() {
return recordType;
}
public void setRecordType(Integer recordType) {
this.recordType = recordType;
}
}

View File

@@ -5,6 +5,11 @@ import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class RecordInfo extends BaseBean {
private Integer islandId;//关联对应功能岛ID
private Integer devId;//关联对应设备ID
private String recordName;
private Integer recordType; // 1-设备异常2-样品异常3-操作异常
@@ -16,8 +21,31 @@ public class RecordInfo extends BaseBean {
public RecordInfo() {
}
public RecordInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
public RecordInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark, Integer islandId, Integer devId,
String recordName, Integer recordType, Boolean recordStatus, String recordContent) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
this.islandId = islandId;
this.devId = devId;
this.recordName = recordName;
this.recordType = recordType;
this.recordStatus = recordStatus;
this.recordContent = recordContent;
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
public String getRecordName() {

View File

@@ -0,0 +1,40 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.RecordDeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface RecordDealMapper {
/**
* 新增
*/
Long insert(RecordDeal recordDeal);
/**
* 修改
*/
Boolean update(RecordDeal recordDeal);
/**
* 逻辑删除
*/
Boolean deleteById(@Param("id") Long id);
/**
* 根据ID查询
*/
RecordDeal selectById(@Param("id") Long id);
/**
* 分页条件查询
*/
List<RecordDeal> selectPage(RecordDeal recordDeal);
/**
* 根据异常记录ID查询
*/
List<RecordDeal> selectByRecordId(@Param("recordId") Integer recordId);
}

View File

@@ -0,0 +1,20 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.RecordDeal;
import java.util.List;
public interface RecordDealService {
PageInfo<RecordDeal> selectPage(Integer pageNum, Integer pageSize, RecordDeal recordDeal);
RecordDeal selectById(Long id);
List<RecordDeal> selectByRecordId(Integer recordId);
Long insert(RecordDeal recordDeal);
Boolean update(RecordDeal recordDeal);
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,67 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.RecordDeal;
import com.rczn.rcznautoplc.mapper.RecordDealMapper;
import com.rczn.rcznautoplc.service.RecordDealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class RecordDealServiceImpl implements RecordDealService {
@Autowired
private RecordDealMapper recordDealMapper;
@Override
public PageInfo<RecordDeal> selectPage(Integer pageNum, Integer pageSize, RecordDeal recordDeal) {
PageHelper.startPage(pageNum, pageSize);
List<RecordDeal> list = recordDealMapper.selectPage(recordDeal);
return new PageInfo<>(list);
}
@Override
public RecordDeal selectById(Long id) {
if (id == null) {
throw new IllegalArgumentException("ID不能为空");
}
return recordDealMapper.selectById(id);
}
@Override
public List<RecordDeal> selectByRecordId(Integer recordId) {
if (recordId == null) {
throw new IllegalArgumentException("异常记录ID不能为空");
}
return recordDealMapper.selectByRecordId(recordId);
}
@Override
public Long insert(RecordDeal recordDeal) {
if (recordDeal.getRecordId() == null) {
throw new IllegalArgumentException("异常记录ID不能为空");
}
if (recordDeal.getDealContent() == null || recordDeal.getDealContent().trim().isEmpty()) {
throw new IllegalArgumentException("处理内容不能为空");
}
return recordDealMapper.insert(recordDeal);
}
@Override
public Boolean update(RecordDeal recordDeal) {
if (recordDeal.getId() == null) {
throw new IllegalArgumentException("ID不能为空");
}
return recordDealMapper.update(recordDeal);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) {
throw new IllegalArgumentException("ID不能为空");
}
return recordDealMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,81 @@
<?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.rczn.rcznautoplc.mapper.RecordDealMapper">
<!-- 基础字段 -->
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<!-- 业务字段 -->
<sql id="dealColumn">
record_id, deal_content, record_name, record_type
</sql>
<!-- 新增 -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_record_deal (
<include refid="dealColumn"/>,
create_id, create_time, update_id, update_time, del_sign
) VALUES (
#{recordId}, #{dealContent}, #{recordName}, #{recordType},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<!-- 修改 -->
<update id="update">
UPDATE tb_record_deal
<set>
<if test="recordId != null">record_id = #{recordId},</if>
<if test="dealContent != null and dealContent != ''">deal_content = #{dealContent},</if>
<if test="recordName != null and recordName != ''">record_name = #{recordName},</if>
<if test="recordType != null">record_type = #{recordType},</if>
<if test="updateId != null">update_id = #{updateId},</if>
update_time = NOW()
</set>
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 逻辑删除 -->
<update id="deleteById">
UPDATE tb_record_deal
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 根据ID查询 -->
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.RecordDeal">
SELECT
<include refid="baseColumn"/>,
<include refid="dealColumn"/>
FROM tb_record_deal
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 分页查询 -->
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.RecordDeal">
SELECT
<include refid="baseColumn"/>,
<include refid="dealColumn"/>
FROM tb_record_deal
WHERE del_sign = 0
<if test="recordId != null">AND record_id = #{recordId}</if>
<if test="recordName != null and recordName != ''">AND record_name LIKE CONCAT('%', #{recordName}, '%')</if>
<if test="recordType != null">AND record_type = #{recordType}</if>
ORDER BY create_time DESC
</select>
<!-- 根据异常记录ID查询 -->
<select id="selectByRecordId" resultType="com.rczn.rcznautoplc.domain.RecordDeal">
SELECT
<include refid="baseColumn"/>,
<include refid="dealColumn"/>
FROM tb_record_deal
WHERE del_sign = 0 AND record_id = #{recordId}
ORDER BY create_time DESC
</select>
</mapper>

View File

@@ -6,14 +6,14 @@
</sql>
<sql id="recordInfoColumn">
record_name, record_type, record_status, record_content
island_id, dev_id, record_name, record_type, record_status, record_content
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_record_info (
<include refid="recordInfoColumn"/>,
create_id, create_time, update_id, update_time, del_sign
) VALUES (
) VALUES (#{islandId}, #{devId},
#{recordName}, #{recordType}, #{recordStatus}, #{recordContent},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
@@ -22,6 +22,8 @@
<update id="update">
UPDATE tb_record_info
<set>
<if test="islandId != null">island_id = #{islandId},</if>
<if test="devId != null">dev_id = #{devId},</if>
<if test="recordName != null and recordName != ''">record_name = #{recordName},</if>
<if test="recordType != null">record_type = #{recordType},</if>
<if test="recordStatus != null">record_status = #{recordStatus},</if>