CourseTableServiceImplTest.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.xjrsoft.module.courseTable.service.impl;
  2. import com.xjrsoft.XjrSoftApplication;
  3. import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
  4. import com.xjrsoft.module.courseTable.service.ICourseTableService;
  5. import com.xjrsoft.module.schedule.entity.WfCourseAdjust;
  6. import com.xjrsoft.module.schedule.service.IWfCourseAdjustService;
  7. import org.junit.jupiter.api.Test;
  8. import org.junit.runner.RunWith;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.boot.test.context.SpringBootTest;
  11. import org.springframework.test.context.junit4.SpringRunner;
  12. import java.util.List;
  13. import java.util.Map;
  14. import static org.junit.jupiter.api.Assertions.*;
  15. /**
  16. * @author dzx
  17. * @date 2024/12/9
  18. */
  19. @RunWith(SpringRunner.class)
  20. @SpringBootTest(classes = XjrSoftApplication.class)
  21. class CourseTableServiceImplTest {
  22. @Autowired
  23. private ICourseTableService courseTableService;
  24. @Autowired
  25. private IWfCourseAdjustService adjustService;
  26. @Test
  27. public void test(){
  28. String sql = "SELECT t1.* FROM wf_course_adjust t1\n" +
  29. "INNER JOIN xjr_workflow_form_relation t2 ON t1.id = t2.form_key_value\n" +
  30. "WHERE t2.current_state = 'COMPLETED'\n" +
  31. "AND t1.delete_mark = 0 AND t1.enabled_mark = 1\n" +
  32. "AND (t1.adjust_date > '2024-12-09' OR t1.exchange_date > '2024-12-09')\n" +
  33. "AND (\n" +
  34. "SELECT COUNT(*) FROM course_table a1\n" +
  35. "INNER JOIN course_table_bak a2 ON a1.key_info = a2.key_info\n" +
  36. "WHERE a2.wf_course_adjust_id = t1.id AND a1.adjust_type IS NULL\n" +
  37. ") > 0";
  38. List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
  39. for (Map<String, Object> objectMap : list) {
  40. long id = Long.parseLong(objectMap.get("id").toString());
  41. WfCourseAdjust courseAdjust = adjustService.getById(id);
  42. courseTableService.adjustCourse(courseAdjust);
  43. }
  44. }
  45. }