AccidentReport.xml 7.33 KB
Newer Older
Rensq's avatar
Rensq 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
<?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.testor.module.accident.dao.AccidentReportDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.accident.model.domain.AccidentReport">
        <id column="id" property="id"/>
        <id column="ref_id" property="refId"/>
        <id column="parent_id" property="parentId"/>
        <id column="tenant_id" property="tenantId"/>
        <id column="process_id" property="processId"/>
        <id column="process_status" property="processStatus"/>
        <id column="report_unit" property="reportUnit"/>
        <id column="accident_time" property="accidentTime"/>
        <id column="fake_type" property="fakeType"/>
        <id column="accident_type" property="accidentType"/>
        <id column="reporter" property="reporter"/>
        <id column="accident_level" property="accidentLevel"/>
        <id column="accident_passed" property="accidentPassed"/>
        <id column="accident_cause" property="accidentCause"/>
        <id column="improvements" property="improvements"/>
        <id column="attachment" property="attachment"/>
    </resultMap>

    <!--<select id="getCountByAccidentTime" parameterType="com.testor.module.accident.model.domain.AccidentReport" resultType="string">-->
        <!--SELECT count(*) AS count-->
        <!--FROM t_accident_report-->
        <!--WHERE YEAR(accident_time) = #{accidentReport.attachment} AND process_status='5'-->
        <!--AND org_id in (select org.org_id from t_sys_org org where org.parent_id like concat('%', #{accidentReport.orgId}, '%'))-->
    <!--</select>-->

    <!--<select id="getAccidentReportByAccidentTime" parameterType="com.testor.module.accident.model.domain.AccidentReport" resultType="com.testor.module.accident.model.domain.AccidentReport">-->
        <!--SELECT *-->
        <!--FROM t_accident_report-->
        <!--WHERE YEAR(accident_time) = #{accidentReport.attachment} AND process_status='5'-->
        <!--AND org_id in (select org.org_id from t_sys_org org where org.parent_id like concat('%', #{accidentReport.orgId}, '%'))-->
    <!--</select>-->
    <select id="getCountByAccidentTime" parameterType="com.testor.module.accident.model.domain.AccidentReport" resultType="string">
        SELECT
            count(a.id) AS count
        FROM
            t_accident_report  a
            LEFT JOIN t_sys_org b ON a.org_id=b.org_id
        WHERE
            YEAR ( a.accident_time ) = #{accidentReport.attachment}
            AND a.process_status = '5'
            AND a.status = '0'
            AND b.status = '0'
            and (b.org_id=#{accidentReport.orgId} or b.parent_ids like concat('%', #{accidentReport.orgId}, '%'))
            and b.is_dept='0'
    </select>

    <select id="getAccidentReportByAccidentTime"
            parameterType="com.testor.module.accident.model.domain.AccidentReport"
            resultType="com.testor.module.accident.model.domain.AccidentReport" databaseId="mysql">
        SELECT
            a.*
        FROM
            t_accident_report  a
            LEFT JOIN t_sys_org b ON a.org_id=b.org_id
        WHERE
            YEAR ( a.accident_time ) = #{accidentReport.attachment}
            AND a.process_status = '5'
            AND a.status = '0'
            AND b.status = '0'
            and (b.org_id=#{accidentReport.orgId} or b.parent_ids like concat('%', #{accidentReport.orgId}, '%'))
            and b.is_dept='0'
    </select>
    <select id="getAccidentReportByAccidentTime"
            parameterType="com.testor.module.accident.model.domain.AccidentReport"
            resultType="com.testor.module.accident.model.domain.AccidentReport" databaseId="kingbase">
        SELECT
            a.*
        FROM
            t_accident_report  a
                LEFT JOIN t_sys_org b ON a.org_id=b.org_id
        WHERE
            EXTRACT(YEAR FROM a.accident_time)  = #{accidentReport.attachment}
          AND a.process_status = '5'
          AND a.status = '0'
          AND b.status = '0'
          and (b.org_id=#{accidentReport.orgId} or b.parent_ids like concat('%', #{accidentReport.orgId}, '%'))
          and b.is_dept='0'
    </select>

    <!--<select id="list" parameterType="com.testor.module.accident.model.domain.AccidentReport" resultType="com.testor.module.accident.model.vo.AccidentReportQuery">-->
    <select id="findExportlist" parameterType="com.testor.module.accident.model.req.AccidentReportExportReq" resultType="com.testor.module.accident.model.domain.AccidentReport" databaseId="mysql">
        SELECT id,report_unit,accident_type,accident_level,accident_time,fake_type,basic_unit_id,regional_company_id,
        direct_economic_loss,
        indirect_economic_loss,
        total_economic_loss,
        accident_passed,
        improvements,
        accident_cause,remarks
        FROM t_accident_report
        <where>
            <if test="qwe.processStatus !=null and qwe.processStatus!=''">
               and process_status=#{qwe.processStatus}
            </if>
            <if test="qwe.idList !=null ">
              and   id in (#{qwe.idList})
            </if>
            <if test="qwe.regionalCompanyId !=null and qwe.regionalCompanyId!=''">
               and  regional_company_id=#{qwe.regionalCompanyId}
            </if>
            <if test="qwe.basicUnitId !=null and qwe.basicUnitId!=''">
               and  basic_unit_id=#{qwe.basicUnitId}
            </if>
            <if test="qwe.accidentStartTime!=null and qwe.accidentEndTime!=null ">
                AND accident_time between #{qwe.accidentStartTime} and #{qwe.accidentEndTime}
            </if>
             <if test="qwe.orgSql !=null and qwe.orgSql!=''">
               and  ${qwe.orgSql}
            </if>
            and  status='0'
        </where>

    </select>
    <select id="findExportlist" parameterType="com.testor.module.accident.model.req.AccidentReportExportReq" resultType="com.testor.module.accident.model.domain.AccidentReport" databaseId="kingbase">
        SELECT id,report_unit,accident_type,accident_level,accident_time,fake_type,basic_unit_id,regional_company_id,
        direct_economic_loss,
        indirect_economic_loss,
        total_economic_loss,
        accident_passed,
        improvements,
        accident_cause,remarks
        FROM t_accident_report
        <where>
            <if test="qwe.processStatus !=null and qwe.processStatus!=''">
                and process_status=#{qwe.processStatus}
            </if>
            <if test="qwe.idList !=null ">
                and   id in (#{qwe.idList})
            </if>
            <if test="qwe.regionalCompanyId !=null and qwe.regionalCompanyId!=''">
                and  regional_company_id=#{qwe.regionalCompanyId}
            </if>
            <if test="qwe.basicUnitId !=null and qwe.basicUnitId!=''">
                and  basic_unit_id=#{qwe.basicUnitId}
            </if>
            <if test="qwe.accidentStartTime!=null and qwe.accidentEndTime!=null ">
                AND accident_time between #{qwe.accidentStartTime} and #{qwe.accidentEndTime}
            </if>
            <if test="qwe.orgSql !=null and qwe.orgSql!=''">
                and  ${qwe.orgSql}
            </if>
            and  status='0'
        </where>

    </select>




</mapper>