Commit 2f59c18482a0407c900fd0e1fb7777b33f1e1245
1 parent
956c2162c1
Exists in
master
and in
1 other branch
增加
Showing 2 changed files with 73 additions and 51 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BasicConfigController.java
View file @
2f59c18
| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | import com.lyms.platform.operate.web.request.BasicConfigQueryRequest; |
| 11 | 11 | import com.lyms.platform.operate.web.request.BasicConfigUpdateRequest; |
| 12 | 12 | import com.lyms.platform.operate.web.result.FrontEndResult; |
| 13 | -import com.lyms.platform.operate.web.result.TreeNode; | |
| 14 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 14 | import org.springframework.http.MediaType; |
| 16 | 15 | import org.springframework.stereotype.Controller; |
| 17 | 16 | |
| 18 | 17 | |
| 19 | 18 | |
| 20 | 19 | |
| 21 | 20 | |
| ... | ... | @@ -21,24 +20,20 @@ |
| 21 | 20 | import java.util.List; |
| 22 | 21 | |
| 23 | 22 | /** |
| 24 | - * | |
| 25 | - * | |
| 26 | 23 | * 基础项配置接口 |
| 27 | - * | |
| 24 | + * | |
| 28 | 25 | * @author Administrator |
| 29 | 26 | */ |
| 30 | 27 | @Controller |
| 31 | 28 | public class BasicConfigController extends BaseController { |
| 32 | - | |
| 29 | + | |
| 33 | 30 | @Autowired |
| 34 | 31 | private BasicConfigFacade basicConfigFacade; |
| 35 | - | |
| 32 | + | |
| 36 | 33 | /** |
| 37 | - * | |
| 38 | 34 | * 基础项配置查询 |
| 39 | - * | |
| 40 | - * @param basicConfigQueryRequest 基础项配置查询请求 | |
| 41 | - * | |
| 35 | + * | |
| 36 | + * @param basicConfigQueryRequest 基础项配置查询请求 | |
| 42 | 37 | * @return 返回结果 |
| 43 | 38 | */ |
| 44 | 39 | @RequestMapping(method = RequestMethod.GET, value = "/basicConfig") |
| 45 | 40 | |
| 46 | 41 | |
| 47 | 42 | |
| 48 | 43 | |
| 49 | 44 | |
| 50 | 45 | |
| 51 | 46 | |
| 52 | 47 | |
| ... | ... | @@ -47,31 +42,26 @@ |
| 47 | 42 | BaseListResponse baseListResponse = basicConfigFacade.findBasicConfigList(basicConfigQueryRequest); |
| 48 | 43 | return FrontEndResult.ini().setData(baseListResponse.getData()).setPageInfo(baseListResponse.getPageInfo()).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); |
| 49 | 44 | } |
| 50 | - | |
| 45 | + | |
| 51 | 46 | /** |
| 52 | - * | |
| 53 | 47 | * 修改一条基础项配置 |
| 54 | - * | |
| 55 | - * @param id 基础项id | |
| 56 | - * | |
| 48 | + * | |
| 49 | + * @param id 基础项id | |
| 57 | 50 | * @param basicConfigUpdateRequest 基础项修改请求 |
| 58 | - * | |
| 59 | 51 | * @return 返回结果 |
| 60 | 52 | */ |
| 61 | 53 | @RequestMapping(method = RequestMethod.PUT, value = "/basicConfig/{id}") |
| 62 | 54 | @ResponseBody |
| 63 | 55 | public BaseResponse updateOneBasicConfigById(@PathVariable("id") |
| 64 | - String id, @Valid BasicConfigUpdateRequest basicConfigUpdateRequest) { | |
| 56 | + String id, @Valid BasicConfigUpdateRequest basicConfigUpdateRequest) { | |
| 65 | 57 | basicConfigUpdateRequest.setId(id); |
| 66 | 58 | return basicConfigFacade.updateOneBasicConfig(basicConfigUpdateRequest); |
| 67 | 59 | } |
| 68 | - | |
| 60 | + | |
| 69 | 61 | /** |
| 70 | - * | |
| 71 | 62 | * 删除一条基础项配置 |
| 72 | - * | |
| 63 | + * | |
| 73 | 64 | * @param id 基础项id |
| 74 | - * | |
| 75 | 65 | * @return 返回结果 |
| 76 | 66 | */ |
| 77 | 67 | @RequestMapping(method = RequestMethod.DELETE, value = "/basicConfig") |
| 78 | 68 | |
| 79 | 69 | |
| 80 | 70 | |
| 81 | 71 | |
| 82 | 72 | |
| 83 | 73 | |
| 84 | 74 | |
| 85 | 75 | |
| ... | ... | @@ -80,34 +70,32 @@ |
| 80 | 70 | return basicConfigFacade.deleteOneBasicConfig(id); |
| 81 | 71 | } |
| 82 | 72 | |
| 83 | - | |
| 73 | + | |
| 84 | 74 | /** |
| 85 | - * | |
| 86 | 75 | * 基础项树形结构数据 |
| 87 | - * | |
| 76 | + * | |
| 88 | 77 | * @return 返回结果 |
| 89 | 78 | */ |
| 90 | 79 | @RequestMapping(method = RequestMethod.GET, value = "/basicConfigTree") |
| 91 | 80 | @ResponseBody |
| 92 | 81 | public BaseListResponse findAllBasicConfigWithTree(BasicConfigQueryRequest basicConfigQueryRequest) { |
| 93 | - if(null == basicConfigQueryRequest.getParentId()) { | |
| 82 | + if (null == basicConfigQueryRequest.getParentId()) { | |
| 94 | 83 | basicConfigQueryRequest.setParentId("0"); |
| 95 | 84 | } |
| 96 | 85 | basicConfigQueryRequest.setLimit(9999); |
| 97 | 86 | return basicConfigFacade.findBasicConfigList(basicConfigQueryRequest); |
| 98 | 87 | } |
| 99 | - | |
| 88 | + | |
| 100 | 89 | /** |
| 101 | - * 批量增加基础项配置 | |
| 102 | - * | |
| 90 | + * 批量增加基础项配置 | |
| 91 | + * | |
| 103 | 92 | * @param basicConfigRequests 批量增加请求 |
| 104 | - * | |
| 105 | 93 | * @return 返回结果 |
| 106 | 94 | */ |
| 107 | - @RequestMapping(method = RequestMethod.POST, value = "/basicConfig", consumes = { MediaType.APPLICATION_JSON_VALUE }) | |
| 95 | + @RequestMapping(method = RequestMethod.POST, value = "/basicConfig", consumes = {MediaType.APPLICATION_JSON_VALUE}) | |
| 108 | 96 | @ResponseBody |
| 109 | 97 | public BaseResponse batchAddBasicConfig(@RequestBody |
| 110 | - List<BasicConfigAddRequest> basicConfigRequests) { | |
| 98 | + List<BasicConfigAddRequest> basicConfigRequests) { | |
| 111 | 99 | return basicConfigFacade.batchAddBasicConfig(basicConfigRequests); |
| 112 | 100 | } |
| 113 | 101 | |
| 114 | 102 | |
| ... | ... | @@ -124,12 +112,11 @@ |
| 124 | 112 | list.add(basicConfigAddRequest); |
| 125 | 113 | |
| 126 | 114 | basicConfigFacade.batchAddBasicConfig(list); |
| 127 | - return 1; | |
| 115 | + return 1; | |
| 128 | 116 | } |
| 129 | 117 | |
| 130 | 118 | |
| 131 | 119 | /** |
| 132 | - * | |
| 133 | 120 | * 查询基础数据根据类型 |
| 134 | 121 | * |
| 135 | 122 | * @return 返回结果 |
| ... | ... | @@ -140,5 +127,15 @@ |
| 140 | 127 | return basicConfigFacade.getBaseConfigByType(type); |
| 141 | 128 | } |
| 142 | 129 | |
| 130 | + /** | |
| 131 | + * 获取高危因素 | |
| 132 | + * | |
| 133 | + * @return 返回结果 | |
| 134 | + */ | |
| 135 | + @RequestMapping(method = RequestMethod.GET, value = "/getHighRisk") | |
| 136 | + @ResponseBody | |
| 137 | + public BaseResponse getHighRisk() { | |
| 138 | + return basicConfigFacade.getHighRisk(); | |
| 139 | + } | |
| 143 | 140 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BasicConfigFacade.java
View file @
2f59c18
| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | import org.springframework.stereotype.Component; |
| 23 | 23 | |
| 24 | 24 | import java.util.ArrayList; |
| 25 | +import java.util.HashMap; | |
| 25 | 26 | import java.util.List; |
| 26 | 27 | |
| 27 | 28 | @Component |
| ... | ... | @@ -52,7 +53,7 @@ |
| 52 | 53 | } |
| 53 | 54 | |
| 54 | 55 | |
| 55 | - public List<BasicConfigResult> buildResult( List<BasicConfig> data){ | |
| 56 | + public List<BasicConfigResult> buildResult(List<BasicConfig> data) { | |
| 56 | 57 | List<BasicConfigResult> dataList = new ArrayList<>(); |
| 57 | 58 | if (CollectionUtils.isNotEmpty(data)) { |
| 58 | 59 | for (BasicConfig basicConfig : data) { |
| 59 | 60 | |
| ... | ... | @@ -61,12 +62,10 @@ |
| 61 | 62 | dataList.add(basicConfigResult); |
| 62 | 63 | } |
| 63 | 64 | } |
| 64 | - return dataList; | |
| 65 | + return dataList; | |
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | |
| 68 | - | |
| 69 | - | |
| 70 | 69 | /** |
| 71 | 70 | * 修改一条基础项配置 |
| 72 | 71 | * |
| ... | ... | @@ -116,7 +115,7 @@ |
| 116 | 115 | public List<TreeNode> findAllBasicConfigWithTree() { |
| 117 | 116 | List<TreeNode> list = new ArrayList<TreeNode>(); |
| 118 | 117 | List<BasicConfig> l = basicConfigService.queryParentConfig(); |
| 119 | - if(CollectionUtils.isNotEmpty(l)){ | |
| 118 | + if (CollectionUtils.isNotEmpty(l)) { | |
| 120 | 119 | for (BasicConfig b : l) { |
| 121 | 120 | TreeNode node = TreeHelper.recursiveTree(b, basicConfigService); |
| 122 | 121 | if (null != node) { |
| 123 | 122 | |
| 124 | 123 | |
| ... | ... | @@ -148,22 +147,20 @@ |
| 148 | 147 | |
| 149 | 148 | /** |
| 150 | 149 | * 查询基础数据通过parentId |
| 150 | + * | |
| 151 | 151 | * @param parentId |
| 152 | 152 | * @return |
| 153 | 153 | */ |
| 154 | - public List<BasicConfigResult> getBaseicConfigByParentId(String parentId) | |
| 155 | - { | |
| 154 | + public List<BasicConfigResult> getBaseicConfigByParentId(String parentId) { | |
| 156 | 155 | BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); |
| 157 | 156 | basicConfigQuery.setNeed("1"); |
| 158 | 157 | basicConfigQuery.setYn(YnEnums.YES.getId()); |
| 159 | 158 | basicConfigQuery.setParentId(parentId); |
| 160 | 159 | List<BasicConfig> datas = basicConfigService.queryBasicConfig(basicConfigQuery); |
| 161 | - List<BasicConfigResult> configResults = new ArrayList<>(); | |
| 162 | - if (datas != null) | |
| 163 | - { | |
| 164 | - for(BasicConfig data : datas) | |
| 165 | - { | |
| 166 | - BasicConfigResult br = new BasicConfigResult(); | |
| 160 | + List<BasicConfigResult> configResults = new ArrayList<>(); | |
| 161 | + if (datas != null) { | |
| 162 | + for (BasicConfig data : datas) { | |
| 163 | + BasicConfigResult br = new BasicConfigResult(); | |
| 167 | 164 | br.setId(data.getId()); |
| 168 | 165 | br.setCode(data.getCode()); |
| 169 | 166 | br.setEnable(data.getEnable()); |
| ... | ... | @@ -178,6 +175,7 @@ |
| 178 | 175 | |
| 179 | 176 | /** |
| 180 | 177 | * 根据类型查询响应的 基础数据 |
| 178 | + * | |
| 181 | 179 | * @param type |
| 182 | 180 | * @return |
| 183 | 181 | */ |
| 184 | 182 | |
| ... | ... | @@ -185,12 +183,11 @@ |
| 185 | 183 | |
| 186 | 184 | BaseObjectResponse objectResponse = new BaseObjectResponse(); |
| 187 | 185 | |
| 188 | - List<BasicConfigResult> results = new ArrayList<>(); | |
| 186 | + List<BasicConfigResult> results = new ArrayList<>(); | |
| 189 | 187 | |
| 190 | - String parentId = ConfigTypeEnums.getTypeParentId(type); | |
| 191 | - | |
| 192 | - if (!StringUtils.isEmpty(parentId)) | |
| 193 | - { | |
| 188 | + String parentId = ConfigTypeEnums.getTypeParentId(type); | |
| 189 | + | |
| 190 | + if (!StringUtils.isEmpty(parentId)) { | |
| 194 | 191 | results = getBaseicConfigByParentId(parentId); |
| 195 | 192 | } |
| 196 | 193 | objectResponse.setData(results); |
| 197 | 194 | |
| ... | ... | @@ -199,6 +196,34 @@ |
| 199 | 196 | return objectResponse; |
| 200 | 197 | } |
| 201 | 198 | |
| 199 | + public BaseResponse getHighRisk() { | |
| 200 | + BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); | |
| 201 | + basicConfigQuery.setYn(YnEnums.YES.getId()); | |
| 202 | + basicConfigQuery.setParentId(SystemConfig.HIGH_RISK_ID); | |
| 203 | + List<BasicConfig> basicConfigs = basicConfigService.queryBasicConfig(basicConfigQuery); | |
| 204 | + List<BasicConfig> basicConfigs1 = new ArrayList<>(); | |
| 205 | + if (CollectionUtils.isNotEmpty(basicConfigs)) { | |
| 206 | + for (BasicConfig basicConfig : basicConfigs) { | |
| 207 | + basicConfigQuery.setParentId(basicConfig.getId()); | |
| 208 | + List<BasicConfig> basicConfigs2 = basicConfigService.queryBasicConfig(basicConfigQuery); | |
| 209 | + if (CollectionUtils.isNotEmpty(basicConfigs2)) { | |
| 210 | + basicConfigs1.addAll(basicConfigs2); | |
| 211 | + } | |
| 212 | + } | |
| 213 | + } | |
| 202 | 214 | |
| 215 | + return new BaseObjectResponse().setData(convertToList(basicConfigs1)).setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 216 | + } | |
| 217 | + | |
| 218 | + private List convertToList(List<BasicConfig> list) { | |
| 219 | + List data = new ArrayList<>(); | |
| 220 | + for (BasicConfig basicConfig : list) { | |
| 221 | + java.util.Map map = new HashMap<>(); | |
| 222 | + map.put("id", basicConfig.getId()); | |
| 223 | + map.put("name", basicConfig.getName()); | |
| 224 | + data.add(map); | |
| 225 | + } | |
| 226 | + return list; | |
| 227 | + } | |
| 203 | 228 | } |