BizWorkOrderUpdateMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.ezhizao.project.business.upgrade.mapper.BizWorkOrderUpdateMapper">
  6. <resultMap type="cn.ezhizao.project.business.upgrade.domain.BizWorkOrderUpdate" id="BizWorkOrderUpdateResult">
  7. <id column="id" property="id"/>
  8. </resultMap>
  9. <resultMap type="cn.ezhizao.project.business.upgrade.domain.BizWorkOrderUpdate" id="BizWorkOrderResult">
  10. <id column="id" property="id"/>
  11. <result column="company_id" jdbcType="BIGINT" property="companyId"/>
  12. <collection property="records" select="getRecords" column="id"/>
  13. <collection property="entrusts" select="getEntrusts" column="id"/>
  14. </resultMap>
  15. <resultMap type="cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord"
  16. id="BizWorkOrderRecordResult">
  17. <id column="id" property="id"/>
  18. </resultMap>
  19. <resultMap type="cn.ezhizao.project.business.entrust.domain.BizEntrust"
  20. id="BizEntrustResult">
  21. <id column="id" property="id"/>
  22. </resultMap>
  23. <select id="getList" parameterType="BizWorkOrderUpdate" resultMap="BizWorkOrderUpdateResult">
  24. SELECT * FROM biz_work_order_update
  25. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  26. deleted = 0
  27. <if test="type != null "> AND type = #{type}</if>
  28. <if test="noContract != null "> AND no_contract = #{noContract}</if>
  29. <if test="workOrderNo != null and workOrderNo != ''"> AND work_order_no = #{workOrderNo}</if>
  30. <if test="startMonth != null "> AND start_month = #{startMonth}</if>
  31. <if test="endMonth != null "> AND end_month = #{endMonth}</if>
  32. <if test="monthNum != null "> AND month_num = #{monthNum}</if>
  33. <if test="isStop != null "> AND is_stop = #{isStop}</if>
  34. <if test="provinceCode != null and provinceCode != ''"> AND province_code = #{provinceCode}</if>
  35. <if test="province != null and province != ''"> AND province = #{province}</if>
  36. <if test="cityCode != null and cityCode != ''"> AND city_code = #{cityCode}</if>
  37. <if test="city != null and city != ''"> AND city = #{city}</if>
  38. <if test="districtCode != null and districtCode != ''"> AND district_code = #{districtCode}</if>
  39. <if test="district != null and district != ''"> AND district = #{district}</if>
  40. <if test="isContinue != null "> AND is_continue = #{isContinue}</if>
  41. <if test="hasImportTasks != null "> AND has_import_tasks = #{hasImportTasks}</if>
  42. </trim>
  43. </select>
  44. <select id="getList2" parameterType="BizWorkOrderUpdate" resultMap="BizWorkOrderResult">
  45. SELECT t1.*, t2.name as company_name, t2.social_credit_code, t3.name as task_type_name, t4.name as
  46. task_type_detail_name, t5.nick_name as service_name, t2.is_zero,t2.tax_type,t6.contract_no FROM biz_work_order_update t1
  47. left join biz_company t2 on t2.id = t1.company_id
  48. left join biz_task_type t3 on t3.id = t1.task_type_id
  49. left join biz_task_type_detail t4 on t4.id = t1.task_type_detail_id
  50. left join sys_user t5 on t5.user_id = t1.service_id
  51. left join biz_archive_input_update t6 on t6.id = t1.contract_id
  52. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  53. t1.deleted = 0 and t1.is_stop = 0 and t1.type = 1
  54. <if test="id != null "> AND t1.id = #{id}</if>
  55. <if test="contractDetailId != null "> AND t1.contract_detail_id = #{contractDetailId}</if>
  56. <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
  57. <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
  58. <if test="serviceId != null">AND t1.service_id = #{serviceId}</if>
  59. <if test="noContract != null ">AND t1.no_contract = #{noContract}</if>
  60. <if test="workOrderNo != null and workOrderNo != ''">AND t1.work_order_no = #{workOrderNo}</if>
  61. <if test="startMonth != null ">AND t1.start_month = #{startMonth}</if>
  62. <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
  63. <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
  64. <if test="companyName != null and companyName != '' "> AND t2.name like concat('%', #{companyName}, '%')</if>
  65. <if test="isStop != null ">AND t1.is_stop = #{isStop}</if>
  66. <if test="year != null ">
  67. AND t1.start_month > 0
  68. <if test="month != null and month != ''">
  69. AND concat(#{year}, '-', #{month}, '-01') &gt;= (case when t1.task_type_id = 1 then DATE_ADD(t1.start_month, interval 1 month) else t1.start_month end) and concat(#{year}, '-', #{month}, '-01') &lt;= (case when t1.task_type_id = 1 then DATE_ADD(t1.end_month,interval 1 month) else t1.end_month end)
  70. </if>
  71. <if test="month == null or month == ''">
  72. AND #{year} >= (case when t1.task_type_id = 1 then DATE_FORMAT(DATE_ADD(t1.start_month,interval 1 month), '%Y') else DATE_FORMAT(t1.start_month, '%Y') end) AND #{year} &lt;= (case when t1.end_month = 0 then #{year} when t1.task_type_id = 1 then DATE_FORMAT(DATE_ADD(t1.end_month,interval 1 month), '%Y') else DATE_FORMAT(t1.end_month, '%Y') end)
  73. </if>
  74. </if>
  75. </trim>
  76. </select>
  77. <select id="gettoUpLoadList" parameterType="BizWorkOrderUpdate" resultMap="BizWorkOrderResult">
  78. SELECT t1.*, t2.name as company_name, t2.social_credit_code, t3.name as task_type_name, t4.name as
  79. task_type_detail_name, t5.nick_name as service_name, t2.is_zero,t2.tax_type,t6.contract_no FROM biz_work_order t1
  80. left join biz_company t2 on t2.id = t1.company_id
  81. left join biz_work_order_update orderupdate on orderupdate.id = t1.id and orderupdate.deleted = 0
  82. left join biz_task_type t3 on t3.id = t1.task_type_id
  83. left join biz_task_type_detail t4 on t4.id = t1.task_type_detail_id
  84. left join sys_user t5 on t5.user_id = t1.service_id
  85. left join biz_archive_input_update t6 on t6.id = t1.contract_id
  86. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  87. orderupdate.id is null and t1.type = 1 and t1.deleted = 0
  88. <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
  89. <if test="isStop != null "> AND t1.is_stop = #{isStop}</if>
  90. <if test="companyName != null and companyName != '' "> AND t2.name like concat('%', #{companyName}, '%')</if>
  91. </trim>
  92. </select>
  93. <select id="getToUpLoadCount" parameterType="BizWorkOrderUpdate" resultType="java.lang.Long">
  94. SELECT count(*) FROM biz_work_order t1
  95. left join biz_work_order_update orderupdate on orderupdate.id = t1.id and orderupdate.deleted = 0
  96. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  97. orderupdate.id is null and t1.type = 1 and t1.deleted = 0 and t1.is_stop = 0
  98. <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
  99. </trim>
  100. </select>
  101. <select id="selectByUpgradeId" resultType="cn.ezhizao.project.business.workOrder.domain.BizWorkOrder">
  102. select * from biz_work_order_update t1
  103. <where>
  104. <if test="tenantId != null "> and t1.tenant_id = #{tenantId}</if>
  105. </where>
  106. </select>
  107. <select id="getRecords" resultMap="BizWorkOrderRecordResult">
  108. SELECT * FROM biz_work_order_record WHERE deleted = 0 AND work_order_id = #{id}
  109. </select>
  110. <select id="getEntrusts" resultMap="BizEntrustResult">
  111. SELECT * FROM biz_entrust WHERE deleted = 0 AND work_order_id = #{id}
  112. </select>
  113. <delete id="physicalDelete">
  114. DELETE FROM biz_work_order_update
  115. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  116. id in
  117. <foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
  118. #{id}
  119. </foreach>
  120. <!-- 删除条件为其他外键可以在这里加 -->
  121. </trim>
  122. </delete>
  123. <select id="getNewOrder" resultType="cn.ezhizao.project.business.workOrder.domain.BizWorkOrder">
  124. select *from biz_work_order_update where is_new = 1 and is_stop = 0;
  125. </select>
  126. <select id="getStopTaskOrder" resultType="cn.ezhizao.project.business.workOrder.domain.BizWorkOrder">
  127. select *from biz_work_order_update where is_new = 1 and is_stop = 1;
  128. </select>
  129. </mapper>