2026-4-30:

1.后端代码初始化
This commit is contained in:
朱春声99
2026-04-30 15:10:28 +08:00
parent 8bb8f4e30b
commit 0bc6dd7761
242 changed files with 27196 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package com.rczn.rcznautoplc.cache;
import java.util.HashMap;
import java.util.Map;
/**
* 1-功能岛>plc地址
* 2-动作单元>plc地址
* 3-参数名字>plc地址
* 三个映射关系Map表
*/
public class IsLandActionParamToPlc {
// 1-功能岛>plc地址:key-功能岛idvalue-功能岛plc地址
public static final Map<Integer, Integer> islandToPlc = new HashMap<>();
// 2-动作单元>plc地址:key-动作单元idvalue-动作单元plc地址
public static final Map<Integer, Integer> actionToPlc = new HashMap<>();
// 3-参数名字>plc地址:key-参数名字value-参数plc地址
public static final Map<String, Integer> paramToPlc = new HashMap<>();
//4-参数id>plc地址:key-参数idvalue-参数plc地址
public static final Map<Integer,Integer> paramIdToPlc = new HashMap<>();
//更新三种数据的方法
//获取spring里面bean
//1-功能岛>plc地址
}

View File

@@ -0,0 +1,110 @@
package com.rczn.rcznautoplc.cache;
//样品准备状态
public class PlcRunStatus {
//定容岛:状态属性:
public static int goodsScanStatus = 0; //货物扫描:0-准备1-扫描完毕
//plc系统运行状态
public static int systemPlcRunStatus = 0; //系统准备:0-未准备1-空闲2-忙4异常
public static int goodsCount = 0;//样品处理数量
public static int goodsCurrentIndex = 0;//当前样品处理索引
//404内照射项目默认样品尿液液体
public static String defaultGoodsName = "尿液";
public static String defaultGoodsType = "液体";
//目标监测物
public static String defaultGoalDetect = "总氮";
public static class PlcRunStatusResponse{
private int goodsScanStatus = 0; //货物扫描:0-准备1-扫描完毕
private int systemPlcRunStatus = 0; //系统准备:0-未准备1-空闲2-忙4异常
private int goodsCount = 0;//样品处理数量
private int goodsCurrentIndex = 0;//当前样品处理索引
private String defaultGoodsName = "尿液";//默认样品名称
private String defaultGoodsType = "液体";//默认样品类型
private String defaultGoalDetect = "总氮";//默认目标监测物
public PlcRunStatusResponse() {
}
public PlcRunStatusResponse(int goodsScanStatus, int systemPlcRunStatus, int goodsCount, int goodsCurrentIndex, String defaultGoodsName, String defaultGoodsType, String defaultGoalDetect) {
this.goodsScanStatus = goodsScanStatus;
this.systemPlcRunStatus = systemPlcRunStatus;
this.goodsCount = goodsCount;
this.goodsCurrentIndex = goodsCurrentIndex;
this.defaultGoodsName = defaultGoodsName;
this.defaultGoodsType = defaultGoodsType;
this.defaultGoalDetect = defaultGoalDetect;
}
public int getGoodsScanStatus() {
return goodsScanStatus;
}
public void setGoodsScanStatus(int goodsScanStatus) {
this.goodsScanStatus = goodsScanStatus;
}
public int getSystemPlcRunStatus() {
return systemPlcRunStatus;
}
public void setSystemPlcRunStatus(int systemPlcRunStatus) {
this.systemPlcRunStatus = systemPlcRunStatus;
}
public int getGoodsCount() {
return goodsCount;
}
public void setGoodsCount(int goodsCount) {
this.goodsCount = goodsCount;
}
public int getGoodsCurrentIndex() {
return goodsCurrentIndex;
}
public void setGoodsCurrentIndex(int goodsCurrentIndex) {
this.goodsCurrentIndex = goodsCurrentIndex;
}
public String getDefaultGoodsName() {
return defaultGoodsName;
}
public void setDefaultGoodsName(String defaultGoodsName) {
this.defaultGoodsName = defaultGoodsName;
}
public String getDefaultGoodsType() {
return defaultGoodsType;
}
public void setDefaultGoodsType(String defaultGoodsType) {
this.defaultGoodsType = defaultGoodsType;
}
public String getDefaultGoalDetect() {
return defaultGoalDetect;
}
public void setDefaultGoalDetect(String defaultGoalDetect) {
this.defaultGoalDetect = defaultGoalDetect;
}
}
}

View File

@@ -0,0 +1,17 @@
package com.rczn.rcznautoplc.cache;
public class RegisterAddrDic {
//主PLC寄存器地址
public final static int goodsScanRegisterArr = 5000;//样品扫描状态寄存器地址:
//整体运转状态:
public final static int wholeRunStatusRegisterArr = 1100;//整体运转状态寄存器地址:
//协议存储地址:
//1-下发plc样品sop指令协议寄存器地址
public final static int downProtcolRegisterArr = 2000;//协议存储寄存器地址:
//2-接收plc处理样品状态数据协议寄存器地址
public final static int upProtcolRegisterArr = 3000;//协议存储寄存器地址:
}

View File

@@ -0,0 +1,185 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.domain.Result;
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.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
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;
/**
* 设备信息 ControllerRESTful 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)
})
public Result getDevInfoPage(
@ParameterObject // 核心注解:标记该实体类从查询参数取值
@Schema(description = "设备查询条件(可选)") // 补充描述
DevInfo devInfo, // 接收查询条件devName、status等
@RequestParam Integer pageNum,
@RequestParam Integer pageSize) {
try {
PageInfo<DevInfo> pageInfo = devInfoService.getDevInfoPage(devInfo, pageNum, pageSize);
Result<PageInfo<DevInfo>> success = Result.success(pageInfo);
return success;
} catch (Exception e) {
return Result.error("数据库异常!");
}
}
/**
* 查询所有设备(不分页)
*/
@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);
}
}
}

View File

@@ -0,0 +1,161 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import com.rczn.rcznautoplc.service.DevParamService;
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.*;
import java.util.List;
@RestController
@RequestMapping("/devParam")
@Tag(name = "设备参数管理", description = "设备参数增删改查+分页查询接口")
public class DevParamController {
@Autowired
DevParamService devParamService;
/**
* 分页查询设备参数
*/
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询设备参数", description = "支持设备ID精准查询、参数名称/值模糊查询")
@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 = "devId", description = "设备ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramTypeData", description = "参数类型(可选,模糊查询)", required = false, example = "耗材,通用", in = ParameterIn.QUERY),
@Parameter(name = "paramName", description = "参数名称(可选,模糊查询)", required = false, example = "温度", in = ParameterIn.QUERY),
@Parameter(name = "paramValue", description = "参数值(可选,模糊查询)", required = false, example = "25", in = ParameterIn.QUERY)
})
public Result getDevParamPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer devId,
@RequestParam(required = false) String paramTypeData,
@RequestParam(required = false) String paramName,
@RequestParam(required = false) String paramValue) {
PageInfo<DevParam> pageBean = devParamService.selectPage(pageNum, pageSize, devId,paramTypeData, paramName, paramValue);
return Result.success(pageBean);
}
/**
* 根据条件,查询设备参数
*/
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询设备参数", description = "支持设备ID精准查询、参数名称/值模糊查询")
@Parameters({
@Parameter(name = "devId", description = "设备ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramTypeData", description = "参数类型(可选,模糊查询)", required = false, example = "耗材,通用", in = ParameterIn.QUERY),
@Parameter(name = "paramName", description = "参数名称(可选,模糊查询)", required = false, example = "温度", in = ParameterIn.QUERY),
@Parameter(name = "paramValue", description = "参数值(可选,模糊查询)", required = false, example = "25", in = ParameterIn.QUERY)
})
public Result getDevParamPage(
@RequestParam(required = false) Integer devId,
@RequestParam(required = false) String paramTypeData,
@RequestParam(required = false) String paramName,
@RequestParam(required = false) String paramValue) {
DevParamQuery query = new DevParamQuery();
query.setDevId(devId);
query.setParamTypeData(paramTypeData);
query.setParamName(paramName);
query.setParamValue(paramValue);
List<DevParam> pageBean = devParamService.selectList( query);
return Result.success(pageBean);
}
/**
* 根据条件,查询设备参数
*/
@PostMapping(value = "/addDevId", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "为参数增加设备的devId", description = "为参数增加设备的devId")
@Parameters({
@Parameter(name = "devId", description = "设备ID", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramId", description = "参数Id", required = true, example = "1", in = ParameterIn.QUERY)
})
public Result addDevId(
@RequestParam(required = true) Integer devId,
@RequestParam(required = true) Integer paramId) {
Boolean result = devParamService.addDevId( devId, paramId );
return Result.success(result);
}
/**
* 根据条件,查询设备参数
*/
@PostMapping(value = "/delDevId", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "为参数减少设备的devId", description = "为参数减少设备的devId")
@Parameters({
@Parameter(name = "devId", description = "设备ID", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramId", description = "参数Id", required = true, example = "1", in = ParameterIn.QUERY)
})
public Result delDevId(
@RequestParam(required = true) Integer devId,
@RequestParam(required = true) Integer paramId) {
Boolean result = devParamService.reduceDevId( devId, paramId );
return Result.success(result);
}
/**
* 根据ID查询设备参数
*/
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个设备参数", description = "根据设备参数ID查询详情")
public Result getDevParamById(@PathVariable Long id) {
DevParam devParam = devParamService.selectById(id);
return devParam != null ? Result.success(devParam) : Result.error("设备参数不存在");
}
/**
* 新增设备参数
*/
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增设备参数", description = "设备ID、参数名称为必填项")
public Result addDevParam(@RequestBody DevParam devParam) {
try {
Long devParamId = devParamService.insert(devParam);
return Result.success(devParamId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 修改设备参数
*/
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改设备参数", description = "需传入设备参数ID其他字段可选非空则更新")
public Result updateDevParam(@RequestBody DevParam devParam) {
try {
Boolean success = devParamService.update(devParam);
return success ? Result.success(true) : Result.error("修改失败(设备参数不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 删除设备参数(逻辑删除)
*/
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除设备参数", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteDevParam(@PathVariable Long id) {
try {
Boolean success = devParamService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(设备参数不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,143 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.FlowInfo;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.domain.UserBusy;
import com.rczn.rcznautoplc.service.FlowInfoService;
import com.rczn.rcznautoplc.service.ManageLogService;
import com.rczn.utils.ThreadLocalUtil;
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.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/flowInfo")
@Tag(name = "标准流程管理", description = "流程信息增删改查+分页查询接口")
public class FlowInfoController {
@Autowired
FlowInfoService flowInfoService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询流程信息", description = "支持流程排序精准查询、流程名称/岛屿ID列表模糊查询")
@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 = "flowIndex", description = "流程排序(可选,精准查询)", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "flowName", description = "流程名称(可选,模糊查询)", required = false, example = "检测流程", in = ParameterIn.QUERY),
@Parameter(name = "islandIdList", description = "岛屿ID列表可选模糊查询", required = false, example = "1,2,3", in = ParameterIn.QUERY)
})
public Result getFlowInfoPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer flowIndex,
@RequestParam(required = false) String flowName,
@RequestParam(required = false) String islandIdList) {
PageInfo<FlowInfo> pageBean = flowInfoService.selectPage(pageNum, pageSize, flowIndex, flowName, islandIdList);
return Result.success(pageBean);
}
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询流程信息", description = "支持流程排序精准查询、流程名称/岛屿ID列表模糊查询")
@Parameters({
@Parameter(name = "flowIndex", description = "流程排序(可选,精准查询)", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "flowName", description = "流程名称(可选,模糊查询)", required = false, example = "检测流程", in = ParameterIn.QUERY),
@Parameter(name = "islandIdList", description = "岛屿ID列表可选模糊查询", required = false, example = "1,2,3", in = ParameterIn.QUERY)
})
public Result getFlowInfoList(
@RequestParam(required = false) Integer flowIndex,
@RequestParam(required = false) String flowName,
@RequestParam(required = false) String islandIdList) {
List<FlowInfo> list = flowInfoService.selectList( flowIndex, flowName, islandIdList);
return Result.success(list);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个流程信息", description = "根据流程信息ID查询详情")
public Result getFlowInfoById(@PathVariable Long id) {
FlowInfo flowInfo = flowInfoService.selectById(id);
return flowInfo != null ? Result.success(flowInfo) : Result.error("流程信息不存在");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增流程信息", description = "流程名称、流程排序为必填项")
public Result addFlowInfo(@RequestBody FlowInfo flowInfo) {
try {
Long flowInfoId = flowInfoService.insert(flowInfo);
//记录操作样品执行SOP操作日志
LocalDateTime loginTime = LocalDateTime.now();
ManageLog info = new ManageLog();
// ========== 修复开始 ==========
Map<String, Object> mapClaims = ThreadLocalUtil.get();
UserBusy userBusy = new UserBusy();
userBusy.setId(Long.valueOf( mapClaims.get("id").toString()));
userBusy.setUserName((String) mapClaims.get("username"));
// ========== 修复结束 ==========
info.setCreateId(userBusy.getId());
info.setLogName("基础数据操作日志");
info.setLogType("基础数据操作日志");//1登录日志、2SOP操作日志、3基础数据操作日志
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("用户名:").append(userBusy.getUserName()).append("SOP配置添加操作时间").append(loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
info.setLogContent(stringBuilder.toString());
info.setCreateTime(loginTime);
manageLogService.insert(info);
return Result.success(flowInfoId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改流程信息", description = "需传入流程信息ID其他字段可选非空则更新")
public Result updateFlowInfo(@RequestBody FlowInfo flowInfo) {
try {
Boolean success = flowInfoService.update(flowInfo);
return success ? Result.success(true) : Result.error("修改失败(流程信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@Autowired
ManageLogService manageLogService;
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除流程信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteFlowInfo(@PathVariable Long id) {
try {
Boolean success = flowInfoService.deleteById(id);
//记录操作样品执行SOP操作日志
LocalDateTime loginTime = LocalDateTime.now();
ManageLog info = new ManageLog();
// ========== 修复开始 ==========
Map<String, Object> mapClaims = ThreadLocalUtil.get();
UserBusy userBusy = new UserBusy();
userBusy.setId(Long.valueOf( mapClaims.get("id").toString()));
userBusy.setUserName((String) mapClaims.get("username"));
// ========== 修复结束 ==========
info.setCreateId(userBusy.getId());
info.setLogName("基础数据操作日志");
info.setLogType("基础数据操作日志");//1登录日志、2SOP操作日志、3基础数据操作日志
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("用户名:").append(userBusy.getUserName()).append("SOP配置删除操作时间").append(loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
info.setLogContent(stringBuilder.toString());
info.setCreateTime(loginTime);
manageLogService.insert(info);
return success ? Result.success(true) : Result.error("删除失败(流程信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,98 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.query.GoodsFlowStatusQuery;
import com.rczn.rcznautoplc.service.GoodsFlowStatusService;
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.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/goodsFlowStatus")
@Tag(name = "样品流程信息管理", description = "样品流程状态增删改查+分页查询接口")
public class GoodsFlowStatusController {
@Autowired
GoodsFlowStatusService goodsFlowStatusService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询样品流程状态", description = "支持样品ID、流程ID、岛屿ID、状态精准查询")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
})
public Result getGoodsFlowStatusPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@ParameterObject
@Schema(description = "样品ID、流程ID、岛屿ID、状态精准查询条件")
GoodsFlowStatusQuery goodsFlowStatus) {
PageInfo<GoodsFlowStatus> pageBean = goodsFlowStatusService.selectPage(pageNum, pageSize, goodsFlowStatus);
return Result.success(pageBean);
}
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询样品流程状态", description = "支持样品ID、流程ID、岛屿ID、状态等精准查询")
@Parameters({
})
public Result getList(
@ParameterObject
@Schema(description = "样品ID、流程ID、岛屿ID、状态等精准查询条件")
GoodsFlowStatusQuery goodsFlowStatus) {
List<GoodsFlowStatus> list = goodsFlowStatusService.selectList( goodsFlowStatus);
return Result.success(list);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个样品流程状态", description = "根据样品流程状态ID查询详情")
public Result getGoodsFlowStatusById(@PathVariable Long id) {
GoodsFlowStatus goodsFlowStatus = goodsFlowStatusService.selectById(id);
return goodsFlowStatus != null ? Result.success(goodsFlowStatus) : Result.error("样品流程状态不存在");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增样品流程状态", description = "样品ID、流程ID、状态为必填项状态0-未执行1-执行10-通过11-失败)")
public Result addGoodsFlowStatus(@RequestBody GoodsFlowStatus goodsFlowStatus) {
try {
Long goodsFlowStatusId = goodsFlowStatusService.insert(goodsFlowStatus);
return Result.success(goodsFlowStatusId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改样品流程状态", description = "需传入样品流程状态ID其他字段可选非空则更新")
public Result updateGoodsFlowStatus(@RequestBody GoodsFlowStatus goodsFlowStatus) {
try {
Boolean success = goodsFlowStatusService.update(goodsFlowStatus);
return success ? Result.success(true) : Result.error("修改失败(样品流程状态不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除样品流程状态", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteGoodsFlowStatus(@PathVariable Long id) {
try {
Boolean success = goodsFlowStatusService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(样品流程状态不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,134 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import com.rczn.rcznautoplc.service.GoodsInfoService;
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.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/goodsInfo")
@Tag(name = "样品信息管理", description = "样品信息增删改查+分页查询接口")
public class GoodsInfoController {
@Autowired
GoodsInfoService goodsInfoService;
/**
* 分页查询样品信息
*/
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询样品信息", description = "支持样品名称/类型/来源模糊查询、批次精准查询")
@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 = "goodsName", description = "样品名称(可选,模糊查询)", required = false, example = "手机", in = ParameterIn.QUERY),
// @Parameter(name = "goodsType", description = "样品类型(可选,模糊查询)", required = false, example = "电子产品", in = ParameterIn.QUERY),
// @Parameter(name = "goodFrom", description = "样品来源(可选,模糊查询)", required = false, example = "深圳", in = ParameterIn.QUERY),
// @Parameter(name = "goodBatch", description = "样品批次(可选,精准查询)", required = false, example = "202501", in = ParameterIn.QUERY)
})
public Result getGoodsInfoPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@ParameterObject
@Schema(description = "样品信息查询条件(可选)", name = "goodsInfo", required = false)
GoodsInfoQuery goodsInfo) {
PageInfo<GoodsInfo> pageBean = goodsInfoService.selectPage(pageNum, pageSize, goodsInfo);
return Result.success(pageBean);
}
/**
* 查询样品信息
*/
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询样品信息", description = "支持样品名称/类型/来源模糊查询、批次精准查询")
@Parameters({
})
public Result getList(
@ParameterObject
@Schema(description = "样品信息查询条件(可选)", name = "goodsInfo", required = false)
GoodsInfoQuery goodsInfo) {
List<GoodsInfo> list = goodsInfoService.selectList( goodsInfo);
return Result.success(list);
}
/**
* 根据ID查询样品信息
*/
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个样品信息", description = "根据样品信息ID查询详情")
public Result getGoodsInfoById(@PathVariable Long id) {
GoodsInfo goodsInfo = goodsInfoService.selectById(id);
return goodsInfo != null ? Result.success(goodsInfo) : Result.error("样品信息不存在");
}
/**
* 新增样品信息
*/
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增样品信息", description = "样品名称、类型、入库时间为必填项")
public Result addGoodsInfo(@RequestBody GoodsInfo goodsInfo) {
try {
Long goodsInfoId = goodsInfoService.insert(goodsInfo);
return Result.success(goodsInfoId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 扫码新增样品信息
* 扫码信息:样品类型、样品编码、样品名称、样品点位
*/
@PostMapping(value = "/scanAdd", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "扫描新增样品", description = "样品名称、类型、编码、点位为必填项")
public Result scanAdd(@RequestBody GoodsInfo goodsInfo) {
try {
GoodsInfo goodInfoResult = goodsInfoService.insertByScan(goodsInfo);
return Result.success(goodInfoResult);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 修改样品信息
*/
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改样品信息", description = "需传入样品信息ID其他字段可选非空则更新")
public Result updateGoodsInfo(@RequestBody GoodsInfo goodsInfo) {
try {
Boolean success = goodsInfoService.update(goodsInfo);
return success ? Result.success(true) : Result.error("修改失败(样品信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 删除样品信息(逻辑删除)
*/
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除样品信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteGoodsInfo(@PathVariable Long id) {
try {
Boolean success = goodsInfoService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(样品信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,81 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.IslandInfo;
import com.rczn.rcznautoplc.service.IslandInfoService;
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("/islandInfo")
@Tag(name = "功能岛信息管理", description = "功能岛信息增删改查+分页查询接口")
public class IslandInfoController {
@Autowired
IslandInfoService islandInfoService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询功能岛信息", description = "支持功能岛名称、编码模糊查询")
@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 = "islandName", description = "功能岛名称(可选,模糊查询)", required = false, example = "一号岛", in = ParameterIn.QUERY),
@Parameter(name = "islandCode", description = "功能岛编码(可选,模糊查询)", required = false, example = "ISLAND001", in = ParameterIn.QUERY)
})
public Result getIslandInfoPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) String islandName,
@RequestParam(required = false) String islandCode) {
PageInfo<IslandInfo> pageBean = islandInfoService.selectPage(pageNum, pageSize, islandName, islandCode);
return Result.success(pageBean);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个功能岛信息", description = "根据功能岛信息ID查询详情")
public Result getIslandInfoById(@PathVariable Long id) {
IslandInfo islandInfo = islandInfoService.selectById(id);
return islandInfo != null ? Result.success(islandInfo) : Result.error("功能岛信息不存在");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增功能岛信息", description = "功能岛名称、编码为必填项")
public Result addIslandInfo(@RequestBody IslandInfo islandInfo) {
try {
Long islandInfoId = islandInfoService.insert(islandInfo);
return Result.success(islandInfoId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改功能岛信息", description = "需传入功能岛信息ID其他字段可选非空则更新")
public Result updateIslandInfo(@RequestBody IslandInfo islandInfo) {
try {
Boolean success = islandInfoService.update(islandInfo);
return success ? Result.success(true) : Result.error("修改失败(功能岛信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除功能岛信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteIslandInfo(@PathVariable Long id) {
try {
Boolean success = islandInfoService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(功能岛信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,86 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.IslandParam;
import com.rczn.rcznautoplc.service.IslandParamService;
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("/islandParam")
@Tag(name = "功能岛参数管理", description = "功能岛参数增删改查+分页查询接口")
public class IslandParamController {
@Autowired
IslandParamService islandParamService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询功能岛参数", description = "支持功能岛ID、步骤ID精准查询参数名称模糊查询、参数类型精准查询")
@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 = "islandId", description = "功能岛ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "stepId", description = "步骤ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramName", description = "参数名称(可选,模糊查询)", required = false, example = "温度", in = ParameterIn.QUERY),
@Parameter(name = "paramType", description = "参数类型(可选,精准查询)", required = false, example = "数值", in = ParameterIn.QUERY)
})
public Result getIslandParamPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer islandId,
@RequestParam(required = false) Integer stepId,
@RequestParam(required = false) String paramName,
@RequestParam(required = false) String paramType) {
PageInfo<IslandParam> pageBean = islandParamService.selectPage(pageNum, pageSize, islandId, stepId, paramName, paramType);
return Result.success(pageBean);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个功能岛参数", description = "根据功能岛参数ID查询详情")
public Result getIslandParamById(@PathVariable Long id) {
IslandParam islandParam = islandParamService.selectById(id);
return islandParam != null ? Result.success(islandParam) : Result.error("功能岛参数不存在");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增功能岛参数", description = "功能岛ID、步骤ID、参数名称为必填项")
public Result addIslandParam(@RequestBody IslandParam islandParam) {
try {
Long islandParamId = islandParamService.insert(islandParam);
return Result.success(islandParamId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改功能岛参数", description = "需传入功能岛参数ID其他字段可选非空则更新")
public Result updateIslandParam(@RequestBody IslandParam islandParam) {
try {
Boolean success = islandParamService.update(islandParam);
return success ? Result.success(true) : Result.error("修改失败(功能岛参数不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除功能岛参数", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteIslandParam(@PathVariable Long id) {
try {
Boolean success = islandParamService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(功能岛参数不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,120 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.service.ManageLogService;
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.format.annotation.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
@RestController
@RequestMapping("/manage-log")
@Tag(name = "操作日志管理", description = "操作日志增删改查+分页查询接口")
public class ManageLogController {
@Autowired
private ManageLogService manageLogService;
/**
* 分页查询日志
*/
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询操作日志", description = "支持多条件筛选,空条件自动忽略")
@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 = "logName", description = "日志名称(可选,模糊查询)", required = false, example = "登录操作", in = ParameterIn.QUERY),
@Parameter(name = "logType", description = "日志类型(可选,精准查询)", required = false, example = "LOGIN", in = ParameterIn.QUERY),
@Parameter(name = "createId", description = "创建人ID可选", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "logWritetimeStart", description = "日志开始时间可选格式yyyy-MM-dd HH:mm:ss", required = false, example = "2025-01-01 00:00:00", in = ParameterIn.QUERY),
@Parameter(name = "logWritetimeEnd", description = "日志结束时间可选格式yyyy-MM-dd HH:mm:ss", required = false, example = "2025-12-31 23:59:59", in = ParameterIn.QUERY)
})
public Result<PageBean<ManageLog>> getLogPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) String logName,
@RequestParam(required = false) String logType,
@RequestParam(required = false) Long createId,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime logWritetimeStart,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime logWritetimeEnd) {
// 构建查询条件(空字段自动忽略)
ManageLog query = new ManageLog();
query.setLogName(logName);
query.setLogType(logType);
query.setCreateId(createId);
// 扩展字段用于时间范围查询实体类无需新增字段MyBatis 支持直接取参)
query.setStartTime(logWritetimeStart); // 实际用 logWritetimeStart这里仅为传递参数
query.setEndTime(logWritetimeEnd);
PageBean<ManageLog> pageBean = manageLogService.selectPage(pageNum, pageSize, query);
return Result.success(pageBean);
}
/**
* 按 ID 查询日志
*/
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个操作日志", description = "按日志ID查询详情")
public Result getLogById(@PathVariable Long id) {
ManageLog log = manageLogService.selectById(id);
return log != null ? Result.success(log) : Result.error("日志不存在或已删除");
}
/**
* 新增操作日志
*/
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增操作日志", description = "日志名称、类型为必填项,其他字段可选")
public Result addLog(@RequestBody ManageLog manageLog) {
try {
Long logId = manageLogService.insert(manageLog);
return Result.success("日志新增成功");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 更新操作日志
*/
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "更新操作日志", description = "需传入日志ID其他字段非空则更新")
public Result updateLog(@RequestBody ManageLog manageLog) {
try {
Boolean success = manageLogService.update(manageLog);
return success ? Result.success( "日志更新成功") : Result.error("更新失败(日志不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 逻辑删除操作日志
*/
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除操作日志", description = "逻辑删除设置delSign=1不物理删除")
public Result deleteLog(
@PathVariable Long id,
@RequestParam(required = false) Long updateId) {
try {
Boolean success = manageLogService.deleteById(id, updateId);
return success ? Result.success("日志删除成功") : Result.error("删除失败(日志不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,337 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.domain.Result;
import com.rczn.modbus.Modbus4jWriteUtils;
import com.rczn.rcznautoplc.cache.PlcRunStatus;
import com.rczn.rcznautoplc.domain.*;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import com.rczn.rcznautoplc.service.*;
import com.rczn.rcznautoplc.utils.PlcConnectMap;
import com.rczn.utils.ThreadLocalUtil;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.code.DataType;
import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 设备信息 ControllerRESTful API
*/
@RestController
@RequestMapping("/plc")
@Tag(name = "plc设备控制类", description = "plc设备初始化查询控制方法集合")
public class PlcController {
@Autowired
private PlcService plcService;
/**
* 设备连接
*/
@PostMapping(value = "/connect", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "连接设备", description = "连接设备...")
public Result plcConnect(
@ParameterObject
@Schema(description = "plc设备参数")
ModbusConnectObj connectObj) {
ModbusMaster connectorInit;
if(PlcConnectMap.modbusConnectorMap.containsKey(connectObj.getIpAddr())){
return Result.error("设备连接已经存在!");
}
try {
connectorInit = plcService.connectModbus(connectObj);
if(connectorInit != null){
return Result.success(true);
}else {
return Result.error("设备连接失败!");
}
} catch (Exception e) {
return Result.error("设备连接失败!");
}
}
/**
* 向plc寄存器写数据
*/
@PostMapping(value = "/plcWrite", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "连接设备", description = "连接设备...")
public Result plcWrite(
@ParameterObject
@Schema(description = "plc设备参数")
ModbusConnectObj connectObj,
@Parameter
@Schema(description = "寄存器地址", required = true, example = "10000")
@RequestParam int registerAddress,
@Parameter
@Schema(description = "寄存器值", required = true, example = "12345")
@RequestParam int registerValue) {
ModbusMaster connectorInit;
if(PlcConnectMap.modbusConnectorMap.containsKey(connectObj.getIpAddr())){
connectorInit = PlcConnectMap.modbusConnectorMap.get(connectObj.getIpAddr());
try {
Modbus4jWriteUtils.writeHoldingRegister(connectorInit,1,registerAddress,registerValue, DataType.TWO_BYTE_INT_UNSIGNED);
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ErrorResponseException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
return Result.error("设备连接已经存在!");
}
try {
connectorInit = plcService.connectModbus(connectObj);
if(connectorInit != null){
//往地址1000里面写入数据
Modbus4jWriteUtils.writeHoldingRegister(connectorInit,1,registerAddress,registerValue, DataType.TWO_BYTE_INT_UNSIGNED);
return Result.success(true);
}else {
return Result.error("设备连接失败!");
}
} catch (Exception e) {
return Result.error("设备连接失败!");
}
}
/**
* 根据ID删除设备逻辑删除
*/
@PostMapping(value = "/run")
@Operation(summary = "运行plc", description = "plc设备运行停止")
public Result runPlc(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.startPlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据ID删除设备逻辑删除
*/
@PostMapping(value = "/pause")
@Operation(summary = "暂停运行plc", description = "暂停运行plc")
public Result pausePlc(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.pausePlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据设备ip地址停止执行
*/
@PostMapping(value = "/stop")
@Operation(summary = "停止plc", description = "plc设备运行停止")
public Result stop(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.stopPlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址故障复位
*/
@PostMapping(value = "/resetError")
@Operation(summary = "plc设备复位故障", description = "plc设备复位故障")
public Result resetError(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.resetErrorPlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址获取plc设备状态
*/
@GetMapping(value = "/plcStatus")
@Operation(summary = "plc设备获取状态值", description = "状态值10-就绪11-执行中12-暂停中19已停止20-故障中")
public Result plcStatus(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Integer resultValue = plcService.getPlcStatus(ipAddr);
return Result.success(resultValue);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址获取plc设备状态
*/
@GetMapping(value = "/mastertPlcStatus")
@Operation(summary = "获取主plc状态对象", description = "goodsScanStatus = 0; //货物扫描:0-准备1-扫描完毕;//系统准备:0-未准备1-空闲2-忙4异常")
public Result mastertPlcStatus() {
try {
PlcRunStatus.PlcRunStatusResponse response = new PlcRunStatus.PlcRunStatusResponse();
response.setGoodsScanStatus(PlcRunStatus.goodsScanStatus);
response.setSystemPlcRunStatus(PlcRunStatus.systemPlcRunStatus);
response.setGoodsCount(PlcRunStatus.goodsCount);
response.setGoodsCurrentIndex(PlcRunStatus.goodsCurrentIndex);
response.setDefaultGoodsName(PlcRunStatus.defaultGoodsName);
response.setDefaultGoodsType(PlcRunStatus.defaultGoodsType);
response.setDefaultGoalDetect(PlcRunStatus.defaultGoalDetect);
return Result.success(response);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址设置plc设备模式
* 0-手动模式1-自动模式
*/
@PostMapping(value = "/setModel")
@Operation(summary = "plc设备设置模式", description = "模式值0-手动模式1-自动模式")
public Result setModel(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123", in = ParameterIn.QUERY)
@RequestParam String ipAddr,
@Parameter(name = "model", description = "设备模式值", required = true, example = "0-1", in = ParameterIn.QUERY)
@RequestParam Integer model) {
try {
Boolean resultValue = plcService.setPlcModel(ipAddr,model);
return Result.success(resultValue);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址获取plc设备模式
* 0-手动模式1-自动模式
*/
@GetMapping(value = "/getModel")
@Operation(summary = "plc设备获取模式值", description = "模式值0-手动模式1-自动模式")
public Result getModel(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Integer resultValue = plcService.getPlcModel(ipAddr);
return Result.success(resultValue);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 更新设备
*/
@GetMapping(value = "/getAll", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "获取全部plc连接对象", description = "获取全部plc连接对象")
public Result getPlcAll() {
Map<String,ModbusMaster> connectorMap = plcService.modbusALlMap();
return Result.success(connectorMap);
}
/**
* 根据ID查询设备
*/
@GetMapping(value = "/getPlcByIp", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "更加ip地址查询plc连接对象", description = "更加ip地址查询plc连接对象")
public Result getConnectByIpaddr(
@Parameter(name = "ipAddr", description = "设备IP", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
ModbusMaster connector = plcService.getModbusConnect(ipAddr);
return Result.success(connector);
}
/**
* 查询所有设备(不分页)
*/
@PostMapping(value = "/doAction", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "调用plc设备执行动作", description = "根据plc设备ip执行动作")
public Result doAction(
@RequestParam String ip,
@RequestParam String action
) {
Boolean aBoolean = plcService.doAction(ip, action);
return Result.success(aBoolean);
}
@Autowired
StepInfoService stepInfoService;
@Autowired
GoodsInfoService goodsInfoService;
@Autowired
ManageLogService manageLogService;
@PostMapping(value = "/runFlow")
@Operation(summary = "为样品执行国标" ,description = "为样品执行国标")
public Result doStandGoods(
@RequestParam String plcIp,
@RequestParam Integer flowId,
@RequestParam List<Integer> goodsIds
){
//根据flowId获取步骤信息表
StepInfoQuery stepInfo = new StepInfoQuery();
stepInfo.setFlowId(flowId);
List<StepInfo> stepInfoList = stepInfoService.selectList(stepInfo);
//stepInfoList根据StepInfo里面的stepOrderint排序
stepInfoList.sort(Comparator.comparing(StepInfo::getStepOrder));
//根据goodsIds获取样品信息的 bar_code编码列表
List<GoodsInfo> goodsInfoList = goodsInfoService.selectByIdList(goodsIds);
List<String> barCodeList = goodsInfoList.stream().map(GoodsInfo::getBarCode).collect(Collectors.toList());
Boolean aBoolean = plcService.runSopInfoForGoodsList(plcIp,flowId, barCodeList, stepInfoList);
//记录操作样品执行SOP操作日志
LocalDateTime loginTime = LocalDateTime.now();
ManageLog info = new ManageLog();
// ========== 修复开始 ==========
Map<String, Object> mapClaims = ThreadLocalUtil.get();
UserBusy userBusy = new UserBusy();
userBusy.setId(Long.valueOf( mapClaims.get("id").toString()));
userBusy.setUserName((String) mapClaims.get("username"));
// ========== 修复结束 ==========
info.setCreateId(userBusy.getId());
info.setLogName("SOP操作日志");
info.setLogType("SOP操作日志");//1登录日志、2SOP操作日志、3基础数据操作日志
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("用户名:").append(userBusy.getUserName()).append("SOP执行操作时间").append(loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
info.setLogContent(stringBuilder.toString());
info.setCreateTime(loginTime);
manageLogService.insert(info);
return Result.success(aBoolean);
}
}

View File

@@ -0,0 +1,84 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.RecordInfo;
import com.rczn.rcznautoplc.service.RecordInfoService;
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("/recordInfo")
@Tag(name = "记录信息管理", description = "记录信息增删改查+分页查询接口")
public class RecordInfoController {
@Autowired
RecordInfoService recordInfoService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询记录信息", description = "支持记录名称模糊查询,记录类型、状态精准查询")
@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 = "recordName", description = "记录名称(可选,模糊查询)", required = false, example = "设备故障", in = ParameterIn.QUERY),
@Parameter(name = "recordType", description = "记录类型可选精准查询1-设备异常2-样品异常3-操作异常)", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "recordStatus", description = "记录状态可选精准查询false-未处理true-已处理)", required = false, example = "false", in = ParameterIn.QUERY)
})
public Result getRecordInfoPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) String recordName,
@RequestParam(required = false) Integer recordType,
@RequestParam(required = false) Boolean recordStatus) {
PageInfo<RecordInfo> pageBean = recordInfoService.selectPage(pageNum, pageSize, recordName, recordType, recordStatus);
return Result.success(pageBean);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个记录信息", description = "根据记录信息ID查询详情")
public Result getRecordInfoById(@PathVariable Long id) {
RecordInfo recordInfo = recordInfoService.selectById(id);
return recordInfo != null ? Result.success(recordInfo) : Result.error("记录信息不存在");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增记录信息", description = "记录名称、类型、内容为必填项类型1-设备异常2-样品异常3-操作异常)")
public Result addRecordInfo(@RequestBody RecordInfo recordInfo) {
try {
Long recordInfoId = recordInfoService.insert(recordInfo);
return Result.success(recordInfoId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改记录信息", description = "需传入记录信息ID其他字段可选非空则更新")
public Result updateRecordInfo(@RequestBody RecordInfo recordInfo) {
try {
Boolean success = recordInfoService.update(recordInfo);
return success ? Result.success(true) : Result.error("修改失败(记录信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除记录信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteRecordInfo(@PathVariable Long id) {
try {
Boolean success = recordInfoService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(记录信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,133 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import com.rczn.rcznautoplc.service.StepInfoService;
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.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/stepInfo")
@Tag(name = "步骤信息管理", description = "步骤信息增删改查+分页查询接口")
public class StepInfoController {
@Autowired
StepInfoService stepInfoService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询步骤信息", description = "支持岛屿ID精准查询、步骤名称模糊查询")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY)
})
public Result getStepInfoPage(
@ParameterObject // 核心注解:标记该实体类从查询参数取值
@Schema(description = "设备查询条件(可选)") // 补充描述
StepInfoQuery stepInfo,
@RequestParam Integer pageNum,
@RequestParam Integer pageSize
) {
PageInfo<StepInfo> pageBean = stepInfoService.selectPage(pageNum, pageSize, stepInfo);
return Result.success(pageBean);
}
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询步骤信息", description = "支持岛屿ID精准查询、步骤名称模糊查询")
public Result getStepInfoList(
@ParameterObject // 核心注解:标记该实体类从查询参数取值
@Schema(description = "设备查询条件(可选)") // 补充描述
StepInfoQuery stepInfo) {
List<StepInfo> list = stepInfoService.selectList( stepInfo);
return Result.success(list);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个步骤信息", description = "根据步骤信息ID查询详情")
public Result getStepInfoById(@PathVariable Long id) {
StepInfo stepInfo = stepInfoService.selectById(id);
return stepInfo != null ? Result.success(stepInfo) : Result.error("步骤信息不存在");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增步骤信息", description = "岛屿ID、步骤名称为必填项")
public Result addStepInfo(@RequestBody StepInfo stepInfo) {
try {
Long stepInfoId = stepInfoService.insert(stepInfo);
return Result.success(stepInfoId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PostMapping(value = "/batchAdd", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "批量新增步骤信息", description = "岛屿ID、步骤名称为必填项")
public Result batchAddStepInfo(@RequestBody List<StepInfo> stepInfoList) {
try {
stepInfoService.insertBatch(stepInfoList);
return Result.success(true);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
//批量更新步骤信息
@PostMapping(value = "/batchUpdate", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "批量更新步骤信息", description = "岛屿ID、步骤名称为必填项")
public Result batchUpdateStepInfo(@RequestBody List<StepInfo> stepInfoList) {
try {
stepInfoService.updateBatch(stepInfoList);
return Result.success(true);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改步骤信息", description = "需传入步骤信息ID其他字段可选非空则更新")
public Result updateStepInfo(@RequestBody StepInfo stepInfo) {
try {
Boolean success = stepInfoService.update(stepInfo);
return success ? Result.success(true) : Result.error("修改失败(步骤信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除步骤信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteStepInfo(@PathVariable Long id) {
try {
Boolean success = stepInfoService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(步骤信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
//批量删除步骤信息
@DeleteMapping(value = "/batchDel", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "批量删除步骤信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result batchDeleteStepInfo(@RequestBody List<Long> ids) {
try {
stepInfoService.deleteBatchByIds(ids);
return Result.success(true);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,23 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.websocket.WebSocketServer;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/websocket")
@Tag(name = "websocket", description = "websocket接口")
public class WebSocketController {
@Autowired
private WebSocketServer webSocketServer;
@RequestMapping("/send/{message}")
public String send(@PathVariable("message") String message){
webSocketServer.onMessage(message,null);
return "success";
}
}

View File

@@ -0,0 +1,132 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
public class DevInfo extends BaseBean {
//功能岛外键
private Integer islandId;
//设备名称
private String devName;
//设备型号
private String devModel;
//plc映射地址
private Integer plcAddr;
//设备IP地址
private String ipAddr;
private Integer port;
private String protocolType;
private String company;
private Integer status; // 0-空闲1-运行4-故障
private Integer runModel;//0-手动模式1-自动模式
private String devDesc;
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 Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
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 Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
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 Integer getRunModel() {
return runModel;
}
public void setRunModel(Integer runModel) {
this.runModel = runModel;
}
public String getDevDesc() {
return devDesc;
}
public void setDevDesc(String devDesc) {
this.devDesc = devDesc;
}
}

View File

@@ -0,0 +1,119 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
public class DevParam extends BaseBean {
private String devIds;
//字典类型-参数分类id
private Integer dicDataId;
private String paramName;
//plc映射地址
private Integer plcAddr;
private String paramValue;
private String paramType;
private String paramUnit;
private String formType;
private String paramDesc;
@JsonIgnore
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 String getDevIds() {
return devIds;
}
public void setDevIds(String devIds) {
this.devIds = devIds;
}
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 getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public Integer getDicDataId() {
return dicDataId;
}
public void setDicDataId(Integer dicDataId) {
this.dicDataId = dicDataId;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public String getParamDesc() {
return paramDesc;
}
public void setParamDesc(String paramDesc) {
this.paramDesc = paramDesc;
}
public DevInfo getDevInfo() {
return devInfo;
}
public void setDevInfo(DevInfo devInfo) {
this.devInfo = devInfo;
}
}

View File

@@ -0,0 +1,114 @@
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;
private String busyCode;
private String goodsCode;
private String goodsName;
private String checkCode; // 校验码
private String programName; // 程序名称
private String testMethod; // 测试方法
private String scanNum; //扫描编号
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 String getBusyCode() {
return busyCode;
}
public void setBusyCode(String busyCode) {
this.busyCode = busyCode;
}
public String getGoodsCode() {
return goodsCode;
}
public void setGoodsCode(String goodsCode) {
this.goodsCode = goodsCode;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getCheckCode() {
return checkCode;
}
public void setCheckCode(String checkCode) {
this.checkCode = checkCode;
}
public String getProgramName() {
return programName;
}
public void setProgramName(String programName) {
this.programName = programName;
}
public String getTestMethod() {
return testMethod;
}
public void setTestMethod(String testMethod) {
this.testMethod = testMethod;
}
public String getScanNum() {
return scanNum;
}
public void setScanNum(String scanNum) {
this.scanNum = scanNum;
}
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;
}
}

View File

@@ -0,0 +1,107 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
public class GoodsFlowStatus extends BaseBean {
private Integer goodsId;
private Integer flowId;
private Integer islandId;
private Integer devId;
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 getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
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;
}
}

View File

@@ -0,0 +1,129 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme;
import java.time.LocalDateTime;
public class GoodsInfo extends BaseBean {
private String goodsName;
private String goodsType;
private LocalDateTime incomeTime;
private String goodFrom;
private Integer goodBatch;
//进样点位
private Integer pointNum;
//目标监测物
private String goalDetect;
//条码
private String barCode;
//国标id
private Integer flowId;
private Integer goodsStatus;
private String desc;
public GoodsInfo() {
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsType() {
return goodsType;
}
public void setGoodsType(String goodsType) {
this.goodsType = goodsType;
}
public LocalDateTime getIncomeTime() {
return incomeTime;
}
public void setIncomeTime(LocalDateTime incomeTime) {
this.incomeTime = incomeTime;
}
public String getGoodFrom() {
return goodFrom;
}
public void setGoodFrom(String goodFrom) {
this.goodFrom = goodFrom;
}
public Integer getGoodBatch() {
return goodBatch;
}
public void setGoodBatch(Integer goodBatch) {
this.goodBatch = goodBatch;
}
public Integer getPointNum() {
return pointNum;
}
public void setPointNum(Integer pointNum) {
this.pointNum = pointNum;
}
public String getGoalDetect() {
return goalDetect;
}
public void setGoalDetect(String goalDetect) {
this.goalDetect = goalDetect;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
public Integer getGoodsStatus() {
return goodsStatus;
}
public void setGoodsStatus(Integer goodsStatus) {
this.goodsStatus = goodsStatus;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -0,0 +1,62 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class IslandInfo extends BaseBean {
private String islandName;
private String islandCode;
//plc映射地址
private Integer plcAddr;
private String islandLogo;
private String desc;
public IslandInfo() {
}
public String getIslandName() {
return islandName;
}
public void setIslandName(String islandName) {
this.islandName = islandName;
}
public String getIslandCode() {
return islandCode;
}
public void setIslandCode(String islandCode) {
this.islandCode = islandCode;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public String getIslandLogo() {
return islandLogo;
}
public void setIslandLogo(String islandLogo) {
this.islandLogo = islandLogo;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -0,0 +1,109 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
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;
@JsonIgnore
private IslandInfo islandInfo;
@JsonIgnore
private StepInfo stepInfo;
public IslandParam() {
}
public IslandParam(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getStepId() {
return stepId;
}
public void setStepId(Integer stepId) {
this.stepId = stepId;
}
public String getParamName() {
return paramName;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public String getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public IslandInfo getIslandInfo() {
return islandInfo;
}
public void setIslandInfo(IslandInfo islandInfo) {
this.islandInfo = islandInfo;
}
public StepInfo getStepInfo() {
return stepInfo;
}
public void setStepInfo(StepInfo stepInfo) {
this.stepInfo = stepInfo;
}
}

View File

@@ -0,0 +1,65 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class ManageLog extends BaseBean {
private String logName;
private String logType;
private LocalDateTime logWritetime;
private String logContent;
public ManageLog() {
}
public ManageLog(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
@Override
public String toString() {
return "ManageLog{" +
"logName='" + logName + '\'' +
", logType='" + logType + '\'' +
", logWritetime=" + logWritetime +
", logContent='" + logContent + '\'' +
'}';
}
public String getLogName() {
return logName;
}
public void setLogName(String logName) {
this.logName = logName;
}
public String getLogType() {
return logType;
}
public void setLogType(String logType) {
this.logType = logType;
}
public LocalDateTime getLogWritetime() {
return logWritetime;
}
public void setLogWritetime(LocalDateTime logWritetime) {
this.logWritetime = logWritetime;
}
public String getLogContent() {
return logContent;
}
public void setLogContent(String logContent) {
this.logContent = logContent;
}
}

View File

@@ -0,0 +1,85 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.github.s7connector.api.S7Connector;
import com.serotonin.modbus4j.ModbusMaster;
public class ModbusConnectObj {
/**
* ip地址
*/
private String ipAddr;
/**
* 端口号
*/
private Integer port;
/**
* 机架号
*/
private Integer rack;
/**
* 插槽
*/
private Integer slot;
/**
* 是否是主机
*/
private Boolean host;
public ModbusConnectObj(String ipAddr, Integer port, Integer rack, Integer slot,Boolean host) {
this.ipAddr = ipAddr;
this.port = port;
this.rack = rack;
this.slot = slot;
this.host = host;
}
public ModbusConnectObj() {
}
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 Integer getRack() {
return rack;
}
public void setRack(Integer rack) {
this.rack = rack;
}
public Integer getSlot() {
return slot;
}
public void setSlot(Integer slot) {
this.slot = slot;
}
public Boolean getHost() {
return host;
}
public void setHost(Boolean host) {
this.host = host;
}
}

View File

@@ -0,0 +1,84 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.github.s7connector.api.S7Connector;
public class PlcConnectObj {
/**
* ip地址
*/
private String ipAddr;
/**
* 端口号
*/
private Integer port;
/**
* 机架号
*/
private Integer rack;
/**
* 插槽
*/
private Integer slot;
/**
* 连接对象
*/
@JsonBackReference
private S7Connector connector;
public PlcConnectObj(String ipAddr, Integer port, Integer rack, Integer slot, S7Connector connector) {
this.ipAddr = ipAddr;
this.port = port;
this.rack = rack;
this.slot = slot;
this.connector = connector;
}
public PlcConnectObj() {
}
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 Integer getRack() {
return rack;
}
public void setRack(Integer rack) {
this.rack = rack;
}
public Integer getSlot() {
return slot;
}
public void setSlot(Integer slot) {
this.slot = slot;
}
public S7Connector getConnector() {
return connector;
}
public void setConnector(S7Connector connector) {
this.connector = connector;
}
}

View File

@@ -0,0 +1,54 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class RecordInfo extends BaseBean {
private String recordName;
private Integer recordType; // 1-设备异常2-样品异常3-操作异常
private Boolean recordStatus; // 0-未处理1-已处理
private String recordContent;
public RecordInfo() {
}
public RecordInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
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;
}
public Boolean getRecordStatus() {
return recordStatus;
}
public void setRecordStatus(Boolean recordStatus) {
this.recordStatus = recordStatus;
}
public String getRecordContent() {
return recordContent;
}
public void setRecordContent(String recordContent) {
this.recordContent = recordContent;
}
}

View File

@@ -0,0 +1,133 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
public class StepInfo extends BaseBean {
private Integer islandId;
//设备id
private Integer devId;
private Integer flowId;
private String paramName;
private String paramType;
private String paramUnit;
private String paramValue;
private String formType;
private Integer stepOrder;
private String stepName;
private String stepDesc;
@JsonIgnore
private IslandInfo islandInfo;
public StepInfo() {
}
public StepInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
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 getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getStepOrder() {
return stepOrder;
}
public void setStepOrder(Integer stepOrder) {
this.stepOrder = stepOrder;
}
public String getStepName() {
return stepName;
}
public void setStepName(String stepName) {
this.stepName = stepName;
}
public String getStepDesc() {
return stepDesc;
}
public void setStepDesc(String stepDesc) {
this.stepDesc = stepDesc;
}
public IslandInfo getIslandInfo() {
return islandInfo;
}
public void setIslandInfo(IslandInfo islandInfo) {
this.islandInfo = islandInfo;
}
}

View File

@@ -0,0 +1,111 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class UserBusy extends BaseBean {
private Long id;
private String userName;
private String password;
private String salt;
private String nicke;
private Boolean sex; // 0-女, 1-男
private String emailAddr;
private String address;
public UserBusy() {
}
public UserBusy(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
@Override
public String toString() {
return "User{" +
"userName='" + userName + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", nicke='" + nicke + '\'' +
", sex=" + sex +
", emailAddr='" + emailAddr + '\'' +
", address='" + address + '\'' +
'}';
}
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public String getNicke() {
return nicke;
}
public void setNicke(String nicke) {
this.nicke = nicke;
}
public Boolean getSex() {
return sex;
}
public void setSex(Boolean sex) {
this.sex = sex;
}
public String getEmailAddr() {
return emailAddr;
}
public void setEmailAddr(String emailAddr) {
this.emailAddr = emailAddr;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}

View File

@@ -0,0 +1,122 @@
package com.rczn.rcznautoplc.domain.query;
public class DevInfoQuery {
//功能岛外键
private Integer islandId;
//设备名称
private String devName;
//设备型号
private String devModel;
//plc映射地址
private Integer plcAddr;
//设备IP地址
private String ipAddr;
private Integer port;
private String protocolType;
private String company;
private Integer status; // 0-空闲1-运行4-故障
private Integer runModel;//0-手动模式1-自动模式
private String devDesc;
public DevInfoQuery() {
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
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 Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
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 Integer getRunModel() {
return runModel;
}
public void setRunModel(Integer runModel) {
this.runModel = runModel;
}
public String getDevDesc() {
return devDesc;
}
public void setDevDesc(String devDesc) {
this.devDesc = devDesc;
}
}

View File

@@ -0,0 +1,87 @@
package com.rczn.rcznautoplc.domain.query;
public class DevParamQuery {
private String devIds;
private Integer devId;
private String paramName;
private String paramValue;
private String paramTypeData;
private String paramUnit;
private String formType;
private String paramDesc;
public DevParamQuery() {
}
public Integer getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
public String getDevIds() {
return devIds;
}
public void setDevIds(String devIds) {
this.devIds = devIds;
}
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 getParamTypeData() {
return paramTypeData;
}
public void setParamTypeData(String paramTypeData) {
this.paramTypeData = paramTypeData;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public String getParamDesc() {
return paramDesc;
}
public void setParamDesc(String paramDesc) {
this.paramDesc = paramDesc;
}
}

View File

@@ -0,0 +1,75 @@
package com.rczn.rcznautoplc.domain.query;
import com.rczn.domain.BaseBean;
import com.rczn.rcznautoplc.domain.FlowInfo;
import com.rczn.rcznautoplc.domain.IslandInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
public class GoodsFlowStatusQuery {
private Integer goodsId;
private Integer flowId;
private Integer islandId;
private Integer devId;
private Integer flowSort;
private Integer status; // 0-未执行1-执行10-通过11-失败
public GoodsFlowStatusQuery() {
}
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 getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@@ -0,0 +1,125 @@
package com.rczn.rcznautoplc.domain.query;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class GoodsInfoQuery extends BaseBean{
private String goodsName;
private String goodsType;
private LocalDateTime incomeTime;
private String goodFrom;
private Integer goodBatch;
private Integer pointNum;
//目标监测物
private String goalDetect;
//条码
private String barCode;
//国标id
private Integer flowId;
private Integer goodsStatus;
private String desc;
public GoodsInfoQuery() {
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsType() {
return goodsType;
}
public void setGoodsType(String goodsType) {
this.goodsType = goodsType;
}
public LocalDateTime getIncomeTime() {
return incomeTime;
}
public void setIncomeTime(LocalDateTime incomeTime) {
this.incomeTime = incomeTime;
}
public String getGoodFrom() {
return goodFrom;
}
public void setGoodFrom(String goodFrom) {
this.goodFrom = goodFrom;
}
public Integer getGoodBatch() {
return goodBatch;
}
public void setGoodBatch(Integer goodBatch) {
this.goodBatch = goodBatch;
}
public Integer getPointNum() {
return pointNum;
}
public void setPointNum(Integer pointNum) {
this.pointNum = pointNum;
}
public String getGoalDetect() {
return goalDetect;
}
public void setGoalDetect(String goalDetect) {
this.goalDetect = goalDetect;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
public Integer getGoodsStatus() {
return goodsStatus;
}
public void setGoodsStatus(Integer goodsStatus) {
this.goodsStatus = goodsStatus;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -0,0 +1,60 @@
package com.rczn.rcznautoplc.domain.query;
import com.rczn.domain.BaseBean;
public class IslandInfoQuery {
private String islandName;
private String islandCode;
//plc映射地址
private Integer plcAddr;
private String islandLogo;
private String desc;
public IslandInfoQuery() {
}
public String getIslandName() {
return islandName;
}
public void setIslandName(String islandName) {
this.islandName = islandName;
}
public String getIslandCode() {
return islandCode;
}
public void setIslandCode(String islandCode) {
this.islandCode = islandCode;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public String getIslandLogo() {
return islandLogo;
}
public void setIslandLogo(String islandLogo) {
this.islandLogo = islandLogo;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -0,0 +1,84 @@
package com.rczn.rcznautoplc.domain.query;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import com.rczn.rcznautoplc.domain.IslandInfo;
import java.time.LocalDateTime;
public class IslandParamQuery {
private Integer islandId;
private Integer stepId;
private String paramName;
private String paramType;
private String paramUnit;
private String paramValue;
private String formType;
public IslandParamQuery() {
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getStepId() {
return stepId;
}
public void setStepId(Integer stepId) {
this.stepId = stepId;
}
public String getParamName() {
return paramName;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public String getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
}

View File

@@ -0,0 +1,118 @@
package com.rczn.rcznautoplc.domain.query;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import com.rczn.rcznautoplc.domain.IslandInfo;
import java.time.LocalDateTime;
public class StepInfoQuery {
private Integer islandId;
//设备id
private Integer devId;
private Integer flowId;
private String paramName;
private String paramType;
private String paramUnit;
private String paramValue;
private String formType;
private Integer stepOrder;
private String stepName;
private String stepDesc;
public StepInfoQuery() {
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
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 getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getStepOrder() {
return stepOrder;
}
public void setStepOrder(Integer stepOrder) {
this.stepOrder = stepOrder;
}
public String getStepName() {
return stepName;
}
public void setStepName(String stepName) {
this.stepName = stepName;
}
public String getStepDesc() {
return stepDesc;
}
public void setStepDesc(String stepDesc) {
this.stepDesc = stepDesc;
}
}

View File

@@ -0,0 +1,37 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.rczn.rcznautoplc.domain.query.DevInfoQuery;
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> selectList(DevInfoQuery devInfo);
// 分页查询设备(支持多条件过滤)
List<DevInfo> selectPage(DevInfo devInfo);
// 查询符合条件的设备总数(用于分页)
int selectTotal(DevInfo devInfo);
// 查询所有未删除的设备(用于下拉选择等场景)
List<DevInfo> selectAll();
}

View File

@@ -0,0 +1,40 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DevParamMapper {
/**
* 新增设备参数
*/
Long insert(DevParam devParam);
/**
* 根据ID更新设备参数
*/
Boolean update(DevParam devParam);
/**
* 逻辑删除设备参数
*/
Boolean deleteById(@Param("id") Long id);
/**
* 根据ID查询设备参数
*/
DevParam selectById(@Param("id") Long id);
/**
* 分页查询设备参数(支持条件过滤)
*/
List<DevParam> selectPage(DevParamQuery devParam);
Boolean addDevId(@Param("devId") Integer devId,@Param("paramId") Integer paramId);
Boolean delDevId(@Param("devId")Integer devId,@Param("paramId") Integer paramId);
}

View File

@@ -0,0 +1,16 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.FlowInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface FlowInfoMapper {
Long insert(FlowInfo flowInfo);
Boolean update(FlowInfo flowInfo);
Boolean deleteById(@Param("id") Long id);
FlowInfo selectById(@Param("id") Long id);
List<FlowInfo> selectPage(FlowInfo flowInfo);
}

View File

@@ -0,0 +1,17 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.query.GoodsFlowStatusQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface GoodsFlowStatusMapper {
Long insert(GoodsFlowStatus goodsFlowStatus);
Boolean update(GoodsFlowStatus goodsFlowStatus);
Boolean deleteById(@Param("id") Long id);
GoodsFlowStatus selectById(@Param("id") Long id);
List<GoodsFlowStatus> selectPage(GoodsFlowStatusQuery goodsFlowStatus);
}

View File

@@ -0,0 +1,25 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface GoodsInfoMapper {
Long insert(GoodsInfo goodsInfo);
//批量插入样品数据:
// Long batchInsert(List<GoodsInfo> goodsInfoList);
Boolean update(GoodsInfo goodsInfo);
Boolean deleteById(@Param("id") Long id);
GoodsInfo selectById(@Param("id") Long id);
List<GoodsInfo> selectByIdList(@Param("idList") List<Integer> idList);
GoodsInfo selectByBarCode(@Param("barCode") String barCode);
List<GoodsInfo> selectPage(GoodsInfoQuery goodsInfo);
}

View File

@@ -0,0 +1,22 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.IslandInfo;
import com.rczn.rcznautoplc.domain.query.IslandInfoQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface IslandInfoMapper {
Long insert(IslandInfo islandInfo);
Boolean update(IslandInfo islandInfo);
Boolean deleteById(@Param("id") Long id);
IslandInfo selectById(@Param("id") Long id);
/**
* 查询功能岛信息List
*/
List<IslandInfo> selectList(IslandInfoQuery islandInfoQuery);
List<IslandInfo> selectPage(IslandInfo islandInfo);
}

View File

@@ -0,0 +1,40 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.IslandParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface IslandParamMapper {
/**
* 新增岛屿参数返回自增ID
*/
Long insert(IslandParam islandParam);
/**
* 根据ID更新岛屿参数非空字段才更新
*/
Boolean update(IslandParam islandParam);
/**
* 逻辑删除岛屿参数设置delSign=1
*/
Boolean deleteById(@Param("id") Long id);
/**
* 根据ID查询岛屿参数关联查询岛屿信息和步骤信息
*/
IslandParam selectById(@Param("id") Long id);
/**
* 分页查询岛屿参数(支持条件过滤,不关联查询关联对象)
*/
List<IslandParam> selectPage(IslandParam islandParam);
/**
* 分页查询岛屿参数(关联查询岛屿信息和步骤信息,支持条件过滤)
*/
List<IslandParam> selectPageWithRelations(IslandParam islandParam);
}

View File

@@ -0,0 +1,27 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.ManageLog;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper // 标记为 MyBatis Mapper 接口,确保被 Spring 扫描
public interface ManageLogMapper {
// 新增日志(支持空字段,空字段用数据库默认值)
int insert(ManageLog manageLog);
// 逻辑删除日志(按 ID设置 delSign=1
int deleteById(Long id);
// 更新日志(仅更新非空字段,空字段不更新)
int update(ManageLog manageLog);
// 按 ID 查询日志(仅查未删除数据)
ManageLog selectById(Long id);
// 分页查询日志(支持按字段筛选,空字段忽略条件)
List<ManageLog> selectPage(ManageLog manageLog);
// 查询分页总数(与分页查询条件一致)
Long selectTotal(ManageLog manageLog);
}

View File

@@ -0,0 +1,16 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.RecordInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface RecordInfoMapper {
Long insert(RecordInfo recordInfo);
Boolean update(RecordInfo recordInfo);
Boolean deleteById(@Param("id") Long id);
RecordInfo selectById(@Param("id") Long id);
List<RecordInfo> selectPage(RecordInfo recordInfo);
}

View File

@@ -0,0 +1,24 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface StepInfoMapper {
Long insert(StepInfo stepInfo);
Boolean update(StepInfo stepInfo);
Boolean deleteById(@Param("id") Long id);
Long deleteBatchByIds(List<Long> ids);
StepInfo selectById(@Param("id") Long id);
List<StepInfo> selectList(StepInfo stepInfo);
List<StepInfo> selectPage(StepInfoQuery stepInfo);
Long insertBatch(List<StepInfo> stepInfoList);
Long updateBatch(List<StepInfo> stepInfoList);
}

View File

@@ -0,0 +1,39 @@
package com.rczn.rcznautoplc.service;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.query.DevInfoQuery;
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);
//根据设备信息查询设备列表数据
/**
* Retrieves a list of device information based on the provided query parameters.
*
* @param devInfo The query parameters used to filter device information
* @return List<DevInfo> A list of device information objects that match the query criteria
*/
List<DevInfo> getDevInfoList(DevInfoQuery devInfo);
// 分页查询设备
PageInfo<DevInfo> getDevInfoPage(DevInfo devInfo, Integer pageNum, Integer pageSize);
// 查询所有设备
List<DevInfo> getAllDevInfo();
}

View File

@@ -0,0 +1,47 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import java.util.List;
public interface DevParamService {
/**
* 分页查询
*/
PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId,String paramTypeData, String paramName, String paramValue);
List<DevParam> selectList(DevParamQuery queryParam);
/**
* 根据ID查询
*/
DevParam selectById(Long id);
/**
* 新增
*/
Long insert(DevParam devParam);
/**
* 修改
*/
Boolean update(DevParam devParam);
/**
* 为参数增加devId值
*/
Boolean addDevId(Integer devId, Integer paramId);
/**
* 根据paramId,减少devIds中的devId
*/
Boolean reduceDevId(Integer devId, Integer paramId);
/**
* 逻辑删除
*/
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,16 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.FlowInfo;
import java.util.List;
public interface FlowInfoService {
PageInfo<FlowInfo> selectPage(Integer pageNum, Integer pageSize, Integer flowIndex, String flowName, String islandIdList);
List<FlowInfo> selectList( Integer flowIndex, String flowName, String islandIdList);
FlowInfo selectById(Long id);
Long insert(FlowInfo flowInfo);
Boolean update(FlowInfo flowInfo);
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,17 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.query.GoodsFlowStatusQuery;
import java.util.List;
public interface GoodsFlowStatusService {
PageInfo<GoodsFlowStatus> selectPage(Integer pageNum, Integer pageSize, GoodsFlowStatusQuery goodsFlowStatus);
List<GoodsFlowStatus> selectList( GoodsFlowStatusQuery goodsFlowStatus);
GoodsFlowStatus selectById(Long id);
Long insert(GoodsFlowStatus goodsFlowStatus);
Boolean update(GoodsFlowStatus goodsFlowStatus);
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,49 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import java.util.List;
public interface GoodsInfoService {
/**
* 分页查询货物信息
*/
PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, GoodsInfoQuery goodsInfo);
/**
* 查询样品信息List
*/
List<GoodsInfo> selectList(GoodsInfoQuery goodsInfo);
/**
* 根据ID查询货物信息
*/
GoodsInfo selectById(Long id);
/**
* 根据ID列表查询货物列表信息
*/
List<GoodsInfo> selectByIdList(List<Integer> ids);
/**
* 新增货物信息
*/
Long insert(GoodsInfo goodsInfo);
/**
* 扫码新增货物信息
*/
GoodsInfo insertByScan(GoodsInfo goodsInfo);
/**
* 修改货物信息
*/
Boolean update(GoodsInfo goodsInfo);
/**
* 逻辑删除货物信息
*/
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,24 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.IslandInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import com.rczn.rcznautoplc.domain.query.IslandInfoQuery;
import java.util.List;
public interface IslandInfoService {
PageInfo<IslandInfo> selectPage(Integer pageNum, Integer pageSize, String islandName, String islandCode);
IslandInfo selectById(Long id);
/**
* 查询功能岛信息List
*/
List<IslandInfo> selectList(IslandInfoQuery islandInfoQuery);
Long insert(IslandInfo islandInfo);
Boolean update(IslandInfo islandInfo);
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,13 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.IslandParam;
public interface IslandParamService {
PageInfo<IslandParam> selectPage(Integer pageNum, Integer pageSize, Integer islandId, Integer stepId, String paramName, String paramType);
IslandParam selectById(Long id);
Long insert(IslandParam islandParam);
Boolean update(IslandParam islandParam);
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,21 @@
package com.rczn.rcznautoplc.service;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.ManageLog;
public interface ManageLogService {
// 新增日志
Long insert(ManageLog manageLog);
// 逻辑删除日志
Boolean deleteById(Long id, Long updateId);
// 更新日志(仅更新非空字段)
Boolean update(ManageLog manageLog);
// 按 ID 查询日志
ManageLog selectById(Long id);
// 分页查询日志(支持多条件筛选)
PageBean<ManageLog> selectPage(Integer pageNum, Integer pageSize, ManageLog manageLog);
}

View File

@@ -0,0 +1,125 @@
package com.rczn.rcznautoplc.service;
import com.github.s7connector.api.S7Connector;
import com.rczn.rcznautoplc.domain.ModbusConnectObj;
import com.rczn.rcznautoplc.domain.PlcConnectObj;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.utils.PlcConnectMap;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import java.util.List;
import java.util.Map;
public interface PlcService {
/**
* 连接plc设备
* @param connectObj-
* @return
*/
PlcConnectObj connect(PlcConnectObj connectObj);
/**
* 连接modbus设备
* @param connectObj-
* @return
*/
ModbusMaster connectModbus(ModbusConnectObj connectObj) throws ModbusInitException, ModbusTransportException;
/**
* 启动plc设备
* @param ipAddr-
* @return
*/
Boolean startPlc(String ipAddr);
/**
* plc设备暂停运行
* @param ipAddr-
* @return
*/
Boolean pausePlc(String ipAddr);
/**
* plc设备故障复位
* @param ipAddr-
* @return
*/
Boolean resetErrorPlc(String ipAddr);
/**
* 根据ip地址获取plc设备状态值
* 0-未连接1-连接11-执行12-暂停19暂停20-故障复位
* @param ipAddr
* @return
*/
Integer getPlcStatus(String ipAddr);
/**
* 根据ip地址设置plc设备模式
* 0-手动1-自动
* @param ipAddr
* @return
*/
Boolean setPlcModel(String ipAddr,Integer modelValue);
/**
* 根据ip地址获取plc设备模式值
* 0-手动1-自动
* @param ipAddr
* @return
*/
Integer getPlcModel(String ipAddr);
/**
* 根据ip地址获取modbus连接设备
*
* @param ipAddr
* @return
*/
public ModbusMaster getModbusConnect(String ipAddr);
/**
* 根据ip地址获取plc设备
* @param ipAddr
* @return
*/
S7Connector getPlc(String ipAddr);
/**
* 获取全部plc连接对象
* @return
*/
Map<String,S7Connector> plcALlMap();
/**
* 获取全部plc连接对象
*
* @return
*/
public Map<String, ModbusMaster> modbusALlMap();
/**
* 执行plc动作
* @param ipAddr
* @param action
* @return
*/
Boolean doAction(String ipAddr,String action);
/**
* 停止plc运行
* @param ipAddr
* @return
*/
Boolean stopPlc(String ipAddr);
/**
* 执行sop信息
* @param sopId
* @param barCodeList
* @param stepInfoList
* @return
*/
Boolean runSopInfoForGoodsList(String plcIp, Integer sopId, List<String> barCodeList,List<StepInfo> stepInfoList);
}

View File

@@ -0,0 +1,12 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.RecordInfo;
public interface RecordInfoService {
PageInfo<RecordInfo> selectPage(Integer pageNum, Integer pageSize, String recordName, Integer recordType, Boolean recordStatus);
RecordInfo selectById(Long id);
Long insert(RecordInfo recordInfo);
Boolean update(RecordInfo recordInfo);
Boolean deleteById(Long id);
}

View File

@@ -0,0 +1,33 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import java.util.List;
public interface StepInfoService {
PageInfo<StepInfo> selectPage(Integer pageNum, Integer pageSize, StepInfoQuery stepInfo);
List<StepInfo> selectList( StepInfoQuery stepInfo);
StepInfo selectById(Long id);
Long insert(StepInfo stepInfo);
Long insertBatch(List<StepInfo> stepInfoList);
Boolean update(StepInfo stepInfo);
/**
* 批量更新
* @param stepInfoList
* @return
*/
Long updateBatch(List<StepInfo> stepInfoList);
Boolean deleteById(Long id);
/**
* 批量删除
* @param ids
* @return
* @throws Exception
*/
Long deleteBatchByIds(List<Long> ids);
}

View File

@@ -0,0 +1,118 @@
package com.rczn.rcznautoplc.service.impl;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.rczn.rcznautoplc.domain.query.DevInfoQuery;
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());
}
//判断设备是否是PLCPLC设备只有一个主PLCcompany-主站
if(devInfo.getDevModel().equals("PLC")&&devInfo.getCompany().equals("主站")){
//查询出devModel为PLCcompany为“主站”的设备
DevInfoQuery devInfo1 = new DevInfoQuery();
devInfo1.setDevModel("PLC");
devInfo1.setCompany("主站");
List<DevInfo> devInfoList = devInfoMapper.selectList(devInfo1);
if(devInfoList.size()>0){
//如果存在,报错抛出异常
throw new RuntimeException("主站PLC设备只能有一个");
}
}
// 调用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());
}
//判断设备是否是PLCPLC设备只有一个主PLCcompany-主站
if(devInfo.getDevModel().equals("PLC")&&devInfo.getCompany().equals("主站")){
//查询出devModel为PLCcompany为“主站”的设备
DevInfoQuery devInfo1 = new DevInfoQuery();
devInfo1.setDevModel("PLC");
devInfo1.setCompany("主站");
List<DevInfo> devInfoList = devInfoMapper.selectList(devInfo1);
if(devInfoList.size()>0){
for (DevInfo devInfo2 : devInfoList)
if(devInfo2.getId().equals(devInfo.getId()))
continue;
else {
//如果存在,报错抛出异常
throw new RuntimeException("主站PLC设备只能有一个");
}
}
}
// 调用Mapper更新
return devInfoMapper.updateById(devInfo) > 0;
}
@Override
public DevInfo getDevInfoById(Long id) {
Assert.notNull(id, "设备ID不能为空");
return devInfoMapper.selectById(id);
}
@Override
public List<DevInfo> getDevInfoList(DevInfoQuery devInfo) {
return devInfoMapper.selectList(devInfo);
}
@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();
}
}

View File

@@ -0,0 +1,107 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import com.rczn.rcznautoplc.mapper.DevParamMapper;
import com.rczn.rcznautoplc.service.DevParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class DevParamServiceImpl implements DevParamService {
@Autowired
DevParamMapper devParamMapper;
@Override
public PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId, String paramTypeData, String paramName, String paramValue) {
// 1. 开启分页
PageHelper.startPage(pageNum, pageSize);
// 2. 构建查询条件
DevParamQuery queryParam = new DevParamQuery();
queryParam.setDevId(devId);
queryParam.setParamTypeData(paramTypeData);
queryParam.setParamName(paramName);
queryParam.setParamValue(paramValue);
// 3. 执行查询
List<DevParam> list = devParamMapper.selectPage(queryParam);
// 4. 包装分页结果
return new PageInfo<>(list);
}
/**
* 根据条件查询设备参数列表
* @param devId
* @param paramName
* @param paramValue
* @return
*/
@Override
public List<DevParam> selectList(DevParamQuery queryParam) {
// 3. 执行查询
List<DevParam> list = devParamMapper.selectPage(queryParam);
return list;
}
@Override
public DevParam selectById(Long id) {
if (id == null) {
throw new IllegalArgumentException("ID不能为空");
}
return devParamMapper.selectById(id);
}
@Override
public Long insert(DevParam devParam) {
if (devParam.getDevIds() == null) {
devParam.setDevIds(";");
}
if (devParam.getParamName() == null || devParam.getParamName().isEmpty()) {
throw new IllegalArgumentException("参数名称不能为空");
}
return devParamMapper.insert(devParam);
}
@Override
public Boolean update(DevParam devParam) {
if (devParam.getId() == null) {
throw new IllegalArgumentException("ID不能为空");
}
return devParamMapper.update(devParam);
}
/**
* 为参数增加devId值
*
* @param devId
* @param paramId
*/
@Override
public Boolean addDevId(Integer devId, Integer paramId) {
return devParamMapper.addDevId(devId, paramId);
}
/**
* 根据paramId,减少devIds中的devId
*
* @param devId
* @param paramId
*/
@Override
public Boolean reduceDevId(Integer devId, Integer paramId) {
return devParamMapper.delDevId(devId, paramId);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) {
throw new IllegalArgumentException("ID不能为空");
}
return devParamMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,74 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.FlowInfo;
import com.rczn.rcznautoplc.mapper.FlowInfoMapper;
import com.rczn.rcznautoplc.service.FlowInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class FlowInfoServiceImpl implements FlowInfoService {
@Autowired
FlowInfoMapper flowInfoMapper;
@Override
public PageInfo<FlowInfo> selectPage(Integer pageNum, Integer pageSize, Integer flowIndex, String flowName, String islandIdList) {
PageHelper.startPage(pageNum, pageSize);
FlowInfo queryParam = new FlowInfo();
queryParam.setFlowIndex(flowIndex);
queryParam.setFlowName(flowName);
queryParam.setIslandIdList(islandIdList);
List<FlowInfo> list = flowInfoMapper.selectPage(queryParam);
return new PageInfo<>(list);
}
/**
* 查询列表g根据国标流程
* @param flowIndex
* @param flowName
* @param islandIdList
* @return
*/
@Override
public List<FlowInfo> selectList(Integer flowIndex, String flowName, String islandIdList) {
FlowInfo queryParam = new FlowInfo();
queryParam.setFlowIndex(flowIndex);
queryParam.setFlowName(flowName);
queryParam.setIslandIdList(islandIdList);
List<FlowInfo> list = flowInfoMapper.selectPage(queryParam);
return list;
}
@Override
public FlowInfo selectById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return flowInfoMapper.selectById(id);
}
@Override
public Long insert(FlowInfo flowInfo) {
if (flowInfo.getFlowName() == null || flowInfo.getFlowName().isEmpty()) {
throw new IllegalArgumentException("流程名称不能为空");
}
Long result = flowInfoMapper.insert(flowInfo);
return flowInfo.getId();
}
@Override
public Boolean update(FlowInfo flowInfo) {
if (flowInfo.getId() == null) throw new IllegalArgumentException("ID不能为空");
return flowInfoMapper.update(flowInfo);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return flowInfoMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,60 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.query.GoodsFlowStatusQuery;
import com.rczn.rcznautoplc.mapper.GoodsFlowStatusMapper;
import com.rczn.rcznautoplc.service.GoodsFlowStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GoodsFlowStatusServiceImpl implements GoodsFlowStatusService {
@Autowired
GoodsFlowStatusMapper goodsFlowStatusMapper;
@Override
public PageInfo<GoodsFlowStatus> selectPage(Integer pageNum, Integer pageSize, GoodsFlowStatusQuery goodsFlowStatus){
PageHelper.startPage(pageNum, pageSize);
List<GoodsFlowStatus> list = goodsFlowStatusMapper.selectPage(goodsFlowStatus);
return new PageInfo<>(list);
}
@Override
public List<GoodsFlowStatus> selectList(GoodsFlowStatusQuery goodsFlowStatus) {
List<GoodsFlowStatus> list = goodsFlowStatusMapper.selectPage(goodsFlowStatus);
return list;
}
@Override
public GoodsFlowStatus selectById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return goodsFlowStatusMapper.selectById(id);
}
@Override
public Long insert(GoodsFlowStatus goodsFlowStatus) {
if (goodsFlowStatus.getGoodsId() == null) throw new IllegalArgumentException("货物ID不能为空");
if (goodsFlowStatus.getFlowId() == null) throw new IllegalArgumentException("流程ID不能为空");
if (goodsFlowStatus.getStatus() == null) throw new IllegalArgumentException("状态不能为空0-未执行1-执行10-通过11-失败)");
return goodsFlowStatusMapper.insert(goodsFlowStatus);
}
@Override
public Boolean update(GoodsFlowStatus goodsFlowStatus) {
if (goodsFlowStatus.getId() == null) throw new IllegalArgumentException("ID不能为空");
return goodsFlowStatusMapper.update(goodsFlowStatus);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return goodsFlowStatusMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,121 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import com.rczn.rcznautoplc.mapper.GoodsInfoMapper;
import com.rczn.rcznautoplc.service.GoodsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GoodsInfoServiceImpl implements GoodsInfoService {
@Autowired
GoodsInfoMapper goodsInfoMapper;
@Override
public PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, GoodsInfoQuery goodsInfo) {
// 开启分页
PageHelper.startPage(pageNum, pageSize);
// 执行查询
List<GoodsInfo> list = goodsInfoMapper.selectPage(goodsInfo);
// 包装分页结果
return new PageInfo<>(list);
}
/**
* 查询样品信息
*
* @param goodsInfo
*/
@Override
public List<GoodsInfo> selectList(GoodsInfoQuery goodsInfo) {
// 执行查询
List<GoodsInfo> list = goodsInfoMapper.selectPage(goodsInfo);
// 包装分页结果
return list;
}
@Override
public GoodsInfo selectById(Long id) {
if (id == null) {
throw new IllegalArgumentException("ID不能为空");
}
return goodsInfoMapper.selectById(id);
}
/**
* 根据ID列表查询货物列表信息
*
* @param ids
*/
@Override
public List<GoodsInfo> selectByIdList(List<Integer> ids) {
return goodsInfoMapper.selectByIdList(ids);
}
@Override
public Long insert(GoodsInfo goodsInfo) {
if (goodsInfo.getGoodsName() == null || goodsInfo.getGoodsName().isEmpty()) {
throw new IllegalArgumentException("货物名称不能为空");
}
if (goodsInfo.getGoodsType() == null || goodsInfo.getGoodsType().isEmpty()) {
throw new IllegalArgumentException("货物类型不能为空");
}
if (goodsInfo.getIncomeTime() == null) {
throw new IllegalArgumentException("入库时间不能为空");
}
return goodsInfoMapper.insert(goodsInfo);
}
/**
* 扫码新增货物信息
*
* @param goodsInfo
*/
@Override
public GoodsInfo insertByScan(GoodsInfo goodsInfo) {
//根据业务扫码录入样品信息有:样品编码,样品类型,样品名称,样品录入时间,点位号
//根据样品编码查询数据库样品信息
GoodsInfo goodsInfo1 = goodsInfoMapper.selectByBarCode(goodsInfo.getBarCode());
if(goodsInfo1 != null){
return goodsInfo1;
}
if (goodsInfo.getGoodsName() == null || goodsInfo.getGoodsName().isEmpty()) {
throw new IllegalArgumentException("货物名称不能为空");
}
if (goodsInfo.getGoodsType() == null || goodsInfo.getGoodsType().isEmpty()) {
throw new IllegalArgumentException("货物类型不能为空");
}
if (goodsInfo.getIncomeTime() == null) {
throw new IllegalArgumentException("入库时间不能为空");
}
goodsInfoMapper.insert(goodsInfo);
return goodsInfo;
}
@Override
public Boolean update(GoodsInfo goodsInfo) {
if (goodsInfo.getId() == null) {
throw new IllegalArgumentException("ID不能为空");
}
return goodsInfoMapper.update(goodsInfo);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) {
throw new IllegalArgumentException("ID不能为空");
}
return goodsInfoMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,68 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.IslandInfo;
import com.rczn.rcznautoplc.domain.query.IslandInfoQuery;
import com.rczn.rcznautoplc.mapper.IslandInfoMapper;
import com.rczn.rcznautoplc.service.IslandInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class IslandInfoServiceImpl implements IslandInfoService {
@Autowired
IslandInfoMapper islandInfoMapper;
@Override
public PageInfo<IslandInfo> selectPage(Integer pageNum, Integer pageSize, String islandName, String islandCode) {
PageHelper.startPage(pageNum, pageSize);
IslandInfo queryParam = new IslandInfo();
queryParam.setIslandName(islandName);
queryParam.setIslandCode(islandCode);
List<IslandInfo> list = islandInfoMapper.selectPage(queryParam);
return new PageInfo<>(list);
}
@Override
public IslandInfo selectById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return islandInfoMapper.selectById(id);
}
/**
* 查询功能岛信息List
*
* @param islandInfoQuery
*/
@Override
public List<IslandInfo> selectList(IslandInfoQuery islandInfoQuery) {
return islandInfoMapper.selectList(islandInfoQuery);
}
@Override
public Long insert(IslandInfo islandInfo) {
if (islandInfo.getIslandName() == null || islandInfo.getIslandName().isEmpty()) {
throw new IllegalArgumentException("岛屿名称不能为空");
}
if (islandInfo.getIslandCode() == null || islandInfo.getIslandCode().isEmpty()) {
throw new IllegalArgumentException("岛屿编码不能为空");
}
return islandInfoMapper.insert(islandInfo);
}
@Override
public Boolean update(IslandInfo islandInfo) {
if (islandInfo.getId() == null) throw new IllegalArgumentException("ID不能为空");
return islandInfoMapper.update(islandInfo);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return islandInfoMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,59 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.IslandParam;
import com.rczn.rcznautoplc.mapper.IslandParamMapper;
import com.rczn.rcznautoplc.service.IslandParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class IslandParamServiceImpl implements IslandParamService {
@Autowired
IslandParamMapper islandParamMapper;
@Override
public PageInfo<IslandParam> selectPage(Integer pageNum, Integer pageSize, Integer islandId, Integer stepId, String paramName, String paramType) {
PageHelper.startPage(pageNum, pageSize);
IslandParam queryParam = new IslandParam();
queryParam.setIslandId(islandId);
queryParam.setStepId(stepId);
queryParam.setParamName(paramName);
queryParam.setParamType(paramType);
List<IslandParam> list = islandParamMapper.selectPage(queryParam);
return new PageInfo<>(list);
}
@Override
public IslandParam selectById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return islandParamMapper.selectById(id);
}
@Override
public Long insert(IslandParam islandParam) {
if (islandParam.getIslandId() == null) throw new IllegalArgumentException("岛屿ID不能为空");
if (islandParam.getStepId() == null) throw new IllegalArgumentException("步骤ID不能为空");
if (islandParam.getParamName() == null || islandParam.getParamName().isEmpty()) {
throw new IllegalArgumentException("参数名称不能为空");
}
return islandParamMapper.insert(islandParam);
}
@Override
public Boolean update(IslandParam islandParam) {
if (islandParam.getId() == null) throw new IllegalArgumentException("ID不能为空");
return islandParamMapper.update(islandParam);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return islandParamMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,85 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.mapper.ManageLogMapper;
import com.rczn.rcznautoplc.service.ManageLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class ManageLogServiceImpl implements ManageLogService {
@Autowired
private ManageLogMapper manageLogMapper;
@Override
public Long insert(ManageLog manageLog) {
// 校验必填字段(日志名称和类型为必填)
Assert.notNull(manageLog.getLogName(), "日志名称不能为空");
Assert.notNull(manageLog.getLogType(), "日志类型不能为空");
//补充日志时间
if (manageLog.getLogWritetime() == null) {
manageLog.setLogWritetime(LocalDateTime.now());
}
// TODO 补充日志创建人信息
// manageLog.setCreateId(null);
manageLog.setCreateTime(LocalDateTime.now());
int rows = manageLogMapper.insert(manageLog);
return rows > 0 ? manageLog.getId() : null;
}
@Override
public Boolean deleteById(Long id, Long updateId) {
Assert.notNull(id, "日志ID不能为空");
int rows = manageLogMapper.deleteById(id);
return rows > 0;
}
@Override
public Boolean update(ManageLog manageLog) {
Assert.notNull(manageLog.getId(), "日志ID不能为空");
//如果更新时间为空,则自动更新
if (manageLog.getUpdateTime() == null) {
manageLog.setUpdateTime(LocalDateTime.now());
}
// TODO 补充日志更新人信息
// manageLog.setUpdateId(null);
int rows = manageLogMapper.update(manageLog);
return rows > 0;
}
@Override
public ManageLog selectById(Long id) {
Assert.notNull(id, "日志ID不能为空");
return manageLogMapper.selectById(id);
}
@Override
public PageBean<ManageLog> selectPage(Integer pageNum, Integer pageSize, ManageLog manageLog) {
// 校验分页参数
Assert.notNull(pageNum, "页码不能为空");
Assert.notNull(pageSize, "每页条数不能为空");
Assert.isTrue(pageNum > 0, "页码必须大于0");
Assert.isTrue(pageSize > 0 && pageSize <= 100000, "每页条数必须在1-10000之间");
// PageHelper 分页(自动拦截查询,添加 LIMIT 条件)
PageHelper.startPage(pageNum, pageSize);
List<ManageLog> logList = manageLogMapper.selectPage(manageLog);
Page<ManageLog> page = (Page<ManageLog>) logList;
PageBean<ManageLog> pageBean = new PageBean<>();
pageBean.setTotal(page.getTotal());
pageBean.setItems(page.getResult());
// 封装PageBean返回
return pageBean;
}
}

View File

@@ -0,0 +1,499 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.s7connector.api.S7Connector;
import com.github.s7connector.api.factory.S7ConnectorFactory;
import com.rczn.ModbusCmdConst;
import com.rczn.modbus.Modbus4jUtils;
import com.rczn.modbus.Modbus4jWriteUtils;
import com.rczn.plc_common.S7ConnectorPLC;
import com.rczn.rcznautoplc.cache.IsLandActionParamToPlc;
import com.rczn.rcznautoplc.cache.PlcRunStatus;
import com.rczn.rcznautoplc.cache.RegisterAddrDic;
import com.rczn.rcznautoplc.domain.*;
import com.rczn.rcznautoplc.domain.query.DevInfoQuery;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import com.rczn.rcznautoplc.domain.query.IslandInfoQuery;
import com.rczn.rcznautoplc.service.DevInfoService;
import com.rczn.rcznautoplc.service.DevParamService;
import com.rczn.rcznautoplc.service.IslandInfoService;
import com.rczn.rcznautoplc.service.PlcService;
import com.rczn.rcznautoplc.utils.PlcCommonProtcolUtil;
import com.rczn.rcznautoplc.utils.PlcConnectMap;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.code.DataType;
import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.util.*;
@Service
public class PlcServiceImpl implements PlcService {
// 核心创建log对象private static final名称固定为log
private static final Logger log = LoggerFactory.getLogger(PlcServiceImpl.class);
// Log log = LogFactory.getLog(PlcServiceImpl.class);
/**
* 连接plc设备
*
* @param connectObj -
* @return
*/
@Override
public PlcConnectObj connect(PlcConnectObj connectObj) {
S7ConnectorPLC plc = new S7ConnectorPLC();
// S7Connector connector = plc.initConnect(connectObj.getIpAddr(), connectObj.getPort(), connectObj.getRack(), connectObj.getSlot());
S7Connector connector = S7ConnectorFactory.buildTCPConnector().build();
connectObj.setConnector(connector);
PlcConnectMap.plcConnectorMap.put(connectObj.getIpAddr(),connector);
return connectObj;
}
/**
* 连接modbus设备
*
* @param connectObj -
* @return
*/
@Override
public ModbusMaster connectModbus(ModbusConnectObj connectObj) throws ModbusInitException, ModbusTransportException {
//初始化modbus连接对象
ModbusMaster modbusMaster = Modbus4jUtils.getAndTestMaster(connectObj.getIpAddr(), connectObj.getPort());
//以ip地址为键值保存连接对象modbusMaster
PlcConnectMap.modbusConnectorMap.put(connectObj.getIpAddr(),modbusMaster);
if(connectObj.getHost()){
PlcConnectMap.masterModbusConnector = modbusMaster;
}
return modbusMaster;
}
/**
* 启动plc设备
*
* @param ipAddr -
* @return
*/
@Override
public Boolean startPlc(String ipAddr) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdByte = new byte[4];
// connector.write(DaveArea.DB,1,1,cmdByte);
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Modbus4jWriteUtils.writeRegister(modbusMaster,1,1,(short) ModbusCmdConst.plc_run);
return true;
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return false;
}
/**
* plc设备暂停运行
*
* @param ipAddr -
* @return
*/
@Override
public Boolean pausePlc(String ipAddr) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdByte = new byte[4];
// connector.write(DaveArea.DB,1,1,cmdByte);
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Modbus4jWriteUtils.writeRegister(modbusMaster,1,1,(short) ModbusCmdConst.plc_pause);
return true;
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return false;
}
/**
* plc设备故障复位
*
* @param ipAddr -
* @return
*/
@Override
public Boolean resetErrorPlc(String ipAddr) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdByte = new byte[4];
// connector.write(DaveArea.DB,1,1,cmdByte);
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Modbus4jWriteUtils.writeRegister(modbusMaster,1,1,(short) ModbusCmdConst.plc_ready);
return true;
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return false;
}
/**
* 根据ip地址获取plc设备状态值
* 0-未连接1-连接10-就绪11-执行12-暂停19暂停20-故障复位
*
* @param ipAddr
* @return
*/
@Override
public Integer getPlcStatus(String ipAddr) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Number number = Modbus4jUtils.readHoldingRegister(modbusMaster, 1, 1, DataType.TWO_BYTE_INT_UNSIGNED);
return number.intValue();
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ErrorResponseException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return -1;
}
/**
* 根据ip地址设置plc设备模式
* 0-手动1-自动
*
* @param ipAddr
* @param modelValue
* @return
*/
@Override
public Boolean setPlcModel(String ipAddr, Integer modelValue) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Modbus4jWriteUtils.writeRegister(modbusMaster,1,0,(short) modelValue.intValue());
return true;
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return false;
}
/**
* 根据ip地址获取plc设备模式值
* 0-手动1-自动
*
* @param ipAddr
* @return
*/
@Override
public Integer getPlcModel(String ipAddr) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Number number = Modbus4jUtils.readHoldingRegister(modbusMaster, 1, 0, DataType.TWO_BYTE_INT_UNSIGNED);
if(number.intValue() != 0 && number.intValue()!=1){
number = 0;
}
return number.intValue();
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ErrorResponseException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return -1;
}
/**
* 根据ip地址获取plc设备
*
* @param ipAddr
* @return
*/
@Override
public S7Connector getPlc(String ipAddr) {
return PlcConnectMap.plcConnectorMap.get(ipAddr);
}
/**
* 根据ip地址获取modbus连接设备
*
* @param ipAddr
* @return
*/
@Override
public ModbusMaster getModbusConnect(String ipAddr) {
return PlcConnectMap.modbusConnectorMap.get(ipAddr);
}
/**
* 获取全部plc连接对象
*
* @return
*/
@Override
public Map<String, S7Connector> plcALlMap() {
return PlcConnectMap.plcConnectorMap;
}
/**
* 获取全部plc连接对象
*
* @return
*/
@Override
public Map<String, ModbusMaster> modbusALlMap() {
return PlcConnectMap.modbusConnectorMap;
}
/**
* 执行plc动作
*
* @param ipAddr
* @param action
* @return
*/
@Override
public Boolean doAction(String ipAddr, String action) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = new byte[5];
// connector.write(DaveArea.DB,1,1,cmdBytes);
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Modbus4jWriteUtils.writeRegister(modbusMaster,1,1,(short) ModbusCmdConst.plc_run);
return true;
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return false;
}
/**
* 停止plc运行
*
* @param ipAddr
* @return
*/
@Override
public Boolean stopPlc(String ipAddr) {
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = new byte[5];
// connector.write(DaveArea.DB,1,1,cmdBytes);
// S7Connector connector = PlcConnectMap.plcConnectorMap.get(ipAddr);
// byte[] cmdBytes = {(byte)(ModbusCmdConst.plc_run>>8),(byte)ModbusCmdConst.plc_run};
// if(connector != null){
// connector.write(DaveArea.DB,1,0,cmdBytes);
// }
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(ipAddr);
if(modbusMaster!=null){
try {
Modbus4jWriteUtils.writeRegister(modbusMaster,1,1,(short) ModbusCmdConst.plc_stop);
return true;
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}
return false;
}
@Autowired
IslandInfoService islandInfoService;
@Autowired
DevInfoService devInfoService;
@Autowired
DevParamService devParamService;
/**
* 执行sop信息
*
* @param sopId
* @param barCodeList
* @param stepInfoList
* @return
*/
@Override
public Boolean runSopInfoForGoodsList(String plcIp,Integer sopId, List<String> barCodeList, List<StepInfo> stepInfoList) {
// 1. 空值校验提前拦截null避免线程内空指针
if (barCodeList == null || barCodeList.isEmpty() || stepInfoList == null || stepInfoList.isEmpty()) {
log.warn("样品编码列表或步骤信息列表为空无需执行PLC动作");
return false;
}
//更新一次功能岛、动作单元、参数对应plc映射地址缓存
List<IslandInfo> islandInfos = islandInfoService.selectList(new IslandInfoQuery());
IsLandActionParamToPlc.islandToPlc.clear();
for (int i = 0; i < islandInfos.size(); i++) {
IslandInfo islandInfo = islandInfos.get(i);
IsLandActionParamToPlc.islandToPlc.put(islandInfo.getId().intValue(),islandInfo.getPlcAddr());
}
List<DevInfo> devInfos = devInfoService.getDevInfoList(new DevInfoQuery());
IsLandActionParamToPlc.actionToPlc.clear();
for (int i = 0; i < devInfos.size(); i++) {
DevInfo devInfo = devInfos.get(i);
IsLandActionParamToPlc.actionToPlc.put(devInfo.getId().intValue(),devInfo.getPlcAddr());
}
List<DevParam> devParams = devParamService.selectList(new DevParamQuery());
IsLandActionParamToPlc.paramToPlc.clear();
IsLandActionParamToPlc.paramIdToPlc.clear();
for (int i = 0; i < devParams.size(); i++) {
DevParam devParam = devParams.get(i);
IsLandActionParamToPlc.paramToPlc.put(devParam.getParamName(),devParam.getPlcAddr());
IsLandActionParamToPlc.paramIdToPlc.put(devParam.getId().intValue(),devParam.getPlcAddr());
}
//为stepInfoList排序根据StepInfo的step_order(int)字段
stepInfoList.sort(Comparator.comparingInt(StepInfo::getStepOrder));
// 2. 深拷贝集合:避免线程共享导致的并发修改问题
List<String> barCodeListCopy = new ArrayList<>(barCodeList);
List<StepInfo> stepInfoListCopy = new ArrayList<>(stepInfoList);
// 若StepInfo是自定义对象需保证深拷贝如果是浅拷贝对象属性仍会共享
// stepInfoListCopy = stepInfoList.stream().map(step -> 深拷贝StepInfo).collect(Collectors.toList());
// 3. 启动线程执行分组逻辑
new Thread(() -> {
try {
runSopInfoForGroup(plcIp,sopId,barCodeListCopy, stepInfoListCopy);
} catch (Exception e) {
// 4. 捕获线程内异常:避免线程静默失败
log.error("执行PLC分组任务失败", e);
}
}, "Sop-PLC-Thread-" + sopId).start(); // 给线程命名,便于日志排查
return true;
}
private void runSopInfoForGroup(String plcIp,Integer sopId,List<String> barCodeList, List<StepInfo> stepInfoList) throws InterruptedException {
//更新plc状态中的当前处理样品数量
PlcRunStatus.goodsCount = barCodeList.size();
PlcRunStatus.goodsCurrentIndex = 0;
// 5. 实现8个一组的分组逻辑核心业务补充
int groupSize = 8;
for (int i = 0; i < barCodeList.size(); i += groupSize) {
// 截取8个一组的子列表最后一组可能不足8个
int end = Math.min(i + groupSize, barCodeList.size());
List<String> subBarCodeList = barCodeList.subList(i, end);
//先判断PLC状态
while (true){
if(PlcRunStatus.systemPlcRunStatus == 1){
// 按分组执行PLC动作核心业务逻辑
executePlcActionByGroup(plcIp,sopId,subBarCodeList, stepInfoList);
//更新样品处理数量索引:
PlcRunStatus.goodsCurrentIndex += subBarCodeList.size();
break;
}
}
//暂停2.2秒,获取状态
Thread.sleep(2200);
//获取PLC整体状态
while (true){
if(PlcRunStatus.systemPlcRunStatus == 1){
//如果空闲
break;
}
}
}
}
// 补充按分组执行PLC动作的核心方法
private void executePlcActionByGroup(String plcIp,Integer sopId,List<String> subBarCodeList, List<StepInfo> stepInfoList) {
// 根据样品编码获取PLC设备
// 根据步骤信息执行PLC动作
log.info("执行PLC分组任务当前分组样品编码{}", subBarCodeList);
ModbusMaster modbusMaster = PlcConnectMap.modbusConnectorMap.get(plcIp);
if(modbusMaster!=null){
int startAddr = RegisterAddrDic.downProtcolRegisterArr;
//获取样品+sop序列协议
List<Byte> sopProtcol = PlcCommonProtcolUtil.getSopProtcol(sopId, subBarCodeList, stepInfoList);
//将协议写入PLC
ByteBuffer sopBuff = ByteBuffer.allocate(sopProtcol.size());
for (byte b1:
sopProtcol) {
sopBuff.put(b1);
}
ShortBuffer sopBuffShort = sopBuff.asShortBuffer();
try {
Modbus4jWriteUtils.writeRegisters(modbusMaster,1,startAddr, sopBuffShort.array());
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
}else {
throw new RuntimeException("未找到对应的modbusMaster");
}
}
}

View File

@@ -0,0 +1,61 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.RecordInfo;
import com.rczn.rcznautoplc.mapper.RecordInfoMapper;
import com.rczn.rcznautoplc.service.RecordInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class RecordInfoServiceImpl implements RecordInfoService {
@Autowired
RecordInfoMapper recordInfoMapper;
@Override
public PageInfo<RecordInfo> selectPage(Integer pageNum, Integer pageSize, String recordName, Integer recordType, Boolean recordStatus) {
PageHelper.startPage(pageNum, pageSize);
RecordInfo queryParam = new RecordInfo();
queryParam.setRecordName(recordName);
queryParam.setRecordType(recordType);
queryParam.setRecordStatus(recordStatus);
List<RecordInfo> list = recordInfoMapper.selectPage(queryParam);
return new PageInfo<>(list);
}
@Override
public RecordInfo selectById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return recordInfoMapper.selectById(id);
}
@Override
public Long insert(RecordInfo recordInfo) {
if (recordInfo.getRecordName() == null || recordInfo.getRecordName().isEmpty()) {
throw new IllegalArgumentException("记录名称不能为空");
}
if (recordInfo.getRecordType() == null) {
throw new IllegalArgumentException("记录类型不能为空1-设备异常2-样品异常3-操作异常)");
}
if (recordInfo.getRecordContent() == null || recordInfo.getRecordContent().isEmpty()) {
throw new IllegalArgumentException("记录内容不能为空");
}
return recordInfoMapper.insert(recordInfo);
}
@Override
public Boolean update(RecordInfo recordInfo) {
if (recordInfo.getId() == null) throw new IllegalArgumentException("ID不能为空");
return recordInfoMapper.update(recordInfo);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return recordInfoMapper.deleteById(id);
}
}

View File

@@ -0,0 +1,89 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import com.rczn.rcznautoplc.mapper.StepInfoMapper;
import com.rczn.rcznautoplc.service.StepInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class StepInfoServiceImpl implements StepInfoService {
@Autowired
StepInfoMapper stepInfoMapper;
@Override
public PageInfo<StepInfo> selectPage(Integer pageNum, Integer pageSize, StepInfoQuery stepInfo) {
PageHelper.startPage(pageNum, pageSize);
List<StepInfo> list = stepInfoMapper.selectPage(stepInfo);
return new PageInfo<>(list);
}
@Override
public List<StepInfo> selectList(StepInfoQuery stepInfo) {
List<StepInfo> list = stepInfoMapper.selectPage(stepInfo);
return list;
}
@Override
public StepInfo selectById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return stepInfoMapper.selectById(id);
}
@Override
public Long insert(StepInfo stepInfo) {
if (stepInfo.getIslandId() == null) throw new IllegalArgumentException("岛屿ID不能为空");
if (stepInfo.getStepName() == null || stepInfo.getStepName().isEmpty()) {
throw new IllegalArgumentException("步骤名称不能为空");
}
return stepInfoMapper.insert(stepInfo);
}
@Override
public Long insertBatch(List<StepInfo> stepInfoList) {
return stepInfoMapper.insertBatch(stepInfoList);
}
@Override
public Boolean update(StepInfo stepInfo) {
if (stepInfo.getId() == null) throw new IllegalArgumentException("ID不能为空");
return stepInfoMapper.update(stepInfo);
}
/**
* 批量更新
*
* @param stepInfoList
* @return
*/
@Override
public Long updateBatch(List<StepInfo> stepInfoList) {
return stepInfoMapper.updateBatch(stepInfoList);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return stepInfoMapper.deleteById(id);
}
/**
* 批量删除
*
* @param ids
* @return
* @throws Exception
*/
@Override
public Long deleteBatchByIds(List<Long> ids) {
return stepInfoMapper.deleteBatchByIds(ids);
}
}

View File

@@ -0,0 +1,159 @@
package com.rczn.rcznautoplc.task;
import com.rczn.modbus.Modbus4jUtils;
import com.rczn.modbus.Modbus4jWriteUtils;
import com.rczn.rcznautoplc.cache.RegisterAddrDic;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.service.GoodsFlowStatusService;
import com.rczn.rcznautoplc.service.GoodsInfoService;
import com.rczn.rcznautoplc.cache.PlcRunStatus;
import com.rczn.rcznautoplc.utils.PlcCommonProtcolUtil;
import com.rczn.rcznautoplc.utils.PlcConnectMap;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.code.DataType;
import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class PlcTask {
Log log = LogFactory.getLog(PlcTask.class);
//样品状态service
@Autowired
GoodsFlowStatusService goodsFlowStatusService;
//定时任务每2秒执行一次Cron 表达式支持 6 位(秒 分 时 日 月 周)或 7 位(秒 分 时 日 月 周 年)
@Scheduled(cron = "0/2 * * * * ?")
public void statusMonitor() throws ModbusInitException, ModbusTransportException, ErrorResponseException {
log.info("plc 设备状态监控.");
//判断是否有plc连接设备,
if(PlcConnectMap.masterModbusConnector != null ){
log.info("plc 主设备状态监控开始...");
//遍历连接对象
ModbusMaster connector = PlcConnectMap.masterModbusConnector;
//1-读取功能岛状态:
//1-1sop中第一个功能岛定容岛>10000(十进制):样品是否扫描完毕-0-10-未扫描完毕1-扫描完毕
Number scanReadyStatusNum = Modbus4jUtils.readHoldingRegister(connector, 1, 5000, DataType.TWO_BYTE_INT_UNSIGNED);
PlcRunStatus.goodsScanStatus = scanReadyStatusNum.intValue();
//判断如果扫描完成获取样品编码数据保存数据库修改plc寄存器状态值和修改索引状态
if(PlcRunStatus.goodsScanStatus == 1){
getGoodsInfoFromPlc( connector, PlcRunStatus.goodsScanStatus);
}
//查看plc的状态返回寄存器开头cc cc-有返回状态数据)
Number goodsStatusStart = Modbus4jUtils.readHoldingRegister(connector, 1, RegisterAddrDic.upProtcolRegisterArr, DataType.TWO_BYTE_INT_UNSIGNED);
if(goodsStatusStart.intValue() == 0xcccc){
//2-读取状态数据长度值
Number goodsStatusLength = Modbus4jUtils.readHoldingRegister(connector, 1, RegisterAddrDic.upProtcolRegisterArr+1, DataType.TWO_BYTE_INT_UNSIGNED);
//3-读取状态数据
Number[] goodsStatusArr = Modbus4jUtils.readHoldingRegisters(connector, 1, RegisterAddrDic.upProtcolRegisterArr, goodsStatusLength.intValue()/2+4, DataType.TWO_BYTE_INT_UNSIGNED);
//4-解析样品状态数据:把number数组数据转正List<byte>
List<Byte> goodsStatusByteList = new ArrayList<>();
for (Number goodsStatusNum:goodsStatusArr
) {
goodsStatusByteList.add((byte) (goodsStatusNum.intValue()>>8));
goodsStatusByteList.add((byte) (goodsStatusNum.intValue()&0xff));
}
List<GoodsFlowStatus> list = PlcCommonProtcolUtil.pareseProtcolStatus(goodsStatusByteList);
//5-插入数据库样品状态:
for (GoodsFlowStatus goodsFlowStatus:list
) {
goodsFlowStatusService.insert(goodsFlowStatus);
}
//6-清空寄存器数据:
Modbus4jWriteUtils.writeRegisters(connector,1,RegisterAddrDic.upProtcolRegisterArr, new short[goodsStatusLength.intValue()/2+4]);
}
//2-读取整个系统sop执行后状态0-未准备1-空闲2-忙4-异常
Number sopRunStatus = Modbus4jUtils.readHoldingRegister(connector, 1, 5500, DataType.TWO_BYTE_INT_UNSIGNED);
PlcRunStatus.systemPlcRunStatus = sopRunStatus.intValue();
}else {
log.info("plc 主设备未连接.");
}
}
@Autowired
GoodsInfoService goodsInfoService;
//任务:样品编码扫描完毕,读取
/**
* 异步执行样品信息读取(单独线程)
* @Async("plcAsyncExecutor") 指定使用自定义的PLC专用线程池
*/
@Async("plcAsyncExecutor")
public void getGoodsInfoFromPlc(ModbusMaster connector,int goodsScanStatus) {
try {
log.info("异步读取样品信息开始,线程名:" + Thread.currentThread().getName());
//10001-10032:32个槽位放置样品
//一个寄存器返回两个字节:是两个样品索引地址:
Number[] goodsIndexStatus = Modbus4jUtils.readHoldingRegisters(connector,1, 5001,16,DataType.TWO_BYTE_INT_UNSIGNED);
List<Integer> goodsIndexNumList = new ArrayList<>();
for (Number goodsIndexNum:goodsIndexStatus
) {
//一个寄存器返回值分成两个样品状态值:
int registerStatus = goodsIndexNum.intValue();
goodsIndexNumList.add(registerStatus>>8);
goodsIndexNumList.add(registerStatus&0xff);
}
// List<GoodsInfo> goodsInfoList = new ArrayList<>();
//当前时间:
LocalDateTime localDateTime = LocalDateTime.now();
//样品编码地址10033-1004810049-10063
for (int i = 0; i < goodsIndexNumList.size(); i++) {
int goodsIndexNum = goodsIndexNumList.get(i);
if (goodsIndexNum == 1) {
Number[] goodsCodeNumTemp = Modbus4jUtils.readHoldingRegisters(connector, 1, 10018 + i * 16,16, DataType.TWO_BYTE_INT_UNSIGNED);
StringBuilder goodCodeNumStr = new StringBuilder();
for (Number goodsIndexNumTemp:goodsCodeNumTemp){
goodCodeNumStr.append(goodsIndexNumTemp.intValue()>>8);
goodCodeNumStr.append(goodsIndexNumTemp.intValue()&0xff);
}
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setBarCode(goodCodeNumStr.toString());
goodsInfo.setPointNum(i+1);
goodsInfo.setGoodsName(PlcRunStatus.defaultGoodsName);
goodsInfo.setGoodsType(PlcRunStatus.defaultGoodsType);
goodsInfo.setGoalDetect(PlcRunStatus.defaultGoalDetect);
goodsInfo.setIncomeTime(localDateTime);
goodsInfo.setCreateTime(LocalDateTime.now());
// goodsInfoList.add(goodsInfo);
//获取的样品对象,保存到数据库,
goodsInfoService.insert(goodsInfo);
log.info("样品编码:" + goodCodeNumStr.toString() + ",样品索引:" + goodsIndexNum);
}
}
//修改寄存器样品索引值:
//10001-10032:16个寄存器每个寄存器两个样品状态值,修改样品索引值为0
short[] goodsRegisterValues = new short[16];
Modbus4jWriteUtils.writeRegisters(connector,1, 10001,goodsRegisterValues);
//修改10000寄存器的值为0
Modbus4jWriteUtils.writeHoldingRegister(connector,1, 10000,0,DataType.TWO_BYTE_INT_UNSIGNED);
// 此处可添加:保存数据到数据库、修改寄存器状态等业务逻辑
log.info("异步读取样品信息完成");
} catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) {
// 捕获异步线程中的异常并记录日志(异步方法异常不会自动抛出到主线程)
log.error("异步读取样品信息失败", e);
}
}
}

View File

@@ -0,0 +1,282 @@
package com.rczn.rcznautoplc.utils;
import com.rczn.rcznautoplc.cache.IsLandActionParamToPlc;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import com.rczn.rcznautoplc.service.GoodsInfoService;
import com.rczn.utils.BeanFactoryUtils;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.*;
public class PlcCommonProtcolUtil {
// 样品SOP执行指令 开始字节(2) 总字节长度(2) SOP id号4 样品数量(1) 样品地址(16) 样品地址(16) 样品地址(16) ... 功能岛PLC(2) 动作PLC地址(2) 参数PLC地址(2) 参数值(2) ... 结束码
// CC CC 0011 11223344 16 0 1 2 AA+01 BB+01 CC+01 0011 EEEE
public static List<Byte> getSopProtcol(Integer sopId,List<String> subBarCodeList, List<StepInfo> stepInfoList) {
List<Byte> protcolByteList = new ArrayList<>();
Byte[] startByte = {(byte) 0xcc,(byte) 0xcc};
for (int i = 0; i < startByte.length; i++) {
protcolByteList.add(startByte[i]);
}
//后面修正数据
byte[] dataLength = new byte[2];
for (int i = 0; i < dataLength.length; i++) {
protcolByteList.add(dataLength[i]);
}
// sop id
byte[] sopIdByte = new byte[4];
sopIdByte[0] = (byte) (sopId >> 24);
sopIdByte[1] = (byte) (sopId >> 16);
sopIdByte[2] = (byte) (sopId >> 8);
sopIdByte[3] = (byte) sopId.intValue();
for (int i = 0; i < sopIdByte.length; i++) {
protcolByteList.add(sopIdByte[i]);
}
//样品数量
byte sampleNum = (byte) subBarCodeList.size();
protcolByteList.add(sampleNum);
//把样品地址写入协议字符串列表
for (int i = 0; i < subBarCodeList.size(); i++) {
String subBarCode = subBarCodeList.get(i);
//subBarCode是一系列数字字符串转成16个10进制数字需要兼容subBarCode长度超过或少于16的情况
byte[] sampleAddress = new byte[16];
for (int j = 0; j < subBarCode.length() && j < sampleAddress.length; j++) {
sampleAddress[j] = (byte) Integer.parseInt(subBarCode.substring(j, j + 1));
}
for (int j = 0; j < sampleAddress.length; j++) {
protcolByteList.add(sampleAddress[j]);
}
}
//stepInfoList列表按照StepInfo对象里面的Integer islandId属性
// 属性里面有stepOrder计算出有多少个连续的不同islandId属性值
//第一个stepInfo的islandId
StepInfo stepInfo_0 = stepInfoList.get(0);
// 1-第一个功能岛plc
Integer islandPlcIntV = IsLandActionParamToPlc.islandToPlc.get(stepInfo_0.getIslandId());
byte[] islandPlc_0 = new byte[2];
islandPlc_0[0] = (byte) 0xaa;
islandPlc_0[1] = (byte) islandPlcIntV.intValue();
for (int i = 0; i < islandPlc_0.length; i++) {
protcolByteList.add(islandPlc_0[i]);
}
//第一个动作单元plc
Integer actionPlcIntV = IsLandActionParamToPlc.actionToPlc.get(stepInfo_0.getDevId());
byte[] actionPlc_0 = new byte[2];
actionPlc_0[0] = (byte) 0xbb;
actionPlc_0[1] = (byte) actionPlcIntV.intValue();
for (int i = 0; i < actionPlc_0.length; i++) {
protcolByteList.add(actionPlc_0[i]);
}
//第一个参数单元plc
Integer paramPlcIntV = IsLandActionParamToPlc.paramToPlc.get(stepInfo_0.getParamName());
byte[] paramPlc_0 = new byte[2];
paramPlc_0[0] = (byte) 0xcc;
paramPlc_0[1] = (byte) paramPlcIntV.intValue();
for (int i = 0; i < paramPlc_0.length; i++) {
protcolByteList.add(paramPlc_0[i]);
}
//第一个参数值
int paramValueInt = Integer.parseInt(stepInfo_0.getParamValue());
byte[] paramValue_0 = new byte[2];
paramValue_0[0] = (byte) (paramValueInt>>8);
paramValue_0[1] = (byte) paramValueInt;
for (int i = 0; i < paramValue_0.length; i++) {
protcolByteList.add(paramValue_0[i]);
}
for (int i = 1; i < stepInfoList.size(); i++) {
// isLandId:1 order:1 => isLandId:1 order:2 => isLandId:2 order:3 => isLandId:2 order:4 => isLandId:3 order:5
StepInfo stepInfo = stepInfoList.get(i);
//判断是否更换功能岛
if (stepInfo.getIslandId() != stepInfo_0.getIslandId()) {
// 1-第一个功能岛plc
Integer islandPlcIntV_1 = IsLandActionParamToPlc.islandToPlc.get(stepInfo_0.getIslandId());
byte[] islandPlc_1 = new byte[2];
islandPlc_1[0] = (byte) 0xaa;
islandPlc_1[1] = (byte) islandPlcIntV_1.intValue();
for (int j = 0; j < islandPlc_1.length; j++) {
protcolByteList.add(islandPlc_1[j]);
}
//第一个动作单元plc
Integer actionPlcIntV_1 = IsLandActionParamToPlc.actionToPlc.get(stepInfo_0.getDevId());
byte[] actionPlc_1 = new byte[2];
actionPlc_1[0] = (byte) 0xbb;
actionPlc_1[1] = (byte) actionPlcIntV_1.intValue();
for (int j = 0; j < actionPlc_1.length; j++) {
protcolByteList.add(actionPlc_1[j]);
}
//第一个参数单元plc
Integer paramPlcIntV_1 = IsLandActionParamToPlc.paramToPlc.get(stepInfo_0.getParamName());
byte[] paramPlc_1 = new byte[2];
paramPlc_1[0] = (byte) 0xcc;
paramPlc_1[1] = (byte) paramPlcIntV.intValue();
for (int j = 0; j < paramPlc_1.length; j++) {
protcolByteList.add(paramPlc_1[j]);
}
//第一个参数值
int paramValueInt_1 = Integer.parseInt(stepInfo_0.getParamValue());
byte[] paramValue_1 = new byte[2];
paramValue_1[0] = (byte) (paramValueInt_1>>8);
paramValue_1[1] = (byte) paramValueInt_1;
for (int j = 0; j < paramValue_1.length; j++) {
protcolByteList.add(paramValue_1[j]);
}
}else if(stepInfo.getDevId()!= stepInfo_0.getDevId()){
//判断是否更换动作单元
//第一个动作单元plc
Integer actionPlcIntV_1 = IsLandActionParamToPlc.actionToPlc.get(stepInfo_0.getDevId());
byte[] actionPlc_1 = new byte[2];
actionPlc_1[0] = (byte) 0xbb;
actionPlc_1[1] = (byte) actionPlcIntV_1.intValue();
for (int j = 0; j < actionPlc_1.length; j++) {
protcolByteList.add(actionPlc_1[j]);
}
//第一个参数单元plc
Integer paramPlcIntV_1 = IsLandActionParamToPlc.paramToPlc.get(stepInfo_0.getParamName());
byte[] paramPlc_1 = new byte[2];
paramPlc_1[0] = (byte) 0xcc;
paramPlc_1[1] = (byte) paramPlcIntV.intValue();
for (int j = 0; j < paramPlc_1.length; j++) {
protcolByteList.add(paramPlc_1[j]);
}
//第一个参数值
int paramValueInt_1 = Integer.parseInt(stepInfo_0.getParamValue());
byte[] paramValue_1 = new byte[2];
paramValue_1[0] = (byte) (paramValueInt_1>>8);
paramValue_1[1] = (byte) paramValueInt_1;
for (int j = 0; j < paramValue_1.length; j++) {
protcolByteList.add(paramValue_1[j]);
}
}else {
//第一个参数单元plc
Integer paramPlcIntV_1 = IsLandActionParamToPlc.paramToPlc.get(stepInfo_0.getParamName());
byte[] paramPlc_1 = new byte[2];
paramPlc_1[0] = (byte) 0xcc;
paramPlc_1[1] = (byte) paramPlcIntV.intValue();
for (int j = 0; j < paramPlc_1.length; j++) {
protcolByteList.add(paramPlc_1[j]);
}
//第一个参数值
int paramValueInt_1 = Integer.parseInt(stepInfo_0.getParamValue());
byte[] paramValue_1 = new byte[2];
paramValue_1[0] = (byte) (paramValueInt_1>>8);
paramValue_1[1] = (byte) paramValueInt_1;
for (int j = 0; j < paramValue_1.length; j++) {
protcolByteList.add(paramValue_1[j]);
}
}
stepInfo_0 = stepInfo;
}
int dataLengthInt = protcolByteList.size();
protcolByteList.set(2, (byte) (dataLengthInt>>8));
protcolByteList.set(3, (byte) dataLengthInt);
byte[] endByte = {(byte) 0xee, (byte) 0xee};
protcolByteList.add(endByte[0]);
protcolByteList.add(endByte[1]);
return protcolByteList;
}
// 样品处理状态返回指令 开始字节(2) 总字节长度(2) SOP id号4 样品数量(4) 样品地址(4) 功能岛PLC(1) 动作PLC地址(1) 参数PLC地址(1) 检测值(2) 样品地址(4) 功能岛PLC(1) 动作PLC地址(1) 参数PLC地址(1) 检测值(2) ... crc校验 结束码
// CCCC 0011 11223344 16 0 1 1 1 0011 1 1 1 1 0011 XX EEEE
public static List<GoodsFlowStatus> pareseProtcolStatus(List<Byte> protcolByteList) {
//获取样品数据整理处理Map对象keybar_codevaluegoodsId
GoodsInfoService goodsInfoService = BeanFactoryUtils.getBean(GoodsInfoService.class);
List<GoodsInfo> goodsInfoList = goodsInfoService.selectList(new GoodsInfoQuery());
Map<String, Long> goodsInfoCodeIDMap = new HashMap<>();
for (GoodsInfo goodsInfo : goodsInfoList) {
goodsInfoCodeIDMap.put(goodsInfo.getBarCode(), goodsInfo.getId());
}
List<GoodsFlowStatus> goodsFlowStatusList = new ArrayList<>();
//sop id值
StringBuilder sopIdSb = new StringBuilder();
for (int i = 0; i < 4; i++) {
Byte sopByte = protcolByteList.get(3 + i);
sopIdSb.append(sopByte.intValue());
}
Integer sopId = Integer.parseInt(sopIdSb.toString());
byte goodsCount = protcolByteList.get(7);
for (int i = 0; i < goodsCount; i++) {
//样品扫描编码地址
StringBuilder goodsAddressSb = new StringBuilder();
for (int j = 0; j < 16; j++){
Byte addByte = protcolByteList.get(8 + i * 16 + j);
goodsAddressSb.append(addByte.intValue());
}
//功能岛PLC地址
byte isLandPlc = protcolByteList.get(8 + (i+1) * 16);
//动作单元plc地址
byte actionPlc = protcolByteList.get(8 + (i+1) * 16 + 1);
//参数plc地址
byte paramPlc = protcolByteList.get(8 + (i+1) * 16 + 2);
//检测值
byte[] checkValue = new byte[2];
for (int j = 0; j < checkValue.length; j++) {
checkValue[j] = protcolByteList.get(8 + (i+1) * 16 + 3 + j);
}
int checkValueInt = ByteBuffer.wrap(checkValue).order(ByteOrder.LITTLE_ENDIAN).getShort();
GoodsFlowStatus flowStatus = new GoodsFlowStatus();
Long goodsId = goodsInfoCodeIDMap.get(goodsAddressSb.toString());
flowStatus.setGoodsId(goodsId.intValue());
flowStatus.setFlowId(sopId);
for (Integer isLandId :
IsLandActionParamToPlc.islandToPlc.keySet()) {
Integer plcValue = IsLandActionParamToPlc.islandToPlc.get(isLandId);
if (plcValue == isLandPlc) {
flowStatus.setIslandId(isLandId);
break;
}
}
for (Integer actionId :
IsLandActionParamToPlc.actionToPlc.keySet()) {
Integer plcValue = IsLandActionParamToPlc.actionToPlc.get(actionId);
if (plcValue == actionPlc) {
flowStatus.setDevId(actionId);
break;
}
}
for (Integer paramId:
IsLandActionParamToPlc.paramIdToPlc.keySet()) {
Integer plcValue = IsLandActionParamToPlc.paramIdToPlc.get(paramId);
if (plcValue == paramPlc) {
flowStatus.setFlowSort(paramId);
break;
}
}
flowStatus.setStatus(checkValueInt);
//保存样品状态数据:
goodsFlowStatusList.add(flowStatus);
}
return goodsFlowStatusList;
}
}

View File

@@ -0,0 +1,24 @@
package com.rczn.rcznautoplc.utils;
import com.github.s7connector.api.S7Connector;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.serotonin.modbus4j.ModbusMaster;
import java.util.HashMap;
import java.util.Map;
public class PlcConnectMap {
//PLC设备map对象keyipvalue设备
public static Map<String, DevInfo> plcDevMap = new HashMap<>();
//plc连接对象缓存
public static Map<String , S7Connector> plcConnectorMap = new HashMap<>();
//Modbus连接对象缓存
public static Map<String , ModbusMaster> modbusConnectorMap = new HashMap<>();
//主plc modbus连接对象:
public static ModbusMaster masterModbusConnector = null;
}

View File

@@ -0,0 +1 @@
##spring.application.name=rczn-autoplc

View File

@@ -0,0 +1,266 @@
<?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">
island_id, dev_name, dev_model,plc_addr, ip_addr, port, protocol_type, company, status,run_model, dev_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="island_id" property="islandId"/>
<result column="dev_name" property="devName"/>
<result column="dev_model" property="devModel"/>
<result column="plc_addr" property="plcAddr"/>
<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="run_model" property="runModel"/>
<result column="dev_desc" property="devDesc"/>
</resultMap>
<!-- 新增设备(空字段忽略,规范优化版) -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_dev_info (
<trim prefix="" suffix="" suffixOverrides=",">
<!-- 设备专属字段(修正 test 表达式 + 关键字转义) -->
<if test="islandId != null">island_id,</if>
<if test="devName != null and devName != ''">dev_name,</if>
<if test="devModel != null and devModel != ''">dev_model,</if>
<if test="plcAddr != null">plc_addr,</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="runModel != null">run_model,</if>
<if test="devDesc != null and devDesc != ''">`dev_desc`,</if> <!-- 核心修正dev_desc → devDesc + 反引号 -->
<!-- 通用字段(仅保留必要的人工传入字段,时间字段由数据库/代码自动生成) -->
<if test="createId != null">create_id,</if>
<if test="remark != null and remark != ''">remark,</if>
<!-- 固定写入:创建/更新时间由数据库生成删除标识默认0 -->
create_time,
update_time,
del_sign
</trim>
) VALUES (
<trim prefix="" suffix="" suffixOverrides=",">
<!-- 设备专属字段(与上方字段一一对应) -->
<if test="islandId != null">#{islandId},</if>
<if test="devName != null and devName != ''">#{devName},</if>
<if test="devModel != null and devModel != ''">#{devModel},</if>
<if test="plcAddr != null ">#{plcAddr},</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="runModel != null">#{runModel},</if>
<if test="devDesc != null and devDesc != ''">#{devDesc},</if> <!-- 核心修正dev_desc → devDesc -->
<!-- 通用字段(与上方字段一一对应) -->
<if test="createId != null">#{createId},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<!-- 固定值:创建/更新时间用数据库当前时间删除标识默认0 -->
NOW(),
NOW(),
0
</trim>
)
</insert>
<!-- 逻辑删除设备 -->
<update id="deleteById">
UPDATE tb_dev_info
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 根据ID更新设备非空字段才更新规范优化版 -->
<update id="updateById">
UPDATE tb_dev_info
<set>
<!-- 设备专属字段修正test表达式 + 关键字转义 + 规范空格 -->
<if test="islandId != null">island_id = #{islandId},</if>
<if test="devName != null and devName != ''">dev_name = #{devName},</if>
<if test="devModel != null and devModel != ''">dev_model = #{devModel},</if>
<if test="plcAddr != null">plc_addr = #{plcAddr},</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="runModel != null and runModel != ''">#{runModel},</if>
<!-- 核心修正dev_desc → devDesc + 反引号转义 -->
<if test="devDesc != null and devDesc != ''">`dev_desc` = #{devDesc},</if>
<!-- 通用字段 -->
<if test="updateId != null">update_id = #{updateId},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<!-- 固定更新时间:无论是否有其他字段更新,都刷新更新时间 -->
update_time = NOW()
</set>
<!-- 条件ID精准匹配 + 未删除,防止更新已删除数据 -->
WHERE id = #{id} AND del_sign = 0
<!-- 兜底:确保至少有一个业务字段更新(避免仅更新时间) -->
<if test="!(islandId != null
or (devName != null and devName != '')
or (devModel != null and devModel != '')
or plcAddr != null
or (ipAddr != null and ipAddr != '')
or port != null
or (protocolType != null and protocolType != '')
or (company != null and company != '')
or status != null
or (devDesc != null and devDesc != '')
or updateId != null
or (remark != null and remark != ''))">
AND 1 = 0 <!-- 无更新字段时让SQL条件不成立避免无效更新 -->
</if>
</update>
<!-- 根据ID查询设备 -->
<select id="selectById" resultMap="DevResultMap">
SELECT
<include refid="baseColumn"/>,
<include refid="devColumn"/>
FROM tb_dev_info
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 分页查询设备(多条件过滤) -->
<select id="selectPage" resultMap="DevResultMap">
SELECT
<include refid="baseColumn"/>,
<include refid="devColumn"/>
FROM tb_dev_info
WHERE del_sign = 0
<!-- 设备名称模糊查询 -->
<if test="devName != null and devName != ''">
AND dev_name LIKE CONCAT('%', #{devName}, '%')
</if>
<!-- 设备所属岛屿精准查询 -->
<if test="islandId != null">
AND island_id = #{islandId}
</if>
<!-- 设备型号模糊查询 -->
<if test="devModel != null and devModel != ''">
AND dev_model LIKE CONCAT('%', #{devModel}, '%')
</if>
<if test="plcAddr != null">
and plc_addr = #{plcAddr}
</if>
<!-- IP地址精准查询 -->
<if test="ipAddr != null and ipAddr != ''">
AND ip_addr = #{ipAddr}
</if>
<!-- 设备状态精准查询 -->
<if test="status != null">
AND status = #{status}
</if>
<if test="runModel != null and runModel != ''">
and run_model = #{runModel}
</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 tb_dev_info
WHERE del_sign = 0
<if test="devName != null and devName != ''">
AND dev_name LIKE CONCAT('%', #{devName}, '%')
</if>
<if test="islandId != null">
AND island_id = #{islandId}
</if>
<if test="devModel != null and devModel != ''">
AND dev_model LIKE CONCAT('%', #{devModel}, '%')
</if>
<if test="plcAddr != null">
and plc_addr = #{plcAddr}
</if>
<if test="ipAddr != null and ipAddr != ''">
AND ip_addr = #{ipAddr}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="runModel != null">
AND run_model = #{runModel}
</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 tb_dev_info
WHERE del_sign = 0
ORDER BY id ASC
</select>
<!-- 根据devinfo信息 -->
<select id="selectList" resultType="com.rczn.rcznautoplc.domain.DevInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="devColumn"/>
FROM tb_dev_info
WHERE del_sign = 0
<!-- 设备名称模糊查询 -->
<if test="devName != null and devName != ''">
AND dev_name LIKE CONCAT('%', #{devName}, '%')
</if>
<!-- 设备所属岛屿精准查询 -->
<if test="islandId != null">
AND island_id = #{islandId}
</if>
<!-- 设备型号模糊查询 -->
<if test="devModel != null and devModel != ''">
AND dev_model LIKE CONCAT('%', #{devModel}, '%')
</if>
<if test="plcAddr != null">
and plc_addr = #{plcAddr}
</if>
<!-- IP地址精准查询 -->
<if test="ipAddr != null and ipAddr != ''">
AND ip_addr = #{ipAddr}
</if>
<!-- 设备状态精准查询 -->
<if test="status != null">
AND status = #{status}
</if>
<if test="runModel != null and runModel != ''">
and run_model = #{runModel}
</if>
<!-- 协议类型精准查询 -->
<if test="protocolType != null and protocolType != ''">
AND protocol_type = #{protocolType}
</if>
ORDER BY update_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,126 @@
<?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.DevParamMapper">
<!-- BaseBean 公共字段 -->
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<!-- DevParam 业务字段 -->
<sql id="devParamColumn">
dev_ids, param_name, plc_addr, dic_data_id, param_value, param_type, param_unit, form_type, param_desc
</sql>
<!-- 新增:修复逗号缺失问题,统一格式 -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_dev_param (
<trim suffixOverrides=",">
<if test="devIds != null">dev_ids,</if>
<if test="plcAddr != null">plc_addr,</if>
<if test="dicDataId != null">dic_data_id,</if>
<if test="paramName != null and paramName != ''">param_name,</if>
<if test="paramValue != null and paramValue != ''">param_value,</if>
<if test="paramType != null and paramType != ''">param_type,</if>
<if test="paramUnit != null and paramUnit != ''">param_unit,</if>
<if test="formType != null and formType != ''">form_type,</if>
<if test="paramDesc != null and paramDesc != ''">param_desc,</if>
<if test="createId != null">create_id,</if>
<if test="updateId != null">update_id,</if>
create_time,
update_time,
del_sign
</trim>
)
VALUES (
<trim suffixOverrides=",">
<if test="devIds != null">#{devIds},</if>
<if test="plcAddr != null">#{plcAddr},</if>
<if test="dicDataId != null">#{dicDataId},</if>
<if test="paramName != null and paramName != ''">#{paramName},</if>
<if test="paramValue != null and paramValue != ''">#{paramValue},</if>
<if test="paramType != null and paramType != ''">#{paramType},</if>
<if test="paramUnit != null and paramUnit != ''">#{paramUnit},</if>
<if test="formType != null and formType != ''">#{formType},</if>
<if test="paramDesc != null and paramDesc != ''">#{paramDesc},</if>
<if test="createId != null">#{createId},</if>
<if test="updateId != null">#{updateId},</if>
NOW(),
NOW(),
0
</trim>
)
</insert>
<!-- 更新:无语法错误,保留原有逻辑 -->
<update id="update">
UPDATE tb_dev_param
<set>
<if test="devIds != null">dev_ids = #{devIds},</if>
<if test="plcAddr != null">plc_addr = #{plcAddr},</if>
<if test="dicDataId != null">dic_data_id = #{dicDataId},</if>
<if test="paramName != null and paramName != ''">param_name = #{paramName},</if>
<if test="paramValue != null and paramValue != ''">param_value = #{paramValue},</if>
<if test="paramType != null and paramType != ''">param_type = #{paramType},</if>
<if test="paramUnit != null and paramUnit != ''">param_unit = #{paramUnit},</if>
<if test="formType != null and formType != ''">form_type = #{formType},</if>
<if test="paramDesc != null and paramDesc != ''">param_desc = #{paramDesc},</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非空判断防止全表更新 -->
<update id="deleteById">
UPDATE tb_dev_param
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
<if test="id == null">AND 1=2</if>
</update>
<!-- 根据ID查询无语法错误 -->
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.DevParam">
SELECT
<include refid="baseColumn"/>,
<include refid="devParamColumn"/>
FROM tb_dev_param
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 分页查询修复参数名devId→devIds优化模糊匹配逻辑 -->
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.DevParam">
SELECT
<include refid="baseColumn"/>,
<include refid="devParamColumn"/>
FROM tb_dev_param
WHERE del_sign = 0
<if test="devId != null">
AND dev_ids LIKE CONCAT('%;', #{devId}, ';%')
</if>
<if test="paramTypeData != null and paramTypeData != ''">AND dic_data_id in (SELECT id FROM sys_dic_data WHERE dic_value LIKE CONCAT('%', #{paramTypeData}, '%'))</if>
<if test="paramName != null and paramName != ''">AND param_name LIKE CONCAT('%', #{paramName}, '%')</if>
<if test="paramValue != null and paramValue != ''">AND param_value LIKE CONCAT('%', #{paramValue}, '%')</if>
ORDER BY create_time DESC
</select>
<!-- 新增devId优化分隔符避免重复拼接; -->
<update id="addDevId">
UPDATE tb_dev_param
SET dev_ids = CASE
WHEN dev_ids IS NULL OR dev_ids = '' THEN CONCAT(#{devId}, ';')
ELSE CONCAT(dev_ids, #{devId}, ';')
END
WHERE id = #{paramId}
<if test="paramId == null">AND 1=2</if>
</update>
<!-- 删除devId兼容全匹配场景清理空字符串 -->
<update id="delDevId">
UPDATE tb_dev_param
SET dev_ids = REPLACE(dev_ids, CONCAT(#{devId}, ';'), '')
WHERE id = #{paramId}
<if test="paramId == null">AND 1=2</if>
</update>
</mapper>

View File

@@ -0,0 +1,112 @@
<?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.FlowInfoMapper">
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<sql id="flowInfoColumn">
flow_index, flow_name, island_id_list,busy_code,goods_code,goods_name,check_code,program_name,test_method,scan_num
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_flow_info (
<trim suffixOverrides=",">
<!-- 以下是基础表字段 -->
<if test="createId != null" >create_id, </if>
<if test="updateId != null" >update_id, </if>
<if test="createTime != null" >create_time, </if>
<if test="updateTime != null" >update_time, </if>
<if test="remark != null" >remark, </if>
<!-- 以下是表本身字段 -->
<if test="flowIndex != null" >flow_index, </if>
<if test="flowName != null and flowName != ''" >flow_name, </if>
<if test="islandIdList != null and islandIdList != ''" >island_id_list, </if>
<if test="busyCode != null and busyCode != ''" >busy_code, </if>
<if test="goodsCode != null and goodsCode != ''" >goods_code, </if>
<if test="goodsName != null and goodsName != ''" >goods_name, </if>
<if test="checkCode != null and checkCode != ''" >check_code, </if>
<if test="programName != null and programName != ''" >program_name, </if>
<if test="testMethod != null and testMethod != ''" >test_method, </if>
<if test="scanNum != null and scanNum != ''" >scan_num, </if>
</trim>
) VALUES (
<trim suffixOverrides=",">
<if test="createId != null" >#{createId}, </if>
<if test="updateId != null" >#{updateId}, </if>
<if test="createTime != null" >#{createTime}, </if>
<if test="updateTime != null" >#{updateTime}, </if>
<if test="remark != null" >#{remark}, </if>
<!-- 以下是表本身字段 -->
<if test="flowIndex != null" >#{flowIndex}, </if>
<if test="flowName != null and flowName != ''" >#{flowName}, </if>
<if test="islandIdList != null and islandIdList != ''" >#{islandIdList}, </if>
<if test="busyCode != null and busyCode != ''" >#{busyCode}, </if>
<if test="goodsCode != null and goodsCode != ''" >#{goodsCode}, </if>
<if test="goodsName != null and goodsName != ''" >#{goodsName}, </if>
<if test="checkCode != null and checkCode != ''" >#{checkCode}, </if>
<if test="programName != null and programName != ''" >#{programName}, </if>
<if test="testMethod != null and testMethod != ''" >#{testMethod}, </if>
<if test="scanNum != null and scanNum != ''" >#{scanNum}, </if>
</trim>
)
</insert>
<update id="update">
UPDATE tb_flow_info
<set>
<if test="flowIndex != null">flow_index = #{flowIndex},</if>
<if test="flowName != null and flowName != ''">flow_name = #{flowName},</if>
<if test="islandIdList != null and islandIdList != ''">island_id_list = #{islandIdList},</if>
<if test="busyCode!=null and busyCode != ''">busy_code = #{busyCode},</if>
<if test="goodsCode!=null and goodsCode != ''">goods_code = #{goodsCode},</if>
<if test="goodsName!=null and goodsName != ''">goods_name = #{goodsName},</if>
<if test="checkCode!=null and checkCode != ''">check_code = #{checkCode},</if>
<if test="programName!=null and programName != ''">program_name = #{programName},</if>
<if test="testMethod!=null and testMethod != ''">test_method = #{testMethod},</if>
<if test="scanNum!=null and scanNum != ''">scan_num = #{scanNum},</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_flow_info
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.FlowInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="flowInfoColumn"/>
FROM tb_flow_info
WHERE id = #{id} AND del_sign = 0
</select>
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.FlowInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="flowInfoColumn"/>
FROM tb_flow_info
WHERE del_sign = 0
<if test="flowIndex != null">AND flow_index = #{flowIndex}</if>
<if test="flowName != null and flowName != ''">AND flow_name LIKE CONCAT('%', #{flowName}, '%')</if>
<if test="islandIdList != null and islandIdList != ''">AND island_id_list LIKE CONCAT('%', #{islandIdList}, '%')</if>
<if test="busyCode != null and busyCode != ''">AND busy_code LIKE CONCAT('%', #{busyCode}, '%')</if>
<if test="goodsCode != null and goodsCode != ''">AND goods_code LIKE CONCAT('%', #{goodsCode}, '%')</if>
<if test="goodsName != null and goodsName != ''">AND goods_name LIKE CONCAT('%', #{goodsName}, '%')</if>
<if test="checkCode != null and checkCode != ''">AND check_code LIKE CONCAT('%', #{checkCode}, '%')</if>
<if test="programName != null and programName != ''">AND program_name LIKE CONCAT('%', #{programName}, '%')</if>
<if test="testMethod != null and testMethod != ''">AND test_method LIKE CONCAT('%', #{testMethod}, '%')</if>
<if test="scanNum != null and scanNum != ''">AND scan_num LIKE CONCAT('%', #{scanNum}, '%')</if>
ORDER BY flow_index ASC
</select>
</mapper>

View File

@@ -0,0 +1,64 @@
<?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.GoodsFlowStatusMapper">
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<sql id="goodsFlowStatusColumn">
goods_id, flow_id, island_id,dev_id, flow_sort, status
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_goods_flow_status (
<include refid="goodsFlowStatusColumn"/>,
create_id, create_time, update_id, update_time, del_sign
) VALUES (
#{goodsId}, #{flowId}, #{islandId},#{devId}, #{flowSort}, #{status},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<update id="update">
UPDATE tb_goods_flow_status
<set>
<if test="goodsId != null">goods_id = #{goodsId},</if>
<if test="flowId != null">flow_id = #{flowId},</if>
<if test="islandId != null">island_id = #{islandId},</if>
<if test="flowSort != null">flow_sort = #{flowSort},</if>
<if test="devId != null">dev_id = #{devId},</if>
<if test="status != null">status = #{status},</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_goods_flow_status
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.GoodsFlowStatus">
SELECT
<include refid="baseColumn"/>,
<include refid="goodsFlowStatusColumn"/>
FROM tb_goods_flow_status
WHERE id = #{id} AND del_sign = 0
</select>
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.GoodsFlowStatus">
SELECT
<include refid="baseColumn"/>,
<include refid="goodsFlowStatusColumn"/>
FROM tb_goods_flow_status
WHERE del_sign = 0
<if test="goodsId != null">AND goods_id = #{goodsId}</if>
<if test="flowId != null">AND flow_id = #{flowId}</if>
<if test="islandId != null">AND island_id = #{islandId}</if>
<if test="devId != null">AND dev_id = #{devId}</if>
<if test="status != null">AND status = #{status}</if>
ORDER BY flow_sort ASC
</select>
</mapper>

View File

@@ -0,0 +1,97 @@
<?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.GoodsInfoMapper">
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<sql id="goodsInfoColumn">
goods_name, goods_type, income_time, good_from, good_batch,point_num ,goal_detect,bar_code,flow_id,goods_status, `desc`
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_goods_info (
<include refid="goodsInfoColumn"/>,
create_id, create_time, update_id, update_time, del_sign
) VALUES (
#{goodsName}, #{goodsType}, #{incomeTime}, #{goodFrom}, #{goodBatch},#{pointNum},#{goalDetect}, #{barCode}, #{flowId}, #{goodsStatus}, #{desc},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<update id="update">
UPDATE tb_goods_info
<set>
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
<if test="goodsType != null and goodsType != ''">goods_type = #{goodsType},</if>
<if test="incomeTime != null">income_time = #{incomeTime},</if>
<if test="goodFrom != null and goodFrom != ''">good_from = #{goodFrom},</if>
<if test="goodBatch != null">good_batch = #{goodBatch},</if>
<if test="pointNum != null">point_num = #{pointNum},</if>
<if test="goalDetect != null">goal_detect = #{goalDetect},</if>
<if test="barCode != null and barCode != ''">bar_code = #{barCode},</if>
<if test="flowId != null">flow_id = #{flowId},</if>
<if test="goodsStatus != null and goodsStatus != ''">goods_status = #{goodsStatus},</if>
<if test="desc != null and desc != ''">`desc` = #{desc},</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_goods_info
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.GoodsInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="goodsInfoColumn"/>
FROM tb_goods_info
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 批量根据ID列表查询新增 -->
<select id="selectByIdList" resultType="com.rczn.rcznautoplc.domain.GoodsInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="goodsInfoColumn"/>
FROM tb_goods_info
WHERE del_sign = 0
AND id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
ORDER BY income_time DESC
</select>
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.GoodsInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="goodsInfoColumn"/>
FROM tb_goods_info
WHERE del_sign = 0
<if test="goodsName != null and goodsName != ''">AND goods_name LIKE CONCAT('%', #{goodsName}, '%')</if>
<if test="goodsType != null and goodsType != ''">AND goods_type LIKE CONCAT('%', #{goodsType}, '%')</if>
<if test="goodFrom != null and goodFrom != ''">AND good_from LIKE CONCAT('%', #{goodFrom}, '%')</if>
<if test="goodBatch != null">AND good_batch = #{goodBatch}</if>
<if test="pointNum != null">AND point_num = #{pointNum}</if>
<if test="goalDetect != null">AND goal_detect = #{goalDetect}</if>
<if test="barCode != null and barCode != ''">AND bar_code LIKE CONCAT('%', #{barCode}, '%')</if>
<if test="flowId != null and flowId != ''">AND flow_id LIKE CONCAT('%', #{flowId}, '%')</if>
<if test="incomeTime != null and incomeTime!=''" >AND income_time = #{incomeTime}</if>
<if test="startTime != null" >AND income_time >= #{startTime}</if>
<if test="endTime != null" >AND income_time &lt;= #{endTime}</if>
<if test="goodsStatus != null and goodsStatus != ''">AND goods_status LIKE CONCAT('%', #{goodsStatus}, '%')</if>
ORDER BY income_time,point_num DESC
</select>
<select id="selectByBarCode" resultType="com.rczn.rcznautoplc.domain.GoodsInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="goodsInfoColumn"/>
FROM tb_goods_info
WHERE bar_code = #{barCode} AND del_sign = 0
</select>
</mapper>

View File

@@ -0,0 +1,75 @@
<?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.IslandInfoMapper">
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<sql id="islandInfoColumn">
island_name, island_code, plc_addr, island_logo, `desc`
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_island_info (
<include refid="islandInfoColumn"/>,
create_id, create_time, update_id, update_time, del_sign
) VALUES (
#{islandName}, #{islandCode},#{plcAddr}, #{islandLogo}, #{desc},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<update id="update">
UPDATE tb_island_info
<set>
<if test="islandName != null and islandName != ''">island_name = #{islandName},</if>
<if test="islandCode != null and islandCode != ''">island_code = #{islandCode},</if>
<if test="plcAddr != null and plcAddr != ''">plc_addr = #{plcAddr},</if>
<if test="islandLogo != null and islandLogo != ''">island_logo = #{islandLogo},</if>
<if test="desc != null and desc != ''">`desc` = #{desc},</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_island_info
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.IslandInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="islandInfoColumn"/>
FROM tb_island_info
WHERE id = #{id} AND del_sign = 0
</select>
<!-- selectList:根据IslandInfo条件查询记录 -->
<select id="selectList" resultType="com.rczn.rcznautoplc.domain.query.IslandInfoQuery">
SELECT
<include refid="baseColumn"/>,
<include refid="islandInfoColumn"/>
FROM tb_island_info
WHERE del_sign = 0
<if test="islandName != null and islandName != ''">AND island_name LIKE CONCAT('%', #{islandName}, '%')</if>
<if test="islandCode != null and islandCode != ''">AND island_code LIKE CONCAT('%', #{islandCode}, '%')</if>
<if test="plcAddr != null ">AND plc_addr = #{plcAddr} </if>
ORDER BY create_time DESC
</select>
<!-- selectPage:根据IslandInfo条件查询分页记录 -->
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.IslandInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="islandInfoColumn"/>
FROM tb_island_info
WHERE del_sign = 0
<if test="islandName != null and islandName != ''">AND island_name LIKE CONCAT('%', #{islandName}, '%')</if>
<if test="islandCode != null and islandCode != ''">AND island_code LIKE CONCAT('%', #{islandCode}, '%')</if>
<if test="plcAddr != null ">AND plc_addr = #{plcAddr} </if>
ORDER BY create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,131 @@
<?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.IslandParamMapper">
<!-- 1. 公共字段定义BaseBean + 业务字段) -->
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<sql id="islandParamColumn">
island_id, step_id, param_name, param_type, param_unit, param_value, form_type
</sql>
<!-- 2. 关联查询结果集(映射 IslandParam + IslandInfo + StepInfo -->
<resultMap id="IslandParamResultMap" type="com.rczn.rcznautoplc.domain.IslandParam">
<!-- 基础字段映射 -->
<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="island_id" property="islandId"/>
<result column="step_id" property="stepId"/>
<result column="param_name" property="paramName"/>
<result column="param_type" property="paramType"/>
<result column="param_unit" property="paramUnit"/>
<result column="param_value" property="paramValue"/>
<result column="form_type" property="formType"/>
<!-- 关联岛屿信息(一对一):通过 island_id 关联 island_info 表 -->
<association property="islandInfo" javaType="com.rczn.rcznautoplc.domain.IslandInfo">
<id column="island_id" property="id"/> <!-- island_info 的主键是 id与 tb_island_param 的 island_id 关联 -->
<result column="island_name" property="islandName"/>
<result column="island_code" property="islandCode"/>
<result column="island_logo" property="islandLogo"/>
<result column="island_desc" property="desc"/> <!-- 注意island_info 的 desc 字段别名,避免与主表冲突 -->
</association>
<!-- 关联步骤信息(一对一):通过 step_id 关联 step_info 表 -->
<association property="stepInfo" javaType="com.rczn.rcznautoplc.domain.StepInfo">
<id column="step_id" property="id"/> <!-- step_info 的主键是 id与 tb_island_param 的 step_id 关联 -->
<result column="step_name" property="stepName"/>
<result column="step_desc" property="stepDesc"/>
</association>
</resultMap>
<!-- 3. 新增 -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_island_param (
<include refid="islandParamColumn"/>,
create_id, create_time, update_id, update_time, del_sign
) VALUES (
#{islandId}, #{stepId}, #{paramName}, #{paramType}, #{paramUnit}, #{paramValue}, #{formType},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<!-- 4. 更新(非空字段才更新) -->
<update id="update">
UPDATE tb_island_param
<set>
<if test="islandId != null">island_id = #{islandId},</if>
<if test="stepId != null">step_id = #{stepId},</if>
<if test="paramName != null and paramName != ''">param_name = #{paramName},</if>
<if test="paramType != null and paramType != ''">param_type = #{paramType},</if>
<if test="paramUnit != null and paramUnit != ''">param_unit = #{paramUnit},</if>
<if test="paramValue != null and paramValue != ''">param_value = #{paramValue},</if>
<if test="formType != null and formType != ''">form_type = #{formType},</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>
<!-- 5. 逻辑删除 -->
<update id="deleteById">
UPDATE tb_island_param
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 6. 根据ID查询关联岛屿和步骤信息 -->
<select id="selectById" resultMap="IslandParamResultMap">
SELECT
ip.*,
ii.island_name, ii.island_code, ii.island_logo, ii.`desc` AS island_desc, -- 别名避免冲突
si.step_name, si.step_desc
FROM tb_island_param ip
LEFT JOIN island_info ii ON ip.island_id = ii.id AND ii.del_sign = 0 -- 关联岛屿表,过滤已删除数据
LEFT JOIN step_info si ON ip.step_id = si.id AND si.del_sign = 0 -- 关联步骤表,过滤已删除数据
WHERE ip.id = #{id} AND ip.del_sign = 0
</select>
<!-- 7. 分页查询(不关联关联对象,性能更优) -->
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.IslandParam">
SELECT
<include refid="baseColumn"/>,
<include refid="islandParamColumn"/>
FROM tb_island_param
WHERE del_sign = 0
<if test="islandId != null">AND island_id = #{islandId}</if>
<if test="stepId != null">AND step_id = #{stepId}</if>
<if test="paramName != null and paramName != ''">AND param_name LIKE CONCAT('%', #{paramName}, '%')</if>
<if test="paramType != null and paramType != ''">AND param_type = #{paramType}</if>
<if test="formType != null and formType != ''">AND form_type = #{formType}</if>
ORDER BY ip.create_time DESC
</select>
<!-- 8. 分页查询(关联岛屿和步骤信息) -->
<select id="selectPageWithRelations" resultMap="IslandParamResultMap">
SELECT
ip.*,
ii.island_name, ii.island_code, ii.island_logo, ii.`desc` AS island_desc,
si.step_name, si.step_desc
FROM tb_island_param ip
LEFT JOIN island_info ii ON ip.island_id = ii.id AND ii.del_sign = 0
LEFT JOIN step_info si ON ip.step_id = si.id AND si.del_sign = 0
WHERE ip.del_sign = 0
<if test="islandId != null">AND ip.island_id = #{islandId}</if>
<if test="stepId != null">AND ip.step_id = #{stepId}</if>
<if test="paramName != null and paramName != ''">AND ip.param_name LIKE CONCAT('%', #{paramName}, '%')</if>
<if test="paramType != null and paramType != ''">AND ip.param_type = #{paramType}</if>
<if test="formType != null and formType != ''">AND ip.form_type = #{formType}</if>
ORDER BY ip.create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,175 @@
<?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.ManageLogMapper">
<!-- 公共字段BaseBean 继承的字段) -->
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<!-- ManageLog 专属字段 -->
<sql id="logColumn">
log_name, log_type, log_writetime, log_content
</sql>
<!-- 结果集映射(关联数据库列与实体类字段) -->
<resultMap id="LogResultMap" type="com.rczn.rcznautoplc.domain.ManageLog">
<!-- 公共字段映射 -->
<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="log_name" property="logName"/>
<result column="log_type" property="logType"/>
<result column="log_writetime" property="logWritetime"/>
<result column="log_content" property="logContent"/>
</resultMap>
<!-- 1. 新增日志(空字段忽略,用数据库默认值) -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sys_manage_log (
<trim suffixOverrides=",">
<!-- 专属字段 -->
<if test="logName != null and logName != ''"> log_name,</if>
<if test="logType != null and logType != ''"> log_type,</if>
<if test="logWritetime != null"> log_writetime,</if>
<if test="logContent != null and logContent != ''"> log_content,</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="delSign != null"> del_sign,</if>
<if test="remark != null and remark != ''"> remark,</if>
</trim>
) VALUES (
<trim suffixOverrides=",">
<!-- 专属字段:空字段传递 null数据库设默认值 -->
<if test="logName != null and logName != ''">#{logName},</if>
<if test="logType != null and logType != ''">#{logType},</if>
<if test="logWritetime != null">#{logWritetime},</if>
<if test="logContent != null and logContent != ''">#{logContent},</if>
<!-- 公共字段:空字段传递 null数据库设默认值 -->
<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="delSign != null">#{delSign},</if>
<if test="remark != null and remark != ''">#{remark},</if>
</trim>
)
</insert>
<!-- 2. 更新日志(仅更新非空字段) -->
<update id="update">
UPDATE sys_manage_log
<set>
<!-- 专属字段:非空才更新 -->
<if test="logName != null and logName != ''">log_name = #{logName},</if>
<if test="logType != null and logType != ''">log_type = #{logType},</if>
<if test="logWritetime != null">log_writetime = #{logWritetime},</if>
<if test="logContent != null and logContent != ''">log_content = #{logContent},</if>
<!-- 公共字段:非空才更新 -->
<if test="updateId != null">update_id = #{updateId},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="delSign != null">del_sign = #{delSign},</if>
<!-- 强制更新时间为当前时间 -->
update_time = NOW()
</set>
WHERE id = #{id}
AND del_sign = 0 <!-- 仅更新未删除的数据 -->
</update>
<!-- 3. 逻辑删除日志 -->
<delete id="deleteById">
UPDATE sys_manage_log
SET
del_sign = 1,
update_time = NOW(),
<if test="updateId != null">update_id = #{updateId}</if>
WHERE id = #{id}
AND del_sign = 0 <!-- 避免重复删除 -->
</delete>
<!-- 4. 按 ID 查询日志 -->
<select id="selectById" resultMap="LogResultMap">
SELECT
<include refid="baseColumn"/>,
<include refid="logColumn"/>
FROM sys_manage_log
WHERE id = #{id}
AND del_sign = 0 <!-- 仅查未删除数据 -->
</select>
<!-- 5. 分页查询日志(空字段忽略条件) -->
<select id="selectPage" resultMap="LogResultMap" parameterType="com.rczn.rcznautoplc.domain.ManageLog">
SELECT
<include refid="baseColumn"/>,
<include refid="logColumn"/>
FROM sys_manage_log
<where>
<!-- 默认查未删除数据,传 delSign=1 可查已删除 -->
<if test="delSign == null">
AND del_sign = 0
</if>
<if test="delSign != null">
AND del_sign = #{delSign}
</if>
<!-- 日志名称:模糊查询,空字段忽略 -->
<if test="logName != null and logName != ''">
AND log_name LIKE CONCAT('%', #{logName}, '%')
</if>
<!-- 日志类型:精准查询,空字段忽略 -->
<if test="logType != null and logType != ''">
AND log_type = #{logType}
</if>
<!-- 日志写入时间:范围查询(可选,空字段忽略) -->
<if test="startTime != null">
AND log_writetime >= #{startTime}
</if>
<if test="endTime != null">
AND log_writetime &lt;= #{endTime}
</if>
<!-- 创建人ID精准查询空字段忽略 -->
<if test="createId != null">
AND create_id = #{createId}
</if>
</where>
ORDER BY log_writetime DESC <!-- 按日志写入时间倒序 -->
</select>
<!-- 6. 查询分页总数(与分页查询条件一致) -->
<select id="selectTotal" resultType="java.lang.Long" parameterType="com.rczn.rcznautoplc.domain.ManageLog">
SELECT COUNT(*)
FROM sys_manage_log
<where>
<if test="delSign == null">
AND del_sign = 0
</if>
<if test="delSign != null">
AND del_sign = #{delSign}
</if>
<if test="logName != null and logName != ''">
AND log_name LIKE CONCAT('%', #{logName}, '%')
</if>
<if test="logType != null and logType != ''">
AND log_type = #{logType}
</if>
<if test="logWritetimeStart != null">
AND log_writetime >= #{logWritetimeStart}
</if>
<if test="logWritetimeEnd != null">
AND log_writetime &lt;= #{logWritetimeEnd}
</if>
<if test="createId != null">
AND create_id = #{createId}
</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,60 @@
<?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.RecordInfoMapper">
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<sql id="recordInfoColumn">
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 (
#{recordName}, #{recordType}, #{recordStatus}, #{recordContent},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<update id="update">
UPDATE tb_record_info
<set>
<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>
<if test="recordContent != null and recordContent != ''">record_content = #{recordContent},</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_info
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.RecordInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="recordInfoColumn"/>
FROM tb_record_info
WHERE id = #{id} AND del_sign = 0
</select>
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.RecordInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="recordInfoColumn"/>
FROM tb_record_info
WHERE del_sign = 0
<if test="recordName != null and recordName != ''">AND record_name LIKE CONCAT('%', #{recordName}, '%')</if>
<if test="recordType != null">AND record_type = #{recordType}</if>
<if test="recordStatus != null">AND record_status = #{recordStatus}</if>
ORDER BY create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,325 @@
<?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.StepInfoMapper">
<sql id="baseColumn">
id, create_id, create_time, update_id, update_time, del_sign, remark
</sql>
<sql id="stepInfoColumn">
island_id,dev_id,step_order ,step_name, step_desc,flow_id,param_name,param_type,param_unit,param_value,form_type
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_step_info (
<trim suffixOverrides=",">
<!-- 基础表字段 -->
<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 ">remark, </if>
<!-- 步骤表字段 -->
<if test="islandId != null">island_id, </if>
<if test="devId != null">dev_id, </if>
<if test="stepOrder != null" >step_order, </if>
<if test="stepName != null and stepName != ''">step_name, </if>
<if test="stepDesc != null and stepDesc != ''">step_desc, </if>
<if test="flowId != null">flow_id, </if>
<if test="paramName != null and paramName != ''">param_name, </if>
<if test="paramType != null and paramType != ''">param_type, </if>
<if test="paramUnit != null and paramUnit != ''">param_unit, </if>
<if test="paramValue != null and paramValue != ''">param_value, </if>
<if test="formType != null and formType != ''">form_type, </if>
</trim>
) VALUES (
<trim suffixOverrides=",">
<!-- 基础表字段 -->
<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 ">#{remark}, </if>
<!-- 步骤表字段 -->
<if test="islandId != null">#{islandId}, </if>
<if test="devId != null">#{devId}, </if>
<if test="stepOrder != null" >#{stepOrder}, </if>
<if test="stepName != null and stepName != ''">#{stepName}, </if>
<if test="stepDesc != null and stepDesc != ''">#{stepDesc}, </if>
<if test="flowId != null">#{flowId}, </if>
<if test="paramName != null and paramName != ''">#{paramName}, </if>
<if test="paramType != null and paramType != ''">#{paramType}, </if>
<if test="paramUnit != null and paramUnit != ''">#{paramUnit}, </if>
<if test="paramValue != null and paramValue != ''">#{paramValue}, </if>
<if test="formType != null and formType != ''">#{formType}, </if>
</trim>
)
</insert>
<!-- 新增批量插入SQL -->
<insert id="insertBatch" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_step_info (
<trim suffixOverrides=",">
create_id,
create_time,
update_id,
update_time,
remark,
del_sign,
island_id,
dev_id,
step_order,
step_name,
step_desc,
flow_id,
param_name,
param_type,
param_unit,
param_value,
form_type
</trim>
) VALUES
<foreach collection="stepInfoList" item="item" separator=",">
(
<trim suffixOverrides=",">
#{item.createId,jdbcType=BIGINT},
NOW(),
#{item.updateId,jdbcType=BIGINT},
NOW(),
<if test="item.remark != null and item.remark != ''">#{item.remark},</if>
<if test="item.remark == null or item.remark == ''">null,</if>
0,
<if test="item.islandId != null">#{item.islandId,jdbcType=INTEGER},</if>
<if test="item.islandId == null">null,</if>
<if test="item.devId != null">#{item.devId,jdbcType=INTEGER},</if>
<if test="item.devId == null">null,</if>
<if test="item.stepOrder != null">#{item.stepOrder,jdbcType=INTEGER},</if>
<if test="item.stepOrder == null">null,</if>
<if test="item.stepName != null and item.stepName != ''">#{item.stepName},</if>
<if test="item.stepName == null or item.stepName == ''">null,</if>
<if test="item.stepDesc != null and item.stepDesc != ''">#{item.stepDesc},</if>
<if test="item.stepDesc == null or item.stepDesc == ''">null,</if>
<if test="item.flowId != null">#{item.flowId,jdbcType=INTEGER},</if>
<if test="item.flowId == null">null,</if>
<if test="item.paramName != null and item.paramName != ''">#{item.paramName},</if>
<if test="item.paramName == null or item.paramName == ''">null,</if>
<if test="item.paramType != null and item.paramType != ''">#{item.paramType},</if>
<if test="item.paramType == null or item.paramType == ''">null,</if>
<if test="item.paramUnit != null and item.paramUnit != ''">#{item.paramUnit},</if>
<if test="item.paramUnit == null or item.paramUnit == ''">null,</if>
<if test="item.paramValue != null and item.paramValue != ''">#{item.paramValue},</if>
<if test="item.paramValue == null or item.paramValue == ''">null,</if>
<if test="item.formType != null and item.formType != ''">#{item.formType},</if>
<if test="item.formType == null or item.formType == ''">null,</if>
</trim>
)
</foreach>
</insert>
<update id="updateBatch">
<foreach collection="stepInfoList" item="item" separator=";">
UPDATE tb_step_info
<set>
<if test="item.updateId != null">update_id = #{item.updateId,jdbcType=BIGINT},</if>
<if test="item.remark != null and item.remark != ''">remark = #{item.remark},</if>
<if test="item.islandId != null">island_id = #{item.islandId,jdbcType=INTEGER},</if>
<if test="item.devId != null">dev_id = #{item.devId,jdbcType=INTEGER},</if>
<if test="item.stepOrder != null">step_order = #{item.stepOrder,jdbcType=INTEGER},</if>
<if test="item.stepName != null and item.stepName != ''">step_name = #{item.stepName},</if>
<if test="item.stepDesc != null and item.stepDesc != ''">step_desc = #{item.stepDesc},</if>
<if test="item.flowId != null">flow_id = #{item.flowId,jdbcType=INTEGER},</if>
<if test="item.paramName != null and item.paramName != ''">param_name = #{item.paramName},</if>
<if test="item.paramType != null and item.paramType != ''">param_type = #{item.paramType},</if>
<if test="item.paramUnit != null and item.paramUnit != ''">param_unit = #{item.paramUnit},</if>
<if test="item.paramValue != null and item.paramValue != ''">param_value = #{item.paramValue},</if>
<if test="item.formType != null and item.formType != ''">form_type = #{item.formType},</if>
update_time = NOW()
</set>
WHERE id = #{item.id,jdbcType=BIGINT}
AND del_sign = 0
</foreach>
</update>
<!-- <update id="updateBatch">-->
<!-- UPDATE tb_step_info-->
<!-- <trim prefix="SET" suffixOverrides=",">-->
<!-- &lt;!&ndash; 批量更新核心用CASE WHEN匹配id赋值 &ndash;&gt;-->
<!-- update_id = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.updateId,jdbcType=BIGINT}-->
<!-- </foreach>-->
<!-- END,-->
<!-- remark = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.remark}-->
<!-- </foreach>-->
<!-- END,-->
<!-- island_id = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.islandId,jdbcType=INTEGER}-->
<!-- </foreach>-->
<!-- END,-->
<!-- dev_id = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.devId,jdbcType=INTEGER}-->
<!-- </foreach>-->
<!-- END,-->
<!-- step_order = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.stepOrder,jdbcType=INTEGER}-->
<!-- </foreach>-->
<!-- END,-->
<!-- step_name = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.stepName}-->
<!-- </foreach>-->
<!-- END,-->
<!-- step_desc = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.stepDesc}-->
<!-- </foreach>-->
<!-- END,-->
<!-- flow_id = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.flowId,jdbcType=INTEGER}-->
<!-- </foreach>-->
<!-- END,-->
<!-- param_name = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.paramName}-->
<!-- </foreach>-->
<!-- END,-->
<!-- param_type = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.paramType}-->
<!-- </foreach>-->
<!-- END,-->
<!-- param_unit = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.paramUnit}-->
<!-- </foreach>-->
<!-- END,-->
<!-- param_value = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.paramValue}-->
<!-- </foreach>-->
<!-- END,-->
<!-- form_type = CASE-->
<!-- <foreach collection="stepInfoList" item="item" separator="">-->
<!-- WHEN id = #{item.id,jdbcType=BIGINT} THEN #{item.formType}-->
<!-- </foreach>-->
<!-- END,-->
<!-- &#45;&#45; 所有记录统一更新update_time-->
<!-- update_time = NOW()-->
<!-- </trim>-->
<!-- &lt;!&ndash; 只更新传入的id列表 &ndash;&gt;-->
<!-- WHERE id IN-->
<!-- <foreach collection="stepInfoList" item="item" open="(" separator="," close=")">-->
<!-- #{item.id,jdbcType=BIGINT}-->
<!-- </foreach>-->
<!-- AND del_sign = 0-->
<!-- </update>-->
<update id="update">
UPDATE tb_step_info
<set>
<if test="islandId != null">island_id = #{islandId},</if>
<if test="devId != null">dev_id = #{devId},</if>
<if test="stepOrder != null" >step_order = #{stepOrder},</if>
<if test="stepName != null and stepName != ''">step_name = #{stepName},</if>
<if test="stepDesc != null and stepDesc != ''">step_desc = #{stepDesc},</if>
<if test="updateId != null">update_id = #{updateId},</if>
<if test="remark != null ">remark = #{remark},</if>
<if test="flowId != null">flow_id = #{flowId},</if>
<if test="paramName != null and paramName != ''">param_name = #{paramName},</if>
<if test="paramType != null and paramType != ''">param_type = #{paramType},</if>
<if test="paramUnit != null and paramUnit != ''">param_unit = #{paramUnit},</if>
<if test="paramValue != null and paramValue != ''">param_value = #{paramValue},</if>
<if test="formType != null and formType != ''">form_type = #{formType},</if>
update_time = NOW()
</set>
WHERE id = #{id} AND del_sign = 0
</update>
<update id="deleteById">
UPDATE tb_step_info
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<update id="deleteBatchByIds">
<if test="ids != null and ids.size() > 0">
UPDATE tb_step_info
SET del_sign = 1, update_time = NOW()
WHERE id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
AND del_sign = 0
</if>
</update>
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.StepInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="stepInfoColumn"/>
FROM tb_step_info
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 适配 List<StepInfo> selectList(StepInfo stepInfo) 接口的SQL -->
<select id="selectList" parameterType="com.rczn.rcznautoplc.domain.StepInfo" resultType="com.rczn.rcznautoplc.domain.StepInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="stepInfoColumn"/>
FROM tb_step_info
WHERE del_sign = 0
<!-- 动态条件:非空参数才拼接 -->
<if test="islandId != null">
AND island_id = #{islandId}
</if>
<if test="devId != null">
AND dev_id = #{devId}
</if>
<if test="flowId != null">
AND flow_id = #{flowId}
</if>
<if test="stepName != null and stepName != ''">
AND step_name LIKE CONCAT('%', #{stepName}, '%')
</if>
<if test="paramName != null and paramName != ''">
AND param_name LIKE CONCAT('%', #{paramName}, '%')
</if>
<if test="formType != null and formType != ''">
AND form_type = #{formType}
</if>
<if test="stepOrder != null">
AND step_order = #{stepOrder}
</if>
<!-- 排序:按步骤顺序升序、创建时间降序 -->
ORDER BY step_order ASC, create_time DESC
</select>
<select id="selectPage" resultType="com.rczn.rcznautoplc.domain.StepInfo">
SELECT
<include refid="baseColumn"/>,
<include refid="stepInfoColumn"/>
FROM tb_step_info
WHERE del_sign = 0
<if test="islandId != null">AND island_id = #{islandId}</if>
<if test="devId != null">AND dev_id = #{devId}</if>
<if test="stepName != null and stepName != ''">AND step_name LIKE CONCAT('%', #{stepName}, '%')</if>
<if test="flowId != null">AND flow_id = #{flowId}</if>
<if test="paramName != null and paramName != ''">AND param_name LIKE CONCAT('%', #{paramName}, '%')</if>
<if test="paramType != null and paramType != ''">AND param_type LIKE CONCAT('%', #{paramType}, '%')</if>
<if test="paramUnit != null and paramUnit != ''">AND param_unit LIKE CONCAT('%', #{paramUnit}, '%')</if>
<if test="paramValue != null and paramValue != ''">AND param_value LIKE CONCAT('%', #{paramValue}, '%')</if>
ORDER BY create_time DESC
</select>
</mapper>