adsfasdfas
This commit is contained in:
3
rc_autoplc_backend/rczn-autoplc/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
3
rc_autoplc_backend/rczn-autoplc/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
wrapperVersion=3.3.4
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
|
||||
94
rc_autoplc_backend/rczn-autoplc/pom.xml
Normal file
94
rc_autoplc_backend/rczn-autoplc/pom.xml
Normal file
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.rczn</groupId>
|
||||
<artifactId>Rc-autoplc-backend</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>rczn-autoplc</artifactId>
|
||||
<name>rczn-autoplc</name>
|
||||
<description>rczn-autoplc(PLC业务模块)</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<!-- 依赖公共模块 -->
|
||||
<dependency>
|
||||
<groupId>com.rczn</groupId>
|
||||
<artifactId>rczn-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot 基础依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 如果需要Web功能 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>5.3.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||
<version>2.2.21</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>3.5.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>7.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 这里可以添加PLC通信相关的依赖 -->
|
||||
<!-- 例如:
|
||||
<dependency>
|
||||
<groupId>com.github.s7connector</groupId>
|
||||
<artifactId>s7connector</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip> <!-- 不作为可执行模块 -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.rczn.rcznautoplc.controller;
|
||||
|
||||
import com.rczn.rcznautoplc.domain.DevInfo;
|
||||
import com.rczn.rcznautoplc.service.DevInfoService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
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.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 设备信息 Controller(RESTful API)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/devInfo")
|
||||
@Tag(name = "设备管理", description = "设备增删改查+分页查询+全量查询接口")
|
||||
public class DevInfoController {
|
||||
|
||||
@Autowired
|
||||
private DevInfoService devInfoService;
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
*/
|
||||
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "新增设备", description = "设备名称为必填项,其他字段可选(非空则入库)")
|
||||
public ResponseEntity<Map<String, Object>> addDevInfo(
|
||||
@Parameter(name = "设备信息", description = "设备新增请求参数", required = true)
|
||||
@RequestBody DevInfo devInfo) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
boolean success = devInfoService.addDevInfo(devInfo);
|
||||
result.put("success", success);
|
||||
result.put("message", success ? "设备新增成功" : "设备新增失败");
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
result.put("message", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "服务器异常:" + e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID删除设备(逻辑删除)
|
||||
*/
|
||||
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "删除设备", description = "逻辑删除(设置delSign=1,不物理删除数据)")
|
||||
public ResponseEntity<Map<String, Object>> removeDevInfoById(
|
||||
@Parameter(name = "id", description = "设备ID", required = true, example = "1")
|
||||
@PathVariable Long id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
boolean success = devInfoService.removeDevInfoById(id);
|
||||
result.put("success", success);
|
||||
result.put("message", success ? "设备删除成功" : "设备不存在或已删除");
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
result.put("message", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "服务器异常:" + e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备
|
||||
*/
|
||||
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "修改设备", description = "需传入设备ID,其他字段可选(非空则更新)")
|
||||
public ResponseEntity<Map<String, Object>> updateDevInfo(
|
||||
@Parameter(name = "设备信息", description = "设备修改请求参数(含ID)", required = true)
|
||||
@RequestBody DevInfo devInfo) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
boolean success = devInfoService.updateDevInfo(devInfo);
|
||||
result.put("success", success);
|
||||
result.put("message", success ? "设备更新成功" : "设备不存在或已删除");
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
result.put("message", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "服务器异常:" + e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询设备
|
||||
*/
|
||||
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "查询单个设备", description = "根据设备ID查询设备完整信息")
|
||||
public ResponseEntity<Map<String, Object>> getDevInfoById(
|
||||
@Parameter(name = "id", description = "设备ID", required = true, example = "1")
|
||||
@PathVariable Long id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
DevInfo devInfo = devInfoService.getDevInfoById(id);
|
||||
if (devInfo != null) {
|
||||
result.put("success", true);
|
||||
result.put("data", devInfo);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "设备不存在或已删除");
|
||||
}
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
result.put("message", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "服务器异常:" + e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备
|
||||
* 示例:/devInfo/listPage?pageNum=1&pageSize=10&devName=设备1&status=0
|
||||
*/
|
||||
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "分页查询设备", description = "支持设备名称、型号、IP、状态等多条件过滤,默认查询未删除设备")
|
||||
@Parameters({
|
||||
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "devName", description = "设备名称(可选,模糊查询)", required = false, example = "PLC设备", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "devModel", description = "设备型号(可选,模糊查询)", required = false, example = "S7-1200", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "ipAddr", description = "IP地址(可选,精准查询)", required = false, example = "192.168.1.100", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "status", description = "设备状态(可选,精准查询:0-空闲,1-运行,4-故障)", required = false, example = "0", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "protocolType", description = "协议类型(可选,精准查询)", required = false, example = "Modbus", in = ParameterIn.QUERY)
|
||||
})
|
||||
public ResponseEntity<Map<String, Object>> getDevInfoPage(
|
||||
DevInfo devInfo, // 接收查询条件(devName、status等)
|
||||
@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
PageInfo<DevInfo> pageInfo = devInfoService.getDevInfoPage(devInfo, pageNum, pageSize);
|
||||
result.put("success", true);
|
||||
result.put("data", pageInfo);
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "服务器异常:" + e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有设备(不分页)
|
||||
*/
|
||||
@GetMapping(value = "/all", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "查询所有设备", description = "返回所有未删除的设备完整信息(不分页,适用于设备数量较少场景)")
|
||||
public ResponseEntity<Map<String, Object>> getAllDevInfo() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
List<DevInfo> devInfoList = devInfoService.getAllDevInfo();
|
||||
result.put("success", true);
|
||||
result.put("data", devInfoList);
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "服务器异常:" + e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DevInfo extends BaseBean {
|
||||
private String devName;
|
||||
|
||||
private String devModel;
|
||||
|
||||
private String ipAddr;
|
||||
|
||||
private Integer port;
|
||||
|
||||
private String protocolType;
|
||||
|
||||
private String company;
|
||||
|
||||
private Integer status; // 0-空闲,1-运行,4-故障
|
||||
|
||||
private String desc;
|
||||
|
||||
public DevInfo() {
|
||||
}
|
||||
|
||||
public DevInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
|
||||
super(id, createId, createTime, updateId, updateTime, delSign, remark);
|
||||
}
|
||||
|
||||
public String getDevName() {
|
||||
return devName;
|
||||
}
|
||||
|
||||
public void setDevName(String devName) {
|
||||
this.devName = devName;
|
||||
}
|
||||
|
||||
public String getDevModel() {
|
||||
return devModel;
|
||||
}
|
||||
|
||||
public void setDevModel(String devModel) {
|
||||
this.devModel = devModel;
|
||||
}
|
||||
|
||||
public String getIpAddr() {
|
||||
return ipAddr;
|
||||
}
|
||||
|
||||
public void setIpAddr(String ipAddr) {
|
||||
this.ipAddr = ipAddr;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getProtocolType() {
|
||||
return protocolType;
|
||||
}
|
||||
|
||||
public void setProtocolType(String protocolType) {
|
||||
this.protocolType = protocolType;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(String company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DevParam extends BaseBean {
|
||||
private Integer devId;
|
||||
|
||||
private String paramName;
|
||||
|
||||
private String paramValue;
|
||||
|
||||
private String desc;
|
||||
|
||||
private DevInfo devInfo;
|
||||
|
||||
public DevParam() {
|
||||
}
|
||||
|
||||
public DevParam(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
|
||||
super(id, createId, createTime, updateId, updateTime, delSign, remark);
|
||||
}
|
||||
|
||||
public Integer getDevId() {
|
||||
return devId;
|
||||
}
|
||||
|
||||
public void setDevId(Integer devId) {
|
||||
this.devId = devId;
|
||||
}
|
||||
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public void setParamName(String paramName) {
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
public String getParamValue() {
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
public void setParamValue(String paramValue) {
|
||||
this.paramValue = paramValue;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public DevInfo getDevInfo() {
|
||||
return devInfo;
|
||||
}
|
||||
|
||||
public void setDevInfo(DevInfo devInfo) {
|
||||
this.devInfo = devInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class FlowInfo extends BaseBean {
|
||||
private Integer flowIndex;
|
||||
|
||||
private String flowName;
|
||||
|
||||
private String islandIdList;
|
||||
|
||||
public FlowInfo() {
|
||||
}
|
||||
|
||||
public FlowInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
|
||||
super(id, createId, createTime, updateId, updateTime, delSign, remark);
|
||||
}
|
||||
|
||||
public Integer getFlowIndex() {
|
||||
return flowIndex;
|
||||
}
|
||||
|
||||
public void setFlowIndex(Integer flowIndex) {
|
||||
this.flowIndex = flowIndex;
|
||||
}
|
||||
|
||||
public String getFlowName() {
|
||||
return flowName;
|
||||
}
|
||||
|
||||
public void setFlowName(String flowName) {
|
||||
this.flowName = flowName;
|
||||
}
|
||||
|
||||
public String getIslandIdList() {
|
||||
return islandIdList;
|
||||
}
|
||||
|
||||
public void setIslandIdList(String islandIdList) {
|
||||
this.islandIdList = islandIdList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class GoodsFlowStatus extends BaseBean {
|
||||
private Integer goodsId;
|
||||
|
||||
private Integer flowId;
|
||||
|
||||
private Integer islandId;
|
||||
|
||||
private Integer flowSort;
|
||||
|
||||
private Integer status; // 0-未执行,1-执行,10-通过,11-失败
|
||||
|
||||
private GoodsInfo goodsInfo;
|
||||
|
||||
private FlowInfo flowInfo;
|
||||
|
||||
private IslandInfo islandInfo;
|
||||
|
||||
public GoodsFlowStatus() {
|
||||
}
|
||||
|
||||
public GoodsFlowStatus(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
|
||||
super(id, createId, createTime, updateId, updateTime, delSign, remark);
|
||||
}
|
||||
|
||||
public Integer getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(Integer goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public Integer getFlowId() {
|
||||
return flowId;
|
||||
}
|
||||
|
||||
public void setFlowId(Integer flowId) {
|
||||
this.flowId = flowId;
|
||||
}
|
||||
|
||||
public Integer getIslandId() {
|
||||
return islandId;
|
||||
}
|
||||
|
||||
public void setIslandId(Integer islandId) {
|
||||
this.islandId = islandId;
|
||||
}
|
||||
|
||||
public Integer getFlowSort() {
|
||||
return flowSort;
|
||||
}
|
||||
|
||||
public void setFlowSort(Integer flowSort) {
|
||||
this.flowSort = flowSort;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public GoodsInfo getGoodsInfo() {
|
||||
return goodsInfo;
|
||||
}
|
||||
|
||||
public void setGoodsInfo(GoodsInfo goodsInfo) {
|
||||
this.goodsInfo = goodsInfo;
|
||||
}
|
||||
|
||||
public FlowInfo getFlowInfo() {
|
||||
return flowInfo;
|
||||
}
|
||||
|
||||
public void setFlowInfo(FlowInfo flowInfo) {
|
||||
this.flowInfo = flowInfo;
|
||||
}
|
||||
|
||||
public IslandInfo getIslandInfo() {
|
||||
return islandInfo;
|
||||
}
|
||||
|
||||
public void setIslandInfo(IslandInfo islandInfo) {
|
||||
this.islandInfo = islandInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
|
||||
public class GoodsInfo extends BaseBean {
|
||||
private String goodsName;
|
||||
|
||||
private String goodsType;
|
||||
|
||||
private LocalDateTime incomeTime;
|
||||
|
||||
private String goodFrom;
|
||||
|
||||
private Integer goodBatch;
|
||||
|
||||
private String desc;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class IslandInfo extends BaseBean {
|
||||
private String islandName;
|
||||
|
||||
private String islandCode;
|
||||
|
||||
private String islandLogo;
|
||||
|
||||
private String desc;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
|
||||
public class IslandParam extends BaseBean {
|
||||
private Integer islandId;
|
||||
|
||||
private Integer stepId;
|
||||
|
||||
private String paramName;
|
||||
|
||||
private String paramType;
|
||||
|
||||
private String paramUnit;
|
||||
|
||||
private String paramValue;
|
||||
|
||||
private String formType;
|
||||
|
||||
private IslandInfo islandInfo;
|
||||
|
||||
private StepInfo stepInfo;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
|
||||
public class RecordInfo extends BaseBean {
|
||||
private String recordName;
|
||||
|
||||
private Integer recordType; // 1-设备异常,2-样品异常,3-操作异常
|
||||
|
||||
private Boolean recordStatus; // 0-未处理,1-已处理
|
||||
|
||||
private String recordContent;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.rczn.rcznautoplc.domain;
|
||||
|
||||
import com.rczn.domain.BaseBean;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
|
||||
public class StepInfo extends BaseBean {
|
||||
private Integer islandId;
|
||||
|
||||
private String stepName;
|
||||
|
||||
private String stepDesc;
|
||||
|
||||
private IslandInfo islandInfo;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.rczn.rcznautoplc.mapper;
|
||||
|
||||
import com.rczn.rcznautoplc.domain.DevInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备信息 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface DevInfoMapper {
|
||||
// 新增设备
|
||||
int insert(DevInfo devInfo);
|
||||
|
||||
// 逻辑删除设备(根据ID)
|
||||
int deleteById(@Param("id") Long id);
|
||||
|
||||
// 根据ID更新设备(非空字段才更新)
|
||||
int updateById(DevInfo devInfo);
|
||||
|
||||
// 根据ID查询设备(未删除)
|
||||
DevInfo selectById(@Param("id") Long id);
|
||||
|
||||
// 分页查询设备(支持多条件过滤)
|
||||
List<DevInfo> selectPage(DevInfo devInfo);
|
||||
|
||||
// 查询符合条件的设备总数(用于分页)
|
||||
int selectTotal(DevInfo devInfo);
|
||||
|
||||
// 查询所有未删除的设备(用于下拉选择等场景)
|
||||
List<DevInfo> selectAll();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.rczn.rcznautoplc.service;
|
||||
|
||||
import com.rczn.rcznautoplc.domain.DevInfo;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备信息 Service 接口
|
||||
*/
|
||||
public interface DevInfoService {
|
||||
// 新增设备
|
||||
boolean addDevInfo(DevInfo devInfo);
|
||||
|
||||
// 逻辑删除设备
|
||||
boolean removeDevInfoById(Long id);
|
||||
|
||||
// 更新设备
|
||||
boolean updateDevInfo(DevInfo devInfo);
|
||||
|
||||
// 根据ID查询设备
|
||||
DevInfo getDevInfoById(Long id);
|
||||
|
||||
// 分页查询设备
|
||||
PageInfo<DevInfo> getDevInfoPage(DevInfo devInfo, Integer pageNum, Integer pageSize);
|
||||
|
||||
// 查询所有设备
|
||||
List<DevInfo> getAllDevInfo();
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.rczn.rcznautoplc.service.impl;
|
||||
|
||||
import com.rczn.rcznautoplc.domain.DevInfo;
|
||||
import com.rczn.rcznautoplc.mapper.DevInfoMapper;
|
||||
import com.rczn.rcznautoplc.service.DevInfoService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备信息 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class DevInfoServiceImpl implements DevInfoService {
|
||||
|
||||
@Autowired
|
||||
private DevInfoMapper devInfoMapper;
|
||||
|
||||
@Override
|
||||
public boolean addDevInfo(DevInfo devInfo) {
|
||||
// 业务校验:设备名称不能为空
|
||||
Assert.notNull(devInfo.getDevName(), "设备名称不能为空");
|
||||
// 填充默认值(也可通过AOP统一填充)
|
||||
// devInfo.setCreateId(null);
|
||||
if (devInfo.getCreateTime() == null) {
|
||||
devInfo.setCreateTime(java.time.LocalDateTime.now());
|
||||
}
|
||||
// 调用Mapper新增
|
||||
return devInfoMapper.insert(devInfo) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeDevInfoById(Long id) {
|
||||
// 校验ID非空
|
||||
Assert.notNull(id, "设备ID不能为空");
|
||||
// 调用Mapper逻辑删除
|
||||
return devInfoMapper.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDevInfo(DevInfo devInfo) {
|
||||
// 校验ID和设备名称非空
|
||||
Assert.notNull(devInfo.getId(), "设备ID不能为空");
|
||||
Assert.notNull(devInfo.getDevName(), "设备名称不能为空");
|
||||
// 填充默认值(也可通过AOP统一填充)
|
||||
// devInfo.setUpdateId(null);
|
||||
if (devInfo.getUpdateTime() == null) {
|
||||
devInfo.setUpdateTime(java.time.LocalDateTime.now());
|
||||
}
|
||||
// 调用Mapper更新
|
||||
return devInfoMapper.updateById(devInfo) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevInfo getDevInfoById(Long id) {
|
||||
Assert.notNull(id, "设备ID不能为空");
|
||||
return devInfoMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<DevInfo> getDevInfoPage(DevInfo devInfo, Integer pageNum, Integer pageSize) {
|
||||
// 分页参数默认值
|
||||
if (pageNum == null) pageNum = 1;
|
||||
if (pageSize == null) pageSize = 10;
|
||||
// PageHelper开启分页
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
// 查询数据
|
||||
List<DevInfo> devInfoList = devInfoMapper.selectPage(devInfo);
|
||||
// 封装分页结果
|
||||
return new PageInfo<>(devInfoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevInfo> getAllDevInfo() {
|
||||
return devInfoMapper.selectAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
##spring.application.name=rczn-autoplc
|
||||
@@ -0,0 +1,172 @@
|
||||
<?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.DevInfoMapper">
|
||||
<!-- 通用字段(BaseBean继承) -->
|
||||
<sql id="baseColumn">
|
||||
id, create_id, create_time, update_id, update_time, del_sign, remark
|
||||
</sql>
|
||||
|
||||
<!-- 设备专属字段 -->
|
||||
<sql id="devColumn">
|
||||
dev_name, dev_model, ip_addr, port, protocol_type, company, status, `desc`
|
||||
</sql>
|
||||
|
||||
<!-- 结果集映射(下划线转驼峰已开启,可简化) -->
|
||||
<resultMap id="DevResultMap" type="com.rczn.rcznautoplc.domain.DevInfo">
|
||||
<id column="id" property="id"/>
|
||||
<!-- 通用字段 -->
|
||||
<result column="create_id" property="createId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_id" property="updateId"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="del_sign" property="delSign"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<!-- 设备专属字段 -->
|
||||
<result column="dev_name" property="devName"/>
|
||||
<result column="dev_model" property="devModel"/>
|
||||
<result column="ip_addr" property="ipAddr"/>
|
||||
<result column="port" property="port"/>
|
||||
<result column="protocol_type" property="protocolType"/>
|
||||
<result column="company" property="company"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="`desc`" property="desc"/> <!-- desc是MySQL关键字,需用反引号包裹 -->
|
||||
</resultMap>
|
||||
|
||||
<!-- 新增设备(空字段忽略) -->
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO tb_dev_info (
|
||||
<trim prefix="" suffix="" suffixOverrides=",">
|
||||
<!-- 专属字段 -->
|
||||
<if test="devName != null and devName != ''">dev_name,</if>
|
||||
<if test="devModel != null and devModel != ''">dev_model,</if>
|
||||
<if test="ipAddr != null and ipAddr != ''">ip_addr,</if>
|
||||
<if test="port != null">port,</if>
|
||||
<if test="protocolType != null and protocolType != ''">protocol_type,</if>
|
||||
<if test="company != null and company != ''">company,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="desc != null and desc != ''">`desc`,</if>
|
||||
<!-- 通用字段 -->
|
||||
<if test="createId != null">create_id,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateId != null">update_id,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
</trim>
|
||||
) VALUES (
|
||||
<trim prefix="" suffix="" suffixOverrides=",">
|
||||
<!-- 专属字段 -->
|
||||
<if test="devName != null and devName != ''">#{devName},</if>
|
||||
<if test="devModel != null and devModel != ''">#{devModel},</if>
|
||||
<if test="ipAddr != null and ipAddr != ''">#{ipAddr},</if>
|
||||
<if test="port != null">#{port},</if>
|
||||
<if test="protocolType != null and protocolType != ''">#{protocolType},</if>
|
||||
<if test="company != null and company != ''">#{company},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="desc != null and desc != ''">#{desc},</if>
|
||||
<!-- 通用字段 -->
|
||||
<if test="createId != null">#{createId},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateId != null">#{updateId},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
</trim>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 逻辑删除设备 -->
|
||||
<update id="deleteById">
|
||||
UPDATE sys_dev_info
|
||||
SET del_sign = 1, update_time = NOW()
|
||||
WHERE id = #{id} AND del_sign = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID更新设备(非空字段才更新) -->
|
||||
<update id="updateById">
|
||||
UPDATE sys_dev_info
|
||||
<set>
|
||||
<if test="devName != null and devName != ''">dev_name = #{devName},</if>
|
||||
<if test="devModel != null and devModel != ''">dev_model = #{devModel},</if>
|
||||
<if test="ipAddr != null and ipAddr != ''">ip_addr = #{ipAddr},</if>
|
||||
<if test="port != null">port = #{port},</if>
|
||||
<if test="protocolType != null and protocolType != ''">protocol_type = #{protocolType},</if>
|
||||
<if test="company != null and company != ''">company = #{company},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="desc != null and desc != ''">`desc` = #{desc},</if>
|
||||
<if test="updateId != null">update_id = #{updateId},</if>
|
||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id} AND del_sign = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据ID查询设备 -->
|
||||
<select id="selectById" resultMap="DevResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumn"/>,
|
||||
<include refid="devColumn"/>
|
||||
FROM sys_dev_info
|
||||
WHERE id = #{id} AND del_sign = 0
|
||||
</select>
|
||||
|
||||
<!-- 分页查询设备(多条件过滤) -->
|
||||
<select id="selectPage" resultMap="DevResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumn"/>,
|
||||
<include refid="devColumn"/>
|
||||
FROM sys_dev_info
|
||||
WHERE del_sign = 0
|
||||
<!-- 设备名称模糊查询 -->
|
||||
<if test="devName != null and devName != ''">
|
||||
AND dev_name LIKE CONCAT('%', #{devName}, '%')
|
||||
</if>
|
||||
<!-- 设备型号模糊查询 -->
|
||||
<if test="devModel != null and devModel != ''">
|
||||
AND dev_model LIKE CONCAT('%', #{devModel}, '%')
|
||||
</if>
|
||||
<!-- IP地址精准查询 -->
|
||||
<if test="ipAddr != null and ipAddr != ''">
|
||||
AND ip_addr = #{ipAddr}
|
||||
</if>
|
||||
<!-- 设备状态精准查询 -->
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<!-- 协议类型精准查询 -->
|
||||
<if test="protocolType != null and protocolType != ''">
|
||||
AND protocol_type = #{protocolType}
|
||||
</if>
|
||||
ORDER BY update_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询符合条件的设备总数 -->
|
||||
<select id="selectTotal" resultType="java.lang.Integer">
|
||||
SELECT COUNT(id)
|
||||
FROM sys_dev_info
|
||||
WHERE del_sign = 0
|
||||
<if test="devName != null and devName != ''">
|
||||
AND dev_name LIKE CONCAT('%', #{devName}, '%')
|
||||
</if>
|
||||
<if test="devModel != null and devModel != ''">
|
||||
AND dev_model LIKE CONCAT('%', #{devModel}, '%')
|
||||
</if>
|
||||
<if test="ipAddr != null and ipAddr != ''">
|
||||
AND ip_addr = #{ipAddr}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="protocolType != null and protocolType != ''">
|
||||
AND protocol_type = #{protocolType}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 查询所有未删除的设备 -->
|
||||
<select id="selectAll" resultMap="DevResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumn"/>,
|
||||
<include refid="devColumn"/>
|
||||
FROM sys_dev_info
|
||||
WHERE del_sign = 0
|
||||
ORDER BY id ASC
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user