1.树状图搜索房产
1.1实现思路
- 因为树状图搜索要显示在界面中,所以需要在html文件中进行添加树状结构
- 而树状结构怎么来的,所以需要在controller中新写一个方法来传输一个树状结构,让html直接访问它即可
- 树状结构在framework->web->Ztree.Java中已经写好了,所以我们不用重新自己编写树状结构,直接调用即可,但是树结点的设置还没写,所以我们需要在service中新写一个方法来完成树的建立
- 树的各结点为街道和片区,所以我们还需要得到这些街道及片区的主键ID和具体名称,因此还需要在片区的mapper中新写一个方法来取到这些片区和街道
1.2修改片区的mapper文件
mapper.Java 新写一个函数selectPqJdTree,表示查询Tree需要的PqJd的数据
mapper.xml 具体实现selectPqJdTree方法
1.3修改房产的service文件
service 新写一个selectPqJdTree方法,表示利用PqJd来建立需要的Tree
servicImp 具体实现需要的Tree结构
/**
* 查询片区街道树结构
*
* @return 片区集合
*/
@Override
public List<Ztree> selectPqJdTree(){
///利用刚刚新写的片区的selectPqJdTree查询出正常使用的所有pq和jd,并全部存在片区pqs中
List <TBxwPqZhk> pqs = tBxwPqZhkMapper.selectPqJdTree();
/创建树tree,每个结点为Ztree数据
List <Ztree> tree = new ArrayList <Ztree> ();
for(TBxwPqZhk pq : pqs) {
//设置树结点中的片区结点Id,Name,Title,父节点Pid
Ztree zt = new Ztree();
//注意这里设置片区的结点id为负数,因为片区id和街道id有可能重复,会导致树的结点id一致,从而导致街道结点的父节点可能为街道,所以导致树状结构错误。而我们在点击树状图中的结点时,只需要街道id,所以片区结点id可以为负数
zt.setId(0-(long)Integer.parseInt(pq.getId()));
zt.setName(pq.getPqmc());
zt.setTitle(pq.getPqmc());
将片区的父节点id设置为0,后续在判断树中点击的是街道还是片区时,只需要判断该结点的父节点是否为0即可
zt.setpId(0L);
将该片区结点加入到tree中去
tree.add(zt);
取出存储在pq中的街道信息
List <TBxwPqJdZhk> jds = pq.gettBxwPqJdZhks();
if(jds == null)continue;
for(TBxwPqJdZhk jd : jds) {
//将街道信息存入Ztree中,并加入到tree,设置父节点id为所属片区结点id
Ztree ztjd = new Ztree();
ztjd.setId((long)Integer.parseInt(jd.getId()));
ztjd.setName(jd.getJdmc());
ztjd.setTitle(jd.getJdmc());
ztjd.setpId(0-(long)Integer.parseInt(pq.getId()));
tree.add(ztjd);
}
}
return tree;
}
如果设置片区的结点id也为片区id时,有可能会出现下图错误:左图为正常显示,右图为错误显示
出现原因就是:南大街的街道id与西区的片区id一致,所以在产生西大街结点时,误认为它的父节点是南大街,导致出现树状结果错误
1.4修改房产的controller文件
新写一个接口,负责传输该树状结构:
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
List<Ztree> ztrees = tBxwFcZhkService.selectPqJdTree();
return ztrees;
}
1.5修改fc.html
具体代码:
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('房产列表')" />
<th:block th:include="include :: layout-latest-css" />
<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
<div class="ui-layout-west">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 街道信息
</div>
<div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool" href="#"
onclick="tjcjd()" title="街道管理"><i class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand"
title="展开" style="display: none;">
<i class="fa fa-chevron-up"></i>
</button>
<button type="button" class="btn btn-box-tool" id="btnCollapse"
title="折叠">
<i class="fa fa-chevron-down"></i>
</button>
<button type="button" class="btn btn-box-tool" id="btnRefresh"
title="刷新街道">
<i class="fa fa-refresh"></i>
</button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
<div class="ui-layout-center">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<input id="tBxwPqJdZhkId" type="hidden" name="tBxwPqJdZhkId" />
<div class="select-list">
<ul>
<li><label>房产编号:</label> <input type="text" name="fcbh" />
</li>
<li ><label>产权人:</label> <input type="text" name="cqr" /></li>
<li ><label>产权人身份证号码:</label> <input type="text"
name="cqrsfz" /></li>
<li><label>居住人:</label> <input type="text" name="jzr" /></li>
<li><label>房屋产权证号:</label> <input type="text" name="fwcqz" />
</li>
<li><label>土地使用证号:</label> <input type="text" name="tdsyzh" />
</li>
<li><label>注销标志:</label> <select name="zxbz"
th:with="type=${@dict.getType('t_jc_zxzt')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
</select></li>
<li><a class="btn btn-primary btn-rounded btn-sm"
onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
<a class="btn btn-warning btn-rounded btn-sm"
onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()"
shiro:hasPermission="jcxx:fc:add"> <i class="fa fa-plus"></i>
添加
</a> <a class="btn btn-primary single disabled"
onclick="$.operate.edit()" shiro:hasPermission="jcxx:fc:edit">
<i class="fa fa-edit"></i> 修改
</a> <a class="btn btn-danger multiple disabled"
onclick="$.operate.removeAll()"
shiro:hasPermission="jcxx:fc:remove"> <i class="fa fa-remove"></i>
删除
</a> <a class="btn btn-warning" onclick="$.table.exportExcel()"
shiro:hasPermission="jcxx:fc:export"> <i
class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('jcxx:fc:edit')}]];
var removeFlag = [[${@permission.hasPermi('jcxx:fc:remove')}]];
var qllxDatas = [[${@dict.getType('t_jc_qllx')}]];
var qlxzDatas = [[${@dict.getType('t_jc_qlxz')}]];
var sfwzfDatas = [[${@dict.getType('t_jc_sfwzf')}]];
var fccsDatas = [[${@dict.getType('t_jc_fccs')}]];
var fwcbDatas = [[${@dict.getType('t_jc_fwcb')}]];
var zxbzDatas = [[${@dict.getType('t_jc_zxztlx')}]];
var prefix = ctx + "jcxx/fc";
$(function() {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({ initClosed: panehHidden, west__size: 185 });
// 回到顶部绑定
if ($.fn.toTop !== undefined) {
var opt = {
win:$('.ui-layout-center'),
doc:$('.ui-layout-center')
};
$('#scroll-up').toTop(opt);
}
queryFcList();
queryJdTree();
});
function queryFcList(){
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "房产",
sortable:true,
columns: [{
checkbox: true
},
{
field: 'id',
title: '主键',
visible: false
},
{
field: 'fcmc',
title: '房产名称'
},
{
field: 'tBxwPqJdZhk.pqmc',
title: '所属片区',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"50px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"100px",
}
}
}
},
{
field: 'tBxwPqJdZhk.jdmc',
title: '所属街道',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"100px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"150px",
}
}
}
},
{
field: 'fwcb',
title: '房屋产别',
formatter: function(value, row, index) {
return $.table.selectDictLabel(fwcbDatas, value);
}
},
{
field: 'fwzl',
title: '房屋座落',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"150px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"300px",
}
}
}
},
{
field: 'cqr',
title: '产权人',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"50px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"100px",
}
}
}
},
{
field: 'cqrsfz',
title: '产权人身份证号码',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"150px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"300px",
}
}
}
},
{
field: 'cqrlxdh',
title: '产权人联系电话',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"150px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"250px",
}
}
}
},
{
field: 'jzr',
title: '居住人',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"50px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"100px",
}
}
}
},
{
field: 'jzrlxdh',
title: '居住人联系电话',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"150px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"250px",
}
}
}
},
{
field: 'fwcqz',
title: '房屋产权证号',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"200px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"300px",
}
}
}
},
{
field: 'tdsyzh',
title: '土地使用证号',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"150px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"300px",
}
}
}
},
{
field: 'tdsymj',
title: '土地使用面积'
},
{
field: 'qllx',
title: '权利类型',
formatter: function(value, row, index) {
return $.table.selectDictLabel(qllxDatas, value);
}
},
{
field: 'qlxz',
title: '权利性质',
formatter: function(value, row, index) {
return $.table.selectDictLabel(qlxzDatas, value);
}
},
{
field: 'sfwzf',
title: '是否无证房',
formatter: function(value, row, index) {
return $.table.selectDictLabel(sfwzfDatas, value);
}
},
{
field: 'fccs',
title: '房产出售',
formatter: function(value, row, index) {
return $.table.selectDictLabel(fccsDatas, value);
}
},
{
field: 'zxbz',
title: '注销标志',
formatter: function(value, row, index) {
return $.table.selectDictLabel(zxbzDatas, value);
}
},
{
field: 'bz',
title: '备注',
formatter:function (value, row, index,field) {
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title="+value+">"+value+"</span>"
},
cellStyle:function (value, row, index,field) {
return {
css:{
"min-width":"50px",
"white-space":"nowrap",
"test-overflow":"ellipsis",
"overflow":"hidden",
"max-width":"100px",
}
}
}
},
{
field: 'jzmj',
title: '建筑面积'
},
{
field: 'fwjs',
title: '房屋间数'
},
{
field: 'fwtms',
title: '房屋条目数'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
}
function queryJdTree()
{
var url = prefix + "/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
if(treeNode.id == -2)$("#tBxwPqJdZhkId").val('');
else $("#tBxwPqJdZhkId").val(treeNode.id);
if (treeNode.pId == null)
{$.modal.alert('请选择要查询的街道!');}
else {
$.table.search();
}
}
}
$('#btnExpand').click(function() {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function() {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function() {
queryJdTree();
});
/* 辖区信息 */
function tjcjd() {
var url = ctx + "jcxx/jd";
$.modal.openTab("辖区管理", url);
}
</script>
</body>
</html>
1.6具体实现
2.房屋连接房产
修改房产的domain属性
因为需要在房产之中显示房屋属性,所以应该在房产的domain属性中加入房屋的集合、
domain代码:
package com.xyt.project.shggc.jcxx.fc.domain;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xyt.framework.aspectj.lang.annotation.Excel;
import com.xyt.framework.web.domain.BaseEntity;
import com.xyt.project.shggc.jcxx.fw.domain.TBxwFcFwZhk;
import com.xyt.project.shggc.jcxx.jd.domain.TBxwPqJdZhk;
/**
* 房产对象 t_bxw_fc_zhk
*
* @author ruoyi
* @date 2024-08-08
*/
public class TBxwFcZhk extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private String id;
/** 街道id */
@Excel(name = "街道id")
private String tBxwPqJdZhkId;
/***********导出属性*************/
@Excel(name = "所属片区")
private String pqmc;
@Excel(name = "所属街道")
private String jdmc;
/** 房产编号 */
@Excel(name = "房产编号")
private String fcbh;
/** 房产名称 */
@Excel(name = "房产名称")
private String fcmc;
/** 房屋坐落 */
@Excel(name = "房屋坐落")
private String fwzl;
/** 产权人 */
@Excel(name = "产权人")
private String cqr;
/** 产权人身份证 */
@Excel(name = "产权人身份证")
private String cqrsfz;
/** 产权人联系电话 */
@Excel(name = "产权人联系电话")
private String cqrlxdh;
/** 居住人 */
@Excel(name = "居住人")
private String jzr;
/** 居住人联系电话 */
@Excel(name = "居住人联系电话")
private String jzrlxdh;
/** 房屋产权证号 */
@Excel(name = "房屋产权证号")
private String fwcqzh;
/** 土地使用证号 */
@Excel(name = "土地使用证号")
private String tdsyzh;
/** 土地使用面积 */
@Excel(name = "土地使用面积")
private Long tdsymj;
/** 权利类型 */
@Excel(name = "权利类型")
private String qllx;
/** 权利性质 */
@Excel(name = "权利性质")
private String qlxz;
/** 是否无证房 */
@Excel(name = "是否无证房")
private String sfwzf;
/** 房屋出售 */
@Excel(name = "房屋出售")
private String fccs;
/** 房屋产别 */
@Excel(name = "房屋产别")
private String fwcb;
/** 建筑面积 */
@Excel(name = "建筑面积")
private double jzmj;
/** 房屋间数 */
@Excel(name = "房屋间数 ")
private double fwjs;
/** 房屋条目数 */
@Excel(name = "房屋条目数")
private int fwtms;
/** 注销标志 */
@Excel(name = "注销标志")
private String zxbz;
/** 备注 */
@Excel(name = "备注")
private String bz;
/***********数据库扩展属性*************/
/** 扩展1 */
@Excel(name = "扩展1")
private String kz1;
/** 扩展2 */
@Excel(name = "扩展2")
private String kz2;
/***********一对一及一对多属性*************/
/** 街道信息 */
private TBxwPqJdZhk tBxwPqJdZhk;
/** 房屋信息 */
List <TBxwFcFwZhk> tBxwFcFwZhks;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public String getPqmc() {
return pqmc;
}
public void setPqmc(String pqmc) {
this.pqmc = pqmc;
}
public String getJdmc() {
return jdmc;
}
public void setJdmc(String jdmc) {
this.jdmc = jdmc;
}
public void settBxwPqJdZhkId(String tBxwPqJdZhkId)
{
this.tBxwPqJdZhkId = tBxwPqJdZhkId;
}
public String gettBxwPqJdZhkId()
{
return tBxwPqJdZhkId;
}
public void setFcbh(String fcbh)
{
this.fcbh = fcbh;
}
public String getFcbh()
{
return fcbh;
}
public void setFcmc(String fcmc)
{
this.fcmc = fcmc;
}
public String getFcmc()
{
return fcmc;
}
public void setFwzl(String fwzl)
{
this.fwzl = fwzl;
}
public String getFwzl()
{
return fwzl;
}
public void setCqr(String cqr)
{
this.cqr = cqr;
}
public String getCqr()
{
return cqr;
}
public void setCqrsfz(String cqrsfz)
{
this.cqrsfz = cqrsfz;
}
public String getCqrsfz()
{
return cqrsfz;
}
public void setCqrlxdh(String cqrlxdh)
{
this.cqrlxdh = cqrlxdh;
}
public String getCqrlxdh()
{
return cqrlxdh;
}
public void setJzr(String jzr)
{
this.jzr = jzr;
}
public String getJzr()
{
return jzr;
}
public void setJzrlxdh(String jzrlxdh)
{
this.jzrlxdh = jzrlxdh;
}
public String getJzrlxdh()
{
return jzrlxdh;
}
public void setFwcqzh(String fwcqzh)
{
this.fwcqzh = fwcqzh;
}
public String getFwcqzh()
{
return fwcqzh;
}
public void setTdsyzh(String tdsyzh)
{
this.tdsyzh = tdsyzh;
}
public String getTdsyzh()
{
return tdsyzh;
}
public void setTdsymj(Long tdsymj)
{
this.tdsymj = tdsymj;
}
public Long getTdsymj()
{
return tdsymj;
}
public void setQllx(String qllx)
{
this.qllx = qllx;
}
public String getQllx()
{
return qllx;
}
public void setQlxz(String qlxz)
{
this.qlxz = qlxz;
}
public String getQlxz()
{
return qlxz;
}
public void setSfwzf(String sfwzf)
{
this.sfwzf = sfwzf;
}
public String getSfwzf()
{
return sfwzf;
}
public void setFccs(String fccs)
{
this.fccs = fccs;
}
public String getFccs()
{
return fccs;
}
public void setFwcb(String fwcb)
{
this.fwcb = fwcb;
}
public String getFwcb()
{
return fwcb;
}
public double getJzmj() {
return jzmj;
}
public void setJzmj(double jzmj) {
this.jzmj = jzmj;
}
public double getFwjs() {
return fwjs;
}
public void setFwjs(double fwjs) {
this.fwjs = fwjs;
}
public int getFwtms() {
return fwtms;
}
public void setFwtms(int fwtms) {
this.fwtms = fwtms;
}
public List<TBxwFcFwZhk> gettBxwFcFwZhks() {
return tBxwFcFwZhks;
}
public void settBxwFcFwZhks(List<TBxwFcFwZhk> tBxwFcFwZhks) {
this.tBxwFcFwZhks = tBxwFcFwZhks;
}
public void setZxbz(String zxbz)
{
this.zxbz = zxbz;
}
public String getZxbz()
{
return zxbz;
}
public void setBz(String bz)
{
this.bz = bz;
}
public String getBz()
{
return bz;
}
public void setKz1(String kz1)
{
this.kz1 = kz1;
}
public String getKz1()
{
return kz1;
}
public void setKz2(String kz2)
{
this.kz2 = kz2;
}
public String getKz2()
{
return kz2;
}
public TBxwPqJdZhk gettBxwPqJdZhk() {
return tBxwPqJdZhk;
}
public void settBxwPqJdZhk(TBxwPqJdZhk tBxwPqJdZhk) {
this.tBxwPqJdZhk = tBxwPqJdZhk;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("tBxwPqJdZhkId", gettBxwPqJdZhkId())
.append("fcbh", getFcbh())
.append("fcmc", getFcmc())
.append("fwzl", getFwzl())
.append("cqr", getCqr())
.append("cqrsfz", getCqrsfz())
.append("cqrlxdh", getCqrlxdh())
.append("jzr", getJzr())
.append("jzrlxdh", getJzrlxdh())
.append("fwcqzh", getFwcqzh())
.append("tdsyzh", getTdsyzh())
.append("tdsymj", getTdsymj())
.append("qllx", getQllx())
.append("qlxz", getQlxz())
.append("sfwzf", getSfwzf())
.append("fccs", getFccs())
.append("fwcb", getFwcb())
.append("zxbz", getZxbz())
.append("bz", getBz())
.append("kz1", getKz1())
.append("kz2", getKz2())
.toString();
}
}
修改房产的xml文件
因为需要在房产中显示房屋信息,所以在SQL查询时就需要将房屋信息给查询出来,并且房产信息与片区街道有关,所以在搜索阶段一共需要连接四张表,片区表,街道表,房产表,房屋表,而在插入删除修改等阶段只需要三张表,片区表,街道表,房产表,所以为了代码方便,我们写了两个SQL查询语句,利用连表查询来查询需要的信息。
需要查询的信息:
总的查询SQL语句:
具体连表操作:
xml文件具体代码:
<?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.xyt.project.shggc.jcxx.fc.mapper.TBxwFcZhkMapper">
<resultMap type="com.xyt.project.shggc.jcxx.fc.domain.TBxwFcZhk" id="TBxwFcZhkResult">
<result property="id" column="id" />
<result property="tBxwPqJdZhkId" column="t_bxw_pq_jd_zhk_id" />
<result property="fcbh" column="fcbh" />
<result property="fcmc" column="fcmc" />
<result property="fwzl" column="fwzl" />
<result property="cqr" column="cqr" />
<result property="cqrsfz" column="cqrsfz" />
<result property="cqrlxdh" column="cqrlxdh" />
<result property="jzr" column="jzr" />
<result property="jzrlxdh" column="jzrlxdh" />
<result property="fwcqzh" column="fwcqzh" />
<result property="tdsyzh" column="tdsyzh" />
<result property="tdsymj" column="tdsymj" />
<result property="qllx" column="qllx" />
<result property="qlxz" column="qlxz" />
<result property="sfwzf" column="sfwzf" />
<result property="fccs" column="fccs" />
<result property="fwcb" column="fwcb" />
<result property="zxbz" column="zxbz" />
<result property="bz" column="bz" />
<result property="kz1" column="kz1" />
<result property="kz2" column="kz2" />
<association property="tBxwPqJdZhk" javaType="com.xyt.project.shggc.jcxx.jd.domain.TBxwPqJdZhk">
<id property="id" column="t_bxw_pq_jd_zhk_id"/>
<result property="pqmc" column="pqmc"/>
<result property="jdmc" column="jdmc"/>
</association>
<collection property="tBxwFcFwZhks" ofType="com.xyt.project.shggc.jcxx.fw.domain.TBxwFcFwZhk">
<id property="id" column="fwid"/>
<result property="tBxwFcZhkId" column="t_bxw_fc_zhk_id"/>
<result property="fwjs" column="fwjs"/>
<result property="jzmj" column="jzmj"/>
<result property="zxbz" column="fwzxbz"/>
<result property="bz" column="fwbz"/>
</collection>
</resultMap>
<sql id="selectTBxwFcZhkVo">
select fc.id as id, t_bxw_pq_jd_zhk_id,pq.pqmc as pqmc, jd.jdmc as jdmc, fcbh, fcmc, fwzl, cqr, cqrsfz, cqrlxdh, jzr, jzrlxdh, fwcqzh, tdsyzh, tdsymj, qllx, qlxz, sfwzf, fccs, fwcb,
fc.zxbz as zxbz, fc.bz as bz, fc.kz1 as kz1, fc.kz2 as kz2
from t_bxw_fc_zhk fc ,t_bxw_pq_jd_zhk jd , t_bxw_pq_zhk pq
</sql>
<sql id="selectTBxwFcFwZhkVo">
select id as fwid, t_bxw_fc_zhk_id, fwjs, jzmj, zxbz as fwzxbz, bz as fwbz from t_bxw_fc_fw_zhk
</sql>
<select id="selectTBxwFcZhkList" parameterType="com.xyt.project.shggc.jcxx.fc.domain.TBxwFcZhk" resultMap="TBxwFcZhkResult">
select a.*, b.* from (
<include refid="selectTBxwFcZhkVo"/>
<where>
t_bxw_pq_zhk_id = pq.id and t_bxw_pq_jd_zhk_id = jd.id and pq.zxbz = '0' and jd.zxbz = '0'
<if test="tBxwPqJdZhkId != null and tBxwPqJdZhkId != ''"> and t_bxw_pq_jd_zhk_id = #{tBxwPqJdZhkId}</if>
<if test="fcbh != null and fcbh != ''"> and fcbh = #{fcbh}</if>
<if test="fcmc != null and fcmc != ''"> and fcmc like concat(concat('%', #{fcmc}), '%')</if>
<if test="cqr != null and cqr != ''"> and cqr like concat(concat('%', #{cqr}), '%')</if>
<if test="cqrsfz != null and cqrsfz != ''"> and cqrsfz = #{cqrsfz}</if>
<if test="jzr != null and jzr != ''"> and jzr like concat(concat('%', #{jzr}), '%')</if>
<if test="fwcqzh != null and fwcqzh != ''"> and fwcqzh = #{fwcqzh}</if>
<if test="zxbz != null and zxbz != ''"> and zxbz = #{zxbz}</if>
<if test="bz != null and bz != ''"> and bz = #{bz}</if>
</where>
) a left join (
<include refid="selectTBxwFcFwZhkVo"/>
) b on id=t_bxw_fc_zhk_id
</select>
<select id="selectTBxwFcZhkById" parameterType="java.lang.String" resultMap="TBxwFcZhkResult">
select a.*, b.* from (
<include refid="selectTBxwFcZhkVo"/>
<where>
t_bxw_pq_zhk_id = pq.id and t_bxw_pq_jd_zhk_id = jd.id and fc.id = #{id}
</where>
) a left join (
<include refid="selectTBxwFcFwZhkVo"/>
) b on id=t_bxw_fc_zhk_id
</select>
<select id="generateFcbh" resultType="java.lang.Integer">
SELECT seq_fcbh_zhk.NEXTVAL as fcbh FROM DUAL
</select>
<select id="selectTBxwFcZhkByJdId" parameterType="java.lang.String" resultMap="TBxwFcZhkResult">
select * from t_bxw_fc_zhk where t_bxw_pq_jd_zhk_id=#{tBxwPqJdZhkId}
</select>
<insert id="insertTBxwFcZhk" parameterType="com.xyt.project.shggc.jcxx.fc.domain.TBxwFcZhk">
<selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
SELECT seq_t_bxw_fc_zhk.NEXTVAL as id FROM DUAL
</selectKey>
insert into t_bxw_fc_zhk
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="tBxwPqJdZhk != null and tBxwPqJdZhk != ''">t_bxw_pq_jd_zhk_id,</if>
<if test="fcbh != null and fcbh != ''">fcbh,</if>
<if test="fcmc != null and fcmc != ''">fcmc,</if>
<if test="fwzl != null">fwzl,</if>
<if test="cqr != null">cqr,</if>
<if test="cqrsfz != null">cqrsfz,</if>
<if test="cqrlxdh != null">cqrlxdh,</if>
<if test="jzr != null">jzr,</if>
<if test="jzrlxdh != null">jzrlxdh,</if>
<if test="fwcqzh != null">fwcqzh,</if>
<if test="tdsyzh != null">tdsyzh,</if>
<if test="tdsymj != null">tdsymj,</if>
<if test="qllx != null">qllx,</if>
<if test="qlxz != null">qlxz,</if>
<if test="sfwzf != null">sfwzf,</if>
<if test="fccs != null">fccs,</if>
<if test="fwcb != null">fwcb,</if>
<if test="zxbz != null and zxbz != ''">zxbz,</if>
<if test="bz != null">bz,</if>
<if test="kz1 != null">kz1,</if>
<if test="kz2 != null">kz2,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="tBxwPqJdZhk != null and tBxwPqJdZhk != ''">#{tBxwPqJdZhk.id},</if>
<if test="fcbh != null and fcbh != ''">#{fcbh},</if>
<if test="fcmc != null and fcmc != ''">#{fcmc},</if>
<if test="fwzl != null">#{fwzl},</if>
<if test="cqr != null">#{cqr},</if>
<if test="cqrsfz != null">#{cqrsfz},</if>
<if test="cqrlxdh != null">#{cqrlxdh},</if>
<if test="jzr != null">#{jzr},</if>
<if test="jzrlxdh != null">#{jzrlxdh},</if>
<if test="fwcqzh != null">#{fwcqzh},</if>
<if test="tdsyzh != null">#{tdsyzh},</if>
<if test="tdsymj != null">#{tdsymj},</if>
<if test="qllx != null">#{qllx},</if>
<if test="qlxz != null">#{qlxz},</if>
<if test="sfwzf != null">#{sfwzf},</if>
<if test="fccs != null">#{fccs},</if>
<if test="fwcb != null">#{fwcb},</if>
<if test="zxbz != null and zxbz != ''">#{zxbz},</if>
<if test="bz != null">#{bz},</if>
<if test="kz1 != null">#{kz1},</if>
<if test="kz2 != null">#{kz2},</if>
</trim>
</insert>
<update id="updateTBxwFcZhk" parameterType="com.xyt.project.shggc.jcxx.fc.domain.TBxwFcZhk">
update t_bxw_fc_zhk
<trim prefix="SET" suffixOverrides=",">
<if test="tBxwPqJdZhkId != null and tBxwPqJdZhkId != ''">t_bxw_pq_jd_zhk_id = #{tBxwPqJdZhkId},</if>
<if test="fcbh != null and fcbh != ''">fcbh = #{fcbh},</if>
<if test="fcmc != null and fcmc != ''">fcmc = #{fcmc},</if>
<if test="fwzl != null">fwzl = #{fwzl},</if>
<if test="cqr != null">cqr = #{cqr},</if>
<if test="cqrsfz != null">cqrsfz = #{cqrsfz},</if>
<if test="cqrlxdh != null">cqrlxdh = #{cqrlxdh},</if>
<if test="jzr != null">jzr = #{jzr},</if>
<if test="jzrlxdh != null">jzrlxdh = #{jzrlxdh},</if>
<if test="fwcqzh != null">fwcqzh = #{fwcqzh},</if>
<if test="tdsyzh != null">tdsyzh = #{tdsyzh},</if>
<if test="tdsymj != null">tdsymj = #{tdsymj},</if>
<if test="qllx != null">qllx = #{qllx},</if>
<if test="qlxz != null">qlxz = #{qlxz},</if>
<if test="sfwzf != null">sfwzf = #{sfwzf},</if>
<if test="fccs != null">fccs = #{fccs},</if>
<if test="fwcb != null">fwcb = #{fwcb},</if>
<if test="zxbz != null and zxbz != ''">zxbz = #{zxbz},</if>
<if test="bz != null">bz = #{bz},</if>
<if test="kz1 != null">kz1 = #{kz1},</if>
<if test="kz2 != null">kz2 = #{kz2},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTBxwFcZhkById" parameterType="com.xyt.project.shggc.jcxx.fc.domain.TBxwFcZhk">
delete from t_bxw_fc_zhk where id = #{id}
</delete>
<delete id="deleteTBxwFcZhkByIds" parameterType="java.lang.String">
delete from t_bxw_fc_zhk where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
3.房屋列表显示
3.1实现思路
- 查询出房产的房屋信息,回显在房产的edit功能中
- 修改房产后,将界面下的全部房屋信息进行存储(无论是否修改)
- 将该房产原有的房屋信息全部删除
- 依次添加存储的房屋信息
3.2修改房产的edit.html
完整代码
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改房产')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-fc-edit" th:object="${tBxwFcZhk}">
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label is-required">街道:</label>
<div class="col-sm-8">
<select id="tBxwPqJdZhk" name="tBxwPqJdZhkId" class="form-control select2-single required" single>
<option th:value="*{tBxwPqJdZhk.id}" th:text="*{tBxwPqJdZhk.jdmc}" ></option>
<option th:each="jd:${jds}" th:value="${jd.id}" th:text="${jd.jdmc}" ></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">房产编号:</label>
<div class="col-sm-8">
<input name="fcbh" th:field="*{fcbh}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">房产名称:</label>
<div class="col-sm-8">
<input name="fcmc" th:field="*{fcmc}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋坐落:</label>
<div class="col-sm-8">
<input name="fwzl" th:field="*{fwzl}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">产权人:</label>
<div class="col-sm-8">
<input name="cqr" th:field="*{cqr}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">产权人身份证:</label>
<div class="col-sm-8">
<input name="cqrsfz" th:field="*{cqrsfz}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">产权人联系电话:</label>
<div class="col-sm-8">
<input name="cqrlxdh" th:field="*{cqrlxdh}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">居住人:</label>
<div class="col-sm-8">
<input name="jzr" th:field="*{jzr}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">居住人联系电话:</label>
<div class="col-sm-8">
<input name="jzrlxdh" th:field="*{jzrlxdh}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋产权证号:</label>
<div class="col-sm-8">
<input name="fwcqzh" th:field="*{fwcqzh}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">土地使用证号:</label>
<div class="col-sm-8">
<input name="tdsyzh" th:field="*{tdsyzh}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">土地使用面积:</label>
<div class="col-sm-8">
<input name="tdsymj" th:field="*{tdsymj}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">权利类型:</label>
<div class="col-sm-8">
<select name="qllx" class="form-control m-b" th:with="type=${@dict.getType('t_jc_qllx')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{qllx}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">权利性质:</label>
<div class="col-sm-8">
<select name="qlxz" class="form-control m-b" th:with="type=${@dict.getType('t_jc_qlxz')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{qlxz}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否无证房:</label>
<div class="col-sm-8">
<select name="sfwzf" class="form-control m-b" th:with="type=${@dict.getType('t_jc_sfwzf')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sfwzf}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋出售:</label>
<div class="col-sm-8">
<select name="fccs" class="form-control m-b" th:with="type=${@dict.getType('t_jc_fccs')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{fccs}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋产别:</label>
<div class="col-sm-8">
<select name="fwcb" class="form-control m-b" th:with="type=${@dict.getType('t_jc_fwcb')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{fwcb}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">注销标志:</label>
<div class="col-sm-8">
<select name="zxbz" class="form-control m-b" th:with="type=${@dict.getType('t_jc_zxztlx')}" required>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{zxbz}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<input name="bz" th:field="*{bz}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">扩展1:</label>
<div class="col-sm-8">
<input name="kz1" th:field="*{kz1}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">扩展2:</label>
<div class="col-sm-8">
<input name="kz2" th:field="*{kz2}" class="form-control" type="text">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h4 class="form-header h4">房屋信息</h4>
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" style="table-layout:fixed;word-break:break-all;"></table>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "jcxx/fc";
var zxztDatas = [[${@dict.getType('t_jc_zxzt')}]];
$("#form-fc-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-fc-edit').serialize());
}
}
$(function() {
var options = {
data: [[${tBxwFcZhk.tBxwFcFwZhks}]],
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [{
checkbox: true,
width: '10%'
},
{
field: 'index',
align: 'center',
title: "序",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
},
width: '8%'
},
{
field: 'fwjs',
align: 'center',
title: '房屋间数',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='tBxwFcFwZhks[%s].fwjs' value='%s'>", index, value);
return html;
},
width: '30%'
},
{
field: 'jzmj',
align: 'center',
title: '建筑面积',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='tBxwFcFwZhks[%s].jzmj' value='%s'>", index, value);
return html;
},
width: '40%'
},
{
field: 'zxbz',
align: 'center',
title: '注销标志',
formatter: function(value, row, index) {
var name = $.common.sprintf("tBxwFcFwZhks[%s].zxbz", index);
return $.common.dictToSelect(zxztDatas, value, name);
},
width: '20%'
},
{
field: 'bz',
align: 'center',
title: '备注',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='tBxwFcFwZhks[%s].bz' value='%s'>", index, value);
return html;
},
width: '30%'
}]
};
$.table.init(options);
});
function addColumn() {
var count = $("#" + table.options.id).bootstrapTable('getData').length + 1;
sub.editColumn();
$("#" + table.options.id).bootstrapTable('insertRow', {
index: count,
row: {
index: $.table.serialNumber(count),
fwjs: "0",
jzmj: "0",
zxbz: "0",
bz: ""
}
});
}
</script>
</body>
</html>
3.3修改房产的serviceImp
updateTbxwFcZhk函数
/**
* 修改房产
*
* @param tBxwFcZhk 房产
* @return 结果
*/
@Override
public int updateTBxwFcZhk(TBxwFcZhk tBxwFcZhk)
{
/先读取修改后的所有的fw,存进fws中
List <TBxwFcFwZhk> fws = tBxwFcZhk.gettBxwFcFwZhks();
修改房产信息成功的话,fcNum=1,修改失败=0
int fcNum = tBxwFcZhkMapper.updateTBxwFcZhk(tBxwFcZhk);
///删除该房产下的全部房屋
tBxwFcFwZhkMapper.deleteTBxwFcFwZhkByFcId(tBxwFcZhk.getId());
如果修改之后没有传房屋信息,直接返回fcNum
if(fws == null)return fcNum;
如果有房屋,遍历进行插入房屋到房产中
for(TBxwFcFwZhk fw : fws ) {
///设置房产id
fw.settBxwFcZhkId(tBxwFcZhk.getId());
//插入一个房屋,fwNum+1,不过在该功能中fwNum无关紧要,只要执行插入操作即可
int fwNum =tBxwFcFwZhkMapper.insertTBxwFcFwZhk(fw);
fcNum += fwNum;
}
///返回fcNum,如果fcNum=0,说明修改失败,fcNum>0,说明修改成功,在该代码中,有没有fcNum影响不大,直接return 1 也不影响
return fcNum;
}
3.4修改房屋的mapper
mapper.Java 添加按房产id删除全部房屋的方法 deleteTBxwFcFwZhkByFcId()
mapper.xml 具体实现该方法
<delete id="deleteTBxwFcFwZhkByFcId" parameterType="com.xyt.project.shggc.jcxx.fw.domain.TBxwFcFwZhk">
delete from t_bxw_fc_fw_zhk where t_bxw_fc_zhk_id = #{tBxwFcZhkId}
</delete>
3.5功能实现
4.房屋添加,房屋修改
3.1修改房产的add.html
完整代码
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增房产')" />
<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-fc-add">
<div class="form-group">
<div class="form-group">
<label class="col-sm-3 control-label is-required" >街道:</label>
<div class="col-sm-8">
<select id="jd" name="tBxwPqJdZhk.id" class="form-control select2-single" single>
<option th:value="-1" th:text="请选择街道"></option>
<option th:each="jd:${jds}" th:value="${jd.id}" th:text="${jd.jdmc}" ></option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">房产编号:</label>
<div class="col-sm-8">
<input name="fcbh" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">房产名称:</label>
<div class="col-sm-8">
<input name="fcmc" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋坐落:</label>
<div class="col-sm-8">
<input name="fwzl" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">产权人:</label>
<div class="col-sm-8">
<input name="cqr" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">产权人身份证:</label>
<div class="col-sm-8">
<input name="cqrsfz" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">产权人联系电话:</label>
<div class="col-sm-8">
<input name="cqrlxdh" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">居住人:</label>
<div class="col-sm-8">
<input name="jzr" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">居住人联系电话:</label>
<div class="col-sm-8">
<input name="jzrlxdh" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋产权证号:</label>
<div class="col-sm-8">
<input name="fwcqzh" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">土地使用证号:</label>
<div class="col-sm-8">
<input name="tdsyzh" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">土地使用面积:</label>
<div class="col-sm-8">
<input name="tdsymj" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">权利类型:</label>
<div class="col-sm-8">
<select name="qllx" class="form-control m-b" th:with="type=${@dict.getType('t_jc_qllx')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">权利性质:</label>
<div class="col-sm-8">
<select name="qlxz" class="form-control m-b" th:with="type=${@dict.getType('t_jc_qlxz')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否无证房:</label>
<div class="col-sm-8">
<select name="sfwzf" class="form-control m-b" th:with="type=${@dict.getType('t_jc_sfwzf')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋出售:</label>
<div class="col-sm-8">
<select name="fccs" class="form-control m-b" th:with="type=${@dict.getType('t_jc_fccs')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">房屋产别:</label>
<div class="col-sm-8">
<select name="fwcb" class="form-control m-b" th:with="type=${@dict.getType('t_jc_fwcb')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">注销标志:</label>
<div class="col-sm-8">
<select name="zxbz" class="form-control m-b" th:with="type=${@dict.getType('t_jc_zxztlx')}" required>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<input name="bz" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">扩展1:</label>
<div class="col-sm-8">
<input name="kz1" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">扩展2:</label>
<div class="col-sm-8">
<input name="kz2" class="form-control" type="text">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h4 class="form-header h4">房屋信息</h4>
<button type="button" class="btn btn-white btn-sm"
onclick="addColumn()">
<i class="fa fa-plus"> 增加</i>
</button>
<button type="button" class="btn btn-white btn-sm"
onclick="sub.delColumn()">
<i class="fa fa-minus"> 删除</i>
</button>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"
style="table-layout: fixed; word-break: break-all;"></table>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
var prefix = ctx + "jcxx/fc"
var zxztDatas = [[${@dict.getType('t_jc_zxzt')}]];
$("#form-fc-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-fc-add').serialize());
}
}
$(function() {
var options = {
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [{
checkbox: true,
width: '10%'
},
{
field: 'index',
align: 'center',
title: "序",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
},
width: '8%'
},
{
field: 'fwjs',
align: 'center',
title: '房屋间数',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='tBxwFcFwZhks[%s].fwjs' value='%s' required>", index, value);
return html;
},
width: '30%'
},
{
field: 'jzmj',
align: 'center',
title: '建筑面积',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='tBxwFcFwZhks[%s].jzmj' value='%s' required>", index, value);
return html;
},
width: '40%'
},
{
field: 'zxbz',
align: 'center',
title: '注销标志',
formatter: function(value, row, index) {
var name = $.common.sprintf("tBxwFcFwZhks[%s].zxbz", index);
return $.common.dictToSelect(zxztDatas, value, name);
},
width: '20%'
},
{
field: 'bz',
align: 'center',
title: '备注',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='tBxwFcFwZhks[%s].bz' value='%s'>", index, value);
return html;
},
width: '30%'
}]
};
$.table.init(options);
});
function addColumn() {
var count = $("#" + table.options.id).bootstrapTable('getData').length + 1;
sub.editColumn();
$("#" + table.options.id).bootstrapTable('insertRow', {
index: count,
row: {
index: $.table.serialNumber(count),
fwjs: "0",
jzmj: "0",
zxbz: "0",
bz: ""
}
});
}
</script>
</body>
</html>
3.2修改房产的serviceImp
insertTbxwFcZhk函数 插入房屋,房产信息
/**
* 新增房产
*
* @param tBxwFcZhk 房产
* @return 结果
*/
@Override
public int insertTBxwFcZhk(TBxwFcZhk tBxwFcZhk)
{
List <TBxwFcFwZhk> fws = tBxwFcZhk.gettBxwFcFwZhks();
/插入房产信息
int fcNum = tBxwFcZhkMapper.insertTBxwFcZhk(tBxwFcZhk);
if(fws == null)return fcNum;
for(TBxwFcFwZhk fw:fws ) {
fw.settBxwFcZhkId(tBxwFcZhk.getId());
/插入房屋信息
int fwNum =tBxwFcFwZhkMapper.insertTBxwFcFwZhk(fw);
fcNum += fwNum;
}
return fcNum;
}