123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.jeeplus.modules.leaveapply.dao.LeaveApplyDao">
-
- <sql id="leaveApplyColumns">
- a.id AS "id",
- a.create_by AS "createBy.id",
- a.create_date AS "createDate",
- a.update_by AS "updateBy.id",
- a.update_date AS "updateDate",
- a.remarks AS "remarks",
- a.del_flag AS "delFlag",
- a.office_id AS "officeId",
- a.company_id AS "companyId",
- a.branch_office AS "branchOffice",
- a.staff_id AS "staffId",
- a.start_time AS "startTime",
- a.end_time AS "endTime",
- a.start_type AS "startType",
- a.end_type AS "endType",
- a.long_time AS "longTime",
- a.status AS "status",
- a.process_instance_id AS "processInstanceId",
- a.sell_status AS "sellStatus",
- a.apply_time AS "applyTime",
- a.no AS "no",
- a.reason AS "reason",
- w.name AS "basicInfo.name",
- w.id AS "basicInfo.id",
- w.no AS "basicInfo.no",
- w.status as "basicInfo.status",
- m.top_company AS "basicInfo.office.name",
- m.id AS "basicInfo.office.id",
- j.name AS "basicInfo.jobGrade.name",
- a.applyer,
- a.back_time,
- a.contrast,
- a.back_start_type as "backStartType"
- </sql>
-
- <sql id="leaveApplyJoins">
- left join work_staff_achives w on w.id=a.staff_id
- left join sys_office m on m.id=w.office_id
- left join work_job_grade j on j.id=w.job_grade
- LEFT JOIN sys_office o ON o.id = a.office_id
- LEFT JOIN sys_office s ON s.id = a.company_id
- LEFT JOIN sys_user u ON u.id = a.create_by
- </sql>
-
-
- <select id="get" resultType="LeaveApply" >
- SELECT
- <include refid="leaveApplyColumns"/>
- FROM leave_apply a
- <include refid="leaveApplyJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="getByStaffIdAndTime" resultType="LeaveApply" >
- SELECT
- <include refid="leaveApplyColumns"/>
- FROM leave_apply a
- <include refid="leaveApplyJoins"/>
- LEFT JOIN leave_detail d ON d.leave_id = a.id
- WHERE a.staff_id = #{staffId}
- AND a.status IN ('5','8')
- AND #{time}
- BETWEEN d.start_time AND d.end_time
- AND #{time} <= d.real_end_time;
- </select>
-
- <select id="findList" resultType="LeaveApply" >
- SELECT
- <include refid="leaveApplyColumns"/>
- FROM leave_apply a
- <include refid="leaveApplyJoins"/>
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- <if test="beginApplyTime != null and endApplyTime != null and beginApplyTime != '' and endApplyTime != ''">
- AND a.apply_time BETWEEN #{beginApplyTime} AND #{endApplyTime}
- </if>
- <if test="basicInfo != null and basicInfo.name != null and basicInfo.name != ''">
- AND w.name LIKE
- <if test="dbName == 'oracle'">'%'||#{basicInfo.name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{basicInfo.name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{basicInfo.name},'%')</if>
- </if>
- ${sqlMap.dsf}
- <if test="staffId != null and staffId != ''">
- AND a.staff_id = #{staffId}
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.update_date DESC
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="LeaveApply" >
- SELECT
- <include refid="leaveApplyColumns"/>
- FROM leave_apply a
- <include refid="leaveApplyJoins"/>
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.update_date DESC
- </otherwise>
- </choose>
- </select>
-
- <insert id="insert">
- INSERT INTO leave_apply(
- id,
- create_by,
- create_date,
- update_by,
- update_date,
- remarks,
- del_flag,
- office_id,
- company_id,
- branch_office,
- staff_id,
- start_time,
- end_time,
- start_type,
- end_type,
- long_time,
- status,
- process_instance_id,
- sell_status,
- apply_time,
- no,
- reason,
- applyer,
- back_time,
- contrast,
- back_start_type
- ) VALUES (
- #{id},
- #{createBy.id},
- #{createDate},
- #{updateBy.id},
- #{updateDate},
- #{remarks},
- #{delFlag},
- #{officeId},
- #{companyId},
- #{branchOffice},
- #{basicInfo.id},
- #{startTime},
- #{endTime},
- #{startType},
- #{endType},
- #{longTime},
- #{status},
- #{processInstanceId},
- #{sellStatus},
- #{applyTime},
- #{no},
- #{reason},
- #{applyer},
- #{backTime},
- #{contrast},
- #{backStartType}
- )
- </insert>
-
- <update id="update">
- UPDATE leave_apply SET
- update_by = #{updateBy.id},
- update_date = #{updateDate},
- remarks = #{remarks},
- office_id = #{officeId},
- company_id = #{companyId},
- branch_office = #{branchOffice},
- staff_id = #{basicInfo.id},
- start_time = #{startTime},
- end_time = #{endTime},
- start_type = #{startType},
- end_type = #{endType},
- long_time = #{longTime},
- status = #{status},
- process_instance_id = #{processInstanceId},
- sell_status = #{sellStatus},
- apply_time = #{applyTime},
- no = #{no},
- reason = #{reason},
- applyer=#{applyer},
- back_time = #{backTime},
- contrast=#{contrast},
- back_start_type = #{backStartType}
- WHERE id = #{id}
- </update>
-
-
- <!--物理删除-->
- <update id="delete">
- DELETE FROM leave_apply
- WHERE id = #{id}
- </update>
-
- <!--逻辑删除-->
- <update id="deleteByLogic">
- UPDATE leave_apply SET
- del_flag = #{DEL_FLAG_DELETE}
- WHERE id = #{id}
- </update>
-
-
- <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
- <select id="findUniqueByProperty" resultType="LeaveApply" statementType="STATEMENT">
- select * FROM leave_apply where ${propertyName} = '${value}'
- </select>
- <update id="updateProcessIdAndStatus" >
- UPDATE leave_apply SET
- process_instance_id = #{processInstanceId},
- status = #{status}
- WHERE id = #{id}
- </update>
- <select id="getCount" resultType="LeaveApply" >
- SELECT
- <include refid="leaveApplyColumns"/>
- FROM leave_apply a
- <include refid="leaveApplyJoins"/>
- WHERE a.staff_id = #{basicInfo.id} and a.status not in ('8')
- </select>
- <select id="getMaxTime" resultType="java.lang.String" parameterType="java.lang.String">
- SELECT
- max(DATE_FORMAT(end_time, '%Y-%m-%d')) AS endTime
- FROM `leave_apply` l
- WHERE
- del_flag='0'
- and staff_id = #{staffId}
- and id !=#{id}
- </select>
- <select id="findHisTime" resultType="java.lang.Integer">
- SELECT
- count(*) as "total"
- FROM leave_detail a
- <where>
- a.del_flag = '0'
- AND a.leave_id in
- (select y.id from leave_apply y where y.staff_id=#{staffId} and y.status='8' and y.del_flag='0'
- <if test="id != null and id != ''">
- and y.id!=#{id}
- </if>)
- and ((#{startTime}> a.start_time and #{startTime} < a.end_time)
- or (#{endTime} > a.start_time and #{endTime} < a.end_time))
- </where>
- </select>
- <select id="findHisDate" resultType="java.lang.Integer">
- SELECT
- count(*) AS "total" FROM
- leave_detail a WHERE
- a.del_flag = '0' AND a.leave_id IN (
- SELECT y.id FROM leave_apply y WHERE y.staff_id =#{staffId}
- AND y. STATUS = '8'
- AND y.del_flag = '0'
- AND y.id !=#{id})
- AND ((a.start_time = #{startTime} and a.start_type=#{startType})
- OR (a.start_time = #{endTime} and a.start_type=#{endType})
- OR (a.end_time = #{startTime} and a.end_type=#{startType})
- OR (a.end_time = #{endTime} and a.end_type=#{endType}))
- </select>
- <select id="getMange" resultType="LeaveApply" >
- SELECT
- <include refid="leaveApplyColumns"/>
- FROM leave_apply a
- <include refid="leaveApplyJoins"/>
- WHERE a.company_id=#{companyId} and a.del_flag = '0' and a.status in('5','8','6','7','9')
- <if test="basicInfo != null and basicInfo.name != null and basicInfo.name != ''">
- AND w.name LIKE
- <if test="dbName == 'oracle'">'%'||#{basicInfo.name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{basicInfo.name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{basicInfo.name},'%')</if>
- </if>
- <if test="basicInfo != null and basicInfo.office != null and basicInfo.office.id != null and basicInfo.office.id != ''">
- AND a.office_id = #{basicInfo.office.id}
- </if>
- <!-- 有异常-->
- <!-- group by a.staff_id order by w.no ASC-->
- </select>
- <select id="getSumDays" resultType="LeaveApply" parameterType="java.lang.String">
- SELECT
- ifnull(sum(a.sums),0) as "sumDays"
- FROM leave_count a
- where
- a.del_flag = '0'
- and a.staff_id =#{staffId}
- </select>
- <select id="getResetState" resultType="int" parameterType="java.lang.String">
- SELECT
- count(*)
- FROM leave_count a
- where
- a.del_flag = '0'
- and a.staff_id =#{staffId}
- and a.reset_state='0'
- </select>
- <update id="updateDetailFlat">
- UPDATE leave_detail a SET
- a.flat = '1',a.state='0'
- WHERE a.leave_id=#{id}
- </update>
- <update id="deleteDetail">
- DELETE FROM leave_detail
- WHERE leave_id = #{id} and state='1'
- </update>
- <update id="updateBack">
- UPDATE leave_apply a SET
- a.back_time=null,
- a.contrast=null
- WHERE a.id=#{id}
- </update>
- <update id="updateLongTime">
- UPDATE leave_apply a SET
- a.long_time=(select ifnull(sum(days),0) from leave_detail
- WHERE leave_id = #{id} and state!='1')
- WHERE a.id=#{id}
- </update>
- <select id="getBackTaskList" resultType="LeaveApply" >
- SELECT
- <include refid="leaveApplyColumns"/>
- FROM leave_apply a
- left join work_staff_achives w on w.id=a.staff_id
- left join sys_office m on m.id=w.office_id
- left join work_job_grade j on j.id=w.job_grade
- where a.id in (SELECT a.id FROM leave_apply a
- LEFT JOIN (SELECT d.leave_id, max(d.end_time) AS end_time FROM leave_detail d
- WHERE d.del_flag = '0' GROUP BY d.leave_id) i ON i.leave_id = a.id
- WHERE a.del_flag = '0'
- AND a.`status` = '5'
- AND date_add(DATE_FORMAT(i.end_time, '%Y-%m-%d'),INTERVAL 1 day)=DATE_FORMAT(now(), '%Y-%m-%d'))
- </select>
- </mapper>
|