|
|
@@ -1,6 +1,5 @@
|
|
|
package com.lc.ibps.platform.plan.job;
|
|
|
|
|
|
-import com.lc.ibps.api.base.model.User;
|
|
|
import com.lc.ibps.base.core.constants.StringPool;
|
|
|
import com.lc.ibps.base.core.util.AppUtil;
|
|
|
import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
@@ -11,13 +10,15 @@ import com.lc.ibps.base.saas.token.ITenantTokenService;
|
|
|
import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.lc.ibps.bpmn.api.IBpmInstService;
|
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
|
-import com.lc.ibps.org.party.persistence.entity.DefaultPartyUserPo;
|
|
|
+import com.lc.ibps.platform.service.TenMinutesService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.quartz.JobDataMap;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@@ -28,7 +29,7 @@ public class TenMinutesJob extends AbstractJob{
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(TenMinutesJob.class);
|
|
|
private ICommonDao<?> commonDao = AppUtil.getBean(ICommonDao.class);
|
|
|
-
|
|
|
+ private TenMinutesService tenMinutesService = AppUtil.getBean(TenMinutesService.class);
|
|
|
|
|
|
@Override
|
|
|
public void executeJob(JobExecutionContext context) throws Exception {
|
|
|
@@ -40,11 +41,139 @@ public class TenMinutesJob extends AbstractJob{
|
|
|
logger.warn("jobDataMap=is {}.", JacksonUtil.toJsonString(dataMap.getWrappedMap()));
|
|
|
|
|
|
//任务1 开启 员工建议调查表 流程
|
|
|
- startYgjydcbFlow();
|
|
|
+ try {
|
|
|
+ startYgjydcbFlow();
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("执行员工建议调查表流程时发生异常", e);
|
|
|
+ }
|
|
|
//任务2 任务4293 新增一个定时 药敏试验人员比对-增加计划功能 都是十分钟执行一次所以和开启员工建议调查表流程放在一起,两个是不同的业务
|
|
|
// 如果以后某一个需要修改推送时间需要移出该定时
|
|
|
- startYmsyrydbFlow();
|
|
|
+ try {
|
|
|
+ startYmsyrydbFlow();
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("执行startYmsyrydbFlow任务时发生异常", e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ startBbrsrybdbFlow();
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("执行startBbrsrybdbFlow任务时发生异常", e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ startPersonnelComparisonFlow("t_smjzhjxqxsyrybdb","t_smjzhjxqxsyrybdxqb");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("执行沙门菌、志贺菌血清学试验人员比对列表流程时发生异常", e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ startPersonnelComparisonFlow("t_sgrsfyyqrsfbdb","t_sgrsfyyqrsfbdzb");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("执行手工染色法与仪器染色法比对列表流程时发生异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void startPersonnelComparisonFlow(String tableName, String zbTableName) throws Exception {
|
|
|
+ //1.0业务处理,只推送比对日期为当日且未推送过的数据
|
|
|
+ String fetchSql = "select * FROM "+tableName+" where type='startRecord' and DATE_FORMAT(bi_dui_ri_qi_,'%Y-%m-%d')=CURRENT_DATE and (flag_ is null or flag_=0)";
|
|
|
+ List<Map<String, Object>> qryList = (List<Map<String, Object>>) commonDao.query(fetchSql);
|
|
|
+ if (BeanUtils.isEmpty(qryList)) return;
|
|
|
+ for(Map<String, Object> zhubData : qryList){
|
|
|
+ Object bi_dui_ren_ ;
|
|
|
+ ArrayList<String> zbParentIds = new ArrayList<>();//子表对应主表的parent_id_集合
|
|
|
+ if(BeanUtils.isEmpty(bi_dui_ren_= zhubData.get("bi_dui_ren_"))){
|
|
|
+ throw new NullPointerException("bi_dui_ren_不允许为空");
|
|
|
+ }
|
|
|
+ String[] biDuiRenArray = bi_dui_ren_.toString().split(StringPool.COMMA);
|
|
|
+ for(String biDuiRen : biDuiRenArray){
|
|
|
+ insertYmsyrybdb(biDuiRen,zhubData,zbParentIds,tableName);
|
|
|
+ }
|
|
|
+ //拆分的数据全部插入数据库之后需要将元数据的flag_值设置为1
|
|
|
+ String execSql = "UPDATE "+tableName+" SET flag_ = '1' where id_= {p0} ";
|
|
|
+ String newExecSql = replaceSqlParams(execSql, zhubData.get("id_"));
|
|
|
+ commonDao.execute(newExecSql);
|
|
|
+ //更新子表
|
|
|
+ if(zbParentIds.size()>0){
|
|
|
+ UpZbData((String) zhubData.get("id_"),zbParentIds,zbTableName);
|
|
|
+ }
|
|
|
+ //2.0流程推送
|
|
|
+ if("t_smjzhjxqxsyrybdb".equals(tableName)){//标本染色人员比对表
|
|
|
+ startYmWorkflow(zbParentIds,"smjzhjxqxsyrybdb","Process_0co8uft");
|
|
|
+ }else if("t_sgrsfyyqrsfbdb".equals(tableName)){
|
|
|
+ startYmWorkflow(zbParentIds,"sgrsfyyqrsfbdb","Process_0c5tr9l");
|
|
|
+ }else{
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void startBbrsrybdbFlow() throws Exception {
|
|
|
+ //1.0业务处理,只推送比对日期为当日且未推送过的数据
|
|
|
+ String fetchSqlym = "select * FROM t_bbrsrybdb where type='startRecord' and DATE_FORMAT(bi_dui_ri_qi_,'%Y-%m-%d')=CURRENT_DATE and (flag_ is null or flag_=0)";
|
|
|
+ List<Map<String, Object>> qryList = (List<Map<String, Object>>) commonDao.query(fetchSqlym);
|
|
|
+ if (BeanUtils.isEmpty(qryList)) return;
|
|
|
+ for(Map<String, Object> zhubData : qryList){
|
|
|
+ Object bi_dui_ren_ ;
|
|
|
+ ArrayList<String> zbParentIds = new ArrayList<>();//子表对应主表的parent_id_集合
|
|
|
+ if(BeanUtils.isEmpty(bi_dui_ren_= zhubData.get("bi_dui_ren_"))){
|
|
|
+ throw new NullPointerException("bi_dui_ren_不允许为空");
|
|
|
+ }
|
|
|
+ String[] biDuiRenArray = bi_dui_ren_.toString().split(StringPool.COMMA);
|
|
|
+ for(String biDuiRen : biDuiRenArray){
|
|
|
+ insertYmsyrybdb(biDuiRen,zhubData,zbParentIds,"t_bbrsrybdb");
|
|
|
+ }
|
|
|
+ //拆分的数据全部插入数据库之后需要将元数据的flag_值设置为1
|
|
|
+ String execSql = "UPDATE t_bbrsrybdb SET flag_ = '1' where id_= {p0} ";
|
|
|
+ String newExecSql = replaceSqlParams(execSql, zhubData.get("id_"));
|
|
|
+ commonDao.execute(newExecSql);
|
|
|
+ //更新子表t_bbrsrybdbzb
|
|
|
+ if(zbParentIds.size()>0){
|
|
|
+ Upbbrsrybdbzb((String) zhubData.get("id_"),zbParentIds);
|
|
|
+ }
|
|
|
+ //2.0流程推送
|
|
|
+ String fangFaMingChen = zhubData.get("fang_fa_ming_chen").toString().trim();
|
|
|
+ if(BeanUtils.isEmpty(fangFaMingChen)){//标本染色人员比对表
|
|
|
+ startYmWorkflow(zbParentIds,"bbrsrybdb","Process_1ruhezs");
|
|
|
+ }else if("结核分枝杆菌抗原检测人员比对表".equals(fangFaMingChen)){
|
|
|
+ startYmWorkflow(zbParentIds,"jhfzgjkyjcrybdb","Process_2ruhezs");
|
|
|
+ }else if("培养结果判读人员比对表".equals(fangFaMingChen)){
|
|
|
+ startYmWorkflow(zbParentIds,"pyjgpdrybdb","Process_0w5e81t");
|
|
|
+ }else if("夜班人员微生物显微镜检查能力人员比对表".equals(fangFaMingChen)){
|
|
|
+ startYmWorkflow(zbParentIds,"ybrywswxwjjcnlrybdb","Process_17q1tcr");
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void UpZbData(String id_, ArrayList<String> zbParentIds,String tableName) throws Exception {
|
|
|
+ String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
+ String sqlJcjgxqb = "select * from "+tableName+" where parent_id_= {p0}";
|
|
|
+ List<Map<String, Object>> qryJcjgxqb = (List<Map<String, Object>>) commonDao.query(replaceSqlParams(sqlJcjgxqb,id_));
|
|
|
+ if(BeanUtils.isNotEmpty(qryJcjgxqb) && qryJcjgxqb.size()>0){
|
|
|
+ for(String zbParentId :zbParentIds){
|
|
|
+ for(Map<String, Object> jcjgxqbData : qryJcjgxqb){
|
|
|
+ String id = UniqueIdUtil.getId();
|
|
|
+ //需要重新修改的值
|
|
|
+ jcjgxqbData.put("id_", id);
|
|
|
+ jcjgxqbData.put("parent_id_", zbParentId);
|
|
|
+ jcjgxqbData.put("create_time_", currentTime);
|
|
|
+ commonDao.execute(buildInsertSql(jcjgxqbData,tableName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void Upbbrsrybdbzb(String id_, ArrayList<String> zbParentIds) throws Exception {
|
|
|
+ String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
+ String sqlJcjgxqb = "select * from t_bbrsrybdbzb where parent_id_= {p0}";
|
|
|
+ List<Map<String, Object>> qryJcjgxqb = (List<Map<String, Object>>) commonDao.query(replaceSqlParams(sqlJcjgxqb,id_));
|
|
|
+ if(BeanUtils.isNotEmpty(qryJcjgxqb) && qryJcjgxqb.size()>0){
|
|
|
+ for(String zbParentId :zbParentIds){
|
|
|
+ for(Map<String, Object> jcjgxqbData : qryJcjgxqb){
|
|
|
+ String id = UniqueIdUtil.getId();
|
|
|
+ //需要重新修改的值
|
|
|
+ jcjgxqbData.put("id_", id);
|
|
|
+ jcjgxqbData.put("parent_id_", zbParentId);
|
|
|
+ jcjgxqbData.put("create_time_", currentTime);
|
|
|
+ commonDao.execute(buildInsertSql(jcjgxqbData,"t_bbrsrybdbzb"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
/**
|
|
|
* 替换SQL中的占位符 {p0}、{p1} 为实际参数值
|
|
|
@@ -89,7 +218,7 @@ public class TenMinutesJob extends AbstractJob{
|
|
|
}
|
|
|
String[] biDuiRenArray = bi_dui_ren_.toString().split(StringPool.COMMA);
|
|
|
for(String biDuiRen : biDuiRenArray){
|
|
|
- insertYmsyrybdb(biDuiRen,zhubData,zbParentIds);
|
|
|
+ insertYmsyrybdb(biDuiRen,zhubData,zbParentIds,"t_ymsyrybdb");
|
|
|
}
|
|
|
//拆分的数据全部插入数据库之后需要将元数据的flag_值设置为1
|
|
|
String execSql = "UPDATE t_ymsyrybdb SET flag_ = '1' where id_= {p0} ";
|
|
|
@@ -154,7 +283,7 @@ public class TenMinutesJob extends AbstractJob{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<String> insertYmsyrybdb(String biDuiRen, Map<String, Object> map, ArrayList<String> zbParentIds) throws Exception {
|
|
|
+ private List<String> insertYmsyrybdb(String biDuiRen, Map<String, Object> map, ArrayList<String> zbParentIds,String tableName) throws Exception {
|
|
|
//深拷贝值
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
String id = UniqueIdUtil.getId();
|
|
|
@@ -172,12 +301,20 @@ public class TenMinutesJob extends AbstractJob{
|
|
|
//data.put("parent_id_",map.get("id_"));
|
|
|
//Map<String, Object> m1 = qryList.get(0);
|
|
|
//String s = (String) m1.get("NAME_");
|
|
|
- data.put("bi_dui_ren_ming_c",qryList.get(0).get("NAME_"));
|
|
|
- //修改编制人为比对人,前端流程审批管理页面候选人取值取得就是编制人
|
|
|
+ if("t_ymsyrybdb".equals(tableName) || "t_smjzhjxqxsyrybdb".equals(tableName)){
|
|
|
+ data.put("bi_dui_ren_ming_c",qryList.get(0).get("NAME_"));
|
|
|
+ }
|
|
|
+ if("t_bbrsrybdb".equals(tableName)){
|
|
|
+ data.put("liu_cheng_biao_ti","比对人:"+qryList.get(0).get("NAME_")+"; 比对时间:"+data.get("bi_dui_ri_qi_"));
|
|
|
+ }
|
|
|
+ if("t_sgrsfyyqrsfbdb".equals(tableName)){
|
|
|
+ data.put("pin_jie_zi_duan_","比对时间:"+data.get("bi_dui_ri_qi_")+ ",操作人:"+qryList.get(0).get("NAME_"));
|
|
|
+ }
|
|
|
+ //修改编制人为比对人,药敏试验人员比对前端流程审批管理页面候选人取值取得就是编制人
|
|
|
data.put("bian_zhi_ren_",data.get("bi_dui_ren_"));
|
|
|
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
data.put("create_time_", currentTime);
|
|
|
- commonDao.execute(buildInsertSql(data,"t_ymsyrybdb"));
|
|
|
+ commonDao.execute(buildInsertSql(data,tableName));
|
|
|
//执行成功后将生成的主表新数据的id登记下来作为子表的parent_id_
|
|
|
zbParentIds.add(id);
|
|
|
return zbParentIds;
|