From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 25 六月 2025 11:51:38 +0800 Subject: [PATCH] Merge branch 'mdc_hyjs_master' --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/DeviceInfoController.java | 181 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 181 insertions(+), 0 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/DeviceInfoController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/DeviceInfoController.java new file mode 100644 index 0000000..a99a09a --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/DeviceInfoController.java @@ -0,0 +1,181 @@ +package org.jeecg.modules.dnc.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.modules.dnc.entity.DeviceInfo; +import org.jeecg.modules.dnc.response.*; +import org.jeecg.modules.dnc.service.IDeviceInfoService; +import org.jeecg.modules.dnc.service.IDevicePermissionService; +import org.jeecg.modules.mdc.model.MdcEquipmentTree; +import org.jeecg.modules.system.entity.SysUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Collections; +import java.util.List; + +@Slf4j +@Api(tags = "璁惧琛�") +@RestController +@RequestMapping("/nc/device") +public class DeviceInfoController extends JeecgController<DeviceInfo, IDeviceInfoService> { + @Autowired + private IDeviceInfoService deviceInfoService; + @Autowired + private IDevicePermissionService devicePermissionService; + + @AutoLog(value = "璁惧琛�-鏂板璁惧") + @ApiOperation(value = "璁惧琛�-鏂板璁惧", notes = "璁惧琛�-鏂板璁惧") + @PostMapping("/add") + public ResponseResult addDeviceInfo(@RequestBody DeviceInfo deviceInfo) { + boolean b = deviceInfoService.addDeviceInfo(deviceInfo); + if(b) { + return new ResponseResult(CommonCode.SUCCESS); + } + return new ResponseResult(CommonCode.FAIL); + } + + @AutoLog(value = "璁惧琛�-缂栬緫璁惧淇℃伅") + @ApiOperation(value = "璁惧琛�-缂栬緫璁惧淇℃伅", notes = "璁惧琛�-缂栬緫璁惧淇℃伅") + @PutMapping("/edit/{id}") + public ResponseResult editDeviceInfo(@PathVariable("id") String id, @RequestBody DeviceInfo deviceInfo) { + boolean b = deviceInfoService.editDeviceInfo(id, deviceInfo); + if(b) { + return new ResponseResult(CommonCode.SUCCESS); + } + return new ResponseResult(CommonCode.FAIL); + } + + @AutoLog(value = "璁惧琛�-鍒犻櫎璁惧") + @ApiOperation(value = "璁惧琛�-鍒犻櫎璁惧", notes = "璁惧琛�-鍒犻櫎璁惧") + @DeleteMapping("/delete") + public ResponseResult deleteDeviceInfo(@RequestParam("id") String id) { + boolean b = deviceInfoService.deleteDeviceInfo(id); + if(b) { + return new ResponseResult(CommonCode.SUCCESS); + } + return new ResponseResult(CommonCode.FAIL); + } + + @AutoLog(value = "璁惧琛�-鏍规嵁鐢ㄦ埛鏉冮檺鑾峰彇鏍�") + @ApiOperation(value = "璁惧琛�-鏍规嵁鐢ㄦ埛鏉冮檺鑾峰彇鏍�", notes = "璁惧琛�-鏍规嵁鐢ㄦ埛鏉冮檺鑾峰彇鏍�") + @GetMapping("/load/tree") + public QueryListResponseResult<CommonGenericTree> loadTree() { + List<CommonGenericTree> list = deviceInfoService.loadTree(); + if(list == null) + list = Collections.emptyList(); + return new QueryListResponseResult(CommonCode.SUCCESS, list); + } + + @AutoLog(value = "璁惧琛�-鑾峰彇鑺傜偣宸插垎閰嶇殑鐢ㄦ埛") + @ApiOperation(value = "璁惧琛�-鑾峰彇鑺傜偣宸插垎閰嶇殑鐢ㄦ埛", notes = "璁惧琛�-鑾峰彇鑺傜偣宸插垎閰嶇殑鐢ㄦ埛") + @GetMapping("/get/perm/user/{nodeType}/{paramId}") + public QueryListResponseResult<SysUser> getUserPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) { + List<SysUser> list = deviceInfoService.getUserPermsList(nodeType, paramId); + if(list == null) + list = Collections.emptyList(); + return new QueryListResponseResult(CommonCode.SUCCESS, list); + } + + @AutoLog(value = "璁惧琛�-鑾峰彇鑺傜偣鏈垎閰嶇殑鐢ㄦ埛") + @ApiOperation(value = "璁惧琛�-鑾峰彇鑺傜偣鏈垎閰嶇殑鐢ㄦ埛", notes = "璁惧琛�-鑾峰彇鑺傜偣鏈垎閰嶇殑鐢ㄦ埛") + @GetMapping("/get/non/perm/user/{nodeType}/{paramId}") + public QueryListResponseResult<SysUser> getUserNonPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) { + List<SysUser> list = deviceInfoService.getUserNonPermsList(nodeType, paramId); + if(list == null) + list = Collections.emptyList(); + return new QueryListResponseResult(CommonCode.SUCCESS, list); + } + + /** + * 妫�鏌ョ敤鎴锋槸鍚︽湁璇ヨ澶囩殑鏉冮檺 + * @param nodeType 1 璁惧鍒嗙粍 2 璁惧 + * @param paramId + * @return + */ + @AutoLog(value = "璁惧琛�-妫�鏌ョ敤鎴锋槸鍚︽湁璇ヨ澶囩殑鏉冮檺 1 璁惧鍒嗙粍 2 璁惧") + @ApiOperation(value = "璁惧琛�-妫�鏌ョ敤鎴锋槸鍚︽湁璇ヨ澶囩殑鏉冮檺 1 璁惧鍒嗙粍 2 璁惧", notes = "璁惧琛�-妫�鏌ョ敤鎴锋槸鍚︽湁璇ヨ澶囩殑鏉冮檺 1 璁惧鍒嗙粍 2 璁惧") + @GetMapping("/check/{nodeType}/{paramId}") + public ResponseResult checkDevicePerm(@PathVariable("nodeType") Integer nodeType,@PathVariable("paramId") String paramId) { + boolean b = deviceInfoService.checkDevicePerm(nodeType, paramId); + if(b) { + return new ResponseResult(CommonCode.SUCCESS); + } + return new ResponseResult(CommonCode.UNAUTHORISE); + } + + @AutoLog(value = "璁惧琛�-澧炲姞璁惧鏍戣妭鐐圭殑鐢ㄦ埛鏉冮檺") + @ApiOperation(value = "璁惧琛�-澧炲姞璁惧鏍戣妭鐐圭殑鐢ㄦ埛鏉冮檺", notes = "璁惧琛�-澧炲姞璁惧鏍戣妭鐐圭殑鐢ㄦ埛鏉冮檺") + @PostMapping("/assign/add/user/{nodeType}/{paramId}/{relativeFlag}") + public ResponseResult assignAddUser(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) { + boolean b = deviceInfoService.assignAddUser(nodeType, paramId, relativeFlag, userIds); + if(b) { + return new ResponseResult(CommonCode.SUCCESS); + } + return new ResponseResult(CommonCode.FAIL); + } + + @AutoLog(value = "璁惧琛�-鍒犻櫎璁惧鏍戣妭鐐圭殑鐢ㄦ埛鏉冮檺") + @ApiOperation(value = "璁惧琛�-鍒犻櫎璁惧鏍戣妭鐐圭殑鐢ㄦ埛鏉冮檺", notes = "璁惧琛�-鍒犻櫎璁惧鏍戣妭鐐圭殑鐢ㄦ埛鏉冮檺") + @PostMapping("/assign/remove/user/{nodeType}/{paramId}/{relativeFlag}") + public ResponseResult assignRemoveUser(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) { + boolean b = deviceInfoService.assignRemoveUser(nodeType, paramId, relativeFlag, userIds); + if(b) { + return new ResponseResult(CommonCode.SUCCESS); + } + return new ResponseResult(CommonCode.FAIL); + } + + @AutoLog(value = "璁惧琛�-鍏ㄩ儴璁惧鍒楄〃") + @ApiOperation(value = "璁惧琛�-鍏ㄩ儴璁惧鍒楄〃", notes = "璁惧琛�-鍏ㄩ儴璁惧鍒楄〃") + @GetMapping("/list/all") + public QueryListResponseResult<DeviceInfo> findListAll() { + List<DeviceInfo> list = deviceInfoService.list(); + if(list == null) + list = Collections.emptyList(); + return new QueryListResponseResult(CommonCode.SUCCESS, list); + } + + @AutoLog(value = "璁惧琛�-鎸囨淳鍒拌澶� 璁惧鏍�") + @ApiOperation(value = "璁惧琛�-鎸囨淳鍒拌澶� 璁惧鏍�", notes = "璁惧琛�-鎸囨淳鍒拌澶� 璁惧鏍�") + @GetMapping("/load/depart/tree/{nodeType}/{paramId}") + public QueryListResponseResult<CommonGenericTree> loadDepartTree(@PathVariable("nodeType") Integer nodeType,@PathVariable("paramId") String paramId) { + List<CommonGenericTree> list = deviceInfoService.loadDepartTree(nodeType, paramId); + if(list == null) + list = Collections.emptyList(); + return new QueryListResponseResult(CommonCode.SUCCESS, list); + } + + @AutoLog(value = "璁惧琛�-鑾峰彇鍞竴 璁惧缂栧彿") + @ApiOperation(value = "璁惧琛�-鑾峰彇鍞竴 璁惧缂栧彿", notes = "璁惧琛�-鑾峰彇鍞竴 璁惧缂栧彿") + @GetMapping("/valid/device") + public ResponseResult validateDeviceNo(String deviceNo) { + DeviceInfo byDeviceNo = deviceInfoService.getByDeviceNo(deviceNo); + if(byDeviceNo == null) { + return new ResponseResult(DeviceCode.DEVICE_NOT_EXIST); + } + return new ResponseResult(CommonCode.SUCCESS); + } + + /** + * 鍔犺浇浜х嚎璁惧鏍� + */ + @AutoLog(value = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�") + @ApiOperation(value = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�", notes = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�") + @GetMapping(value = "/queryTreeListByProduction") + public Result<List<MdcEquipmentTree>> queryTreeListByProduction() { + Result<List<MdcEquipmentTree>> result = new Result<>(); + try { + List<MdcEquipmentTree> mdcEquipmentTreeList = devicePermissionService.DncLoadTreeListByProduction(); + result.setSuccess(true); + result.setResult(mdcEquipmentTreeList); + } catch (Exception e) { + return Result.error("鍔犺浇浜х嚎璁惧鏍戝け璐ワ紒" + e.getMessage()); + } + return result; + } +} -- Gitblit v1.9.3