Commit 19d050649d219b930c7738fa7ceafab8c983f3a4

Authored by liquanyu
1 parent be6b7aa46d

儿童

Showing 8 changed files with 487 additions and 1 deletions

platform-dal/src/main/java/com/lyms/platform/pojo/BabyModel.java View file @ 19d0506
... ... @@ -210,6 +210,59 @@
210 210 //儿童诊断
211 211 private String babyDiagnosis;
212 212  
  213 + //体重评价
  214 + private String weightEvaluate;
  215 + //身长评价
  216 + private String heightEvaluate;
  217 + //头围评价
  218 + private String headEvaluate;
  219 +
  220 + //身长别体重
  221 + private String heightWeight;
  222 +
  223 + //病历号(住院号)
  224 + private String blNo;
  225 +
  226 + public String getBlNo() {
  227 + return blNo;
  228 + }
  229 +
  230 + public void setBlNo(String blNo) {
  231 + this.blNo = blNo;
  232 + }
  233 +
  234 + public String getWeightEvaluate() {
  235 + return weightEvaluate;
  236 + }
  237 +
  238 + public void setWeightEvaluate(String weightEvaluate) {
  239 + this.weightEvaluate = weightEvaluate;
  240 + }
  241 +
  242 + public String getHeightEvaluate() {
  243 + return heightEvaluate;
  244 + }
  245 +
  246 + public void setHeightEvaluate(String heightEvaluate) {
  247 + this.heightEvaluate = heightEvaluate;
  248 + }
  249 +
  250 + public String getHeadEvaluate() {
  251 + return headEvaluate;
  252 + }
  253 +
  254 + public void setHeadEvaluate(String headEvaluate) {
  255 + this.headEvaluate = headEvaluate;
  256 + }
  257 +
  258 + public String getHeightWeight() {
  259 + return heightWeight;
  260 + }
  261 +
  262 + public void setHeightWeight(String heightWeight) {
  263 + this.heightWeight = heightWeight;
  264 + }
  265 +
213 266 public String getBabyDiagnosis() {
214 267 return babyDiagnosis;
215 268 }
platform-dal/src/main/java/com/lyms/platform/query/BabyModelQuery.java View file @ 19d0506
... ... @@ -245,6 +245,48 @@
245 245  
246 246 private String queryNo;
247 247  
  248 + //体重评价
  249 + private String weightEvaluate;
  250 + //身长评价
  251 + private String heightEvaluate;
  252 + //头围评价
  253 + private String headEvaluate;
  254 +
  255 + //身长别体重
  256 + private String heightWeight;
  257 +
  258 + public String getWeightEvaluate() {
  259 + return weightEvaluate;
  260 + }
  261 +
  262 + public void setWeightEvaluate(String weightEvaluate) {
  263 + this.weightEvaluate = weightEvaluate;
  264 + }
  265 +
  266 + public String getHeightEvaluate() {
  267 + return heightEvaluate;
  268 + }
  269 +
  270 + public void setHeightEvaluate(String heightEvaluate) {
  271 + this.heightEvaluate = heightEvaluate;
  272 + }
  273 +
  274 + public String getHeadEvaluate() {
  275 + return headEvaluate;
  276 + }
  277 +
  278 + public void setHeadEvaluate(String headEvaluate) {
  279 + this.headEvaluate = headEvaluate;
  280 + }
  281 +
  282 + public String getHeightWeight() {
  283 + return heightWeight;
  284 + }
  285 +
  286 + public void setHeightWeight(String heightWeight) {
  287 + this.heightWeight = heightWeight;
  288 + }
  289 +
248 290 public String getQueryNo() {
249 291 return queryNo;
250 292 }
... ... @@ -448,6 +490,20 @@
448 490 if (null != pregnancyOut) {
449 491 condition = condition.and("pregnancyOut", pregnancyOut, MongoOper.IS);
450 492 }
  493 +
  494 + if (null != weightEvaluate) {
  495 + condition = condition.and("weightEvaluate", weightEvaluate, MongoOper.IS);
  496 + }
  497 + if (null != heightEvaluate) {
  498 + condition = condition.and("heightEvaluate", heightEvaluate, MongoOper.IS);
  499 + }
  500 + if (null != headEvaluate) {
  501 + condition = condition.and("pregnancyOut", headEvaluate, MongoOper.IS);
  502 + }
  503 + if (null != heightWeight) {
  504 + condition = condition.and("pregnancyOut", heightWeight, MongoOper.IS);
  505 + }
  506 +
451 507  
452 508 if (!StringUtils.isEmpty(mcertNo)) {
453 509 condition = condition.and("mcertNo", mcertNo, MongoOper.IS);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java View file @ 19d0506
... ... @@ -371,5 +371,19 @@
371 371 return babyBookbuildingFacade.queryHisBabyDiagnosis(blNo);
372 372 }
373 373  
  374 +
  375 + /**
  376 + * 儿童生长统计
  377 + * @return
  378 + */
  379 + @RequestMapping(method = RequestMethod.GET, value = "/getBabyGroupCount")
  380 + @ResponseBody
  381 + public BaseResponse getBabyGroupCount(@Valid @RequestBody BabyManageRequest babyManageRequest,
  382 + HttpServletRequest request) {
  383 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  384 + return babyBookbuildingFacade.getBabyGroupCount(babyManageRequest,loginState.getId());
  385 + }
  386 +
  387 +
374 388 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java View file @ 19d0506
... ... @@ -14,6 +14,7 @@
14 14 import com.lyms.platform.operate.web.request.*;
15 15 import com.lyms.platform.operate.web.result.*;
16 16 import com.lyms.platform.operate.web.utils.BabyListTask;
  17 +import com.lyms.platform.operate.web.utils.GrowthCountTask;
17 18 import com.lyms.platform.operate.web.utils.HiskCountTask;
18 19 import com.lyms.platform.operate.web.utils.MessageCenterService;
19 20 import com.lyms.platform.permission.model.Organization;
... ... @@ -798,6 +799,7 @@
798 799  
799 800 bm.setDueWeek(b.getDueWeek());
800 801 bm.setBabyDiagnosis(b.getBabyDiagnosis());
  802 + bm.setBlNo(b.getBlNo());
801 803  
802 804 return bm;
803 805 }
... ... @@ -965,7 +967,7 @@
965 967 result.setExpType(model.getExpType());
966 968  
967 969 result.setBabyDiagnosis(model.getBabyDiagnosis());
968   -
  970 + result.setBlNo(model.getBlNo());
969 971 result.setDueWeek(model.getDueWeek());
970 972 return result;
971 973 }
... ... @@ -2110,6 +2112,212 @@
2110 2112 objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
2111 2113 objectResponse.setErrormsg("成功");
2112 2114 return objectResponse;
  2115 + }
  2116 +
  2117 + /**
  2118 + * 儿童生长发育统计
  2119 + * @param request
  2120 + * @param userId
  2121 + * @return
  2122 + */
  2123 + public BaseResponse getBabyGroupCount(BabyManageRequest request, Integer userId) {
  2124 + String hospitalId = "";
  2125 + //得到当前登录的医院id
  2126 + if (userId != null) {
  2127 + Users dbuser = usersService.getUsers(userId);
  2128 + if (dbuser != null) {
  2129 + hospitalId = String.valueOf(dbuser.getOrgId());
  2130 + }
  2131 + }
  2132 +
  2133 + BabyModelQuery babyQuery = new BabyModelQuery();
  2134 + List buildType = new ArrayList();
  2135 + buildType.add(1);
  2136 + buildType.add(2);
  2137 + babyQuery.setBuildTypeList(buildType);
  2138 + babyQuery.setHospitalId(hospitalId);
  2139 +
  2140 + babyQuery.setYn(YnEnums.YES.getId());
  2141 + Date currentDate = DateUtil.formatDate(new Date());
  2142 +
  2143 + if(StringUtils.isNotEmpty(request.getBirth()) && request.getMonthAgeStart() != null && request.getMonthAgeEnd() != null)
  2144 + {
  2145 +
  2146 + Date start = DateUtil.addMonth(currentDate, -request.getMonthAgeStart());
  2147 + String birthStr = request.getBirth();
  2148 + String[] dates = birthStr.split(" - ");
  2149 +
  2150 + if (DateUtil.parseYMD(dates[1]).getTime() < start.getTime())
  2151 + {
  2152 + babyQuery.setBirthEnd(DateUtil.parseYMD(dates[1]));
  2153 +
  2154 + }
  2155 + else
  2156 + {
  2157 + babyQuery.setBirthEnd(start);
  2158 + }
  2159 +
  2160 + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -request.getMonthAgeEnd() - 1), 1);
  2161 +
  2162 + if (DateUtil.parseYMD(dates[0]).getTime() < end.getTime())
  2163 + {
  2164 + babyQuery.setBirthStart(end);
  2165 + }
  2166 + else
  2167 + {
  2168 + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0]));
  2169 + }
  2170 + }
  2171 + else if (StringUtils.isNotEmpty(request.getBirth()) && request.getMonthAgeStart() != null )
  2172 + {
  2173 +
  2174 + Date start = DateUtil.addMonth(currentDate, -request.getMonthAgeStart());
  2175 + String birthStr = request.getBirth();
  2176 + String[] dates = birthStr.split(" - ");
  2177 +
  2178 + if (DateUtil.parseYMD(dates[1]).getTime() < start.getTime())
  2179 + {
  2180 + babyQuery.setBirthEnd(DateUtil.parseYMD(dates[1]));
  2181 + }
  2182 + else
  2183 + {
  2184 + babyQuery.setBirthEnd(start);
  2185 + }
  2186 +
  2187 + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0]));
  2188 +
  2189 + }
  2190 + else if (StringUtils.isNotEmpty(request.getBirth()))
  2191 + {
  2192 + String birthStr = request.getBirth();
  2193 + String[] dates = birthStr.split(" - ");
  2194 + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0]));
  2195 + babyQuery.setBirthEnd(DateUtil.parseYMD(dates[1]));
  2196 + }
  2197 + else if (request.getMonthAgeStart() != null && request.getMonthAgeEnd() != null)
  2198 + {
  2199 + Date start = DateUtil.addMonth(currentDate, -request.getMonthAgeStart());
  2200 + babyQuery.setBirthEnd(start);
  2201 +
  2202 + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -request.getMonthAgeEnd() - 1), 1);
  2203 + babyQuery.setBirthStart(end);
  2204 + }
  2205 + else if (request.getMonthAgeStart() != null)
  2206 + {
  2207 + Date start = DateUtil.addMonth(currentDate, -request.getMonthAgeStart());
  2208 + babyQuery.setBirthEnd(start);
  2209 + }
  2210 + else if (request.getMonthAgeEnd() != null)
  2211 + {
  2212 + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -request.getMonthAgeEnd() - 1), 1);
  2213 + babyQuery.setBirthStart(end);
  2214 + }
  2215 + Map<String,List<BabyGrowthCountResult>> result = new HashMap<>();
  2216 +
  2217 + Map<String,List<BabyGrowthCountResult>> mapItems = getCountGroupItemMaps();
  2218 + for(String key : mapItems.keySet())
  2219 + {
  2220 + List<BabyGrowthCountResult> groups = mapItems.get(key);
  2221 + GrowthCountTask task = new GrowthCountTask(groups,babyQuery,babyBookbuildingService,key);
  2222 + result.put(key,task.getResults());
  2223 + }
  2224 +
  2225 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  2226 + objectResponse.setData(result);
  2227 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  2228 + objectResponse.setErrormsg("成功");
  2229 + return objectResponse;
  2230 + }
  2231 +
  2232 +
  2233 + public Map<String,List<BabyGrowthCountResult>> getCountGroupItemMaps()
  2234 + {
  2235 + List<BabyGrowthCountResult> list1 = new ArrayList<>();
  2236 + BabyGrowthCountResult growH = new BabyGrowthCountResult();
  2237 + growH.setBzc("> +3SD");
  2238 + growH.setEvaluate("上");
  2239 + list1.add(growH);
  2240 +
  2241 + BabyGrowthCountResult growH1 = new BabyGrowthCountResult();
  2242 + growH1.setBzc("+2SD - +3SD");
  2243 + growH1.setEvaluate("中上");
  2244 + list1.add(growH1);
  2245 +
  2246 +
  2247 + BabyGrowthCountResult growH2 = new BabyGrowthCountResult();
  2248 + growH2.setBzc("+1SD > +2SD");
  2249 + growH2.setEvaluate("中+");
  2250 + list1.add(growH2);
  2251 +
  2252 + BabyGrowthCountResult growH3 = new BabyGrowthCountResult();
  2253 + growH3.setBzc("-1SD - +1SD");
  2254 + growH3.setEvaluate("中");
  2255 + list1.add(growH3);
  2256 +
  2257 +
  2258 + BabyGrowthCountResult growH4 = new BabyGrowthCountResult();
  2259 + growH4.setBzc("-2SD> -1SD");
  2260 + growH4.setEvaluate("中-");
  2261 + list1.add(growH4);
  2262 +
  2263 +
  2264 + BabyGrowthCountResult growH5 = new BabyGrowthCountResult();
  2265 + growH5.setBzc("-3SD - -2SD");
  2266 + growH5.setEvaluate("中下");
  2267 + list1.add(growH5);
  2268 +
  2269 + BabyGrowthCountResult growH6 = new BabyGrowthCountResult();
  2270 + growH6.setBzc("< -3SD");
  2271 + growH6.setEvaluate("下");
  2272 + list1.add(growH5);
  2273 +
  2274 +
  2275 +
  2276 + List<BabyGrowthCountResult> list2 = new ArrayList<>();
  2277 + BabyGrowthCountResult growW = new BabyGrowthCountResult();
  2278 + growW.setBzc("> +3SD");
  2279 + growW.setEvaluate("上");
  2280 + list2.add(growW);
  2281 +
  2282 + BabyGrowthCountResult growW1 = new BabyGrowthCountResult();
  2283 + growW1.setBzc("+2SD - +3SD");
  2284 + growW1.setEvaluate("中上");
  2285 + list2.add(growW1);
  2286 +
  2287 +
  2288 + BabyGrowthCountResult growW2 = new BabyGrowthCountResult();
  2289 + growW2.setBzc("+1SD > +2SD");
  2290 + growW2.setEvaluate("中+");
  2291 + list2.add(growW2);
  2292 +
  2293 + BabyGrowthCountResult growW3 = new BabyGrowthCountResult();
  2294 + growW3.setBzc("-1SD - +1SD");
  2295 + growW3.setEvaluate("中");
  2296 + list2.add(growW3);
  2297 +
  2298 +
  2299 + BabyGrowthCountResult growW4 = new BabyGrowthCountResult();
  2300 + growW4.setBzc("-2SD> -1SD");
  2301 + growW4.setEvaluate("中-");
  2302 + list2.add(growW4);
  2303 +
  2304 +
  2305 + BabyGrowthCountResult growW5 = new BabyGrowthCountResult();
  2306 + growW5.setBzc("-3SD - -2SD");
  2307 + growW5.setEvaluate("中下");
  2308 + list2.add(growH5);
  2309 +
  2310 + BabyGrowthCountResult growW6 = new BabyGrowthCountResult();
  2311 + growW6.setBzc("< -3SD");
  2312 + growW6.setEvaluate("下");
  2313 + list2.add(growW6);
  2314 +
  2315 +
  2316 + Map<String,List<BabyGrowthCountResult>> map1 = new HashMap<>();
  2317 + map1.put("身长",list1);
  2318 + map1.put("体重",list2);
  2319 +
  2320 + return map1;
2113 2321 }
2114 2322 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyBookbuildingAddRequest.java View file @ 19d0506
... ... @@ -166,6 +166,17 @@
166 166 //儿童诊断
167 167 private String babyDiagnosis;
168 168  
  169 + //病历号(住院号)
  170 + private String blNo;
  171 +
  172 + public String getBlNo() {
  173 + return blNo;
  174 + }
  175 +
  176 + public void setBlNo(String blNo) {
  177 + this.blNo = blNo;
  178 + }
  179 +
169 180 public String getBabyDiagnosis() {
170 181 return babyDiagnosis;
171 182 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyBuildResult.java View file @ 19d0506
... ... @@ -137,6 +137,18 @@
137 137 //儿童诊断
138 138 private String babyDiagnosis;
139 139  
  140 +
  141 + //病历号(住院号)
  142 + private String blNo;
  143 +
  144 + public String getBlNo() {
  145 + return blNo;
  146 + }
  147 +
  148 + public void setBlNo(String blNo) {
  149 + this.blNo = blNo;
  150 + }
  151 +
140 152 public String getBabyDiagnosis() {
141 153 return babyDiagnosis;
142 154 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyGrowthCountResult.java View file @ 19d0506
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.HashMap;
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +/**
  9 + * Created by lqy on 2016-12-21.
  10 + */
  11 +public class BabyGrowthCountResult {
  12 +
  13 + //标准差
  14 + private String bzc;
  15 +
  16 + //评价
  17 + private String evaluate;
  18 +
  19 + //人数
  20 + private String count;
  21 +
  22 + public String getBzc() {
  23 + return bzc;
  24 + }
  25 +
  26 + public void setBzc(String bzc) {
  27 + this.bzc = bzc;
  28 + }
  29 +
  30 + public String getEvaluate() {
  31 + return evaluate;
  32 + }
  33 +
  34 + public void setEvaluate(String evaluate) {
  35 + this.evaluate = evaluate;
  36 + }
  37 +
  38 + public String getCount() {
  39 + return count;
  40 + }
  41 +
  42 + public void setCount(String count) {
  43 + this.count = count;
  44 + }
  45 +
  46 +
  47 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/GrowthCountTask.java View file @ 19d0506
  1 +package com.lyms.platform.operate.web.utils;
  2 +
  3 +import com.lyms.platform.biz.service.BabyBookbuildingService;
  4 +import com.lyms.platform.common.utils.ExceptionUtils;
  5 +import com.lyms.platform.operate.web.result.BabyGrowthCountResult;
  6 +import com.lyms.platform.query.BabyModelQuery;
  7 +import org.apache.commons.collections.CollectionUtils;
  8 +
  9 +import java.util.ArrayList;
  10 +import java.util.List;
  11 +import java.util.concurrent.*;
  12 +
  13 +/**
  14 + * Created by lqy on 2016-12-21.
  15 + */
  16 +public class GrowthCountTask{
  17 +
  18 + private static ExecutorService pool = Executors.newFixedThreadPool(6);
  19 + private BabyModelQuery babyQuery;
  20 + private List<BabyGrowthCountResult> growth;
  21 + private BabyBookbuildingService babyBookbuildingService;
  22 + private String type;
  23 + public GrowthCountTask(List<BabyGrowthCountResult> growth,BabyModelQuery babyQuery,
  24 + BabyBookbuildingService babyBookbuildingService,String type)
  25 + {
  26 + this.babyQuery=babyQuery;
  27 + this.growth = growth;
  28 + this.babyBookbuildingService = babyBookbuildingService;
  29 + this.type = type;
  30 + }
  31 + public List<BabyGrowthCountResult> getResults() {
  32 + List<BabyGrowthCountResult> results = new ArrayList<>();
  33 + if (CollectionUtils.isNotEmpty(growth)) {
  34 +
  35 + int batchSize = 1;
  36 + int end = 0;
  37 + List<Future> futures = new ArrayList<>();
  38 + for (int i = 0; i < growth.size(); i += batchSize) {
  39 + end = (end + batchSize);
  40 + if (end > growth.size()) {
  41 + end = growth.size();
  42 + }
  43 +
  44 + final List<BabyGrowthCountResult> growths = growth.subList(i, end);
  45 + Callable c = new Callable()
  46 + {
  47 + @Override
  48 + public List<BabyGrowthCountResult> call() throws Exception {
  49 +
  50 + if (CollectionUtils.isNotEmpty(growths))
  51 + {
  52 + for(BabyGrowthCountResult grouwth : growths)
  53 + {
  54 + if ("身长".equals(type))
  55 + {
  56 + babyQuery.setHeightEvaluate(grouwth.getEvaluate());
  57 + }
  58 + else if ("体重".equals(type))
  59 + {
  60 + babyQuery.setWeightEvaluate(grouwth.getEvaluate());
  61 + }
  62 + int count = babyBookbuildingService.queryBabyCount(babyQuery);
  63 + grouwth.setCount(String.valueOf(count));
  64 + }
  65 + }
  66 +
  67 + return growths;
  68 + }
  69 + };
  70 +
  71 + Future f = pool.submit(c);
  72 + futures.add(f);
  73 + }
  74 + for (Future f : futures) {
  75 + try {
  76 + results.addAll((List) f.get(30, TimeUnit.SECONDS));
  77 + } catch (Exception e) {
  78 + ExceptionUtils.catchException(e, "baby growth count");
  79 + }
  80 + }
  81 + }
  82 +
  83 + return results;
  84 + }
  85 +}