From 662a1de0fdb2b190cb63b692e5172097aed11269 Mon Sep 17 00:00:00 2001
From: wangmengzhao <1036088376@qq.com>
Date: 星期六, 09 十二月 2023 23:48:54 +0800
Subject: [PATCH] 设备安装查询的代码优化,打通emq与设备端数据交互与下发指令设备端接受,设备端大宋指令系统平台接收,设备安装/维修单定时任务调试20231209wmz
---
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java | 181 ++++++++++++++++++++------------------------
1 files changed, 83 insertions(+), 98 deletions(-)
diff --git a/wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java b/wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java
index 27cd325..8af3746 100644
--- a/wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java
+++ b/wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java
@@ -4,17 +4,14 @@
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.file.FileUploadUtils;
-import com.ruoyi.framework.web.service.TokenService;
-import com.ruoyi.iot.domain.Device;
import com.ruoyi.iot.domain.DeviceOrder;
+import com.ruoyi.iot.domain.DeviceOrderTime;
import com.ruoyi.iot.service.IDeviceOrderService;
-import com.ruoyi.iot.service.IDeviceService;
-import com.ruoyi.system.service.ISysUserService;
+import com.ruoyi.iot.service.IDeviceOrderTimeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@@ -26,14 +23,13 @@
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
-import java.io.IOException;
import java.util.List;
/**
* @author wmz
* @version v1.0
* @ClassName DeviceOrderController
- * @description 璁惧瀹夎controller
+ * @description 璁惧瀹夎鍗�/缁翠慨鍗昪ontroller
* @createTime 2023/11/13 0:27
*/
@Api(tags = "璁惧瀹夎淇℃伅")
@@ -47,17 +43,12 @@
private IDeviceOrderService iDeviceOrderService;
@Autowired
- private IDeviceService deviceService;
-
- @Autowired
- private ISysUserService userService;
-
- @Autowired
- private TokenService tokenService;
+ private IDeviceOrderTimeService deviceOrderTimeService;
/**
* 鏌ヨ鍏ㄩ儴璁惧瀹夎鍗曡鍗曚俊鎭�
*
+ * @param deviceOrder
* @return
* @throws Exception
*/
@@ -71,56 +62,81 @@
}
/**
+ * 鏍规嵁鐧诲綍鐨勮仈钀ュ晢鏌ヨ璁惧璁㈠崟瓒呮椂鐨勬椂闂撮棿闅�
+ *
+ * @param deviceOrderTime
+ * @return
+ * @throws Exception
+ */
+ @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')")
+ @GetMapping("/selecttimeout")
+ @ApiOperation(value = "鏍规嵁鐧诲綍鐨勮仈钀ュ晢鏌ヨ璁惧璁㈠崟瓒呮椂鐨勬椂闂撮棿闅�")
+ public AjaxResult selectTimeout(DeviceOrderTime deviceOrderTime) throws Exception {
+ return deviceOrderTimeService.selectDeviceOrderTimeoutById(deviceOrderTime);
+ }
+
+ /**
+ * 鏍规嵁鐧诲綍鐨勮仈钀ュ晢淇敼璁惧璁㈠崟瓒呮椂鐨勬椂闂撮棿闅�
+ *
+ * @param deviceOrderTime
+ * @return
+ * @throws Exception
+ */
+ @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')")
+ @Log(title = "鑱旇惀鍟嗙櫥褰曞悗淇敼璁惧璁㈠崟瓒呮椂鐨勬椂闂撮棿闅�", businessType = BusinessType.UPDATE)
+ @PutMapping("/updatetimeout")
+ @ApiOperation(value = "鏍规嵁鐧诲綍鐨勮仈钀ュ晢淇敼璁惧璁㈠崟瓒呮椂鐨勬椂闂撮棿闅�")
+ public AjaxResult assignDeviceOrderTimeout(DeviceOrderTime deviceOrderTime) throws Exception {
+ return deviceOrderTimeService.updateDeviceOrderTimeoutById(deviceOrderTime);
+ }
+
+
+ /**
+ * 瀹夎鍗�/缁翠慨鍗曞畬鎴愬悗鐢ㄦ埛鐨勮瘎浠�
+ *
+ * @param deviceOrder
+ * @return
+ * @throws Exception 鍙傛暟鏄畨瑁呭崟鐨刬d锛岀敤鎴风殑id,ordertype绫诲瀷
+ */
+ @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')")
+ @PostMapping("/editDeviceOrderScore")
+ @Log(title = "瀹夎鍗�/缁翠慨鍗曞畬鎴愬悗鐢ㄦ埛娣诲姞璇勪环", businessType = BusinessType.UPDATE)
+ @ApiOperation(value = "瀹夎鍗�/缁翠慨鍗曞畬鎴愬悗鐢ㄦ埛鐨勮瘎浠�")
+ public AjaxResult updateDeviceOrderScoreAndComment(DeviceOrder deviceOrder) throws Exception {
+ return iDeviceOrderService.updateDeviceOrderScoreAndComment(deviceOrder);
+ }
+
+ /**
+ * 鏌ヨ鏈淳鍗�/宸叉淳鍗�/宸叉帴鍗�/宸插畬鎴愮殑瀹夎鍗�/缁翠慨鍗曟暟缁翠慨鍗曟暟閲�
+ *
+ * @param deviceOrder
+ * @return
+ * @throws Exception
+ */
+ @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')")
+ @GetMapping("/get")
+ @ApiOperation(value = "鑾峰彇鏈淳鍗�/宸叉淳鍗�/宸叉帴鍗�/宸插畬鎴愮殑瀹夎鍗�/缁翠慨鍗曟暟閲�")
+ public AjaxResult selectDeviceOrderCount(DeviceOrder deviceOrder) throws Exception {
+ if (deviceOrder != null) {
+ return iDeviceOrderService.selectDeviceOrderCountByUndeliveredorders(deviceOrder);
+ } else {
+ return AjaxResult.error("鏈煡璇㈠埌鏈夊叧淇℃伅");
+ }
+ }
+
+ /**
* 娣诲姞瀹夎璁惧璁㈠崟淇℃伅
*
* @param deviceOrder
* @return
* @throws Exception
*/
- @ApiOperation("娣诲姞瀹夎鍗�")
+ @ApiOperation("娣诲姞瀹夎鍗�/缁翠慨鍗�")
@PreAuthorize("@ss.hasPermi('iot:device:add')")
- @Log(title = "娣诲姞瀹夎鍗曚俊鎭�", businessType = BusinessType.INSERT)
+ @Log(title = "娣诲姞瀹夎鍗�/缁翠慨鍗曚俊鎭�", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody DeviceOrder deviceOrder) throws Exception {
- //鏇存柊璁㈠崟鐨勫垵濮嬪寲鐘舵��
- if ("鏈寚娲�".equals(deviceOrder.getErectoName())) {
- deviceOrder.setState(0);
- } else {
- deviceOrder.setState(1);
- }
- //鍒ゆ柇浼犺繃鏉ョ殑orderType鐨勫�兼槸鍚︿负2-缁翠慨
- if ("2".equals(deviceOrder.getOrderType())) {
- log.info("orderType{}", deviceOrder.getOrderType());
- System.out.println(deviceOrder.getOrderType());
- //鏇存柊璁㈠崟鐨勭敤鎴蜂俊鎭�
- SysUser sysUser = getLoginUser().getUser();
- deviceOrder.setCreateUserId(sysUser.getUserId());
- //鎻掑叆缁翠慨鍗�
- int rows = iDeviceOrderService.insertDeviceOrder(deviceOrder);
- if (rows > 0) {
- Device device1 = deviceService.selectDeviceByDeviceId(deviceOrder.getDeviceId());
- //鏇存柊褰撳墠璁惧鐨勬槸鍚︾淮淇俊鎭�-鏈淮淇�
- Device device = new Device();
- device.setDeviceId(deviceOrder.getDeviceId());
- device.setRepairFlag(1);
- device.setStatus(device1.getStatus());
- deviceService.updateDevice(device);
- }
- return toAjax(rows);
- }
- //鏇存柊璁㈠崟鐨勭敤鎴蜂俊鎭�
- SysUser sysUser = getLoginUser().getUser();
- deviceOrder.setCreateUserId(sysUser.getUserId());
- //鎻掑叆瀹夎璁㈠崟
- int rows = iDeviceOrderService.insertDeviceOrder(deviceOrder);
- if (rows > 0) {
- //鏇存柊褰撳墠璁惧鐘舵�佷俊鎭�--瀹夎涓�
- Device device = new Device();
- device.setDeviceId(deviceOrder.getDeviceId());
- device.setStatus(5);
- deviceService.updateDevice(device);
- }
- return toAjax(rows);
+ return iDeviceOrderService.insertDeviceOrder(deviceOrder);
}
/**
@@ -135,28 +151,7 @@
@Log(title = "淇敼璁惧璁㈠崟淇℃伅", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DeviceOrder deviceOrder) throws Exception {
- //鍒ゆ柇浼犺繃鏉ョ殑orderType鐨勫�兼槸鍚︿负1-瀹夎锛屽苟涓斿畨瑁呭崟鐨勭姸鎬佷负涓哄凡瀹屾垚锛屼慨鏀硅澶囩殑鐘舵�佷负绂荤嚎鐘舵��
- if ("1".equals(deviceOrder.getOrderType()) && deviceOrder.getState() == 3) {
- Device device = new Device();
- device.setDeviceId(deviceOrder.getDeviceId());
- //淇敼璁惧鐨勭姸鎬佷负绂荤嚎
- device.setStatus(4);
- deviceService.updateDevice(device);
- }
- //鍒ゆ柇浼犺繃鏉ョ殑orderType鐨勫�兼槸鍚︿负2-缁翠慨锛屽苟涓旂淮淇崟鐨勭姸鎬佷负涓哄凡瀹屾垚锛屼慨鏀硅澶囩殑鏄惁涓轰慨涓�0-宸茬淮淇�
- if ("2".equals(deviceOrder.getOrderType()) && deviceOrder.getState() == 3) {
- Device device1 = deviceService.selectDeviceByDeviceId(deviceOrder.getDeviceId());
- Device device = new Device();
- device.setDeviceId(deviceOrder.getDeviceId());
- device.setRepairFlag(0);
- device.setStatus(device1.getStatus());
- deviceService.updateDevice(device);
- }
- //鑾峰彇淇敼璁㈠崟鐨勭敤鎴蜂俊鎭�
- SysUser sysUser = getLoginUser().getUser();
- //鎷垮埌淇敼瀹夎鍗曠殑鐢ㄦ埛id
- deviceOrder.setUpdateUserId(sysUser.getUserId());
- return toAjax(iDeviceOrderService.updateDeviceOrder(deviceOrder));
+ return iDeviceOrderService.updateDeviceOrder(deviceOrder);
}
/**
@@ -168,33 +163,23 @@
*/
@PreAuthorize("@ss.hasPermi('iot:device:remove')")
@Log(title = "鍒犻櫎璁惧璁㈠崟淇℃伅", businessType = BusinessType.DELETE)
- @DeleteMapping("/{deviceId}")
- @ApiOperation("鍒犻櫎璁㈠崟淇℃伅")
- public AjaxResult remove(@PathVariable("deviceId") Integer deviceId) throws Exception {
- //鏍规嵁瑕佸垹闄ゅ畨瑁呭崟鐨刬d鏌ヨ鍑哄畨瑁呭崟淇℃伅
- DeviceOrder deviceOrder = iDeviceOrderService.selectDeviceOrderById(deviceId);
- SysUser user = getLoginUser().getUser();
- //濡傛灉鏍规嵁鏌ヨ鍑烘潵鐨勫畨瑁呭崟瀵硅薄涓嶄负绌虹殑璇濓紝骞朵笖鐘舵�佺瓑浜庢湭娲惧崟鎵嶅彲浠ュ垹闄�
- if (deviceOrder != null && deviceOrder.getState() == 0 && user.getUserId() != 1) {
- //鏈淳鍗曠殑瀹夎鍗曞垹闄ゅ悗璁惧鐨勭姸鎬佹洿鏂颁负-鏈縺娲�
- Device device = new Device();
- device.setDeviceId(deviceOrder.getDeviceId());
- device.setStatus(1);
- deviceService.updateDevice(device);
- int i = iDeviceOrderService.deleteDeviceOrderById(deviceOrder.getId());
- return toAjax(i);
- } else {
- return AjaxResult.error();
- }
+ @DeleteMapping("/{id}/{deviceId}")
+ @ApiOperation("鍒犻櫎璁惧璁㈠崟淇℃伅")
+ public AjaxResult remove(@PathVariable("id") Long id, @PathVariable("deviceId") Long deviceId) throws Exception {
+ return iDeviceOrderService.deleteDeviceOrderById(id, deviceId);
}
/**
- * 瀹夎鍗曠淮淇崟鍥剧墖涓婁紶
+ * 瀹夎鍗�/缁翠慨鍗曞浘鐗囦笂浼�
+ *
+ * @param file
+ * @return
+ * @throws Exception
*/
- @Log(title = "瀹夎鍗曞浘鐗囦笂浼�", businessType = BusinessType.INSERT)
+ @Log(title = "瀹夎鍗�/缁翠慨鍗曞浘鐗囦笂浼�", businessType = BusinessType.INSERT)
@PostMapping("/profile/avatar")
- @ApiOperation("瀹夎鍗曞浘鐗囦笂浼�")
+ @ApiOperation("瀹夎鍗�/缁翠慨鍗曞浘鐗囦笂浼�")
public AjaxResult imgurl(@RequestParam("avatarfile") MultipartFile file) throws Exception {
// 鍒ゆ柇澶村儚鏂囦欢涓嶄负绌�
if (!file.isEmpty()) {
--
Gitblit v1.8.0