MaintenancePlanMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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="cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper" >
  4. <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan" >
  5. <id column="id" property="id" jdbcType="BIGINT" />
  6. <result column="lift_id" property="liftId" jdbcType="BIGINT" />
  7. <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
  8. <result column="project_id" property="projectId" jdbcType="BIGINT" />
  9. <result column="worker_id" property="workerId" jdbcType="BIGINT" />
  10. <result column="plan_date" property="planDate" jdbcType="TIMESTAMP" />
  11. <result column="work_date" property="workDate" jdbcType="TIMESTAMP" />
  12. <result column="count" property="count" jdbcType="INTEGER" />
  13. <result column="type" property="type" jdbcType="TINYINT" />
  14. <result column="status" property="status" jdbcType="TINYINT" />
  15. <result column="demand" property="demand" jdbcType="VARCHAR" />
  16. </resultMap>
  17. <sql id="Base_Column_List" >
  18. id, lift_id, mt_company_id, project_id, worker_id, plan_date, work_date, count, type,
  19. status
  20. </sql>
  21. <select id="findByCondition" resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenancePlanResponse"
  22. parameterType="cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenancePlanRequest">
  23. SELECT
  24. mp.id AS id,
  25. if(isnull(mp.id), '0', '1') AS status,
  26. mp.plan_date AS planDate,
  27. l.id AS liftId,
  28. l.registration_code AS registrationCode,
  29. l.device_position AS devicePosition,
  30. plr.id AS relevanceId,
  31. plr.mt_company_id AS mtCompanyId,
  32. plr.worker_id AS workerId,
  33. plr.plan_interval AS planInterval,
  34. p.id AS projectId,
  35. p.project_name AS projectName,
  36. p.project_code AS projectCode,
  37. pclr.lift_company_status AS liftStatus,
  38. r.area_name AS regionName,
  39. ui.name AS workerName
  40. FROM
  41. project_lift_relevance plr
  42. LEFT JOIN platform_company_lift_relevance pclr ON plr.mt_company_id = pclr.mt_company_id AND plr.lift_id = pclr.lift_id
  43. LEFT JOIN lift l ON plr.lift_id = l.id
  44. LEFT JOIN project p ON plr.mt_company_id = p.mt_company_id AND plr.project_id = p.id
  45. LEFT JOIN maintenance_plan mp ON plr.mt_company_id = mp.mt_company_id AND plr.project_id = mp.project_id
  46. AND mp.status = 0 AND mp.plan_date = (SELECT MIN(plan_date) FROM maintenance_plan WHERE status = 0
  47. AND mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR} AND lift_id = plr.lift_id) AND plr.lift_id = mp.lift_id
  48. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  49. LEFT JOIN region r ON p.region_id = r.id
  50. WHERE plr.mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR}
  51. <if test="request.projectId!=null and request.projectId!=''">
  52. AND p.id = #{request.projectId,jdbcType=BIGINT}
  53. </if>
  54. <if test="request.workerId!=null and request.workerId!=''">
  55. AND mp.worker_id = #{request.workerId,jdbcType=BIGINT}
  56. </if>
  57. <if test="request.regionId!=null and request.regionId!=''">
  58. AND p.region_id = #{request.regionId,jdbcType=BIGINT}
  59. </if>
  60. <if test="request.planInterval!=null and request.planInterval!=''">
  61. AND plr.plan_interval = #{request.planInterval,jdbcType=INTEGER}
  62. </if>
  63. <if test="request.beginTime!=null and request.beginTime!=''">
  64. AND mp.plan_date > #{request.beginTime,jdbcType=VARCHAR}
  65. </if>
  66. <if test="request.endTime!=null and request.endTime!=''">
  67. AND <![CDATA[mp.plan_date < #{request.endTime,jdbcType=VARCHAR}]]>
  68. </if>
  69. <if test="request.registrationCode!=null and request.registrationCode!=''">
  70. AND l.registration_code LIKE #{request.registrationCode,jdbcType=VARCHAR}
  71. </if>
  72. </select>
  73. <!--app端 保养任务列表 -->
  74. <select id="findListByWorkerId" resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenanceAppResponse"
  75. parameterType="cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceAppRequest">
  76. SELECT p.project_name AS projectName,
  77. p.id AS projectId,
  78. mp.id AS mtPlanId,
  79. mr.id AS recordId,
  80. l.id AS liftId,
  81. l.coordinate AS coordinate,
  82. l.registration_code AS registrationCode,
  83. l.use_company_code AS useCompanyCode,
  84. l.lift_type AS liftType,
  85. l.lift_code AS liftCode,
  86. ui.name AS workerName,
  87. mp.worker_id AS workerId,
  88. mp.plan_date AS planDate,
  89. mp.type AS maintenanceType,
  90. mr.status AS status
  91. FROM maintenance_plan mp
  92. LEFT JOIN maintenance_record mr ON mp.id = mr.mt_plan_id
  93. LEFT JOIN project p ON mp.project_id = p.id
  94. LEFT JOIN lift l ON mp.lift_id = l.id
  95. LEFT JOIN user_info ui ON mp.worker_id = ui.user_id
  96. WHERE 1=1
  97. <if test="request.workerId!=null and request.workerId!=''">
  98. AND mp.worker_id = #{request.workerId,jdbcType=BIGINT}
  99. </if>
  100. <if test="request.status!=null and request.status!=''">
  101. AND mp.status = #{request.status,jdbcType=VARCHAR}
  102. </if>
  103. </select>
  104. </mapper>