Commit 743a833b1b4e03d9fdd4c8b453ca488c6d5994cc

Authored by litao
1 parent 1410e43f1b

逻辑完善+登陆时多返回医院所对应的产检券type信息

Showing 5 changed files with 48 additions and 9 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java View file @ 743a833
... ... @@ -4,6 +4,7 @@
4 4  
5 5 import java.util.List;
6 6 import java.util.Map;
  7 +import java.util.Set;
7 8  
8 9 /**
9 10 * @Author: litao
... ... @@ -24,5 +25,7 @@
24 25 Map<String,Object> findValidateParam(Map<String, Object> param);
25 26  
26 27 void use(Map<String, Object> param);
  28 +
  29 + Set<Integer> findTypes(Map<String, Object> param);
27 30 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java View file @ 743a833
... ... @@ -2,6 +2,8 @@
2 2  
3 3 import com.lyms.platform.common.result.BaseObjectResponse;
4 4  
  5 +import java.util.Set;
  6 +
5 7 /**
6 8 * @Author: litao
7 9 * @Date: 2017/4/27 0027 9:15
... ... @@ -15,5 +17,7 @@
15 17 BaseObjectResponse findList(String userId, String hospitalId);
16 18  
17 19 BaseObjectResponse use(String hospitalId, String code, Integer userId);
  20 +
  21 + Set<Integer> findTypes(String hospital);
18 22 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java View file @ 743a833
... ... @@ -5,6 +5,7 @@
5 5 import com.lyms.platform.common.result.RespBuilder;
6 6 import com.lyms.platform.common.result.ResponseCode;
7 7 import com.lyms.platform.common.utils.DateUtil;
  8 +import com.lyms.platform.common.utils.StringUtils;
8 9 import com.lyms.platform.permission.dao.master.CouponMapper;
9 10 import com.lyms.platform.permission.model.CouponInfo;
10 11 import com.lyms.platform.permission.service.CouponService;
... ... @@ -51,6 +52,9 @@
51 52 /** 产妇有分娩记录且有出院小结 */
52 53 private static final String MATERNAL_YCHILDBIRTH_YHOSPITAL = "3_3";
53 54  
  55 + /** 建档 */
  56 + private static final String PUT_ON_RECORD = "4";
  57 +
54 58 @Value("${or.code.url}")
55 59 private String url;
56 60  
... ... @@ -82,6 +86,7 @@
82 86 put(MATERNAL_NCHILDBIRTH_NHOSPITAL, Arrays.asList(4, 5, 6));
83 87 put(MATERNAL_YCHILDBIRTH_NHOSPITAL, Arrays.asList(5, 6));
84 88 put(MATERNAL_YCHILDBIRTH_YHOSPITAL, Arrays.asList(6));
  89 + put(PUT_ON_RECORD, Arrays.asList(1, 3, 7));
85 90 }
86 91 };
87 92  
88 93  
... ... @@ -135,13 +140,24 @@
135 140 if(temp.get("coupon_template_id") != null) {
136 141 couponInfo.setCouponTemplateId(temp.get("coupon_template_id").toString());
137 142 }
  143 + /** 统一处理建档数据 自动使用,使用日期为建档日期,使用人为建档人,建档机构为建档人机构 */
  144 + Object type = temp.get("type");
  145 + if(type != null && typeMap.get(PUT_ON_RECORD).contains(Integer.parseInt(type.toString()))) {
  146 + couponInfo.setStatus(2);
  147 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), Patients.class);
  148 + if(patients != null) {
  149 + couponInfo.setUseDate(patients.getBookbuildingDate());
  150 + couponInfo.setOperatorUseId(patients.getBookbuildingDoctor());
  151 + couponInfo.setUsedHospitalId(patients.getHospitalId());
  152 + }
  153 + }
  154 +
138 155 if("1".equals(sendType.toString())) {
139 156 couponMapper.save(couponInfo);
140 157 } else if("2".equals(sendType.toString())) {
141 158 Object actualStart = temp.get("actual_start");
142 159 Object actualEnd = temp.get("actual_end");
143 160 Object unitType = temp.get("unit_type");
144   - Object type = temp.get("type");
145 161 if(actualStart != null && actualEnd != null && unitType != null && type != null) {
146 162 if(validateDate(userId, Integer.parseInt(actualStart.toString()), Integer.parseInt(actualEnd.toString()),
147 163 Integer.parseInt(unitType.toString()), hospitalId, Integer.parseInt(type.toString()))) {
... ... @@ -194,8 +210,6 @@
194 210 }
195 211 }
196 212  
197   -
198   -
199 213 @Override
200 214 public BaseObjectResponse validate(String userId, String code, Integer type) {
201 215 Map<String, Object> param = new HashMap<>();
202 216  
... ... @@ -242,14 +256,16 @@
242 256 Date midDate = null;
243 257 Date startDate = null;
244 258 Date endDate = null;
245   - if(couponType == 1) {/** 根据末次月经对比 midDate = 末次月经时间 */
  259 +// if(couponType == 1) {/** 根据末次月经对比 midDate = 末次月经时间 */
  260 + if(typeMap.get(PREGNANT_WOMAN).contains(couponType)) {/** 孕妇: 根据末次月经对比 midDate = 末次月经时间 */
246 261 List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("type").is(1).and("hospitalId").is(hospitalId).and("pid").is(userId)), Patients.class);
247 262 if(CollectionUtils.isEmpty(patients)) {
248 263 logger.info("未找到pid: " + userId + ", hospitalId: " + hospitalId + ", type: 1 的孕妇信息");
249 264 return false;
250 265 }
251 266 midDate = patients.get(0).getLastMenses();
252   - } else if(couponType == 2 || couponType == 3) {/** 根据分娩时间对比 midDate = 分娩时间 */
  267 +// } else if(couponType == 2 || couponType == 3) {/** 根据分娩时间对比 midDate = 分娩时间 */
  268 + } else {/** 产妇或者儿童:根据分娩时间对比 midDate = 分娩时间 */
253 269 List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("type").is(3).and("hospitalId").is(hospitalId).and("pid").is(userId))
254 270 .with(new Sort(Sort.Direction.DESC, "fmDate")), Patients.class);
255 271 if(CollectionUtils.isEmpty(patients)) {
... ... @@ -301,6 +317,13 @@
301 317 param.put("code", code);
302 318 couponMapper.use(param);
303 319 return RespBuilder.buildSuccess();
  320 + }
  321 +
  322 + @Override
  323 + public Set<Integer> findTypes(String hospital) {
  324 + Map<String, Object> param = new HashMap<>();
  325 + param.put("hospitalId", hospital);
  326 + return couponMapper.findTypes(param);
304 327 }
305 328  
306 329 }
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ 743a833
... ... @@ -75,5 +75,10 @@
75 75 where sequence_id = #{code}
76 76 </update>
77 77  
  78 + <select id="findTypes" parameterType="map" resultType="integer">
  79 + select c.type
  80 + from hospital_coupon_template_group a,coupon_template b, coupon_type c
  81 + where a.hospital_id = #{hospitalId} and a.coupon_template_group_id = b.group_id and b.type_id = c.id
  82 + </select>
78 83 </mapper>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java View file @ 743a833
... ... @@ -16,7 +16,6 @@
16 16 import com.lyms.platform.operate.web.facade.OrganizationGroupsFacade;
17 17 import com.lyms.platform.operate.web.result.FrontEndResult;
18 18 import com.lyms.platform.operate.web.session.SessionProvider;
19   -import com.lyms.platform.operate.web.session.strategy.ISessionProvider;
20 19 import com.lyms.platform.permission.model.*;
21 20 import com.lyms.platform.permission.service.*;
22 21 import com.lyms.platform.pojo.BasicConfig;
... ... @@ -24,7 +23,6 @@
24 23 import com.lyms.platform.pojo.OrganizationGroups;
25 24 import org.apache.commons.collections.CollectionUtils;
26 25 import org.apache.commons.lang.StringUtils;
27   -import org.apache.commons.lang.math.*;
28 26 import org.apache.commons.lang.math.NumberUtils;
29 27 import org.springframework.beans.factory.annotation.Autowired;
30 28 import org.springframework.beans.factory.annotation.Value;
31 29  
... ... @@ -32,10 +30,8 @@
32 30 import org.springframework.stereotype.Controller;
33 31 import org.springframework.web.bind.annotation.*;
34 32  
35   -import javax.management.relation.Role;
36 33 import javax.servlet.http.HttpServletRequest;
37 34 import javax.servlet.http.HttpServletResponse;
38   -import javax.validation.constraints.Pattern;
39 35 import java.util.*;
40 36  
41 37 /**
... ... @@ -78,6 +74,8 @@
78 74 private AutoMatchFacade autoMatchFacade;
79 75 @Autowired
80 76 private BasicConfigService basicConfigService;
  77 + @Autowired
  78 + private CouponService couponService;
81 79  
82 80 private static final String LYMS = "龙源美生";
83 81  
84 82  
... ... @@ -550,11 +548,17 @@
550 548 }
551 549 users.setOrganizations(organizations);
552 550  
  551 + /** 设置产检券类型 */
  552 + String hospital = autoMatchFacade.getHospitalId(loginContext.getId());
  553 + Set<Integer> types = couponService.findTypes(hospital);
  554 +
  555 +
553 556 Map<String, Object> map = new HashMap<>();
554 557 map.put("user", users);
555 558 map.put("watermark", CompressEncodeingUtil.compressNumber(users.getId().toString() + DateUtil.getymd6()));
556 559 map.put("roles", roles);
557 560 map.put("permissions", permissions);
  561 + map.put("types", types);
558 562  
559 563 ResultUtils.buildSuccessResultAndWrite(response, map);
560 564 }