BizWorkOrderUpdateMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. </resultMap>
  14. <resultMap type="cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord"
  15. id="BizWorkOrderRecordResult">
  16. <id column="id" property="id"/>
  17. </resultMap>
  18. <select id="getList" parameterType="BizWorkOrderUpdate" resultMap="BizWorkOrderUpdateResult">
  19. SELECT * FROM biz_work_order_update
  20. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  21. deleted = 0
  22. <if test="type != null "> AND type = #{type}</if>
  23. <if test="noContract != null "> AND no_contract = #{noContract}</if>
  24. <if test="workOrderNo != null and workOrderNo != ''"> AND work_order_no = #{workOrderNo}</if>
  25. <if test="startMonth != null "> AND start_month = #{startMonth}</if>
  26. <if test="endMonth != null "> AND end_month = #{endMonth}</if>
  27. <if test="monthNum != null "> AND month_num = #{monthNum}</if>
  28. <if test="isStop != null "> AND is_stop = #{isStop}</if>
  29. <if test="provinceCode != null and provinceCode != ''"> AND province_code = #{provinceCode}</if>
  30. <if test="province != null and province != ''"> AND province = #{province}</if>
  31. <if test="cityCode != null and cityCode != ''"> AND city_code = #{cityCode}</if>
  32. <if test="city != null and city != ''"> AND city = #{city}</if>
  33. <if test="districtCode != null and districtCode != ''"> AND district_code = #{districtCode}</if>
  34. <if test="district != null and district != ''"> AND district = #{district}</if>
  35. <if test="isContinue != null "> AND is_continue = #{isContinue}</if>
  36. <if test="hasImportTasks != null "> AND has_import_tasks = #{hasImportTasks}</if>
  37. </trim>
  38. </select>
  39. <select id="getList2" parameterType="BizWorkOrderUpdate" resultMap="BizWorkOrderResult">
  40. SELECT t1.*, t2.name as company_name, t2.social_credit_code, t3.name as task_type_name, t4.name as
  41. 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
  42. left join biz_company t2 on t2.id = t1.company_id
  43. left join biz_task_type t3 on t3.id = t1.task_type_id
  44. left join biz_task_type_detail t4 on t4.id = t1.task_type_detail_id
  45. left join sys_user t5 on t5.user_id = t1.service_id
  46. left join biz_archive_input_update t6 on t6.id = t1.contract_id
  47. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  48. t1.deleted = 0
  49. <if test="id != null "> AND t1.id = #{id}</if>
  50. <if test="contractDetailId != null "> AND t1.contract_detail_id = #{contractDetailId}</if>
  51. <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
  52. <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
  53. <if test="type != null ">AND t1.type = #{type}</if>
  54. <if test=" serviceId != null">AND t1.service_id = #{serviceId}</if>
  55. <if test="noContract != null ">AND t1.no_contract = #{noContract}</if>
  56. <if test="workOrderNo != null and workOrderNo != ''">AND t1.work_order_no = #{workOrderNo}</if>
  57. <if test="startMonth != null ">AND t1.start_month = #{startMonth}</if>
  58. <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
  59. <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
  60. <if test="companyName != null and companyName != '' "> AND t2.name like concat('%', #{companyName}, '%')</if>
  61. <if test="isStop != null ">AND t1.is_stop = #{isStop}</if>
  62. <if test="year != null ">
  63. AND t1.start_month > 0
  64. <if test="month != null and month != ''">
  65. 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)
  66. </if>
  67. <if test="month == null or month == ''">
  68. 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)
  69. </if>
  70. </if>
  71. </trim>
  72. </select>
  73. <select id="gettoUpLoadList" parameterType="BizWorkOrderUpdate" resultMap="BizWorkOrderResult">
  74. SELECT t1.*, t2.name as company_name, t2.social_credit_code, t3.name as task_type_name, t4.name as
  75. task_type_detail_name, t5.nick_name as service_name, t2.is_zero,t2.tax_type FROM biz_work_order t1
  76. left join biz_company t2 on t2.id = t1.company_id
  77. left join biz_work_order_update orderupdate on orderupdate.id = t1.id and orderupdate.deleted = 0
  78. left join biz_task_type t3 on t3.id = t1.task_type_id
  79. left join biz_task_type_detail t4 on t4.id = t1.task_type_detail_id
  80. left join sys_user t5 on t5.user_id = t1.service_id
  81. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  82. orderupdate.id is null and t1.type = 1
  83. <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
  84. <if test="companyName != null and companyName != '' "> AND t2.name like concat('%', #{companyName}, '%')</if>
  85. </trim>
  86. </select>
  87. <select id="getToUpLoadCount" parameterType="BizWorkOrderUpdate" resultType="java.lang.Long">
  88. SELECT count(*) FROM biz_work_order t1
  89. left join biz_work_order_update orderupdate on orderupdate.id = t1.id and orderupdate.deleted = 0
  90. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  91. orderupdate.id is null and t1.type = 1
  92. <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
  93. </trim>
  94. </select>
  95. <select id="selectByUpgradeId" resultType="cn.ezhizao.project.business.workOrder.domain.BizWorkOrder">
  96. select * from biz_work_order_update t1
  97. <where>
  98. <if test="tenantId != null "> and t1.tenant_id = #{tenantId}</if>
  99. </where>
  100. </select>
  101. <select id="getRecords" resultMap="BizWorkOrderRecordResult">
  102. SELECT * FROM biz_work_order_record WHERE deleted = 0 AND work_order_id = #{id}
  103. </select>
  104. <delete id="physicalDelete">
  105. DELETE FROM biz_work_order_update
  106. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  107. id in
  108. <foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
  109. #{id}
  110. </foreach>
  111. <!-- 删除条件为其他外键可以在这里加 -->
  112. </trim>
  113. </delete>
  114. <select id="getNewOrder" resultType="cn.ezhizao.project.business.workOrder.domain.BizWorkOrder">
  115. select *from biz_work_order_update where is_new = 1
  116. </select>
  117. </mapper>