diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IOrganizationGroupsItemsDao.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IOrganizationGroupsItemsDao.java index ad6bb13..dedb0e9 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IOrganizationGroupsItemsDao.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IOrganizationGroupsItemsDao.java @@ -38,4 +38,12 @@ public interface IOrganizationGroupsItemsDao { */ OrganizationGroupsItems addOneEntity(OrganizationGroupsItems groupsItems); + /** + * 获取一个机构组 + * + * @param id + * @return + */ + OrganizationGroupsItems findById(String id); + } diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/OrganizationGroupsItemsDaoImpl.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/OrganizationGroupsItemsDaoImpl.java index 5c48ea1..4583c78 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/OrganizationGroupsItemsDaoImpl.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/OrganizationGroupsItemsDaoImpl.java @@ -3,6 +3,7 @@ package com.lyms.platform.biz.dal.impl; import com.lyms.platform.biz.dal.IOrganizationGroupsItemsDao; import com.lyms.platform.common.dao.BaseMongoDAOImpl; import com.lyms.platform.common.dao.operator.MongoQuery; +import com.lyms.platform.permission.model.Organization; import com.lyms.platform.pojo.OrganizationGroupsItems; import org.springframework.stereotype.Repository; @@ -30,4 +31,7 @@ public class OrganizationGroupsItemsDaoImpl extends BaseMongoDAOImpl queryList(OrganizationGroupsItemQuery mogoQuery) { + public List queryList(OrganizationGroupsItemQuery mogoQuery) + { MongoQuery mogo = mogoQuery.convertToQuery(); - if (StringUtils.isNotEmpty(mogoQuery.getNeed())) { + if (StringUtils.isNotEmpty(mogoQuery.getNeed())) + { mogoQuery.mysqlBuild(iOrganizationGroupsItemsDao.count(mogo)); mogo.start(mogoQuery.getOffset()).end(mogoQuery.getLimit()); } return iOrganizationGroupsItemsDao.queryList(mogo.addOrder(Sort.Direction.DESC, "modified")); } - public int count(OrganizationGroupsItemQuery mogoQuery) { + public int count(OrganizationGroupsItemQuery mogoQuery) + { MongoQuery mogo = mogoQuery.convertToQuery(); return iOrganizationGroupsItemsDao.count(mogo); } /** + * 获取单个机构组 + * + * @param id + * @return + */ + public OrganizationGroupsItems findById(String id) + { + return iOrganizationGroupsItemsDao.findById(id); + } + + /** * 增加一条记录 * * @param groupsItems * @return */ - public OrganizationGroupsItems addOneEntity(OrganizationGroupsItems groupsItems) { + public OrganizationGroupsItems addOneEntity(OrganizationGroupsItems groupsItems) + { groupsItems.setCreated(new Date()); groupsItems.setModified(new Date()); return iOrganizationGroupsItemsDao.addOneEntity(groupsItems); diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/OrganizationGroupsItems.java b/platform-dal/src/main/java/com/lyms/platform/pojo/OrganizationGroupsItems.java index ce9ec50..4124d08 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/OrganizationGroupsItems.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/OrganizationGroupsItems.java @@ -9,7 +9,7 @@ import java.util.List; /** * 机构组项目 * - * + * @link TicketTypeEnums * Created by Administrator on 2016/12/21 0021. */ @Document(collection = "lyms_group_items") @@ -26,11 +26,23 @@ public class OrganizationGroupsItems extends BaseModel { private Integer type; //选择的医院 private List hId; + //@link TicketTypeEnums + private Integer ticketType; private Date created; private Date modified; + public Integer getTicketType() + { + return ticketType; + } + + public void setTicketType(Integer ticketType) + { + this.ticketType = ticketType; + } + public String getGroupId() { return groupId; } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java index bcbe59c..9760a13 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java @@ -271,21 +271,31 @@ public class BookbuildingFacade { areaCodeQuery.setYn(YnEnums.YES.getId()); List code = areaCodeService.queryList(areaCodeQuery); AreaCodeModel areaCode = null; - if (CollectionUtils.isNotEmpty(code)) { - areaCode = code.get(0); - } - if (null != areaCode&&StringUtils.isNotEmpty(areaCode.getAreaCode())) { - // 建档成功后,给孕妇造五个条形码 - String ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode()); - for (Integer i = PatientCheckTicketFacade.complyCurrentDay(p.getLastMenses()); i <= 5; i++) { - PatientCheckTicket ticket = new PatientCheckTicket(); - ticket.setStatus(1); - ticket.setHospitalId(p.getHospitalId()); - ticket.setPatientId(p.getId()); - ticket.setCreated(new Date()); - ticket.setId(areaCode.getAreaCode() + ticketPid + i); - ticket.setPid(p.getPid()); - patientCheckTicketService.addTicket(ticket); + + + String groupId= groupsFacade.findByCurrentUserId(autoMatchFacade.getHospitalId(userId)); + if(org.apache.commons.lang.StringUtils.isNotEmpty(groupId)){ + OrganizationGroupsItems groupsItems = groupsFacade.findById(groupId); + if(null!=groupsItems){ + if (CollectionUtils.isNotEmpty(code)) { + areaCode = code.get(0); + } + if (null != areaCode&&StringUtils.isNotEmpty(areaCode.getAreaCode())) { + // 建档成功后,给孕妇造五个条形码 + String ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode()); + + int start = TicketTypeEnums.TICKTE_ALL.getType().equals(groupsItems.getTicketType()) ?0:PatientCheckTicketFacade.complyCurrentDay(p.getLastMenses()); + for (Integer i =start; i <= 5; i++) { + PatientCheckTicket ticket = new PatientCheckTicket(); + ticket.setStatus(1); + ticket.setHospitalId(p.getHospitalId()); + ticket.setPatientId(p.getId()); + ticket.setCreated(new Date()); + ticket.setId(areaCode.getAreaCode() + ticketPid + i); + ticket.setPid(p.getPid()); + patientCheckTicketService.addTicket(ticket); + } + } } } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/OrganizationGroupsFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/OrganizationGroupsFacade.java index 2dc06e1..6da6bae 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/OrganizationGroupsFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/OrganizationGroupsFacade.java @@ -39,6 +39,11 @@ public class OrganizationGroupsFacade { @Autowired private OrganizationService organizationService; + + public OrganizationGroupsItems findById(String id){ + return groupsItemService.findById(id); + } + /** * 增加一个分组 * diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java index b39bf50..59f9e33 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import com.lyms.platform.common.enums.TicketTypeEnums; +import com.lyms.platform.pojo.OrganizationGroupsItems; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -34,43 +36,48 @@ import com.lyms.platform.query.PatientsQuery; *

* 补发规则: *

- * 当前孕周   <= 孕12周+6天 补发1、2、3、4、5券 
- * 孕12周+6天 < 当前孕周 <= 孕20周+6天 补发2、3、4、5券 
- * 孕20周+6天 < 当前孕周 <= 孕24周+6天 补发3、4、5券 
- * 孕24周+6天 < 当前孕周 <= 孕36周+6天 补发4、5券 
+ * 当前孕周   <= 孕12周+6天 补发1、2、3、4、5券
+ * 孕12周+6天 < 当前孕周 <= 孕20周+6天 补发2、3、4、5券
+ * 孕20周+6天 < 当前孕周 <= 孕24周+6天 补发3、4、5券
+ * 孕24周+6天 < 当前孕周 <= 孕36周+6天 补发4、5券
  * 孕36周+6天 <当前孕周 <= 孕40周+6天 补发5券
  * 
  * 

* Created by Administrator on 2017/1/5 0005. */ @Component -public class PatientCheckTicketFacade { +public class PatientCheckTicketFacade +{ @Autowired private PatientCheckTicketService checkTicketServicel; @Autowired - private PatientsService patientsService; + private PatientsService patientsService; @Autowired - private AreaCodeService areaCodeService; + private AreaCodeService areaCodeService; @Autowired - private AutoIncermentService autoIncermentService; + private AutoIncermentService autoIncermentService; @Autowired - private OrganizationService organizationService; + private OrganizationService organizationService; @Autowired @Qualifier("commonThreadPool") - private ThreadPoolTaskExecutor commonThreadPool; + private ThreadPoolTaskExecutor commonThreadPool; + + @Autowired + private OrganizationGroupsFacade groupsFacade; /** * 补发以前建档的产检劵 - * + * * @return */ - public BaseResponse supplyCheckTicket(String hId) { + public BaseResponse supplyCheckTicket(String hId) + { PatientsQuery patientsQuery1 = new PatientsQuery(); patientsQuery1.setHospitalId(hId); patientsQuery1.setYn(YnEnums.YES.getId()); @@ -85,9 +92,11 @@ public class PatientCheckTicketFacade { int batchSize = 400; int end = 0; - for (int i = 0; i < patientses.size(); i += batchSize) { + for (int i = 0; i < patientses.size(); i += batchSize) + { end = (end + batchSize); - if (end > patientses.size()) { + if (end > patientses.size()) + { end = patientses.size(); } commonThreadPool.execute(new SupplyCheckTicketThread(patientses.subList(i, end))); @@ -97,11 +106,12 @@ public class PatientCheckTicketFacade { /** * 补发单个建档的产检劵 - * + * * @param parentId * @return */ - public BaseResponse supplyCheckTicketByPatientId(String parentId) { + public BaseResponse supplyCheckTicketByPatientId(String parentId) + { Patients patients = patientsService.findOnePatientById(parentId); // 表示不是隐藏建档 @@ -114,15 +124,19 @@ public class PatientCheckTicketFacade { buildType.add(2); patientsQuery1.setBuildTypeList(buildType); - if (!"2".equals(patients.getEnable())) { + if (!"2".equals(patients.getEnable())) + { patientsQuery1.setId(parentId); - } else { + } else + { patientsQuery1.setPid(patients.getPid()); } List patientses = patientsService.queryPatient(patientsQuery1); - if (CollectionUtils.isNotEmpty(patientses)) { + if (CollectionUtils.isNotEmpty(patientses)) + { PatientCheckTicketQuery checkTicketQuery = new PatientCheckTicketQuery(); - for (Patients p : patientses) { + for (Patients p : patientses) + { checkTicketQuery.setPatientId(p.getId()); /** * 执行补发操作 @@ -133,66 +147,87 @@ public class PatientCheckTicketFacade { return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("操作成功."); } - private class SupplyCheckTicketThread extends Thread { + private class SupplyCheckTicketThread extends Thread + { private List patientses; - public SupplyCheckTicketThread(List patientses) { + public SupplyCheckTicketThread(List patientses) + { this.patientses = patientses; } @Override - public void run() { + public void run() + { PatientCheckTicketQuery checkTicketQuery = new PatientCheckTicketQuery(); - for (Patients p : patientses) { - try { + for (Patients p : patientses) + { + try + { checkTicketQuery.setPatientId(p.getId()); /** * 执行补发操作 */ doBiz(checkTicketQuery, p); - } catch (Exception e) { + } catch (Exception e) + { ExceptionUtils.catchException(e, "SupplyCheckTicketThread Error."); } } } } - private void doBiz(PatientCheckTicketQuery checkTicketQuery, Patients p) { - if (0 == checkTicketServicel.queryTicketCount(checkTicketQuery)) { + private void doBiz(PatientCheckTicketQuery checkTicketQuery, Patients p) + { + if (0 == checkTicketServicel.queryTicketCount(checkTicketQuery)) + { // 建档成功后,给孕妇造五个条形码 Organization organization = organizationService.getOrganization(Integer.valueOf(p.getHospitalId())); - if (null != organization) { + if (null != organization) + { AreaCodeQuery areaCodeQuery = new AreaCodeQuery(); areaCodeQuery.setAreaId(organization.getCityId()); areaCodeQuery.setYn(YnEnums.YES.getId()); List code = areaCodeService.queryList(areaCodeQuery); AreaCodeModel areaCode = null; - if (CollectionUtils.isNotEmpty(code)) { + if (CollectionUtils.isNotEmpty(code)) + { areaCode = code.get(0); } - if (null != areaCode && StringUtils.isNotEmpty(areaCode.getAreaCode())) { + if (null != areaCode && StringUtils.isNotEmpty(areaCode.getAreaCode())) + { String ticketPid = null; int index = 0; // 重试3次获取劵,取不到就失败 - do { + do + { index++; ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode()); } while (StringUtils.isEmpty(ticketPid) && index < 3); - if (StringUtils.isEmpty(ticketPid)) { + if (StringUtils.isEmpty(ticketPid)) + { ExceptionUtils.catchException(null, "补发产检劵失败.id : " + p.getId()); return; } - // 建档成功后,给孕妇造五个条形码 - for (Integer i = complyCurrentDay(p.getLastMenses()); i <= 5; i++) { - PatientCheckTicket ticket = new PatientCheckTicket(); - ticket.setStatus(1); - ticket.setHospitalId(p.getHospitalId()); - ticket.setPatientId(p.getId()); - ticket.setCreated(new Date()); - ticket.setId(areaCode.getAreaCode() + ticketPid + i); - ticket.setPid(p.getPid()); - checkTicketServicel.addTicket(ticket); + + String groupId = groupsFacade.findByCurrentUserId(p.getHospitalId()); + if (org.apache.commons.lang.StringUtils.isNotEmpty(groupId)) + { + OrganizationGroupsItems groupsItems = groupsFacade.findById(groupId); + // 建档成功后,给孕妇造五个条形码 + int start = TicketTypeEnums.TICKTE_ALL.getType().equals(groupsItems.getTicketType()) ? 0 : PatientCheckTicketFacade.complyCurrentDay(p.getLastMenses()); + for (Integer i = start; i <= 5; i++) + { + PatientCheckTicket ticket = new PatientCheckTicket(); + ticket.setStatus(1); + ticket.setHospitalId(p.getHospitalId()); + ticket.setPatientId(p.getId()); + ticket.setCreated(new Date()); + ticket.setId(areaCode.getAreaCode() + ticketPid + i); + ticket.setPid(p.getPid()); + checkTicketServicel.addTicket(ticket); + } } } } @@ -201,12 +236,14 @@ public class PatientCheckTicketFacade { /** * 获取当前月经从第几期开始补发 - * + * * @param lastMess * @return */ - public static int complyCurrentDay(Date lastMess) { - if(null==lastMess){ + public static int complyCurrentDay(Date lastMess) + { + if (null == lastMess) + { return 0; } int day = DateUtil.getDays(lastMess, new Date());