Commit ab34eed0b5fdfa4e910f60815e3f1930ad7dd770

Authored by liquanyu
1 parent 18c4eef5ac

育龄服务生孩统计

Showing 5 changed files with 349 additions and 181 deletions

platform-dal/src/main/java/com/lyms/platform/query/MatDeliverQuery.java View file @ ab34eed
... ... @@ -31,29 +31,15 @@
31 31 private String hospitalId;
32 32 private boolean neStart;
33 33  
  34 + private Integer fmAge;
34 35  
  36 + private List<Integer> fmChildTimes;
  37 +
  38 +
35 39 private Date createdTimeStart;
36 40 private Date createdTimeEnd;
37 41  
38   - public Date getCreatedTimeStart() {
39   - return createdTimeStart;
40   - }
41 42  
42   - public void setCreatedTimeStart(Date createdTimeStart) {
43   - this.createdTimeStart = createdTimeStart;
44   - }
45   -
46   - public Date getCreatedTimeEnd() {
47   - return createdTimeEnd;
48   - }
49   -
50   - public void setCreatedTimeEnd(Date createdTimeEnd) {
51   - this.createdTimeEnd = createdTimeEnd;
52   - }
53   -
54   -
55   -
56   -
57 43 private boolean neEnd;
58 44 /**
59 45 * 出血量:
... ... @@ -103,6 +89,193 @@
103 89 */
104 90 private String matFollowId;
105 91  
  92 +
  93 +
  94 + @Override
  95 + public MongoQuery convertToQuery() {
  96 + MongoCondition condition = MongoCondition.newInstance();
  97 + if (null != id) {
  98 + condition = condition.and("id", id, MongoOper.IS);
  99 + }
  100 +
  101 + if (CollectionUtils.isNotEmpty(ids)) {
  102 + condition = condition.and("id", ids, MongoOper.IN);
  103 + }
  104 + if (null != pid) {
  105 + condition = condition.and("pid", pid, MongoOper.IS);
  106 + }
  107 + if (null != vcCardNo) {
  108 + condition = condition.and("vcCardNo", vcCardNo, MongoOper.IS);
  109 + }
  110 + if (null != dueDate) {
  111 + condition = condition.and("dueDate", dueDate, MongoOper.IS);
  112 + }
  113 +
  114 + if (null != fmAge) {
  115 + condition = condition.and("fmAge", fmAge, MongoOper.IS);
  116 + }
  117 +
  118 + if (hloseBloodType != null) {
  119 + /**
  120 + * 出血量:
  121 + * 顺产:1-产后2小时出血≥300ml、2-产后24小时出血<500ml、3-产后24小时出血≥500ml
  122 + * 破宫产:4-产后24小时出血<1000ml、5-产后24小时出血≥2000ml
  123 + */
  124 + switch (hloseBloodType) {
  125 + case 1:
  126 + condition = condition.and("tHloseBloodL", 300, MongoOper.GTE);
  127 + break;
  128 + case 2:
  129 + condition = condition.and("rHloseBloodL", 500, MongoOper.LT);
  130 + break;
  131 + case 3:
  132 + condition = condition.and("rHloseBloodL", 500, MongoOper.GTE);
  133 + break;
  134 + case 4:
  135 + condition = condition.and("rHloseBloodL", 1000, MongoOper.LT);
  136 + break;
  137 + case 5:
  138 + condition = condition.and("rHloseBloodL", 2000, MongoOper.GTE);
  139 + break;
  140 + }
  141 + }
  142 +
  143 + if (null != cardNo) {
  144 + condition = condition.and("cardNo", cardNo, MongoOper.IS);
  145 + }
  146 + if (null != yn) {
  147 + condition = condition.and("yn", yn, MongoOper.IS);
  148 + }
  149 + if (null != parentId) {
  150 + condition = condition.and("parentId", parentId, MongoOper.IS);
  151 + }
  152 + if (null != parentIdList) {
  153 + condition = condition.and("parentId", parentIdList, MongoOper.IN);
  154 + }
  155 + if (null != deliveryMode) {
  156 + condition = condition.and("deliveryMode", deliveryMode, MongoOper.IS);
  157 + }
  158 + if (null != hospitalId) {
  159 + condition = condition.and("hospitalId", hospitalId, MongoOper.IS);
  160 + }
  161 + if (null != contactResult) {
  162 + condition = condition.and("contactResult", contactResult, MongoOper.IS);
  163 + }
  164 + if (null != makeType) {
  165 + condition = condition.and("makeType", makeType, MongoOper.IS);
  166 + }
  167 + if (null != contactReason) {
  168 + condition = condition.and("contactReason", contactReason, MongoOper.IS);
  169 + }
  170 + if (null != fmChildTimes) {
  171 + condition = condition.and("fmChildTimes", fmChildTimes, MongoOper.IN);
  172 + }
  173 + if (null != visitStatus) {
  174 + condition = condition.and("visitStatus", visitStatus, MongoOper.IS);
  175 + }
  176 + if (null != visitResult) {
  177 + condition = condition.and("visitResult", visitResult, MongoOper.IS);
  178 + }
  179 + if (null != visitAffirm) {
  180 + condition = condition.and("visitAffirm", visitAffirm, MongoOper.IS);
  181 + }
  182 + if (null != matFollowId) {
  183 + condition = condition.and("matFollowId", matFollowId, MongoOper.IS);
  184 + }
  185 + if (CollectionUtils.isNotEmpty(fmHospitalList)) {
  186 + if(fsHospital!=null){
  187 + condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospitalList, MongoOper.IN),MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS));
  188 + }else {
  189 + condition = condition.and("fmHospital", fmHospitalList, MongoOper.IN);
  190 + }
  191 + }
  192 +
  193 + if (null != fmHospital) {
  194 + if(fsHospital!=null){
  195 + condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospital, MongoOper.IS),MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS));
  196 + }else {
  197 + condition = condition.and("fmHospital", fmHospital, MongoOper.IS);
  198 + }
  199 + }
  200 + if (null != deliveryModeQueryJson) {
  201 + condition = condition.and("deliveryMode", deliveryModeQueryJson, MongoOper.LIKE);
  202 + }
  203 + Criteria c = null;
  204 +
  205 + Boolean isAddStart = Boolean.FALSE;
  206 +
  207 + if (null != createdStart) {
  208 + if (neStart) {
  209 + c = Criteria.where("dueDate1").gt(createdStart);
  210 + } else {
  211 + c = Criteria.where("dueDate1").gte(createdStart);
  212 + }
  213 + isAddStart = Boolean.TRUE;
  214 + }
  215 + if (null != endStart) {
  216 + if (isAddStart) {
  217 + if (neEnd) {
  218 + c = c.lt(endStart);
  219 + } else {
  220 + c = c.lte(endStart);
  221 + }
  222 + } else {
  223 + if (neEnd) {
  224 + c = Criteria.where("dueDate1").lt(endStart);
  225 + } else {
  226 + c = Criteria.where("dueDate1").lte(endStart);
  227 + }
  228 + }
  229 + isAddStart = Boolean.TRUE;
  230 + }
  231 + if(null != createdTimeStart && null != createdTimeEnd){
  232 + if(null != c){
  233 + c = c.where("created").gte(createdTimeStart).lte(createdTimeEnd);
  234 + }else{
  235 + c = Criteria.where("created").gte(createdTimeStart).lte(createdTimeEnd);
  236 + }
  237 + isAddStart = Boolean.TRUE;
  238 + }
  239 + if (isAddStart) {
  240 + return new MongoCondition(c.andOperator(condition.getCriteria())).toMongoQuery();
  241 + }
  242 + return condition.toMongoQuery();
  243 + }
  244 +
  245 +
  246 + public Integer getFmAge() {
  247 + return fmAge;
  248 + }
  249 +
  250 + public void setFmAge(Integer fmAge) {
  251 + this.fmAge = fmAge;
  252 + }
  253 +
  254 + public List<Integer> getFmChildTimes() {
  255 + return fmChildTimes;
  256 + }
  257 +
  258 + public void setFmChildTimes(List<Integer> fmChildTimes) {
  259 + this.fmChildTimes = fmChildTimes;
  260 + }
  261 +
  262 + public Date getCreatedTimeStart() {
  263 + return createdTimeStart;
  264 + }
  265 +
  266 + public void setCreatedTimeStart(Date createdTimeStart) {
  267 + this.createdTimeStart = createdTimeStart;
  268 + }
  269 +
  270 + public Date getCreatedTimeEnd() {
  271 + return createdTimeEnd;
  272 + }
  273 +
  274 + public void setCreatedTimeEnd(Date createdTimeEnd) {
  275 + this.createdTimeEnd = createdTimeEnd;
  276 + }
  277 +
  278 +
106 279 public List<String> getIds() {
107 280 return ids;
108 281 }
... ... @@ -255,149 +428,6 @@
255 428 this.pid = pid;
256 429 }
257 430  
258   - @Override
259   - public MongoQuery convertToQuery() {
260   - MongoCondition condition = MongoCondition.newInstance();
261   - if (null != id) {
262   - condition = condition.and("id", id, MongoOper.IS);
263   - }
264   -
265   - if (CollectionUtils.isNotEmpty(ids)) {
266   - condition = condition.and("id", ids, MongoOper.IN);
267   - }
268   - if (null != pid) {
269   - condition = condition.and("pid", pid, MongoOper.IS);
270   - }
271   - if (null != vcCardNo) {
272   - condition = condition.and("vcCardNo", vcCardNo, MongoOper.IS);
273   - }
274   - if (null != dueDate) {
275   - condition = condition.and("dueDate", dueDate, MongoOper.IS);
276   - }
277   -
278   - if (hloseBloodType != null) {
279   - /**
280   - * 出血量:
281   - * 顺产:1-产后2小时出血≥300ml、2-产后24小时出血<500ml、3-产后24小时出血≥500ml
282   - * 破宫产:4-产后24小时出血<1000ml、5-产后24小时出血≥2000ml
283   - */
284   - switch (hloseBloodType) {
285   - case 1:
286   - condition = condition.and("tHloseBloodL", 300, MongoOper.GTE);
287   - break;
288   - case 2:
289   - condition = condition.and("rHloseBloodL", 500, MongoOper.LT);
290   - break;
291   - case 3:
292   - condition = condition.and("rHloseBloodL", 500, MongoOper.GTE);
293   - break;
294   - case 4:
295   - condition = condition.and("rHloseBloodL", 1000, MongoOper.LT);
296   - break;
297   - case 5:
298   - condition = condition.and("rHloseBloodL", 2000, MongoOper.GTE);
299   - break;
300   - }
301   - }
302   -
303   - if (null != cardNo) {
304   - condition = condition.and("cardNo", cardNo, MongoOper.IS);
305   - }
306   - if (null != yn) {
307   - condition = condition.and("yn", yn, MongoOper.IS);
308   - }
309   - if (null != parentId) {
310   - condition = condition.and("parentId", parentId, MongoOper.IS);
311   - }
312   - if (null != parentIdList) {
313   - condition = condition.and("parentId", parentIdList, MongoOper.IN);
314   - }
315   - if (null != deliveryMode) {
316   - condition = condition.and("deliveryMode", deliveryMode, MongoOper.IS);
317   - }
318   - if (null != hospitalId) {
319   - condition = condition.and("hospitalId", hospitalId, MongoOper.IS);
320   - }
321   - if (null != contactResult) {
322   - condition = condition.and("contactResult", contactResult, MongoOper.IS);
323   - }
324   - if (null != makeType) {
325   - condition = condition.and("makeType", makeType, MongoOper.IS);
326   - }
327   - if (null != contactReason) {
328   - condition = condition.and("contactReason", contactReason, MongoOper.IS);
329   - }
330   - if (null != visitStatus) {
331   - condition = condition.and("visitStatus", visitStatus, MongoOper.IS);
332   - }
333   - if (null != visitResult) {
334   - condition = condition.and("visitResult", visitResult, MongoOper.IS);
335   - }
336   - if (null != visitAffirm) {
337   - condition = condition.and("visitAffirm", visitAffirm, MongoOper.IS);
338   - }
339   - if (null != matFollowId) {
340   - condition = condition.and("matFollowId", matFollowId, MongoOper.IS);
341   - }
342   - if (CollectionUtils.isNotEmpty(fmHospitalList)) {
343   - if(fsHospital!=null){
344   - condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospitalList, MongoOper.IN),MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS));
345   - }else {
346   - condition = condition.and("fmHospital", fmHospitalList, MongoOper.IN);
347   - }
348   - }
349   -
350   - if (null != fmHospital) {
351   - if(fsHospital!=null){
352   - condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospital, MongoOper.IS),MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS));
353   - }else {
354   - condition = condition.and("fmHospital", fmHospital, MongoOper.IS);
355   - }
356   - }
357   - if (null != deliveryModeQueryJson) {
358   - condition = condition.and("deliveryMode", deliveryModeQueryJson, MongoOper.LIKE);
359   - }
360   - Criteria c = null;
361   -
362   - Boolean isAddStart = Boolean.FALSE;
363   -
364   - if (null != createdStart) {
365   - if (neStart) {
366   - c = Criteria.where("dueDate1").gt(createdStart);
367   - } else {
368   - c = Criteria.where("dueDate1").gte(createdStart);
369   - }
370   - isAddStart = Boolean.TRUE;
371   - }
372   - if (null != endStart) {
373   - if (isAddStart) {
374   - if (neEnd) {
375   - c = c.lt(endStart);
376   - } else {
377   - c = c.lte(endStart);
378   - }
379   - } else {
380   - if (neEnd) {
381   - c = Criteria.where("dueDate1").lt(endStart);
382   - } else {
383   - c = Criteria.where("dueDate1").lte(endStart);
384   - }
385   - }
386   - isAddStart = Boolean.TRUE;
387   - }
388   - if(null != createdTimeStart && null != createdTimeEnd){
389   - if(null != c){
390   - c = c.where("created").gte(createdTimeStart).lte(createdTimeEnd);
391   - }else{
392   - c = Criteria.where("created").gte(createdTimeStart).lte(createdTimeEnd);
393   - }
394   - isAddStart = Boolean.TRUE;
395   - }
396   - if (isAddStart) {
397   - return new MongoCondition(c.andOperator(condition.getCriteria())).toMongoQuery();
398   - }
399   - return condition.toMongoQuery();
400   - }
401 431  
402 432 public String getCardNo() {
403 433 return cardNo;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java View file @ ab34eed
... ... @@ -162,25 +162,6 @@
162 162 // System.out.println(tzzs);
163 163 // System.out.println(df.format(tzzs));
164 164  
165   -
166   - double kulStart = 1611;
167   - int k1 = ((int)kulStart/100)*100;
168   - double k2 = kulStart - k1;
169   - if (k2 > 50)
170   - {
171   - k1+=100;
172   - }
173   -
174   - if (k1 < 1500)
175   - {
176   - k1 = 1500;
177   - }
178   - else if (k1 > 2800)
179   - {
180   - k1 = 2800;
181   - }
182   - System.out.print(k1);
183   -
184 165 }
185 166  
186 167 public static void configData(BasicConfig bs, List<BasicConfig> basicConfigList,Map<String, List<BasicConfig>> slaveBasicConfigMap) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatDeliverController.java View file @ ab34eed
... ... @@ -5,6 +5,7 @@
5 5 import com.lyms.platform.common.base.LoginContext;
6 6 import com.lyms.platform.common.constants.ErrorCodeConstants;
7 7 import com.lyms.platform.common.result.BaseListResponse;
  8 +import com.lyms.platform.common.result.BaseObjectResponse;
8 9 import com.lyms.platform.common.result.BaseResponse;
9 10 import com.lyms.platform.common.utils.BeanUtils;
10 11 import com.lyms.platform.common.utils.ExcelUtil;
... ... @@ -354,6 +355,23 @@
354 355 }
355 356 }
356 357  
357   -
  358 + /**
  359 + * 育龄服务生孩统计
  360 + * @param request
  361 + * @param birth
  362 + * @return
  363 + */
  364 + @TokenRequired
  365 + @ResponseBody
  366 + @RequestMapping(value = "getChildbearAgeCount", method = RequestMethod.GET)
  367 + public BaseObjectResponse getChildbearAgeCount(HttpServletRequest request,
  368 + @RequestParam String birth,
  369 + @RequestParam String hospitalId,
  370 + @RequestParam String proviceId,
  371 + @RequestParam String cityId,
  372 + @RequestParam String areaId) {
  373 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  374 + return matDeliverFacade.getChildbearAgeCount(birth,loginState.getId(),hospitalId,proviceId,cityId,areaId);
  375 + }
358 376 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java View file @ ab34eed
... ... @@ -15,6 +15,7 @@
15 15 import com.lyms.platform.operate.web.service.ITrackDownService;
16 16 import com.lyms.platform.operate.web.utils.CommonsHelper;
17 17 import com.lyms.platform.operate.web.utils.UnitConstants;
  18 +import com.lyms.platform.operate.web.worker.ChildbearAgeWorker;
18 19 import com.lyms.platform.operate.web.worker.MaterDeliverWorker;
19 20 import com.lyms.platform.permission.model.Organization;
20 21 import com.lyms.platform.permission.model.OrganizationQuery;
... ... @@ -125,6 +126,9 @@
125 126  
126 127 private static Map<String, List> babyMap = new HashMap<>();
127 128  
  129 + @Autowired
  130 + private AreaCountFacade areaCountFacade;
  131 +
128 132 static {
129 133 ONE_ENUMS.put(0, "长");
130 134 ONE_ENUMS.put(1, "次");
... ... @@ -2385,5 +2389,56 @@
2385 2389 }
2386 2390  
2387 2391  
  2392 + public BaseObjectResponse getChildbearAgeCount(String birth, Integer userId,String hospitalId,
  2393 + String proviceId,String cityId,String areaId) {
  2394 + List<String> hospitalIds = new ArrayList<>();
  2395 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(hospitalId)) {
  2396 + hospitalIds.add(hospitalId);
  2397 + } else {
  2398 + //获取用户拥有的权限医院和条件筛选的医院交集
  2399 + hospitalIds = areaCountFacade.getCurrentUserHospPermissions(userId, proviceId,
  2400 + cityId, areaId);
  2401 + }
  2402 +
  2403 + List<Map<String,Integer>> list = new ArrayList<>();
  2404 +
  2405 + //String hospitalId = autoMatchFacade.getHospitalId(userId);
  2406 + List<Integer> ages = new ArrayList<>();
  2407 + for (int i = 15; i < 16; i ++)
  2408 + {
  2409 + ages.add(i);
  2410 + }
  2411 +
  2412 + int batchSize = 5;
  2413 + int end = 0;
  2414 + List<Future> futures = new ArrayList<>();
  2415 + for (int i = 0; i < ages.size(); i += batchSize) {
  2416 + end = (end + batchSize);
  2417 + if (end > ages.size()) {
  2418 + end = ages.size();
  2419 + }
  2420 + List<Integer> alist = ages.subList(i, end);
  2421 + Callable c = new ChildbearAgeWorker(birth,
  2422 + alist,hospitalIds,matDeliverService);
  2423 + Future f = commonThreadPool.submit(c);
  2424 + futures.add(f);
  2425 + }
  2426 +
  2427 + if (CollectionUtils.isNotEmpty(futures)) {
  2428 + for (Future f : futures) {
  2429 + try {
  2430 + list.addAll((List<Map<String,Integer>>) f.get());
  2431 + } catch (Exception e) {
  2432 + ExceptionUtils.catchException(e, "getChildbearAgeCount list error.");
  2433 + }
  2434 + }
  2435 + }
  2436 +
  2437 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  2438 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  2439 + objectResponse.setErrormsg("成功");
  2440 + objectResponse.setData(list);
  2441 + return objectResponse;
  2442 + }
2388 2443 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ChildbearAgeWorker.java View file @ ab34eed
  1 +package com.lyms.platform.operate.web.worker;
  2 +
  3 +
  4 +import com.lyms.platform.biz.service.MatDeliverService;
  5 +import com.lyms.platform.common.enums.YnEnums;
  6 +import com.lyms.platform.common.utils.DateUtil;
  7 +import com.lyms.platform.common.utils.StringUtils;
  8 +import com.lyms.platform.pojo.MaternalDeliverModel;
  9 +import com.lyms.platform.query.MatDeliverQuery;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.HashMap;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +import java.util.concurrent.Callable;
  16 +
  17 +/**
  18 + * Created by Administrator on 2018-08-14.
  19 + */
  20 +public class ChildbearAgeWorker implements Callable<List<Map<String,Integer>>> {
  21 +
  22 + private String birth;
  23 + private List<Integer> ages;
  24 +
  25 + private List<String> hospitalIds;
  26 + private MatDeliverService matDeliverService;
  27 +
  28 + public ChildbearAgeWorker(String birth,List<Integer> ages,
  29 + List<String> hospitalIds,
  30 + MatDeliverService matDeliverService)
  31 + {
  32 + this.birth = birth;
  33 + this.ages = ages;
  34 + this.hospitalIds = hospitalIds;
  35 + this.matDeliverService = matDeliverService;
  36 + }
  37 +
  38 + @Override
  39 + public List<Map<String,Integer>> call() throws Exception {
  40 +
  41 + List<Integer> fmChildTimes = new ArrayList<>();
  42 +
  43 + List<Map<String,Integer>> list = new ArrayList<>();
  44 +
  45 + for (Integer fmAge : ages)
  46 + {
  47 + Map<String,Integer> map = new HashMap<>();
  48 + map.put("age", fmAge);
  49 + MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
  50 + matDeliverQuery.setYn(YnEnums.YES.getId());
  51 + matDeliverQuery.setFmAge(fmAge);
  52 + matDeliverQuery.setFmHospitalList(hospitalIds);
  53 +
  54 + if (StringUtils.isNotEmpty(birth))
  55 + {
  56 + matDeliverQuery.setCreatedStart(DateUtil.getSNDate(birth)[0]);
  57 + matDeliverQuery.setEndStart(DateUtil.getSNDate(birth)[1]);
  58 + }
  59 +
  60 +
  61 + fmChildTimes.add(1);
  62 + matDeliverQuery.setFmChildTimes(fmChildTimes);
  63 + int oneCount = matDeliverService.count(matDeliverQuery);
  64 + map.put("oneChild", oneCount);
  65 + fmChildTimes.clear();
  66 +
  67 +
  68 + fmChildTimes.add(2);
  69 + matDeliverQuery.setFmChildTimes(fmChildTimes);
  70 + int twoCount = matDeliverService.count(matDeliverQuery);
  71 + fmChildTimes.clear();
  72 + map.put("twoChild", twoCount);
  73 +
  74 + fmChildTimes.add(3);
  75 + matDeliverQuery.setFmChildTimes(fmChildTimes);
  76 + int threeCount = matDeliverService.count(matDeliverQuery);
  77 + fmChildTimes.clear();
  78 + map.put("threeChild",threeCount);
  79 +
  80 + list.add(map);
  81 + }
  82 + return list;
  83 + }
  84 +}