| | |
| | | </select> |
| | | |
| | | <select id="useCountStatic" resultType="com.gkhy.hazmat.system.domain.vo.HzHazmatUseVO"> |
| | | select count(*) as count,basic_id from hz_hazmat |
| | | where create_time >= #{startTime} and create_time <= #{endTime} and state =3 |
| | | SELECT |
| | | count(*) AS count, |
| | | hh2.basic_id |
| | | FROM |
| | | hz_hazmat hh2 |
| | | LEFT JOIN hz_hazmat_flow hhf2 on hh2.id = hhf2.hazmat_id |
| | | LEFT JOIN sys_user sy on hhf2.create_id = sy.id |
| | | LEFT JOIN sys_dept sd on sy.depart_id = sd.id |
| | | where hh2.create_time >= #{startTime} and hh2.create_time <= #{endTime} and hh2.state =3 and hhf2.state = 4 |
| | | <if test="companyId!=null"> |
| | | and company_id=#{companyId} |
| | | and hh2.company_id=#{companyId} |
| | | </if> |
| | | group by basic_id |
| | | order by count desc |
| | | <if test="userId!=null"> |
| | | and hhf2.create_id = #{userId} |
| | | </if> |
| | | <if test="departId!=null"> |
| | | and sd.id = #{departId} |
| | | </if> |
| | | GROUP BY |
| | | hh2.basic_id |
| | | ORDER BY |
| | | count DESC |
| | | </select> |
| | | |
| | | |
| | |
| | | order by a.id |
| | | limit #{startIndex},#{pageSize} |
| | | </select> |
| | | <select id="useCountHourlyStatic" resultType="com.gkhy.hazmat.system.domain.vo.HzEntryRecordVO"> |
| | | SELECT |
| | | DATE_FORMAT(create_time, '%H') AS hour, |
| | | COUNT(*) AS count |
| | | FROM hz_hazmat |
| | | WHERE create_time >= #{startDate} |
| | | AND create_time < #{endDate} |
| | | AND state IN (2, 3) |
| | | <if test="companyId != null"> |
| | | AND company_id = #{companyId} |
| | | </if> |
| | | GROUP BY hour |
| | | ORDER BY hour ASC |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="companyMessage" resultType="com.gkhy.hazmat.system.domain.vo.HzCompanyMessage"> |
| | | SELECT |
| | | sc.id, |
| | | sc.name as company_name, |
| | | scf.longitude, |
| | | scf.latitude, |
| | | COALESCE(hw.warehouse_count, 0) AS warehouse_count, |
| | | COALESCE(htw.warning_count, 0) AS warning_count, |
| | | htw.latest_warning_time |
| | | FROM sys_company sc |
| | | LEFT JOIN ( |
| | | SELECT company_id, COUNT(*) AS warehouse_count |
| | | FROM hz_warehouse |
| | | WHERE del_flag = 0 |
| | | GROUP BY company_id |
| | | ) hw ON sc.id = hw.company_id |
| | | LEFT JOIN ( |
| | | SELECT |
| | | company_id, |
| | | COUNT(*) AS warning_count, |
| | | MAX(create_time) AS latest_warning_time |
| | | FROM hz_taboo_warning |
| | | WHERE del_flag = 0 |
| | | GROUP BY company_id |
| | | ) htw ON sc.id = htw.company_id |
| | | LEFT JOIN sys_config scf on sc.id = scf.company_id |
| | | <where> |
| | | sc.del_flag = 0 |
| | | <if test="type!=null"> |
| | | and sc.type = #{type} |
| | | </if> |
| | | </where> |
| | | ORDER BY htw.latest_warning_time DESC; |
| | | </select> |
| | | <select id="countTotal" resultType="java.lang.Integer"> |
| | | SELECT |
| | | COUNT(*) AS total_count |
| | | FROM hz_hazmat |
| | | WHERE state IN (2, 3) |
| | | <if test="companyId != null"> |
| | | AND company_id = #{companyId} |
| | | </if> |
| | | </select> |
| | | <!-- SELECT COUNT(*) AS count, DATE_FORMAT(create_time, '%H') AS hour--> |
| | | <!-- FROM hz_hazmat--> |
| | | <!-- WHERE create_time >= #{startDate} AND create_time < #{endDate}--> |
| | | <!-- AND state IN (2, 3)--> |
| | | <!-- <if test="companyId != null">--> |
| | | <!-- AND company_id = #{companyId}--> |
| | | <!-- </if>--> |
| | | <!-- GROUP BY hour--> |
| | | <!-- ORDER BY hour ASC--> |
| | | </mapper> |