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