Commit 9e285f23326c1722cb71070b8499f1da4d6dd58d
1 parent
aaabbfcf7e
Exists in
dev
#fix:优化五色专案管理 查询五色逻辑
Showing 3 changed files with 110 additions and 30 deletions
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java
View file @
9e285f2
| ... | ... | @@ -132,7 +132,7 @@ |
| 132 | 132 | patientsQuery.mysqlBuild(iPatientDao.queryPatientCount(query)); |
| 133 | 133 | query.start(patientsQuery.getOffset()).end(patientsQuery.getLimit()); |
| 134 | 134 | } |
| 135 | - // System.out.println(query.convertToMongoQuery().toString()); | |
| 135 | + // System.out.println(query.convertToMongoQuery().toString()); | |
| 136 | 136 | return iPatientDao.queryPatient(query.addOrder(Sort.Direction.fromString(sort), field)); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
| ... | ... | @@ -142,8 +142,13 @@ |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | public int queryPatientCount(PatientsQuery patientsQuery) { |
| 145 | - System.out.println(patientsQuery.convertToQuery().convertToMongoQuery().toString()); | |
| 145 | + // System.out.println(patientsQuery.convertToQuery().convertToMongoQuery().toString()); | |
| 146 | 146 | return iPatientDao.queryPatientCount(patientsQuery.convertToQuery()); |
| 147 | + } | |
| 148 | + | |
| 149 | + public int queryRiskCount(MongoQuery query){ | |
| 150 | + // System.out.println(query.convertToMongoQuery().toString()); | |
| 151 | + return iPatientDao.queryPatientCount(query); | |
| 147 | 152 | } |
| 148 | 153 | |
| 149 | 154 | public int queryPatientCount(String _id) { |
platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java
View file @
9e285f2
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | import org.springframework.data.mongodb.core.query.Criteria; |
| 12 | 12 | |
| 13 | 13 | import java.util.*; |
| 14 | +import java.util.regex.Pattern; | |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * 产妇模型定义 |
| 17 | 18 | |
| ... | ... | @@ -1125,8 +1126,8 @@ |
| 1125 | 1126 | |
| 1126 | 1127 | Criteria c1 = null; |
| 1127 | 1128 | |
| 1129 | + Criteria c5 = MongoCondition.newInstance().getCriteria(); | |
| 1128 | 1130 | |
| 1129 | - | |
| 1130 | 1131 | if (StringUtils.isNotEmpty(rLevel)) { |
| 1131 | 1132 | //大同特殊处理 按颜色等于查询 |
| 1132 | 1133 | if("2100002419".equals(hospitalId)&&StringUtils.isEmpty(allPats)){ |
| 1133 | 1134 | |
| 1134 | 1135 | |
| 1135 | 1136 | |
| 1136 | 1137 | |
| 1137 | 1138 | |
| 1138 | 1139 | |
| 1139 | 1140 | |
| 1140 | 1141 | |
| ... | ... | @@ -1316,38 +1317,40 @@ |
| 1316 | 1317 | }else { |
| 1317 | 1318 | condition = condition.and("riskLevelId", JsonUtil.array2JsonString(levelList), MongoOper.IS); |
| 1318 | 1319 | } |
| 1319 | - | |
| 1320 | 1320 | } |
| 1321 | - | |
| 1322 | 1321 | }else { |
| 1323 | - String [] strs= allPats.split(","); | |
| 1324 | - //针对单颜色级别处理 如果是单颜色level是1查询包含此颜色及紫色的所有数据 | |
| 1325 | - if(strs.length>1){ | |
| 1326 | - if ("1".equals(strs[1]) && !"224b2329-cb82-4da3-a071-8527f8283aab".equals(rLevel)){ | |
| 1322 | + if ("1".equals(allPats)){ | |
| 1323 | + //黄色 查询黄色和紫色 | |
| 1324 | + if ("315107bd-91fe-42a1-9237-752f3c046a40".equals(rLevel)){ | |
| 1327 | 1325 | List<String> riskLevelIds=new ArrayList<>(); |
| 1328 | 1326 | riskLevelIds.add(rLevel); |
| 1329 | 1327 | MongoCondition c = MongoCondition.newInstance(); |
| 1330 | 1328 | MongoCondition condition1 = MongoCondition.newInstance("riskLevelId", JsonUtil.array2JsonString(riskLevelIds), MongoOper.IS); |
| 1331 | - | |
| 1332 | 1329 | riskLevelIds.add("224b2329-cb82-4da3-a071-8527f8283aab"); |
| 1333 | - | |
| 1334 | 1330 | MongoCondition condition2 = MongoCondition.newInstance("riskLevelId",JsonUtil.array2JsonString(riskLevelIds), MongoOper.IS); |
| 1335 | 1331 | riskLevelIds.clear(); |
| 1336 | - | |
| 1337 | 1332 | riskLevelIds.add("224b2329-cb82-4da3-a071-8527f8283aab"); |
| 1338 | 1333 | riskLevelIds.add(rLevel); |
| 1339 | 1334 | MongoCondition condition3 = MongoCondition.newInstance("riskLevelId",JsonUtil.array2JsonString(riskLevelIds), MongoOper.IS); |
| 1340 | 1335 | if (c1 != null) { |
| 1341 | - c1 = c1.andOperator(c.orCondition(new MongoCondition[]{condition1, condition2,condition3}).getCriteria()); | |
| 1342 | - } else { | |
| 1343 | - c1 = c.orCondition(new MongoCondition[]{condition1, condition2,condition3}).getCriteria(); | |
| 1344 | - } | |
| 1336 | + c1 = c1.andOperator(c.orCondition(new MongoCondition[]{condition1, condition2,condition3}).getCriteria()); | |
| 1337 | + } else { | |
| 1338 | + c1 = c.orCondition(new MongoCondition[]{condition1, condition2,condition3}).getCriteria(); | |
| 1339 | + } | |
| 1340 | + //橙色 查询除了红色以外的 | |
| 1341 | + }else if ("49a36aea-c5b6-4162-87d2-9eb3c6ec00c2".equals(rLevel)){ | |
| 1342 | + //查询不包含红色 eb146c03-b19f-4e28-b85f-fda574b2283b | |
| 1343 | + Pattern compile = Pattern.compile("^((?!" + "eb146c03-b19f-4e28-b85f-fda574b2283b"+ ").)*$", Pattern.CASE_INSENSITIVE); | |
| 1344 | + c5 =Criteria.where("riskLevelId").is(compile).regex(rLevel); | |
| 1345 | + //红色查询所有包含红色的 | |
| 1346 | + }else if ("eb146c03-b19f-4e28-b85f-fda574b2283b".equals(rLevel)){ | |
| 1347 | + condition = condition.and("riskLevelId", rLevel,MongoOper.LIKE); | |
| 1345 | 1348 | }else { |
| 1346 | 1349 | List<String> riskLevelIds=new ArrayList<>(); |
| 1347 | 1350 | riskLevelIds.add(rLevel); |
| 1348 | - condition = condition.and("riskLevelId", JsonUtil.array2JsonString(riskLevelIds), MongoOper.IS); | |
| 1351 | + condition = condition.and("riskLevelId", JsonUtil.array2JsonString(riskLevelIds),MongoOper.IS); | |
| 1349 | 1352 | } |
| 1350 | - }else { | |
| 1353 | + }else{ | |
| 1351 | 1354 | condition = condition.and("riskLevelId", rLevel, MongoOper.LIKE); |
| 1352 | 1355 | } |
| 1353 | 1356 | |
| 1354 | 1357 | |
| ... | ... | @@ -1926,10 +1929,10 @@ |
| 1926 | 1929 | c4.and("firstCheckId").exists(firstCheckId2); |
| 1927 | 1930 | } |
| 1928 | 1931 | if (null != c1) { |
| 1929 | - return new MongoCondition(c1.andOperator(condition.getCriteria(), c2, c3, c4)).toMongoQuery(); | |
| 1932 | + return new MongoCondition(c1.andOperator(condition.getCriteria(), c2, c3, c4,c5)).toMongoQuery(); | |
| 1930 | 1933 | // return new MongoCondition(c1.andOperator(condition.getCriteria())).toMongoQuery(); |
| 1931 | 1934 | } |
| 1932 | - return new MongoCondition(c2.andOperator(condition.getCriteria(), c3, c4)).toMongoQuery(); | |
| 1935 | + return new MongoCondition(c2.andOperator(condition.getCriteria(), c3, c4,c5)).toMongoQuery(); | |
| 1933 | 1936 | // return condition.toMongoQuery(); |
| 1934 | 1937 | } |
| 1935 | 1938 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RiskReportFacade.java
View file @
9e285f2
| ... | ... | @@ -5,6 +5,9 @@ |
| 5 | 5 | import com.lyms.platform.biz.service.BasicConfigService; |
| 6 | 6 | import com.lyms.platform.biz.service.PatientsService; |
| 7 | 7 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 8 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 9 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
| 10 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 8 | 11 | import com.lyms.platform.common.enums.YnEnums; |
| 9 | 12 | import com.lyms.platform.common.result.BaseListResponse; |
| 10 | 13 | import com.lyms.platform.common.result.BaseObjectResponse; |
| ... | ... | @@ -30,6 +33,7 @@ |
| 30 | 33 | import org.apache.commons.collections.MapUtils; |
| 31 | 34 | import org.springframework.beans.factory.annotation.Autowired; |
| 32 | 35 | import org.springframework.beans.factory.annotation.Qualifier; |
| 36 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 33 | 37 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 34 | 38 | import org.springframework.stereotype.Component; |
| 35 | 39 | |
| ... | ... | @@ -40,6 +44,7 @@ |
| 40 | 44 | import java.util.*; |
| 41 | 45 | import java.util.concurrent.*; |
| 42 | 46 | import java.util.concurrent.atomic.AtomicInteger; |
| 47 | +import java.util.regex.Pattern; | |
| 43 | 48 | |
| 44 | 49 | @Component |
| 45 | 50 | public class RiskReportFacade { |
| 46 | 51 | |
| 47 | 52 | |
| 48 | 53 | |
| 49 | 54 | |
| 50 | 55 | |
| ... | ... | @@ -711,24 +716,27 @@ |
| 711 | 716 | |
| 712 | 717 | List<BasicConfig> riskLevelConfig = basicConfigService.queryBasicConfig(basicConfigQuery); |
| 713 | 718 | if (CollectionUtils.isNotEmpty(riskLevelConfig)) { |
| 714 | - riskLevelConfig=addRisk(riskLevelConfig); | |
| 719 | + riskLevelConfig=addRisk(riskLevelConfig); | |
| 715 | 720 | for (BasicConfig levelConfig : riskLevelConfig) { |
| 716 | 721 | if ("e637b361-99cf-41eb-84f2-f0dab596e928".equals(levelConfig.getId())) { |
| 717 | 722 | continue; |
| 718 | 723 | } |
| 724 | + int allPatientCount=0; | |
| 725 | + patientsQuery.setrLevel(levelConfig.getId()); | |
| 719 | 726 | //高危等级 |
| 720 | 727 | List<String> levelList= StringUtils.covertToList(levelConfig.getId(), String.class); |
| 721 | - if (levelList.size()==1){ | |
| 728 | + if (levelList.size()==1&& (StringUtils.isEmpty(levelConfig.getLevel())|| "1".equals(levelConfig.getLevel()))){ | |
| 729 | + | |
| 722 | 730 | if (StringUtils.isEmpty(levelConfig.getLevel())){ |
| 723 | 731 | levelConfig.setLevel("1"); |
| 724 | 732 | } |
| 725 | - //针对与单颜色做特殊处理 | |
| 726 | - patientsQuery.setAllPats("allPats,"+levelConfig.getLevel()); | |
| 733 | + //针对与单颜色做特殊处理 | |
| 734 | + allPatientCount= patientsService.queryRiskCount(getQuery(patientsQuery)); | |
| 727 | 735 | }else { |
| 728 | 736 | patientsQuery.setAllPats(""); |
| 737 | + allPatientCount = patientsService.queryPatientCount(patientsQuery); | |
| 729 | 738 | } |
| 730 | - patientsQuery.setrLevel(levelConfig.getId()); | |
| 731 | - int allPatientCount = patientsService.queryPatientCount(patientsQuery); | |
| 739 | + | |
| 732 | 740 | if (allPatientCount>0){ |
| 733 | 741 | RiskReportResult risk = new RiskReportResult(); |
| 734 | 742 | risk.setLevel(Integer.valueOf(levelConfig.getLevel())); |
| ... | ... | @@ -747,6 +755,70 @@ |
| 747 | 755 | .setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(results); |
| 748 | 756 | } |
| 749 | 757 | |
| 758 | + | |
| 759 | + private MongoQuery getQuery(PatientsQuery patientsQuery){ | |
| 760 | + Criteria c1 = Criteria.where("hospitalId").is(patientsQuery.getHospitalId()).and("yn").is(1); | |
| 761 | + String rLevel=patientsQuery.getrLevel(); | |
| 762 | + if (patientsQuery.getType()!=null &&patientsQuery.getType()!=-1){ | |
| 763 | + if (patientsQuery.getType()==1){ | |
| 764 | + c1=c1.and("dtFm").ne(0); | |
| 765 | + } | |
| 766 | + c1=c1.and("type").is(patientsQuery.getType()); | |
| 767 | + } | |
| 768 | + if (StringUtils.isNotEmpty(patientsQuery.getLastCheckEmployeeId())){ | |
| 769 | + c1=c1.and("lastCheckEmployeeId").is(patientsQuery.getLastCheckEmployeeId()); | |
| 770 | + } | |
| 771 | + if (null != patientsQuery.getLastCTimeStart()) { | |
| 772 | + c1 = c1.and("lastCTime").gte(patientsQuery.getLastCTimeStart()); | |
| 773 | + } | |
| 774 | + if (null != patientsQuery.getLastCTimeEnd()) { | |
| 775 | + c1 = c1.lte(patientsQuery.getLastCTimeEnd()); | |
| 776 | + } | |
| 777 | + List buildTypes = new ArrayList(); | |
| 778 | + buildTypes.add(0); | |
| 779 | + buildTypes.add(2); | |
| 780 | + Criteria buildType =Criteria.where("buildType").is(3).and("enable").is(1); | |
| 781 | + Criteria buildType2= Criteria.where("buildType").in(buildTypes); | |
| 782 | + c1=c1.orOperator(buildType,buildType2); | |
| 783 | + | |
| 784 | + //针对单颜色级别处理 如果是单颜色level是1查询包含此颜色及紫色的所有数据 | |
| 785 | + if (!"224b2329-cb82-4da3-a071-8527f8283aab".equals(rLevel)){ | |
| 786 | + //黄色只查询 黄色和紫色 | |
| 787 | + if("315107bd-91fe-42a1-9237-752f3c046a40".equals(rLevel)){ | |
| 788 | + List<String> riskLevelIds=new ArrayList<>(); | |
| 789 | + riskLevelIds.add(rLevel); | |
| 790 | + MongoCondition c = MongoCondition.newInstance(); | |
| 791 | + MongoCondition condition1 = MongoCondition.newInstance("riskLevelId", JsonUtil.array2JsonString(riskLevelIds), MongoOper.IS); | |
| 792 | + riskLevelIds.add("224b2329-cb82-4da3-a071-8527f8283aab"); | |
| 793 | + MongoCondition condition2 = MongoCondition.newInstance("riskLevelId",JsonUtil.array2JsonString(riskLevelIds), MongoOper.IS); | |
| 794 | + riskLevelIds.clear(); | |
| 795 | + riskLevelIds.add("224b2329-cb82-4da3-a071-8527f8283aab"); | |
| 796 | + riskLevelIds.add(rLevel); | |
| 797 | + MongoCondition condition3 = MongoCondition.newInstance("riskLevelId",JsonUtil.array2JsonString(riskLevelIds), MongoOper.IS); | |
| 798 | + | |
| 799 | + c1 = c1.andOperator(c.orCondition(new MongoCondition[]{condition1, condition2,condition3}).getCriteria()); | |
| 800 | + //橙色需要查询 不包含红色 eb146c03-b19f-4e28-b85f-fda574b2283b | |
| 801 | + }else if ("49a36aea-c5b6-4162-87d2-9eb3c6ec00c2".equals(rLevel)){ | |
| 802 | + /* Criteria c2 =Criteria.where("riskLevelId").ne("[]"); | |
| 803 | + Criteria c3 =Criteria.where("riskLevelId").exists(true);*/ | |
| 804 | + Criteria c4 =Criteria.where("riskLevelId").regex(rLevel); | |
| 805 | + //查询不包含红色 eb146c03-b19f-4e28-b85f-fda574b2283b | |
| 806 | + Pattern compile = Pattern.compile("^((?!" + "eb146c03-b19f-4e28-b85f-fda574b2283b"+ ").)*$", Pattern.CASE_INSENSITIVE); | |
| 807 | + Criteria c5 =Criteria.where("riskLevelId").is(compile); | |
| 808 | + c1=c1.andOperator(c4,c5); | |
| 809 | + }else if ("eb146c03-b19f-4e28-b85f-fda574b2283b".equals(rLevel)){ | |
| 810 | + Criteria c4 =Criteria.where("riskLevelId").regex(rLevel); | |
| 811 | + c1=c1.andOperator(c4); | |
| 812 | + } | |
| 813 | + }else { | |
| 814 | + List<String> riskLevelIds=new ArrayList<>(); | |
| 815 | + riskLevelIds.add(rLevel); | |
| 816 | + c1 = c1.and("riskLevelId").is(JsonUtil.array2JsonString(riskLevelIds)); | |
| 817 | + } | |
| 818 | + | |
| 819 | + return new MongoCondition(c1).toMongoQuery(); | |
| 820 | + } | |
| 821 | + | |
| 750 | 822 | private static List<BasicConfig> basicConfigs; |
| 751 | 823 | |
| 752 | 824 | private static List<BasicConfig> addRisk(List<BasicConfig> basicConfigList){ |
| ... | ... | @@ -790,7 +862,7 @@ |
| 790 | 862 | BasicConfig chz =new BasicConfig(); |
| 791 | 863 | chz.setName("橙色-黄色-紫色"); |
| 792 | 864 | chz.setpId("fb43fd5a-b153-4cb9-9180-c46f5612ba43"); |
| 793 | - chz.setLevel("3"); | |
| 865 | + chz.setLevel("2"); | |
| 794 | 866 | chz.setId("49a36aea-c5b6-4162-87d2-9eb3c6ec00c2,315107bd-91fe-42a1-9237-752f3c046a40,224b2329-cb82-4da3-a071-8527f8283aab"); |
| 795 | 867 | basicConfigList.add(chz); |
| 796 | 868 | BasicConfig hs =new BasicConfig(); |
| 797 | 869 | |
| 798 | 870 | |
| ... | ... | @@ -826,19 +898,19 @@ |
| 826 | 898 | BasicConfig hhz =new BasicConfig(); |
| 827 | 899 | hhz.setName("红色-黄色-紫色"); |
| 828 | 900 | hhz.setpId("fb43fd5a-b153-4cb9-9180-c46f5612ba43"); |
| 829 | - hhz.setLevel("3"); | |
| 901 | + hhz.setLevel("2"); | |
| 830 | 902 | hhz.setId("eb146c03-b19f-4e28-b85f-fda574b2283b,315107bd-91fe-42a1-9237-752f3c046a40,224b2329-cb82-4da3-a071-8527f8283aab"); |
| 831 | 903 | basicConfigList.add(hhz); |
| 832 | 904 | BasicConfig hch =new BasicConfig(); |
| 833 | 905 | hch.setName("红色-橙色-黄色"); |
| 834 | 906 | hch.setpId("fb43fd5a-b153-4cb9-9180-c46f5612ba43"); |
| 835 | - hch.setLevel("3"); | |
| 907 | + hch.setLevel("2"); | |
| 836 | 908 | hch.setId("eb146c03-b19f-4e28-b85f-fda574b2283b,49a36aea-c5b6-4162-87d2-9eb3c6ec00c2,315107bd-91fe-42a1-9237-752f3c046a40"); |
| 837 | 909 | basicConfigList.add(hch); |
| 838 | 910 | BasicConfig hchz =new BasicConfig(); |
| 839 | 911 | hchz.setName("红色-橙色-黄色-紫色"); |
| 840 | 912 | hchz.setpId("fb43fd5a-b153-4cb9-9180-c46f5612ba43"); |
| 841 | - hchz.setLevel("3"); | |
| 913 | + hchz.setLevel("2"); | |
| 842 | 914 | hchz.setId("eb146c03-b19f-4e28-b85f-fda574b2283b,49a36aea-c5b6-4162-87d2-9eb3c6ec00c2,315107bd-91fe-42a1-9237-752f3c046a40,224b2329-cb82-4da3-a071-8527f8283aab"); |
| 843 | 915 | basicConfigList.add(hchz); |
| 844 | 916 | BasicConfig z =new BasicConfig(); |