Quellcode durchsuchen

fix 修改接口

daiyihua vor 1 Jahr
Ursprung
Commit
c58509682a

+ 104 - 4
ywt-platform-outpatient-batch/src/main/java/com/ywt/outpatient/batch/jobhandler/OutpatientJob.java

@@ -2,27 +2,35 @@ package com.ywt.outpatient.batch.jobhandler;
 
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.ywt.biz.common.util.Checker;
+import com.ywt.biz.common.util.DateUtil;
 import com.ywt.biz.common.util.serializers.JsonSerializer;
+import com.ywt.gapi.Result;
 import com.ywt.gapi.ResultCode;
+import com.ywt.gapi.doctor.DoctorHisCode;
+import com.ywt.gapi.doctor.SaveDoctorHisCodeListRequest;
+import com.ywt.gapi.doctor.SaveDoctorHisCodeListResponse;
 import com.ywt.gapi.med_equip.MedEquipService;
 import com.ywt.gapi.med_equip.TriggerScheduledJobRequest;
+import com.ywt.gapi.system.*;
 import com.ywt.gapi.third.taihe.PhyPayOrderRequest;
 import com.ywt.gapi.third.taihe.PhyPayOrderResponse;
+import com.ywt.gapi.third.taihe.Schedule;
 import com.ywt.gapi.third.taihe.TaiheService;
+import com.ywt.outpatient.batch.models.DoctorHisCodePojo;
 import com.ywt.outpatient.domain.entity.center.CheckUpOrder;
 import com.ywt.outpatient.domain.entity.center.CheckUpOrderRepository;
 import com.ywt.outpatient.domain.models.enums.TriggerScheduledJobEnum;
 import com.ywt.outpatient.service.batch.DoctorHisCodeService;
+import com.ywt.outpatient.service.batch.DoctorServiceSrv;
+import com.ywt.outpatient.service.batch.SystemServiceSrv;
+import com.ywt.outpatient.service.batch.TaiheServiceSrv;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
+import java.util.*;
 
 /**
  * XxlJob开发示例(Bean模式)
@@ -51,6 +59,14 @@ public class OutpatientJob {
     @Autowired
     private DoctorHisCodeService doctorHisCodeService;
 
+    @Autowired
+    private TaiheServiceSrv taiheServiceSrv;
+
+    @Autowired
+    private SystemServiceSrv systemServiceSrv;
+
+    @Autowired
+    private DoctorServiceSrv doctorServiceSrv;
 
     /**
      * 得到amount分支之前的时间
@@ -124,4 +140,88 @@ public class OutpatientJob {
         }
     }
 
+    /**
+     * 每小时执行一次
+     * 0 0 1 * * ?
+     * 同步doctor_his_code 里面的信息
+     */
+    @XxlJob("syncDoctorHisCodeInfoJobHandler")
+    public void syncDoctorHisCodeInfoJobHandler() {
+        logger.info("In syncDoctorHisCodeInfoJobHandler - executing its JOB at " + new Date());
+        try {
+            List<DoctorHisCodePojo> doctorHisCodePojoList = new ArrayList<>();
+            List<DoctorHisCodePojo> byDoctorHisCodePojoList = syncDoctorHisCodeInfo(41, 541);
+            List<DoctorHisCodePojo> thDoctorHisCodePojoList = syncDoctorHisCodeInfo(12, 0);
+            if (!Checker.isNone(byDoctorHisCodePojoList)) {
+                doctorHisCodePojoList.addAll(byDoctorHisCodePojoList);
+            }
+            if (!Checker.isNone(thDoctorHisCodePojoList)) {
+                doctorHisCodePojoList.addAll(thDoctorHisCodePojoList);
+            }
+            if (Checker.isNone(doctorHisCodePojoList)) {
+                return;
+            }
+            // 对 doctorHisCodePojoList 进行去重(deptCode、hisCode、hospitalId)这三个能确定唯一
+            List newDoctorHisCodeList = new ArrayList<>();
+            Map map = new HashMap();
+            for (DoctorHisCodePojo pojo : doctorHisCodePojoList) {
+                String key = pojo.getDeptCode() + "_" + pojo.getHisCode() + "_" + pojo.getHospitalId();
+                if (Checker.isNone(map.get(key))) {
+                    map.put(key, key);
+                    DoctorHisCode doctorHisCode = DoctorHisCode.newBuilder()
+                            .setDoctorId(pojo.getDoctorId())
+                            .setHospitalId(pojo.getHospitalId())
+                            .setDeptCode(pojo.getDeptCode())
+                            .setDoctorCode(pojo.getHisCode())
+                            .setDoctorName(pojo.getDoctorName())
+                            .setDoctorJobNum(pojo.getDoctorJobNum())
+                            .build();
+                    newDoctorHisCodeList.add(doctorHisCode);
+                }
+            }
+            doctorServiceSrv.saveDoctorHisCodeList(newDoctorHisCodeList);
+        } catch (Exception e) {
+            logger.error("invoiceNotifyReturnEquipJobHandler.execute(): {}", e.getMessage(), e);
+        }
+    }
+
+
+    public List<DoctorHisCodePojo> syncDoctorHisCodeInfo(int hospitalId, int subHospitalId) throws Exception {
+        List<HospitalDept> deptList = systemServiceSrv.getHospitalDeptList(hospitalId, subHospitalId);
+        if (Checker.isNone(deptList)) {
+            return null;
+        }
+        List<Dept> secondDeptList = new ArrayList<>();
+        for (HospitalDept dept : deptList) {
+            if (!Checker.isNone(dept.getDeptListList())) {
+                secondDeptList.addAll(dept.getDeptListList());
+            }
+        }
+        if (Checker.isNone(secondDeptList)) {
+            return null;
+        }
+        List<DoctorHisCodePojo> doctorHisCodePojoList = new ArrayList<>();
+        for (Dept dept : secondDeptList) {
+            Calendar calendar = Calendar.getInstance();
+            String strDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
+            // 不包括今天
+            calendar.add(Calendar.DATE, 7);
+            // 日期
+            String endDate = DateUtil.formatDate(calendar.getTime(), "yyyy-MM-dd");
+            List<Schedule> scheduleList = taiheServiceSrv.getScheduleList(strDate, endDate, "", dept.getDeptCode(), hospitalId);
+            if (!Checker.isNone(scheduleList)) {
+                for (Schedule schedule : scheduleList) {
+                    DoctorHisCodePojo pojo = new DoctorHisCodePojo();
+                    pojo.setDeptCode(dept.getDeptCode());
+                    pojo.setDoctorId(0);
+                    pojo.setDoctorJobNum("");
+                    pojo.setDoctorName(schedule.getDoctorName());
+                    pojo.setHisCode(schedule.getDoctorCode());
+                    pojo.setHospitalId(hospitalId);
+                    doctorHisCodePojoList.add(pojo);
+                }
+            }
+        }
+        return doctorHisCodePojoList;
+    }
 }

+ 74 - 0
ywt-platform-outpatient-batch/src/main/java/com/ywt/outpatient/batch/models/DoctorHisCodePojo.java

@@ -0,0 +1,74 @@
+package com.ywt.outpatient.batch.models;
+
+/**
+ * @author daiyihua
+ * @create 2023-07-06 15:19
+ * @program dispatcher
+ * @description 科室对象
+ **/
+public class DoctorHisCodePojo {
+
+    private Integer doctorId;
+    private Integer hospitalId;
+    /**
+     * 科室编码
+     */
+    private String deptCode;
+    /**
+     * 医生HIS系统编码
+     */
+    private String hisCode;
+    private String doctorName;
+    /**
+     * 用于处方回写插入医嘱 & 诊断的医生代码
+     */
+    private String doctorJobNum;
+
+    public Integer getDoctorId() {
+        return doctorId;
+    }
+
+    public void setDoctorId(Integer doctorId) {
+        this.doctorId = doctorId;
+    }
+
+    public Integer getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Integer hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public String getDeptCode() {
+        return deptCode;
+    }
+
+    public void setDeptCode(String deptCode) {
+        this.deptCode = deptCode;
+    }
+
+    public String getDoctorName() {
+        return doctorName;
+    }
+
+    public void setDoctorName(String doctorName) {
+        this.doctorName = doctorName;
+    }
+
+    public String getHisCode() {
+        return hisCode;
+    }
+
+    public void setHisCode(String hisCode) {
+        this.hisCode = hisCode;
+    }
+
+    public String getDoctorJobNum() {
+        return doctorJobNum;
+    }
+
+    public void setDoctorJobNum(String doctorJobNum) {
+        this.doctorJobNum = doctorJobNum;
+    }
+}