| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?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.management.platform.mapper.DeviceLogMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.management.platform.entity.DeviceLog">
- <id column="id" property="id" />
- <result column="device_id" property="deviceId" />
- <result column="project_id" property="projectId" />
- <result column="start_time" property="startTime" />
- <result column="end_time" property="endTime" />
- <result column="create_date" property="createDate" />
- <result column="usage_user_id" property="usageUserId" />
- <result column="usage_cost" property="usageCost" />
- <result column="use_time" property="useTime" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, device_id, project_id, start_time, end_time, create_date, usage_user_id, usage_cost, use_time
- </sql>
- <select id="getDeviceLogList" resultType="java.util.HashMap">
- SELECT d.id deviceId,d.device_code deviceCode,d.device_name deviceName,d.usage_status usageStatus,d.usage_user_id usageUserId,
- p.project_code projectCode,p.project_name projectName,p.id projectId,
- dl.create_date createDate,dl.start_time startTime,dl.end_time endTime,dl.id deviceLogId,dl.use_time useTime
- from device d
- inner join device_log dl on d.id=dl.device_id
- INNER JOIN project p on dl.project_id=p.id
- <where>
- <if test="hashMap.startDate !=null and hashMap.endDate !=null ">
- and dl.start_time BETWEEN #{hashMap.startDate} and #{hashMap.endDate}
- </if>
- <if test="hashMap.companyId!=null">
- and d.company_id=#{hashMap.companyId}
- </if>
- <if test="hashMap.usageUserId!=null">
- and dl.usage_user_id=#{hashMap.usageUserId}
- </if>
- <if test="hashMap.deviceLogId!=null">
- and dl.id=#{hashMap.deviceLogId}
- </if>
- </where>
- order by dl.id desc
- </select>
- <select id="selectListGroupByProject" resultType="java.util.Map">
- select p.id id,p.project_code projectCode,p.project_name projectName,sum(dl.usage_cost) costMoney,sum(dl.use_time) cost
- from project p
- inner JOIN device_log dl on p.id=dl.project_id
- <where>
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate!='' ">
- and dl.start_time BETWEEN #{startDate} and #{endDate}
- </if>
- <if test="companyId!=null">
- and p.company_id=#{companyId}
- </if>
- <if test="projectId!=null">
- and p.id=#{projectId}
- </if>
- </where>
- group by p.id ,p.project_code,p.project_name
- </select>
- </mapper>
|