BizCarrierMapper.xml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.mapper.BizCarrierMapper">
  6. <resultMap type="cn.ezhizao.project.business.domain.BizCarrier" id="BizCarrierResult">
  7. <id column="id" property="id"/>
  8. </resultMap>
  9. <select id="getList" resultMap="BizCarrierResult" parameterType="cn.ezhizao.project.business.domain.BizCarrier">
  10. select t1.id,t1.category_id,t1.code,t1.qc_code,t1.remark,t1.tenant_id,t1.is_allow_more,COALESCE((SELECT t2.is_abandoned FROM biz_carrier_reject t2 WHERE t1.id = t2.carrier_id ORDER BY t2.create_time DESC LIMIT 1), 0) AS is_abandoned
  11. FROM biz_carrier t1
  12. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  13. deleted = 0
  14. <if test="categoryId != null and categoryId != 0"> AND category_id = #{categoryId}</if>
  15. <if test="tenantId != null and tenantId != 0"> AND tenant_id = #{tenantId}</if>
  16. <if test="code != null and code != ''"> AND code LIKE CONCAT('%', #{code}, '%')</if>
  17. <if test="isAbandoned != null"> AND is_abandoned = #{isAbandoned}</if>
  18. <!-- 未关联任何生产单 -->
  19. <if test="notInUse == 1">
  20. AND not exists (select 1 from biz_daywork_carrier t where t.is_changed = 0 and t.carrier_id = t1.id and t.deleted = 0)
  21. </if>
  22. </trim>
  23. </select>
  24. <select id="getListFromOutsource" resultMap="BizCarrierResult" parameterType="cn.ezhizao.project.business.domain.BizCarrier">
  25. select t1.id,t1.category_id,t1.code,t1.qc_code,t1.remark,t1.tenant_id,t1.is_allow_more,COALESCE((SELECT t2.is_abandoned FROM biz_carrier_reject t2 WHERE t1.id = t2.carrier_id ORDER BY t2.create_time DESC LIMIT 1), 0) AS is_abandoned
  26. FROM biz_carrier t1 left join biz_carrier_category t2 on t2.id = t1.category_id
  27. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  28. t1.deleted = 0 and t2.is_inspection = 0 and t2.is_none = 0
  29. <if test="categoryId != null and categoryId != 0"> AND t1.category_id = #{categoryId}</if>
  30. <if test="code != null and code != ''"> AND t1.code=#{code}</if>
  31. <!-- 未关联任何生产单 -->
  32. <if test="notInUse == 1">
  33. AND case when t1.is_allow_more = 0 then (not exists (select 1 from biz_daywork_carrier t where t.is_changed = 0 and t.carrier_id = t1.id and t.daywork_id != #{dayworkId} and t.deleted = 0)) else true end
  34. </if>
  35. </trim>
  36. </select>
  37. <update id="unAbandoned">
  38. update biz_carrier
  39. <set>
  40. is_abandoned=0,
  41. abandonment_date = '0000-00-00 00:00:00.000000',
  42. abandonment_reason = ''
  43. </set>
  44. where id = #{id}
  45. </update>
  46. <delete id="physicalDelete">
  47. DELETE FROM biz_carrier
  48. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  49. <if test="id != null">
  50. id = #{id} AND
  51. </if>
  52. <!-- 删除条件为其他外键可以在这里加 -->
  53. </trim>
  54. </delete>
  55. </mapper>