SolutionIntroduceTask.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.dashitech.migration.task.solution;
  2. import com.dashitech.migration.BaseTask;
  3. import com.dashitech.migration.core.FieldMapper;
  4. import com.dashitech.migration.task.uc.UserTask;
  5. import com.dashitech.migration.util.JdbcUtil;
  6. import org.apache.commons.logging.Log;
  7. import org.apache.commons.logging.LogFactory;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Component;
  10. import org.springframework.transaction.annotation.Transactional;
  11. import java.util.List;
  12. import java.util.Map;
  13. /**
  14. * @author song
  15. * @date 2024年10月12日
  16. */
  17. @Component
  18. public class SolutionIntroduceTask extends BaseTask {
  19. private Log log = LogFactory.getLog(SolutionIntroduceTask.class);
  20. @Autowired
  21. private UserTask userTask;
  22. @Override
  23. @Transactional(rollbackFor = Exception.class)
  24. public void start() {
  25. log.info("知识库引用数据SolutionIntroduceTask转换开始");
  26. StringBuffer sql = new StringBuffer("select * from itsm_solution_introduce");
  27. List<Map<String, Object>> solutionStarList = jdbcTemplateMdv2.queryForList(sql.toString());
  28. FieldMapper mapper = new FieldMapper();
  29. Map<Long, Long> userIdCache = userTask.loadCache().getIdCache();
  30. mapper.addOperationReplace("user_id", userIdCache);
  31. mapper.trans2JdbcRow(solutionStarList);
  32. JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
  33. jdbcUtil.batchPageInsert("itsm_itsm_solution_introduce", mapper.getRows());
  34. }
  35. @Override
  36. public FieldMapper loadCache() {
  37. return null;
  38. }
  39. }