| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?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="com.yunfeiyun.agmp.fms.mapper.FmsBlockMapper">
- <sql id="selectFmsBlockVo">
- select blockId, landId, blockName, blockType, blockManager, blockManagername, blockArea, blockAreaplant,blockSeq,
- blockLngrange, blockColor, blockRemark, blockIcon, tid, blockIstransfer, blockTransferinfo, blockOwnerinfo from FmsBlock
- </sql>
- <sql id="selectFmsBlockHasResVo">
- select b.blockId, b.landId, b.blockName, b.blockType, b.blockManager, b.blockManagername, b.blockArea, b.blockSeq, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon, b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,
- (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = b.blockId) blockPreview,
- (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = b.blockId) resIds,
- b.tid
- from FmsBlock b
- </sql>
- <sql id="selectFmsBlockHasResVo2">
- select b.blockId, b.landId, b.blockName, b.blockType, b.blockManager, b.blockManagername, b.blockArea,
- b.blockSeq, b.tid, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon, l.landName,
- b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,
- (select GROUP_CONCAT(c.cropName) from FmsCrop c
- left join FmsPlan p on p.cropId = c.cropId
- where p.blockId = b.blockId) cropName,
- (select GROUP_CONCAT(r.resUrl) from FmsCrop c
- left join FmsPlan p on p.cropId = c.cropId
- left join SysRes r on r.resBusId = c.cropId
- where p.blockId = b.blockId and r.resBiztype = 'CROP') cropPreview,
- (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = b.blockId) blockPreview,
- (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = b.blockId) resIds
- from FmsBlock b
- left join FmsLand l on b.landId = l.landId
- </sql>
- <select id="selectFmsBlockList" parameterType="FmsBlock" resultType="com.yunfeiyun.agmp.fms.domain.FmsBlock">
- <include refid="selectFmsBlockHasResVo"/>
- <where>
- b.tid = #{tid}
- <if test="landId != null and landId != ''"> and landId = #{landId}</if>
- <if test="blockName != null and blockName != ''"> and blockName like concat('%', #{blockName}, '%')</if>
- <if test="blockNameEq != null and blockNameEq != ''"> and blockName = #{blockNameEq}</if>
- <if test="blockType != null and blockType != ''"> and blockType = #{blockType}</if>
- <if test="blockManager != null and blockManager != ''"> and blockManager = #{blockManager}</if>
- <if test="blockManagername != null and blockManagername != ''"> and blockManagername like concat('%', #{blockManagername}, '%')</if>
- <if test="blockArea != null "> and blockArea = #{blockArea}</if>
- <if test="blockAreaplant != null "> and blockAreaplant = #{blockAreaplant}</if>
- <if test="blockLngrange != null and blockLngrange != ''"> and blockLngrange = #{blockLngrange}</if>
- <if test="blockColor != null and blockColor != ''"> and blockColor = #{blockColor}</if>
- <if test="blockRemark != null and blockRemark != ''"> and blockRemark = #{blockRemark}</if>
- <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">
- and b.blockId in
- <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
- #{blockId}
- </foreach>
- </if>
- </where>
- order by b.blockSeq
- </select>
- <select id="selectFmsBlockByBlockId" parameterType="String" resultType="com.yunfeiyun.agmp.fms.domain.FmsBlock">
- <include refid="selectFmsBlockHasResVo"/>
- <where>
- blockId = #{blockId}
- and tid = #{tid}
- </where>
- </select>
- <select id="selectFmsBlockInfoByBlockId" parameterType="String" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsBlockResVo">
- SELECT b.blockId, b.landId, b.blockName, b.blockType, b.blockManager, b.blockArea,
- b.blockSeq, b.blockAreaplant, b.blockLngrange, b.blockColor, b.blockRemark, b.blockIcon,
- b.blockIstransfer, b.blockTransferinfo, b.blockOwnerinfo,
- b.tid, l.landName,
- u.userName as blockManagername, (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = b.blockId) blockPreview
- from FmsBlock b
- LEFT JOIN FmsLand l ON b.landId = l.landId
- LEFT JOIN SysUser u ON b.blockManager = u.userId
- <where>
- blockId = #{blockId}
- and b.tid = #{tid}
- </where>
- </select>
- <select id="selectCountByLandId" parameterType="String" resultType="Integer">
- select count(1) from FmsBlock
- <where>
- tid = #{tid}
- <if test="landId != null and landId != ''"> and landId = #{landId}</if>
- </where>
- </select>
- <select id="selectSumAreaByLandId" parameterType="FmsLand" resultType="java.math.BigDecimal">
- select sum(blockArea) from FmsBlock
- <where>
- tid = #{tid}
- <if test="landId != null and landId != ''"> and landId = #{landId}</if>
- <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">
- and blockId in
- <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
- #{blockId}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectSumArea" parameterType="FmsBlockReqVo" resultType="java.math.BigDecimal">
- select sum(b.blockArea) from FmsBlock b LEFT JOIN FmsLand l ON b.landId = l.landId WHERE l.landId is not null
- and b.tid = #{tid}
- <if test="landId != null and landId != ''"> and l.landId = #{landId}</if>
- <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">
- and b.blockId in
- <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
- #{blockId}
- </foreach>
- </if>
- </select>
- <select id="selectFmsBlockHasPlan" parameterType="FmsBlockReqVo" resultType="com.yunfeiyun.agmp.fms.domain.resvo.FmsBlockResVo">
- select b.* , l.landName,
- tb1.blockPreview,
- tb1.resIds,
- (SELECT GROUP_CONCAT(c.cropName) FROM FmsPlan p LEFT JOIN FmsCrop c ON p.cropId = c.cropId WHERE p.blockId = b.blockId and (p.planStatus = 0 or p.planStatus = 1) limit 1) cropNames
- from FmsBlock b
- left join FmsLand l on b.landId = l.landId
- left join (select GROUP_CONCAT(resUrl) blockPreview, GROUP_CONCAT(resId) resIds, resBusId from SysRes
- WHERE resBiztype = 'BLOCK' group by resBusId ) tb1 on b.blockId = tb1.resBusId
- having 1=1
- and b.tid = #{tid}
- <if test="hasPlan != null and hasPlan == '0'.toString() "> and cropNames is null</if>
- <if test="hasPlan != null and hasPlan == '1'.toString() "> and cropNames is not null</if>
- <if test="landId != null and landId != ''"> and landId = #{landId}</if>
- <if test="blockId != null and blockId != ''"> and blockId = #{blockId}</if>
- <if test="cropName != null and cropName != ''"> and cropNames like concat('%', #{cropName}, '%')</if>
- <if test="blockName != null and blockName != ''"> and b.blockName like concat('%', #{blockName}, '%')</if>
- <if test="dataFilter == true and blockIds !=null and blockIds.size()>0">
- and b.blockId in
- <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
- #{blockId}
- </foreach>
- </if>
- order by b.blockSeq
- </select>
- <select id="selectFmsLandByBlockIds" parameterType="String" resultType="com.yunfeiyun.agmp.fms.domain.FmsLand">
- select l.* from FmsBlock b LEFT JOIN FmsLand l ON b.landId = l.landId
- <where>
- b.blockId in
- <foreach item="blockId" collection="array" open="(" separator="," close=")">
- #{blockId}
- </foreach>
- and b.tid = #{tid}
- </where>
- group by b.landId
- </select>
- <select id="selectValidDataNumber" parameterType="String" resultType="java.lang.Integer">
- select sum(num) from
- <trim prefix="(" suffix=")">
- <include refid="selectFmsPlanValidData"/>
- UNION ALL
- <include refid="selectIcsIrrgrcdValidData"/>
- </trim>
- AS validDataNum
- </select>
- <select id="selectFmsBlockListByLandManager" resultType="com.yunfeiyun.agmp.fms.domain.FmsBlock">
- select * from FmsBlock
- where landId in (
- select landId from FmsLand where landManager = #{userId} and tid = #{tid}
- )
- </select>
- <sql id="selectFmsPlanValidData">
- SELECT
- count( 1 ) AS num
- FROM
- FmsPlan
- <where>
- blockId = #{blockId} and tid = #{tid}
- </where>
- </sql>
- <sql id="selectIcsIrrgrcdValidData">
- SELECT
- count( 1 ) AS num
- FROM
- IcsIrrgrcd
- <where>
- blockId = #{blockId} and tid = #{tid}
- </where>
- </sql>
- <insert id="bindUser" parameterType="FmsBlockBindUserReqVo">
- insert into FmsBlockUser
- <trim prefix="(" suffix=")" suffixOverrides=",">
- userId,
- blockId,
- tid
- </trim>
- values
- <foreach item="blockId" collection="blockIds" separator=",">
- (
- #{userId},
- #{blockId},
- #{tid}
- )
- </foreach>
- </insert>
- <select id="userBindList" resultType="java.lang.String">
- select blockId from FmsBlockUser where userId =#{userId} and tid = #{tid}
- </select>
- <delete id="unbindUser">
- delete from FmsBlockUser where userId = #{userId} and tid = #{tid}
- </delete>
- <update id="updateFmsBlock" parameterType="FmsBlock">
- update FmsBlock
- <trim prefix="SET" suffixOverrides=",">
- <if test="landId != null">landId = #{landId},</if>
- <if test="blockName != null">blockName = #{blockName},</if>
- <if test="blockType != null">blockType = #{blockType},</if>
- <if test="blockManager != null">blockManager = #{blockManager},</if>
- <if test="blockManagername != null">blockManagername = #{blockManagername},</if>
- <if test="blockArea != null">blockArea = #{blockArea},</if>
- <if test="blockAreaplant != null">blockAreaplant = #{blockAreaplant},</if>
- <if test="blockLngrange != null">blockLngrange = #{blockLngrange},</if>
- <if test="blockColor != null">blockColor = #{blockColor},</if>
- <if test="blockRemark != null">blockRemark = #{blockRemark},</if>
- <if test="blockSeq != null">blockSeq =#{blockSeq},</if>
- <if test="blockIcon != null">blockIcon = #{blockIcon},</if>
- <if test="tid != null">tid = #{tid},</if>
- </trim>
- <where>
- blockId = #{blockId}
- and tid = #{tid}
- </where>
- </update>
- <select id="selectFmsBlockBindUserList" resultType="com.yunfeiyun.agmp.common.core.domain.entity.SysUser">
- select * from SysUser where userId in ( select userId from FmsBlockUser where blockId = #{blockId} )
- </select>
- </mapper>
|