DeviceLogMapper.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.management.platform.mapper.DeviceLogMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.DeviceLog">
  6. <id column="id" property="id" />
  7. <result column="device_id" property="deviceId" />
  8. <result column="project_id" property="projectId" />
  9. <result column="start_time" property="startTime" />
  10. <result column="end_time" property="endTime" />
  11. <result column="create_date" property="createDate" />
  12. <result column="usage_user_id" property="usageUserId" />
  13. <result column="usage_cost" property="usageCost" />
  14. <result column="use_time" property="useTime" />
  15. </resultMap>
  16. <!-- 通用查询结果列 -->
  17. <sql id="Base_Column_List">
  18. id, device_id, project_id, start_time, end_time, create_date, usage_user_id, usage_cost, use_time
  19. </sql>
  20. <select id="getDeviceLogList" resultType="java.util.HashMap">
  21. SELECT d.id deviceId,d.device_code deviceCode,d.device_name deviceName,d.usage_status usageStatus,d.usage_user_id usageUserId,
  22. p.project_code projectCode,p.project_name projectName,p.id projectId,
  23. dl.create_date createDate,dl.start_time startTime,dl.end_time endTime,dl.id deviceLogId,dl.use_time useTime
  24. from device d
  25. inner join device_log dl on d.id=dl.device_id
  26. INNER JOIN project p on dl.project_id=p.id
  27. <where>
  28. <if test="hashMap.startDate !=null and hashMap.endDate !=null ">
  29. and dl.start_time BETWEEN #{hashMap.startDate} and #{hashMap.endDate}
  30. </if>
  31. <if test="hashMap.companyId!=null">
  32. and d.company_id=#{hashMap.companyId}
  33. </if>
  34. <if test="hashMap.usageUserId!=null">
  35. and dl.usage_user_id=#{hashMap.usageUserId}
  36. </if>
  37. <if test="hashMap.deviceLogId!=null">
  38. and dl.id=#{hashMap.deviceLogId}
  39. </if>
  40. </where>
  41. order by dl.id desc
  42. </select>
  43. <select id="selectListGroupByProject" resultType="java.util.Map">
  44. select p.id id,p.project_code projectCode,p.project_name projectName,sum(dl.usage_cost) costMoney,sum(dl.use_time) cost
  45. from project p
  46. inner JOIN device_log dl on p.id=dl.project_id
  47. <where>
  48. <if test="startDate !=null and startDate!='' and endDate !=null and endDate!='' ">
  49. and dl.start_time BETWEEN #{startDate} and #{endDate}
  50. </if>
  51. <if test="companyId!=null">
  52. and p.company_id=#{companyId}
  53. </if>
  54. <if test="projectId!=null">
  55. and p.id=#{projectId}
  56. </if>
  57. </where>
  58. group by p.id ,p.project_code,p.project_name
  59. </select>
  60. </mapper>