<?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="io.renren.modules.app.dao.LpqcDao">
	<select id="selectDhbm" resultType="string">
		select dhbm from zhxx where
		dhmc= #{dhmc} and xmbm = #{xmbm}
	</select>

	<!-- 获取最新的房屋编码 -->
	<select id="querydhbm" resultType="string">
		SELECT fwbm FROM fwxx ORDER BY
		fwbm DESC LIMIT 1
	</select>

	<select id="selectDhbm2" resultType="string">
		SELECT dhbm FROM zhxx WHERE
		LENGTH(dhbm)>=8 ORDER BY dhbm DESC LIMIT 1
	</select>

	<select id="selectFwxzID" resultType="string">
		select id from sys_dict
		where `value` = #{value} and `type` = #{type}
	</select>

	<select id="selectDybm" resultType="string">
		SELECT fwdybm from dyxx where
		dhbm = #{dhbm} and dymc = #{dymc}
	</select>

	<insert id="insertDyxx" parameterType="io.renren.modules.app.entity.DyxxEntity">
		INSERT INTO dyxx ( fwdybm,
		dhbm, dymc, hs, lcs ) VALUES ( #{fwdybm},
		#{dhbm}, #{dymc}, #{hs},
		#{lcs} );
	</insert>

	<update id="updateLcs">
		update dyxx set lcs = 1 where dymc = '0/' or dymc =
		'0y'
	</update>

	<select id="selectDhmc" resultType="integer">
		select count(*) from zhxx
		where xmbm = #{xmbm} and dhmc = #{dhmc}
	</select>

	<!-- 新增 -->
	<insert id="insertFwxx" parameterType="io.renren.modules.app.entity.FwxxEntity">
		INSERT INTO
		`renren_fast`.`fwxx` (
		`cczh`,
		`fwbm`,
		`dhbm`,
		`mphm`,
		`lc`,
		`hx`,
		`fwxz`,
		`ssdj`,
		`mj`,
		`fwje`,
		`gfrq`,
		`lfmj`,
		`lfdj`,
		`lfje`,
		`zjk`,
		`hxt`,
		`xm`,
		`sfzh`,
		`lxdh`,
		`jjze`,



		`sfsc`,
		`mh`,
		`grjjl`,
		`jsbz`,
		`gzdbm`,






		`htbh`,
		`fpbh`,
		`zjlb`,
		`dz`,
		`bz`,
		`jcbzbm`,
		`fwyt`,
		`spzt`,
		`yzkm`,
		`sfyj`,
		`sfjq`
		)
		VALUES
		(
		#{cczh},
		#{fwbm},
		#{dhbm},
		#{mphm},
		#{lc},
		#{hx},
		#{fwxz},
		#{ssdj},
		#{mj},
		#{fwje},
		#{gfrq},
		#{lfmj},
		#{lfdj},
		#{lfje},
		#{zjk},
		#{hxt},
		#{xm},
		#{sfzh},
		#{lxdh},
		#{jjze},



		#{sfsc},
		#{mh},
		#{grjjl},
		#{jsbz},
		#{gzdbm},






		#{htbh},
		#{fpbh},
		#{zjlb},
		#{dz},
		#{bz},
		#{jcbzbm},
		#{fwyt},
		#{spzt},
		#{yzkm},
		#{sfyj},
		'0'
		)
	</insert>

	<insert id="insertFwxxList">
		INSERT INTO fwxx(`cczh`, `fwbm`, `dhbm`, `mphm`, `lc`, `hx`, `fwxz`, `ssdj`, `mj`, `fwje`, `gfrq`, `lfmj`, `lfdj`, `lfje`, `zjk`, `hxt`, `xm`, `sfzh`, `lxdh`, `jjze`, `sfsc`, `mh`, `grjjl`, `jsbz`, `gzdbm`, `htbh`, `fpbh`, `zjlb`, `dz`, `bz`, `jcbzbm`, `fwyt`, `spzt`, `yzkm`, `sfyj`, `sfjq` )
		VALUES
		<foreach collection="list" item="item" separator=",">
			(#{item.cczh}, #{item.fwbm}, #{item.dhbm}, #{item.mphm}, #{item.lc}, #{item.hx}, #{item.fwxz}, #{item.ssdj}, #{item.mj}, #{item.fwje}, #{item.gfrq}, #{item.lfmj}, #{item.lfdj}, #{item.lfje}, #{item.zjk}, #{item.hxt}, #{item.xm}, #{item.sfzh}, #{item.lxdh}, #{item.jjze}, #{item.sfsc}, #{item.mh}, #{item.grjjl}, #{item.jsbz}, #{item.gzdbm}, #{item.htbh}, #{item.fpbh}, #{item.zjlb}, #{item.dz}, #{item.bz}, #{item.jcbzbm}, #{item.fwyt}, #{item.spzt}, #{item.yzkm}, #{item.sfyj}, '0')
		</foreach>
	</insert>

	<select id="selectdhbmbyxmdh" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="Integer">
		select lcs from dyxx where dhbm=(select dhbm from zhxx
		where dhmc=#{dhmc}
		and xmbm=#{xmbm})
	</select>
	<update id="updatezhxxlcs" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		lcs=#{lcs} where dhbm=#{dhbm}
	</update>

	<select id="selectdhbmbymc" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select dhbm from zhxx where dhmc=#{dhmc} and xmbm=#{xmbm}
	</select>
	
	<select id="selectdhbmfwbm" parameterType="io.renren.modules.app.entity.ZhxxEntity"
		resultType="java.lang.String">
		select fwbm from fwxx where dhbm=(select dhbm from zhxx where xmbm=#{xmbm} and dhmc=#{dhmc}) and mphm=#{mphm}
	</select>
	
	<select id="selectfwxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select mj,grjjl,sfyj from fwxx where fwbm=#{id}
	</select>
</mapper>