|
|
@@ -0,0 +1,91 @@
|
|
|
+package org.jeecg.modules.medical.job;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jeecg.modules.medical.afterwaring.XCFYDataTransferService;
|
|
|
+import org.jeecg.modules.medical.common.CommonUtil;
|
|
|
+import org.jeecg.modules.medical.ruleengine.TransferDataCallFunction;
|
|
|
+import org.quartz.Job;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.quartz.JobExecutionException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 门诊结算主单 增量同步
|
|
|
+ * 执行频率:每天执行1次
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+public class XCFYDatav_outpatient_settle_billJob implements Job {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ XCFYDataTransferService xcfyDataTransferService;
|
|
|
+ @Autowired
|
|
|
+ JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ String insertSql = "INSERT INTO outpatient_settle_bill (id, hisid, visit_no, recipe_no, pay_method, " +
|
|
|
+ "bmi_area_id, bmi_area_name, hospital_id, hospital_name, p_level_yy, benefit_type, " +
|
|
|
+ "admission_dept_id, admission_dept_name, doctor_id, doctor_name, refund_falge, " +
|
|
|
+ "fee_ocur_time, bill_date, refund_date, patient_id, patient_name, patient_gender, " +
|
|
|
+ "patient_birthday, patient_age, visit_time, benefit_group_id, claim_type, if_local_flag, " +
|
|
|
+ "admission_disease_id, admission_disease_name, medfee_sumamt, fulamt_ownpay_amt, " +
|
|
|
+ "overlmt_selfpay, preselfpay_amt, inscp_scp_amt, act_pay_dedc, hifp_pay, pool_prop_selfpay, " +
|
|
|
+ "cvlserv_pay, hifes_pay, hifmi_pay, hifob_pay, maf_pay, oth_pay, fund_pay_sumamt, " +
|
|
|
+ "create_time, create_by) VALUES (:ID,:HISID,:VISIT_NO,:RECIPE_NO,:PAY_METHOD,:BMI_AREA_ID," +
|
|
|
+ ":BMI_AREA_NAME,:HOSPITAL_ID,:HOSPITAL_NAME,:P_LEVEL_YY,:BENEFIT_TYPE,:ADMISSION_DEPT_ID," +
|
|
|
+ ":ADMISSION_DEPT_NAME,:DOCTOR_ID,:DOCTOR_NAME,:REFUND_FALGE,:FEE_OCUR_TIME,:BILL_DATE," +
|
|
|
+ ":REFUND_DATE,:PATIENT_ID,:PATIENT_NAME,:PATIENT_GENDER,:PATIENT_BIRTHDAY,:PATIENT_AGE," +
|
|
|
+ ":VISIT_TIME,:BENEFIT_GROUP_ID,:CLAIM_TYPE,:IF_LOCAL_FLAG,:ADMISSION_DISEASE_ID," +
|
|
|
+ ":ADMISSION_DISEASE_NAME,:MEDFEE_SUMAMT,:FULAMT_OWNPAY_AMT,:OVERLMT_SELFPAY,:PRESELFPAY_AMT," +
|
|
|
+ ":INSCP_SCP_AMT,:ACT_PAY_DEDC,:HIFP_PAY,:POOL_PROP_SELFPAY,:CVLSERV_PAY,:HIFES_PAY,:HIFMI_PAY," +
|
|
|
+ ":HIFOB_PAY,:MAF_PAY,:OTH_PAY,:FUND_PAY_SUMAMT,:CREATE_TIME,:CREATE_BY)";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
+ String sql = "select * from V_OUTPATIENT_SETTLE_BILL where rownum<1000 %s";
|
|
|
+ while (true) {
|
|
|
+ log.info("开始同步v_outpatient_settle_bill数据");
|
|
|
+ String whereSql = "";
|
|
|
+ Long hsdId = getLastId();
|
|
|
+ log.info("开始同步v_outpatient_settle_bill数据,获取上个同步记录访问最大主键ID:{}", hsdId);
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ if (null != hsdId && hsdId > 0) {
|
|
|
+ whereSql = "and ID>:ID";
|
|
|
+ paramMap.put("ID", hsdId);
|
|
|
+ }
|
|
|
+ String querySql = String.format(sql, whereSql);
|
|
|
+ Integer count = xcfyDataTransferService.transferDataList(querySql, insertSql, paramMap, new TransferDataCallFunction() {
|
|
|
+ @Override
|
|
|
+ public void transferData(Map<String, Object> dataMap) throws Exception {
|
|
|
+ dataMap.put("CREATE_BY", "auto");
|
|
|
+ dataMap.put("CREATE_TIME", new Date());
|
|
|
+// String itemIDHosp = dataMap.getOrDefault("ITEM_ID_HOSP", "").toString();
|
|
|
+// String itemId = dataMap.getOrDefault("ITEM_ID", "").toString();
|
|
|
+// if (StringUtils.isNotBlank(itemIDHosp) && StringUtils.isBlank(itemId)) {
|
|
|
+// String[] itemIdArr = CommonUtil.getMedicalCodeAndName(itemIDHosp);
|
|
|
+// if (null != itemIdArr) {
|
|
|
+// dataMap.put("ITEM_ID", itemIdArr[0]);
|
|
|
+// dataMap.put("ITEM_NAME", itemIdArr[1]);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (count <= 0) {
|
|
|
+ log.info("v_outpatient_settle_bill 大于ID:{} 没有的数据,停止同步", hsdId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public Long getLastId() {
|
|
|
+ Long id = jdbcTemplate.queryForObject("select max(id) as id from outpatient_settlement_bill", Long.class);
|
|
|
+ return id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|