修复机房和机柜列表子条件搜索问题

This commit is contained in:
tangpeng 2019-06-18 11:54:31 +08:00
parent bf1e675967
commit 3756b0a012
9 changed files with 298 additions and 180 deletions

View File

@ -71,13 +71,13 @@
required: true, required: true,
minlength: 1, minlength: 1,
maxlength: 3, maxlength: 3,
min:1, min: 1
}, },
cabinetAvailElec: { cabinetAvailElec: {
required: true, required: true,
minlength: 1, minlength: 1,
maxlength: 5, maxlength: 5,
min:1 min: 1
} }
}, },
focusCleanup: true focusCleanup: true

View File

@ -10,14 +10,12 @@
<form id="formId"> <form id="formId">
<div class="select-list"> <div class="select-list">
<ul> <ul>
<li>
机房:<input type="text" name="machineRoomId"/>
</li>
<li> <li>
机柜名称:<input type="text" name="cabinetName"/> 机柜名称:<input type="text" name="cabinetName"/>
</li> </li>
<li>
机房:<input type="text" name="dictCode"/>
</li>
<li> <li>
机柜所在区域:<input type="text" name="cabinetArea"/> 机柜所在区域:<input type="text" name="cabinetArea"/>
</li> </li>
@ -91,7 +89,12 @@
visible: false visible: false
}, },
{ {
field: 'machineRoomId', field: 'cabinetName',
title: '机柜名称',
sortable: true
},
{
field: 'machineRoom',
title: '所属机房', title: '所属机房',
sortable: true, sortable: true,
formatter: function (value, row, index) { formatter: function (value, row, index) {
@ -102,11 +105,6 @@
return value; return value;
} }
}, },
{
field: 'cabinetName',
title: '机柜名称',
sortable: true
},
{ {
field: 'cabinetArea', field: 'cabinetArea',
title: '机柜所在区域', title: '机柜所在区域',

View File

@ -1,96 +1,140 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > <html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<th:block th:include="include :: header('新增机房')" /> <th:block th:include="include :: header('新增机房')"/>
</head> </head>
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-assetsMachineRoom-add"> <form class="form-horizontal m" id="form-assetsMachineRoom-add">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">机房名称:</label> <label class="col-sm-3 control-label">机房名称:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="machineRoomName" name="machineRoomName" class="form-control" type="text"> <input id="machineRoomName" name="machineRoomName" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">带宽类型:</label> <label class="col-sm-3 control-label">带宽类型:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="bandwidthType" name="bandwidthType" class="form-control" type="text"> <select id="bandwidthType" name="bandwidthType.dictCode"
</div> th:with="type=${@dict.getType('dict_bandwidth_type')}">
</div> <option value="">请选择带宽类型</option>
<div class="form-group"> <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
<label class="col-sm-3 control-label">带宽大小:</label> th:value="${dict.dictCode}">
<div class="col-sm-8"> </option>
<input id="bandwidthSize" name="bandwidthSize" class="form-control" type="text"> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">所在国家:</label> <label class="col-sm-3 control-label">带宽大小:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="country" name="country" class="form-control" type="text"> <input id="bandwidthSize" name="bandwidthSize" class="form-control" type="number" min="1">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">所在省:</label> <label class="col-sm-3 control-label">所在国家:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="province" name="province" class="form-control" type="text"> <input id="country" name="country" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">所在市:</label> <label class="col-sm-3 control-label">所在省:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="city" name="city" class="form-control" type="text"> <input id="province" name="province" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">所在区:</label> <label class="col-sm-3 control-label">所在市:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="area" name="area" class="form-control" type="text"> <input id="city" name="city" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">地址:</label> <label class="col-sm-3 control-label">所在区:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="location" name="location" class="form-control" type="text"> <input id="area" name="area" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">联系人:</label> <label class="col-sm-3 control-label">地址:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="contactPerson" name="contactPerson" class="form-control" type="text"> <input id="location" name="location" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">联系电话:</label> <label class="col-sm-3 control-label">联系人:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="contactPhone" name="contactPhone" class="form-control" type="text"> <input id="contactPerson" name="contactPerson" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">邮箱:</label> <label class="col-sm-3 control-label">联系电话:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="email" name="email" class="form-control" type="text"> <input id="contactPhone" name="contactPhone" class="form-control" type="text">
</div> </div>
</div> </div>
</form> <div class="form-group">
</div> <label class="col-sm-3 control-label">邮箱:</label>
<div th:include="include::footer"></div> <div class="col-sm-8">
<script type="text/javascript"> <input id="email" name="email" class="form-control" type="text">
var prefix = ctx + "assets/assetsMachineRoom" </div>
$("#form-assetsMachineRoom-add").validate({ </div>
rules:{ </form>
xxxx:{ </div>
required:true, <div th:include="include::footer"></div>
}, <script type="text/javascript">
}, var prefix = ctx + "assets/assetsMachineRoom";
focusCleanup: true $("#form-assetsMachineRoom-add").validate({
}); rules: {
"bandwidthType.dictCode": {
required: true
},
machineRoomName: {
required: true,
minlength: 1,
maxlength: 10
},
bandwidthSize: {
required: true,
minlength: 1,
maxlength: 10
},
country: {
required: true,
minlength: 1,
maxlength: 10
},
province: {
required: true,
minlength: 1,
maxlength: 10
},
city: {
required: true,
minlength: 1,
maxlength: 10
},
area: {
required: true,
minlength: 1,
maxlength: 10
},
email: {
required: false,
email: true
},
contactPhone: {
required: false,
isPhone: true
}
},
focusCleanup: true
});
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-assetsMachineRoom-add').serialize()); $.operate.save(prefix + "/add", $('#form-assetsMachineRoom-add').serialize());
} }
} }
</script> </script>
</body> </body>
</html> </html>

View File

@ -15,7 +15,7 @@
</li> </li>
<li> <li>
带宽类型:<input type="text" name="bandwidthType"/> 带宽类型:<input type="text" name="dictCode"/>
</li> </li>
<li> <li>
@ -116,7 +116,7 @@
sortable: true sortable: true
}, },
{ {
field: 'bandwidthType', field: 'bandwidthType.dictLabel',
title: '带宽类型', title: '带宽类型',
sortable: true sortable: true
}, },

View File

@ -17,8 +17,14 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">带宽类型:</label> <label class="col-sm-3 control-label">带宽类型:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="bandwidthType" name="bandwidthType" th:field="*{bandwidthType}" class="form-control" <select id="bandwidthType" name="bandwidthType.dictCode"
type="text"> th:with="type=${@dict.getType('dict_bandwidth_type')}">
<option value="">请选择带宽类型</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictCode}"
th:selected="*{bandwidthType.dictCode} == ${dict.dictCode} ? true :false">
</option>
</select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -85,9 +91,47 @@
var prefix = ctx + "assets/assetsMachineRoom"; var prefix = ctx + "assets/assetsMachineRoom";
$("#form-assetsMachineRoom-edit").validate({ $("#form-assetsMachineRoom-edit").validate({
rules: { rules: {
xxxx: { "bandwidthType.dictCode": {
required: true, required: true
}, },
machineRoomName: {
required: true,
minlength: 1,
maxlength: 10
},
bandwidthSize: {
required: true,
minlength: 1,
maxlength: 10
},
country: {
required: true,
minlength: 1,
maxlength: 10
},
province: {
required: true,
minlength: 1,
maxlength: 10
},
city: {
required: true,
minlength: 1,
maxlength: 10
},
area: {
required: true,
minlength: 1,
maxlength: 10
},
email: {
required: false,
email: true
},
contactPhone: {
required: false,
isPhone: true
}
}, },
focusCleanup: true focusCleanup: true
}); });

View File

@ -20,7 +20,12 @@ public class AssetsCabinet extends BaseEntity {
/** /**
* 机房编号 * 机房编号
*/ */
private Integer dictCode;
/**
* 机房对象
*/
private AssetsMachineRoom machineRoom; private AssetsMachineRoom machineRoom;
/** /**
* 机柜名称 * 机柜名称
*/ */
@ -46,6 +51,14 @@ public class AssetsCabinet extends BaseEntity {
this.cabinetId = cabinetId; this.cabinetId = cabinetId;
} }
public Integer getDictCode() {
return dictCode;
}
public void setDictCode(Integer dictCode) {
this.dictCode = dictCode;
}
public AssetsMachineRoom getMachineRoom() { public AssetsMachineRoom getMachineRoom() {
return machineRoom; return machineRoom;
} }

View File

@ -1,9 +1,12 @@
package com.ruoyi.assets.domain; package com.ruoyi.assets.domain;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.system.domain.SysDictData;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import java.beans.Transient;
/** /**
* 机房表 assets_machine_room * 机房表 assets_machine_room
* *
@ -24,7 +27,11 @@ public class AssetsMachineRoom extends BaseEntity {
/** /**
* 带宽类型 * 带宽类型
*/ */
private Long bandwidthType; private Integer dictCode;
/**
* 带宽类型 实体关联
*/
private SysDictData bandwidthType;
/** /**
* 带宽大小 * 带宽大小
*/ */
@ -78,11 +85,20 @@ public class AssetsMachineRoom extends BaseEntity {
this.machineRoomName = machineRoomName; this.machineRoomName = machineRoomName;
} }
public Long getBandwidthType() { @Transient
public Integer getDictCode() {
return dictCode;
}
public void setDictCode(Integer dictCode) {
this.dictCode = dictCode;
}
public SysDictData getBandwidthType() {
return bandwidthType; return bandwidthType;
} }
public void setBandwidthType(Long bandwidthType) { public void setBandwidthType(SysDictData bandwidthType) {
this.bandwidthType = bandwidthType; this.bandwidthType = bandwidthType;
} }

View File

@ -6,7 +6,6 @@
<resultMap type="AssetsCabinet" id="AssetsCabinetResult"> <resultMap type="AssetsCabinet" id="AssetsCabinetResult">
<result property="cabinetId" column="cabinet_id"/> <result property="cabinetId" column="cabinet_id"/>
<!-- <result property="machineRoom" column="machine_room_id"/>-->
<result property="cabinetName" column="cabinet_name"/> <result property="cabinetName" column="cabinet_name"/>
<result property="cabinetArea" column="cabinet_area"/> <result property="cabinetArea" column="cabinet_area"/>
<result property="cabinetAvailU" column="cabinet_avail_u"/> <result property="cabinetAvailU" column="cabinet_avail_u"/>
@ -25,7 +24,7 @@
<include refid="selectAssetsCabinetVo"/> <include refid="selectAssetsCabinetVo"/>
<where> <where>
<if test="cabinetId != null ">and cabinet_id = #{cabinetId}</if> <if test="cabinetId != null ">and cabinet_id = #{cabinetId}</if>
<if test="machineRoom != null ">and machine_room_id = #{machineRoom.machineRoomId}</if> <if test="dictCode != null ">and machine_room_id = #{dictCode}</if>
<if test="cabinetName != null and cabinetName != '' ">and cabinet_name = #{cabinetName}</if> <if test="cabinetName != null and cabinetName != '' ">and cabinet_name = #{cabinetName}</if>
<if test="cabinetArea != null ">and cabinet_area = #{cabinetArea}</if> <if test="cabinetArea != null ">and cabinet_area = #{cabinetArea}</if>
<if test="cabinetAvailU != null ">and cabinet_avail_u = #{cabinetAvailU}</if> <if test="cabinetAvailU != null ">and cabinet_avail_u = #{cabinetAvailU}</if>

View File

@ -1,44 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.assets.mapper.AssetsMachineRoomMapper"> <mapper namespace="com.ruoyi.assets.mapper.AssetsMachineRoomMapper">
<resultMap type="AssetsMachineRoom" id="AssetsMachineRoomResult"> <resultMap type="AssetsMachineRoom" id="AssetsMachineRoomResult">
<result property="machineRoomId" column="machine_room_id" /> <result property="machineRoomId" column="machine_room_id"/>
<result property="machineRoomName" column="machine_room_name" /> <result property="machineRoomName" column="machine_room_name"/>
<result property="bandwidthType" column="bandwidth_type" /> <result property="bandwidthSize" column="bandwidth_size"/>
<result property="bandwidthSize" column="bandwidth_size" /> <result property="country" column="country"/>
<result property="country" column="country" /> <result property="province" column="province"/>
<result property="province" column="province" /> <result property="city" column="city"/>
<result property="city" column="city" /> <result property="area" column="area"/>
<result property="area" column="area" /> <result property="location" column="location"/>
<result property="location" column="location" /> <result property="contactPerson" column="contact_person"/>
<result property="contactPerson" column="contact_person" /> <result property="contactPhone" column="contact_phone"/>
<result property="contactPhone" column="contact_phone" /> <result property="email" column="email"/>
<result property="email" column="email" /> <association property="bandwidthType" column="bandwidth_type"
select="com.ruoyi.system.mapper.SysDictDataMapper.selectDictDataById">
</association>
</resultMap> </resultMap>
<sql id="selectAssetsMachineRoomVo"> <sql id="selectAssetsMachineRoomVo">
select machine_room_id, machine_room_name, bandwidth_type, bandwidth_size, country, province, city, area, location, contact_person, contact_phone, email from assets_machine_room select machine_room_id, machine_room_name, bandwidth_type, bandwidth_size, country, province, city, area, location, contact_person, contact_phone, email from assets_machine_room
</sql> </sql>
<select id="selectAssetsMachineRoomList" parameterType="AssetsMachineRoom" resultMap="AssetsMachineRoomResult"> <select id="selectAssetsMachineRoomList" parameterType="AssetsMachineRoom" resultMap="AssetsMachineRoomResult">
<include refid="selectAssetsMachineRoomVo"/> <include refid="selectAssetsMachineRoomVo"/>
<where> <where>
<if test="machineRoomId != null "> and machine_room_id = #{machineRoomId}</if> <if test="machineRoomId != null ">and machine_room_id = #{machineRoomId}</if>
<if test="machineRoomName != null and machineRoomName != '' "> and machine_room_name = #{machineRoomName}</if> <if test="machineRoomName != null and machineRoomName != '' ">and machine_room_name = #{machineRoomName}
<if test="bandwidthType != null "> and bandwidth_type = #{bandwidthType}</if> </if>
<if test="bandwidthSize != null "> and bandwidth_size = #{bandwidthSize}</if> <if test="dictCode != null ">and bandwidth_type = #{dictCode}</if>
<if test="country != null and country != '' "> and country = #{country}</if> <if test="bandwidthSize != null ">and bandwidth_size = #{bandwidthSize}</if>
<if test="province != null and province != '' "> and province = #{province}</if> <if test="country != null and country != '' ">and country = #{country}</if>
<if test="city != null and city != '' "> and city = #{city}</if> <if test="province != null and province != '' ">and province = #{province}</if>
<if test="area != null and area != '' "> and area = #{area}</if> <if test="city != null and city != '' ">and city = #{city}</if>
<if test="location != null and location != '' "> and location = #{location}</if> <if test="area != null and area != '' ">and area = #{area}</if>
<if test="contactPerson != null and contactPerson != '' "> and contact_person = #{contactPerson}</if> <if test="location != null and location != '' ">and location = #{location}</if>
<if test="contactPhone != null and contactPhone != '' "> and contact_phone = #{contactPhone}</if> <if test="contactPerson != null and contactPerson != '' ">and contact_person = #{contactPerson}</if>
<if test="email != null and email != '' "> and email = #{email}</if> <if test="contactPhone != null and contactPhone != '' ">and contact_phone = #{contactPhone}</if>
</where> <if test="email != null and email != '' ">and email = #{email}</if>
</where>
</select> </select>
<select id="selectAssetsMachineRoomById" parameterType="Integer" resultMap="AssetsMachineRoomResult"> <select id="selectAssetsMachineRoomById" parameterType="Integer" resultMap="AssetsMachineRoomResult">
@ -46,41 +49,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where machine_room_id = #{machineRoomId} where machine_room_id = #{machineRoomId}
</select> </select>
<insert id="insertAssetsMachineRoom" parameterType="AssetsMachineRoom" useGeneratedKeys="true" keyProperty="machineRoomId"> <insert id="insertAssetsMachineRoom" parameterType="AssetsMachineRoom" useGeneratedKeys="true"
keyProperty="machineRoomId">
insert into assets_machine_room insert into assets_machine_room
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="machineRoomName != null and machineRoomName != '' ">machine_room_name,</if> <if test="machineRoomName != null and machineRoomName != '' ">machine_room_name,</if>
<if test="bandwidthType != null ">bandwidth_type,</if> <if test="bandwidthType != null ">bandwidth_type,</if>
<if test="bandwidthSize != null ">bandwidth_size,</if> <if test="bandwidthSize != null ">bandwidth_size,</if>
<if test="country != null and country != '' ">country,</if> <if test="country != null and country != '' ">country,</if>
<if test="province != null and province != '' ">province,</if> <if test="province != null and province != '' ">province,</if>
<if test="city != null and city != '' ">city,</if> <if test="city != null and city != '' ">city,</if>
<if test="area != null and area != '' ">area,</if> <if test="area != null and area != '' ">area,</if>
<if test="location != null and location != '' ">location,</if> <if test="location != null and location != '' ">location,</if>
<if test="contactPerson != null and contactPerson != '' ">contact_person,</if> <if test="contactPerson != null and contactPerson != '' ">contact_person,</if>
<if test="contactPhone != null and contactPhone != '' ">contact_phone,</if> <if test="contactPhone != null and contactPhone != '' ">contact_phone,</if>
<if test="email != null and email != '' ">email,</if> <if test="email != null and email != '' ">email,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="machineRoomName != null and machineRoomName != '' ">#{machineRoomName},</if> <if test="machineRoomName != null and machineRoomName != '' ">#{machineRoomName},</if>
<if test="bandwidthType != null ">#{bandwidthType},</if> <if test="bandwidthType != null ">#{bandwidthType.dictCode},</if>
<if test="bandwidthSize != null ">#{bandwidthSize},</if> <if test="bandwidthSize != null ">#{bandwidthSize},</if>
<if test="country != null and country != '' ">#{country},</if> <if test="country != null and country != '' ">#{country},</if>
<if test="province != null and province != '' ">#{province},</if> <if test="province != null and province != '' ">#{province},</if>
<if test="city != null and city != '' ">#{city},</if> <if test="city != null and city != '' ">#{city},</if>
<if test="area != null and area != '' ">#{area},</if> <if test="area != null and area != '' ">#{area},</if>
<if test="location != null and location != '' ">#{location},</if> <if test="location != null and location != '' ">#{location},</if>
<if test="contactPerson != null and contactPerson != '' ">#{contactPerson},</if> <if test="contactPerson != null and contactPerson != '' ">#{contactPerson},</if>
<if test="contactPhone != null and contactPhone != '' ">#{contactPhone},</if> <if test="contactPhone != null and contactPhone != '' ">#{contactPhone},</if>
<if test="email != null and email != '' ">#{email},</if> <if test="email != null and email != '' ">#{email},</if>
</trim> </trim>
</insert> </insert>
<update id="updateAssetsMachineRoom" parameterType="AssetsMachineRoom"> <update id="updateAssetsMachineRoom" parameterType="AssetsMachineRoom">
update assets_machine_room update assets_machine_room
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="machineRoomName != null and machineRoomName != '' ">machine_room_name = #{machineRoomName},</if> <if test="machineRoomName != null and machineRoomName != '' ">machine_room_name = #{machineRoomName},</if>
<if test="bandwidthType != null ">bandwidth_type = #{bandwidthType},</if> <if test="bandwidthType != null ">bandwidth_type = #{bandwidthType.dictCode},</if>
<if test="bandwidthSize != null ">bandwidth_size = #{bandwidthSize},</if> <if test="bandwidthSize != null ">bandwidth_size = #{bandwidthSize},</if>
<if test="country != null and country != '' ">country = #{country},</if> <if test="country != null and country != '' ">country = #{country},</if>
<if test="province != null and province != '' ">province = #{province},</if> <if test="province != null and province != '' ">province = #{province},</if>
@ -94,7 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where machine_room_id = #{machineRoomId} where machine_room_id = #{machineRoomId}
</update> </update>
<delete id="deleteAssetsMachineRoomById" parameterType="Integer"> <delete id="deleteAssetsMachineRoomById" parameterType="Integer">
delete from assets_machine_room where machine_room_id = #{machineRoomId} delete from assets_machine_room where machine_room_id = #{machineRoomId}
</delete> </delete>