| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- <?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.FmsLandMapper">
- <sql id="selectFmsLandVo">
- select landId, landName, landArea, landBlockcount, landDevcount, landManager, landTel, landLocation, landRemark,
- landLatitude, landLongitude, landSeqfrom FmsLand
- </sql>
- <!-- <sql id="selectFmsLandHasResVo">-->
- <!-- select l.*,-->
- <!-- (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = l.landId) landPreview,-->
- <!-- (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = l.landId) resIds-->
- <!-- from FmsLand l-->
- <!-- </sql>-->
- <sql id="selectFmsLandHasResVo">
- SELECT l.landId, l.landName, l.landArea, l.landBlockcount, l.landManager, l.landTel, l.landLocation,
- l.landRemark, l.landLatitude, l.landLongitude,l.landSeq,
- (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = l.landId) landPreview,
- (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = l.landId) resIds,
- (SELECT COUNT(tmnlandId) FROM TmnLand tl WHERE tl.landId = l.landId) landDevcount,
- (SELECT u.userName FROM SysUser u WHERE u.userId = l.landManager) landManagerName
- from FmsLand l
- </sql>
- <select id="selectFmsLandList" parameterType="FmsLand" resultType="FmsLand">
- SELECT l.landId, l.landName, l.landArea, bc.landBlockcount, l.landManager, l.landTel, l.landLocation,
- l.landRemark, l.landLatitude, l.landLongitude,l.landSeq,l.tid,
- (select GROUP_CONCAT(resUrl) from SysRes r where r.resBusId = l.landId) landPreview,
- (select GROUP_CONCAT(resId) from SysRes r where r.resBusId = l.landId) resIds,
- (SELECT COUNT(tmnlandId) FROM TmnLand tl WHERE tl.landId = l.landId) landDevcount,
- (SELECT u.userName FROM SysUser u WHERE u.userId = l.landManager) landManagerName
- from FmsLand l
- LEFT JOIN (
- select count(landId) as landBlockcount,landId from FmsBlock where tid = #{tid} GROUP BY landId
- ) bc on bc.landId = l.landId
- <where>
- <if test="landId != null ">and l.landId = #{landId}</if>
- <if test="landName != null and landName != ''">and landName like concat('%', #{landName}, '%')</if>
- <if test="landNameEq != null and landNameEq != ''">and landName = #{landNameEq}</if>
- <if test="landArea != null ">and landArea = #{landArea}</if>
- <if test="landBlockcount != null ">and landBlockcount = #{landBlockcount}</if>
- <if test="landDevcount != null ">and landDevcount = #{landDevcount}</if>
- <if test="landManager != null and landManager != ''">and landManager = #{landManager}</if>
- <if test="landTel != null and landTel != ''">and landTel = #{landTel}</if>
- <if test="landLocation != null and landLocation != ''">and landLocation = #{landLocation}</if>
- <if test="landRemark != null and landRemark != ''">and landRemark = #{landRemark}</if>
- <if test="dataFilter == true and landIds !=null and landIds.size()>0">
- and l.landId in
- <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
- #{landId}
- </foreach>
- </if>
- and l.tid = #{tid}
- </where>
- order by l.landSeq
- </select>
- <select id="selectFmsLandByLandId" parameterType="String" resultType="FmsLand">
- <include refid="selectFmsLandHasResVo"/>
- where landId = #{landId} and tid = #{tid}
- </select>
- <select id="selectFmsLandTotal" parameterType="FmsLand" resultType="FmsLandTotalResVo">
- SELECT count(1) count, sum(landArea) landAreaSum, sum(landBlockcountSum) landBlockcountSum,
- (
- SELECT COUNT(tmnlandId) FROM TmnLand tl
- LEFT JOIN IotDevice idv on idv.devBid = tl.tmnId
- <where>
- idv.devDelstatus = '0' and tl.tid = #{tid}
- <if test="landId != null and landId != ''">and tl.landId = #{landId}</if>
- <if test="dataFilter == true and landIds !=null and landIds.size()>0">
- and tl.landId in
- <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
- #{landId}
- </foreach>
- </if>
- </where>
- ) landDevcountSum
- from FmsLand fl
- LEFT JOIN (select count(blockId) as landBlockcountSum,landId from FmsBlock GROUP BY landId ) fb on
- fb.landId = fl.landId
- <where>
- fl.tid = #{tid}
- <if test="landId != null and landId != ''">and fl.landId = #{landId}</if>
- <if test="dataFilter == true and landIds !=null and landIds.size()>0">
- and fl.landId in
- <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
- #{landId}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectDevCount" parameterType="FmsLand" resultType="int">
- SELECT COUNT(1) FROM (SELECT COUNT(tmnId) count FROM TmnLand
- <where>
- tid = #{tid}
- <if test="landId != null and landId != ''">and landId = #{landId}</if>
- <if test="dataFilter == true and landIds !=null and landIds.size()>0">
- and landId in
- <foreach collection="landIds" item="landId" index="index" open="(" close=")" separator=",">
- #{landId}
- </foreach>
- </if>
- </where>
- GROUP BY tmnId
- ) tb
- </select>
- <insert id="insertFmsLand" parameterType="FmsLand">
- insert into FmsLand
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="landId != null">landId,</if>
- <if test="landName != null">landName,</if>
- <if test="landArea != null">landArea,</if>
- <if test="landBlockcount != null">landBlockcount,</if>
- <if test="landDevcount != null">landDevcount,</if>
- <if test="landManager != null">landManager,</if>
- <if test="landTel != null">landTel,</if>
- <if test="landLocation != null">landLocation,</if>
- <if test="landRemark != null">landRemark,</if>
- <if test="landLatitude != null">landLatitude,</if>
- <if test="landLongitude != null">landLongitude,</if>
- <if test="landSeq !=null">landSeq,</if>
- <if test="tid != null">tid,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="landId != null">#{landId},</if>
- <if test="landName != null">#{landName},</if>
- <if test="landArea != null">#{landArea},</if>
- <if test="landBlockcount != null">#{landBlockcount},</if>
- <if test="landDevcount != null">#{landDevcount},</if>
- <if test="landManager != null">#{landManager},</if>
- <if test="landTel != null">#{landTel},</if>
- <if test="landLocation != null">#{landLocation},</if>
- <if test="landRemark != null">#{landRemark},</if>
- <if test="landLatitude != null">#{landLatitude},</if>
- <if test="landLongitude != null">#{landLongitude},</if>
- <if test="landSeq != null">#{landSeq},</if>
- <if test="tid != null">#{tid},</if>
- </trim>
- </insert>
- <update id="updateFmsLand" parameterType="FmsLand">
- update FmsLand
- <trim prefix="SET" suffixOverrides=",">
- <if test="landName != null">landName = #{landName},</if>
- <if test="landArea != null">landArea = #{landArea},</if>
- <if test="landBlockcount != null">landBlockcount = #{landBlockcount},</if>
- <if test="landDevcount != null">landDevcount = #{landDevcount},</if>
- <if test="landManager != null">landManager = #{landManager},</if>
- <if test="landTel != null">landTel = #{landTel},</if>
- <if test="landLocation != null">landLocation = #{landLocation},</if>
- <if test="landRemark != null">landRemark = #{landRemark},</if>
- <if test="landLatitude != null">landLatitude = #{landLatitude},</if>
- <if test="landLongitude != null">landLongitude = #{landLongitude},</if>
- <if test="landSeq != null">landSeq =#{landSeq},</if>
- </trim>
- where landId = #{landId} and tid = #{tid}
- </update>
- <update id="updateFmsLandBatch">
- <foreach collection="list" item="fmsLand" separator=";">
- update FmsLand
- <trim prefix="SET" suffixOverrides=",">
- <if test="fmsLand.landName != null">landName = #{fmsLand.landName},</if>
- <if test="fmsLand.landArea != null">landArea = #{fmsLand.landArea},</if>
- <if test="fmsLand.landBlockcount != null">landBlockcount = #{fmsLand.landBlockcount},</if>
- <if test="fmsLand.landDevcount != null">landDevcount = #{fmsLand.landDevcount},</if>
- <if test="fmsLand.landManager != null">landManager = #{fmsLand.landManager},</if>
- <if test="fmsLand.landTel != null">landTel = #{fmsLand.landTel},</if>
- <if test="fmsLand.landLocation != null">landLocation = #{fmsLand.landLocation},</if>
- <if test="fmsLand.landRemark != null">landRemark = #{fmsLand.landRemark},</if>
- <if test="fmsLand.landLatitude != null">landLatitude = #{fmsLand.landLatitude},</if>
- <if test="fmsLand.landLongitude != null">landLongitude = #{fmsLand.landLongitude},</if>
- <if test="fmsLand.landSeq != null">landSeq =#{fmsLand.landSeq},</if>
- <if test="tid != null and tid !='' and tid != '-1'">
- and tid = #{fmsLand.tid}
- </if>
- </trim>
- where landId = #{fmsLand.landId} and tid = #{fmsLand.tid}
- </foreach>
- </update>
- <delete id="deleteFmsLandByLandId" parameterType="String">
- delete from FmsLand where landId = #{landId} and tid = #{tid}
- </delete>
- <delete id="deleteFmsLandByLandIds" parameterType="String">
- delete from FmsLand where landId in
- <foreach item="landId" collection="array" open="(" separator="," close=")">
- #{landId}
- </foreach>
- and tid = #{tid}
- </delete>
- <select id="selectFmsLandByTarcecodeapplyno" parameterType="String" resultType="FmsLand">
- SELECT
- l.*
- FROM
- FmsLand l
- LEFT JOIn FmsTask t on t.landId = l.landId
- LEFT JOIN FmsTaskpick tp on tp.taskId = t.taskId
- where tp.pickNo = #{tarcecodeapplyno}
- and l.tid = #{tid}
- </select>
- <select id="selectFmsLandDeviceList" parameterType="TmnLandDeviceListReqVo"
- resultType="com.yunfeiyun.agmp.fms.domain.resvo.TmnLandDeviceInfoResVo">
- SELECT
- tb.tmnId, tb.tmnName, tb.tmnBizcode, tb.tmnType, tb.tmnLongitude, tb.tmnLatitude, tb.tmnCreateddate,
- tb.tmnStatus, tb.tmnUpdateddate, tb.tmnAddress
- FROM TmnLand AS tl
- LEFT JOIN TmnBase AS tb ON tl.tmnId = tb.tmnId
- <where>
- tl.landId = #{landId} and tl.tid = #{tid}
- <if test="tmnTypes !=null">
- and tb.tmnType in
- <foreach item="ty" collection="tmnTypes" open="(" separator="," close=")">
- #{ty}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectUserManagerWarehouseLandIds" resultType="java.lang.String">
- (
- SELECT
- landId
- FROM
- FmsLand
- WHERE
- landManager = #{userId}
- and tid = #{tid}
- )
- UNION ALL
- (
- SELECT
- landId
- FROM
- FmsLandHouse
- WHERE
- warehouseId IN ( SELECT warehouseId FROM WmsWarehouse WHERE warehouseManager = #{userId} and tid = #{tid})
- and tid = #{tid}
- )
- </select>
- <select id="selectFmsLandListByDeviceBind" resultType="FmsLandListByDeviceBindResVo">
- SELECT f.landId, f.landName, COUNT(t.tmnId) as devNum
- FROM FmsLand AS f
- LEFT JOIN (
- SELECT t.*
- FROM TmnLand AS t
- LEFT JOIN IotDevice AS d ON d.devBid = t.tmnId
- WHERE d.devDelstatus = '0' AND (NOT ((t.landId IS NULL) OR (t.landId = '') OR (d.devBid IS NULL)))
- and t.tid = #{tid}
- GROUP BY t.tmnId, t.landId
- ) AS t ON f.landId = t.landId
- GROUP BY f.landId
- </select>
- </mapper>
|