添加 使用记录

master
wanghao 1 month ago
parent dc877552fb
commit c4523aa95a

@ -76,7 +76,7 @@
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
sortName: "dictId",
sortOrder: "asc",
sortOrder: "desc",
modalName: "类型",
columns: [{
checkbox: true

@ -125,4 +125,10 @@ public class BaseInfoController extends BaseController
{
return toAjax(baseInfoService.deleteBaseInfoByObjIds(ids));
}
@PostMapping("/checkDeviceCode")
@ResponseBody
public boolean ccheckDeviceCode(BaseInfo baseInfo){
return baseInfoService.checkDeviceCode(baseInfo);
}
}

@ -90,12 +90,6 @@ public class BaseTypeController extends BaseController
return toAjax(baseTypeService.insertBaseType(baseType));
}
@PostMapping("/checkDeviceTypeName")
@ResponseBody
public boolean checkDeviceTypeName(BaseType baseType) {
return baseTypeService.checkDeviceTypeName(baseType);
}
/**
@ -133,4 +127,15 @@ public class BaseTypeController extends BaseController
{
return toAjax(baseTypeService.deleteBaseTypeByObjIds(ids));
}
/**
*
*/
@PostMapping("/checkDeviceTypeName")
@ResponseBody
public boolean checkDeviceTypeName(BaseType baseType) {
return baseTypeService.checkDeviceTypeName(baseType);
}
}

@ -45,8 +45,18 @@ public class BaseInfo extends BaseEntity
/** 开锁密码 */
@Excel(name = "开锁密码")
private String openPassword;
private String typeName;
public void setObjId(Long objId)
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public void setObjId(Long objId)
{
this.objId = objId;
}

@ -1,6 +1,8 @@
package com.ruoyi.device.mapper;
import java.util.List;
import com.ruoyi.device.domain.BaseType;
import org.springframework.stereotype.Repository;
import com.ruoyi.device.domain.BaseInfo;
@ -60,4 +62,6 @@ public interface BaseInfoMapper
* @return
*/
public int deleteBaseInfoByObjIds(String[] objIds);
BaseInfo checkDeviceCode(BaseInfo baseInfo);
}

@ -58,4 +58,6 @@ public interface IBaseInfoService
* @return
*/
public int deleteBaseInfoByObjId(Long objId);
boolean checkDeviceCode(BaseInfo baseInfo);
}

@ -3,6 +3,7 @@ package com.ruoyi.device.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.device.domain.BaseType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.BaseInfoMapper;
@ -97,4 +98,16 @@ public class BaseInfoServiceImpl implements IBaseInfoService
{
return baseInfoMapper.deleteBaseInfoByObjId(objId);
}
@Override
public boolean checkDeviceCode(BaseInfo baseInfo) {
BaseInfo result = baseInfoMapper.checkDeviceCode(baseInfo);
if (result==null) {
return true;
}
if (result.getObjId().equals(baseInfo.getObjId())) {
return true;
}
return false;
}
}

@ -9,6 +9,7 @@ import com.ruoyi.device.service.IBaseTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.naming.Name;
import java.util.List;
/**
@ -17,7 +18,7 @@ import java.util.List;
* @author ruoyi
* @date 2025-05-19
*/
@Service
@Service("baseTypeService")
public class BaseTypeServiceImpl implements IBaseTypeService {
@Autowired
private BaseTypeMapper baseTypeMapper;

@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.device.mapper.BaseInfoMapper">
<resultMap type="BaseInfo" id="BaseInfoResult">
<resultMap type="com.ruoyi.device.domain.BaseInfo" id="BaseInfoResult">
<result property="objId" column="obj_id" />
<result property="deviceCode" column="device_code" />
<result property="deviceName" column="device_name" />
@ -17,6 +17,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="openPassword" column="open_password" />
<result property="typeName" column="device_type_name" />
</resultMap>
<sql id="selectBaseInfoVo">
@ -24,15 +26,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectBaseInfoList" parameterType="BaseInfo" resultMap="BaseInfoResult">
<include refid="selectBaseInfoVo"/>
<where>
<if test="deviceCode != null and deviceCode != ''"> and device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceType != null "> and device_type = #{deviceType}</if>
<if test="useState != null and useState != ''"> and use_state = #{useState}</if>
<if test="deviceState != null and deviceState != ''"> and device_state = #{deviceState}</if>
<if test="locationName != null and locationName != ''"> and location_name like concat('%', #{locationName}, '%')</if>
<if test="openPassword != null and openPassword != ''"> and open_password = #{openPassword}</if>
select info.obj_id,
device_code,
device_name,
device_type,
use_state,
device_state,
location_name,
info.create_by,
info.create_time,
info.update_by,
info.update_time,
open_password,
dbt.device_type_name
from device_base_info info
left join no_power_control.device_base_type dbt on info.device_type = dbt.obj_id
<where>
<if test="deviceCode != null and deviceCode != ''">and device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')
</if>
<if test="deviceType != null ">and device_type = #{deviceType}</if>
<if test="useState != null and useState != ''">and use_state = #{useState}</if>
<if test="deviceState != null and deviceState != ''">and device_state = #{deviceState}</if>
<if test="locationName != null and locationName != ''">and location_name like concat('%', #{locationName},
'%')
</if>
<if test="openPassword != null and openPassword != ''">and open_password = #{openPassword}</if>
</where>
</select>
@ -99,5 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{objId}
</foreach>
</delete>
<select id="checkDeviceCode" resultMap="BaseInfoResult">
<include refid="selectBaseInfoVo"/>
where device_code = #{deviceCode} limit 1
</select>
</mapper>

@ -10,7 +10,7 @@
<div class="form-group">
<label class="col-sm-4 control-label">设备编码:</label>
<div class="col-sm-8">
<input name="deviceCode" class="form-control" type="text">
<input name="deviceCode" id="deviceCode" class="form-control" type="text" required>
</div>
</div>
</div>
@ -22,6 +22,16 @@
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">设备类型:</label>
<div class="col-sm-8">
<select name="deviceType" class="form-control" th:with="type=${@baseTypeService.selectBaseTypeList(null)}">
<option th:each="dict : ${type}" th:text="${dict.deviceTypeName}" th:value="${dict.objId}"></option>
</select>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">摆放桩位:</label>
@ -30,20 +40,42 @@
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">开锁密码:</label>
<div class="col-sm-8">
<input name="openPassword" class="form-control" type="text">
</div>
</div>
</div>
<!-- <div class="col-xs-6">-->
<!-- <div class="form-group">-->
<!-- <label class="col-sm-4 control-label">开锁密码:</label>-->
<!-- <div class="col-sm-8">-->
<!-- <input name="openPassword" class="form-control" type="text">-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "device/base_info"
$("#form-base_info-add").validate({
onkeyup: false,
rules: {
deviceCode: {
remote: {
url: prefix + "/checkDeviceCode",
type: "post",
dataType: "json",
data: {
"deviceCode": function() {
return $("input[name='deviceCode']").val();
},
}
}
},
},
messages: {
"deviceCode": {
remote: "设备编码已经存在"
}
},
focusCleanup: true
});

@ -10,21 +10,29 @@
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>设备编码:</label>
<input type="text" name="deviceCode"/>
</li>
<!-- <li>-->
<!-- <label>设备编码:</label>-->
<!-- <input type="text" name="deviceCode"/>-->
<!-- </li>-->
<li>
<label>设备名称:</label>
<input type="text" name="deviceName"/>
</li>
<li>
<label>设备类型:</label>
<select name="deviceType" class="form-control" th:with="type=${@baseTypeService.selectBaseTypeList(null)}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.deviceTypeName}" th:value="${dict.objId}"></option>
</select>
</li>
<li>
<label>使用状态:</label>
<select name="useState" th:with="type=${@dict.getType('use_state')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<label>设备状态:</label>
<select name="deviceState" th:with="type=${@dict.getType('device_state')}">
@ -36,10 +44,10 @@
<label>摆放桩位:</label>
<input type="text" name="locationName"/>
</li>
<li>
<label>开锁密码:</label>
<input type="text" name="openPassword"/>
</li>
<!-- <li>-->
<!-- <label>开锁密码:</label>-->
<!-- <input type="text" name="openPassword"/>-->
<!-- </li>-->
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
@ -101,7 +109,7 @@
title: '设备名称'
},
{
field: 'deviceType',
field: 'typeName',
title: '设备类型'
},
{
@ -140,7 +148,8 @@
},
{
field: 'openPassword',
title: '开锁密码'
title: '开锁密码',
visible: false
},
{
title: '操作',

@ -11,7 +11,7 @@
<div class="form-group">
<label class="col-sm-4 control-label">设备编码:</label>
<div class="col-sm-8">
<input name="deviceCode" th:field="*{deviceCode}" class="form-control" type="text">
<input name="deviceCode" th:field="*{deviceCode}" class="form-control" type="text" required>
</div>
</div>
</div>
@ -23,6 +23,17 @@
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">设备类型:</label>
<div class="col-sm-8">
<select name="deviceType" class="form-control" th:field="*{deviceType}" th:with="type=${@baseTypeService.selectBaseTypeList(null)}">
<option th:each="dict : ${type}" th:text="${dict.deviceTypeName}" th:value="${dict.objId}"></option>
</select>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">使用状态:</label>
@ -51,20 +62,44 @@
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">开锁密码:</label>
<div class="col-sm-8">
<input name="openPassword" th:field="*{openPassword}" class="form-control" type="text">
</div>
</div>
</div>
<!-- <div class="col-xs-6">-->
<!-- <div class="form-group">-->
<!-- <label class="col-sm-4 control-label">开锁密码:</label>-->
<!-- <div class="col-sm-8">-->
<!-- <input name="openPassword" th:field="*{openPassword}" class="form-control" type="text">-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "device/base_info";
$("#form-base_info-edit").validate({
onkeyup: false,
rules: {
deviceCode: {
remote: {
url: prefix + "/checkDeviceCode",
type: "post",
dataType: "json",
data: {
"deviceCode": function() {
return $("input[name='deviceCode']").val();
},
"objId": function() {
return $("input[name='objId']").val();
}
}
}
}
},
messages: {
"deviceCode": {
remote: "设备编码已经存在"
}
},
focusCleanup: true
});

Loading…
Cancel
Save