¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |