Browse Source

添加自动打印,我这往redis存就好了

master
shenzhouyu 4 days ago
parent
commit
dc85609c29
  1. 54
      glue-modbus-collector/src/main/java/com/xujie/devicecollector/controller/DeviceController.java
  2. 37
      glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/DeviceInfoVO.java
  3. 4
      glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java

54
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());
}
}

37
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<BigDecimal> 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<BigDecimal> getMultipleRollsList() {
return multipleRollsList;
}
public void setMultipleRollsList(List<BigDecimal> multipleRollsList) {
this.multipleRollsList = multipleRollsList;
}
}

4
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)); logger.info("调用下机卷分切sIn1CreateRoll存储过程参数:{}", JSON.toJSONString(params));
List<Map<String, Object>> data = procedureDao.getProcedureData("sIn1CreateRoll", params); List<Map<String, Object>> data = procedureDao.getProcedureData("sIn1CreateRoll", params);
logger.info("调用下机卷分切sIn1CreateRoll存储过程结果:{}", JSON.toJSONString(data)); 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"));
}
} }
} }
Loading…
Cancel
Save