|
@@ -4,17 +4,17 @@ import com.alibaba.fastjson.JSONObject;
|
4
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
5
|
5
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
6
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
7
|
|
-import com.yunzhi.nanyang.common.BaseController;
|
8
|
|
-import com.yunzhi.nanyang.common.HttpUtils;
|
9
|
|
-import com.yunzhi.nanyang.common.ResponseBean;
|
|
7
|
+import com.yunzhi.nanyang.common.*;
|
10
|
8
|
|
11
|
9
|
import java.time.LocalDateTime;
|
12
|
10
|
import java.util.List;
|
13
|
11
|
|
14
|
|
-import com.yunzhi.nanyang.common.StringUtils;
|
|
12
|
+import com.yunzhi.nanyang.entity.TdDevice;
|
|
13
|
+import com.yunzhi.nanyang.service.ITdDeviceService;
|
15
|
14
|
import io.swagger.annotations.Api;
|
16
|
15
|
import io.swagger.annotations.ApiOperation;
|
17
|
16
|
import io.swagger.annotations.ApiParam;
|
|
17
|
+import org.apache.poi.ss.formula.functions.T;
|
18
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
19
|
19
|
import org.springframework.beans.factory.annotation.Value;
|
20
|
20
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -41,6 +41,9 @@ public class TdRawDeviceController extends BaseController {
|
41
|
41
|
@Autowired
|
42
|
42
|
private TdRawDeviceService tdRawDeviceService;
|
43
|
43
|
|
|
44
|
+ @Autowired
|
|
45
|
+ private ITdDeviceService iTdDeviceService;
|
|
46
|
+
|
44
|
47
|
// /**
|
45
|
48
|
// * 通过ID查询单条数据
|
46
|
49
|
// *
|
|
@@ -107,6 +110,7 @@ public class TdRawDeviceController extends BaseController {
|
107
|
110
|
tdRawDevice.setDeviceStatus(0); // 默认离线
|
108
|
111
|
tdRawDevice.setCreateDate(LocalDateTime.now());
|
109
|
112
|
tdRawDeviceService.save(tdRawDevice);
|
|
113
|
+
|
110
|
114
|
return ResponseBean.success(tdRawDevice);
|
111
|
115
|
}
|
112
|
116
|
|
|
@@ -123,17 +127,29 @@ public class TdRawDeviceController extends BaseController {
|
123
|
127
|
String s = httpUtils.get(url);
|
124
|
128
|
return JSONObject.parseObject(s, ResponseBean.class);
|
125
|
129
|
}
|
126
|
|
-//
|
127
|
|
-// /**
|
128
|
|
-// * 通过主键删除数据
|
129
|
|
-// *
|
130
|
|
-// * @param deviceId 主键
|
131
|
|
-// * @return 是否成功
|
132
|
|
-// */
|
133
|
|
-// @ApiOperation("通过主键删除数据")
|
134
|
|
-// @DeleteMapping("/raw-device/{id}")
|
135
|
|
-// public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
|
136
|
|
-// tdRawDeviceService.removeLogicById(id);
|
137
|
|
-// return ResponseBean.success("success");
|
138
|
|
-// }
|
|
130
|
+
|
|
131
|
+ /**
|
|
132
|
+ * 通过主键删除数据
|
|
133
|
+ *
|
|
134
|
+ * @param deviceId 主键
|
|
135
|
+ * @return 是否成功
|
|
136
|
+ */
|
|
137
|
+ @ApiOperation("通过主键删除数据")
|
|
138
|
+ @DeleteMapping("/admin/raw-device/{id}")
|
|
139
|
+ public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
|
|
140
|
+
|
|
141
|
+ TdRawDevice tdRawDevice = tdRawDeviceService.getById(id);
|
|
142
|
+ if (null == tdRawDevice) {
|
|
143
|
+ return ResponseBean.error("未找到数据");
|
|
144
|
+ }
|
|
145
|
+
|
|
146
|
+ TdDevice tdDevice = iTdDeviceService.getExistByDevice(tdRawDevice.getDeviceKind(), tdRawDevice.getDeviceNo());
|
|
147
|
+ if (null != tdDevice) {
|
|
148
|
+ tdDevice.setStatus(Constants.STATUS_DELETE);
|
|
149
|
+ iTdDeviceService.updateById(tdDevice);
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ tdRawDeviceService.removeById(id);
|
|
153
|
+ return ResponseBean.success("success");
|
|
154
|
+ }
|
139
|
155
|
}
|