Commit 9037207b45c3c5e2b7533a35993c1525ee2fe5f5
1 parent
e90ca46177
Exists in
master
and in
6 other branches
自定义高危因素数据接口
Showing 5 changed files with 172 additions and 30 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/HisptialRiskTypeEnum.java
- platform-common/src/main/java/com/lyms/platform/common/enums/RiskDefaultTypeEnum.java
- platform-dal/src/main/java/com/lyms/platform/pojo/HosptialHighRisk.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HosptialHighRiskController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/HosptialHighRiskFacade.java
platform-common/src/main/java/com/lyms/platform/common/enums/HisptialRiskTypeEnum.java
View file @
9037207
| 1 | +package com.lyms.platform.common.enums; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.HashMap; | |
| 5 | +import java.util.List; | |
| 6 | +import java.util.Map; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @auther yangfei | |
| 10 | + * @createTime 2018年01月04日 16时40分 | |
| 11 | + * @discription | |
| 12 | + */ | |
| 13 | +public enum HisptialRiskTypeEnum { | |
| 14 | + YBFX("315107bd-91fe-42a1-9237-752f3c046a40", "一般风险","risk_yellow"), | |
| 15 | + JGFX("49a36aea-c5b6-4162-87d2-9eb3c6ec00c2", "较高风险","risk_orange"), | |
| 16 | + GFX("eb146c03-b19f-4e28-b85f-fda574b2283b", "高风险","risk_red"), | |
| 17 | + CRB("224b2329-cb82-4da3-a071-8527f8283aab", "传染病","risk_purple"); | |
| 18 | + private String id; | |
| 19 | + private String name; | |
| 20 | + private String color; | |
| 21 | + | |
| 22 | + public static String getTitle(String id) { | |
| 23 | + for (HisptialRiskTypeEnum cfEnums : HisptialRiskTypeEnum.values()) { | |
| 24 | + if (id.equals(cfEnums.getId())) { | |
| 25 | + return cfEnums.getName(); | |
| 26 | + } | |
| 27 | + } | |
| 28 | + return ""; | |
| 29 | + } | |
| 30 | + public static List<Map> getHandlingSuggestionEnums() { | |
| 31 | + List<Map> list = new ArrayList<>(); | |
| 32 | + for (HisptialRiskTypeEnum e : HisptialRiskTypeEnum.values()) { | |
| 33 | + Map rootMap = new HashMap(); | |
| 34 | + rootMap.put("id", e.getId()); | |
| 35 | + rootMap.put("name", e.getName()); | |
| 36 | + rootMap.put("color", e.getColor()); | |
| 37 | + list.add(rootMap); | |
| 38 | + } | |
| 39 | + return list; | |
| 40 | + } | |
| 41 | + | |
| 42 | + HisptialRiskTypeEnum(String id, String name, String color) { | |
| 43 | + this.id = id; | |
| 44 | + this.name = name; | |
| 45 | + this.color = color; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public String getId() { | |
| 49 | + return id; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public String getColor() { | |
| 53 | + return color; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public void setColor(String color) { | |
| 57 | + this.color = color; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setId(String id) { | |
| 61 | + this.id = id; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public String getName() { | |
| 65 | + return name; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setName(String name) { | |
| 69 | + this.name = name; | |
| 70 | + } | |
| 71 | + | |
| 72 | +} |
platform-common/src/main/java/com/lyms/platform/common/enums/RiskDefaultTypeEnum.java
View file @
9037207
platform-dal/src/main/java/com/lyms/platform/pojo/HosptialHighRisk.java
View file @
9037207
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | |
| 16 | 16 | @Id |
| 17 | 17 | private String id; |
| 18 | - //分数 | |
| 18 | + //评分Id | |
| 19 | 19 | private String code; |
| 20 | 20 | //名称 |
| 21 | 21 | private String name; |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | |
| ... | ... | @@ -25,19 +25,24 @@ |
| 25 | 25 | private Integer yn; |
| 26 | 26 | //医院id |
| 27 | 27 | private String hospitalId; |
| 28 | - private String typeId; | |
| 29 | - | |
| 30 | 28 | //权重 |
| 31 | 29 | private Integer weight; |
| 32 | - | |
| 33 | 30 | private Long createDate; |
| 34 | 31 | private Long modifiedDate; |
| 35 | - | |
| 32 | + //分数 | |
| 36 | 33 | private Integer score; |
| 37 | 34 | private String describe; |
| 38 | 35 | //颜色 |
| 39 | 36 | private String color; |
| 40 | 37 | |
| 38 | + public String getCode() { | |
| 39 | + return code; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void setCode(String code) { | |
| 43 | + this.code = code; | |
| 44 | + } | |
| 45 | + | |
| 41 | 46 | public Integer getWeight() { |
| 42 | 47 | return weight; |
| 43 | 48 | } |
| ... | ... | @@ -98,14 +103,6 @@ |
| 98 | 103 | this.modifiedDate = modifiedDate; |
| 99 | 104 | } |
| 100 | 105 | |
| 101 | - public String getTypeId() { | |
| 102 | - return typeId; | |
| 103 | - } | |
| 104 | - | |
| 105 | - public void setTypeId(String typeId) { | |
| 106 | - this.typeId = typeId; | |
| 107 | - } | |
| 108 | - | |
| 109 | 106 | public Integer getEnable() { |
| 110 | 107 | return enable; |
| 111 | 108 | } |
| ... | ... | @@ -129,14 +126,6 @@ |
| 129 | 126 | |
| 130 | 127 | public void setId(String id) { |
| 131 | 128 | this.id = id; |
| 132 | - } | |
| 133 | - | |
| 134 | - public String getCode() { | |
| 135 | - return code; | |
| 136 | - } | |
| 137 | - | |
| 138 | - public void setCode(String code) { | |
| 139 | - this.code = code; | |
| 140 | 129 | } |
| 141 | 130 | |
| 142 | 131 | public Integer getYn() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HosptialHighRiskController.java
View file @
9037207
| 1 | 1 | package com.lyms.platform.operate.web.controller; |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.common.annotation.TokenRequired; |
| 4 | +import com.lyms.platform.common.base.BaseController; | |
| 4 | 5 | import com.lyms.platform.common.base.LoginContext; |
| 6 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 5 | 7 | import com.lyms.platform.common.result.BaseResponse; |
| 8 | +import com.lyms.platform.common.utils.StringUtils; | |
| 6 | 9 | import com.lyms.platform.operate.web.facade.HosptialHighRiskFacade; |
| 7 | 10 | import com.lyms.platform.pojo.HosptialHighRisk; |
| 8 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 12 | |
| ... | ... | @@ -19,11 +22,22 @@ |
| 19 | 22 | */ |
| 20 | 23 | @Controller |
| 21 | 24 | @RequestMapping("/hospHightRisk") |
| 22 | -public class HosptialHighRiskController { | |
| 25 | +public class HosptialHighRiskController extends BaseController { | |
| 23 | 26 | @Autowired |
| 24 | 27 | private HosptialHighRiskFacade hosptialHighRiskFacade; |
| 25 | 28 | |
| 26 | 29 | /** |
| 30 | + * 自定义高危页面初始化数据 | |
| 31 | + * | |
| 32 | + * @return | |
| 33 | + */ | |
| 34 | + @RequestMapping(method = RequestMethod.GET, value = "/init") | |
| 35 | + @ResponseBody | |
| 36 | + public BaseResponse initHosptialHighRisk(){ | |
| 37 | + return hosptialHighRiskFacade.initHosptialHighRisk(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 27 | 41 | * 添加自定义高危 |
| 28 | 42 | * |
| 29 | 43 | * @param request |
| ... | ... | @@ -34,6 +48,16 @@ |
| 34 | 48 | @TokenRequired |
| 35 | 49 | public BaseResponse addHightRisk(@Valid @RequestBody HosptialHighRisk request, HttpServletRequest httpServletRequest) { |
| 36 | 50 | LoginContext loginState = (LoginContext) httpServletRequest.getAttribute("loginContext"); |
| 51 | + //分数为空 | |
| 52 | + if(request.getScore()==null||request.getScore()==0){ | |
| 53 | + return new BaseResponse("请填写高危因数分数", ErrorCodeConstants.PARAMETER_ERROR); | |
| 54 | + }else if(StringUtils.isEmpty(request.getName())){//高危因数名称为null | |
| 55 | + return new BaseResponse("请填写高危因数名称", ErrorCodeConstants.PARAMETER_ERROR); | |
| 56 | + }else if(StringUtils.isEmpty(request.getColor())){//高危因数等级null | |
| 57 | + return new BaseResponse("请选择高危因数等级", ErrorCodeConstants.PARAMETER_ERROR); | |
| 58 | + } | |
| 59 | + | |
| 60 | + | |
| 37 | 61 | return hosptialHighRiskFacade.addHosptialHighRisk(request, loginState.getId()); |
| 38 | 62 | } |
| 39 | 63 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/HosptialHighRiskFacade.java
View file @
9037207
| 1 | 1 | package com.lyms.platform.operate.web.facade; |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.biz.service.HosptialHighRiskService; |
| 4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 5 | +import com.lyms.platform.common.enums.HisptialRiskTypeEnum; | |
| 6 | +import com.lyms.platform.common.enums.RiskDefaultTypeEnum; | |
| 4 | 7 | import com.lyms.platform.common.result.BaseResponse; |
| 8 | +import com.lyms.platform.common.utils.SystemConfig; | |
| 5 | 9 | import com.lyms.platform.pojo.HosptialHighRisk; |
| 6 | 10 | import com.lyms.platform.query.HosptialHighRiskQuery; |
| 11 | +import org.apache.commons.collections.CollectionUtils; | |
| 7 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | 13 | import org.springframework.stereotype.Component; |
| 9 | 14 | |
| 15 | +import java.util.HashMap; | |
| 10 | 16 | import java.util.List; |
| 17 | +import java.util.Map; | |
| 11 | 18 | |
| 12 | 19 | /** |
| 13 | 20 | * @auther yangfei |
| 14 | 21 | |
| 15 | 22 | |
| 16 | 23 | |
| 17 | 24 | |
| 18 | 25 | |
| 19 | 26 | |
| 20 | 27 | |
| 21 | 28 | |
| 22 | 29 | |
| ... | ... | @@ -20,37 +27,88 @@ |
| 20 | 27 | private HosptialHighRiskService hosptialHighRiskService; |
| 21 | 28 | @Autowired |
| 22 | 29 | private AutoMatchFacade autoMatchFacade; |
| 30 | + @Autowired | |
| 31 | + private BasicConfigFacade basicConfigFacade; | |
| 23 | 32 | |
| 33 | + private static Map<String, String> colorMap = new HashMap<>(); | |
| 34 | + | |
| 35 | + static { | |
| 36 | + colorMap.put("224b2329-cb82-4da3-a071-8527f8283aab", "risk_" + RiskDefaultTypeEnum.getColor("紫色")); | |
| 37 | + colorMap.put("e637b361-99cf-41eb-84f2-f0dab596e928", "risk_" + RiskDefaultTypeEnum.getColor("绿色")); | |
| 38 | + colorMap.put("eb146c03-b19f-4e28-b85f-fda574b2283b", "risk_" + RiskDefaultTypeEnum.getColor("红色")); | |
| 39 | + colorMap.put("49a36aea-c5b6-4162-87d2-9eb3c6ec00c2", "risk_" + RiskDefaultTypeEnum.getColor("橙色")); | |
| 40 | + colorMap.put("315107bd-91fe-42a1-9237-752f3c046a40", "risk_" + RiskDefaultTypeEnum.getColor("黄色")); | |
| 41 | + } | |
| 42 | + | |
| 24 | 43 | /** |
| 44 | + * 页面初始化数据 | |
| 45 | + * | |
| 46 | + * @return | |
| 47 | + */ | |
| 48 | + public BaseResponse initHosptialHighRisk() { | |
| 49 | + BaseResponse baseResponse = new BaseResponse(); | |
| 50 | + Map<String, Object> map = new HashMap<>(); | |
| 51 | + map.put("gwdj", HisptialRiskTypeEnum.getHandlingSuggestionEnums()); | |
| 52 | + map.put("gwfz", basicConfigFacade.getBaseicConfigByParentId(SystemConfig.GWFZ)); | |
| 53 | + baseResponse.setObject(map); | |
| 54 | + return baseResponse; | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 25 | 58 | * 新增自定义高危 |
| 59 | + * | |
| 26 | 60 | * @param hosptialHighRisk |
| 27 | 61 | * @return |
| 28 | 62 | */ |
| 29 | - public BaseResponse addHosptialHighRisk(HosptialHighRisk hosptialHighRisk, int userId){ | |
| 30 | - BaseResponse baseResponse = new BaseResponse(); | |
| 63 | + public BaseResponse addHosptialHighRisk(HosptialHighRisk hosptialHighRisk, int userId) { | |
| 64 | + | |
| 65 | + | |
| 31 | 66 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
| 32 | - hosptialHighRisk.setHospitalId(hospitalId); | |
| 33 | - hosptialHighRiskService.addHosptialHighRisk(hosptialHighRisk); | |
| 67 | + HosptialHighRiskQuery hosptialHighRiskQuery = new HosptialHighRiskQuery(); | |
| 68 | + hosptialHighRiskQuery.setHospitalId(hospitalId); | |
| 69 | + hosptialHighRiskQuery.setColor(hosptialHighRisk.getColor()); | |
| 70 | + hosptialHighRiskQuery.setName(hosptialHighRisk.getName()); | |
| 71 | + | |
| 72 | + List<HosptialHighRisk> hosptialHighRisks = hosptialHighRiskService.queryHosptialHighRisk(hosptialHighRiskQuery); | |
| 73 | + | |
| 74 | + BaseResponse baseResponse = new BaseResponse(); | |
| 75 | + if (CollectionUtils.isEmpty(hosptialHighRisks)) { | |
| 76 | + hosptialHighRisk.setEnable(1); | |
| 77 | + hosptialHighRisk.setYn(1); | |
| 78 | + hosptialHighRisk.setHospitalId(hospitalId); | |
| 79 | + hosptialHighRiskService.addHosptialHighRisk(hosptialHighRisk); | |
| 80 | + } else { | |
| 81 | + baseResponse.setErrorcode(ErrorCodeConstants.DATA_EXIST); | |
| 82 | + baseResponse.setErrormsg("添加的高危因数名称已经存在,请勿重复添加"); | |
| 83 | + } | |
| 34 | 84 | return baseResponse; |
| 35 | 85 | } |
| 36 | 86 | |
| 37 | 87 | /** |
| 38 | 88 | * 根据用户id查询自定义高危 |
| 89 | + * | |
| 39 | 90 | * @param userId 当前登录用户id |
| 40 | 91 | * @return |
| 41 | 92 | */ |
| 42 | - public BaseResponse getHosptialHighRisk(int userId){ | |
| 93 | + public BaseResponse getHosptialHighRisk(int userId) { | |
| 43 | 94 | BaseResponse baseResponse = new BaseResponse(); |
| 44 | 95 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
| 45 | 96 | HosptialHighRiskQuery hosptialHighRiskQuery = new HosptialHighRiskQuery(); |
| 46 | 97 | hosptialHighRiskQuery.setHospitalId(hospitalId); |
| 47 | 98 | List<HosptialHighRisk> hosptialHighRisks = hosptialHighRiskService.queryHosptialHighRisk(hosptialHighRiskQuery); |
| 48 | - baseResponse.setObject(hosptialHighRisks); | |
| 99 | + if (CollectionUtils.isNotEmpty(hosptialHighRisks)) { | |
| 100 | + for (HosptialHighRisk hr : hosptialHighRisks) { | |
| 101 | + hr.setColor(colorMap.get(hr.getColor())); | |
| 102 | + } | |
| 103 | + baseResponse.setObject(hosptialHighRisks); | |
| 104 | + } | |
| 105 | + | |
| 49 | 106 | return baseResponse; |
| 50 | 107 | } |
| 51 | 108 | |
| 52 | 109 | /** |
| 53 | 110 | * 根据Id,删除自定义高危 |
| 111 | + * | |
| 54 | 112 | * @param id |
| 55 | 113 | * @return |
| 56 | 114 | */ |