Commit 956183c0666b8c9684f5704fcea17f753e1342ee

Authored by zhangchao
1 parent b9cd9b392b
Exists in luanping and in 1 other branch dev

#优化威县服务开通同步问题

Showing 8 changed files with 172 additions and 1 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/PatientServiceMapper.java View file @ 956183c
... ... @@ -30,6 +30,7 @@
30 30 */
31 31 List<Map> selectOnlyBzService(PatientServiceQuery query);
32 32  
  33 + List<Map<String,Object>> selectServiceByHospital(String hospitalId);
33 34  
34 35 int selectOnlyBzServiceCount(PatientServiceQuery query);
35 36  
platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientServiceQuery.java View file @ 956183c
... ... @@ -15,6 +15,7 @@
15 15 private String[] parentIds;
16 16 private String pid;
17 17 private Integer serType;
  18 + private Integer[] serTypes;
18 19 /**
19 20 * 服务人类型(1-孕妇、2-儿童)
20 21 */
... ... @@ -431,6 +432,14 @@
431 432  
432 433 public void setParentIds(String[] parentIds) {
433 434 this.parentIds = parentIds;
  435 + }
  436 +
  437 + public Integer[] getSerTypes() {
  438 + return serTypes;
  439 + }
  440 +
  441 + public void setSerTypes(Integer[] serTypes) {
  442 + this.serTypes = serTypes;
434 443 }
435 444 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/PatientServiceService.java View file @ 956183c
... ... @@ -20,7 +20,7 @@
20 20  
21 21 public List<PatientService> queryPatientService(PatientServiceQuery query);
22 22  
23   -
  23 + List<Map<String,Object>> selectServiceByHospital(String hospitalId);
24 24 List<Map> selectOnlyBzService(PatientServiceQuery query);
25 25  
26 26 List<Map> getPatientServices(Map map);
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/PatientServiceServiceImpl.java View file @ 956183c
... ... @@ -51,6 +51,11 @@
51 51 }
52 52  
53 53 @Override
  54 + public List<Map<String, Object>> selectServiceByHospital(String hospitalId) {
  55 + return patientServiceMapper.selectServiceByHospital(hospitalId);
  56 + }
  57 +
  58 + @Override
54 59 public List<Map> selectOnlyBzService(PatientServiceQuery query) {
55 60 if (query.getNeed() != null) {
56 61 query.mysqlBuild(patientServiceMapper.selectOnlyBzServiceCount(query));
platform-biz-service/src/main/resources/mainOrm/master/PatientService.xml View file @ 956183c
... ... @@ -218,6 +218,13 @@
218 218 <if test="serType != null and serType >= 0">
219 219 and ser_type = #{serType,jdbcType=INTEGER}
220 220 </if>
  221 + <if test="serTypes!=null">
  222 + and ser_type in (
  223 + <foreach item="serType" collection="serTypes" separator=",">
  224 + #{serType}
  225 + </foreach>
  226 + )
  227 + </if>
221 228 <if test="serDoct != null and serDoct != ''">
222 229 and ser_doct = #{serDoct,jdbcType=VARCHAR}
223 230 </if>
... ... @@ -634,6 +641,15 @@
634 641 where parentid = #{patientsId} and ser_status = 1 and per_type = #{patientType}
635 642 </select>
636 643  
  644 + <select id="selectServiceByHospital" resultType="java.util.HashMap">
  645 + SELECT
  646 + hso.ser_type as serType,hds.doct_id as doctId
  647 +FROM
  648 + `hospital_service_content` hso
  649 +INNER JOIN hospital_doct_service hds
  650 +on hso.id=hds.hosp_service_id
  651 +where hso.hospital_id=#{hospitalId} and hso.ser_type in (3,4,6)
  652 + </select>
637 653  
638 654 </mapper>
platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java View file @ 956183c
... ... @@ -29,6 +29,7 @@
29 29  
30 30 private String id;
31 31 private List<String> ids;
  32 + private List<String> idns;
32 33 private String pid;
33 34  
34 35 private List<String> pIds;
... ... @@ -891,6 +892,9 @@
891 892 if (CollectionUtils.isNotEmpty(ids)) {
892 893 condition = condition.and("id", ids, MongoOper.IN);
893 894 }
  895 + if (CollectionUtils.isNotEmpty(idns)) {
  896 + condition = condition.and("id", idns, MongoOper.NIN);
  897 + }
894 898  
895 899 if (null != vcCardNo) {
896 900 condition = condition.and("vcCardNo", vcCardNo, MongoOper.IS);
... ... @@ -2603,6 +2607,14 @@
2603 2607  
2604 2608 public void setTownOrgId(String townOrgId) {
2605 2609 this.townOrgId = townOrgId;
  2610 + }
  2611 +
  2612 + public List<String> getIdns() {
  2613 + return idns;
  2614 + }
  2615 +
  2616 + public void setIdns(List<String> idns) {
  2617 + this.idns = idns;
2606 2618 }
2607 2619 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java View file @ 956183c
... ... @@ -24,6 +24,8 @@
24 24 import com.lyms.platform.query.TServiceTimeRecordQuery;
25 25 import net.sf.json.JSONObject;
26 26 import org.apache.commons.collections.CollectionUtils;
  27 +import org.slf4j.Logger;
  28 +import org.slf4j.LoggerFactory;
27 29 import org.springframework.beans.factory.annotation.Autowired;
28 30 import org.springframework.stereotype.Component;
29 31  
... ... @@ -82,6 +84,8 @@
82 84 @Autowired
83 85 private AreaCountFacade areaCountFacade;
84 86  
  87 + private static Logger logger = LoggerFactory.getLogger(PatientServiceFacade.class);
  88 +
85 89 public BaseResponse babyServiceInit(Integer userId) {
86 90 Map map = new HashMap();
87 91 //服务类型
... ... @@ -292,6 +296,114 @@
292 296 baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
293 297 baseResponse.setErrormsg("成功");
294 298 return baseResponse;
  299 + }
  300 +
  301 + /**
  302 + * 威县开通服务同步任务
  303 + * 只同步 6围产小助理/3血糖管理服务/4血压管理服务
  304 + */
  305 + public void patientServiceSync(){
  306 + logger.info("patientServiceSync start");
  307 + String hospitalId="2100002421";
  308 + List<Map<String, Object>> mapList= patientServiceService.selectServiceByHospital(hospitalId);
  309 + if (CollectionUtils.isNotEmpty(mapList)){
  310 + Integer [] serTypes={3,4,6};
  311 + PatientServiceQuery patientQuery = new PatientServiceQuery();
  312 + patientQuery.setHospitalId(hospitalId);
  313 + patientQuery.setSerTypes(serTypes);
  314 + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
  315 +
  316 + PatientsQuery patientsQuery=new PatientsQuery();
  317 + patientsQuery.setHospitalId(hospitalId);
  318 + patientsQuery.setExtEnable(false);
  319 + patientsQuery.setBuildTypeNot(1);
  320 + patientsQuery.setYn(YnEnums.YES.getId());
  321 + if (CollectionUtils.isNotEmpty(patientServices)){
  322 + List<String> ids=new ArrayList<>();
  323 + for (int i = 0,j=patientServices.size(); i < j; i++) {
  324 + PatientService patientService= patientServices.get(i);
  325 + ids.add(patientService.getParentid());
  326 + }
  327 + patientsQuery.setIdns(ids);
  328 + }
  329 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  330 + if (CollectionUtils.isNotEmpty(patientsList)){
  331 + for (int i = 0,j=mapList.size(); i < j; i++) {
  332 + Map<String,Object> params= mapList.get(i);
  333 + Integer serType= Integer.parseInt(String.valueOf(params.get("serType")));
  334 + String createUser=String.valueOf(params.get("doctId"));
  335 + for (int k = 0,f=patientsList.size(); k < f; k++) {
  336 + Patients patients= patientsList.get(k);
  337 + String parentId= patients.getId();
  338 + //先根据孕妇id和开通服务类型、开通医生进行查询,如果已经开通过则开通失败
  339 + /* PatientServiceQuery patientQuery = new PatientServiceQuery();
  340 + patientQuery.setParentid(parentId);
  341 + patientQuery.setSerType(serType);
  342 + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
  343 + if (CollectionUtils.isNotEmpty(patientServices)) {
  344 + continue;
  345 + }*/
  346 + PatientService pser = new PatientService();
  347 + pser.setCreateUser(createUser);
  348 + pser.setCreateDate(patients.getCreated());
  349 + //设置服务对象类型 服务人类型(1-孕妇、2-儿童)
  350 + pser.setPerType(1);
  351 + pser.setPid(patients.getPid());
  352 + //如果有数据源id,取主档案id
  353 + if (StringUtils.isNotEmpty(patients.getSource())) {
  354 + pser.setParentid(patients.getSource());
  355 + }else {
  356 + pser.setParentid(parentId);
  357 + }
  358 + pser.setId(UUID.randomUUID().toString().replace("-", ""));
  359 + //开通医院
  360 + pser.setHospitalId(hospitalId);
  361 + //默认开通状态
  362 + pser.setSerStatus(PatientSerEnums.SerStatusEnums.kt.getId());
  363 + //服务类型
  364 + pser.setSerType(serType);
  365 + //默认已经领取
  366 + pser.setStatus(2);
  367 + //默认待同步
  368 + pser.setSynStatus(1);
  369 + //领取时间
  370 + pser.setReceiveDate(new Date());
  371 + //领取操作医生id
  372 + pser.setReceiveUser(createUser);
  373 + //服务开通操作时间
  374 + pser.setUpdateDate(new Date());
  375 + //服务开通操作人
  376 + pser.setUpdateUser(createUser);
  377 + //默认是全孕周42
  378 + pser.setDoctorWeek(42);
  379 + pser.setServiceWeek(42);
  380 +
  381 + setServiceRecordAdd(pser, patients);
  382 +
  383 + patientServiceService.addPatientService(pser);
  384 +
  385 + operateLogFacade.addAddOptLog(Integer.valueOf(createUser), Integer.valueOf(hospitalId), pser, OptActionEnums.ADD.getId(), "开通增值服务");
  386 +
  387 +
  388 + if (PatientSerEnums.SerTypeEnums.bzfw.getId().intValue() == serType) {
  389 + PatientServiceQuery query = new PatientServiceQuery();
  390 + query.setParentid(parentId);
  391 + query.setSerType(PatientSerEnums.SerTypeEnums.yqjzzd.getId());
  392 + int count = patientServiceService.queryPatientServiceCount(query);
  393 + //是否有增值服务--没有则处理标准服务
  394 + if (count == 0) {
  395 + Patients patient = new Patients();
  396 + patient.setServiceType(ServiceTypeEnums.STANDARD_SERVICE.getId());
  397 + patient.setServiceStatus(ServiceStatusEnums.STANDARD_OPEN.getId());
  398 + bookbuildingFacade.updatePatientSerById(parentId, patient);
  399 + }
  400 + }
  401 + }
  402 + }
  403 + logger.info("addPatientServiceAll end");
  404 + }
  405 + }
  406 + logger.info("patientServiceSync end");
295 407 }
296 408  
297 409 /**
platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml View file @ 956183c
... ... @@ -655,7 +655,21 @@
655 655 </bean>
656 656  
657 657  
  658 + <!--威县孕妇开通服务定时同步18点 -->
  659 + <bean id="patientServiceSyncWork" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  660 + <!-- 要调用的bean -->
  661 + <property name="targetObject" ref="patientServiceFacade"></property>
  662 + <!-- 要调用的Method -->
  663 + <property name="targetMethod" value="patientServiceSync"></property>
  664 + <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 -->
  665 + <property name="concurrent" value="false"></property>
  666 + </bean>
658 667  
  668 + <!-- 配置一个触发器 0 0 18 * * ?-->
  669 + <bean id="patientServiceSyncTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
  670 + <property name="jobDetail" ref="patientServiceSyncWork"></property>
  671 + <property name="cronExpression" value="0 5 17 * * ?"></property>
  672 + </bean>
659 673  
660 674  
661 675 <!-- 总调度,用于启动定时器 -->
... ... @@ -721,6 +735,8 @@
721 735 <ref bean="babyBuildClassifyTrigger"/>
722 736 <!-- 南和课程发布19点推送-->
723 737 <ref bean="coursesTrigger"/>
  738 + <!-- 威县孕妇开通服务同步-->
  739 + <ref bean="patientServiceSyncTrigger"/>
724 740 </list>
725 741 </property>
726 742 </bean>