1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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.stereotype.Component;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.List;
- import java.util.Map;
- /**
- * Created by CX on 2024/10/10.
- */
- @Component
- public class IncidentAssignManagerTask extends BaseTask {
- @Autowired
- SqlTask hospitalTask;
- @Autowired
- SqlTask departmentTask;
- @Autowired
- SqlTask userTask;
- @Autowired
- SqlTask groupTask;
- public static Log log = LogFactory.getLog(IncidentAssignManagerTask.class);
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void start() {
- log.info(" *** IncidentAssignManagerTask start 开始 *** ");
- StringBuffer sb = new StringBuffer();
- sb.append(" select * from itsm_incident_assign_manager ");
- List list = jdbcTemplateMdv2.queryForList(sb.toString());
- FieldMapper mapper = new FieldMapper();
- mapper.addOperationRemove("id").addOperationRemove("userOrGroupType").addOperationRemove("branch_id");
- mapper.addOperationUpdate("handle_group", "_group");
- mapper.addOperationUpdate("batch_no", "batch_id");
- mapper.addOperationUpdate("hos_id", "duty_id");
- mapper.addOperationReplace("duty_id", hospitalTask.loadCache().getIdCache());
- mapper.addOperationReplace("dept_id", departmentTask.loadCache().getIdCache());
- mapper.addOperationReplace("handle_user", userTask.loadCache().getIdCache());
- mapper.addOperationReplace("_group", groupTask.loadCache().getIdCache());
- mapper.trans2JdbcRow(list);
- JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
- jdbcUtil.batchPageInsert("itsm_itsm_incident_assign_manager", mapper.getRows());
- //clear释放内存
- mapper.clear();
- }
- @Override
- public FieldMapper loadCache() {
- log.info(" *** IncidentAssignManagerTask loadCache 开始 *** ");
- String sql = " select id,ACCOUNT,delete_flag from itsm_incident ";
- List<Map<String, Object>> list = jdbcTemplateHsms.queryForList(sql);
- sql = " select id,ACCOUNT,delete_flag from itsm_itsm_incident ";
- List<Map<String, Object>> list2 = jdbcTemplateMdv2.queryForList(sql);
- FieldMapper mapper = new FieldMapper();
- mapper.addFieldMapper("ACCOUNT", "ACCOUNT");
- mapper.addFieldMapper("delete_flag", "delete_flag");
- DataMigrationter.loadCache(list, list2, mapper);
- return mapper;
- }
- }
|