ZcglAssoZcdaMapper.xml 6.9 KB
Newer Older
yuquan.zhu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
<?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.timer.api.dao.zcgl.ZcglAssoZcdaMapper">

	<resultMap id="BaseResultMap"
		type="cn.timer.api.bean.zcgl.ZcglAssoZcda">
		<id column="id" property="id" />
		<result column="zcbh" property="zcbh" />
		<result column="mc" property="mc" />
		<result column="ggxh" property="ggxh" />
		<result column="jldw" property="jldw" />
		<result column="cs" property="cs" />
		<result column="tulj" property="tulj" />
		<result column="bzxx" property="bzxx" />
		<result column="lrsj_time" property="lrsjTime" />
		<result column="lrrid" property="lrrid" />
	</resultMap>

	<sql id="Base_Column_List">
		id,
		zcbh,
		mc,
		ggxh,
		lb,
		jldw,
		zt_type,
		cs,
		tulj,
		bzxx,
		lrsj_time,
		lrrid
	</sql>

	<sql id="Base_Column_List_Alias">
		id ZcglAssoZcda_id,
		zcbh ZcglAssoZcda_zcbh,
		mc ZcglAssoZcda_mc,
		ggxh ZcglAssoZcda_ggxh,
		lb ZcglAssoZcda_lb,
		jldw ZcglAssoZcda_jldw,
		zt_type ZcglAssoZcda_zt_type,
		cs ZcglAssoZcda_cs,
		tulj ZcglAssoZcda_tulj,
		bzxx ZcglAssoZcda_bzxx,
		lrsj_time ZcglAssoZcda_lrsj_time,
		lrrid ZcglAssoZcda_lrrid
	</sql>
	
	<select id="queryCategory" parameterType="java.lang.Integer" resultType="cn.timer.api.dto.zcgl.ZcglCartogramDto">
		SELECT
			COUNT(b.lbmc) sl
			,b.lbmc mc
		FROM
			zcgl_asso_zcda a
		LEFT JOIN
			zcgl_asso_zcgx b
		ON
			a.lbid = b.id
		WHERE
			b.org_code = #{orgCode}
		AND
		 	FIND_IN_SET(b.id, queryDetails(#{id}
		))
	</select>

	<!-- 根据类别选择查询资产 -->
	<select id="queryDetails" parameterType="java.lang.Integer"  resultType="cn.timer.api.dto.zcgl.ZcglDetailsDto">
		SELECT
			a.id id,
			a.zdyid zdyid,
			a.mc mc,
			a.zcbh zcbh,
			a.ggxh ggxh,
			a.jldw jldw,
			a.cs cs,
			a.tulj tulj,
			a.bzxx bzxx,
			a.lbid lbid,
			b.lbmc lbmc,
			a.xzsl xzsl,
			a.lysl lysl,
			a.bfsl bfsl,
			a.zcdj zcdj
		FROM
			zcgl_asso_zcda a
		LEFT JOIN 
			zcgl_asso_zcgx b 
		ON 
			a.lbid = b.id
		WHERE
			a.org_code = #{orgCode}
		AND FIND_IN_SET(b.id, queryDetails(#{id}
		))
	</select>
	
	<!-- 固定资产/消耗资产(手机端) -->
	<select id="queryGdzc" parameterType="java.lang.Integer"  resultType="cn.timer.api.dto.zcgl.ZcglDetailsDto">
		SELECT
		    a.zdyid zdyid,
			a.mc mc,
			a.zcbh zcbh,
			a.ggxh ggxh,
			a.jldw jldw,
			a.lbid lbid,
			a.xzsl xzsl,
			a.lysl lysl,
			a.bfsl bfsl,
			a.zcdj zcdj
		FROM
			zcgl_asso_zcda a
		LEFT JOIN 
			zcgl_asso_zcgx b 
		ON 
			a.lbid = b.id
		WHERE
			a.org_code = #{orgCode}
		AND FIND_IN_SET(b.id, queryDetails(1
		))
		limit #{currPage},#{pageSize}
	</select>
	<select id="queryXhzc" parameterType="java.lang.Integer"  resultType="cn.timer.api.dto.zcgl.ZcglDetailsDto">
		SELECT
			a.zdyid zdyid,
			a.mc mc,
			a.zcbh zcbh,
			a.ggxh ggxh,
			a.jldw jldw,
			a.lbid lbid,
			a.xzsl xzsl,
			a.lysl lysl,
			a.bfsl bfsl,
			a.zcdj zcdj
		FROM
			zcgl_asso_zcda a
		LEFT JOIN 
			zcgl_asso_zcgx b 
		ON 
			a.lbid = b.id
		WHERE
			a.org_code = #{orgCode}
		AND FIND_IN_SET(b.id, queryDetails(2
		))
		limit #{currPage},#{pageSize}
	</select>
	
	<!-- 根据类别选择删除资产 -->
	<delete id="deleteDetails" parameterType="java.lang.Integer">
		DELETE FROM 
			zcgl_asso_zcda 
		WHERE
			org_code = #{orgCode}
		AND FIND_IN_SET(lbid, queryDetails(#{id}
			))
	</delete>

	<!-- 个人资产 -->
	<select id="personalassets"
		resultType="cn.timer.api.dto.zcgl.ZcglPersonalAssetsDto">
		SELECT
			a.id zcid,
			a.mc zcmc,
			b.lyrq_time lyrq,
			b.ghrq_time ghrq,
			IFNULL(a.zcbh, 'null') bh,
			IFNULL(d.lbmc, 'null') lb,
			IFNULL(a.ggxh, 'null') xh,
			IFNULL(b.lysl, 0) sl,
			IFNULL(a.jldw, 'null') dw,
			IFNULL(a.zcdj, 0.0) je,
			b.lyhcfd cfd
		FROM
			zcgl_asso_zcda a
		LEFT JOIN zcgl_asso_zcly b ON a.id = b.zcid
		LEFT JOIN zcgl_asso_zcgx d ON a.lbid = d.id
		WHERE
			b.lysl>0
		AND	a.org_code = #{orgCode}
		AND b.lyrid = #{empNum}
		
		<if test="query != null">
		and (
			a.mc like CONCAT('%',#{query},'%')
            or 
            a.ggxh like CONCAT('%',#{query},'%')
		) 
        </if>
        <if test="startTime != null and startTime != ''">
        	and b.lyrq_time > #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
        	and b.lyrq_time <![CDATA[ < ]]> #{endTime}
        </if>
        <!-- limit #{currPage},#{pageSize} -->
	</select>
	
	
	<select id="queryZczj" resultType="cn.timer.api.dto.zcgl.ZcglDetailsDto">
		
		SELECT
			zcdj,xzsl,lysl,bfsl,mc
		FROM
			zcgl_asso_zcda a
		LEFT JOIN
			zcgl_asso_zcgx b
		ON
			a.lbid = b.id
		WHERE
			a.org_code = #{orgCode}
		AND
			FIND_IN_SET(a.lbid, queryDetails(#{id}
		))
		
	</select>


	<!-- <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.zcgl.ZcglAssoZcda"> 
		INSERT INTO zcgl_asso_zcda <trim prefix="(" suffix=")" suffixOverrides=","> 
		<if test ='null != zcbh'> zcbh, </if> <if test ='null != mc'> mc, </if> <if 
		test ='null != ggxh'> ggxh, </if> <if test ='null != lb'> lb, </if> <if test 
		='null != jldw'> jldw, </if> <if test ='null != ztType'> zt_type, </if> <if 
		test ='null != cs'> cs, </if> <if test ='null != tulj'> tulj, </if> <if test 
		='null != bzxx'> bzxx, </if> <if test ='null != lrsjTime'> lrsj_time, </if> 
		<if test ='null != lrrid'> lrrid </if> </trim> <trim prefix="values (" suffix=")" 
		suffixOverrides=","> <if test ='null != zcbh'> #{zcbh}, </if> <if test ='null 
		!= mc'> #{mc}, </if> <if test ='null != ggxh'> #{ggxh}, </if> <if test ='null 
		!= lb'> #{lb}, </if> <if test ='null != jldw'> #{jldw}, </if> <if test ='null 
		!= ztType'> #{ztType}, </if> <if test ='null != cs'> #{cs}, </if> <if test 
		='null != tulj'> #{tulj}, </if> <if test ='null != bzxx'> #{bzxx}, </if> 
		<if test ='null != lrsjTime'> #{lrsjTime}, </if> <if test ='null != lrrid'> 
		#{lrrid} </if> </trim> </insert> <delete id="delete" > DELETE FROM zcgl_asso_zcda 
		WHERE id = #{id} </delete> <update id="update" parameterType="cn.timer.api.bean.zcgl.ZcglAssoZcda"> 
		UPDATE zcgl_asso_zcda <set> <if test ='null != zcbh'>zcbh = #{zcbh},</if> 
		<if test ='null != mc'>mc = #{mc},</if> <if test ='null != ggxh'>ggxh = #{ggxh},</if> 
		<if test ='null != lb'>lb = #{lb},</if> <if test ='null != jldw'>jldw = #{jldw},</if> 
		<if test ='null != ztType'>zt_type = #{ztType},</if> <if test ='null != cs'>cs 
		= #{cs},</if> <if test ='null != tulj'>tulj = #{tulj},</if> <if test ='null 
		!= bzxx'>bzxx = #{bzxx},</if> <if test ='null != lrsjTime'>lrsj_time = #{lrsjTime},</if> 
		<if test ='null != lrrid'>lrrid = #{lrrid}</if> </set> WHERE id = #{id} </update> 
		<select id="load" resultMap="BaseResultMap"> SELECT <include refid="Base_Column_List" 
		/> FROM zcgl_asso_zcda WHERE id = #{id} </select> <select id="pageList" resultMap="BaseResultMap"> 
		SELECT <include refid="Base_Column_List" /> FROM zcgl_asso_zcda LIMIT #{offset}, 
		#{pageSize} </select> <select id="pageListCount" resultType="java.lang.Integer"> 
		SELECT count(1) FROM zcgl_asso_zcda </select> -->

</mapper>