You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
3.4 KiB
XML

5 months ago
<?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.iocoder.yudao.module.product.dal.mysql.landplan.LandPlanMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="queryLandPlansMap" type="cn.iocoder.yudao.module.product.controller.admin.landplan.vo.LandPlanRespVO">
<result column="land_id" property="landId"></result>
<result column="land_type" property="landType"></result>
<result column="plan_start_time" property="planStartTime"></result>
<result column="plan_end_time" property="planEndTime"></result>
<result column="belong_business_id" property="belongBusinessId"></result>
<collection property="landJobs" column="landId=land_id,landType=landType,planStartTime=plan_start_time,planEndTime=plan_end_time,belongBusinessId=belong_business_id" select="queryLandJobs"></collection>
</resultMap>
<select id="queryLandPlansByParams" resultMap="queryLandPlansMap">
select
lp.*, li.land_type landType
from
product_land_plan lp
left join product_land_info li on li.land_id = lp.land_id
<where>
lp.deleted = 0 and li.deleted = 0
<if test="params.goodsId != null and params.goodsId != ''">
and lp.goods_id = #{params.goodsId}
</if>
<if test="params.planIds != null and params.planIds.size() > 0">
and lp.land_plan_id in
<foreach collection="params.planIds" open="(" close=")" item="planId" separator=",">
#{planId}
</foreach>
</if>
<if test="params.ids != null and params.ids.size() > 0">
and lp.id in
<foreach collection="params.ids" open="(" close=")" item="id" separator=",">
#{id}
</foreach>
</if>
</where>
</select>
<resultMap id="queryLandJobsMap" type="cn.iocoder.yudao.module.product.controller.admin.landjob.vo.LandJobRespVO">
<result column="land_job_id" property="landJobId"></result>
<collection property="landJobInputs" column="landJobId=land_job_id" select="queryJobInputs"></collection>
</resultMap>
<select id="queryLandJobs" resultMap="queryLandJobsMap">
select plj.*, pljt.type_name jobTypeName from
product_land_job plj
left join product_land_job_type pljt on pljt.id = plj.job_type
where plj.deleted = 0
and plj.land_id = #{landId}
and plj.land_type = #{landType}
AND (unix_timestamp(plj.job_date) BETWEEN unix_timestamp(#{planStartTime}) and unix_timestamp(#{planEndTime}))
and plj.belong_business_id = #{belongBusinessId}
order by plj.job_date
</select>
<select id="queryJobInputs" resultType="cn.iocoder.yudao.module.product.controller.admin.landjobinputs.vo.LandJobInputsRespVO">
select * from
product_land_job_inputs
where deleted = 0
and land_job_id = #{landJobId}
</select>
</mapper>