package com.xjrsoft.module.courseTable.service.impl; import com.xjrsoft.XjrSoftApplication; import com.xjrsoft.common.mybatis.SqlRunnerAdapter; import com.xjrsoft.module.courseTable.service.ICourseTableService; import com.xjrsoft.module.schedule.entity.WfCourseAdjust; import com.xjrsoft.module.schedule.service.IWfCourseAdjustService; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import java.util.Map; import static org.junit.jupiter.api.Assertions.*; /** * @author dzx * @date 2024/12/9 */ @RunWith(SpringRunner.class) @SpringBootTest(classes = XjrSoftApplication.class) class CourseTableServiceImplTest { @Autowired private ICourseTableService courseTableService; @Autowired private IWfCourseAdjustService adjustService; @Test public void test(){ String sql = "SELECT t1.* FROM wf_course_adjust t1\n" + "INNER JOIN xjr_workflow_form_relation t2 ON t1.id = t2.form_key_value\n" + "WHERE t2.current_state = 'COMPLETED'\n" + "AND t1.delete_mark = 0 AND t1.enabled_mark = 1\n" + "AND (t1.adjust_date > '2024-12-09' OR t1.exchange_date > '2024-12-09')\n" + "AND (\n" + "SELECT COUNT(*) FROM course_table a1\n" + "INNER JOIN course_table_bak a2 ON a1.key_info = a2.key_info\n" + "WHERE a2.wf_course_adjust_id = t1.id AND a1.adjust_type IS NULL\n" + ") > 0"; List> list = SqlRunnerAdapter.db().selectList(sql); for (Map objectMap : list) { long id = Long.parseLong(objectMap.get("id").toString()); WfCourseAdjust courseAdjust = adjustService.getById(id); courseTableService.adjustCourse(courseAdjust); } } }