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

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,
minlength: 1,
maxlength: 3,
min:1,
min: 1
},
cabinetAvailElec: {
required: true,
minlength: 1,
maxlength: 5,
min:1
min: 1
}
},
focusCleanup: true

View File

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

View File

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

View File

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

View File

@ -17,8 +17,14 @@
<div class="form-group">
<label class="col-sm-3 control-label">带宽类型:</label>
<div class="col-sm-8">
<input id="bandwidthType" name="bandwidthType" th:field="*{bandwidthType}" class="form-control"
type="text">
<select id="bandwidthType" name="bandwidthType.dictCode"
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 class="form-group">
@ -85,9 +91,47 @@
var prefix = ctx + "assets/assetsMachineRoom";
$("#form-assetsMachineRoom-edit").validate({
rules: {
xxxx: {
required: true,
"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
});

View File

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

View File

@ -1,9 +1,12 @@
package com.ruoyi.assets.domain;
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.ToStringStyle;
import java.beans.Transient;
/**
* 机房表 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;
}
public Long getBandwidthType() {
@Transient
public Integer getDictCode() {
return dictCode;
}
public void setDictCode(Integer dictCode) {
this.dictCode = dictCode;
}
public SysDictData getBandwidthType() {
return bandwidthType;
}
public void setBandwidthType(Long bandwidthType) {
public void setBandwidthType(SysDictData bandwidthType) {
this.bandwidthType = bandwidthType;
}

View File

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

View File

@ -1,86 +1,90 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.assets.mapper.AssetsMachineRoomMapper">
<resultMap type="AssetsMachineRoom" id="AssetsMachineRoomResult">
<result property="machineRoomId" column="machine_room_id" />
<result property="machineRoomName" column="machine_room_name" />
<result property="bandwidthType" column="bandwidth_type" />
<result property="bandwidthSize" column="bandwidth_size" />
<result property="country" column="country" />
<result property="province" column="province" />
<result property="city" column="city" />
<result property="area" column="area" />
<result property="location" column="location" />
<result property="contactPerson" column="contact_person" />
<result property="contactPhone" column="contact_phone" />
<result property="email" column="email" />
<result property="machineRoomId" column="machine_room_id"/>
<result property="machineRoomName" column="machine_room_name"/>
<result property="bandwidthSize" column="bandwidth_size"/>
<result property="country" column="country"/>
<result property="province" column="province"/>
<result property="city" column="city"/>
<result property="area" column="area"/>
<result property="location" column="location"/>
<result property="contactPerson" column="contact_person"/>
<result property="contactPhone" column="contact_phone"/>
<result property="email" column="email"/>
<association property="bandwidthType" column="bandwidth_type"
select="com.ruoyi.system.mapper.SysDictDataMapper.selectDictDataById">
</association>
</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
</sql>
<select id="selectAssetsMachineRoomList" parameterType="AssetsMachineRoom" resultMap="AssetsMachineRoomResult">
<include refid="selectAssetsMachineRoomVo"/>
<where>
<if test="machineRoomId != null "> and machine_room_id = #{machineRoomId}</if>
<if test="machineRoomName != null and machineRoomName != '' "> and machine_room_name = #{machineRoomName}</if>
<if test="bandwidthType != null "> and bandwidth_type = #{bandwidthType}</if>
<if test="bandwidthSize != null "> and bandwidth_size = #{bandwidthSize}</if>
<if test="country != null and country != '' "> and country = #{country}</if>
<if test="province != null and province != '' "> and province = #{province}</if>
<if test="city != null and city != '' "> and city = #{city}</if>
<if test="area != null and area != '' "> and area = #{area}</if>
<if test="location != null and location != '' "> and location = #{location}</if>
<if test="contactPerson != null and contactPerson != '' "> and contact_person = #{contactPerson}</if>
<if test="contactPhone != null and contactPhone != '' "> and contact_phone = #{contactPhone}</if>
<if test="email != null and email != '' "> and email = #{email}</if>
</where>
<where>
<if test="machineRoomId != null ">and machine_room_id = #{machineRoomId}</if>
<if test="machineRoomName != null and machineRoomName != '' ">and machine_room_name = #{machineRoomName}
</if>
<if test="dictCode != null ">and bandwidth_type = #{dictCode}</if>
<if test="bandwidthSize != null ">and bandwidth_size = #{bandwidthSize}</if>
<if test="country != null and country != '' ">and country = #{country}</if>
<if test="province != null and province != '' ">and province = #{province}</if>
<if test="city != null and city != '' ">and city = #{city}</if>
<if test="area != null and area != '' ">and area = #{area}</if>
<if test="location != null and location != '' ">and location = #{location}</if>
<if test="contactPerson != null and contactPerson != '' ">and contact_person = #{contactPerson}</if>
<if test="contactPhone != null and contactPhone != '' ">and contact_phone = #{contactPhone}</if>
<if test="email != null and email != '' ">and email = #{email}</if>
</where>
</select>
<select id="selectAssetsMachineRoomById" parameterType="Integer" resultMap="AssetsMachineRoomResult">
<include refid="selectAssetsMachineRoomVo"/>
where machine_room_id = #{machineRoomId}
</select>
<insert id="insertAssetsMachineRoom" parameterType="AssetsMachineRoom" useGeneratedKeys="true" keyProperty="machineRoomId">
<insert id="insertAssetsMachineRoom" parameterType="AssetsMachineRoom" useGeneratedKeys="true"
keyProperty="machineRoomId">
insert into assets_machine_room
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="machineRoomName != null and machineRoomName != '' ">machine_room_name,</if>
<if test="bandwidthType != null ">bandwidth_type,</if>
<if test="bandwidthSize != null ">bandwidth_size,</if>
<if test="country != null and country != '' ">country,</if>
<if test="province != null and province != '' ">province,</if>
<if test="city != null and city != '' ">city,</if>
<if test="area != null and area != '' ">area,</if>
<if test="location != null and location != '' ">location,</if>
<if test="contactPerson != null and contactPerson != '' ">contact_person,</if>
<if test="contactPhone != null and contactPhone != '' ">contact_phone,</if>
<if test="email != null and email != '' ">email,</if>
</trim>
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="machineRoomName != null and machineRoomName != '' ">machine_room_name,</if>
<if test="bandwidthType != null ">bandwidth_type,</if>
<if test="bandwidthSize != null ">bandwidth_size,</if>
<if test="country != null and country != '' ">country,</if>
<if test="province != null and province != '' ">province,</if>
<if test="city != null and city != '' ">city,</if>
<if test="area != null and area != '' ">area,</if>
<if test="location != null and location != '' ">location,</if>
<if test="contactPerson != null and contactPerson != '' ">contact_person,</if>
<if test="contactPhone != null and contactPhone != '' ">contact_phone,</if>
<if test="email != null and email != '' ">email,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="machineRoomName != null and machineRoomName != '' ">#{machineRoomName},</if>
<if test="bandwidthType != null ">#{bandwidthType},</if>
<if test="bandwidthSize != null ">#{bandwidthSize},</if>
<if test="country != null and country != '' ">#{country},</if>
<if test="province != null and province != '' ">#{province},</if>
<if test="city != null and city != '' ">#{city},</if>
<if test="area != null and area != '' ">#{area},</if>
<if test="location != null and location != '' ">#{location},</if>
<if test="contactPerson != null and contactPerson != '' ">#{contactPerson},</if>
<if test="contactPhone != null and contactPhone != '' ">#{contactPhone},</if>
<if test="email != null and email != '' ">#{email},</if>
</trim>
<if test="machineRoomName != null and machineRoomName != '' ">#{machineRoomName},</if>
<if test="bandwidthType != null ">#{bandwidthType.dictCode},</if>
<if test="bandwidthSize != null ">#{bandwidthSize},</if>
<if test="country != null and country != '' ">#{country},</if>
<if test="province != null and province != '' ">#{province},</if>
<if test="city != null and city != '' ">#{city},</if>
<if test="area != null and area != '' ">#{area},</if>
<if test="location != null and location != '' ">#{location},</if>
<if test="contactPerson != null and contactPerson != '' ">#{contactPerson},</if>
<if test="contactPhone != null and contactPhone != '' ">#{contactPhone},</if>
<if test="email != null and email != '' ">#{email},</if>
</trim>
</insert>
<update id="updateAssetsMachineRoom" parameterType="AssetsMachineRoom">
update assets_machine_room
<trim prefix="SET" suffixOverrides=",">
<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="country != null and country != '' ">country = #{country},</if>
<if test="province != null and province != '' ">province = #{province},</if>
@ -94,15 +98,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where machine_room_id = #{machineRoomId}
</update>
<delete id="deleteAssetsMachineRoomById" parameterType="Integer">
<delete id="deleteAssetsMachineRoomById" parameterType="Integer">
delete from assets_machine_room where machine_room_id = #{machineRoomId}
</delete>
<delete id="deleteAssetsMachineRoomByIds" parameterType="String">
delete from assets_machine_room where machine_room_id in
delete from assets_machine_room where machine_room_id in
<foreach item="machineRoomId" collection="array" open="(" separator="," close=")">
#{machineRoomId}
</foreach>
</delete>
</mapper>