TBusWarningEmployeeMapper.xml 11.3 KB
Newer Older
huyuchen's avatar
huyuchen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
<?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.yifu.cloud.plus.v1.business.mapper.system.TBusWarningEmployeeMapper">
    <resultMap id="tBusWarningEmployeeMap" type="com.yifu.cloud.plus.v1.business.entity.system.TBusWarningEmployee">
        <id property="id" column="id"/>
        <result property="warningId" column="warning_id"/>
        <result property="busDeptId" column="bus_dept_id"/>
        <result property="busDeptCode" column="bus_dept_code"/>
        <result property="busDeptName" column="bus_dept_name"/>
        <result property="empName" column="emp_name"/>
        <result property="empIdcard" column="emp_idcard"/>
        <result property="empPhone" column="emp_phone"/>
        <result property="sendDate" column="send_date"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="sendStatus" column="send_status"/>
        <result property="remark" column="remark"/>
        <result property="bizId" column="Biz_Id"/>
        <result property="updateStatus" column="update_status"/>
        <result property="message" column="message"/>
        <result property="businessTelecomNumber" column="BUSINESS_TELECOM_NUMBER"/>
        <result property="certType" column="cert_type"/>
        <result property="notUsedVacationDuration" column="NOT_USED_VACATION_DURATION"/>
    </resultMap>
    <sql id="Base_Column_List">
             a.id,
              a.warning_id,
              a.bus_dept_id,
              a.bus_dept_code,
              a.bus_dept_name,
              a.emp_name,
              a.emp_idcard,
              a.emp_phone,
              a.send_date,
              a.CREATE_USER,
              a.send_status,
              a.remark,
              a.Biz_Id,
              a.update_status,
              a.message,
              a.BUSINESS_TELECOM_NUMBER,
              a.cert_type,
              a.NOT_USED_VACATION_DURATION
     </sql>
    <sql id="tBusWarningEmployee_where">
        <if test="tBusWarningEmployee != null">
            <if test="tBusWarningEmployee.id != null and tBusWarningEmployee.id.trim() != ''">
                AND a.id = #{tBusWarningEmployee.id}
            </if>
            <if test="tBusWarningEmployee.warningId != null and tBusWarningEmployee.warningId.trim() != ''">
                AND a.warning_id = #{tBusWarningEmployee.warningId}
            </if>
            <if test="tBusWarningEmployee.busDeptId != null and tBusWarningEmployee.busDeptId.trim() != ''">
                AND a.bus_dept_id = #{tBusWarningEmployee.busDeptId}
            </if>
            <if test="tBusWarningEmployee.busDeptCode != null and tBusWarningEmployee.busDeptCode.trim() != ''">
                AND a.bus_dept_code = #{tBusWarningEmployee.busDeptCode}
            </if>
            <if test="tBusWarningEmployee.busDeptName != null and tBusWarningEmployee.busDeptName.trim() != ''">
                AND a.bus_dept_name = #{tBusWarningEmployee.busDeptName}
            </if>
            <if test="tBusWarningEmployee.empName != null and tBusWarningEmployee.empName.trim() != ''">
                AND a.emp_name = #{tBusWarningEmployee.empName}
            </if>
            <if test="tBusWarningEmployee.empIdcard != null and tBusWarningEmployee.empIdcard.trim() != ''">
                AND a.emp_idcard = #{tBusWarningEmployee.empIdcard}
            </if>
            <if test="tBusWarningEmployee.empPhone != null and tBusWarningEmployee.empPhone.trim() != ''">
                AND a.emp_phone = #{tBusWarningEmployee.empPhone}
            </if>
            <if test="tBusWarningEmployee.sendDate != null">
                AND a.send_date = #{tBusWarningEmployee.sendDate}
            </if>
            <if test="tBusWarningEmployee.createUser != null and tBusWarningEmployee.createUser.trim() != ''">
                AND a.CREATE_USER = #{tBusWarningEmployee.createUser}
            </if>
            <if test="tBusWarningEmployee.sendStatus != null and tBusWarningEmployee.sendStatus.trim() != ''">
                AND a.send_status = #{tBusWarningEmployee.sendStatus}
            </if>
            <if test="tBusWarningEmployee.remark != null and tBusWarningEmployee.remark.trim() != ''">
                AND a.remark = #{tBusWarningEmployee.remark}
            </if>
            <if test="tBusWarningEmployee.bizId != null and tBusWarningEmployee.bizId.trim() != ''">
                AND a.Biz_Id = #{tBusWarningEmployee.bizId}
            </if>
            <if test="tBusWarningEmployee.updateStatus != null and tBusWarningEmployee.updateStatus.trim() != ''">
                AND a.update_status = #{tBusWarningEmployee.updateStatus}
            </if>
            <if test="tBusWarningEmployee.message != null and tBusWarningEmployee.message.trim() != ''">
                AND a.message = #{tBusWarningEmployee.message}
            </if>
            <if test="null != tBusWarningEmployee.sendDateStart and tBusWarningEmployee.sendDateStart.trim() != ''">
                AND a.send_date >= concat(#{tBusWarningEmployee.sendDateStart},' 00:00:00')
            </if>
            <if test="null != tBusWarningEmployee.sendDateEnd and tBusWarningEmployee.sendDateEnd.trim() != ''">
                AND a.send_date <![CDATA[ <= ]]>  concat(#{tBusWarningEmployee.sendDateEnd},' 23:59:59')
            </if>
            <if test="null != tBusWarningEmployee.businessTelecomNumber and tBusWarningEmployee.businessTelecomNumber.trim() != ''">
                AND a.BUSINESS_TELECOM_NUMBER like concat('%', #{tBusWarningEmployee.businessTelecomNumber}, '%')
            </if>
        </if>
    </sql>
    <!--tBusWarningEmployee简单分页查询-->
    <select id="getTBusWarningEmployeePage" resultMap="tBusWarningEmployeeMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_bus_warning_employee a
        <where>
            1=1
            <include refid="tBusWarningEmployee_where"/>
        </where>
        order by a.send_date desc
    </select>

    <!--简单list-->
    <select id="getTBusWarningEmployeeListToday" resultMap="tBusWarningEmployeeMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_bus_warning_employee a
        <where>
            DATE_FORMAT(a.send_date,"%Y%m%d")  = #{dateStr}
        </where>
    </select>

    <!--简单list-->
    <select id="getByBizId" resultMap="tBusWarningEmployeeMap">
        SELECT
            <include refid="Base_Column_List"/>
        FROM t_bus_warning_employee a
        where a.Biz_Id = #{bizId}
    </select>

    <!--更新-->
    <update id="updateSendStatusByBizId" >
        update t_bus_warning_employee e set e.send_status = #{sendStatus},e.update_status = #{updateStatus} where e.Biz_Id = #{bizId}
    </update>

    <!-- 基础sql -->
    <insert id="saveNewEmployee">
        INSERT into
        t_bus_warning_employee
        set warning_id = #{se.warningId},bus_dept_id = #{se.busDeptId},bus_dept_code = #{se.busDeptCode},bus_dept_name = #{se.busDeptName}
        ,emp_name = #{se.empName},EMP_IDCARD = #{se.empIdcard},EMP_PHONE = #{se.empPhone},send_date = #{se.sendDate}
        ,CREATE_USER = #{se.createUser},send_status = #{se.sendStatus},Biz_Id = #{se.bizId},update_status = #{se.updateStatus}
        ,BUSINESS_TELECOM_NUMBER = #{se.businessTelecomNumber},cert_type = #{se.certType},NOT_USED_VACATION_DURATION = #{se.notUsedVacationDuration}
    </insert>

    <!--更新-->
    <update id="updateBizIdByBizId" >
        update t_bus_warning_employee e set e.Biz_Id = #{newBizId} where e.Biz_Id = #{oldBizId}
    </update>

    <!-- 复审到期日 -->
    <insert id="insertByReviewDate">
        INSERT into t_bus_warning_employee
        (warning_id,bus_dept_id,bus_dept_code,bus_dept_name,emp_name,EMP_IDCARD,EMP_PHONE,send_date,CREATE_USER,send_status,Biz_Id,update_status,business_telecom_number,cert_type)
        SELECT #{warningId} warning_id,d.id bus_dept_id,d.tree_logo bus_dept_code,d.name bus_dept_name,c.emp_name,c.EMP_IDCARD,e.phone EMP_PHONE
        ,now() send_date, #{userId} CREATE_USER,'1' send_status,#{bizId} Biz_Id,'0' update_status,c.business_telecom_number,sd.label cert_type
        FROM t_cert_info c
        left join t_bus_dept d on d.id=c.organ_id
        left join sys_bus_dict sd on sd.value=c.cert_type and sd.item_type = 'cert_type'
        join view_employee_phone e on e.dx_no = c.business_telecom_number
		where  datediff(c.review_date,now()) = #{days} and c.delete_flag ='0'
		and not exists (
            select 1 from t_bus_leave l where l.tele_no = c.business_telecom_number
        )
		GROUP BY c.id
    </insert>

    <!-- 证件到期日 -->
    <insert id="insertByTermValidityEnd">
        INSERT into t_bus_warning_employee
        (warning_id,bus_dept_id,bus_dept_code,bus_dept_name,emp_name,EMP_IDCARD,EMP_PHONE,send_date,CREATE_USER,send_status,Biz_Id,update_status,business_telecom_number,cert_type)
        SELECT #{warningId} warning_id,d.id bus_dept_id,d.tree_logo bus_dept_code,d.name bus_dept_name,c.emp_name,c.EMP_IDCARD,e.phone EMP_PHONE
        ,now() send_date, #{userId} CREATE_USER,'1' send_status,#{bizId} Biz_Id,'0' update_status,c.business_telecom_number,sd.label cert_type
        FROM t_cert_info c
        left join sys_bus_dict sd on sd.value=c.cert_type and sd.item_type = 'cert_type'
        left join t_bus_dept d on d.id=c.organ_id
        join view_employee_phone e on e.dx_no = c.business_telecom_number
		where  datediff(c.term_validity_end,now()) = #{days} and c.delete_flag ='0'
		and not exists (
            select 1 from t_bus_leave l where l.tele_no = c.business_telecom_number
        )
		GROUP BY c.id
    </insert>

    <!-- 年假未休时长 -->
    <insert id="insertByYearVacation">
        INSERT into t_bus_warning_employee
        (warning_id,bus_dept_id,bus_dept_code,bus_dept_name,emp_name,EMP_IDCARD,EMP_PHONE,send_date,CREATE_USER,send_status,Biz_Id,update_status,business_telecom_number,NOT_USED_VACATION_DURATION)
        SELECT #{warningId} warning_id,d.id bus_dept_id,d.tree_logo bus_dept_code,d.name bus_dept_name,c.emp_name,c.EMP_IDCARD,e.phone EMP_PHONE
        ,now() send_date, #{userId} CREATE_USER,'1' send_status,#{bizId} Biz_Id,'0' update_status,c.business_telecom_number,concat(c.NOT_USED_VACATION_DURATION,'小时')
        FROM t_vacation_monitor c
        left join t_bus_dept d on d.id=c.DEPART_ID
        join view_employee_phone e on e.dx_no = c.business_telecom_number
        where c.NOT_USED_VACATION_DURATION>0 and DATE_FORMAT(now(),'%Y') = c.VACATION_YEAR
        and not exists (
            select 1 from t_bus_leave l where l.tele_no = c.business_telecom_number
        )
        GROUP BY c.id
    </insert>

huyuchen's avatar
huyuchen committed
202 203 204 205 206 207 208 209 210 211 212
	<!--假期结束提醒-->
	<select id="getVacationEmpName" resultType="java.lang.String">
		SELECT c.EMP_NAME
		FROM t_vacation_monitor c
		where c.NOT_USED_VACATION_DURATION>0 and DATE_FORMAT(now(),'%Y') = c.VACATION_YEAR
		and not exists (
			select 1 from t_bus_leave l where l.tele_no = c.business_telecom_number
		)
        limit 1
	</select>

huyuchen's avatar
huyuchen committed
213 214 215 216 217 218 219 220 221 222 223 224 225
    <!--假期结束提醒-->
    <select id="getVacationInfoEmpName" resultType="java.lang.String">
        SELECT c.EMP_NAME
        FROM t_vacation_info c
        where c.VACATION_STATUS != '3' and datediff(c.VACATION_END_TIME,now()) = -1 and c.EMP_NAME is not null
        and not exists (
            select 1 from t_bus_leave l where l.tele_no = c.business_telecom_number
        )
        limit 1
    </select>


</mapper>