Commit b065ab13056ee1fc8b8ab9b07fe25bf2e7134d34

Authored by dongqin
1 parent 50e0fb0af7

新增增值服务统计模块

Showing 7 changed files with 629 additions and 2 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/PatientServiceMapper.java View file @ b065ab1
... ... @@ -2,6 +2,8 @@
2 2  
3 3 import com.lyms.platform.permission.model.PatientService;
4 4 import com.lyms.platform.permission.model.PatientServiceQuery;
  5 +import com.lyms.platform.permission.model.ServiceListQuery;
  6 +import org.apache.ibatis.annotations.Param;
5 7  
6 8 import java.util.List;
7 9 import java.util.Map;
... ... @@ -30,5 +32,37 @@
30 32  
31 33 int selectOnlyBzServiceCount(PatientServiceQuery query);
32 34  
  35 + /**
  36 + * 所有增值服务list
  37 + *
  38 + * @param query
  39 + * @return
  40 + */
  41 + Map<String, Object> getServiceList(@Param("query") ServiceListQuery query);
  42 +
  43 +
  44 + /**
  45 + * 根据状态统计数量
  46 + *
  47 + * @param param
  48 + * @return
  49 + */
  50 + int countStatusInfo(@Param("param") ServiceListQuery param);
  51 +
  52 + /**
  53 + * 所有增值服务详情list的总数
  54 + *
  55 + * @param param
  56 + * @return
  57 + */
  58 + int getServeDetailListCount(@Param("param") ServiceListQuery param);
  59 +
  60 + /**
  61 + * 所有增值服务详情list
  62 + *
  63 + * @param param
  64 + * @return
  65 + */
  66 + List<Map> getServeDetailList(@Param("param") ServiceListQuery param);
33 67 }
platform-biz-service/src/main/java/com/lyms/platform/permission/model/ServiceListQuery.java View file @ b065ab1
  1 +package com.lyms.platform.permission.model;
  2 +
  3 +import com.lyms.platform.common.dao.BaseQuery;
  4 +
  5 +import java.util.Date;
  6 +import java.util.List;
  7 +
  8 +/**
  9 + *
  10 + * @Author dongqin
  11 + * @Description 增值服务list请求参数类
  12 + * @Date 15:49 2019/5/15
  13 + **/
  14 +
  15 +public class ServiceListQuery extends BaseQuery {
  16 +
  17 + private Date startTime;
  18 +
  19 + private String provinceId;
  20 +
  21 + private String cityId;
  22 +
  23 + private String areaId;
  24 +
  25 + private String hospitalId;
  26 +
  27 + private Integer userId;
  28 +
  29 + private List<String> hospitalIds;
  30 +
  31 + /**
  32 + * 针对详情列表:-1 全部 1-开通、2-退订、3-过期、4-暂停
  33 + */
  34 + private String serStatus;
  35 +
  36 + public String getSerStatus() {
  37 + return serStatus;
  38 + }
  39 +
  40 + public void setSerStatus(String serStatus) {
  41 + this.serStatus = serStatus;
  42 + }
  43 +
  44 + public List<String> getHospitalIds() {
  45 + return hospitalIds;
  46 + }
  47 +
  48 + public void setHospitalIds(List<String> hospitalIds) {
  49 + this.hospitalIds = hospitalIds;
  50 + }
  51 +
  52 + public Integer getUserId() {
  53 + return userId;
  54 + }
  55 +
  56 + public void setUserId(Integer userId) {
  57 + this.userId = userId;
  58 + }
  59 +
  60 + public Date getStartTime() {
  61 + return startTime;
  62 + }
  63 +
  64 + public void setStartTime(Date startTime) {
  65 + this.startTime = startTime;
  66 + }
  67 +
  68 + public String getProvinceId() {
  69 + return provinceId;
  70 + }
  71 +
  72 + public void setProvinceId(String provinceId) {
  73 + this.provinceId = provinceId;
  74 + }
  75 +
  76 + public String getCityId() {
  77 + return cityId;
  78 + }
  79 +
  80 + public void setCityId(String cityId) {
  81 + this.cityId = cityId;
  82 + }
  83 +
  84 + public String getAreaId() {
  85 + return areaId;
  86 + }
  87 +
  88 + public void setAreaId(String areaId) {
  89 + this.areaId = areaId;
  90 + }
  91 +
  92 + public String getHospitalId() {
  93 + return hospitalId;
  94 + }
  95 +
  96 + public void setHospitalId(String hospitalId) {
  97 + this.hospitalId = hospitalId;
  98 + }
  99 +}
platform-biz-service/src/main/java/com/lyms/platform/permission/service/PatientServiceService.java View file @ b065ab1
... ... @@ -2,6 +2,7 @@
2 2  
3 3 import com.lyms.platform.permission.model.PatientService;
4 4 import com.lyms.platform.permission.model.PatientServiceQuery;
  5 +import com.lyms.platform.permission.model.ServiceListQuery;
5 6  
6 7 import java.util.List;
7 8 import java.util.Map;
... ... @@ -21,5 +22,11 @@
21 22  
22 23  
23 24 List<Map> selectOnlyBzService(PatientServiceQuery query);
  25 +
  26 + Map<String, Object> getServiceList(ServiceListQuery param);
  27 +
  28 + int countStatusInfo(ServiceListQuery param);
  29 +
  30 + List<Map> getServeDetailList(ServiceListQuery param);
24 31 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/PatientServiceServiceImpl.java View file @ b065ab1
... ... @@ -3,6 +3,7 @@
3 3 import com.lyms.platform.permission.dao.master.PatientServiceMapper;
4 4 import com.lyms.platform.permission.model.PatientService;
5 5 import com.lyms.platform.permission.model.PatientServiceQuery;
  6 +import com.lyms.platform.permission.model.ServiceListQuery;
6 7 import com.lyms.platform.permission.service.PatientServiceService;
7 8 import org.springframework.beans.factory.annotation.Autowired;
8 9 import org.springframework.stereotype.Service;
... ... @@ -55,6 +56,24 @@
55 56 query.mysqlBuild(patientServiceMapper.selectOnlyBzServiceCount(query));
56 57 }
57 58 return patientServiceMapper.selectOnlyBzService(query);
  59 + }
  60 +
  61 + @Override
  62 + public Map<String, Object> getServiceList(ServiceListQuery query) {
  63 + return patientServiceMapper.getServiceList(query);
  64 + }
  65 +
  66 + @Override
  67 + public int countStatusInfo(ServiceListQuery param) {
  68 + return patientServiceMapper.countStatusInfo(param);
  69 + }
  70 +
  71 + @Override
  72 + public List<Map> getServeDetailList(ServiceListQuery param) {
  73 + if (param.getNeed() != null) {
  74 + param.mysqlBuild(patientServiceMapper.getServeDetailListCount(param));
  75 + }
  76 + return patientServiceMapper.getServeDetailList(param);
58 77 }
59 78 }
platform-biz-service/src/main/resources/mainOrm/master/PatientService.xml View file @ b065ab1
... ... @@ -393,6 +393,201 @@
393 393 select count(1) from patient_service
394 394 <include refid="PatientServiceCondition"/>
395 395 </select>
  396 + <select id="getServiceList" parameterType="com.lyms.platform.permission.model.ServiceListQuery" resultType="java.util.Map" fetchSize="10000">
  397 +
  398 + SELECT
  399 + o.name as "name",
  400 + o.province_id as "provinceId",
  401 + o.city_id as "cityId",
  402 + o.area_id as "areaId",
  403 + o.id as "hospitalId",
  404 + (SELECT Count(1)
  405 + FROM patient_service ps
  406 + join organization o ON o.id = ps.hospital_id
  407 + WHERE ps.hospital_id = #{query.hospitalId}
  408 + AND ps.ser_status = 1
  409 + <if test="query.startTime != null ">
  410 + AND ps.create_date &lt;= #{query.startTime}
  411 + </if>
  412 + <if test="query.provinceId != null">
  413 + and o.province_id = #{query.provinceId}
  414 + </if>
  415 + <if test="query.cityId != null">
  416 + and o.city_id = #{query.cityId}
  417 + </if>
  418 + <if test="query.areaId != null">
  419 + and o.area_id = #{query.areaId}
  420 + </if>
  421 + ) as "open",
  422 + (SELECT Count(1)
  423 + FROM patient_service ps
  424 + join organization o ON o.id = ps.hospital_id
  425 + WHERE ps.hospital_id = #{query.hospitalId}
  426 + AND ps.ser_status = 2
  427 + <if test="query.startTime != null ">
  428 + AND ps.create_date &lt;= #{query.startTime}
  429 + </if>
  430 + <if test="query.provinceId != null">
  431 + and o.province_id = #{query.provinceId}
  432 + </if>
  433 + <if test="query.cityId != null">
  434 + and o.city_id = #{query.cityId}
  435 + </if>
  436 + <if test="query.areaId != null">
  437 + and o.area_id = #{query.areaId}
  438 + </if>
  439 + ) as "unsubscribe",
  440 + (SELECT Count(1)
  441 + FROM patient_service ps
  442 + join organization o ON o.id = ps.hospital_id
  443 + WHERE ps.hospital_id = #{query.hospitalId}
  444 + AND ps.ser_status = 3
  445 + <if test="query.startTime != null ">
  446 + AND ps.create_date &lt;= #{query.startTime}
  447 + </if>
  448 + <if test="query.provinceId != null">
  449 + and o.province_id = #{query.provinceId}
  450 + </if>
  451 + <if test="query.cityId != null">
  452 + and o.city_id = #{query.cityId}
  453 + </if>
  454 + <if test="query.areaId != null">
  455 + and o.area_id = #{query.areaId}
  456 + </if>
  457 + ) as "expire",
  458 + (SELECT Count(1)
  459 + FROM patient_service ps
  460 + join organization o ON o.id = ps.hospital_id
  461 + WHERE ps.hospital_id = #{query.hospitalId}
  462 + AND ps.ser_status = 4
  463 + <if test="query.startTime != null ">
  464 + AND ps.create_date &lt;= #{query.startTime}
  465 + </if>
  466 + <if test="query.provinceId != null">
  467 + and o.province_id = #{query.provinceId}
  468 + </if>
  469 + <if test="query.cityId != null">
  470 + and o.city_id = #{query.cityId}
  471 + </if>
  472 + <if test="query.areaId != null">
  473 + and o.area_id = #{query.areaId}
  474 + </if>
  475 + ) as "suspend"
  476 + FROM patient_service ps
  477 + JOIN organization o
  478 + ON o.id = ps.hospital_id
  479 + WHERE ps.hospital_id = #{query.hospitalId}
  480 + <if test="query.startTime != null ">
  481 + AND ps.create_date &lt;= #{query.startTime}
  482 + </if>
  483 + <if test="query.provinceId != null">
  484 + and o.province_id = #{query.provinceId}
  485 + </if>
  486 + <if test="query.cityId != null">
  487 + and o.city_id = #{query.cityId}
  488 + </if>
  489 + <if test="query.areaId != null">
  490 + and o.area_id = #{query.areaId}
  491 + </if>
  492 + GROUP BY o.name,o.province_id,
  493 + o.city_id,
  494 + o.area_id
  495 +
  496 + </select>
  497 + <select id="countStatusInfo" parameterType="com.lyms.platform.permission.model.ServiceListQuery" resultType="int">
  498 + select count(1)
  499 + from patient_service ps
  500 + join organization o on o.id = ps.hospital_id
  501 + where 1=1
  502 + <if test="param.startTime != null">
  503 + and ps.create_date &lt;= #{param.startTime}
  504 + </if>
  505 + <if test="param.provinceId != null">
  506 + and o.province_id = #{param.provinceId}
  507 + </if>
  508 + <if test="param.cityId != null">
  509 + and o.city_id = #{param.cityId}
  510 + </if>
  511 + <if test="param.areaId != null">
  512 + and o.area_id = #{param.areaId}
  513 + </if>
  514 + <if test="param.hospitalIds.size() > 0">
  515 + and ps.hospital_id in
  516 + <foreach collection="param.hospitalIds" item="item" open="(" close=")" separator=",">
  517 + #{item}
  518 + </foreach>
  519 + </if>
  520 + and ps.ser_status = #{param.serStatus}
  521 + </select>
  522 + <select id="getServeDetailList" parameterType="com.lyms.platform.permission.model.ServiceListQuery" resultType="java.util.Map">
  523 + SELECT
  524 + ps.create_date as "createDate",
  525 + ps.parentid as "parentId",
  526 + ps.per_type as "perType", -- 1-孕妇、2-儿童
  527 + '', -- 孕周
  528 + IFNULL(ps.serviceWeek, 24) as "serviceWeek",
  529 + ps.ser_type as "serType",
  530 + ps.ser_doct as "serDoct",
  531 + CASE ps.ser_status
  532 + WHEN 1 THEN
  533 + '开通中'
  534 + WHEN 2 THEN
  535 + '退订'
  536 + WHEN 3 THEN
  537 + '过期'
  538 + WHEN 4 THEN
  539 + '暂停'
  540 + END AS "serStatus"
  541 + FROM
  542 + patient_service ps
  543 + JOIN organization o ON o.id = ps.hospital_id
  544 + WHERE 1=1
  545 + <if test="param.hospitalId != null">
  546 + and o.id = #{param.hospitalId}
  547 + </if>
  548 + <if test="param.provinceId != null">
  549 + AND o.province_id = #{param.provinceId}
  550 + </if>
  551 + <if test="param.cityId != null">
  552 + AND o.city_id = #{param.cityId}
  553 + </if>
  554 + <if test="param.areaId != null">
  555 + AND o.area_id = #{param.areaId}
  556 + </if>
  557 + <if test="param.serStatus != null">
  558 + AND ps.ser_status = #{param.serStatus}
  559 + </if>
  560 + <if test="param.sort != null and param.sort != '' ">
  561 + order by "createDate" ${param.sort}
  562 + <if test="param.need != null">
  563 + limit #{param.offset, jdbcType=INTEGER} , #{param.limit, jdbcType=INTEGER}
  564 + </if>
  565 + </if>
  566 + </select>
  567 + <select id="getServeDetailListCount" parameterType="com.lyms.platform.permission.model.ServiceListQuery" resultType="int">
  568 + SELECT
  569 + count(1)
  570 + FROM
  571 + patient_service ps
  572 + JOIN organization o ON o.id = ps.hospital_id
  573 + WHERE 1=1
  574 + <if test="param.hospitalId != null">
  575 + and o.id = #{param.hospitalId}
  576 + </if>
  577 + <if test="param.provinceId != null">
  578 + AND o.province_id = #{param.provinceId}
  579 + </if>
  580 + <if test="param.cityId != null">
  581 + AND o.city_id = #{param.cityId}
  582 + </if>
  583 + <if test="param.areaId != null">
  584 + AND o.area_id = #{param.areaId}
  585 + </if>
  586 + <if test="param.serStatus != null">
  587 + AND ps.ser_status = #{param.serStatus}
  588 + </if>
  589 + </select>
  590 +
396 591  
397 592 </mapper>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java View file @ b065ab1
... ... @@ -5,13 +5,14 @@
5 5 import com.lyms.platform.common.base.LoginContext;
6 6 import com.lyms.platform.common.result.BaseResponse;
7 7 import com.lyms.platform.operate.web.facade.AreaCountFacade;
8   -
  8 +import com.lyms.platform.permission.model.ServiceListQuery;
9 9 import org.springframework.beans.factory.annotation.Autowired;
10 10 import org.springframework.stereotype.Controller;
11 11 import org.springframework.web.bind.annotation.*;
12 12  
13 13 import javax.servlet.http.HttpServletRequest;
14 14 import javax.servlet.http.HttpServletResponse;
  15 +import javax.validation.Valid;
15 16  
16 17 /**
17 18 *
... ... @@ -184,6 +185,33 @@
184 185 cityId, areaId, loginState.getId(),response, nodeName);
185 186 }
186 187  
  188 + /**
  189 + * 增值服务统计list
  190 + *
  191 + * @param query
  192 + */
  193 + @RequestMapping(value = "/getService/list",method = RequestMethod.POST)
  194 + @ResponseBody
  195 + @TokenRequired
  196 + public BaseResponse getServiceList(@RequestBody @Valid ServiceListQuery query, HttpServletRequest request){
  197 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  198 + query.setUserId(loginState.getId());
  199 + return areaCountFacade.getServiceList(query);
  200 + }
  201 +
  202 + /**
  203 + * 增值服务统计detailList
  204 + *
  205 + * @param param
  206 + */
  207 + @RequestMapping(value = "/getServiceDetail/list",method = RequestMethod.POST)
  208 + @ResponseBody
  209 + @TokenRequired
  210 + public BaseResponse getServiceDetailList(@RequestBody @Valid ServiceListQuery param, HttpServletRequest request){
  211 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  212 + param.setUserId(loginState.getId());
  213 + return areaCountFacade.getServiceDetailList(param);
  214 + }
187 215  
188 216 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java View file @ b065ab1
... ... @@ -10,7 +10,6 @@
10 10 import com.lyms.platform.common.result.BaseResponse;
11 11 import com.lyms.platform.common.result.RespBuilder;
12 12 import com.lyms.platform.common.utils.*;
13   -import com.lyms.platform.common.utils.StringUtils;
14 13 import com.lyms.platform.operate.web.utils.CommonsHelper;
15 14 import com.lyms.platform.operate.web.utils.FunvCommonUtil;
16 15 import com.lyms.platform.operate.web.utils.MongoUtil;
17 16  
... ... @@ -18,8 +17,10 @@
18 17 import com.lyms.platform.operate.web.worker.CheckPointCountWorker;
19 18 import com.lyms.platform.permission.model.Organization;
20 19 import com.lyms.platform.permission.model.OrganizationQuery;
  20 +import com.lyms.platform.permission.model.ServiceListQuery;
21 21 import com.lyms.platform.permission.model.Users;
22 22 import com.lyms.platform.permission.service.OrganizationService;
  23 +import com.lyms.platform.permission.service.PatientServiceService;
23 24 import com.lyms.platform.permission.service.UsersService;
24 25 import com.lyms.platform.pojo.AntExRecordModel;
25 26 import com.lyms.platform.pojo.BasicConfig;
... ... @@ -39,6 +40,8 @@
39 40 import org.springframework.stereotype.Component;
40 41  
41 42 import javax.servlet.http.HttpServletResponse;
  43 +import java.time.*;
  44 +import java.time.temporal.TemporalAdjusters;
42 45 import java.util.*;
43 46 import java.util.concurrent.Callable;
44 47 import java.util.concurrent.ExecutionException;
45 48  
... ... @@ -86,7 +89,12 @@
86 89 @Autowired
87 90 private MongoUtil mongoUtil;
88 91  
  92 + @Autowired
  93 + private PatientServiceService patientServiceService;
89 94  
  95 + @Autowired
  96 + private BabyBookbuildingService babyBookbuildingService;
  97 +
90 98 /**
91 99 * 获取当前用户拥有的医院权限列表并和查询条件取交集
92 100 *
... ... @@ -1018,6 +1026,243 @@
1018 1026  
1019 1027 public BaseResponse getAreaName(String id) {
1020 1028 return RespBuilder.buildSuccess(mongoUtil.findName(id));
  1029 + }
  1030 +
  1031 + /**
  1032 + * 增值服务统计
  1033 + *
  1034 + * @param param
  1035 + * @return
  1036 + */
  1037 + public BaseResponse getServiceList(ServiceListQuery param) {
  1038 + BaseResponse baseResponse = new BaseResponse();
  1039 + if (param.getStartTime() == null){
  1040 + Date startDate = getStartDate();
  1041 + param.setStartTime(startDate);
  1042 + }
  1043 + long startTime = System.currentTimeMillis();
  1044 +
  1045 + HashMap<String, Object> objectHashMap = new HashMap<>(16);
  1046 + LinkedList<Object> linkedList = new LinkedList<>();
  1047 +
  1048 + String hospitalId = param.getHospitalId();
  1049 + String provinceId = param.getProvinceId();
  1050 + String cityId = param.getCityId();
  1051 + String areaId = param.getAreaId();
  1052 + List<String> hospitalIds = new ArrayList<>();
  1053 + if (StringUtils.isEmpty(hospitalId)){
  1054 + /* hospitalIds = getCurrentUserHospPermissions(param.getUserId(),
  1055 + StringUtils.isEmpty(provinceId) ? null : provinceId, StringUtils.isEmpty(cityId) ? null : cityId, StringUtils.isEmpty(areaId) ? null : areaId);*/
  1056 + hospitalIds = getCurrentUserHospPermissions2(param.getUserId(),
  1057 + StringUtils.isEmpty(provinceId) ? null : provinceId, StringUtils.isEmpty(cityId) ? null : cityId, StringUtils.isEmpty(areaId) ? null : areaId);
  1058 + } else {
  1059 + hospitalIds.add(hospitalId);
  1060 + }
  1061 + long timeMillis = System.currentTimeMillis();
  1062 + System.err.println(startTime - timeMillis);
  1063 + for (String hospital: hospitalIds){
  1064 + System.err.print(hospital + ", ");
  1065 + param.setHospitalId(hospital);
  1066 + Map<String, Object> map = patientServiceService.getServiceList(param);
  1067 + System.err.println(System.currentTimeMillis() - timeMillis);
  1068 + if (map == null){
  1069 + continue;
  1070 + }
  1071 + HashMap<String, Object> hashMap = new HashMap<>(16);
  1072 + String id = map.get("provinceId").toString();
  1073 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id);
  1074 + hashMap.put("provinceName", basicConfig.getName());
  1075 +
  1076 + id = map.get("cityId").toString();
  1077 + basicConfig = basicConfigService.getOneBasicConfigById(id);
  1078 + hashMap.put("cityName", basicConfig.getName());
  1079 +
  1080 + id = map.get("areaId").toString();
  1081 + basicConfig = basicConfigService.getOneBasicConfigById(id);
  1082 + hashMap.put("areaName", basicConfig.getName());
  1083 + hashMap.put("total", Integer.parseInt(map.get("open").toString())
  1084 + + Integer.parseInt(map.get("unsubscribe").toString())
  1085 + + Integer.parseInt(map.get("expire").toString())
  1086 + + Integer.parseInt(map.get("suspend").toString()));
  1087 +
  1088 + hashMap.putAll(map);
  1089 +
  1090 +
  1091 + linkedList.add(hashMap);
  1092 + }
  1093 + long ttt = System.currentTimeMillis();
  1094 + System.err.println(timeMillis - ttt);
  1095 + ArrayList<Object> statusNameList = new ArrayList<>();
  1096 + statusNameList.add("开通");
  1097 + statusNameList.add("退订");
  1098 + statusNameList.add("过期");
  1099 + statusNameList.add("暂停");
  1100 +
  1101 + param.setHospitalIds(hospitalIds);
  1102 + ArrayList<Object> statusValList = new ArrayList<>();
  1103 + param.setSerStatus("1");
  1104 + int number = patientServiceService.countStatusInfo(param);
  1105 + statusValList.add(number);
  1106 + param.setSerStatus("2");
  1107 + number = patientServiceService.countStatusInfo(param);
  1108 + statusValList.add(number);
  1109 + param.setSerStatus("3");
  1110 + number = patientServiceService.countStatusInfo(param);
  1111 + statusValList.add(number);
  1112 + param.setSerStatus("4");
  1113 + number = patientServiceService.countStatusInfo(param);
  1114 + statusValList.add(number);
  1115 +
  1116 + objectHashMap.put("statusNameList",statusNameList);
  1117 + objectHashMap.put("statusValList", statusValList);
  1118 + objectHashMap.put("serviceList", linkedList);
  1119 +
  1120 + baseResponse.setObject(objectHashMap);
  1121 +
  1122 + return baseResponse;
  1123 + }
  1124 +
  1125 + /**
  1126 + * 本年的起始时间
  1127 + *
  1128 + * @return
  1129 + */
  1130 + private Date getStartDate() {
  1131 + LocalDate with = LocalDate.now().plusYears(0).with(TemporalAdjusters.firstDayOfYear());
  1132 + ZoneId zoneId = ZoneId.systemDefault();
  1133 + Instant instant = with.atStartOfDay().atZone(zoneId).toInstant();
  1134 + return Date.from(instant);
  1135 + }
  1136 +
  1137 + /**
  1138 + * 增值服务详情list
  1139 + *
  1140 + * @param param
  1141 + * @return
  1142 + */
  1143 + public BaseResponse getServiceDetailList(ServiceListQuery param) {
  1144 + param.setNeed("Y");
  1145 + param.setSort("desc");
  1146 + BaseResponse response = new BaseResponse();
  1147 + if (param.getStartTime() == null){
  1148 + Date startDate = getStartDate();
  1149 + param.setStartTime(startDate);
  1150 + }
  1151 + List<Map> mapList = patientServiceService.getServeDetailList(param);
  1152 + for (Map map : mapList){
  1153 + String parentId = map.get("parentId").toString();
  1154 + String perType = map.get("perType").toString();
  1155 + String serType = map.get("serType").toString();
  1156 + //String serDoct = map.get("serDoct").toString();
  1157 + Date createDate = (Date) map.get("createDate");
  1158 + String userName;
  1159 + if ("1".equals(perType)){
  1160 + // 孕妇
  1161 + Patients patient = patientsService.findOnePatientById(parentId);
  1162 + userName = patient.getUsername();
  1163 + Date lastMenses = patient.getLastMenses();
  1164 + int differentDays = differentDays(lastMenses, createDate);
  1165 + int week = differentDays / 7;
  1166 + map.put("openYumSize", week);
  1167 +
  1168 + }else {
  1169 + // 儿童 不显示孕周数和服务周期
  1170 + userName = babyBookbuildingService.queryBabyBuildById(parentId).getName();
  1171 + map.put("opnYumSize", "");
  1172 + map.put("serviceWeek", "");
  1173 + }
  1174 + map.put("patientName", userName);
  1175 + String serTypeName = getSerTypeName(serType);
  1176 + map.put("serTypeName", serTypeName);
  1177 + // String doctorName = usersService.getUsers(Integer.parseInt(serDoct)).getName();
  1178 + map.put("doctorName", "");
  1179 +
  1180 + map.remove("parentId");
  1181 + map.remove("perType");
  1182 + map.remove("serType");
  1183 + map.remove("serDoct");
  1184 + }
  1185 + response.setObject(mapList);
  1186 + return response;
  1187 + }
  1188 +
  1189 + private String getSerTypeName(String serType){
  1190 + String str = "";
  1191 + switch (serType){
  1192 + case "1" :
  1193 + str = "孕期精准医疗";
  1194 + break;
  1195 + case "2" :
  1196 + str = "体重管理";
  1197 + break;
  1198 + case "3" :
  1199 + str = "血糖管理";
  1200 + break;
  1201 + case "4" :
  1202 + str = "血压管理";
  1203 + break;
  1204 + case "5" :
  1205 + str = "专家咨询";
  1206 + break;
  1207 + case "6" :
  1208 + str = "标准服务";
  1209 + break;
  1210 + case "7" :
  1211 + str = "体温管理";
  1212 + break;
  1213 + case "8" :
  1214 + str = "";
  1215 + break;
  1216 + case "9" :
  1217 + str = "";
  1218 + break;
  1219 + case "10" :
  1220 + str = "精准指导";
  1221 + break;
  1222 + case "11" :
  1223 + str = "标准服务";
  1224 + break;
  1225 + default:
  1226 + str = "";
  1227 + }
  1228 + return str;
  1229 + }
  1230 +
  1231 + /**
  1232 + * 相差天数
  1233 + *
  1234 + * @param date1
  1235 + * @param date2
  1236 + * @return
  1237 + */
  1238 + public static int differentDays(Date date1,Date date2) {
  1239 + Calendar cal1 = Calendar.getInstance();
  1240 + cal1.setTime(date1);
  1241 +
  1242 + Calendar cal2 = Calendar.getInstance();
  1243 + cal2.setTime(date2);
  1244 + int day1= cal1.get(Calendar.DAY_OF_YEAR);
  1245 + int day2 = cal2.get(Calendar.DAY_OF_YEAR);
  1246 +
  1247 + int year1 = cal1.get(Calendar.YEAR);
  1248 + int year2 = cal2.get(Calendar.YEAR);
  1249 + if(year1 != year2) {
  1250 + // 同一年
  1251 + int timeDistance = 0 ;
  1252 + for(int i = year1 ; i < year2 ; i ++) {
  1253 + if(i%4==0 && i%100!=0 || i%400==0) {
  1254 + // 闰年
  1255 + timeDistance += 366;
  1256 + } else {
  1257 + // 不是闰年
  1258 + timeDistance += 365;
  1259 + }
  1260 + }
  1261 + return timeDistance + (day2-day1) ;
  1262 + } else {
  1263 + // 不同年
  1264 + return day2-day1;
  1265 + }
1021 1266 }
1022 1267 }