Commit bbbfc5c7b90d3cbb4184d8e9ff2794ddfe5e632d
1 parent
aac0d8aafd
Exists in
master
and in
1 other branch
增加补发产检劵
Showing 4 changed files with 152 additions and 39 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientTicketIdDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AutoIncermentService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UpdateController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientTicketIdDaoImpl.java
View file @
bbbfc5c
... | ... | @@ -2,9 +2,13 @@ |
2 | 2 | |
3 | 3 | import com.lyms.platform.biz.dal.PatientTicketIdDao; |
4 | 4 | import com.lyms.platform.common.dao.BaseMongoDAOImpl; |
5 | +import com.lyms.platform.common.utils.MongoConvertHelper; | |
6 | +import com.lyms.platform.common.utils.ReflectionUtils; | |
5 | 7 | import com.lyms.platform.pojo.PatientTicketId; |
8 | +import com.mongodb.WriteResult; | |
6 | 9 | import org.springframework.data.mongodb.core.query.Criteria; |
7 | 10 | import org.springframework.data.mongodb.core.query.Query; |
11 | +import org.springframework.data.mongodb.core.query.Update; | |
8 | 12 | import org.springframework.stereotype.Repository; |
9 | 13 | |
10 | 14 | /** |
... | ... | @@ -24,9 +28,16 @@ |
24 | 28 | save(ticketId); |
25 | 29 | id = 1; |
26 | 30 | } else { |
27 | - id = ticketId.getTicketId() + 1; | |
28 | - ticketId.setTicketId(id); | |
29 | - update(new Query(Criteria.where("id").is(tableName)),ticketId); | |
31 | + /*id = ticketId.getTicketId() + 1; | |
32 | + ticketId.setTicketId(id); | |
33 | + update(,ticketId);*/ | |
34 | + synchronized (PatientTicketIdDaoImpl.class){ | |
35 | + Update update = new Update(); | |
36 | + update.inc("ticketId", 1); | |
37 | + mongoTemplate.updateMulti(new Query(Criteria.where("_id").is(tableName)), update, "lyms_patient_ticket_id"); | |
38 | + ticketId = findById(tableName); | |
39 | + id = ticketId.getTicketId(); | |
40 | + } | |
30 | 41 | } |
31 | 42 | return id; |
32 | 43 | } |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AutoIncermentService.java
View file @
bbbfc5c
... | ... | @@ -15,10 +15,6 @@ |
15 | 15 | @Autowired |
16 | 16 | private PatientTicketIdDao patientTicketIdDao; |
17 | 17 | |
18 | - public Integer nextId(Class cls) { | |
19 | - return patientTicketIdDao.nextId(cls.getSimpleName()); | |
20 | - } | |
21 | - | |
22 | 18 | public String nextPatientTicketId(String hospital) { |
23 | 19 | Integer id = patientTicketIdDao.nextId(hospital); |
24 | 20 | return String.format("%07d", id); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UpdateController.java
View file @
bbbfc5c
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import com.lyms.platform.common.annotation.TokenRequired; | |
3 | 4 | import com.lyms.platform.common.base.BaseController; |
4 | 5 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
5 | 6 | import com.lyms.platform.common.result.BaseResponse; |
... | ... | @@ -31,6 +32,7 @@ |
31 | 32 | |
32 | 33 | @Autowired |
33 | 34 | private PatientCheckTicketFacade patientCheckTicketFacade; |
35 | + | |
34 | 36 | @RequestMapping(value = "/updateData", method = RequestMethod.GET) |
35 | 37 | @ResponseBody |
36 | 38 | private Map<String, String> updateCorrectData(@RequestParam("hId") String hId) { |
37 | 39 | |
... | ... | @@ -58,8 +60,21 @@ |
58 | 60 | */ |
59 | 61 | @RequestMapping(value = "/supplyCheckTicket", method = RequestMethod.GET) |
60 | 62 | @ResponseBody |
61 | - private BaseResponse supplyCheckTicket(@RequestParam("hId")String hId){ | |
63 | + private BaseResponse supplyCheckTicket(@RequestParam("hId") String hId) { | |
62 | 64 | return patientCheckTicketFacade.supplyCheckTicket(hId); |
65 | + } | |
66 | + | |
67 | + /** | |
68 | + * 补发指定医院的产检劵 | |
69 | + * | |
70 | + * @param parentId | |
71 | + * @return | |
72 | + */ | |
73 | + @TokenRequired | |
74 | + @RequestMapping(value = "/supplyticket", method = RequestMethod.GET) | |
75 | + @ResponseBody | |
76 | + private BaseResponse supplyCheckTicket1(@RequestParam("parentId") String parentId) { | |
77 | + return patientCheckTicketFacade.supplyCheckTicketByPatientId(parentId); | |
63 | 78 | } |
64 | 79 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java
View file @
bbbfc5c
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
8 | 8 | import com.lyms.platform.common.enums.YnEnums; |
9 | 9 | import com.lyms.platform.common.result.BaseResponse; |
10 | +import com.lyms.platform.common.utils.DateUtil; | |
10 | 11 | import com.lyms.platform.common.utils.ExceptionUtils; |
11 | 12 | import com.lyms.platform.common.utils.StringUtils; |
12 | 13 | import com.lyms.platform.operate.web.worker.WorkHR; |
... | ... | @@ -32,6 +33,17 @@ |
32 | 33 | /** |
33 | 34 | * 产检劵补发 |
34 | 35 | * <p/> |
36 | + * 补发规则: | |
37 | + * <p/> | |
38 | + * 当前孕周 <= 孕12周+6天 补发1、2、3、4、5券 | |
39 | + * 孕12周+6天 < 当前孕周 <= 孕20周+6天 补发2、3、4、5券 | |
40 | + * 孕20周+6天 < 当前孕周 <= 孕24周+6天 补发3、4、5券 | |
41 | + * 孕24周+6天 < 当前孕周 <= 孕36周+6天 补发4、5券 | |
42 | + * 孕36周+6天 < 当前孕周 <= 孕40周+6天 补发5券 | |
43 | + * <p/> | |
44 | + * <p/> | |
45 | + * <p/> | |
46 | + * <p/> | |
35 | 47 | * Created by Administrator on 2017/1/5 0005. |
36 | 48 | */ |
37 | 49 | @Component |
38 | 50 | |
... | ... | @@ -41,9 +53,8 @@ |
41 | 53 | private PatientCheckTicketService checkTicketServicel; |
42 | 54 | @Autowired |
43 | 55 | private PatientsService patientsService; |
56 | + | |
44 | 57 | @Autowired |
45 | - private AutoMatchFacade autoMatchFacade; | |
46 | - @Autowired | |
47 | 58 | private AreaCodeService areaCodeService; |
48 | 59 | |
49 | 60 | @Autowired |
... | ... | @@ -65,6 +76,7 @@ |
65 | 76 | patientsQuery1.setHospitalId(hId); |
66 | 77 | patientsQuery1.setYn(YnEnums.YES.getId()); |
67 | 78 | patientsQuery1.setType(1); |
79 | + patientsQuery1.setExtEnable(false); | |
68 | 80 | List buildType = new ArrayList(); |
69 | 81 | buildType.add(0); |
70 | 82 | buildType.add(2); |
... | ... | @@ -84,6 +96,46 @@ |
84 | 96 | return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); |
85 | 97 | } |
86 | 98 | |
99 | + /** | |
100 | + * 补发单个建档的产检劵 | |
101 | + * | |
102 | + * @param parentId | |
103 | + * @return | |
104 | + */ | |
105 | + public BaseResponse supplyCheckTicketByPatientId(String parentId) { | |
106 | + | |
107 | + | |
108 | + Patients patients = patientsService.findOnePatientById(parentId); | |
109 | + //表示不是隐藏建档 | |
110 | + PatientsQuery patientsQuery1 = new PatientsQuery(); | |
111 | + patientsQuery1.setYn(YnEnums.YES.getId()); | |
112 | + patientsQuery1.setType(1); | |
113 | + patientsQuery1.setExtEnable(false); | |
114 | + List buildType = new ArrayList(); | |
115 | + buildType.add(0); | |
116 | + buildType.add(2); | |
117 | + patientsQuery1.setBuildTypeList(buildType); | |
118 | + | |
119 | + if (!"2".equals(patients.getEnable())) { | |
120 | + patientsQuery1.setId(parentId); | |
121 | + } else { | |
122 | + patientsQuery1.setPid(patients.getPid()); | |
123 | + } | |
124 | + List<Patients> patientses = patientsService.queryPatient(patientsQuery1); | |
125 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
126 | + PatientCheckTicketQuery checkTicketQuery = new PatientCheckTicketQuery(); | |
127 | + for (Patients p : patientses) { | |
128 | + checkTicketQuery.setPatientId(p.getId()); | |
129 | + /** | |
130 | + * 执行补发操作 | |
131 | + */ | |
132 | + doBiz(checkTicketQuery, p); | |
133 | + } | |
134 | + } | |
135 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("操作成功."); | |
136 | + } | |
137 | + | |
138 | + | |
87 | 139 | private class SupplyCheckTicketThread extends Thread { |
88 | 140 | private List<Patients> patientses; |
89 | 141 | |
90 | 142 | |
... | ... | @@ -97,40 +149,79 @@ |
97 | 149 | for (Patients p : patientses) { |
98 | 150 | try { |
99 | 151 | checkTicketQuery.setPatientId(p.getId()); |
100 | - if (0 == checkTicketServicel.queryTicketCount(checkTicketQuery)) { | |
101 | - //建档成功后,给孕妇造五个条形码 | |
102 | - Organization organization = organizationService.getOrganization(Integer.valueOf(p.getHospitalId())); | |
103 | - if (null != organization) { | |
104 | - AreaCodeQuery areaCodeQuery = new AreaCodeQuery(); | |
105 | - areaCodeQuery.setAreaId(organization.getCityId()); | |
106 | - areaCodeQuery.setYn(YnEnums.YES.getId() | |
107 | - ); | |
108 | - List<AreaCodeModel> code = areaCodeService.queryList(areaCodeQuery); | |
109 | - AreaCodeModel areaCode = null; | |
110 | - if (CollectionUtils.isNotEmpty(code)) { | |
111 | - areaCode = code.get(0); | |
112 | - } | |
113 | - if (null != areaCode&& StringUtils.isNotEmpty(areaCode.getAreaCode())) { | |
114 | - // 建档成功后,给孕妇造五个条形码 | |
115 | - String ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode()); | |
116 | - for (Integer i = 1; i <= 5; i++) { | |
117 | - PatientCheckTicket ticket = new PatientCheckTicket(); | |
118 | - ticket.setStatus(1); | |
119 | - ticket.setHospitalId(p.getHospitalId()); | |
120 | - ticket.setPatientId(p.getId()); | |
121 | - ticket.setCreated(new Date()); | |
122 | - ticket.setId(areaCode.getAreaCode() + ticketPid + i); | |
123 | - ticket.setPid(p.getPid()); | |
124 | - checkTicketServicel.addTicket(ticket); | |
125 | - } | |
126 | - } | |
127 | - } | |
128 | - } | |
152 | + /** | |
153 | + * 执行补发操作 | |
154 | + */ | |
155 | + doBiz(checkTicketQuery, p); | |
129 | 156 | } catch (Exception e) { |
130 | 157 | ExceptionUtils.catchException(e, "SupplyCheckTicketThread Error."); |
131 | 158 | } |
132 | 159 | } |
133 | 160 | } |
161 | + } | |
162 | + | |
163 | + private void doBiz(PatientCheckTicketQuery checkTicketQuery, Patients p) { | |
164 | + if (0 == checkTicketServicel.queryTicketCount(checkTicketQuery)) { | |
165 | + //建档成功后,给孕妇造五个条形码 | |
166 | + Organization organization = organizationService.getOrganization(Integer.valueOf(p.getHospitalId())); | |
167 | + if (null != organization) { | |
168 | + AreaCodeQuery areaCodeQuery = new AreaCodeQuery(); | |
169 | + areaCodeQuery.setAreaId(organization.getCityId()); | |
170 | + areaCodeQuery.setYn(YnEnums.YES.getId()); | |
171 | + List<AreaCodeModel> code = areaCodeService.queryList(areaCodeQuery); | |
172 | + AreaCodeModel areaCode = null; | |
173 | + if (CollectionUtils.isNotEmpty(code)) { | |
174 | + areaCode = code.get(0); | |
175 | + } | |
176 | + if (null != areaCode && StringUtils.isNotEmpty(areaCode.getAreaCode())) { | |
177 | + String ticketPid = null; | |
178 | + int index = 0; | |
179 | + //重试3次获取劵,取不到就失败 | |
180 | + do { | |
181 | + index++; | |
182 | + ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode()); | |
183 | + } while (StringUtils.isEmpty(ticketPid) && index < 3); | |
184 | + | |
185 | + if (StringUtils.isEmpty(ticketPid)) { | |
186 | + ExceptionUtils.catchException(null, "补发产检劵失败.id : "+p.getId()); | |
187 | + return; | |
188 | + } | |
189 | + // 建档成功后,给孕妇造五个条形码 | |
190 | + for (Integer i = complyCurrentDay(p.getLastMenses()); i <= 5; i++) { | |
191 | + PatientCheckTicket ticket = new PatientCheckTicket(); | |
192 | + ticket.setStatus(1); | |
193 | + ticket.setHospitalId(p.getHospitalId()); | |
194 | + ticket.setPatientId(p.getId()); | |
195 | + ticket.setCreated(new Date()); | |
196 | + ticket.setId(areaCode.getAreaCode() + ticketPid + i); | |
197 | + ticket.setPid(p.getPid()); | |
198 | + checkTicketServicel.addTicket(ticket); | |
199 | + } | |
200 | + } | |
201 | + } | |
202 | + } | |
203 | + } | |
204 | + | |
205 | + | |
206 | + /** | |
207 | + * 获取当前月经从第几期开始补发 | |
208 | + * | |
209 | + * @param lastMess | |
210 | + * @return | |
211 | + */ | |
212 | + public static int complyCurrentDay(Date lastMess) { | |
213 | + int day = DateUtil.getDays(lastMess, new Date()); | |
214 | + if (day <= 12 * 7 + 6) | |
215 | + return 1; | |
216 | + if (12 * 7 + 6 < day && day <= 20 * 7 + 6) | |
217 | + return 2; | |
218 | + if (20 * 7 + 6 < day && day <= 24 * 7 + 6) | |
219 | + return 3; | |
220 | + if (24 * 7 + 6 < day && day <= 36 * 7 + 6) | |
221 | + return 4; | |
222 | + if (36 * 7 + 6 < day && day <= 40 * 7 + 6) | |
223 | + return 5; | |
224 | + return 6; | |
134 | 225 | } |
135 | 226 | } |