XyGroupTask.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.dashitech.migration.task.uc;
  2. import com.dashitech.migration.BaseTask;
  3. import com.dashitech.migration.core.FieldMapper;
  4. import com.dashitech.migration.util.JdbcUtil;
  5. import org.apache.commons.logging.Log;
  6. import org.apache.commons.logging.LogFactory;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Component;
  9. import org.springframework.transaction.annotation.Transactional;
  10. import java.util.List;
  11. import java.util.Map;
  12. /**
  13. * @author song
  14. * @date 2024年10月12日
  15. */
  16. @Component
  17. public class XyGroupTask extends BaseTask {
  18. public static Log log = LogFactory.getLog(XyGroupTask.class);
  19. @Autowired
  20. private HospitalTask hospitalTask;
  21. @Override
  22. @Transactional
  23. public void start() {
  24. log.info(" *** 襄阳工作组group转换开始 *** ");
  25. StringBuffer sql = new StringBuffer("select 0 as version,a.groupname,a.delete_flag,a.duty_id ,now() as operator_time,1 as schedule_class_id");
  26. sql.append(" from itsm_uc_groups a join itsm_uc_duty_dept b on a.duty_id = b.id ");
  27. sql.append("where b.dept not like 'Z%' and dept not like '%保卫%' and b.id not in (20,21)");
  28. List<Map<String, Object>> groupList = jdbcTemplateMdv2.queryForList(sql.toString());
  29. //测试
  30. FieldMapper mapper = new FieldMapper();
  31. mapper.addOperationUpdate("_hospital_id", "duty_id");
  32. mapper.addOperationAdd("type", 3);
  33. Map<Long, Long> hosIdCache = hospitalTask.loadXiangyangCache().getIdCache();
  34. mapper.addOperationReplace("duty_id", hosIdCache);
  35. mapper.trans2JdbcRow(groupList);
  36. JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
  37. jdbcUtil.batchPageInsert("itsm_uc_groups", mapper.getRows());
  38. //clear释放内存
  39. mapper.clear();
  40. }
  41. @Override
  42. public FieldMapper loadCache() {
  43. return null;
  44. }
  45. }