PtServiceLogStatisMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.ruoyi.interfaces.mapper.PtServiceLogStatisMapper">
  4. <resultMap type="com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo" id="PtServiceLogStatisMap">
  5. <result property="statisTm" column="STATIS_TM" jdbcType="DATE"/>
  6. <result property="mdId" column="MD_ID" jdbcType="VARCHAR"/>
  7. <result property="mdName" column="MD_NAME" jdbcType="VARCHAR"/>
  8. <result property="serId" column="SER_ID" jdbcType="VARCHAR"/>
  9. <result property="serName" column="SER_NAME" jdbcType="VARCHAR"/>
  10. <result property="statusCode" column="STATUS_CODE" jdbcType="VARCHAR"/>
  11. <result property="statisNum" column="STATIS_NUM" jdbcType="INTEGER"/>
  12. </resultMap>
  13. <sql id="selectPtServiceLogStatis">
  14. select l.STATIS_TM,
  15. l.MD_ID,
  16. l.SER_ID,
  17. l.STATUS_CODE,
  18. l.STATIS_NUM,
  19. m.name as MD_NAME,
  20. s.name as SER_NAME
  21. from PT_SERVICE_LOG_STATIS l
  22. left join md_model_info m on l.MD_ID = m.MDID
  23. left join pt_service s on l.SER_ID = s.SRV_ID
  24. </sql>
  25. <insert id="insertPtServiceLogStatis">
  26. insert into PT_SERVICE_LOG_STATIS
  27. (STATIS_TM,
  28. MD_ID,
  29. SER_ID,
  30. STATUS_CODE,
  31. STATIS_NUM)
  32. values (#{statisTm,jdbcType=DATE},
  33. #{mdId,jdbcType=VARCHAR},
  34. #{serId,jdbcType=VARCHAR},
  35. #{statusCode,jdbcType=VARCHAR},
  36. #{statisNum,jdbcType=INTEGER})
  37. </insert>
  38. <update id="updatePtServiceLogStatis">
  39. update PT_SERVICE_LOG_STATIS
  40. STATIS_NUM = #{statisNum,jdbcType=INTEGER},
  41. where
  42. STATIS_TM = #{statisTm,jdbcType=DATE}
  43. and MD_ID = #{mdId,jdbcType=VARCHAR}
  44. and SER_ID = #{serId,jdbcType=VARCHAR}
  45. and STATUS_CODE = #{statusCode,jdbcType=VARCHAR}
  46. </update>
  47. <select id="selectPtServiceLogStatis" resultMap="PtServiceLogStatisMap">
  48. <include refid="selectPtServiceLogStatis"/>
  49. <where>
  50. and m.name is not null
  51. and s.name is not null
  52. <if test="statisTm != null ">
  53. and STATIS_TM = #{statisTm}
  54. </if>
  55. <if test="params.beginTime != null">
  56. and STATIS_TM &gt;= to_date(#{params.beginTime},'yyyy-mm-dd')
  57. </if>
  58. <if test="params.endTime != null">
  59. and STATIS_TM &lt;= to_date(#{params.endTime},'yyyy-mm-dd')
  60. </if>
  61. <if test="mdId != null and mdId != ''">
  62. and l.MD_ID = #{mdId}
  63. </if>
  64. <if test="serId != null and serId != ''">
  65. and l.SER_ID = #{serId}
  66. </if>
  67. <if test="statusCode != null and statusCode != ''">
  68. and STATUS_CODE = #{statusCode}
  69. </if>
  70. <if test="statisNum != null ">
  71. and STATIS_NUM = #{statisNum}
  72. </if>
  73. </where>
  74. ORDER BY STATIS_TM,MD_ID,SER_ID,STATUS_CODE
  75. </select>
  76. <select id="selectPtServiceLogStatisMonthList"
  77. resultMap="PtServiceLogStatisMap">
  78. select l.STATIS_TM,
  79. l.MD_ID,
  80. l.SER_ID,
  81. l.STATUS_CODE,
  82. l.STATIS_NUM,
  83. m.name as MD_NAME,
  84. s.name as SER_NAME
  85. from (
  86. SELECT
  87. mmdd AS STATIS_TM ,MD_ID,SER_ID,STATUS_CODE,sum(statis_num) statis_num
  88. FROM (
  89. SELECT t.*,to_char(STATIS_TM,'yyyy-mm' ) || '-01' mmdd FROM PT_SERVICE_LOG_STATIS t
  90. <where>
  91. <if test="params.beginTime != null">
  92. and STATIS_TM &gt;= to_date(#{params.beginTime},'yyyy-mm-dd')
  93. </if>
  94. <if test="params.endTime != null">
  95. and STATIS_TM &lt;= to_date(#{params.endTime},'yyyy-mm-dd')
  96. </if>
  97. <if test="mdId != null and mdId != ''">
  98. and t.MD_ID = #{mdId}
  99. </if>
  100. <if test="serId != null and serId != ''">
  101. and t.SER_ID = #{serId}
  102. </if>
  103. <if test="statusCode != null and statusCode != ''">
  104. and STATUS_CODE = #{statusCode}
  105. </if>
  106. </where>
  107. ) GROUP BY mmdd,MD_ID,SER_ID,STATUS_CODE
  108. ) l
  109. left join md_model_info m on l.MD_ID = m.MDID
  110. left join pt_service s on l.SER_ID = s.SRV_ID
  111. <where>
  112. and m.name is not null
  113. and s.name is not null
  114. </where>
  115. </select>
  116. </mapper>