|
|
@@ -2,6 +2,7 @@ package org.jeecg.modules.medical.job;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.modules.medical.Constant;
|
|
|
import org.jeecg.modules.medical.afterwaring.XCFYDataTransferService;
|
|
|
import org.jeecg.modules.medical.entity.DiagnoseItems;
|
|
|
import org.jeecg.modules.medical.entity.HospitalizatioSettleDetail;
|
|
|
@@ -12,6 +13,7 @@ import org.quartz.Job;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.quartz.JobExecutionException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
@@ -23,57 +25,46 @@ import java.util.Map;
|
|
|
* 每个月执行一次
|
|
|
*/
|
|
|
@Slf4j
|
|
|
-public class XCFYDatav_diagnose_itemsJob implements Job {
|
|
|
+@Component
|
|
|
+public class XCFYDatav_diagnose_itemsJob {
|
|
|
|
|
|
@Autowired
|
|
|
XCFYDataTransferService xcfyDataTransferService;
|
|
|
@Autowired
|
|
|
IDiagnoseItemsService diagnoseItemsService;
|
|
|
|
|
|
- String insertSql = "INSERT INTO diagnose_items (id, diagnose_code, diagnose_name, medical_diagnose_code, medical_diagnose_name, state, CREATE_BY, CREATE_TIME) VALUES (:ID,:DIAGNOSE_CODE,:DIAGNOSE_NAME,:MEDICAL_DIAGNOSE_CODE,:MEDICAL_DIAGNOSE_NAME,:STATE,:CREATE_BY,:CREATE_TIME)";
|
|
|
+ String insertSql = "INSERT INTO diagnose_items_copy1 (diagnose_code, diagnose_name, medical_diagnose_code, " +
|
|
|
+ "medical_diagnose_name, state, CREATE_BY, CREATE_TIME) VALUES (:DIAGNOSE_CODE," +
|
|
|
+ ":DIAGNOSE_NAME,:MEDICAL_DIAGNOSE_CODE,:MEDICAL_DIAGNOSE_NAME,:STATE,:CREATE_BY,:CREATE_TIME) on duplicate key update " +
|
|
|
+ "MEDICAL_DIAGNOSE_CODE = :MEDICAL_DIAGNOSE_CODE," +
|
|
|
+ "MEDICAL_DIAGNOSE_NAME = :MEDICAL_DIAGNOSE_NAME," +
|
|
|
+ "DIAGNOSE_NAME = :DIAGNOSE_NAME,CREATE_TIME=:CREATE_TIME";
|
|
|
|
|
|
- @Override
|
|
|
+// @Override
|
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
- String sql = "select * from v_diagnose_items where rownum<1000 %s";
|
|
|
- while(true) {
|
|
|
- log.info("开始同步v_diagnose_items数据");
|
|
|
- String whereSql = "";
|
|
|
- Long hsdId = getLastId();
|
|
|
- log.info("开始同步v_diagnose_items数据,获取上个同步记录访问最大主键ID:{}", hsdId);
|
|
|
- Map<String,Object> paramMap = new HashMap<>();
|
|
|
- if(null != hsdId){
|
|
|
- whereSql = "and ID>:ID";
|
|
|
- paramMap.put("ID", hsdId);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- String querySql = String.format(sql, whereSql);
|
|
|
-
|
|
|
+ Integer startRows = 0;
|
|
|
+ Integer endRows = 1000;
|
|
|
+ String sql = "SELECT * FROM (SELECT A.*, ROWNUM RN FROM (SELECT * FROM V_DIAGNOSE_ITEMS) A WHERE ROWNUM < %s) WHERE RN >= %s";
|
|
|
+ while (true) {
|
|
|
+ log.info("开始同步v_diagnose_items数据 startRows:{} endRows:{}", startRows, endRows);
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ String querySql = String.format(sql, endRows, startRows);
|
|
|
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());
|
|
|
+ dataMap.put("STATE", Constant.EFF_STATE);
|
|
|
}
|
|
|
});
|
|
|
- if(count<=0){
|
|
|
- log.info("v_diagnose_items 没有大于id:{} 的数据,停止同步", hsdId);
|
|
|
+ if (count <= 0) {
|
|
|
+ log.info("v_diagnose_items 开始rownum:{} 结束rownum:{} 没有的数据,停止同步", startRows, endRows);
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ startRows = endRows;
|
|
|
+ endRows = endRows + 1000;
|
|
|
|
|
|
- public Long getLastId(){
|
|
|
- List<DiagnoseItems> diagnoseItems = diagnoseItemsService.lambdaQuery().orderByDesc(DiagnoseItems::getId).last("limit 1").list();
|
|
|
- if(CollectionUtil.isEmpty(diagnoseItems)){
|
|
|
- return null;
|
|
|
}
|
|
|
- return diagnoseItems.get(0).getId();
|
|
|
}
|
|
|
|
|
|
-// @Async("commonTaskAsyncPool")
|
|
|
-// public void statictisRuleByRuleEngine(MedicalInsRuleInfo medicalInsRuleInfo) {
|
|
|
-// ruleEngine.runStatictisEngine(new HashMap<>(), medicalInsRuleInfo);
|
|
|
-// }
|
|
|
}
|