<?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.WmTaskTypeMapper">

  <resultMap id="wmTaskTypeMap" type="com.qunzhixinxi.hnqz.admin.entity.WmTaskType">
                  <id property="id" column="id"/>
                        <result property="taskTypeName" column="task_type_name"/>
                        <result property="taskTypeLevel" column="task_type_level"/>
	  					<result property="status" column="status"/>
	  					<result property="score" column="score"/>
	  					<result property="baseId" column="base_id"/>
	  					<result property="taskScoreStart" column="task_score_start"/>
                        <result property="taskScoreEnd" column="task_score_end"/>
						<result property="taskEntId" column="task_ent_id"/>
	  					<result property="durgentId" column="durgent_id"/>
	  					<result property="level1Id" column="level1_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="realFlag" column="real_flag"/>
	 					<result property="ruleId" column="rule_id"/>
	 					<result property="parentId" column="parent_id"/>
  </resultMap>

	<select id="getTaskTypeDeptList" resultType="com.qunzhixinxi.hnqz.admin.entity.output.WmTaskTypeDeptOutput" >
		SELECT durgent_id ,level1_id ,rule_id  from wm_task_type
		where dept_id = #{query.deptId,jdbcType=VARCHAR}
		GROUP BY rule_id
	</select>

	<select id="selectByRuleId" resultMap="wmTaskTypeMap" parameterType="java.lang.String" >
		select
		*
		from wm_task_type
		where rule_id = #{ruleId,jdbcType=VARCHAR}
	</select>

	<select id="getWmTaskType" resultType="com.qunzhixinxi.hnqz.admin.entity.WmTaskTypeTree">
		select
		t.task_type_name as taskTypeName,
		t.id as taskTypeId,
		'1' as type
		from wm_task_type  t
		where t.del_flag='0' and t.enable_flag=0
		and t.task_type_level=1
		<if test="query.parentId!=null and query.parentId!=''">
			AND t.parent_id =#{query.parentId}
		</if>
		order by t.id

	</select>

	<select id="getWmTaskTypeYX" resultType="com.qunzhixinxi.hnqz.admin.entity.WmTaskTypeTree">
		select
		t.task_type_name as taskTypeName,
		t.id as taskTypeId,
		'1' as type
		from wm_task_type  t
		where t.del_flag='0' and t.enable_flag=0
		and t.task_type_level=1
		<if test="query.parentId!=null and query.parentId!=''">
			AND t.parent_id =#{query.parentId}
		</if>
		order by t.id

	</select>


</mapper>
