package com.dashitech.migration.task.incident; import com.dashitech.migration.BaseTask; import com.dashitech.migration.SqlTask; import com.dashitech.migration.core.DataMigrationter; import com.dashitech.migration.core.FieldMapper; import com.dashitech.migration.util.JdbcUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Map; /** * Created by CX on 2024/10/10. */ @Component @Order(4) public class IncidentTask extends BaseTask { @Autowired SqlTask hospitalTask; @Autowired SqlTask userTask; @Autowired SqlTask departmentTask; @Autowired SqlTask dictionaryTask; @Autowired SqlTask placeTask; public static Log log = LogFactory.getLog(IncidentTask.class); @Override @Transactional(rollbackFor = Exception.class) public void start() { log.info(" *** IncidentTask start 开始 *** "); StringBuffer sb = new StringBuffer(); sb.append(" select * from itsm_incident "); List list = jdbcTemplateMdv2.queryForList(sb.toString()); FieldMapper mapper = new FieldMapper(); Map userCache = userTask.loadCache().getIdCache(); Map dicCache = dictionaryTask.loadCache().getIdCache(); mapper.addOperationRemove("emergencyid").addOperationRemove("influenceid"); mapper.addOperationUpdate("priority_id", "priorityid"); mapper.addOperationUpdate("hos_id", "branch_id"); //襄阳id4- mapper.addOperationReplace("userid", userCache); mapper.addOperationReplace("close_userid", dicCache); mapper.addOperationReplace("close_codeid", dicCache); mapper.addOperationReplace("degreeid", dicCache); mapper.addOperationReplace("priorityid", dicCache); mapper.addOperationReplace("sourceid", dicCache); mapper.addOperationReplace("statusid", dicCache); mapper.addOperationReplace("handleresult", dicCache); mapper.addOperationReplace("handlecategory", dicCache); mapper.addOperationReplace("wxdegreeid", dicCache); mapper.addOperationReplace("requesterid", userCache); mapper.addOperationReplace("handleruserid", userCache); mapper.addOperationReplace("handlingPersonnelUserId", userCache); mapper.addOperationReplace("duty_id", hospitalTask.loadCache().getIdCache()); //只有襄阳需要处理科室,南京不用 if ("xiangyang".equals(appName)) { mapper.addOperationReplace("dept", departmentTask.loadCache().getIdCache()); mapper.addOperationReplace("placeid", placeTask.loadCache().getIdCache()); } mapper.trans2JdbcRow(list); JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms); jdbcUtil.batchPageInsert("itsm_itsm_incident", mapper.getRows()); //clear释放内存 mapper.clear(); } @Override public FieldMapper loadCache() { log.info(" *** IncidentTask loadCache 开始 *** "); String sql = " select id,incidentsign from itsm_itsm_incident "; List> list = jdbcTemplateHsms.queryForList(sql); sql = " select id,incidentsign from itsm_incident "; List> list2 = jdbcTemplateMdv2.queryForList(sql); FieldMapper mapper = new FieldMapper(); mapper.addFieldMapper("incidentsign", "incidentsign"); DataMigrationter.loadCache(list, list2, mapper); return mapper; } }