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")); + } } }