IncidentTask.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package com.dashitech.migration.task.incident;
  2. import com.dashitech.migration.BaseTask;
  3. import com.dashitech.migration.SqlTask;
  4. import com.dashitech.migration.core.DataMigrationter;
  5. import com.dashitech.migration.core.FieldMapper;
  6. import com.dashitech.migration.util.JdbcUtil;
  7. import org.apache.commons.logging.Log;
  8. import org.apache.commons.logging.LogFactory;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.core.annotation.Order;
  11. import org.springframework.stereotype.Component;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import java.util.List;
  14. import java.util.Map;
  15. /**
  16. * Created by CX on 2024/10/10.
  17. */
  18. @Component
  19. @Order(4)
  20. public class IncidentTask extends BaseTask {
  21. @Autowired
  22. SqlTask hospitalTask;
  23. @Autowired
  24. SqlTask userTask;
  25. @Autowired
  26. SqlTask departmentTask;
  27. @Autowired
  28. SqlTask dictionaryTask;
  29. @Autowired
  30. SqlTask placeTask;
  31. public static Log log = LogFactory.getLog(IncidentTask.class);
  32. @Override
  33. @Transactional(rollbackFor = Exception.class)
  34. public void start() {
  35. log.info(" *** IncidentTask start 开始 *** ");
  36. StringBuffer sb = new StringBuffer();
  37. sb.append(" select * from itsm_incident ");
  38. List list = jdbcTemplateMdv2.queryForList(sb.toString());
  39. FieldMapper mapper = new FieldMapper();
  40. Map<Long, Long> userCache = userTask.loadCache().getIdCache();
  41. Map<Long, Long> dicCache = dictionaryTask.loadCache().getIdCache();
  42. mapper.addOperationRemove("emergencyid").addOperationRemove("influenceid");
  43. mapper.addOperationUpdate("priority_id", "priorityid");
  44. mapper.addOperationUpdate("hos_id", "branch_id");
  45. //襄阳id4-
  46. mapper.addOperationReplace("userid", userCache);
  47. mapper.addOperationReplace("close_userid", dicCache);
  48. mapper.addOperationReplace("close_codeid", dicCache);
  49. mapper.addOperationReplace("degreeid", dicCache);
  50. mapper.addOperationReplace("priorityid", dicCache);
  51. mapper.addOperationReplace("sourceid", dicCache);
  52. mapper.addOperationReplace("statusid", dicCache);
  53. mapper.addOperationReplace("handleresult", dicCache);
  54. mapper.addOperationReplace("handlecategory", dicCache);
  55. mapper.addOperationReplace("wxdegreeid", dicCache);
  56. mapper.addOperationReplace("requesterid", userCache);
  57. mapper.addOperationReplace("handleruserid", userCache);
  58. mapper.addOperationReplace("handlingPersonnelUserId", userCache);
  59. mapper.addOperationReplace("duty_id", hospitalTask.loadCache().getIdCache());
  60. //只有襄阳需要处理科室,南京不用
  61. if ("xiangyang".equals(appName)) {
  62. mapper.addOperationReplace("dept", departmentTask.loadCache().getIdCache());
  63. mapper.addOperationReplace("placeid", placeTask.loadCache().getIdCache());
  64. }
  65. mapper.trans2JdbcRow(list);
  66. JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
  67. jdbcUtil.batchPageInsert("itsm_itsm_incident", mapper.getRows());
  68. //clear释放内存
  69. mapper.clear();
  70. }
  71. @Override
  72. public FieldMapper loadCache() {
  73. log.info(" *** IncidentTask loadCache 开始 *** ");
  74. String sql = " select id,incidentsign from itsm_itsm_incident ";
  75. List<Map<String, Object>> list = jdbcTemplateHsms.queryForList(sql);
  76. sql = " select id,incidentsign from itsm_incident ";
  77. List<Map<String, Object>> list2 = jdbcTemplateMdv2.queryForList(sql);
  78. FieldMapper mapper = new FieldMapper();
  79. mapper.addFieldMapper("incidentsign", "incidentsign");
  80. DataMigrationter.loadCache(list, list2, mapper);
  81. return mapper;
  82. }
  83. }