Commit e990ad99c3f051e9d81081c3b9e1aaf088e1a8fe

Authored by jiangjiazhi
1 parent 7f4624460e

修改机构组发放产检劵

Showing 7 changed files with 159 additions and 67 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IOrganizationGroupsItemsDao.java View file @ e990ad9
... ... @@ -38,5 +38,13 @@
38 38 */
39 39 OrganizationGroupsItems addOneEntity(OrganizationGroupsItems groupsItems);
40 40  
  41 + /**
  42 + * 获取一个机构组
  43 + *
  44 + * @param id
  45 + * @return
  46 + */
  47 + OrganizationGroupsItems findById(String id);
  48 +
41 49 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/OrganizationGroupsItemsDaoImpl.java View file @ e990ad9
... ... @@ -3,6 +3,7 @@
3 3 import com.lyms.platform.biz.dal.IOrganizationGroupsItemsDao;
4 4 import com.lyms.platform.common.dao.BaseMongoDAOImpl;
5 5 import com.lyms.platform.common.dao.operator.MongoQuery;
  6 +import com.lyms.platform.permission.model.Organization;
6 7 import com.lyms.platform.pojo.OrganizationGroupsItems;
7 8 import org.springframework.stereotype.Repository;
8 9  
... ... @@ -29,6 +30,9 @@
29 30  
30 31 public OrganizationGroupsItems addOneEntity(OrganizationGroupsItems groupsItems){
31 32 return save(groupsItems);
  33 + }
  34 + public OrganizationGroupsItems findById(String id){
  35 + return findById(id);
32 36 }
33 37 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/OrganizationGroupsItemService.java View file @ e990ad9
... ... @@ -18,7 +18,8 @@
18 18 * Created by Administrator on 2016/12/21 0021.
19 19 */
20 20 @Service
21   -public class OrganizationGroupsItemService {
  21 +public class OrganizationGroupsItemService
  22 +{
22 23 @Autowired
23 24 private IOrganizationGroupsItemsDao iOrganizationGroupsItemsDao;
24 25  
25 26  
26 27  
27 28  
28 29  
... ... @@ -28,27 +29,42 @@
28 29 * @param mogoQuery
29 30 * @return
30 31 */
31   - public List<OrganizationGroupsItems> queryList(OrganizationGroupsItemQuery mogoQuery) {
  32 + public List<OrganizationGroupsItems> queryList(OrganizationGroupsItemQuery mogoQuery)
  33 + {
32 34 MongoQuery mogo = mogoQuery.convertToQuery();
33   - if (StringUtils.isNotEmpty(mogoQuery.getNeed())) {
  35 + if (StringUtils.isNotEmpty(mogoQuery.getNeed()))
  36 + {
34 37 mogoQuery.mysqlBuild(iOrganizationGroupsItemsDao.count(mogo));
35 38 mogo.start(mogoQuery.getOffset()).end(mogoQuery.getLimit());
36 39 }
37 40 return iOrganizationGroupsItemsDao.queryList(mogo.addOrder(Sort.Direction.DESC, "modified"));
38 41 }
39 42  
40   - public int count(OrganizationGroupsItemQuery mogoQuery) {
  43 + public int count(OrganizationGroupsItemQuery mogoQuery)
  44 + {
41 45 MongoQuery mogo = mogoQuery.convertToQuery();
42 46 return iOrganizationGroupsItemsDao.count(mogo);
43 47 }
44 48  
45 49 /**
  50 + * 获取单个机构组
  51 + *
  52 + * @param id
  53 + * @return
  54 + */
  55 + public OrganizationGroupsItems findById(String id)
  56 + {
  57 + return iOrganizationGroupsItemsDao.findById(id);
  58 + }
  59 +
  60 + /**
46 61 * 增加一条记录
47 62 *
48 63 * @param groupsItems
49 64 * @return
50 65 */
51   - public OrganizationGroupsItems addOneEntity(OrganizationGroupsItems groupsItems) {
  66 + public OrganizationGroupsItems addOneEntity(OrganizationGroupsItems groupsItems)
  67 + {
52 68 groupsItems.setCreated(new Date());
53 69 groupsItems.setModified(new Date());
54 70 return iOrganizationGroupsItemsDao.addOneEntity(groupsItems);
platform-dal/src/main/java/com/lyms/platform/pojo/OrganizationGroupsItems.java View file @ e990ad9
... ... @@ -9,7 +9,7 @@
9 9 /**
10 10 * 机构组项目
11 11 *
12   - *
  12 + * @link TicketTypeEnums
13 13 * Created by Administrator on 2016/12/21 0021.
14 14 */
15 15 @Document(collection = "lyms_group_items")
16 16  
... ... @@ -26,10 +26,22 @@
26 26 private Integer type;
27 27 //选择的医院
28 28 private List<Integer> hId;
  29 + //@link TicketTypeEnums
  30 + private Integer ticketType;
29 31  
30 32 private Date created;
31 33  
32 34 private Date modified;
  35 +
  36 + public Integer getTicketType()
  37 + {
  38 + return ticketType;
  39 + }
  40 +
  41 + public void setTicketType(Integer ticketType)
  42 + {
  43 + this.ticketType = ticketType;
  44 + }
33 45  
34 46 public String getGroupId() {
35 47 return groupId;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ e990ad9
... ... @@ -271,21 +271,31 @@
271 271 areaCodeQuery.setYn(YnEnums.YES.getId());
272 272 List<AreaCodeModel> code = areaCodeService.queryList(areaCodeQuery);
273 273 AreaCodeModel areaCode = null;
274   - if (CollectionUtils.isNotEmpty(code)) {
275   - areaCode = code.get(0);
276   - }
277   - if (null != areaCode&&StringUtils.isNotEmpty(areaCode.getAreaCode())) {
278   - // 建档成功后,给孕妇造五个条形码
279   - String ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode());
280   - for (Integer i = PatientCheckTicketFacade.complyCurrentDay(p.getLastMenses()); i <= 5; i++) {
281   - PatientCheckTicket ticket = new PatientCheckTicket();
282   - ticket.setStatus(1);
283   - ticket.setHospitalId(p.getHospitalId());
284   - ticket.setPatientId(p.getId());
285   - ticket.setCreated(new Date());
286   - ticket.setId(areaCode.getAreaCode() + ticketPid + i);
287   - ticket.setPid(p.getPid());
288   - patientCheckTicketService.addTicket(ticket);
  274 +
  275 +
  276 + String groupId= groupsFacade.findByCurrentUserId(autoMatchFacade.getHospitalId(userId));
  277 + if(org.apache.commons.lang.StringUtils.isNotEmpty(groupId)){
  278 + OrganizationGroupsItems groupsItems = groupsFacade.findById(groupId);
  279 + if(null!=groupsItems){
  280 + if (CollectionUtils.isNotEmpty(code)) {
  281 + areaCode = code.get(0);
  282 + }
  283 + if (null != areaCode&&StringUtils.isNotEmpty(areaCode.getAreaCode())) {
  284 + // 建档成功后,给孕妇造五个条形码
  285 + String ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode());
  286 +
  287 + int start = TicketTypeEnums.TICKTE_ALL.getType().equals(groupsItems.getTicketType()) ?0:PatientCheckTicketFacade.complyCurrentDay(p.getLastMenses());
  288 + for (Integer i =start; i <= 5; i++) {
  289 + PatientCheckTicket ticket = new PatientCheckTicket();
  290 + ticket.setStatus(1);
  291 + ticket.setHospitalId(p.getHospitalId());
  292 + ticket.setPatientId(p.getId());
  293 + ticket.setCreated(new Date());
  294 + ticket.setId(areaCode.getAreaCode() + ticketPid + i);
  295 + ticket.setPid(p.getPid());
  296 + patientCheckTicketService.addTicket(ticket);
  297 + }
  298 + }
289 299 }
290 300 }
291 301 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/OrganizationGroupsFacade.java View file @ e990ad9
... ... @@ -39,6 +39,11 @@
39 39 @Autowired
40 40 private OrganizationService organizationService;
41 41  
  42 +
  43 + public OrganizationGroupsItems findById(String id){
  44 + return groupsItemService.findById(id);
  45 + }
  46 +
42 47 /**
43 48 * 增加一个分组
44 49 *
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java View file @ e990ad9
... ... @@ -4,6 +4,8 @@
4 4 import java.util.Date;
5 5 import java.util.List;
6 6  
  7 +import com.lyms.platform.common.enums.TicketTypeEnums;
  8 +import com.lyms.platform.pojo.OrganizationGroupsItems;
7 9 import org.apache.commons.collections.CollectionUtils;
8 10 import org.springframework.beans.factory.annotation.Autowired;
9 11 import org.springframework.beans.factory.annotation.Qualifier;
10 12  
11 13  
12 14  
13 15  
14 16  
15 17  
16 18  
17 19  
18 20  
... ... @@ -34,43 +36,48 @@
34 36 * <p/>
35 37 * 补发规则:
36 38 * <pre/>
37   - * 当前孕周 <= 孕12周+6天 补发1、2、3、4、5券
38   - * 孕12周+6天 < 当前孕周 <= 孕20周+6天 补发2、3、4、5券
39   - * 孕20周+6天 < 当前孕周 <= 孕24周+6天 补发3、4、5券
40   - * 孕24周+6天 < 当前孕周 <= 孕36周+6天 补发4、5券
  39 + * 当前孕周 <= 孕12周+6天 补发1、2、3、4、5券
  40 + * 孕12周+6天 < 当前孕周 <= 孕20周+6天 补发2、3、4、5券
  41 + * 孕20周+6天 < 当前孕周 <= 孕24周+6天 补发3、4、5券
  42 + * 孕24周+6天 < 当前孕周 <= 孕36周+6天 补发4、5券
41 43 * 孕36周+6天 <当前孕周 <= 孕40周+6天 补发5券
42 44 * <pre/>
43 45 * <p/>
44 46 * Created by Administrator on 2017/1/5 0005.
45 47 */
46 48 @Component
47   -public class PatientCheckTicketFacade {
  49 +public class PatientCheckTicketFacade
  50 +{
48 51  
49 52 @Autowired
50 53 private PatientCheckTicketService checkTicketServicel;
51 54  
52 55 @Autowired
53   - private PatientsService patientsService;
  56 + private PatientsService patientsService;
54 57  
55 58 @Autowired
56   - private AreaCodeService areaCodeService;
  59 + private AreaCodeService areaCodeService;
57 60  
58 61 @Autowired
59   - private AutoIncermentService autoIncermentService;
  62 + private AutoIncermentService autoIncermentService;
60 63  
61 64 @Autowired
62   - private OrganizationService organizationService;
  65 + private OrganizationService organizationService;
63 66  
64 67 @Autowired
65 68 @Qualifier("commonThreadPool")
66   - private ThreadPoolTaskExecutor commonThreadPool;
  69 + private ThreadPoolTaskExecutor commonThreadPool;
67 70  
  71 + @Autowired
  72 + private OrganizationGroupsFacade groupsFacade;
  73 +
68 74 /**
69 75 * 补发以前建档的产检劵
70   - *
  76 + *
71 77 * @return
72 78 */
73   - public BaseResponse supplyCheckTicket(String hId) {
  79 + public BaseResponse supplyCheckTicket(String hId)
  80 + {
74 81 PatientsQuery patientsQuery1 = new PatientsQuery();
75 82 patientsQuery1.setHospitalId(hId);
76 83 patientsQuery1.setYn(YnEnums.YES.getId());
77 84  
... ... @@ -85,9 +92,11 @@
85 92  
86 93 int batchSize = 400;
87 94 int end = 0;
88   - for (int i = 0; i < patientses.size(); i += batchSize) {
  95 + for (int i = 0; i < patientses.size(); i += batchSize)
  96 + {
89 97 end = (end + batchSize);
90   - if (end > patientses.size()) {
  98 + if (end > patientses.size())
  99 + {
91 100 end = patientses.size();
92 101 }
93 102 commonThreadPool.execute(new SupplyCheckTicketThread(patientses.subList(i, end)));
94 103  
... ... @@ -97,11 +106,12 @@
97 106  
98 107 /**
99 108 * 补发单个建档的产检劵
100   - *
  109 + *
101 110 * @param parentId
102 111 * @return
103 112 */
104   - public BaseResponse supplyCheckTicketByPatientId(String parentId) {
  113 + public BaseResponse supplyCheckTicketByPatientId(String parentId)
  114 + {
105 115  
106 116 Patients patients = patientsService.findOnePatientById(parentId);
107 117 // 表示不是隐藏建档
108 118  
109 119  
110 120  
... ... @@ -114,15 +124,19 @@
114 124 buildType.add(2);
115 125 patientsQuery1.setBuildTypeList(buildType);
116 126  
117   - if (!"2".equals(patients.getEnable())) {
  127 + if (!"2".equals(patients.getEnable()))
  128 + {
118 129 patientsQuery1.setId(parentId);
119   - } else {
  130 + } else
  131 + {
120 132 patientsQuery1.setPid(patients.getPid());
121 133 }
122 134 List<Patients> patientses = patientsService.queryPatient(patientsQuery1);
123   - if (CollectionUtils.isNotEmpty(patientses)) {
  135 + if (CollectionUtils.isNotEmpty(patientses))
  136 + {
124 137 PatientCheckTicketQuery checkTicketQuery = new PatientCheckTicketQuery();
125   - for (Patients p : patientses) {
  138 + for (Patients p : patientses)
  139 + {
126 140 checkTicketQuery.setPatientId(p.getId());
127 141 /**
128 142 * 执行补发操作
129 143  
130 144  
131 145  
132 146  
133 147  
134 148  
135 149  
136 150  
137 151  
138 152  
139 153  
... ... @@ -133,66 +147,87 @@
133 147 return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("操作成功.");
134 148 }
135 149  
136   - private class SupplyCheckTicketThread extends Thread {
  150 + private class SupplyCheckTicketThread extends Thread
  151 + {
137 152 private List<Patients> patientses;
138 153  
139   - public SupplyCheckTicketThread(List<Patients> patientses) {
  154 + public SupplyCheckTicketThread(List<Patients> patientses)
  155 + {
140 156 this.patientses = patientses;
141 157 }
142 158  
143 159 @Override
144   - public void run() {
  160 + public void run()
  161 + {
145 162 PatientCheckTicketQuery checkTicketQuery = new PatientCheckTicketQuery();
146   - for (Patients p : patientses) {
147   - try {
  163 + for (Patients p : patientses)
  164 + {
  165 + try
  166 + {
148 167 checkTicketQuery.setPatientId(p.getId());
149 168 /**
150 169 * 执行补发操作
151 170 */
152 171 doBiz(checkTicketQuery, p);
153   - } catch (Exception e) {
  172 + } catch (Exception e)
  173 + {
154 174 ExceptionUtils.catchException(e, "SupplyCheckTicketThread Error.");
155 175 }
156 176 }
157 177 }
158 178 }
159 179  
160   - private void doBiz(PatientCheckTicketQuery checkTicketQuery, Patients p) {
161   - if (0 == checkTicketServicel.queryTicketCount(checkTicketQuery)) {
  180 + private void doBiz(PatientCheckTicketQuery checkTicketQuery, Patients p)
  181 + {
  182 + if (0 == checkTicketServicel.queryTicketCount(checkTicketQuery))
  183 + {
162 184 // 建档成功后,给孕妇造五个条形码
163 185 Organization organization = organizationService.getOrganization(Integer.valueOf(p.getHospitalId()));
164   - if (null != organization) {
  186 + if (null != organization)
  187 + {
165 188 AreaCodeQuery areaCodeQuery = new AreaCodeQuery();
166 189 areaCodeQuery.setAreaId(organization.getCityId());
167 190 areaCodeQuery.setYn(YnEnums.YES.getId());
168 191 List<AreaCodeModel> code = areaCodeService.queryList(areaCodeQuery);
169 192 AreaCodeModel areaCode = null;
170   - if (CollectionUtils.isNotEmpty(code)) {
  193 + if (CollectionUtils.isNotEmpty(code))
  194 + {
171 195 areaCode = code.get(0);
172 196 }
173   - if (null != areaCode && StringUtils.isNotEmpty(areaCode.getAreaCode())) {
  197 + if (null != areaCode && StringUtils.isNotEmpty(areaCode.getAreaCode()))
  198 + {
174 199 String ticketPid = null;
175 200 int index = 0;
176 201 // 重试3次获取劵,取不到就失败
177   - do {
  202 + do
  203 + {
178 204 index++;
179 205 ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode());
180 206 } while (StringUtils.isEmpty(ticketPid) && index < 3);
181 207  
182   - if (StringUtils.isEmpty(ticketPid)) {
  208 + if (StringUtils.isEmpty(ticketPid))
  209 + {
183 210 ExceptionUtils.catchException(null, "补发产检劵失败.id : " + p.getId());
184 211 return;
185 212 }
186   - // 建档成功后,给孕妇造五个条形码
187   - for (Integer i = complyCurrentDay(p.getLastMenses()); i <= 5; i++) {
188   - PatientCheckTicket ticket = new PatientCheckTicket();
189   - ticket.setStatus(1);
190   - ticket.setHospitalId(p.getHospitalId());
191   - ticket.setPatientId(p.getId());
192   - ticket.setCreated(new Date());
193   - ticket.setId(areaCode.getAreaCode() + ticketPid + i);
194   - ticket.setPid(p.getPid());
195   - checkTicketServicel.addTicket(ticket);
  213 +
  214 + String groupId = groupsFacade.findByCurrentUserId(p.getHospitalId());
  215 + if (org.apache.commons.lang.StringUtils.isNotEmpty(groupId))
  216 + {
  217 + OrganizationGroupsItems groupsItems = groupsFacade.findById(groupId);
  218 + // 建档成功后,给孕妇造五个条形码
  219 + int start = TicketTypeEnums.TICKTE_ALL.getType().equals(groupsItems.getTicketType()) ? 0 : PatientCheckTicketFacade.complyCurrentDay(p.getLastMenses());
  220 + for (Integer i = start; i <= 5; i++)
  221 + {
  222 + PatientCheckTicket ticket = new PatientCheckTicket();
  223 + ticket.setStatus(1);
  224 + ticket.setHospitalId(p.getHospitalId());
  225 + ticket.setPatientId(p.getId());
  226 + ticket.setCreated(new Date());
  227 + ticket.setId(areaCode.getAreaCode() + ticketPid + i);
  228 + ticket.setPid(p.getPid());
  229 + checkTicketServicel.addTicket(ticket);
  230 + }
196 231 }
197 232 }
198 233 }
199 234  
... ... @@ -201,12 +236,14 @@
201 236  
202 237 /**
203 238 * 获取当前月经从第几期开始补发
204   - *
  239 + *
205 240 * @param lastMess
206 241 * @return
207 242 */
208   - public static int complyCurrentDay(Date lastMess) {
209   - if(null==lastMess){
  243 + public static int complyCurrentDay(Date lastMess)
  244 + {
  245 + if (null == lastMess)
  246 + {
210 247 return 0;
211 248 }
212 249 int day = DateUtil.getDays(lastMess, new Date());