Newer
Older
casic-metering-biz-xichang / casic-metering-dao / src / main / resources / mapper / resource / BizResourceStaffVerifierMapper.xml
<?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.casic.missiles.mapper.resource.BizResourceStaffVerifierMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.model.resource.BizResourceStaffVerifier">
        <id column="id" property="id" />
        <result column="staff_id" property="staffId" />
        <result column="cert_no" property="certNo" />
        <result column="cert_name" property="certName" />
        <result column="effective_date" property="effectiveDate" />
        <result column="grant_date" property="grantDate" />
        <result column="grant_company" property="grantCompany" />
        <result column="file" property="file" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, staff_id, cert_no, cert_name, effective_date, grant_date, grant_company, file
    </sql>

    <select id="selectCertListPage" resultType="com.casic.missiles.dto.resource.staff.StaffCertResponse">
        SELECT brsv.id, brsv.cert_no, brsv.cert_name, brsv.effective_date, brsv.grant_date, brsv.grant_company, brsv.file,
            brsi.id AS staff_id, brsi.staff_no, staff_name, id_card, gender, dept_id, dept_name, station, major, engage_date,
            working_age, staff_type, job_level, job_level_date,brsv.cert_type
        FROM biz_resource_staff_verifier brsv
        JOIN biz_resource_staff_info brsi ON brsv.staff_id = brsi.id
        WHERE 1=1
        <if test="request.name != null and request.name !=''">
            and brsi.staff_name like concat('%',#{request.name},'%')
        </if>
        <if test="request.deptName != null and request.deptName !=''">
            and brsi.dept_name like concat('%',#{request.deptName},'%')
        </if>
        <if test="request.station != null and request.station !=''">
            and brsi.station like concat('%',#{request.station},'%')
        </if>
        <if test="request.certType != null and request.certType !=''">
            and brsv.cert_type  =  #{request.certType}
        </if>
        <if test="request.certNo != null and request.certNo !=''">
            and brsv.cert_no like concat('%',#{request.certNo},'%')
        </if>
        <if test="request.certName != null and request.certName !=''">
            and brsv.cert_name like concat('%',#{request.certName},'%')
        </if>
        <if test="request.beginTime != null and request.beginTime !=''">
            and brsv.effective_date  >= #{request.beginTime}
        </if>
        <if test="request.endTime != null and request.endTime !=''">
            and brsv.effective_date &lt;= #{request.endTime}
        </if>
        <if test="request.ids != null">
            and brsv.id in
            <foreach collection="request.ids" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
        ORDER BY brsv.cert_type asc, brsv.grant_date DESC
    </select>

    <select id="selectNewNoByStaffId" resultType="java.lang.String">
        SELECT cert_no
        FROM biz_resource_staff_verifier
        WHERE staff_id = #{staffId}
        ORDER BY grant_date DESC
        LIMIT 1
    </select>

    <select id="selectStaffCertList" resultType="com.casic.missiles.dto.data.BizDataResourceStaffCertExpireDTO">
        SELECT YEAR(brsv.effective_date) AS year, QUARTER(brsv.effective_date) AS quarter, COUNT(brsv.id) AS certExpireAmount
        FROM biz_resource_staff_verifier brsv
        JOIN biz_resource_staff_info brsi ON brsv.staff_id = brsi.id
        WHERE 1=1
        <if test="request != null and request.timeStart != null and request.timeStart !=''">
            and brsv.effective_date &gt;= #{request.timeStart}
        </if>
        <if test="request != null and request.timeEnd != null and request.timeEnd !=''">
            and brsv.effective_date &lt;= #{request.timeEnd}
        </if>
        <if test="deptIds != null and deptIds.size() != 0">
            and brsi.dept_id in
            <foreach collection="deptIds" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
        GROUP BY YEAR(brsv.effective_date), QUARTER(brsv.effective_date)
        ORDER BY YEAR(brsv.effective_date), QUARTER(brsv.effective_date)
    </select>
</mapper>