From dc85609c29a6bb6934599ba8942c6151db995c74 Mon Sep 17 00:00:00 2001 From: shenzhouyu Date: Thu, 9 Apr 2026 11:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=89=93?= =?UTF-8?q?=E5=8D=B0=EF=BC=8C=E6=88=91=E8=BF=99=E5=BE=80redis=E5=AD=98?= =?UTF-8?q?=E5=B0=B1=E5=A5=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeviceController.java | 54 +++++++++++++++++++ .../devicecollector/entity/DeviceInfoVO.java | 37 +++++++++++++ .../service/impl/DeviceGatherServiceImpl.java | 4 ++ 3 files changed, 95 insertions(+) create mode 100644 glue-modbus-collector/src/main/java/com/xujie/devicecollector/controller/DeviceController.java create mode 100644 glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/DeviceInfoVO.java diff --git a/glue-modbus-collector/src/main/java/com/xujie/devicecollector/controller/DeviceController.java b/glue-modbus-collector/src/main/java/com/xujie/devicecollector/controller/DeviceController.java new file mode 100644 index 0000000..896fa6c --- /dev/null +++ b/glue-modbus-collector/src/main/java/com/xujie/devicecollector/controller/DeviceController.java @@ -0,0 +1,54 @@ +package com.xujie.devicecollector.controller; + +import com.xujie.devicecollector.entity.DeviceInfo; +import com.xujie.devicecollector.entity.DeviceInfoVO; +import com.xujie.devicecollector.service.DeviceGatherService; +import com.xujie.devicecollector.service.DeviceInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/device/collect") +public class DeviceController { + + @Autowired + private DeviceGatherService deviceGatherService; + @Autowired + private DeviceInfoService deviceInfoService; + + @PostMapping("/scan") + public void collect(@RequestBody DeviceInfoVO deviceInfo){ + + deviceGatherService.scanRollNo(deviceInfo,"",deviceInfo.getRollNo()); + } + + //测试接口 + //http://127.0.0.1:8996/device/collect/split + @PostMapping("/split") + public void collectMinRollData(@RequestBody DeviceInfoVO deviceInfo){ + if (deviceInfo == null || !StringUtils.hasText(deviceInfo.getIp()) || !StringUtils.hasText(deviceInfo.getRollNo()) + || deviceInfo.getTotalQty() == null || deviceInfo.getMultipleRollsList() == null + || deviceInfo.getMultipleRollsList().size() < 12) { + throw new IllegalArgumentException("split接口参数不完整:ip、rollNo、totalQty、multipleRollsList(12项)必填"); + } + String site = ""; + String seqNo = ""; + String value = deviceInfoService.queryDeviceSiteByIp(deviceInfo.getIp()); + if (StringUtils.isEmpty(value)){ + value = "2"; + } + // 判断是否存在 ; 分割 + String[] strings = value.split(";"); + if (strings.length > 1){ + seqNo = strings[1]; + } + site = strings[0]; + deviceGatherService.handleMinData(deviceInfo.getIp(),deviceInfo.getRollNo(),site,seqNo,deviceInfo.getTotalQty(),deviceInfo.getMultipleRollsList()); + } +} diff --git a/glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/DeviceInfoVO.java b/glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/DeviceInfoVO.java new file mode 100644 index 0000000..75222cd --- /dev/null +++ b/glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/DeviceInfoVO.java @@ -0,0 +1,37 @@ +package com.xujie.devicecollector.entity; + +import java.math.BigDecimal; +import java.util.List; + +public class DeviceInfoVO extends DeviceInfo{ + + private String rollNo; + + private Integer totalQty; + + private List multipleRollsList; + + public String getRollNo() { + return rollNo; + } + + public void setRollNo(String rollNo) { + this.rollNo = rollNo; + } + + public Integer getTotalQty() { + return totalQty; + } + + public void setTotalQty(Integer totalQty) { + this.totalQty = totalQty; + } + + public List getMultipleRollsList() { + return multipleRollsList; + } + + public void setMultipleRollsList(List multipleRollsList) { + this.multipleRollsList = multipleRollsList; + } +} diff --git a/glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java b/glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java index ae0c9e3..26140ee 100644 --- a/glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java +++ b/glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java @@ -121,6 +121,10 @@ public class DeviceGatherServiceImpl implements DeviceGatherService { logger.info("调用下机卷分切sIn1CreateRoll存储过程参数:{}", JSON.toJSONString(params)); List> data = procedureDao.getProcedureData("sIn1CreateRoll", params); logger.info("调用下机卷分切sIn1CreateRoll存储过程结果:{}", JSON.toJSONString(data)); + if ("200".equals(data.get(0).get("result_code"))){ + // todo 存储卷号到redis + redisTemplate.opsForValue().set("3in1:rollNos", data.get(0).get("roll_no")); + } } }