| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- <?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 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,
- (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,
- (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="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="FmsBlock">
- <include refid="selectFmsBlockHasResVo"/>
- <where>
- blockId = #{blockId}
- and tid = #{tid}
- </where>
- </select>
- <select id="selectFmsBlockInfoByBlockId" parameterType="String" resultType="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.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="selectCountByPlanStatus" parameterType="SelectCountByPlanStatusReqVo" resultType="Integer">
- SELECT count(1) FROM
- (SELECT b.blockId,(SELECT count(1) FROM FmsPlan p
- <where>
- p.blockId = b.blockId
- and p.tid = #{tid}
- <if test="planStatus != null and planStatus != ''">
- and p.planStatus in
- <foreach collection="planStatus.split(',')" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- ) count FROM FmsBlock b
- <where>
- b.tid = #{tid}
- <if test="landId != null and landId != ''">and b.landId = #{landId}</if>
- </where>
- ) tb
- WHERE tb.count > 0
- </select>
- <select id="selectSumAreaByLandId" parameterType="FmsLand" resultType="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="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="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>
- <insert id="insertFmsBlock" parameterType="FmsBlock">
- insert into FmsBlock
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="blockId != null">blockId,</if>
- <if test="landId != null">landId,</if>
- <if test="blockName != null">blockName,</if>
- <if test="blockType != null">blockType,</if>
- <if test="blockManager != null">blockManager,</if>
- <if test="blockManagername != null">blockManagername,</if>
- <if test="blockArea != null">blockArea,</if>
- <if test="blockAreaplant != null">blockAreaplant,</if>
- <if test="blockLngrange != null">blockLngrange,</if>
- <if test="blockColor != null">blockColor,</if>
- <if test="blockRemark != null">blockRemark,</if>
- <if test="blockIcon != null">blockIcon,</if>
- <if test="blockSeq != null">blockSeq,</if>
- <if test="tid != null">tid,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="blockId != null">#{blockId},</if>
- <if test="landId != null">#{landId},</if>
- <if test="blockName != null">#{blockName},</if>
- <if test="blockType != null">#{blockType},</if>
- <if test="blockManager != null">#{blockManager},</if>
- <if test="blockManagername != null">#{blockManagername},</if>
- <if test="blockArea != null">#{blockArea},</if>
- <if test="blockAreaplant != null">#{blockAreaplant},</if>
- <if test="blockLngrange != null">#{blockLngrange},</if>
- <if test="blockColor != null">#{blockColor},</if>
- <if test="blockRemark != null">#{blockRemark},</if>
- <if test="blockIcon != null">#{blockIcon},</if>
- <if test="blockSeq != null">#{blockSeq},</if>
- <if test="tid != null">#{tid},</if>
- </trim>
- </insert>
- <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>
- <update id="updateFmsBlockBatch" parameterType="FmsBlock">
- <foreach collection="list" item="block" separator=";">
- update FmsBlock
- <trim prefix="SET" suffixOverrides=",">
- <if test="block.landId != null">landId = #{block.landId},</if>
- <if test="block.blockName != null">blockName = #{block.blockName},</if>
- <if test="block.blockType != null">blockType = #{block.blockType},</if>
- <if test="block.blockManager != null">blockManager = #{block.blockManager},</if>
- <if test="block.blockManagername != null">blockManagername = #{block.blockManagername},</if>
- <if test="block.blockArea != null">blockArea = #{block.blockArea},</if>
- <if test="block.blockAreaplant != null">blockAreaplant = #{block.blockAreaplant},</if>
- <if test="block.blockLngrange != null">blockLngrange = #{block.blockLngrange},</if>
- <if test="block.blockColor != null">blockColor = #{block.blockColor},</if>
- <if test="block.blockRemark != null">blockRemark = #{block.blockRemark},</if>
- <if test="block.blockSeq != null">blockSeq =#{block.blockSeq},</if>
- <if test="block.blockIcon != null">blockIcon = #{block.blockIcon},</if>
- <if test="block.tid != null">tid = #{block.tid},</if>
- </trim>
- <where>
- blockId = #{block.blockId}
- and tid = #{block.tid}
- </where>
- </foreach>
- </update>
- <update id="updateManagerByBlockIds">
- update FmsBlock set blockManager = #{manager},blockManagername = #{managerName}
- <where>
- blockId in
- <foreach collection="blockIds" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- and tid = #{tid}
- </where>
- </update>
- <update id="clearManagerByManagerId">
- update FmsBlock set blockManager = null
- <where>
- blockManager = #{manager}
- and tid = #{tid}
- </where>
- </update>
- <delete id="deleteFmsBlockByBlockId" parameterType="String">
- delete from FmsBlock
- <where>
- blockId = #{blockId}
- and tid = #{tid}
- </where>
- </delete>
- <delete id="deleteFmsBlockByBlockIds" parameterType="String">
- delete from FmsBlock
- <where>
- blockId in
- <foreach item="blockId" collection="array" open="(" separator="," close=")">
- #{blockId}
- </foreach>
- and tid = #{tid}
- </where>
- </delete>
- <select id="selectFmsLandByBlockIds" parameterType="String" resultType="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 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="selectBlockManagerAndLandManager"
- resultType="SysUser">
- select u.userId, u.deptId, u.userLoginname, u.userName, u.userEmail, u.userMobile, u.userLoginpwd, u.userSex, u.userLockstatus, u.userDelstatus, u.userLastloginip, u.userLastlogindate, u.userCreator, u.userCreateddate, u.userRemark,u.userRegion,
- GROUP_CONCAT(r.roleId) as roleId,
- GROUP_CONCAT(r.roleName) as roleName,
- GROUP_CONCAT(r.roleKey) as roleKey,
- res.resUrl as userAvatar
- from SysUser u
- left join SysUserrole ur on u.userId = ur.userId
- left join SysRole r on r.roleId = ur.roleId
- left join SysRes res on res.resBusId = u.userId
- <where>
- r.roleKey in ('land_admin','block_admin') and u.tid = #{tid}
- <if test="roleName != null and roleName != ''">and r.roleName like CONCAT('%',#{roleName},'%')</if>
- <if test="userName != null and userName != ''">and u.userName like CONCAT('%',#{userName},'%')</if>
- <if test="userLoginname != null and userLoginname !=''">and u.userLoginname = #{userLoginname}</if>
- <if test="userMobile != null and userMobile !=''">and u.userMobile = #{userMobile}</if>
- </where>
- GROUP BY u.userId
- </select>
- <select id="selectFmsBlockBaseDataList" resultType="com.yunfeiyun.agmp.fms.domain.FmsBlock">
- <include refid="selectFmsBlockVo"/>
- <where>
- and 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 blockId in
- <foreach collection="blockIds" item="blockId" index="index" open="(" close=")" separator=",">
- #{blockId}
- </foreach>
- </if>
- <if test="landIds != null and landIds.size()!=0">
- and landId in
- <foreach collection="landIds" item="item" index="index" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectFmsBlockListByManager" resultType="com.yunfeiyun.agmp.fms.domain.FmsBlock">
- select * from FmsBlock
- where landId in (
- select landId from FmsLand where landManager = #{userId} and tid = #{tid}
- ) or blockManager = #{userId}
- </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>
- </mapper>
|