feat: 湛江附属首页编目添加出院日期条件配置,湛江附属费用清单队列配置

master
wyb 1 year ago
parent 0e37ab26f7
commit 6ae6691a91

@ -2,5 +2,6 @@
"lastDate": "2024-08-13 00:00:00",
"jobIntervalSeconds": 300,
"sysCodes":"catalog",
"open": 1
"open": 1,
"where":"AND discharge_date_time >=TO_DATE('2024-07-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') "
}

@ -0,0 +1,7 @@
{
"lastDate": "2024-08-13 00:00:00",
"delayDays": 1,
"jobIntervalSeconds": 43200,
"sysCodes":"costlist",
"open": 1
}

@ -19,4 +19,6 @@ public interface ArchiveMasterMapper {
* @return
*/
List<ArchiveMaster> listByCondition(@Param("condition") ArchiveMaster condition);
List<ArchiveMaster> listByNoCollectTaskAndGeDisDate(@Param("disDate")String disDate,@Param("sysCode")String sysCode);
}

@ -1,6 +1,7 @@
package com.docus.server.jobadmin.scheduler;
import com.docus.server.jobadmin.thread.ZjFsCatalogCollectTaskHelper;
import com.docus.server.jobadmin.thread.ZjFsCostListCollectTaskHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -15,6 +16,7 @@ public class JobScheduler {
public void init() throws Exception {
ZjFsCatalogCollectTaskHelper.getInstance().start();
ZjFsCostListCollectTaskHelper.getInstance().start();
logger.info(">>>>>>>>> init job admin success.");
}
@ -22,5 +24,6 @@ public class JobScheduler {
public void destroy() {
ZjFsCatalogCollectTaskHelper.getInstance().toStop();
ZjFsCostListCollectTaskHelper.getInstance().toStop();
}
}

@ -52,6 +52,10 @@ public class ZjFsCatalogCollectTaskHelper {
int jobIntervalSeconds = jobConfig.getIntValue("jobIntervalSeconds");
String lastDate = jobConfig.getString("lastDate");
String sysCodes = jobConfig.getString("sysCodes");
String where = jobConfig.getString("where");
if (where == null) {
where = "";
}
int open = jobConfig.getIntValue("open");
if (open == 0) {
TimeUnit.SECONDS.sleep(60);
@ -61,9 +65,9 @@ public class ZjFsCatalogCollectTaskHelper {
Date maxCatalogDate = zjFsPatIndexViewMapper.maxCatalogDate();
String maxCatalogDateStr = Func.formatDateTime(maxCatalogDate);
// 查询视图数据视图数据查询患者信息id进行任务生成
List<ZjFsPatIndexView> zjFsPatIndexViews = zjFsPatIndexViewMapper.listByCatalogDateRange(lastDate, maxCatalogDateStr);
List<ZjFsPatIndexView> zjFsPatIndexViews = zjFsPatIndexViewMapper.listByCatalogDateRange(lastDate, maxCatalogDateStr, where);
if (Func.isNotEmpty(zjFsPatIndexViews)) {
logger.info("首页编目数据查询,根据最后编目时间查询(不包含截止时间),开始时间:{},截止时间:{},视图数据:{} 条,数据为:{}", lastDate, maxCatalogDateStr, zjFsPatIndexViews.size(), Func.toJson(zjFsPatIndexViews));
logger.info("首页编目数据查询,根据最后编目时间查询(不包含截止时间),开始时间:{},截止时间:{},额外条件:{},视图数据:{} 条,数据为:{}", lastDate, maxCatalogDateStr, where, zjFsPatIndexViews.size(), Func.toJson(zjFsPatIndexViews));
for (ZjFsPatIndexView view : zjFsPatIndexViews) {
String inpNo = view.getInpNo();
Integer visitId = view.getVisitId();

@ -0,0 +1,124 @@
package com.docus.server.jobadmin.thread;
import com.alibaba.fastjson.JSONObject;
import com.docus.core.util.Func;
import com.docus.infrastructure.core.utils.TableJsonRead;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.archivesqlserver.entity.ArchiveMaster;
import com.docus.server.archivesqlserver.mapper.ArchiveMasterMapper;
import com.docus.server.jobadmin.config.JobAdminConfig;
import com.docus.server.rpc.V2ViewTaskCollectService;
import com.docus.server.rpc.dto.TaskMakeupDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* job
*
* @author YongBin Wen
* @date 2024/1/23 10:59
*/
public class ZjFsCostListCollectTaskHelper {
private static final Logger logger = LoggerFactory.getLogger(ZjFsCostListCollectTaskHelper.class);
private static final ZjFsCostListCollectTaskHelper instance = new ZjFsCostListCollectTaskHelper();
public static ZjFsCostListCollectTaskHelper getInstance() {
return instance;
}
private Thread zjFsCostListCollectTaskThread;
private volatile boolean toStop = false;
public void start() {
zjFsCostListCollectTaskThread = new Thread(() -> {
TableJsonRead tableJsonRead = new TableJsonRead();
ArchiveMasterMapper archiveMasterMapper = JobAdminConfig.getJobAdminConfig().getArchiveMasterMapper();
V2ViewTaskCollectService v2ViewTaskCollectService = JobAdminConfig.getJobAdminConfig().getV2ViewTaskCollectService();
String configPath = "data-config\\jobconfig";
String configFileName = "ZjFsCostListCollectTask";
while (!toStop) {
try {
LocalDateTime runTime = LocalDateTime.now();
// 读取配置,实时观察配置文件状况
JSONObject jobConfig = tableJsonRead.Read(configPath, configFileName, JSONObject.class);
int jobIntervalSeconds = jobConfig.getIntValue("jobIntervalSeconds");
String lastDate = jobConfig.getString("lastDate");
String sysCodes = jobConfig.getString("sysCodes");
int delayDays = jobConfig.getIntValue("delayDays");
LocalDateTime nextSelectDateTime = runTime.plusDays(-delayDays);
int open = jobConfig.getIntValue("open");
if (open == 0) {
TimeUnit.SECONDS.sleep(60);
continue;
}
// 下次执行的开始时间为现在时间减去间隔时间
String nextSelectDateTimeStr=Func.formatDateTime(nextSelectDateTime);
if(Func.isBlank(lastDate)){
lastDate=nextSelectDateTimeStr;
}
// 查询视图数据视图数据查询患者信息id进行任务生成
List<ArchiveMaster> archiveMasterList = archiveMasterMapper.listByNoCollectTaskAndGeDisDate(lastDate, sysCodes);
if (archiveMasterList == null) {
archiveMasterList = new ArrayList<>();
}
logger.info("查询未生成费用清单队列 {} 的患者基础数据,出院时间大于等于 {} 的数据有 {} 条,数据为:{}",sysCodes,lastDate,archiveMasterList.size(),Func.toJson(archiveMasterList));
if (!archiveMasterList.isEmpty()) {
// 生成采集任务
List<String> masterIds = archiveMasterList.stream().map(ArchiveMaster::getId).collect(Collectors.toList());
TaskMakeupDto makeupDto = new TaskMakeupDto();
makeupDto.setPatientIds(masterIds);
makeupDto.setSysCodes(sysCodes);
logger.info("费用清单生成队列参数:{}", Func.toJson(makeupDto));
CommonResult<String> result = v2ViewTaskCollectService.generateTaskByPatientIdAndSysCodes(makeupDto);
logger.info("费用清单生成队列返回结果:{}", Func.toJson(result));
}
// 刷新配置
jobConfig.put("lastDate", nextSelectDateTimeStr);
tableJsonRead.Save(configPath, configFileName, jobConfig.toJSONString());
TimeUnit.SECONDS.sleep(jobIntervalSeconds);
} catch (Exception ex) {
if (!toStop) {
logger.error(">>>>>>>>>>> zjFs CostList CollectTask Thread error:" + ex.getMessage(), ex);
try {
TimeUnit.SECONDS.sleep(60);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
logger.info(">>>>>>>>>>> zjFs CostList CollectTask Thread stop");
});
zjFsCostListCollectTaskThread.setDaemon(true);
zjFsCostListCollectTaskThread.setName("ZjFsCostListCollectTaskHelper");
zjFsCostListCollectTaskThread.start();
}
public void toStop() {
toStop = false;
zjFsCostListCollectTaskThread.interrupt();
try {
zjFsCostListCollectTaskThread.join();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
public static void main(String[] args) {
TableJsonRead tableJsonRead = new TableJsonRead();
JSONObject config = tableJsonRead.Read("data-config\\jobconfig", "ZjFsCatalogCollectTask", JSONObject.class);
System.out.println(config);
}
}

@ -25,7 +25,8 @@ public interface ZjFsPatIndexViewMapper {
*
* @param startDate yyyy-MM-dd HH:mm:ss
* @param endDate yyyy-MM-dd HH:mm:ss
* @param where
* @return
*/
List<ZjFsPatIndexView> listByCatalogDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate);
List<ZjFsPatIndexView> listByCatalogDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate,@Param("where")String where);
}

@ -25,4 +25,18 @@
</where>
</select>
<select id="listByNoCollectTaskAndGeDisDate"
resultType="com.docus.server.archivesqlserver.entity.ArchiveMaster">
select master.id,
master.inp_no as inpNo,
master.visit_id as visitId
from dbo.Archive_Master master
where master.discharge_date_time >= #{disDate}
and id not in (
select
MasterID
from dbo.archive_collect_task task
where sysflag=#{sysCode}
)
</select>
</mapper>

@ -16,6 +16,7 @@
from jhemr.v_pat_index
where catalog_date >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss')
and catalog_date <![CDATA[<]]> TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss')
${where}
order by catalog_date
</select>
<select id="maxCatalogDate" resultType="java.util.Date">

Loading…
Cancel
Save