BizEntityMapper.xml 13.7 KB
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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
<?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.runsa.portal.base.dao.BizEntityMapper">
	<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.BizEntity">
		<id column="beId" property="id" jdbcType="INTEGER" />
		<result column="beOrgType" property="orgType" jdbcType="INTEGER" />
		<result column="beCode" property="code" jdbcType="VARCHAR" />
		<result column="beName" property="name" jdbcType="VARCHAR" />
		<result column="beDesc" property="desc" jdbcType="VARCHAR" />
		<result column="ptValid" property="valid" jdbcType="SMALLINT" />
		<result column="beChief" property="chief" jdbcType="VARCHAR" />
		<result column="ptEmail" property="email" jdbcType="VARCHAR" />
		<result column="ptPost" property="post" jdbcType="VARCHAR" />
		<result column="ptTaxrate" property="taxrate" jdbcType="DECIMAL" />
		<result column="ptCurrency" property="currency" jdbcType="INTEGER" />
		<result column="ptTphone" property="tphone" jdbcType="VARCHAR" />
		<result column="beBeginDate" property="beginDate" jdbcType="TIMESTAMP" />
		<result column="beEndDate" property="endDate" jdbcType="TIMESTAMP" />
		<result column="diId" property="diId" jdbcType="INTEGER" />
		<result column="ptAddr" property="addr" jdbcType="VARCHAR" />
		<result column="ptPhone" property="phone" jdbcType="VARCHAR" />
		<result column="ptAnniversary" property="anniversary" jdbcType="DATE" />
		<result column="ptRemark" property="remark" jdbcType="VARCHAR" />
		<result column="ptRemark1" property="remark1" jdbcType="VARCHAR" />
		<result column="ptRemark2" property="remark2" jdbcType="VARCHAR" />
		<result column="ptRemark3" property="remark3" jdbcType="VARCHAR" />
		<result column="ptUpTime" property="uptime" jdbcType="TIMESTAMP" />
		<result column="ptUpdater" property="updater" jdbcType="INTEGER" />
		<association property="varItem" javaType="cn.runsa.portal.base.entity.VarItem">
			<id column="vaiId" property="id" />
			<result column="vaiName" property="name" jdbcType="VARCHAR" />
		</association>
	</resultMap>

	<resultMap id="CurrencyUnitResultMap" type="cn.runsa.portal.base.entity.CurrencyUnit">
		<id column="cuId" property="cuid" jdbcType="INTEGER" />
		<result column="cuCode" property="cucode" jdbcType="VARCHAR" />
		<result column="cuName" property="cuname" jdbcType="VARCHAR" />
		<result column="cuRate" property="curate" jdbcType="DECIMAL" />
		<result column="cuSort" property="sort" jdbcType="INTEGER" />
	</resultMap>

	<resultMap id="PayWayResultMap" type="cn.runsa.portal.base.entity.PayWay">
		<id column="pwId" property="id" jdbcType="INTEGER" />
		<result column="pwName" property="name" jdbcType="VARCHAR" />
		<result column="cuId" property="cuid" jdbcType="INTEGER" />
	</resultMap>

	<sql id="Base_Column_List">
		beId, beOrgType,beCode, beName, beDesc, ptValid, beChief, ptEmail, ptPost, ptTaxrate, ptCurrency,
		ptTphone, beBeginDate, beEndDate, diId, ptAddr, ptPhone, ptAnniversary, ptRemark,
		ptRemark1, ptRemark2, ptRemark3, ptUpTime, ptUpdater
	</sql>
	<select id="findById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		select
		t1.*,
		t2.vaiName
		FROM mtBizEntity t1
		LEFT JOIN mtVarItem t2 ON t2.vaiId = t1.beOrgType
		WHERE t1.beId=#{id,jdbcType=INTEGER}
	</select>
	<select id="findAll" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.BizEntity">
		select
		<include refid="Base_Column_List" />
		from mtBizEntity
		where 1=1
	</select>
	<delete id="delete" parameterType="java.lang.Integer">
		delete from mtBizEntity
		where beId = #{id,jdbcType=INTEGER}
	</delete>
	<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="cn.runsa.portal.base.entity.BizEntity">
		insert into mtBizEntity (beOrgType,beCode, beName, beDesc,
		ptValid, beChief, ptEmail,
		ptPost, ptTaxrate, ptCurrency,
		ptTphone, beBeginDate, beEndDate,
		diId, ptAddr, ptPhone,
		ptAnniversary, ptRemark, ptRemark1,
		ptRemark2, ptRemark3, ptUpTime,
		ptUpdater)
		values (#{orgtype,jdbcType=INTEGER}, #{code,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR},
		#{valid,jdbcType=SMALLINT}, #{chief,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
		#{post,jdbcType=VARCHAR}, #{taxrate,jdbcType=DECIMAL}, #{currency,jdbcType=INTEGER},
		#{tphone,jdbcType=VARCHAR}, #{begindate,jdbcType=TIMESTAMP}, #{enddate,jdbcType=TIMESTAMP},
		#{diid,jdbcType=INTEGER}, #{addr,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
		#{anniversary,jdbcType=DATE}, #{remark,jdbcType=VARCHAR}, #{remark1,jdbcType=VARCHAR},
		#{remark2,jdbcType=VARCHAR}, #{remark3,jdbcType=VARCHAR}, now(),
		#{updater,jdbcType=INTEGER})
	</insert>
	<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="cn.runsa.portal.base.entity.BizEntity">
		insert into mtBizEntity
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="orgType != null">
				beOrgType,
			</if>
			<if test="code != null">
				beCode,
			</if>
			<if test="name != null">
				beName,
			</if>
			<if test="desc != null">
				beDesc,
			</if>
			<if test="valid != null">
				ptValid,
			</if>
			<if test="chief != null">
				beChief,
			</if>
			<if test="email != null">
				ptEmail,
			</if>
			<if test="post != null">
				ptPost,
			</if>
			<if test="taxrate != null">
				ptTaxrate,
			</if>
			<if test="currency != null">
				ptCurrency,
			</if>
			<if test="tphone != null">
				ptTphone,
			</if>
			<if test="beginDate != null">
				beBeginDate,
			</if>
			<if test="endDate != null">
				beEndDate,
			</if>
			<if test="diId != null">
				diId,
			</if>
			<if test="addr != null">
				ptAddr,
			</if>
			<if test="phone != null">
				ptPhone,
			</if>
			<if test="anniversary != null">
				ptAnniversary,
			</if>
			<if test="remark != null">
				ptRemark,
			</if>
			<if test="remark1 != null">
				ptRemark1,
			</if>
			<if test="remark2 != null">
				ptRemark2,
			</if>
			<if test="remark3 != null">
				ptRemark3,
			</if>
			<if test="uptime != null">
				ptUpTime,
			</if>
			<if test="updater != null">
				ptUpdater,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="orgType != null">
				#{orgType,jdbcType=INTEGER},
			</if>
			<if test="code != null">
				#{code,jdbcType=VARCHAR},
			</if>
			<if test="name != null">
				#{name,jdbcType=VARCHAR},
			</if>
			<if test="desc != null">
				#{desc,jdbcType=VARCHAR},
			</if>
			<if test="valid != null">
				#{valid,jdbcType=SMALLINT},
			</if>
			<if test="chief != null">
				#{chief,jdbcType=VARCHAR},
			</if>
			<if test="email != null">
				#{email,jdbcType=VARCHAR},
			</if>
			<if test="post != null">
				#{post,jdbcType=VARCHAR},
			</if>
			<if test="taxrate != null">
				#{taxrate,jdbcType=DECIMAL},
			</if>
			<if test="currency != null">
				#{currency,jdbcType=INTEGER},
			</if>
			<if test="tphone != null">
				#{tphone,jdbcType=VARCHAR},
			</if>
			<if test="beginDate != null">
				#{beginDate,jdbcType=TIMESTAMP},
			</if>
			<if test="endDate != null">
				#{endDate,jdbcType=TIMESTAMP},
			</if>
			<if test="diId != null">
				#{diId,jdbcType=INTEGER},
			</if>
			<if test="addr != null">
				#{addr,jdbcType=VARCHAR},
			</if>
			<if test="phone != null">
				#{phone,jdbcType=VARCHAR},
			</if>
			<if test="anniversary != null">
				#{anniversary,jdbcType=DATE},
			</if>
			<if test="remark != null">
				#{remark,jdbcType=VARCHAR},
			</if>
			<if test="remark1 != null">
				#{remark1,jdbcType=VARCHAR},
			</if>
			<if test="remark2 != null">
				#{remark2,jdbcType=VARCHAR},
			</if>
			<if test="remark3 != null">
				#{remark3,jdbcType=VARCHAR},
			</if>
			<if test="uptime != null">
				#{uptime,jdbcType=TIMESTAMP},
			</if>
			<if test="updater != null">
				#{updater,jdbcType=INTEGER},
			</if>
		</trim>
	</insert>
	<update id="updateSelective" parameterType="cn.runsa.portal.base.entity.BizEntity">
		update mtBizEntity
		<set>
			<if test="orgType != null">
				beOrgType = #{orgType,jdbcType=INTEGER},
			</if>
			<if test="code != null">
				beCode =#{code,jdbcType=VARCHAR},
			</if>
			<if test="name != null">
				beName = #{name,jdbcType=VARCHAR},
			</if>
			<if test="desc != null">
				beDesc = #{desc,jdbcType=VARCHAR},
			</if>
			<if test="valid != null">
				ptValid = #{valid,jdbcType=SMALLINT},
			</if>
			<if test="chief != null">
				beChief = #{chief,jdbcType=VARCHAR},
			</if>
			<if test="email != null">
				ptEmail = #{email,jdbcType=VARCHAR},
			</if>
			<if test="post != null">
				ptPost = #{post,jdbcType=VARCHAR},
			</if>
			<if test="taxrate != null">
				ptTaxrate = #{taxrate,jdbcType=DECIMAL},
			</if>
			<if test="currency != null">
				ptCurrency = #{currency,jdbcType=INTEGER},
			</if>
			<if test="tphone != null">
				ptTphone = #{tphone,jdbcType=VARCHAR},
			</if>
			<if test="beginDate != null">
				beBeginDate = #{beginDate,jdbcType=TIMESTAMP},
			</if>
			<if test="endDate != null">
				beEndDate = #{endDate,jdbcType=TIMESTAMP},
			</if>
			<if test="diId != null">
				diId = #{diId,jdbcType=INTEGER},
			</if>
			<if test="addr != null">
				ptAddr = #{addr,jdbcType=VARCHAR},
			</if>
			<if test="phone != null">
				ptPhone = #{phone,jdbcType=VARCHAR},
			</if>
			<if test="anniversary != null">
				ptAnniversary = #{anniversary,jdbcType=DATE},
			</if>
			<if test="remark != null">
				ptRemark = #{remark,jdbcType=VARCHAR},
			</if>
			<if test="remark1 != null">
				ptRemark1 = #{remark1,jdbcType=VARCHAR},
			</if>
			<if test="remark2 != null">
				ptRemark2 = #{remark2,jdbcType=VARCHAR},
			</if>
			<if test="remark3 != null">
				ptRemark3 = #{remark3,jdbcType=VARCHAR},
			</if>
			<if test="uptime != null">
				ptUpTime = #{uptime,jdbcType=TIMESTAMP},
			</if>
			<if test="updater != null">
				ptUpdater = #{updater,jdbcType=INTEGER},
			</if>
		</set>
		where beId = #{id,jdbcType=INTEGER}
	</update>
	<update id="update" parameterType="cn.runsa.portal.base.entity.BizEntity">
		update mtBizEntity
		set beOrgType = #{orgType,jdbcType=INTEGER},
		beCode = #{code,jdbcType=VARCHAR},
		beName = #{name,jdbcType=VARCHAR},
		beDesc = #{desc,jdbcType=VARCHAR},
		ptValid = #{valid,jdbcType=SMALLINT},
		beChief = #{chief,jdbcType=VARCHAR},
		ptEmail = #{email,jdbcType=VARCHAR},
		ptPost = #{post,jdbcType=VARCHAR},
		ptTaxrate = #{taxrate,jdbcType=DECIMAL},
		ptCurrency = #{currency,jdbcType=INTEGER},
		ptTphone = #{tphone,jdbcType=VARCHAR},
		beBeginDate = #{beginDate,jdbcType=TIMESTAMP},
		beEndDate = #{endDate,jdbcType=TIMESTAMP},
		diId = #{diId,jdbcType=INTEGER},
		ptAddr = #{addr,jdbcType=VARCHAR},
		ptPhone = #{phone,jdbcType=VARCHAR},
		ptAnniversary = #{anniversary,jdbcType=DATE},
		ptRemark = #{remark,jdbcType=VARCHAR},
		ptRemark1 = #{remark1,jdbcType=VARCHAR},
		ptRemark2 =
		#{remark2,jdbcType=VARCHAR},
		ptRemark3 = #{remark3,jdbcType=VARCHAR},
		ptUpTime = #{uptime,jdbcType=TIMESTAMP},
		ptUpdater = #{updater,jdbcType=INTEGER}
		where beId = #{id,jdbcType=INTEGER}
	</update>
	<!-- 根据编号或名称模糊查询 -->
	<select id="fuzzyByCodeOrName" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.BizEntity">
		SELECT beId,beCode,beName FROM mtBizEntity
		where 1=1
		<if test="code != null">
			and code like CONCAT('%',${code},'%')
		</if>
		<if test="code != null">
			and name like CONCAT('%',${name},'%')
		</if>
	</select>

	<select id="findBizCode" resultMap="BaseResultMap">
		select
		MAX(cast(beCode as signed)) as beCode
		from mtBizEntity
		<!-- ORDER BY beCode DESC LIMIT 1 -->
	</select>

	<select id="findCurrencyUnit" resultMap="CurrencyUnitResultMap">
		select
		cuId,cuName
		from mtCurrencyUnit
	</select>

	<select id="findPayWay" resultMap="PayWayResultMap">
		select
		pwId,pwName,cuId
		from mtPayway where ptValid=1
	</select>

	<select id="findCurrencyUnitByPwid" resultMap="CurrencyUnitResultMap" parameterType="java.lang.Integer">
		select
		cuId,cuName,cuRate
		from mtCurrencyUnit where cuId=#{cuid}
	</select>

	<!-- 插入所属经营主体上下级关系 -->
	<insert id="insertbizEntityInfo" parameterType="cn.runsa.portal.base.entity.BizEntityInfo">
		insert into mtBizEntityInfo (beId, chId, beParent)
		values
		(#{beid}, #{chid}, #{beparent})
	</insert>

	<delete id="deleteBizEntityInfo" parameterType="java.lang.Integer">
		delete from mtBizEntityInfo
		where beId = #{id,jdbcType=INTEGER}
	</delete>

	<select id="fuzzyUnusedDisByCodeOrName" resultMap="BaseResultMap">
		SELECT beId,beCode,beName FROM mtBizEntity
		where beOrgType = (SELECT b.vaiId FROM mtvariable a LEFT JOIN mtvaritem b ON
		a.vaId = b.vaId WHERE a.vaCode = 'OrgType' AND b.vaiCode ='Dis')
		<if test="code != null">
			and code like CONCAT('%',${code},'%')
		</if>
		<if test="name != null">
			and name like CONCAT('%',${name},'%')
		</if>
		AND beId NOT IN (SELECT DISTINCT beId FROM smPlatform WHERE pltId = 3)
		AND	CASE (SELECT pltId FROM smPlatform WHERE plId = #{plId,jdbcType=INTEGER})
			WHEN 1 THEN
				1=1
			ELSE
				beId IN (
					SELECT DISTINCT s2.beId FROM mtBizEntityInfo s1 LEFT JOIN smPlatform s2 ON s2.beId = s1.beParent
					WHERE s2.plId = #{plId,jdbcType=INTEGER}
				)
			END
	</select>
	
	<select id="existsUnusedDisByCodeAndName" resultMap="BaseResultMap">
		select *
		from mtBizEntity
		where beOrgType = (SELECT b.vaiId FROM mtvariable a LEFT JOIN mtvaritem b ON
		a.vaId = b.vaId WHERE a.vaCode = 'OrgType' AND b.vaiCode ='Dis')
		AND beCode=#{code} AND beName=#{name}
		AND beId NOT IN (SELECT DISTINCT beId FROM smplatform WHERE pltId = 3)
	</select>

	<select id="existsCode" resultType="Boolean">
		select count(*)
		from mtBizEntity
		where beCode=#{code}
	</select>
	
	<select id="existsName" resultType="Boolean">
		select count(*)
		from mtBizEntity
		where beName=#{name}
	</select>
	
	<insert id="insertbizEntityInfoLoop" parameterType="map">
	    insert into mtBizEntityInfo (beId, chId, beParent)
		SELECT #{beId},chId,beParent FROM mtBizEntityInfo
		WHERE beId = #{parent}
	</insert>
</mapper>