多表条件查询

   @AutoLog(value = "根据成果等条件查询教师")
    @ApiOperation(value = "根据成果等条件查询教师",notes="根据成果等条件查询教师")
    @GetMapping(value = "/selectTeacher")
    public Result<?> selectTeacher(String finished,
                                    String totalPaper,
                                   Integer period,
                                    String title,
                                    String finishedK,
                                    String createTime_begin,
                                   String createTime_end,
                                    String type973,
                                    String type863,
                                    String committee,
                                    String fundNational,
                                    String fundProvince,
                                    String fondCity,
                                    String joinNumber,
                                    String level,
                                    String keyanNumber,
                                    String sciNumber,
                                    String chinaNumber,
                                    String teachingNumber,
                                    String zhuanliNumber,
                                    String meetingNumber) {
        List<StaTeacher> staTeacher = staTeacherService.selectTeacher(finished,totalPaper,period,title,finishedK,createTime_begin,createTime_end,type973,type863,committee,fundNational,fundProvince,fondCity,joinNumber,level,keyanNumber,sciNumber,chinaNumber,teachingNumber,zhuanliNumber,meetingNumber);
        return Result.ok(staTeacher);
    }
    List<StaTeacher>selectTeacher(String finished,
                                  String totalPaper,
                                  Integer period,
                                  String title,
                                  String finishedK,
                                  String createTime_begin,
                                  String createTime_end,
                                  String type973,
                                  String type863,
                                  String committee,
                                  String fundNational,
                                  String fundProvince,
                                  String fondCity,
                                  String joinNumber,
                                  String level,
                                  String keyanNumber,
                                  String sciNumber,
                                  String chinaNumber,
                                  String teachingNumber,
                                  String zhuanliNumber,
                                  String meetingNumber);
	@Override
	public List<StaTeacher> selectTeacher(String finished, String totalPaper, Integer period, String title, String finishedK, String createTime_begin, String createTime_end, String type973, String type863, String committee, String fundNational, String fundProvince, String fondCity, String joinNumber, String level, String keyanNumber, String sciNumber, String chinaNumber, String teachingNumber, String zhuanliNumber, String meetingNumber) {
		return  staTeacherMapper.selectTeacher(finished,totalPaper,period,title,finishedK,createTime_begin,createTime_end,type973,type863,committee,fundNational,fundProvince,fondCity,joinNumber,level,keyanNumber,sciNumber,chinaNumber,teachingNumber,zhuanliNumber,meetingNumber);
	}
 List<StaTeacher>selectTeacher(@Param("finished")String finished,
                                  @Param("totalPaper")String totalPaper,
                                  @Param("period")Integer period,
                                  @Param("title")String title,
                                  @Param("finishedK")String finishedK,
                                  @Param("createTime_begin")String createTime_begin,
                                  @Param("createTime_end")String createTime_end,
                                  @Param("type973")String type973,
                                  @Param("type863")String type863,
                                  @Param("committee")String committee,
                                  @Param("fundNational")String fundNational,
                                  @Param("fundProvince")String fundProvince,
                                  @Param("fondCity")String fondCity,
                                  @Param("joinNumber")String joinNumber,
                                  @Param("level")String level,
                                  @Param("keyanNumber")String keyanNumber,
                                  @Param("sciNumber")String sciNumber,
                                  @Param("chinaNumber")String chinaNumber,
                                  @Param("teachingNumber")String teachingNumber,
                                  @Param("zhuanliNumber")String zhuanliNumber,
                                  @Param("meetingNumber")String meetingNumber);

<select id="selectTeacher" resultType="org.jeecg.modules.statistical.entity.StaTeacher">
SELECT
	*
FROM
	sta_teacher
WHERE
      delect='0'
and id IN (
            SELECT
			teacher_id
		FROM
			sta_teaching_project
      <if test="finished !=null and finished != ''">
		WHERE
          finished = #{finished}</if>
    <if test="totalPaper !=null and totalPaper != ''">
		UNION
			(
				SELECT
					teacher_id
				FROM
					sta_papers_statistical
				WHERE
					total_paper = #{totalPaper}
      )</if>
    <if test="period !=null and period != ''">
		UNION
			(
				SELECT
					teacher_id
				FROM
					sta_education_exp
				WHERE
					period = #{period}
      )</if>
    <if test="title !=null and title != ''">
		UNION
			(
				SELECT
					teacher_id
				FROM
					sta_work_exp
				WHERE
					title = #{title}
      )</if>
      <if test="finishedK !=null and finishedK != '' or  createTime_begin !=null and createTime_begin != '' or  createTime_end !=null and createTime_end != ''" >
		UNION
			(
				SELECT
					teacher_id
				FROM
					sta_research
				WHERE
				finished = #{finishedK}
				AND start_time = #{createTime_begin}
				and end_time=#{createTime_end}
        )</if>
    <if test="type973 !=null and type973 != ''
    or  type863 !=null and type863 != ''
    or  committee !=null and committee != ''
    or  fundNational !=null and fundNational != ''
    or  fundProvince !=null and fundProvince != ''
    or  fondCity !=null and fondCity != ''
    or  joinNumber !=null and joinNumber != ''" >
		UNION
			(
				SELECT
					teacher_id
				FROM
					sta_join_research_st
				WHERE
					type973 = #{type973}
				AND type863 = #{type863}
				AND committee = #{committee}
				AND fund_national = #{fundNational}
				AND fund_province = #{fundProvince}
				AND fond_city = #{fondCity}
				AND join_number = #{joinNumber}
      )</if>
      <if test="level !=null and level != '' ">
		UNION
			(
				SELECT
					teacher_id
				FROM
					sta_reward_student
				WHERE
					level = #{level}
			)</if>
          )
      <if test="keyanNumber !=null and keyanNumber != ''">
          and huo_jiang_number = #{keyanNumber}
      </if>
      <if test="sciNumber !=null and sciNumber != ''">
          AND sci_number = #{sciNumber}
      </if>
      <if test="chinaNumber !=null and chinaNumber != ''">
          AND china_number = #{chinaNumber}
      </if>
      <if test="teachingNumber !=null and teachingNumber != ''">
          AND teaching_number = #{teachingNumber}
      </if>
      <if test="zhuanliNumber !=null and zhuanliNumber != ''">
          AND zhuanli_number = #{zhuanliNumber}
      </if>
      <if test="meetingNumber !=null and meetingNumber != ''">
          AND meeting_number = #{meetingNumber}
      </if>
  </select>

你可能感兴趣的:(项目碎片——sql)