12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package com.dashitech.migration.task.solution;
- import com.dashitech.migration.BaseTask;
- import com.dashitech.migration.core.FieldMapper;
- import com.dashitech.migration.task.other.DictionaryTask;
- import com.dashitech.migration.task.uc.HospitalTask;
- 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;
- /**
- * @author song
- * @date 2024年10月12日
- */
- @Component
- public class SolutionTask extends BaseTask {
- private Log log = LogFactory.getLog(SolutionTask.class);
- @Autowired
- HospitalTask hospitalTask;
- @Autowired
- DictionaryTask dictionaryTask;
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void start() {
- log.info("知识库数据SolutionTask转换开始");
- StringBuffer sql = new StringBuffer("SELECT id,version,case when categoryId is null then "+getDicId(jdbcTemplateHsms,"solution_type","3")+" else "+getDicId(jdbcTemplateHsms,"solution_type","1")+" end as type,");
- sql.append("title,keywords,content,status,create_user_id,createtime as create_time,renew_user_id,renewtime as renew_time,solutionnumber as solution_number,");
- sql.append("version_number,star,categoryId as category_id,introduce_count,file_abstract,duty_dept as hos_id,IF( `status` = 74, 1, 0 ) AS delete_flag FROM itsm_solution");
- List<Map<String, Object>> solutionList = jdbcTemplateMdv2.queryForList(sql.toString());
- FieldMapper mapper = new FieldMapper();
- Map<Long, Long> hosIdCache = hospitalTask.loadCache().getIdCache();
- Map<Long, Long> dicIdCache = dictionaryTask.loadCache().getIdCache();
- mapper.addOperationReplace("hos_id", hosIdCache);
- mapper.addOperationReplace("status", dicIdCache);
- mapper.trans2JdbcRow(solutionList);
- JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
- jdbcUtil.batchPageInsert("itsm_itsm_solution", mapper.getRows());
- //clear释放内存
- mapper.clear();
- }
- @Override
- public FieldMapper loadCache() {
- return null;
- }
- }
|