<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, hnqz All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the pig4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: hnqz
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.qunzhixinxi.hnqz.admin.mapper.WmReportMapper">

	<resultMap id="wmReportMap" type="com.qunzhixinxi.hnqz.admin.entity.WmReport">
		<id property="id" column="id"/>
		<result property="reportNo" column="report_no"/>
		<result property="drugEntId" column="drug_ent_id"/>
		<result property="scoreId" column="score_id"/>
		<result property="applyDrugEntId" column="apply_drug_ent_id"/>
		<result property="packageScore" column="package_score"/>
		<result property="taskNumber" column="task_number"/>
		<result property="totalScore" column="total_score"/>
		<result property="reportStatus" column="report_status"/>
		<result property="createPeople" column="create_people"/>
		<result property="createTime" column="create_time"/>
		<result property="approvalPeople" column="approval_people"/>
		<result property="approvalTime" column="approval_time"/>
		<result property="updatePeople" column="update_people"/>
		<result property="updateTime" column="update_time"/>
		<result property="delFlag" column="del_flag"/>
		<result property="export1" column="export1"/>
		<result property="export2" column="export2"/>
		<result property="export3" column="export3"/>
		<result property="scorePackageName" column="score_package_name"/>

	</resultMap>

	<select id="getReportListPage" resultMap="wmReportMap">
		select p.score_package_name,t.* from wm_report t
		left join wm_score_package p on p.id=t.score_id
		<if test="query.drugEntId != null and query.drugEntId !=''">
			left join sys_dept d on t.drug_ent_id=d.dept_id
		</if>
		<if test="query.applyDrugEntId != null and query.applyDrugEntId !=''">
			left join sys_dept d on t.apply_drug_ent_id=d.dept_id
		</if>

		where 1=1
		and t.del_flag=0
		<if test="queryScoreId != null and queryScoreId !=''">
			AND p.score_id like CONCAT('%',#{queryScoreId},'%')
		</if>
		<if test="queryName != null and queryName !=''">
			AND d.`name` like CONCAT('%',#{queryName},'%')
		</if>
		<if test="query.reportNo != null and query.reportNo !=''">
			AND t.report_no like CONCAT('%',#{query.reportNo},'%')
		</if>
		<if test="query.reportStatus != null and query.reportStatus !=''">
			AND t.report_status =#{query.reportStatus}
		</if>
		<if test="query.drugEntId != null and query.drugEntId !=''">
			AND t.drug_ent_id =#{query.drugEntId}
		</if>
		<if test="query.applyDrugEntId != null and query.applyDrugEntId !=''">
			AND t.apply_drug_ent_id =#{query.applyDrugEntId}
		</if>
		<if test="query.scorePackageName != null and query.scorePackageName !=''">
			AND p.score_package_name like CONCAT('%',#{query.scorePackageName},'%')
		</if>
		order by t.create_time desc
	</select>


</mapper>
