|
@@ -3,13 +3,18 @@ package com.usky.park.controller.web;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
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.ApplicationRun;
|
|
|
import com.usky.park.domain.DmpDevice;
|
|
|
import com.usky.park.service.DmpDeviceService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -31,6 +36,8 @@ import java.util.List;
|
|
|
@RequestMapping("deviceHttp")
|
|
|
public class DeviceHttpController {
|
|
|
|
|
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(DeviceHttpController.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private DmpDeviceService dmpDeviceService;
|
|
|
|
|
@@ -182,7 +189,7 @@ public class DeviceHttpController {
|
|
|
map.put("jsonrpc","2.0");
|
|
|
map.put("method","DeviceInfo");
|
|
|
Map<String,Object> map1 = new HashMap<>();
|
|
|
- map1.put("regionIndexCodes","["+regionIndexCodes+"]");
|
|
|
+ map1.put("regionIndexCodes",regionIndexCodes);
|
|
|
map.put("params",map1);
|
|
|
map.put("id",3);
|
|
|
try {
|
|
@@ -194,9 +201,9 @@ public class DeviceHttpController {
|
|
|
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")));
|
|
|
+ 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 删除
|
|
|
+ int flag = (int)(data.get(i).get("flag")); //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();
|
|
@@ -204,29 +211,31 @@ public class DeviceHttpController {
|
|
|
String company_code = data.get(i).get("company_code").toString();
|
|
|
|
|
|
|
|
|
- if(flag.equals("-1") || flag.equals("0")){
|
|
|
- List<DmpDevice> list = new ArrayList<>();
|
|
|
+ if(flag == -1 || flag == 0){
|
|
|
LambdaQueryWrapper<DmpDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(DmpDevice::getDeviceCode,device_code);
|
|
|
- list = dmpDeviceService.list(queryWrapper);
|
|
|
+ queryWrapper.eq(DmpDevice::getDeleteFlag,0)
|
|
|
+ .eq(DmpDevice::getDeviceCode,device_code);
|
|
|
+ List<DmpDevice> 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);
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ 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.setUpdatedTime(LocalDateTime.now());
|
|
|
+ if(flag == -1){
|
|
|
+ dmpDevice.setDeviceName(list.get(0).getDeviceName());
|
|
|
+ dmpDevice.setDeleteFlag(1);
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }else if(flag == 0){
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }
|
|
|
}
|
|
|
- }else if(flag.equals("1")){
|
|
|
+ }else if(flag == 1){
|
|
|
DmpDevice dmpDevice = new DmpDevice();
|
|
|
dmpDevice.setDeviceId(device_id);
|
|
|
dmpDevice.setDeviceCode(device_code);
|
|
@@ -235,7 +244,6 @@ public class DeviceHttpController {
|
|
|
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);
|
|
|
}
|
|
@@ -265,43 +273,47 @@ public class DeviceHttpController {
|
|
|
map1.put("scene_id",sceneId);
|
|
|
map.put("params",map1);
|
|
|
map.put("id",3);
|
|
|
+ String str = "";
|
|
|
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")));
|
|
|
+ List<Map<String,Object>> data = (List) JSONObject.parseArray(JSONObject.toJSONString(data_map.get("data")));
|
|
|
+ LOGGER.info(JSONObject.toJSONString(data));
|
|
|
for(int i=0;i<data.size();i++){
|
|
|
- String flag = data.get(i).get("flag").toString(); //1 新增 0 更新 -1 删除
|
|
|
+ int flag = (int)(data.get(i).get("flag")); //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<>();
|
|
|
+ if(flag == -1 || flag == 0){
|
|
|
LambdaQueryWrapper<DmpDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(DmpDevice::getDeviceCode,device_code);
|
|
|
- list = dmpDeviceService.list(queryWrapper);
|
|
|
+ queryWrapper.eq(DmpDevice::getDeleteFlag,0)
|
|
|
+ .eq(DmpDevice::getDeviceCode,device_code);
|
|
|
+ List<DmpDevice> 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);
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ 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.setUpdatedTime(LocalDateTime.now());
|
|
|
+ if(flag == -1){
|
|
|
+ dmpDevice.setDeviceName(list.get(0).getDeviceName());
|
|
|
+ dmpDevice.setDeleteFlag(1);
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }else if(flag == 0){
|
|
|
+ dmpDeviceService.updateById(dmpDevice);
|
|
|
+ }
|
|
|
}
|
|
|
- }else if(flag.equals("1")){
|
|
|
+
|
|
|
+ }else if(flag == 1){
|
|
|
DmpDevice dmpDevice = new DmpDevice();
|
|
|
dmpDevice.setDeviceId(device_id);
|
|
|
dmpDevice.setDeviceCode(device_code);
|
|
@@ -310,7 +322,6 @@ public class DeviceHttpController {
|
|
|
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);
|
|
|
}
|