123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper" >
- <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan" >
- <id column="id" property="id" jdbcType="BIGINT" />
- <result column="lift_id" property="liftId" jdbcType="BIGINT" />
- <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
- <result column="project_id" property="projectId" jdbcType="BIGINT" />
- <result column="worker_id" property="workerId" jdbcType="BIGINT" />
- <result column="plan_date" property="planDate" jdbcType="TIMESTAMP" />
- <result column="work_date" property="workDate" jdbcType="TIMESTAMP" />
- <result column="count" property="count" jdbcType="INTEGER" />
- <result column="type" property="type" jdbcType="TINYINT" />
- <result column="status" property="status" jdbcType="TINYINT" />
- <result column="demand" property="demand" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="Base_Column_List" >
- id, lift_id, mt_company_id, project_id, worker_id, plan_date, work_date, count, type,
- status
- </sql>
- <select id="findByCondition" resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenancePlanResponse"
- parameterType="cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenancePlanRequest">
- SELECT
- mp.id AS id,
- if(isnull(mp.id), '0', '1') AS status,
- mp.plan_date AS planDate,
- l.id AS liftId,
- l.registration_code AS registrationCode,
- l.device_position AS devicePosition,
- plr.id AS relevanceId,
- plr.mt_company_id AS mtCompanyId,
- plr.worker_id AS workerId,
- plr.plan_interval AS planInterval,
- p.id AS projectId,
- p.project_name AS projectName,
- p.project_code AS projectCode,
- pclr.lift_company_status AS liftStatus,
- r.area_name AS regionName,
- ui.name AS workerName
- FROM
- project_lift_relevance plr
- LEFT JOIN platform_company_lift_relevance pclr ON plr.mt_company_id = pclr.mt_company_id AND plr.lift_id = pclr.lift_id
- LEFT JOIN lift l ON plr.lift_id = l.id
- LEFT JOIN project p ON plr.mt_company_id = p.mt_company_id AND plr.project_id = p.id
- LEFT JOIN maintenance_plan mp ON plr.mt_company_id = mp.mt_company_id AND plr.project_id = mp.project_id
- AND mp.status = 0 AND mp.plan_date = (SELECT MIN(plan_date) FROM maintenance_plan WHERE status = 0
- AND mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR} AND lift_id = plr.lift_id) AND plr.lift_id = mp.lift_id
- LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
- LEFT JOIN region r ON p.region_id = r.id
- WHERE plr.mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR}
- <if test="request.projectId!=null and request.projectId!=''">
- AND p.id = #{request.projectId,jdbcType=BIGINT}
- </if>
- <if test="request.workerId!=null and request.workerId!=''">
- AND mp.worker_id = #{request.workerId,jdbcType=BIGINT}
- </if>
- <if test="request.regionId!=null and request.regionId!=''">
- AND p.region_id = #{request.regionId,jdbcType=BIGINT}
- </if>
- <if test="request.planInterval!=null and request.planInterval!=''">
- AND plr.plan_interval = #{request.planInterval,jdbcType=INTEGER}
- </if>
- <if test="request.beginTime!=null and request.beginTime!=''">
- AND mp.plan_date > #{request.beginTime,jdbcType=VARCHAR}
- </if>
- <if test="request.endTime!=null and request.endTime!=''">
- AND <![CDATA[mp.plan_date < #{request.endTime,jdbcType=VARCHAR}]]>
- </if>
- <if test="request.registrationCode!=null and request.registrationCode!=''">
- AND l.registration_code LIKE #{request.registrationCode,jdbcType=VARCHAR}
- </if>
- </select>
- <!--app端 保养任务列表 -->
- <select id="findListByWorkerId" resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenanceAppResponse"
- parameterType="cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceAppRequest">
- SELECT p.project_name AS projectName,
- p.id AS projectId,
- mp.id AS mtPlanId,
- mr.id AS recordId,
- l.id AS liftId,
- l.coordinate AS coordinate,
- l.registration_code AS registrationCode,
- l.use_company_code AS useCompanyCode,
- l.lift_type AS liftType,
- l.lift_code AS liftCode,
- ui.name AS workerName,
- mp.worker_id AS workerId,
- mp.plan_date AS planDate,
- mp.type AS maintenanceType,
- mr.status AS status
- FROM maintenance_plan mp
- LEFT JOIN maintenance_record mr ON mp.id = mr.mt_plan_id
- LEFT JOIN project p ON mp.project_id = p.id
- LEFT JOIN lift l ON mp.lift_id = l.id
- LEFT JOIN user_info ui ON mp.worker_id = ui.user_id
- WHERE 1=1
- <if test="request.workerId!=null and request.workerId!=''">
- AND mp.worker_id = #{request.workerId,jdbcType=BIGINT}
- </if>
- <if test="request.status!=null and request.status!=''">
- AND mp.status = #{request.status,jdbcType=VARCHAR}
- </if>
- </select>
- </mapper>
|