动作参数取值范围+角色配置权限
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
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-功能岛id,value-功能岛plc地址
|
||||
public static final Map<Integer, Integer> islandToPlc = new HashMap<>();
|
||||
|
||||
// 2-动作单元>plc地址:key-动作单元id,value-动作单元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-参数id,value-参数plc地址
|
||||
public static final Map<Integer,Integer> paramIdToPlc = new HashMap<>();
|
||||
//更新三种数据的方法
|
||||
//获取spring里面bean
|
||||
//1-功能岛>plc地址
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
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;//协议存储寄存器地址:
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
@@ -26,7 +25,7 @@ import java.util.Map;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/devInfo")
|
||||
@Tag(name = "动作单元管理", description = "设备增删改查+分页查询+全量查询接口")
|
||||
@Tag(name = "设备管理", description = "设备增删改查+分页查询+全量查询接口")
|
||||
public class DevInfoController {
|
||||
|
||||
@Autowired
|
||||
@@ -36,15 +35,15 @@ public class DevInfoController {
|
||||
* 新增设备
|
||||
*/
|
||||
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "新增动作单元", description = "动作单元名称为必填项,其他字段可选(非空则入库)")
|
||||
@Operation(summary = "新增设备", description = "设备名称为必填项,其他字段可选(非空则入库)")
|
||||
public ResponseEntity<Map<String, Object>> addDevInfo(
|
||||
@Parameter(name = "动作单元信息", description = "动作单元新增请求参数", required = true)
|
||||
@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 ? "动作单元新增成功" : "动作单元新增失败");
|
||||
result.put("message", success ? "设备新增成功" : "设备新增失败");
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
@@ -61,15 +60,15 @@ public class DevInfoController {
|
||||
* 根据ID删除设备(逻辑删除)
|
||||
*/
|
||||
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "删除动作单元", description = "逻辑删除(设置delSign=1,不物理删除数据)")
|
||||
@Operation(summary = "删除设备", description = "逻辑删除(设置delSign=1,不物理删除数据)")
|
||||
public ResponseEntity<Map<String, Object>> removeDevInfoById(
|
||||
@Parameter(name = "id", description = "动作单元ID", required = true, example = "1")
|
||||
@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 ? "动作单元删除成功" : "动作单元不存在或已删除");
|
||||
result.put("message", success ? "设备删除成功" : "设备不存在或已删除");
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
@@ -86,15 +85,15 @@ public class DevInfoController {
|
||||
* 更新设备
|
||||
*/
|
||||
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "修改动作单元", description = "需传入动作单元ID,其他字段可选(非空则更新)")
|
||||
@Operation(summary = "修改设备", description = "需传入设备ID,其他字段可选(非空则更新)")
|
||||
public ResponseEntity<Map<String, Object>> updateDevInfo(
|
||||
@Parameter(name = "动作单元信息", description = "动作单元修改请求参数(含ID)", required = true)
|
||||
@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 ? "动作单元更新成功" : "动作单元不存在或已删除");
|
||||
result.put("message", success ? "设备更新成功" : "设备不存在或已删除");
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
@@ -108,12 +107,12 @@ public class DevInfoController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询动作单元
|
||||
* 根据ID查询设备
|
||||
*/
|
||||
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "查询单个动作单元", description = "根据动作单元ID查询动作单元完整信息")
|
||||
@Operation(summary = "查询单个设备", description = "根据设备ID查询设备完整信息")
|
||||
public ResponseEntity<Map<String, Object>> getDevInfoById(
|
||||
@Parameter(name = "id", description = "动作单元ID", required = true, example = "1")
|
||||
@Parameter(name = "id", description = "设备ID", required = true, example = "1")
|
||||
@PathVariable Long id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
@@ -123,7 +122,7 @@ public class DevInfoController {
|
||||
result.put("data", devInfo);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "动作单元不存在或已删除");
|
||||
result.put("message", "设备不存在或已删除");
|
||||
}
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
@@ -138,29 +137,33 @@ public class DevInfoController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询动作单元
|
||||
* 示例:/devInfo/listPage?pageNum=1&pageSize=10&devName=动作单元1&status=0
|
||||
* 分页查询设备
|
||||
* 示例:/devInfo/listPage?pageNum=1&pageSize=10&devName=设备1&status=0
|
||||
*/
|
||||
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "分页查询动作单元", description = "支持动作单元名称、型号、IP、状态等多条件过滤,默认查询未删除动作单元")
|
||||
@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(
|
||||
public ResponseEntity<Map<String, Object>> getDevInfoPage(
|
||||
@ParameterObject // 核心注解:标记该实体类从查询参数取值
|
||||
@Schema(description = "设备查询条件(可选)") // 补充描述
|
||||
DevInfo devInfo, // 接收查询条件(devName、status等)
|
||||
@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
PageInfo<DevInfo> pageInfo = devInfoService.getDevInfoPage(devInfo, pageNum, pageSize);
|
||||
Result<PageInfo<DevInfo>> success = Result.success(pageInfo);
|
||||
return success;
|
||||
result.put("success", true);
|
||||
result.put("data", pageInfo);
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("数据库异常!");
|
||||
result.put("success", false);
|
||||
result.put("message", "服务器异常:" + e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -34,7 +33,6 @@ public class DevParamController {
|
||||
@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)
|
||||
})
|
||||
@@ -42,10 +40,9 @@ public class DevParamController {
|
||||
@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);
|
||||
PageInfo<DevParam> pageBean = devParamService.selectPage(pageNum, pageSize, devId, paramName, paramValue);
|
||||
return Result.success(pageBean);
|
||||
}
|
||||
|
||||
@@ -56,57 +53,17 @@ public class DevParamController {
|
||||
@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);
|
||||
List<DevParam> pageBean = devParamService.selectList( devId, paramName, paramValue);
|
||||
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查询设备参数
|
||||
*/
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
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.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;
|
||||
@@ -17,10 +14,7 @@ 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")
|
||||
@@ -30,6 +24,7 @@ public class FlowInfoController {
|
||||
@Autowired
|
||||
FlowInfoService flowInfoService;
|
||||
|
||||
|
||||
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "分页查询流程信息", description = "支持流程排序精准查询、流程名称/岛屿ID列表模糊查询")
|
||||
@Parameters({
|
||||
@@ -76,23 +71,6 @@ public class FlowInfoController {
|
||||
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:登录日志、2:SOP操作日志、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());
|
||||
@@ -110,31 +88,11 @@ public class FlowInfoController {
|
||||
}
|
||||
}
|
||||
|
||||
@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:登录日志、2:SOP操作日志、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());
|
||||
|
||||
@@ -4,21 +4,16 @@ 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 = "样品流程状态增删改查+分页查询接口")
|
||||
@@ -33,29 +28,22 @@ public class GoodsFlowStatusController {
|
||||
@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 = "goodsId", description = "样品ID(可选,精准查询)", required = false, example = "1", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "flowId", description = "流程ID(可选,精准查询)", required = false, example = "1", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "islandId", description = "岛屿ID(可选,精准查询)", required = false, example = "1", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "status", description = "状态(可选,精准查询:0-未执行,1-执行,10-通过,11-失败)", required = false, 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);
|
||||
@RequestParam(required = false) Integer goodsId,
|
||||
@RequestParam(required = false) Integer flowId,
|
||||
@RequestParam(required = false) Integer islandId,
|
||||
@RequestParam(required = false) Integer status) {
|
||||
PageInfo<GoodsFlowStatus> pageBean = goodsFlowStatusService.selectPage(pageNum, pageSize, goodsId, flowId, islandId, status);
|
||||
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) {
|
||||
|
||||
@@ -4,21 +4,16 @@ 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 = "样品信息增删改查+分页查询接口")
|
||||
@@ -34,37 +29,23 @@ public class GoodsInfoController {
|
||||
@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)
|
||||
@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);
|
||||
@RequestParam(required = false) String goodsName,
|
||||
@RequestParam(required = false) String goodsType,
|
||||
@RequestParam(required = false) String goodFrom,
|
||||
@RequestParam(required = false) Integer goodBatch) {
|
||||
PageInfo<GoodsInfo> pageBean = goodsInfoService.selectPage(pageNum, pageSize, goodsName, goodsType, goodFrom, goodBatch);
|
||||
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查询样品信息
|
||||
*/
|
||||
@@ -89,21 +70,6 @@ public class GoodsInfoController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码新增样品信息
|
||||
* 扫码信息:样品类型、样品编码、样品名称、样品点位
|
||||
*/
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改样品信息
|
||||
*/
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 设备信息 Controller(RESTful 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里面的stepOrder(int)排序
|
||||
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:登录日志、2:SOP操作日志、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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,15 +4,12 @@ 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.*;
|
||||
@@ -27,31 +24,35 @@ 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)
|
||||
@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 = "stepName", description = "步骤名称(可选,模糊查询)", required = false, example = "检测", 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);
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam(required = false) Integer islandId,
|
||||
@RequestParam(required = false) String stepName) {
|
||||
PageInfo<StepInfo> pageBean = stepInfoService.selectPage(pageNum, pageSize, islandId, stepName);
|
||||
return Result.success(pageBean);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "查询步骤信息", description = "支持岛屿ID精准查询、步骤名称模糊查询")
|
||||
@Parameters({
|
||||
@Parameter(name = "islandId", description = "岛屿ID(可选,精准查询)", required = false, example = "1", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "stepName", description = "步骤名称(可选,模糊查询)", required = false, example = "检测", in = ParameterIn.QUERY)
|
||||
})
|
||||
public Result getStepInfoList(
|
||||
@ParameterObject // 核心注解:标记该实体类从查询参数取值
|
||||
@Schema(description = "设备查询条件(可选)") // 补充描述
|
||||
StepInfoQuery stepInfo) {
|
||||
List<StepInfo> list = stepInfoService.selectList( stepInfo);
|
||||
@RequestParam(required = false) Integer islandId,
|
||||
@RequestParam(required = false) String stepName) {
|
||||
List<StepInfo> list = stepInfoService.selectList( islandId, stepName);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@@ -73,30 +74,6 @@ public class StepInfoController {
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
@@ -118,16 +95,4 @@ public class StepInfoController {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -17,9 +15,6 @@ public class DevInfo extends BaseBean {
|
||||
//设备型号
|
||||
private String devModel;
|
||||
|
||||
//plc映射地址
|
||||
private Integer plcAddr;
|
||||
|
||||
//设备IP地址
|
||||
private String ipAddr;
|
||||
|
||||
@@ -31,8 +26,6 @@ public class DevInfo extends BaseBean {
|
||||
|
||||
private Integer status; // 0-空闲,1-运行,4-故障
|
||||
|
||||
private Integer runModel;//0-手动模式,1-自动模式
|
||||
|
||||
private String devDesc;
|
||||
|
||||
public DevInfo() {
|
||||
@@ -66,14 +59,6 @@ public class DevInfo extends BaseBean {
|
||||
this.devModel = devModel;
|
||||
}
|
||||
|
||||
public Integer getPlcAddr() {
|
||||
return plcAddr;
|
||||
}
|
||||
|
||||
public void setPlcAddr(Integer plcAddr) {
|
||||
this.plcAddr = plcAddr;
|
||||
}
|
||||
|
||||
public String getIpAddr() {
|
||||
return ipAddr;
|
||||
}
|
||||
@@ -114,14 +99,6 @@ public class DevInfo extends BaseBean {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getRunModel() {
|
||||
return runModel;
|
||||
}
|
||||
|
||||
public void setRunModel(Integer runModel) {
|
||||
this.runModel = runModel;
|
||||
}
|
||||
|
||||
public String getDevDesc() {
|
||||
return devDesc;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
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 Integer devId;
|
||||
|
||||
private String paramName;
|
||||
//plc映射地址
|
||||
private Integer plcAddr;
|
||||
|
||||
private String paramValue;
|
||||
|
||||
@@ -24,10 +16,8 @@ public class DevParam extends BaseBean {
|
||||
private String paramUnit;
|
||||
|
||||
private String formType;
|
||||
|
||||
private String paramDesc;
|
||||
|
||||
@JsonIgnore
|
||||
private DevInfo devInfo;
|
||||
|
||||
public DevParam() {
|
||||
@@ -37,12 +27,12 @@ public class DevParam extends BaseBean {
|
||||
super(id, createId, createTime, updateId, updateTime, delSign, remark);
|
||||
}
|
||||
|
||||
public String getDevIds() {
|
||||
return devIds;
|
||||
public Integer getDevId() {
|
||||
return devId;
|
||||
}
|
||||
|
||||
public void setDevIds(String devIds) {
|
||||
this.devIds = devIds;
|
||||
public void setDevId(Integer devId) {
|
||||
this.devId = devId;
|
||||
}
|
||||
|
||||
public String getParamName() {
|
||||
@@ -69,22 +59,6 @@ public class DevParam extends BaseBean {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -14,8 +11,6 @@ public class GoodsFlowStatus extends BaseBean {
|
||||
|
||||
private Integer islandId;
|
||||
|
||||
private Integer devId;
|
||||
|
||||
private Integer flowSort;
|
||||
|
||||
private Integer status; // 0-未执行,1-执行,10-通过,11-失败
|
||||
@@ -65,14 +60,6 @@ public class GoodsFlowStatus extends BaseBean {
|
||||
this.flowSort = flowSort;
|
||||
}
|
||||
|
||||
public Integer getDevId() {
|
||||
return devId;
|
||||
}
|
||||
|
||||
public void setDevId(Integer devId) {
|
||||
this.devId = devId;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -20,25 +16,15 @@ public class GoodsInfo extends BaseBean {
|
||||
|
||||
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 GoodsInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
|
||||
super(id, createId, createTime, updateId, updateTime, delSign, remark);
|
||||
}
|
||||
|
||||
public String getGoodsName() {
|
||||
return goodsName;
|
||||
}
|
||||
@@ -79,46 +65,6 @@ public class GoodsInfo extends BaseBean {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ public class IslandInfo extends BaseBean {
|
||||
|
||||
private String islandCode;
|
||||
|
||||
//plc映射地址
|
||||
private Integer plcAddr;
|
||||
|
||||
private String islandLogo;
|
||||
|
||||
private String desc;
|
||||
@@ -20,6 +17,10 @@ public class IslandInfo extends BaseBean {
|
||||
public IslandInfo() {
|
||||
}
|
||||
|
||||
public IslandInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
|
||||
super(id, createId, createTime, updateId, updateTime, delSign, remark);
|
||||
}
|
||||
|
||||
public String getIslandName() {
|
||||
return islandName;
|
||||
}
|
||||
@@ -36,14 +37,6 @@ public class IslandInfo extends BaseBean {
|
||||
this.islandCode = islandCode;
|
||||
}
|
||||
|
||||
public Integer getPlcAddr() {
|
||||
return plcAddr;
|
||||
}
|
||||
|
||||
public void setPlcAddr(Integer plcAddr) {
|
||||
this.plcAddr = plcAddr;
|
||||
}
|
||||
|
||||
public String getIslandLogo() {
|
||||
return islandLogo;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -22,10 +19,8 @@ public class IslandParam extends BaseBean {
|
||||
|
||||
private String formType;
|
||||
|
||||
@JsonIgnore
|
||||
private IslandInfo islandInfo;
|
||||
|
||||
@JsonIgnore
|
||||
private StepInfo stepInfo;
|
||||
|
||||
public IslandParam() {
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -20,12 +17,10 @@ public class StepInfo extends BaseBean {
|
||||
private String paramValue;
|
||||
private String formType;
|
||||
|
||||
private Integer stepOrder;
|
||||
private String stepName;
|
||||
|
||||
private String stepDesc;
|
||||
|
||||
@JsonIgnore
|
||||
private IslandInfo islandInfo;
|
||||
|
||||
public StepInfo() {
|
||||
@@ -99,14 +94,6 @@ public class StepInfo extends BaseBean {
|
||||
this.islandId = islandId;
|
||||
}
|
||||
|
||||
public Integer getStepOrder() {
|
||||
return stepOrder;
|
||||
}
|
||||
|
||||
public void setStepOrder(Integer stepOrder) {
|
||||
this.stepOrder = stepOrder;
|
||||
}
|
||||
|
||||
public String getStepName() {
|
||||
return stepName;
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -24,8 +23,6 @@ public interface DevInfoMapper {
|
||||
// 根据ID查询设备(未删除)
|
||||
DevInfo selectById(@Param("id") Long id);
|
||||
|
||||
//根据设备信息,查询设备信息列表
|
||||
List<DevInfo> selectList(DevInfoQuery devInfo);
|
||||
// 分页查询设备(支持多条件过滤)
|
||||
List<DevInfo> selectPage(DevInfo devInfo);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -32,9 +31,5 @@ public interface DevParamMapper {
|
||||
/**
|
||||
* 分页查询设备参数(支持条件过滤)
|
||||
*/
|
||||
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);
|
||||
List<DevParam> selectPage(DevParam devParam);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -13,5 +12,5 @@ public interface GoodsFlowStatusMapper {
|
||||
Boolean update(GoodsFlowStatus goodsFlowStatus);
|
||||
Boolean deleteById(@Param("id") Long id);
|
||||
GoodsFlowStatus selectById(@Param("id") Long id);
|
||||
List<GoodsFlowStatus> selectPage(GoodsFlowStatusQuery goodsFlowStatus);
|
||||
List<GoodsFlowStatus> selectPage(GoodsFlowStatus goodsFlowStatus);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -10,16 +9,8 @@ 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);
|
||||
List<GoodsInfo> selectPage(GoodsInfo goodsInfo);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -13,10 +12,5 @@ public interface IslandInfoMapper {
|
||||
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);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -12,13 +11,6 @@ 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);
|
||||
List<StepInfo> selectPage(StepInfo stepInfo);
|
||||
}
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
|
||||
@@ -22,15 +21,6 @@ public interface DevInfoService {
|
||||
// 根据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);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
|
||||
@@ -11,9 +10,9 @@ public interface DevParamService {
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId,String paramTypeData, String paramName, String paramValue);
|
||||
PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId, String paramName, String paramValue);
|
||||
|
||||
List<DevParam> selectList(DevParamQuery queryParam);
|
||||
List<DevParam> selectList(Integer devId, String paramName, String paramValue);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
@@ -30,16 +29,6 @@ public interface DevParamService {
|
||||
*/
|
||||
Boolean update(DevParam devParam);
|
||||
|
||||
/**
|
||||
* 为参数增加devId值
|
||||
*/
|
||||
Boolean addDevId(Integer devId, Integer paramId);
|
||||
|
||||
/**
|
||||
* 根据paramId,减少devIds中的devId
|
||||
*/
|
||||
Boolean reduceDevId(Integer devId, Integer paramId);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
|
||||
@@ -3,13 +3,9 @@ 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);
|
||||
PageInfo<GoodsFlowStatus> selectPage(Integer pageNum, Integer pageSize, Integer goodsId, Integer flowId, Integer islandId, Integer status);
|
||||
GoodsFlowStatus selectById(Long id);
|
||||
Long insert(GoodsFlowStatus goodsFlowStatus);
|
||||
Boolean update(GoodsFlowStatus goodsFlowStatus);
|
||||
|
||||
@@ -1,42 +1,25 @@
|
||||
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.query.GoodsInfoQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GoodsInfoService {
|
||||
/**
|
||||
* 分页查询货物信息
|
||||
*/
|
||||
PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, GoodsInfoQuery goodsInfo);
|
||||
|
||||
/**
|
||||
* 查询样品信息List
|
||||
*/
|
||||
List<GoodsInfo> selectList(GoodsInfoQuery goodsInfo);
|
||||
PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, String goodsName, String goodsType, String goodFrom, Integer goodBatch);
|
||||
|
||||
/**
|
||||
* 根据ID查询货物信息
|
||||
*/
|
||||
GoodsInfo selectById(Long id);
|
||||
|
||||
/**
|
||||
* 根据ID列表查询货物列表信息
|
||||
*/
|
||||
List<GoodsInfo> selectByIdList(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 新增货物信息
|
||||
*/
|
||||
Long insert(GoodsInfo goodsInfo);
|
||||
|
||||
/**
|
||||
* 扫码新增货物信息
|
||||
*/
|
||||
GoodsInfo insertByScan(GoodsInfo goodsInfo);
|
||||
|
||||
/**
|
||||
* 修改货物信息
|
||||
*/
|
||||
|
||||
@@ -2,22 +2,11 @@ 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);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -2,32 +2,14 @@ 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);
|
||||
PageInfo<StepInfo> selectPage(Integer pageNum, Integer pageSize, Integer islandId, String stepName);
|
||||
List<StepInfo> selectList( Integer islandId, String stepName);
|
||||
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);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -30,18 +29,6 @@ public class DevInfoServiceImpl implements DevInfoService {
|
||||
if (devInfo.getCreateTime() == null) {
|
||||
devInfo.setCreateTime(java.time.LocalDateTime.now());
|
||||
}
|
||||
//判断设备是否是PLC,PLC设备只有一个主PLC:company-主站
|
||||
if(devInfo.getDevModel().equals("PLC")&&devInfo.getCompany().equals("主站")){
|
||||
//查询出devModel为PLC,company为“主站”的设备
|
||||
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;
|
||||
}
|
||||
@@ -64,25 +51,6 @@ public class DevInfoServiceImpl implements DevInfoService {
|
||||
if (devInfo.getUpdateTime() == null) {
|
||||
devInfo.setUpdateTime(java.time.LocalDateTime.now());
|
||||
}
|
||||
|
||||
//判断设备是否是PLC,PLC设备只有一个主PLC:company-主站
|
||||
if(devInfo.getDevModel().equals("PLC")&&devInfo.getCompany().equals("主站")){
|
||||
//查询出devModel为PLC,company为“主站”的设备
|
||||
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;
|
||||
}
|
||||
@@ -93,11 +61,6 @@ public class DevInfoServiceImpl implements DevInfoService {
|
||||
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) {
|
||||
// 分页参数默认值
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -19,13 +18,12 @@ public class DevParamServiceImpl implements DevParamService {
|
||||
DevParamMapper devParamMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId, String paramTypeData, String paramName, String paramValue) {
|
||||
public PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId, String paramName, String paramValue) {
|
||||
// 1. 开启分页
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
// 2. 构建查询条件
|
||||
DevParamQuery queryParam = new DevParamQuery();
|
||||
DevParam queryParam = new DevParam();
|
||||
queryParam.setDevId(devId);
|
||||
queryParam.setParamTypeData(paramTypeData);
|
||||
queryParam.setParamName(paramName);
|
||||
queryParam.setParamValue(paramValue);
|
||||
// 3. 执行查询
|
||||
@@ -42,7 +40,12 @@ public class DevParamServiceImpl implements DevParamService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DevParam> selectList(DevParamQuery queryParam) {
|
||||
public List<DevParam> selectList(Integer devId, String paramName, String paramValue) {
|
||||
// 1. 构建查询条件
|
||||
DevParam queryParam = new DevParam();
|
||||
queryParam.setDevId(devId);
|
||||
queryParam.setParamName(paramName);
|
||||
queryParam.setParamValue(paramValue);
|
||||
// 3. 执行查询
|
||||
List<DevParam> list = devParamMapper.selectPage(queryParam);
|
||||
return list;
|
||||
@@ -58,8 +61,8 @@ public class DevParamServiceImpl implements DevParamService {
|
||||
|
||||
@Override
|
||||
public Long insert(DevParam devParam) {
|
||||
if (devParam.getDevIds() == null) {
|
||||
devParam.setDevIds(";");
|
||||
if (devParam.getDevId() == null) {
|
||||
throw new IllegalArgumentException("设备ID不能为空");
|
||||
}
|
||||
if (devParam.getParamName() == null || devParam.getParamName().isEmpty()) {
|
||||
throw new IllegalArgumentException("参数名称不能为空");
|
||||
@@ -75,28 +78,6 @@ public class DevParamServiceImpl implements DevParamService {
|
||||
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) {
|
||||
|
||||
@@ -56,8 +56,10 @@ public class FlowInfoServiceImpl implements FlowInfoService {
|
||||
if (flowInfo.getFlowName() == null || flowInfo.getFlowName().isEmpty()) {
|
||||
throw new IllegalArgumentException("流程名称不能为空");
|
||||
}
|
||||
Long result = flowInfoMapper.insert(flowInfo);
|
||||
return flowInfo.getId();
|
||||
if (flowInfo.getFlowIndex() == null) {
|
||||
throw new IllegalArgumentException("流程排序不能为空");
|
||||
}
|
||||
return flowInfoMapper.insert(flowInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -19,19 +18,17 @@ public class GoodsFlowStatusServiceImpl implements GoodsFlowStatusService {
|
||||
GoodsFlowStatusMapper goodsFlowStatusMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<GoodsFlowStatus> selectPage(Integer pageNum, Integer pageSize, GoodsFlowStatusQuery goodsFlowStatus){
|
||||
public PageInfo<GoodsFlowStatus> selectPage(Integer pageNum, Integer pageSize, Integer goodsId, Integer flowId, Integer islandId, Integer status) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
List<GoodsFlowStatus> list = goodsFlowStatusMapper.selectPage(goodsFlowStatus);
|
||||
GoodsFlowStatus queryParam = new GoodsFlowStatus();
|
||||
queryParam.setGoodsId(goodsId);
|
||||
queryParam.setFlowId(flowId);
|
||||
queryParam.setIslandId(islandId);
|
||||
queryParam.setStatus(status);
|
||||
List<GoodsFlowStatus> list = goodsFlowStatusMapper.selectPage(queryParam);
|
||||
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不能为空");
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -19,29 +18,21 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
|
||||
GoodsInfoMapper goodsInfoMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, GoodsInfoQuery goodsInfo) {
|
||||
public PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, String goodsName, String goodsType, String goodFrom, Integer goodBatch) {
|
||||
// 开启分页
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
// 构建查询条件
|
||||
GoodsInfo queryParam = new GoodsInfo();
|
||||
queryParam.setGoodsName(goodsName);
|
||||
queryParam.setGoodsType(goodsType);
|
||||
queryParam.setGoodFrom(goodFrom);
|
||||
queryParam.setGoodBatch(goodBatch);
|
||||
// 执行查询
|
||||
List<GoodsInfo> list = goodsInfoMapper.selectPage(goodsInfo);
|
||||
List<GoodsInfo> list = goodsInfoMapper.selectPage(queryParam);
|
||||
// 包装分页结果
|
||||
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) {
|
||||
@@ -50,16 +41,6 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
|
||||
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()) {
|
||||
@@ -74,35 +55,6 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
|
||||
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) {
|
||||
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
@@ -33,16 +32,6 @@ public class IslandInfoServiceImpl implements IslandInfoService {
|
||||
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()) {
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,499 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
@@ -18,15 +17,21 @@ public class StepInfoServiceImpl implements StepInfoService {
|
||||
StepInfoMapper stepInfoMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<StepInfo> selectPage(Integer pageNum, Integer pageSize, StepInfoQuery stepInfo) {
|
||||
public PageInfo<StepInfo> selectPage(Integer pageNum, Integer pageSize, Integer islandId, String stepName) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<StepInfo> list = stepInfoMapper.selectPage(stepInfo);
|
||||
StepInfo queryParam = new StepInfo();
|
||||
queryParam.setIslandId(islandId);
|
||||
queryParam.setStepName(stepName);
|
||||
List<StepInfo> list = stepInfoMapper.selectPage(queryParam);
|
||||
return new PageInfo<>(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StepInfo> selectList(StepInfoQuery stepInfo) {
|
||||
List<StepInfo> list = stepInfoMapper.selectPage(stepInfo);
|
||||
public List<StepInfo> selectList(Integer islandId, String stepName) {
|
||||
StepInfo queryParam = new StepInfo();
|
||||
queryParam.setIslandId(islandId);
|
||||
queryParam.setStepName(stepName);
|
||||
List<StepInfo> list = stepInfoMapper.selectPage(queryParam);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -36,8 +41,6 @@ public class StepInfoServiceImpl implements StepInfoService {
|
||||
return stepInfoMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long insert(StepInfo stepInfo) {
|
||||
if (stepInfo.getIslandId() == null) throw new IllegalArgumentException("岛屿ID不能为空");
|
||||
@@ -47,43 +50,15 @@ public class StepInfoServiceImpl implements StepInfoService {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
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-1:sop中第一个功能岛,定容岛>10000(十进制):样品是否扫描完毕-0-1:0-未扫描完毕,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-10048;10049-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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
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对象,key:bar_code,value:goodsId
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
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对象:key:ip,value:设备
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<!-- 设备专属字段 -->
|
||||
<sql id="devColumn">
|
||||
island_id, dev_name, dev_model,plc_addr, ip_addr, port, protocol_type, company, status,run_model, dev_desc
|
||||
island_id, dev_name, dev_model, ip_addr, port, protocol_type, company, status, dev_desc
|
||||
</sql>
|
||||
|
||||
<!-- 结果集映射(下划线转驼峰已开启,可简化) -->
|
||||
@@ -25,13 +25,11 @@
|
||||
<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>
|
||||
|
||||
@@ -43,13 +41,11 @@
|
||||
<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>
|
||||
@@ -65,13 +61,11 @@
|
||||
<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>
|
||||
@@ -84,6 +78,7 @@
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
||||
<!-- 逻辑删除设备 -->
|
||||
<update id="deleteById">
|
||||
UPDATE tb_dev_info
|
||||
@@ -99,13 +94,11 @@
|
||||
<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>
|
||||
<!-- 通用字段 -->
|
||||
@@ -120,7 +113,6 @@
|
||||
<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 != '')
|
||||
@@ -162,9 +154,6 @@
|
||||
<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}
|
||||
@@ -173,9 +162,6 @@
|
||||
<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}
|
||||
@@ -197,18 +183,12 @@
|
||||
<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>
|
||||
@@ -223,44 +203,4 @@
|
||||
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>
|
||||
@@ -8,56 +8,45 @@
|
||||
|
||||
<!-- DevParam 业务字段 -->
|
||||
<sql id="devParamColumn">
|
||||
dev_ids, param_name, plc_addr, dic_data_id, param_value, param_type, param_unit, form_type, param_desc
|
||||
dev_id, param_name, 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>
|
||||
<trim suffixOverrides=",">
|
||||
<if test="devId != null">dev_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="devId != null">#{devId}, </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="devId != null">dev_id = #{devId},</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>
|
||||
@@ -65,21 +54,19 @@
|
||||
<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查询:无语法错误 -->
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectById" resultType="com.rczn.rcznautoplc.domain.DevParam">
|
||||
SELECT
|
||||
<include refid="baseColumn"/>,
|
||||
@@ -88,39 +75,16 @@
|
||||
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="devId != null">AND dev_id = #{devId}</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>
|
||||
@@ -6,7 +6,7 @@
|
||||
</sql>
|
||||
|
||||
<sql id="goodsFlowStatusColumn">
|
||||
goods_id, flow_id, island_id,dev_id, flow_sort, status
|
||||
goods_id, flow_id, island_id, flow_sort, status
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -14,7 +14,7 @@
|
||||
<include refid="goodsFlowStatusColumn"/>,
|
||||
create_id, create_time, update_id, update_time, del_sign
|
||||
) VALUES (
|
||||
#{goodsId}, #{flowId}, #{islandId},#{devId}, #{flowSort}, #{status},
|
||||
#{goodsId}, #{flowId}, #{islandId}, #{flowSort}, #{status},
|
||||
#{createId}, NOW(), #{updateId}, NOW(), 0
|
||||
)
|
||||
</insert>
|
||||
@@ -26,7 +26,6 @@
|
||||
<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()
|
||||
@@ -57,7 +56,6 @@
|
||||
<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>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</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`
|
||||
goods_name, goods_type, income_time, good_from, good_batch, `desc`
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -14,7 +14,7 @@
|
||||
<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},
|
||||
#{goodsName}, #{goodsType}, #{incomeTime}, #{goodFrom}, #{goodBatch}, #{desc},
|
||||
#{createId}, NOW(), #{updateId}, NOW(), 0
|
||||
)
|
||||
</insert>
|
||||
@@ -27,11 +27,6 @@
|
||||
<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()
|
||||
@@ -53,20 +48,6 @@
|
||||
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"/>,
|
||||
@@ -77,21 +58,6 @@
|
||||
<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 <= #{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
|
||||
ORDER BY income_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -6,7 +6,7 @@
|
||||
</sql>
|
||||
|
||||
<sql id="islandInfoColumn">
|
||||
island_name, island_code, plc_addr, island_logo, `desc`
|
||||
island_name, island_code, island_logo, `desc`
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -14,7 +14,7 @@
|
||||
<include refid="islandInfoColumn"/>,
|
||||
create_id, create_time, update_id, update_time, del_sign
|
||||
) VALUES (
|
||||
#{islandName}, #{islandCode},#{plcAddr}, #{islandLogo}, #{desc},
|
||||
#{islandName}, #{islandCode}, #{islandLogo}, #{desc},
|
||||
#{createId}, NOW(), #{updateId}, NOW(), 0
|
||||
)
|
||||
</insert>
|
||||
@@ -24,7 +24,6 @@
|
||||
<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>
|
||||
@@ -47,20 +46,6 @@
|
||||
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"/>,
|
||||
@@ -69,7 +54,6 @@
|
||||
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>
|
||||
@@ -1,175 +0,0 @@
|
||||
<?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 <= #{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 <= #{logWritetimeEnd}
|
||||
</if>
|
||||
<if test="createId != null">
|
||||
AND create_id = #{createId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -6,7 +6,7 @@
|
||||
</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
|
||||
island_id,dev_id, step_name, step_desc,flow_id,param_name,param_type,param_unit,param_value,form_type
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -21,7 +21,6 @@
|
||||
<!-- 步骤表字段 -->
|
||||
<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>
|
||||
@@ -44,7 +43,6 @@
|
||||
<!-- 步骤表字段 -->
|
||||
<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>
|
||||
@@ -59,178 +57,11 @@
|
||||
)
|
||||
</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=",">-->
|
||||
<!-- <!– 批量更新核心:用CASE WHEN匹配id赋值 –>-->
|
||||
<!-- 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,-->
|
||||
<!-- -- 所有记录统一更新update_time-->
|
||||
<!-- update_time = NOW()-->
|
||||
<!-- </trim>-->
|
||||
<!-- <!– 只更新传入的id列表 –>-->
|
||||
<!-- 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>
|
||||
@@ -252,19 +83,6 @@
|
||||
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"/>,
|
||||
@@ -273,39 +91,6 @@
|
||||
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"/>,
|
||||
|
||||
Reference in New Issue
Block a user