|
@@ -1,16 +1,24 @@
|
|
|
package com.usky.park.controller.web;
|
|
|
|
|
|
|
|
|
-import com.alibaba.nacos.common.utils.StringUtils;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
import com.usky.common.core.util.HttpUtils;
|
|
|
+import com.usky.common.core.util.JsonUtils;
|
|
|
+import com.usky.common.security.utils.SecurityUtils;
|
|
|
+import com.usky.park.domain.DmpDevice;
|
|
|
+import com.usky.park.service.DmpDeviceService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Date;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.List;
|
|
@@ -23,6 +31,9 @@ import java.util.List;
|
|
|
@RequestMapping("deviceHttp")
|
|
|
public class DeviceHttpController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DmpDeviceService dmpDeviceService;
|
|
|
+
|
|
|
|
|
|
public static final String light_url = "http://172.17.35.51:15224";
|
|
|
public static final String video_url = "http://172.17.35.51:15225";
|
|
@@ -164,7 +175,7 @@ public class DeviceHttpController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("DeviceInfo")
|
|
|
- public static String DeviceInfo(@RequestParam(value = "deviceType") Integer deviceType,
|
|
|
+ public String DeviceInfo(@RequestParam(value = "deviceType") Integer deviceType,
|
|
|
@RequestParam(value = "regionIndexCodes") List<String> regionIndexCodes){
|
|
|
String result = "";
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
@@ -182,11 +193,60 @@ public class DeviceHttpController {
|
|
|
}else if(deviceType == 503){
|
|
|
result = HttpUtils.postJson(elevator_devinfo,map,null);
|
|
|
}
|
|
|
+ Map data_map = JsonUtils.fromJson(result,Map.class);
|
|
|
+ List<Map<String,Object>> data =(List) JSONObject.parseArray(JSONObject.toJSONString(data_map.get("data")));
|
|
|
+ for(int i=0;i<data.size();i++){
|
|
|
+ String flag = data.get(i).get("flag").toString(); //1 新增 0 更新 -1 删除
|
|
|
+ String device_id = data.get(i).get("device_id").toString();
|
|
|
+ String device_code = data.get(i).get("device_code").toString();
|
|
|
+ String device_name = data.get(i).get("device_name").toString();
|
|
|
+ String product_id = data.get(i).get("product_id").toString();
|
|
|
+ String company_code = data.get(i).get("company_code").toString();
|
|
|
+
|
|
|
+
|
|
|
+ if(flag.equals("-1") || flag.equals("0")){
|
|
|
+ List<DmpDevice> list = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<DmpDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DmpDevice::getDeviceCode,device_code);
|
|
|
+ list = dmpDeviceService.list(queryWrapper);
|
|
|
+
|
|
|
+ DmpDevice dmpDevice = new DmpDevice();
|
|
|
+ dmpDevice.setId(list.get(0).getId());
|
|
|
+ dmpDevice.setDeviceId(device_id);
|
|
|
+ dmpDevice.setDeviceCode(device_code);
|
|
|
+ dmpDevice.setDeviceName(device_name);
|
|
|
+ dmpDevice.setDeviceType(deviceType);
|
|
|
+ dmpDevice.setProductId(Integer.parseInt(product_id));
|
|
|
+ dmpDevice.setCompanyCode(company_code);
|
|
|
+ dmpDevice.setUpdatedBy(SecurityUtils.getLoginUser().getSysPerson().getFullName());
|
|
|
+ dmpDevice.setUpdatedTime(LocalDateTime.now());
|
|
|
+ if(flag.equals("-1")){
|
|
|
+ dmpDevice.setDeleteFlag(1);
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }else if(flag.equals("0")){
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }
|
|
|
+ }else if(flag.equals("1")){
|
|
|
+ DmpDevice dmpDevice = new DmpDevice();
|
|
|
+ dmpDevice.setDeviceId(device_id);
|
|
|
+ dmpDevice.setDeviceCode(device_code);
|
|
|
+ dmpDevice.setDeviceName(device_name);
|
|
|
+ dmpDevice.setDeviceType(deviceType);
|
|
|
+ dmpDevice.setProductId(Integer.parseInt(product_id));
|
|
|
+ dmpDevice.setCompanyCode(company_code);
|
|
|
+ dmpDevice.setDeleteFlag(0);
|
|
|
+ dmpDevice.setCreatedBy(SecurityUtils.getLoginUser().getSysPerson().getFullName());
|
|
|
+ dmpDevice.setCreatedTime(LocalDateTime.now());
|
|
|
+ dmpDeviceService.save(dmpDevice);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
throw new BusinessException("设备管理-监控系统、门禁系统、梯控系统设备信息同步http调用异常"+e.getMessage());
|
|
|
}
|
|
|
- return result;
|
|
|
+
|
|
|
+ String data = "{\"code\": \"0\",\"msg\": \"success\",\"data\": \"\"}";
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -196,7 +256,7 @@ public class DeviceHttpController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("GeneratorDevInfo")
|
|
|
- public static String GeneratorDevInfo(@RequestParam(value = "sceneId") String sceneId){
|
|
|
+ public String GeneratorDevInfo(@RequestParam(value = "sceneId") String sceneId){
|
|
|
String result = "";
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("jsonrpc","2.0");
|
|
@@ -208,9 +268,58 @@ public class DeviceHttpController {
|
|
|
try {
|
|
|
result = HttpUtils.postJson(generator_devinfo,map,null);
|
|
|
|
|
|
+ Map data_map = JsonUtils.fromJson(result,Map.class);
|
|
|
+ List<Map<String,Object>> data =(List) JSONObject.parseArray(JSONObject.toJSONString(data_map.get("data")));
|
|
|
+ for(int i=0;i<data.size();i++){
|
|
|
+ String flag = data.get(i).get("flag").toString(); //1 新增 0 更新 -1 删除
|
|
|
+ String device_id = data.get(i).get("device_id").toString();
|
|
|
+ String device_code = data.get(i).get("device_code").toString();
|
|
|
+ String device_name = data.get(i).get("device_name").toString();
|
|
|
+ String product_id = data.get(i).get("product_id").toString();
|
|
|
+ String company_code = data.get(i).get("company_code").toString();
|
|
|
+
|
|
|
+
|
|
|
+ if(flag.equals("-1") || flag.equals("0")){
|
|
|
+ List<DmpDevice> list = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<DmpDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DmpDevice::getDeviceCode,device_code);
|
|
|
+ list = dmpDeviceService.list(queryWrapper);
|
|
|
+
|
|
|
+ DmpDevice dmpDevice = new DmpDevice();
|
|
|
+ dmpDevice.setId(list.get(0).getId());
|
|
|
+ dmpDevice.setDeviceId(device_id);
|
|
|
+ dmpDevice.setDeviceCode(device_code);
|
|
|
+ dmpDevice.setDeviceName(device_name);
|
|
|
+ dmpDevice.setDeviceType(504);
|
|
|
+ dmpDevice.setProductId(Integer.parseInt(product_id));
|
|
|
+ dmpDevice.setCompanyCode(company_code);
|
|
|
+ dmpDevice.setUpdatedBy(SecurityUtils.getLoginUser().getSysPerson().getFullName());
|
|
|
+ dmpDevice.setUpdatedTime(LocalDateTime.now());
|
|
|
+ if(flag.equals("-1")){
|
|
|
+ dmpDevice.setDeleteFlag(1);
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }else if(flag.equals("0")){
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }
|
|
|
+ }else if(flag.equals("1")){
|
|
|
+ DmpDevice dmpDevice = new DmpDevice();
|
|
|
+ dmpDevice.setDeviceId(device_id);
|
|
|
+ dmpDevice.setDeviceCode(device_code);
|
|
|
+ dmpDevice.setDeviceName(device_name);
|
|
|
+ dmpDevice.setDeviceType(504);
|
|
|
+ dmpDevice.setProductId(Integer.parseInt(product_id));
|
|
|
+ dmpDevice.setCompanyCode(company_code);
|
|
|
+ dmpDevice.setDeleteFlag(0);
|
|
|
+ dmpDevice.setCreatedBy(SecurityUtils.getLoginUser().getSysPerson().getFullName());
|
|
|
+ dmpDevice.setCreatedTime(LocalDateTime.now());
|
|
|
+ dmpDeviceService.save(dmpDevice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} catch (IOException e) {
|
|
|
throw new BusinessException("设备管理-机房系统设备信息同步http调用异常"+e.getMessage());
|
|
|
}
|
|
|
- return result;
|
|
|
+ String data = "{\"code\": \"0\",\"msg\": \"success\",\"data\": \"\"}";
|
|
|
+ return data;
|
|
|
}
|
|
|
}
|