3 changed files with 95 additions and 0 deletions
-
54glue-modbus-collector/src/main/java/com/xujie/devicecollector/controller/DeviceController.java
-
37glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/DeviceInfoVO.java
-
4glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.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()); |
|||
} |
|||
} |
|||
@ -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; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue