|
@@ -306,8 +306,8 @@ public class EnvDeviceServiceImpl extends ServiceImpl<EnvDeviceMapper, EnvDevice
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Result sync(Map<String, Integer> params) throws Exception {
|
|
|
- Integer farmId = params.get("farmId");
|
|
|
+ public Result sync(Map<String, String> params) throws Exception {
|
|
|
+ String farmId = params.get("farmId");
|
|
|
//获取所有栏舍
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
String s = HttpClientSSLUtils.doPost("https://yzwlw.loongk.com/mobile/login?username=江西增鑫&password=21218cca77804d2ba1922c33e0151105", JSON.toJSONString(map));
|
|
@@ -321,7 +321,7 @@ public class EnvDeviceServiceImpl extends ServiceImpl<EnvDeviceMapper, EnvDevice
|
|
|
List<DataShacks> shacks = loginDto.getData().getShacks();
|
|
|
// 不能删除,需做比较
|
|
|
List<String> zengXinDeviceId = shacks.stream().map(DataShacks::getId).collect(Collectors.toList());
|
|
|
- List<String> huatongDeviceId = envDeviceMapper.selectDeviceCodeByfarmId(farmId);
|
|
|
+ List<String> huatongDeviceId = envDeviceMapper.selectDeviceCodeByfarmId(Integer.parseInt(farmId));
|
|
|
|
|
|
CopyOnWriteArrayList<String> zengXinDeviceIdCopy = ListUtil.toCopyOnWriteArrayList(zengXinDeviceId);
|
|
|
CopyOnWriteArrayList<String> huatongDeviceIdCopy = ListUtil.toCopyOnWriteArrayList(huatongDeviceId);
|
|
@@ -343,7 +343,17 @@ public class EnvDeviceServiceImpl extends ServiceImpl<EnvDeviceMapper, EnvDevice
|
|
|
return new Result(10000,"同步成功",false);
|
|
|
}
|
|
|
|
|
|
- private void syncConfig(String shackId,HttpEntity httpEntity,Integer farmId) {
|
|
|
+ @Override
|
|
|
+ public Result bandingUnitId(HttpServletRequest httpServletRequest, EnvDevice envDevice) {
|
|
|
+ Integer unitId = envDevice.getUnitId();
|
|
|
+ int count = this.count(new QueryWrapper<EnvDevice>().eq("unit_id", unitId));
|
|
|
+ if (count>0){
|
|
|
+ return new Result(10001,"绑定失败,该栋舍已有设备",false);
|
|
|
+ }
|
|
|
+ return new Result(10000,"绑定成功",true);
|
|
|
+ }
|
|
|
+ //添加新的设备
|
|
|
+ private void syncConfig(String shackId,HttpEntity httpEntity,String farmId) {
|
|
|
ResponseEntity<String> exchangePeizhi = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackConfig/"+shackId, HttpMethod.GET, httpEntity, String.class);
|
|
|
String peizhibody = exchangePeizhi.getBody();
|
|
|
ShackConfigDto shackConfigDto = JSONUtil.toBean(peizhibody, ShackConfigDto.class);
|
|
@@ -351,7 +361,7 @@ public class EnvDeviceServiceImpl extends ServiceImpl<EnvDeviceMapper, EnvDevice
|
|
|
List<ShackConfigDataSensors> sensors = data.getSensors();
|
|
|
if (ObjectUtil.isNotEmpty(sensors)){
|
|
|
EnvDevice envDevice =new EnvDevice();
|
|
|
- envDevice.setFarmId(farmId);
|
|
|
+ envDevice.setFarmId(Integer.parseInt(farmId));
|
|
|
envDevice.setDeviceBrand("增鑫");
|
|
|
envDevice.setDeviceCode(data.getId());
|
|
|
envDevice.setDeviceName(data.getName());
|