<?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.daemon.quartz.mapper.WmScorePackageMapper">

	<resultMap id="wmScorePackageMap" type="com.qunzhixinxi.hnqz.daemon.quartz.entity.WmScorePackage">
		<id property="id" column="id"/>
		<result property="taskRuleId" column="task_rule_id"/>
		<result property="drugEntId" column="drug_ent_id"/>
		<result property="scoreId" column="score_id"/>
		<result property="scoreName" column="score_name"/>
		<result property="score" column="score"/>
		<result property="agentTypeId" column="agent_type_id"/>
		<result property="level1Id" column="level1_id"/>
		<result property="level2Id" column="level2_id"/>
		<result property="zbId" column="zb_id"/>
		<result property="xxdbId" column="xxdb_id"/>
		<result property="typeid" column="typeid"/>
		<result property="packageStatus" column="package_status"/>
		<result property="packageFinishStatus" column="package_finish_status"/>
		<result property="sendPackageDeptId" column="send_package_dept_id"/>
		<result property="deptId" column="dept_id"/>
		<result property="delFlag" column="del_flag"/>
		<result property="enableFlag" column="enable_flag"/>
		<result property="tenantId" column="tenant_id"/>
		<result property="createTime" column="create_time"/>
		<result property="createUser" column="create_user"/>
		<result property="updateTime" column="update_time"/>
		<result property="updateUser" column="update_user"/>
		<result property="ytj" column="ytj"/>
		<result property="ysh" column="ysh"/>
		<result property="dsh" column="dsh"/>
		<result property="ytjtt" column="ytjtt"/>
		<result property="ywctt" column="ywctt"/>
		<result property="yshtt" column="yshtt"/>
	</resultMap>

	<select id="listPackageInfo" resultType="map">
		SELECT sp.id AS `packageId`,
		u.user_id AS `userId`,
		u.username,
		u.realname,
		sp.score_package_name AS `packageName`,
		CASE sp.score_package_status
		WHEN 1 THEN '审核中'
		WHEN 2 THEN '审核通过'
		WHEN 3 THEN '审核不通过'
		WHEN 4 THEN '终止'
		END `status`,
		sd.name AS `deptName`,
		sd.dept_id AS `deptId`,
		sp.create_time AS `packageCreateTime`,
		sps.create_time AS `packagePickUpTime`
		FROM wm_score_package sp
		LEFT JOIN wm_score_package_status sps ON sp.id = sps.package_id
		LEFT JOIN sys_user u ON sps.user_id = u.user_id
		LEFT JOIN sys_dept sd ON sp.send_package_dept_id = sd.dept_id
		<where>

			sp.id IN
			<foreach collection="packageIds" index="idx" item="id" separator="," open="(" close=")">
				#{id}
			</foreach>
		</where>
	</select>
</mapper>
