AppRoadProtectionController.java 4.2 KB

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