AppRoadProtectionController.java 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.sooka.sponest.mobile.comprehensive.roadCaseController;
  2. import com.ruoyi.common.core.constant.HttpStatus;
  3. import com.ruoyi.common.core.web.controller.BaseController;
  4. import com.ruoyi.common.core.web.domain.AjaxResult;
  5. import com.ruoyi.common.core.web.page.PageDomain;
  6. import com.ruoyi.common.core.web.page.TableDataInfo;
  7. import com.ruoyi.common.core.web.page.TableSupport;
  8. import com.ruoyi.common.security.utils.DictUtils;
  9. import com.sooka.sponest.comprehensive.api.comprehensiveOrganizationAndInstitution.domain.ComprehensiveRoom;
  10. import com.sooka.sponest.comprehensive.api.comprehensiveRoadCase.domain.ComprehensiveRoadProtection;
  11. import com.sooka.sponest.comprehensive.api.comprehensiveRoadCase.service.RemoteRoadProtectionService;
  12. import com.ruoyi.common.core.domain.DictKeys;
  13. import org.apache.commons.collections4.MapUtils;
  14. import org.springframework.web.bind.annotation.*;
  15. import javax.annotation.Resource;
  16. import java.util.HashMap;
  17. import java.util.List;
  18. import java.util.Map;
  19. @RestController
  20. @RequestMapping("/AppRoadProtectionController")
  21. public class AppRoadProtectionController extends BaseController {
  22. @Resource
  23. private RemoteRoadProtectionService remoteRoadProtectionService;
  24. /**
  25. * 查询护路护线
  26. */
  27. @GetMapping("/RoadProtection/list")
  28. public AjaxResult list(ComprehensiveRoadProtection comprehensiveRoadProtection) {
  29. PageDomain pageDomain = TableSupport.buildPageRequest();
  30. Integer pageNum = pageDomain.getPageNum();
  31. Integer pageSize = pageDomain.getPageSize();
  32. TableDataInfo tableDataInfo = remoteRoadProtectionService.selectComprehensiveRoadProtectionList(pageNum, pageSize, comprehensiveRoadProtection.getName());
  33. if (HttpStatus.SUCCESS == tableDataInfo.getCode()) {
  34. List<HashMap<String, Object>> rows = (List<HashMap<String, Object>>) tableDataInfo.getRows();
  35. Map<String, Object> dictCacheToMap = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_LINE_TYPE);
  36. Map<String, Object> dictCacheToMap1 = DictUtils.getDictCacheToMap(DictKeys.COMPREHENSIVE_POLICING_LEVEL);
  37. if (!rows.isEmpty()) {
  38. for (HashMap<String, Object> row : rows) {
  39. row.put("routeTypeLabel", dictCacheToMap.get(row.get("routeType")));
  40. row.put("publicSecurityHazardLevelLabel", dictCacheToMap1.get(row.get("publicSecurityHazardLevel")));
  41. }
  42. }
  43. return AjaxResult.success(tableDataInfo.getRows());
  44. } else {
  45. return AjaxResult.error(tableDataInfo.getCode(), tableDataInfo.getMsg());
  46. }
  47. }
  48. /**
  49. * 获取护路护线详细信息
  50. */
  51. @GetMapping("/RoadProtection/edit")
  52. public AjaxResult getInfo(String id) {
  53. AjaxResult ajaxResult = remoteRoadProtectionService.selectComprehensiveRoadProtectionById(id);
  54. if("200".equals(String.valueOf(ajaxResult.get("code")))){
  55. HashMap<String,Object> comprehensiveRoadProtection = (HashMap<String, Object>) ajaxResult.get("data");
  56. comprehensiveRoadProtection.put("routeTypeLabel",DictUtils.getDictDataByValue(DictKeys.COMPREHENSIVE_LINE_TYPE, MapUtils.getString(comprehensiveRoadProtection,"routeType")));
  57. comprehensiveRoadProtection.put("publicSecurityHazardLevelLabel",DictUtils.getDictDataByValue(DictKeys.COMPREHENSIVE_POLICING_LEVEL,MapUtils.getString(comprehensiveRoadProtection,"publicSecurityHazardLevel")));
  58. return AjaxResult.success(comprehensiveRoadProtection);
  59. }else{
  60. return AjaxResult.error(ajaxResult.get("code").toString(), ajaxResult.get("msg"));
  61. }
  62. }
  63. /**
  64. * 新增护路护线
  65. */
  66. @PostMapping("/RoadProtection")
  67. public AjaxResult add(@RequestBody String json) {
  68. return remoteRoadProtectionService.insertComprehensiveRoadProtection(json);
  69. }
  70. /**
  71. * 修改护路护线
  72. */
  73. @PostMapping("/RoadProtection/put")
  74. public AjaxResult edit(@RequestBody String json) {
  75. return remoteRoadProtectionService.updateComprehensiveRoadProtection(json);
  76. }
  77. /**
  78. * 删除护路护线
  79. */
  80. @GetMapping("/RoadProtection/del")
  81. public AjaxResult remove(@RequestParam("id") List<String> id) {
  82. return remoteRoadProtectionService.deleteComprehensiveRoadProtectionByIds(id.toArray(new String[0]));
  83. }
  84. }