Commit de0266f94876baff925025a53193ea1f6d404494

Authored by yangfei

Merge remote-tracking branch 'origin/master'

Showing 24 changed files

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/RemoteService.java View file @ de0266f
... ... @@ -15,7 +15,8 @@
15 15 public class RemoteService {
16 16  
17 17 // private String BASE_URL = PropertiesUtils.getPropertyValue("platform.operate.api.validate.url");
18   - private String BASE_URL = "http://dev-rp-api.healthbaby.com.cn:8082/";
  18 +// private String BASE_URL = "http://dev-rp-api.healthbaby.com.cn:8082/";
  19 + private String BASE_URL = "http://localhost:8080/";
19 20  
20 21 /**
21 22 * 作废优惠券相关
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/BabyPatientExtendEarMapper.java View file @ de0266f
1 1 package com.lyms.platform.permission.dao.master;
2 2  
3   -public interface BabyPatientExtendEarMapper {
  3 +import com.lyms.platform.permission.model.BabyPatientExtendEar;
  4 +import com.lyms.platform.permission.model.BabyPatientExtendEarQuery;
  5 +
  6 +import java.util.List;
  7 +
  8 +public interface BabyPatientExtendEarMapper
  9 +{
  10 + public void addBabyPatientExtendEar(BabyPatientExtendEar obj);
  11 +
  12 + public void updateBabyPatientExtendEar(BabyPatientExtendEar obj);
  13 +
  14 + public void deleteBabyPatientExtendEar(String id);
  15 +
  16 + public BabyPatientExtendEar getBabyPatientExtendEar(String id);
  17 +
  18 + public int queryBabyPatientExtendEarCount(BabyPatientExtendEarQuery query);
  19 +
  20 + public List<BabyPatientExtendEar> queryBabyPatientExtendEar(BabyPatientExtendEarQuery query);
4 21  
5 22 }
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java View file @ de0266f
... ... @@ -44,5 +44,15 @@
44 44  
45 45 String findCityId(String hospitalId);
46 46  
  47 + /**
  48 + * 查询报表详情(发放人数、发放券数、使用人数、使用券数)
  49 + * @param param
  50 + * @return
  51 + */
  52 + List<Map<String,Object>> findReport(Map<String, Object> param);
  53 +
  54 + List<Map<String,Object>> findUsedInfo(Map<String, Object> param);
  55 +
  56 + List<Map<String, Object>> findHospitals(Map<String, Object> param);
47 57 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/BabyPatientExtendEarService.java View file @ de0266f
1 1 package com.lyms.platform.permission.service;
2 2  
3 3 import com.lyms.platform.common.result.BaseObjectResponse;
4   -import com.lyms.platform.permission.model.BabyPatientExtendEar;
5   -import com.lyms.platform.permission.model.BabyPatientExtendEarBirth;
6   -import com.lyms.platform.permission.model.BabyPatientExtendEarFamily;
7   -import com.lyms.platform.permission.model.BabyPatientExtendEarMother;
  4 +import com.lyms.platform.permission.model.*;
8 5  
9   -public interface BabyPatientExtendEarService {
  6 +import java.util.List;
10 7  
  8 +public interface BabyPatientExtendEarService
  9 +{
  10 +
11 11 BaseObjectResponse insert(BabyPatientExtendEar ear, BabyPatientExtendEarBirth earBirth, BabyPatientExtendEarMother earMother, BabyPatientExtendEarFamily earFamily, Integer userId);
12 12  
13 13 BaseObjectResponse getConfigs();
  14 +
  15 + public void addBabyPatientExtendEar(BabyPatientExtendEar obj);
  16 +
  17 + public void updateBabyPatientExtendEar(BabyPatientExtendEar obj);
  18 +
  19 + public void deleteBabyPatientExtendEar(String id);
  20 +
  21 + public BabyPatientExtendEar getBabyPatientExtendEar(String id);
  22 +
  23 + public int queryBabyPatientExtendEarCount(BabyPatientExtendEarQuery query);
  24 +
  25 + public List<BabyPatientExtendEar> queryBabyPatientExtendEar(BabyPatientExtendEarQuery query);
14 26 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/BabyPatientExtendEarServiceImpl.java View file @ de0266f
... ... @@ -6,20 +6,19 @@
6 6 import com.lyms.platform.common.result.RespBuilder;
7 7 import com.lyms.platform.common.utils.EnumUtil;
8 8 import com.lyms.platform.permission.dao.master.BabyPatientExtendEarMapper;
9   -import com.lyms.platform.permission.model.BabyPatientExtendEar;
10   -import com.lyms.platform.permission.model.BabyPatientExtendEarBirth;
11   -import com.lyms.platform.permission.model.BabyPatientExtendEarFamily;
12   -import com.lyms.platform.permission.model.BabyPatientExtendEarMother;
  9 +import com.lyms.platform.permission.model.*;
13 10 import com.lyms.platform.permission.service.BabyPatientExtendEarService;
14 11 import org.springframework.beans.factory.annotation.Autowired;
15 12 import org.springframework.data.mongodb.core.MongoTemplate;
16 13 import org.springframework.stereotype.Service;
17 14  
18 15 import java.util.HashMap;
  16 +import java.util.List;
19 17 import java.util.Map;
20 18  
21 19 @Service
22   -public class BabyPatientExtendEarServiceImpl implements BabyPatientExtendEarService {
  20 +public class BabyPatientExtendEarServiceImpl implements BabyPatientExtendEarService
  21 +{
23 22  
24 23 @Autowired
25 24 private MongoTemplate mongoTemplate;
26 25  
... ... @@ -29,13 +28,15 @@
29 28  
30 29 @Override
31 30 public BaseObjectResponse insert(BabyPatientExtendEar ear, BabyPatientExtendEarBirth earBirth,
32   - BabyPatientExtendEarMother earMother, BabyPatientExtendEarFamily earFamily, Integer userId) {
  31 + BabyPatientExtendEarMother earMother, BabyPatientExtendEarFamily earFamily, Integer userId)
  32 + {
33 33 System.out.println("ear = [" + ear + "], earBirth = [" + earBirth + "], earMother = [" + earMother + "], earFamily = [" + earFamily + "], userId = [" + userId + "]");
34 34 return RespBuilder.buildSuccess();
35 35 }
36 36  
37 37 @Override
38   - public BaseObjectResponse getConfigs() {
  38 + public BaseObjectResponse getConfigs()
  39 + {
39 40 Map<String, Object> restMap = new HashMap<>();
40 41 restMap.put("fmType", EnumUtil.toJson(FmTypeEnums.class)); /** 分娩方式 */
41 42 restMap.put("aborType", EnumUtil.toJson(AbortionEnums.class)); /** 流产方式 */
... ... @@ -45,5 +46,44 @@
45 46 return RespBuilder.buildSuccess(restMap);
46 47 }
47 48  
  49 + @Override
  50 + public void addBabyPatientExtendEar(BabyPatientExtendEar obj)
  51 + {
  52 + earMapper.addBabyPatientExtendEar(obj);
  53 + }
  54 +
  55 + @Override
  56 + public void updateBabyPatientExtendEar(BabyPatientExtendEar obj)
  57 + {
  58 + earMapper.updateBabyPatientExtendEar(obj);
  59 + }
  60 +
  61 + @Override
  62 + public void deleteBabyPatientExtendEar(String id)
  63 + {
  64 + earMapper.deleteBabyPatientExtendEar(id);
  65 + }
  66 +
  67 + @Override
  68 + public BabyPatientExtendEar getBabyPatientExtendEar(String id)
  69 + {
  70 + return earMapper.getBabyPatientExtendEar(id);
  71 + }
  72 +
  73 + @Override
  74 + public int queryBabyPatientExtendEarCount(BabyPatientExtendEarQuery query)
  75 + {
  76 + return earMapper.queryBabyPatientExtendEarCount(query);
  77 + }
  78 +
  79 + @Override
  80 + public List<BabyPatientExtendEar> queryBabyPatientExtendEar(BabyPatientExtendEarQuery query)
  81 + {
  82 + if (query.getNeed() != null)
  83 + {
  84 + query.mysqlBuild(earMapper.queryBabyPatientExtendEarCount(query));
  85 + }
  86 + return earMapper.queryBabyPatientExtendEar(query);
  87 + }
48 88 }
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ de0266f
... ... @@ -134,5 +134,81 @@
134 134 where h.hospital_id=#{hospitalId} and ct.type=#{type} order by t.coupon_order ASC
135 135 </select>
136 136  
  137 + <select id="findReport" parameterType="map" resultType="map">
  138 + select a.people_send_count, a.coupon_send_count, a.used_hospital_id, b.user_used_count, b.coupon_used_count, c.province_id, c.city_id, c.area_id, c.name
  139 + from (
  140 + select count(distinct(a.user_id)) as people_send_count, count(1) as coupon_send_count, a.used_hospital_id
  141 + from coupon_info a, coupon_template b, coupon_type c, organization d, hospital_coupon_template_group e
  142 + where a.status = #{status} and a.used_hospital_id = d.id and a.used_hospital_id in
  143 + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid">
  144 + #{hid}
  145 + </foreach>
  146 + and a.coupon_template_id = b.id and b.type_id = c.id and c.type in
  147 + <foreach collection="couponTypes" open="(" close=")" separator="," item="type">
  148 + #{type}
  149 + </foreach>
  150 + <if test="startDate != null">
  151 + and a.use_date >= #{startDate}
  152 + </if>
  153 + <if test="endDate != null">
  154 + #and a.use_date <![CDATA[<]]>= #{endDate}
  155 + </if>
  156 + <if test="provinceId != null and provinceId != ''">
  157 + and d.province_id = #{provinceId}
  158 + </if>
  159 + <if test="cityId != null and cityId != '' ">
  160 + and d.city_id = #{cityId}
  161 + </if>
  162 + <if test="areaId != null and areaId != ''">
  163 + and d.area_id = #{areaId}
  164 + </if>
  165 + <if test="tempId != null and tempId != ''">
  166 + and e.coupon_template_group_id = #{tempId}
  167 + </if>
  168 + and a.used_hospital_id = e.hospital_id
  169 + group by a.used_hospital_id
  170 + ) a, (
  171 + select count(distinct(a.user_id)) as user_used_count, count(1) as coupon_used_count, a.used_hospital_id
  172 + from coupon_info a, coupon_template b, coupon_type c
  173 + where used_hospital_id in
  174 + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid">
  175 + #{hid}
  176 + </foreach>
  177 + and status = #{status} and a.coupon_template_id = b.id and b.type_id = c.id and c.type in
  178 + <foreach collection="couponTypes" open="(" close=")" separator="," item="type">
  179 + #{type}
  180 + </foreach>
  181 + group by used_hospital_id
  182 + ) b, organization c
  183 + where a.used_hospital_id = b.used_hospital_id and a.used_hospital_id = c.id
  184 + </select>
  185 +
  186 + <select id="findUsedInfo" parameterType="map" resultType="map">
  187 + select count(1) as type_used_count, b.coupon_order, b.type, a.used_hospital_id
  188 + from coupon_info a, (
  189 + select a.id, a.coupon_order, b.type, d.hospital_id
  190 + from coupon_template a, coupon_type b, hospital_coupon_template_group d
  191 + where a.group_id = d.coupon_template_group_id and b.id = a.type_id and d.hospital_id in
  192 + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid">
  193 + #{hid}
  194 + </foreach>
  195 + and b.type in
  196 + <foreach collection="couponTypes" open="(" close=")" separator="," item="type">
  197 + #{type}
  198 + </foreach>
  199 + ) b
  200 + where a.used_hospital_id = b.hospital_id and a.coupon_template_id = b.id and a.status = #{status}
  201 + group by b.coupon_order, b.type, a.used_hospital_id
  202 + </select>
  203 +
  204 + <select id="findHospitals" parameterType="map" resultType="map">
  205 + select a.coupon_template_group_id as id, b.name
  206 + from hospital_coupon_template_group a, organization b
  207 + where a.hospital_id = b.id and a.hospital_id in
  208 + <foreach collection="hospitalIds" open="(" close=")" separator="," item="hid">
  209 + #{hid}
  210 + </foreach>
  211 + </select>
  212 +
137 213 </mapper>
platform-common/src/main/java/com/lyms/platform/common/enums/CouponEnums.java View file @ de0266f
... ... @@ -6,12 +6,17 @@
6 6 * @Version: V1.0
7 7 */
8 8 public enum CouponEnums {
9   -
10   - PRENATAL(1, "产检券"),
11   - ANTENATAL(2, "产前券"),
12   - POSTPARTUM(3, "产后券"),
13   - REVIEW(4, "复查券"),
14   - CHILD_HEALTH(5, "儿保券");
  9 + /***
  10 + * 1=孕妇建档 2=孕妇产检 3=产妇建档 4=产妇分娩 5=产妇出院小结 6=产妇产后复查 7=儿童建档 8=儿童保健
  11 + */
  12 + PRENATAL_FILE(1, "孕妇建档"),
  13 + ANTENATAL_CHECK(2, "孕妇产检"),
  14 + POSTPARTUM_FILE(3, "产妇建档"),
  15 + MATERNAL_DELIVER(4, "产妇分娩"),
  16 + MATERNAL_LEAVE_HOSPITAL(5, "产妇出院小结"),
  17 + MATERNAL_REVIEW(6, "产妇产后复查"),
  18 + CHILDREN_FILE(7, "儿童建档"),
  19 + CHILDREN_HEALTHCARE(8, "儿童保健");
15 20  
16 21 private Integer code;
17 22 private String name;
platform-common/src/main/java/com/lyms/platform/common/enums/QbTypeEnums.java View file @ de0266f
... ... @@ -14,7 +14,7 @@
14 14 */
15 15 public enum QbTypeEnums {
16 16  
17   - WXYC(1,"未异常"),TL(2,"脱落"),WTL(3,"未脱落"),YC(4,"异常");
  17 + WXYC(1,"未异常"),TL(2,"脱落"),WTL(3,"未脱落"),YC(4,"异常");
18 18  
19 19 private QbTypeEnums(int id, String name) {
20 20 this.id = id;
platform-common/src/main/java/com/lyms/platform/common/log4j/DailyRollingFileAppender.java View file @ de0266f
  1 +package com.lyms.platform.common.log4j;
  2 +
  3 +import org.apache.log4j.Layout;
  4 +import org.apache.log4j.helpers.QuietWriter;
  5 +
  6 +import java.io.File;
  7 +import java.io.IOException;
  8 +
  9 +/**
  10 + *
  11 + * 解决log4j BufferedIO=true 时,buffer有残余日志不能记录的问题
  12 + *
  13 + * Created by jiangjiazhi on 2017/5/22.
  14 + */
  15 +public class DailyRollingFileAppender extends
  16 + org.apache.log4j.DailyRollingFileAppender {
  17 +
  18 + public DailyRollingFileAppender() {
  19 + super();
  20 + Runtime.getRuntime().addShutdownHook(new Log4jHockThread());
  21 + }
  22 +
  23 + public DailyRollingFileAppender(Layout layout, String filename,
  24 + String datePattern) throws IOException {
  25 + super(layout, filename, datePattern);
  26 + Runtime.getRuntime().addShutdownHook(new Log4jHockThread());
  27 + }
  28 +
  29 + @Override
  30 + public synchronized void setFile(String fileName, boolean append,
  31 + boolean bufferedIO, int bufferSize) throws IOException {
  32 + File logfile = new File(fileName);
  33 +
  34 + logfile.getParentFile().mkdirs();
  35 +
  36 + super.setFile(fileName, append, bufferedIO, bufferSize);
  37 + }
  38 +
  39 + public QuietWriter getQw() {
  40 + return super.qw;
  41 + }
  42 +
  43 + private class Log4jHockThread extends Thread {
  44 + @Override
  45 + public void run() {
  46 + QuietWriter qw = DailyRollingFileAppender.this.getQw();
  47 + if (qw != null) {
  48 + qw.flush();
  49 + }
  50 + }
  51 + }
  52 + }
platform-common/src/main/java/com/lyms/platform/common/result/RespBuilder.java View file @ de0266f
1 1 package com.lyms.platform.common.result;
2 2  
  3 +import org.apache.commons.lang3.StringUtils;
  4 +
  5 +import java.util.HashMap;
  6 +import java.util.Map;
  7 +
3 8 /**
4 9 * @Author: litao
5 10 * @Date: 2017/4/27 0027 10:45
... ... @@ -14,6 +19,17 @@
14 19 BaseObjectResponse resp = new BaseObjectResponse();
15 20 resp.setData(data);
16 21 return resp;
  22 + /* BaseObjectResponse resp = new BaseObjectResponse();
  23 + if(data != null) {
  24 + Assert.isTrue(data.length == 1 || data.length % 2 == 0, "length必须为偶数");
  25 +
  26 + if(data.length == 1) {
  27 + resp.setData(data);
  28 + } else {
  29 + resp.setData(createMap(data));
  30 + }
  31 + }
  32 + return resp;*/
17 33 }
18 34  
19 35 public static BaseObjectResponse buildErro(ResponseCode code) {
... ... @@ -31,6 +47,18 @@
31 47 resp.setErrormsg(ResponseCode.ERROR.getMsg());
32 48 }
33 49 return resp;
  50 + }
  51 +
  52 + private static Map<String,Object> createMap(Object ... args){
  53 + Map<String,Object> map = new HashMap<>();
  54 + for (int i = 0; i < args.length; i++) {
  55 + String key = args[i++].toString();
  56 + Object value = args[i];
  57 + if(value != null && StringUtils.isNotBlank(value.toString())) {
  58 + map.put(key, value);
  59 + }
  60 + }
  61 + return map;
34 62 }
35 63 }
platform-common/src/main/java/com/lyms/platform/common/result/ResponseCode.java View file @ de0266f
... ... @@ -8,10 +8,12 @@
8 8 public enum ResponseCode {
9 9 SUCCESS(0, "成功"),
10 10 ERROR(500, "系统错误,请联系管理员"),
  11 + DATA_ERROR(3001, "数据错误"),
11 12  
12 13 PERSON_NOT_FOUND(2001, "用户未查询到或type为空"),
13 14 PATIENT_NOT_FOUND(2002, "未查询到患者"),
14 15  
  16 + HOSPITAL_TEMP_NOT_UNIQUE(4001, "请选择优惠券模板"),
15 17  
16 18 COUPON_TEMP_NOT_FOUND(1006, "医院未绑定模板或无可生成的优惠券类型"),
17 19 COUPON_IS_CREATED(1007, "该用户已生成优惠券"),
platform-common/src/main/java/com/lyms/platform/common/utils/EnumUtil.java View file @ de0266f
... ... @@ -39,7 +39,8 @@
39 39 Object value = PropertyUtils.getProperty(ec,valueName);
40 40 if(key != null && value != null) {
41 41 Map<String, Object> tempMap = new HashMap<>();
42   - tempMap.put(key.toString(), value);
  42 + tempMap.put("id", key.toString());
  43 + tempMap.put("name", value);
43 44 list.add(tempMap);
44 45 }
45 46 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ de0266f
... ... @@ -5,6 +5,7 @@
5 5 import com.lyms.platform.common.base.LoginContext;
6 6 import com.lyms.platform.common.result.BaseObjectResponse;
7 7 import com.lyms.platform.operate.web.service.IReportService;
  8 +import com.lyms.platform.operate.web.utils.CollectionUtils;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9 10 import org.springframework.stereotype.Controller;
10 11 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -13,6 +14,8 @@
13 14  
14 15 import javax.servlet.http.HttpServletRequest;
15 16 import javax.servlet.http.HttpServletResponse;
  17 +import java.util.Date;
  18 +import java.util.Map;
16 19  
17 20 /**
18 21 * @Author: litao
... ... @@ -184,6 +187,38 @@
184 187 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
185 188 reportService.exportDoctor(startDate, endDate, childBirth, loginState.getId(), resp);
186 189 // reportService.exportDoctor(startDate, endDate, childBirth, 753, resp);
  190 + }
  191 +
  192 +
  193 + /**
  194 + * 优惠券相关统计
  195 + * @param request
  196 + * @param startDate 开始时间
  197 + * @param endDate 结束时间
  198 + * @param provinceId 省
  199 + * @param cityId 市
  200 + * @param areaId 区
  201 + * @param hospitalId 医院id
  202 + * @param tempId 模板id
  203 + * @param couponType 优惠券类型
  204 + * @return
  205 + */
  206 + @ResponseBody
  207 + @TokenRequired
  208 + @RequestMapping(value = "/coupon", method = RequestMethod.GET)
  209 + public BaseObjectResponse coupon(HttpServletRequest request, Date startDate, Date endDate,
  210 + String provinceId, String cityId, String areaId, String hospitalId, String tempId, String couponType) {
  211 + Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate,
  212 + "endDate", endDate, "hospitalIds", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId",
  213 + areaId, "tempId", tempId, "couponType", couponType);
  214 + return reportService.couponInfo(param);
  215 + }
  216 +
  217 + @ResponseBody
  218 + @TokenRequired
  219 + @RequestMapping(value = "/init/coupon", method = RequestMethod.GET)
  220 + public BaseObjectResponse initCoupon(HttpServletRequest request) {
  221 + return reportService.couponInit(CollectionUtils.createMap("userId", getUserId(request)));
187 222 }
188 223  
189 224 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ de0266f
... ... @@ -4,7 +4,6 @@
4 4 import com.lyms.hospitalapi.qhdfy.QhdfyHisService;
5 5 import com.lyms.platform.biz.JdbcUtil;
6 6 import com.lyms.platform.biz.service.*;
7   -import com.lyms.platform.common.enums.CouponEnums;
8 7 import com.lyms.platform.common.enums.YnEnums;
9 8 import com.lyms.platform.common.utils.CompressEncodeingUtil;
10 9 import com.lyms.platform.common.utils.DateUtil;
... ... @@ -1042,7 +1041,7 @@
1042 1041 public String initTicket() {
1043 1042 List<PatientCheckTicket> tickets = mongoTemplate.findAll(PatientCheckTicket.class);
1044 1043 for (PatientCheckTicket ticket : tickets) {
1045   - ticket.setCoupon(CouponEnums.PRENATAL);
  1044 +// ticket.setCoupon(CouponEnums.PRENATAL);
1046 1045 mongoTemplate.save(ticket);
1047 1046 }
1048 1047 return "1";
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AccessPermissionFacade.java View file @ de0266f
... ... @@ -5,6 +5,8 @@
5 5 import java.util.List;
6 6 import java.util.Set;
7 7  
  8 +import com.lyms.platform.common.enums.YnEnums;
  9 +import com.lyms.platform.permission.model.OrganizationQuery;
8 10 import org.apache.commons.collections.CollectionUtils;
9 11 import org.apache.commons.lang.StringUtils;
10 12 import org.apache.commons.lang.math.NumberUtils;
... ... @@ -47,6 +49,10 @@
47 49 @Autowired
48 50 private OrganizationService organizationService;
49 51  
  52 +
  53 + @Autowired
  54 + private AutoMatchFacade autoMatchFacade;
  55 +
50 56 /**
51 57 * 增加访问权限
52 58 *
... ... @@ -109,6 +115,39 @@
109 115 DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery();
110 116 dataPermissionsModelQuery.setUserId(userId);
111 117 return dataPermissionService.queryPermission(dataPermissionsModelQuery);
  118 + }
  119 +
  120 +
  121 + /**
  122 + * 获取当前用户拥有的医院权限列表
  123 + * @param userId
  124 + * @return
  125 + */
  126 + public List<String> getCurrentUserHospPermissions(Integer userId)
  127 + {
  128 + List<String> hospitalList = new ArrayList<>();
  129 + String hospital = autoMatchFacade.getHospitalId(userId);
  130 + if (null != hospital) {
  131 + hospitalList.add(hospital);
  132 + }
  133 +
  134 + //权限所有的医院
  135 + List<String> allHospitalList = new ArrayList<>();
  136 + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery();
  137 + dataPermissionsModelQuery.setUserId(userId);
  138 + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery);
  139 + if (CollectionUtils.isNotEmpty(permissionsModels)) {
  140 + Set<String> set = permissionsModels.get(0).getData().keySet();
  141 + Iterator<String> it = set.iterator();
  142 + while (it.hasNext()) {
  143 + String id = it.next();
  144 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(id) && !hospitalList.contains(id)) {
  145 + allHospitalList.add(id);
  146 + }
  147 + }
  148 + }
  149 +
  150 + return allHospitalList;
112 151 }
113 152  
114 153 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ de0266f
... ... @@ -498,7 +498,7 @@
498 498 // ticket.setId(areaCode.getAreaCode() + ticketPid + i);
499 499 ticket.setId(genSequenceIdService.poll(areaCode.getAreaCode()));
500 500 ticket.setPid(p.getPid());
501   - ticket.setCoupon(CouponEnums.PRENATAL);
  501 +// ticket.setCoupon(CouponEnums.PRENATAL);
502 502 // patientCheckTicketService.addTicket(ticket);
503 503 }
504 504 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java View file @ de0266f
... ... @@ -858,12 +858,21 @@
858 858  
859 859 maternalDeliverResult.convertToResult(deliverModel);
860 860 String doctorId = deliverModel.getDeliverDoctor();
861   - Users users = usersService.getUsers(Integer.valueOf(doctorId));
862 861 Map<String, String> map = new HashMap<>();
863   - if (null != users) {
864   - map.put("id", users.getId() + "");
865   - map.put("name", users.getName());
  862 + try{
  863 + Users users = usersService.getUsers(Integer.valueOf(doctorId));
  864 +
  865 + if (null != users) {
  866 + map.put("id", users.getId() + "");
  867 + map.put("name", users.getName());
  868 + }
  869 + }catch (Exception e)
  870 + {
  871 + map.put("id", "-1");
  872 + map.put("name", doctorId);
866 873 }
  874 +
  875 +
867 876 maternalDeliverResult.setDeliverDoctor(map);
868 877 //获取新生儿信息
869 878 List<MaternalDeliverModel.Baby> babyIdList = deliverModel.getBaby();
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java View file @ de0266f
... ... @@ -3,6 +3,7 @@
3 3 import com.lyms.platform.common.result.BaseObjectResponse;
4 4  
5 5 import javax.servlet.http.HttpServletResponse;
  6 +import java.util.Map;
6 7  
7 8 /**
8 9 * 报表service
... ... @@ -65,5 +66,9 @@
65 66 void exportDoctorInfo(String startDate, String endDate, Integer childBirth, Integer number, String name, Integer userId, HttpServletResponse resp);
66 67  
67 68 void exportCheckInfo(Integer childBirth, String startDate, String endDate, Integer startWeek, Integer endWeek, Integer number, String name, Integer userId, HttpServletResponse resp);
  69 +
  70 + BaseObjectResponse couponInfo(Map<String, Object> param);
  71 +
  72 + BaseObjectResponse couponInit(Map<String, Object> userId);
68 73 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ de0266f
1 1 package com.lyms.platform.operate.web.service.impl;
2 2  
3 3 import com.lyms.hospitalapi.pojo.ReportModel;
  4 +import com.lyms.platform.common.enums.CouponEnums;
4 5 import com.lyms.platform.common.result.BaseObjectResponse;
5 6 import com.lyms.platform.common.result.PageResult;
  7 +import com.lyms.platform.common.result.RespBuilder;
  8 +import com.lyms.platform.common.result.ResponseCode;
  9 +import com.lyms.platform.common.utils.EnumUtil;
6 10 import com.lyms.platform.operate.web.dao.IReportDao;
7 11 import com.lyms.platform.operate.web.facade.AutoMatchFacade;
8 12 import com.lyms.platform.operate.web.service.IReportService;
  13 +import com.lyms.platform.operate.web.utils.CollectionUtils;
9 14 import com.lyms.platform.operate.web.utils.MathUtil;
10 15 import com.lyms.platform.operate.web.utils.ResponseUtil;
11 16 import com.lyms.platform.operate.web.utils.SystemDataSource;
  17 +import com.lyms.platform.permission.dao.master.CouponMapper;
  18 +import com.lyms.platform.pojo.BasicConfig;
12 19 import org.apache.commons.lang.StringUtils;
13 20 import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.data.mongodb.core.MongoTemplate;
14 22 import org.springframework.stereotype.Service;
15 23  
16 24 import javax.servlet.http.HttpServletResponse;
17 25  
... ... @@ -33,8 +41,29 @@
33 41 @Autowired
34 42 AutoMatchFacade autoMatchFacade;
35 43  
  44 + @Autowired
  45 + private CouponMapper couponMapper;
  46 +
  47 + @Autowired
  48 + private MongoTemplate mongoTemplate;
  49 +
36 50 private static final Map<String, String> colorMap = new HashMap<>();
37 51  
  52 + /**
  53 + * 用户类型所对应的优惠券类型
  54 + * 1=孕妇 2=儿童 3=产妇
  55 + * 1=孕妇建档 2=孕妇产检 3=产妇建档 4=产妇分娩 5=产妇出院小结 6=产妇产后复查 7=儿童建档 8=儿童保健
  56 + * 1 : (1, 2)
  57 + * 2 : (7, 8)
  58 + * 3 : (3, 4, 5, 6)
  59 + * */
  60 + private static final Map<Integer, List<Integer>> personCouponMap = new HashMap<>();
  61 +
  62 + /**
  63 + * 优惠券统计报表key(type + "_" + coupon_order)所对应的header名称
  64 + */
  65 + private static final Map<String, Object> couponReportMap = new HashMap<>();
  66 +
38 67 @Autowired
39 68 private SystemDataSource db;
40 69  
... ... @@ -44,6 +73,26 @@
44 73 colorMap.put("橙色预警", "#f17d02");
45 74 colorMap.put("红色预警", "#ff6767");
46 75 colorMap.put("紫色预警", "#be75ff");
  76 +
  77 + personCouponMap.put(1, Arrays.asList(1, 2));
  78 + personCouponMap.put(2, Arrays.asList(7, 8));
  79 + personCouponMap.put(3, Arrays.asList(3, 4, 5, 6));
  80 +
  81 + /** 孕妇 */
  82 + couponReportMap.put("1_1", "孕期建档券使用人次");
  83 + couponReportMap.put("2_1", "首次产检券使用人次");
  84 + couponReportMap.put("2_2", "孕中期一券使用人次");
  85 + couponReportMap.put("2_3", "孕中期二券使用人次");
  86 + couponReportMap.put("2_4", "孕晚期一券使用人次");
  87 + couponReportMap.put("2_5", "孕晚期二券使用人次");
  88 + /** 儿童 */
  89 + couponReportMap.put("7_1", "儿童建档券使用人次");
  90 + couponReportMap.put("8_1", "新生儿保健券使用人次");
  91 + couponReportMap.put("8_2", "<div class='ag-double-line'>儿童保健券(一)<div>使用人次</div></div>");
  92 + couponReportMap.put("8_3", "<div class='ag-double-line'>儿童保健券(二)<div>使用人次</div></div>");
  93 + couponReportMap.put("8_4", "<div class='ag-double-line'>儿童保健券(三)<div><div>使用人次</div></div>");
  94 + couponReportMap.put("8_5", "<div class='ag-double-line'>儿童保健券(四)<div>使用人次</div></div>");
  95 + couponReportMap.put("8_6", "<div class='ag-double-line'>儿童保健券(五)<div>使用人次</div></div>");
47 96 }
48 97  
49 98 @Override
... ... @@ -354,6 +403,57 @@
354 403 }
355 404  
356 405 ResponseUtil.responseExcel(cnames,results, resp);
  406 + }
  407 +
  408 + @Override
  409 + public BaseObjectResponse couponInfo(Map<String ,Object> param) {
  410 + List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */
  411 +
  412 + param.put("hospitalIds", CollectionUtils.asList((String) param.get("hospitalIds")));
  413 + param.put("status", 2);
  414 + param.put("couponTypes", CollectionUtils.asList((String) param.get("couponTypes")));
  415 +
  416 + List<Map<String, Object>> couponReport = couponMapper.findReport(param); /** 优惠券统计详情(发放人数、发放券数、使用人数、使用券数) */
  417 + List<Map<String, Object>> usedInfo = couponMapper.findUsedInfo(param); /** 优惠券使用详情 */
  418 +
  419 + if(org.apache.commons.collections.CollectionUtils.isNotEmpty(couponReport) &&
  420 + org.apache.commons.collections.CollectionUtils.isNotEmpty(usedInfo)) {
  421 + if(CollectionUtils.putAll(couponReport, usedInfo, "used_hospital_id", "used_hospital_id")) {
  422 +
  423 + for (Map<String, Object> map : couponReport) {
  424 + map.put("province_name", findName(map.get("province_id")));
  425 + map.put("city_name", findName(map.get("city_id")));
  426 + map.put("area_name", findName(map.get("area_id")));
  427 + }
  428 +// return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap);
  429 + } else{
  430 + return RespBuilder.buildErro(ResponseCode.DATA_ERROR);
  431 + }
  432 + }
  433 + return RespBuilder.buildSuccess();
  434 + }
  435 +
  436 + @Override
  437 + public BaseObjectResponse couponInit(Map<String, Object> param) {
  438 + List<String> hospitalIds = Arrays.asList("216", "245"); /** 模拟根据登陆人id 查询出来的医院 */
  439 + param.put("hospitalIds", hospitalIds);
  440 + /* return RespBuilder.buildSuccess("coupons", EnumUtil.toJson(CouponEnums.class, "code", "name"),
  441 + "hTemp", couponMapper.findHospitals(param));*/
  442 + return RespBuilder.buildSuccess();
  443 + }
  444 +
  445 + public static void main(String[] args) {
  446 + System.out.println(EnumUtil.toJson(CouponEnums.class, "code", "name"));
  447 + }
  448 +
  449 + private String findName(Object id) {
  450 + if(id != null) {
  451 + BasicConfig basicConfig = mongoTemplate.findById(id, BasicConfig.class);
  452 + if(basicConfig != null) {
  453 + return basicConfig.getName();
  454 + }
  455 + }
  456 + return null;
357 457 }
358 458  
359 459 private String getDoctorInfoSql(String startDate, String endDate, Integer childBirth, Integer number, String name, String hospitalId, List<Object> params) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java View file @ de0266f
  1 +package com.lyms.platform.operate.web.utils;
  2 +
  3 +import org.eclipse.jetty.util.StringUtil;
  4 +import org.springframework.util.Assert;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.HashMap;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +
  11 +/**
  12 + * @Author: litao
  13 + * @Date: 2017/5/22 0022 10:44
  14 + * @Version: V1.0
  15 + */
  16 +public class CollectionUtils {
  17 + private CollectionUtils(){}
  18 +
  19 + public static Map<String,Object> createMap(Object ... args){
  20 + Assert.notNull(args, "参数不能为null");
  21 + Assert.isTrue(args.length % 2 == 0, "length必须为偶数");
  22 +
  23 + Map<String,Object> map = new HashMap<>();
  24 + for (int i = 0; i < args.length; i++) {
  25 + String key = args[i++].toString();
  26 + Object value = args[i];
  27 + if(value != null && StringUtil.isNotBlank(value.toString())) {
  28 + map.put(key, value);
  29 + }
  30 + }
  31 + return map;
  32 + }
  33 +
  34 + /**
  35 + * 合并两个集合中 key 相同的数据 为一行
  36 + * 以第一个集合为主
  37 + * @param listOne
  38 + * @param listTwo
  39 + * @param oneKey
  40 + * @param twoKey
  41 + * @return 是否修改了
  42 + */
  43 + public static boolean putAll(List<Map<String, Object>> listOne, List<Map<String, Object>> listTwo, String oneKey, String twoKey) {
  44 + Assert.notNull(listOne);
  45 + Assert.notNull(listTwo);
  46 + Assert.notNull(oneKey);
  47 + Assert.notNull(twoKey);
  48 + return getIntersect(listOne, listTwo, oneKey, twoKey);
  49 + }
  50 +
  51 + private static boolean getIntersect(List<Map<String, Object>> listOne, List<Map<String, Object>> listTwo, String oneKey, String twoKey) {
  52 + boolean modified = false;
  53 + for (Map<String, Object> mapOne : listOne) {
  54 + for (Map<String, Object> mapTwo : listTwo) {
  55 + if(mapOne.get(oneKey).toString().equals(mapTwo.get(twoKey).toString())) {
  56 + putCouponInfo(mapOne, mapTwo);
  57 + modified = true;
  58 + }
  59 + }
  60 + }
  61 + return modified;
  62 + }
  63 +
  64 + private static void putCouponInfo(Map<String, Object> couponMap, Map<String, Object> couponInfoMap) {
  65 + /** key命名为 type + "_" + coupon_order */
  66 + couponMap.put(couponInfoMap.get("type") + "_" + couponInfoMap.get("coupon_order"), couponInfoMap.get("type_used_count"));
  67 + }
  68 +
  69 +
  70 + public static <T> List<T> asList(String ids) {
  71 + return (List<T>) asList(ids, String.class);
  72 + }
  73 +
  74 + public static <T> List<T> asList(String ids, Class<T> clazz) {
  75 + Assert.notNull(ids);
  76 + Assert.notNull(clazz);
  77 +
  78 + List<T> list = new ArrayList<>();
  79 + String[] id = ids.split(",");
  80 + for (String s : id) {
  81 + list.add((T) s);
  82 + }
  83 + return list;
  84 + }
  85 +
  86 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SystemDataSource.java View file @ de0266f
... ... @@ -60,7 +60,7 @@
60 60 dataSource.setTestOnReturn(false);
61 61 dataSource.setFilters("stat");
62 62  
63   - dataSource.init();
  63 +// dataSource.init();
64 64  
65 65 logger.info("init datasource success");
66 66 }
platform-operate-api/src/main/resources/config.properties View file @ de0266f
... ... @@ -14,7 +14,7 @@
14 14  
15 15  
16 16 #His系统版本 0:未使用,1:桓台,2:新乐,3:青龙县医院,4:秦皇岛妇幼,5:抚宁妇幼, 6: 德州妇幼,7:南充中心医院
17   -his_version=7
  17 +his_version=0
18 18  
19 19 #统计中心url
20 20 center_statistics_url=http://api.healthbaby.com.cn/
21 21  
... ... @@ -31,14 +31,14 @@
31 31  
32 32  
33 33 #区域统计地址
34   -area_count_url=119.90.57.26:1522
  34 +area_count_url=192.168.1.32:1521
35 35  
36 36 #同步mysql数据到各个区域的地址,多个用逗号隔开 如:https://area-qhd-api.healthbaby.com.cn:18019/syncMysqlData,https://area-dz-api.healthbaby.com.cn:12356/syncMysqlData
37 37 sync_mysql_data_url=
38 38  
39 39 #数据源相关配置
40 40 jdbc.0.driver=oracle.jdbc.driver.OracleDriver
41   -jdbc.0.url=jdbc:oracle:thin:@119.90.57.26:1522:orcl
  41 +jdbc.0.url=jdbc:oracle:thin:@192.168.1.32:1521:orcl
42 42 jdbc.0.username=LYMS_ODS
43 43 jdbc.0.password=Welcome1
44 44  
platform-operate-api/src/main/resources/log4j_config.xml View file @ de0266f
... ... @@ -23,9 +23,12 @@
23 23 <param name="ConversionPattern" value="%d %p - %m%n" />
24 24 </layout>
25 25 </appender>
26   - <appender name="HTTP-INVOKE-Info" class="org.apache.log4j.DailyRollingFileAppender">
  26 + <appender name="HTTP-INVOKE-Info" class="com.lyms.platform.common.log4j.DailyRollingFileAppender">
27 27 <param name="Append" value="true" />
28 28 <param name="File" value="${catalina.base}/logs/http-invoke.log" />
  29 + <param name="bufferedIO" value="true" />
  30 + <!-- 50k为一个写单元 ,可以自己定义-->
  31 + <param name="bufferSize" value="8192" />
29 32 <layout class="org.apache.log4j.PatternLayout">
30 33 <param name="ConversionPattern" value="%d %p - %m%n" />
31 34 </layout>
... ... @@ -35,6 +38,9 @@
35 38 <param name="AcceptOnMatch" value="true" />
36 39 </filter>
37 40 </appender>
  41 +
  42 +
  43 +
38 44 <!-- ERORR LOG: [ERROR->FATAL] -->
39 45 <appender name="Error" class="org.apache.log4j.DailyRollingFileAppender">
40 46 <param name="Append" value="true" />
41 47  
42 48  
43 49  
44 50  
45 51  
46 52  
47 53  
48 54  
... ... @@ -61,37 +67,47 @@
61 67 </layout>
62 68 </appender>
63 69  
64   - <appender name="DAL-MONITOR" class="org.apache.log4j.DailyRollingFileAppender">
  70 + <appender name="DAL-MONITOR" class="com.lyms.platform.common.log4j.DailyRollingFileAppender">
65 71 <param name="Append" value="true" />
66 72 <param name="File" value="${catalina.base}/logs/dal-perf.log" />
  73 + <param name="bufferedIO" value="true" />
  74 + <!-- 50k为一个写单元 ,可以自己定义-->
  75 + <param name="bufferSize" value="8192" />
67 76 <layout class="org.apache.log4j.PatternLayout">
68 77 <param name="ConversionPattern" value="%d %p - %m%n" />
69 78 </layout>
70 79 </appender>
71 80  
72   - <appender name="SYNC_DATA" class="org.apache.log4j.RollingFileAppender">
  81 + <appender name="SYNC_DATA" class="com.lyms.platform.common.log4j.DailyRollingFileAppender">
73 82 <param name="Append" value="true" />
74 83 <param name="File" value="${catalina.base}/logs/sync-data.log" />
75 84 <param name="maxBackupIndex" value="3"/>
76 85 <param name="MaxFileSize" value="3MB"/>
  86 + <param name="bufferedIO" value="true" />
  87 + <!-- 50k为一个写单元 ,可以自己定义-->
  88 + <param name="bufferSize" value="51200" />
77 89  
78 90 <layout class="org.apache.log4j.PatternLayout">
79 91 <param name="ConversionPattern" value="%d %p - %m%n" />
80 92 </layout>
81 93 </appender>
82   - <logger name="SYNC_DATA">
  94 + <appender name="ASYNC_SYNC_DATA" class="org.apache.log4j.AsyncAppender">
  95 + <appender-ref ref="SYNC_DATA"/>
  96 + </appender>
  97 +
  98 + <logger name="SYNC_DATA" additivity="false">
83 99 <level value="info" />
84   - <appender-ref ref="SYNC_DATA" />
  100 + <appender-ref ref="ASYNC_SYNC_DATA" />
85 101 </logger>
86   - <logger name="DAL-MONITOR">
  102 + <logger name="DAL-MONITOR" additivity="false">
87 103 <level value="debug" />
88 104 <appender-ref ref="DAL-MONITOR" />
89 105 </logger>
90   - <logger name="HTTP-INVOKE">
  106 + <logger name="HTTP-INVOKE" additivity="false">
91 107 <level value="debug" />
92 108 <appender-ref ref="HTTP-INVOKE-Info" />
93 109 </logger>
94   - <logger name="ACCESS-MONITOR">
  110 + <logger name="ACCESS-MONITOR" additivity="false">
95 111 <level value="debug" />
96 112 <appender-ref ref="Access" />
97 113 </logger>
platform-operate-api/src/main/resources/mybatis.xml View file @ de0266f
... ... @@ -13,10 +13,10 @@
13 13 <setting name="defaultStatementTimeout" value="25000" />
14 14 <setting name="callSettersOnNulls" value="true"/>
15 15 </settings>
16   - <plugins>
17   - <plugin interceptor="com.lyms.platform.operate.web.inteceptor.MybatisSqlInterceptor">
18   - <property name="dialect" value="mysql"/>
19   - </plugin>
20   - </plugins>
  16 + <!--<plugins>-->
  17 + <!--<plugin interceptor="com.lyms.platform.operate.web.inteceptor.MybatisSqlInterceptor">-->
  18 + <!--<property name="dialect" value="mysql"/>-->
  19 + <!--</plugin>-->
  20 + <!--</plugins>-->
21 21 </configuration>