视频设备管理接口
This commit is contained in:
parent
e6007ed667
commit
4f302cef20
|
|
@ -1,7 +1,64 @@
|
|||
package com.bonus.base.basic.controller;
|
||||
|
||||
import com.bonus.base.basic.domain.vo.DeviceVo;
|
||||
import com.bonus.base.basic.service.IDevService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
public class DevController {
|
||||
@Api(tags = "设备管理")
|
||||
@RestController
|
||||
@RequestMapping("/dev/")
|
||||
public class DevController extends BaseController {
|
||||
|
||||
@Resource(name = "IDevService")
|
||||
private IDevService service;
|
||||
|
||||
@ApiOperation(value = "查询设备数据")
|
||||
// @RequiresPermissions("basic:dev:list")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.QUERY, logType = 1,module = "设备管理->查询设备数据")
|
||||
@GetMapping("queryDevList")
|
||||
public TableDataInfo queryDevList(DeviceVo vo) {
|
||||
startPage();
|
||||
List<DeviceVo> list = service.queryDevList(vo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增设备")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:dev:add")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.INSERT, logType = 1,module = "设备管理->新增设备")
|
||||
@PostMapping("addDev")
|
||||
public AjaxResult addDev(@RequestBody DeviceVo vo) {
|
||||
return service.addDev(vo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改设备")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:dev:edit")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.UPDATE, logType = 1,module = "设备管理->修改设备")
|
||||
@PostMapping("editDev")
|
||||
public AjaxResult editDev(@RequestBody DeviceVo vo) {
|
||||
return service.editDev(vo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除设备")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:dev:del")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.UPDATE, logType = 1,module = "设备管理->删除设备")
|
||||
@PostMapping("delDev")
|
||||
public AjaxResult delDev(@RequestBody DeviceVo vo) {
|
||||
return service.delDev(vo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
package com.bonus.base.basic.controller;
|
||||
|
||||
import com.bonus.base.basic.domain.BmProject;
|
||||
import com.bonus.base.basic.domain.UnitVo;
|
||||
import com.bonus.base.basic.domain.vo.UnitVo;
|
||||
import com.bonus.base.basic.service.IUnitService;
|
||||
import com.bonus.base.common.annotation.PreventRepeatSubmit;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -26,7 +23,7 @@ import java.util.List;
|
|||
*/
|
||||
@Api(tags = "单位管理")
|
||||
@RestController
|
||||
@RequestMapping("/unit")
|
||||
@RequestMapping("/unit/")
|
||||
public class UnitController extends BaseController {
|
||||
|
||||
@Resource(name = "IUnitService")
|
||||
|
|
@ -35,7 +32,7 @@ public class UnitController extends BaseController {
|
|||
@ApiOperation(value = "查询单位数据")
|
||||
// @RequiresPermissions("basic:unit:list")
|
||||
@SysLog(title = "单位管理", businessType = OperaType.QUERY, logType = 1,module = "单位管理->查询单位数据")
|
||||
@GetMapping("/queryUnitList")
|
||||
@GetMapping("queryUnitList")
|
||||
public TableDataInfo queryUnitList(UnitVo vo) {
|
||||
startPage();
|
||||
List<UnitVo> list = service.queryUnitList(vo);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
package com.bonus.base.basic.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @className:DeviceVo
|
||||
* @author:cwchen
|
||||
* @date:2025-04-10-15:14
|
||||
* @version:1.0
|
||||
* @description:设备-vo
|
||||
*/
|
||||
@Data
|
||||
public class DeviceVo {
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String keyWord;
|
||||
|
||||
@NotBlank(message = "id不能为空", groups = {Edit.class, Del.class})
|
||||
private String id;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@NotBlank(message = "设备名称不能为空", groups = {Add.class, Edit.class})
|
||||
@Length(max = 255, message = "设备名称字符长度不能超过255", groups = {Add.class, Edit.class})
|
||||
private String devName;
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@NotBlank(message = "设备编码不能为空", groups = {Add.class, Edit.class})
|
||||
@Length(max = 64, message = "设备编码字符长度不能超过64", groups = {Add.class, Edit.class})
|
||||
private String macId;
|
||||
/**
|
||||
* 设备类型编码
|
||||
*/
|
||||
@NotBlank(message = "设备类型编码不能为空", groups = {Add.class, Edit.class})
|
||||
private String devTypeCode;
|
||||
/**
|
||||
* 设备类型名称
|
||||
*/
|
||||
@NotBlank(message = "设备类型名称不能为空", groups = {Add.class, Edit.class})
|
||||
private String devTypeName;
|
||||
/**
|
||||
* puid (固定式球机允许有多个)
|
||||
*/
|
||||
@NotBlank(message = "puid不能为空", groups = {Add.class, Edit.class})
|
||||
@Length(max = 64, message = "puid字符长度不能超过64", groups = {Add.class, Edit.class})
|
||||
private String puid;
|
||||
/**
|
||||
* 国标编码
|
||||
*/
|
||||
@Length(max = 64, message = "国标编码字符长度不能超过64", groups = {Add.class, Edit.class})
|
||||
private String gbCode;
|
||||
/**
|
||||
* 设备播放下标默认为0,多个为1,2,3.....
|
||||
*/
|
||||
@Min(value = 0, message = "设备播放下标不能小于0", groups = {Add.class, Edit.class})
|
||||
@Max(value = 11, message = "设备播放下标不能大于11", groups = {Add.class, Edit.class})
|
||||
private int playIdx;
|
||||
/**
|
||||
* 在线状态 0.不在线 1.在线
|
||||
*/
|
||||
private String onlineStatus;
|
||||
/**
|
||||
* 在线状态名称
|
||||
*/
|
||||
private String onlineStatusName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Length(max = 255, message = "备注字符长度不能超过255", groups = {Add.class, Edit.class})
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 新增条件限制
|
||||
*/
|
||||
public interface Add {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改条件限制
|
||||
*/
|
||||
public interface Edit {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除条件限制
|
||||
*/
|
||||
public interface Del {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.base.basic.domain;
|
||||
package com.bonus.base.basic.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
|
|
@ -17,6 +18,10 @@ import javax.validation.constraints.Pattern;
|
|||
@Data
|
||||
public class UnitVo {
|
||||
|
||||
/**关键字*/
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String keyWord;
|
||||
|
||||
@NotBlank(message = "id不能为空", groups = {Edit.class,Del.class})
|
||||
private String id;
|
||||
/**
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.bonus.base.basic.mapper;
|
||||
|
||||
import com.bonus.base.basic.domain.vo.DeviceVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:IDevMapper
|
||||
* @author:cwchen
|
||||
* @date:2025-04-10-14:28
|
||||
* @version:1.0
|
||||
* @description:设备管理-数据层
|
||||
*/
|
||||
@Repository(value = "IDevMapper")
|
||||
public interface IDevMapper {
|
||||
/**
|
||||
* 查询设备数据
|
||||
*
|
||||
* @param vo
|
||||
* @return List<DeviceVo>
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 15:24
|
||||
*/
|
||||
List<DeviceVo> queryDevList(DeviceVo vo);
|
||||
|
||||
/**
|
||||
* 查询数据是否重复
|
||||
*
|
||||
* @param vo
|
||||
* @param value
|
||||
* @param columnName
|
||||
* @return int
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 16:12
|
||||
*/
|
||||
int queryValueIsExist(@Param("params") DeviceVo vo, @Param("value") String value, @Param("columnName") String columnName);
|
||||
|
||||
/**
|
||||
* 1.新增/2.修改/3.删除设备
|
||||
*
|
||||
* @param vo
|
||||
* @param type
|
||||
* @return void
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 16:14
|
||||
*/
|
||||
void addOrUpdateDevice(@Param("params") DeviceVo vo, @Param("type") int type);
|
||||
|
||||
/**
|
||||
* 查询数据是否重复-共用同一个puid的视频设备
|
||||
*
|
||||
* @param vo
|
||||
* @param value
|
||||
* @param columnName
|
||||
* @return int
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 16:12
|
||||
*/
|
||||
int queryValueIsExist2(@Param("params") DeviceVo vo, @Param("value") String value, @Param("columnName") String columnName);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bonus.base.basic.mapper;
|
||||
|
||||
import com.bonus.base.basic.domain.UnitVo;
|
||||
import com.bonus.base.basic.domain.vo.UnitVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package com.bonus.base.basic.service;
|
||||
|
||||
import com.bonus.base.basic.domain.vo.DeviceVo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:IDevService
|
||||
* @author:cwchen
|
||||
* @date:2025-04-10-14:26
|
||||
* @version:1.0
|
||||
* @description:设备管理-业务层
|
||||
*/
|
||||
public interface IDevService {
|
||||
/**
|
||||
* 查询设备数据
|
||||
* @param vo
|
||||
* @return List<UnitVo>
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 15:14
|
||||
*/
|
||||
List<DeviceVo> queryDevList(DeviceVo vo);
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
* @param vo
|
||||
* @return AjaxResult
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 15:54
|
||||
*/
|
||||
AjaxResult addDev(DeviceVo vo);
|
||||
/**
|
||||
* 修改设备
|
||||
* @param vo
|
||||
* @return AjaxResult
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 15:54
|
||||
*/
|
||||
AjaxResult editDev(DeviceVo vo);
|
||||
/**
|
||||
* 删除设备
|
||||
* @param vo
|
||||
* @return AjaxResult
|
||||
* @author cwchen
|
||||
* @date 2025/4/10 15:54
|
||||
*/
|
||||
AjaxResult delDev(DeviceVo vo);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bonus.base.basic.service;
|
||||
|
||||
import com.bonus.base.basic.domain.UnitVo;
|
||||
import com.bonus.base.basic.domain.vo.UnitVo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
package com.bonus.base.basic.service.impl;
|
||||
|
||||
import com.bonus.base.basic.domain.vo.DeviceVo;
|
||||
import com.bonus.base.basic.mapper.IDevMapper;
|
||||
import com.bonus.base.basic.service.IDevService;
|
||||
import com.bonus.common.core.utils.uuid.IdUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.ValidatorsUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @className:DevServiceImpl
|
||||
* @author:cwchen
|
||||
* @date:2025-04-10-14:27
|
||||
* @version:1.0
|
||||
* @description:设备管理-业务逻辑层
|
||||
*/
|
||||
@Service(value = "IDevService")
|
||||
@Slf4j
|
||||
public class DevServiceImpl implements IDevService {
|
||||
|
||||
@Resource(name = "IDevMapper")
|
||||
private IDevMapper mapper;
|
||||
|
||||
@Resource(name = "ValidatorsUtils")
|
||||
private ValidatorsUtils validatorsUtils;
|
||||
|
||||
@Override
|
||||
public List<DeviceVo> queryDevList(DeviceVo vo) {
|
||||
try {
|
||||
List<DeviceVo> list = Optional.ofNullable(mapper.queryDevList(vo)).orElseGet(ArrayList::new);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
return new ArrayList<DeviceVo>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult addDev(DeviceVo vo) {
|
||||
try {
|
||||
// 校验必填数据
|
||||
String validResult = validatorsUtils.valid(vo, DeviceVo.Add.class);
|
||||
if (StringUtils.isNotBlank(validResult)) {
|
||||
return AjaxResult.error(validResult);
|
||||
}
|
||||
// 校验设备编码是否重复
|
||||
int flag = mapper.queryValueIsExist(vo,vo.getMacId(),"mac_id");
|
||||
if (flag > 0) return AjaxResult.error("设备编码已存在");
|
||||
// 校验puid是否重复
|
||||
if(vo.getDevTypeCode().contains("_1")){ // 可配置多个相同puid
|
||||
int flag2 = mapper.queryValueIsExist2(vo,vo.getPuid(),"puid");
|
||||
if (flag2 > 0) return AjaxResult.error("puid已存在或puid和播放索引已存在");
|
||||
}else{ // 只可配置一个puid
|
||||
int flag2 = mapper.queryValueIsExist(vo,vo.getPuid(),"puid");
|
||||
if (flag2 > 0) return AjaxResult.error("puid已存在");
|
||||
}
|
||||
vo.setId(IdUtils.simpleUUID());
|
||||
mapper.addOrUpdateDevice(vo,1);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult editDev(DeviceVo vo) {
|
||||
try {
|
||||
// 校验必填数据
|
||||
String validResult = validatorsUtils.valid(vo, DeviceVo.Edit.class);
|
||||
if (StringUtils.isNotBlank(validResult)) {
|
||||
return AjaxResult.error(validResult);
|
||||
}
|
||||
// 校验设备编码是否重复
|
||||
int flag = mapper.queryValueIsExist(vo,vo.getMacId(),"mac_id");
|
||||
if (flag > 0) return AjaxResult.error("设备编码已存在");
|
||||
// 校验puid是否重复
|
||||
if(vo.getDevTypeCode().contains("_1")){ // 可配置多个相同puid
|
||||
int flag2 = mapper.queryValueIsExist2(vo,vo.getPuid(),"puid");
|
||||
if (flag2 > 0) return AjaxResult.error("puid已存在或puid和播放索引已存在");
|
||||
}else{ // 只可配置一个puid
|
||||
int flag2 = mapper.queryValueIsExist(vo,vo.getPuid(),"puid");
|
||||
if (flag2 > 0) return AjaxResult.error("puid已存在");
|
||||
}
|
||||
mapper.addOrUpdateDevice(vo,2);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult delDev(DeviceVo vo) {
|
||||
try {
|
||||
// 校验必填数据
|
||||
String validResult = validatorsUtils.valid(vo, DeviceVo.Del.class);
|
||||
if (StringUtils.isNotBlank(validResult)) {
|
||||
return AjaxResult.error(validResult);
|
||||
}
|
||||
mapper.addOrUpdateDevice(vo,3);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bonus.base.basic.service.impl;
|
||||
|
||||
import com.bonus.base.basic.domain.UnitVo;
|
||||
import com.bonus.base.basic.domain.vo.UnitVo;
|
||||
import com.bonus.base.basic.mapper.IUnitMapper;
|
||||
import com.bonus.base.basic.service.IUnitService;
|
||||
import com.bonus.common.core.utils.uuid.IdUtils;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
<?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.bonus.base.basic.mapper.IDevMapper">
|
||||
<!--1.新增/2.修改/3.删除设备-->
|
||||
<insert id="addOrUpdateDevice">
|
||||
<if test="type == 1">
|
||||
INSERT INTO tt_device
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="params.id != null and params.id != ''">id,</if>
|
||||
<if test="params.devName != null and params.devName != ''">dev_name,</if>
|
||||
<if test="params.macId != null and params.macId != ''">mac_id,</if>
|
||||
<if test="params.devTypeCode != null and params.devTypeCode != ''">dev_type_code,</if>
|
||||
<if test="params.devTypeName != null and params.devTypeName!=''">dev_type_name,</if>
|
||||
<if test="params.puid != null and params.puid!=''">puid,</if>
|
||||
<if test="params.gbCode != null and params.gbCode!=''">gb_code,</if>
|
||||
<if test="params.playIdx != null">play_idx,</if>
|
||||
<if test="params.remark != null and params.remark!=''">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="params.id != null and params.id != ''">#{params.id},</if>
|
||||
<if test="params.devName != null and params.devName != ''">#{params.devName},</if>
|
||||
<if test="params.macId != null and params.macId != ''">#{params.macId},</if>
|
||||
<if test="params.devTypeCode != null and params.devTypeCode != ''">#{params.devTypeCode},</if>
|
||||
<if test="params.devTypeName != null and params.devTypeName!=''">#{params.devTypeName},</if>
|
||||
<if test="params.puid != null and params.puid!=''">#{params.puid},</if>
|
||||
<if test="params.gbCode != null and params.gbCode!=''">#{params.gbCode},</if>
|
||||
<if test="params.playIdx != null">#{params.playIdx},</if>
|
||||
<if test="params.remark != null and params.remark!=''">#{params.remark},</if>
|
||||
</trim>
|
||||
</if>
|
||||
<if test="type == 2">
|
||||
UPDATE tt_device
|
||||
<trim prefix="SET " suffixOverrides=",">
|
||||
dev_name = #{params.devName},
|
||||
mac_id = #{params.macId},
|
||||
dev_type_code = #{params.devTypeCode},
|
||||
dev_type_name = #{params.devTypeName},
|
||||
puid =#{params.puid},
|
||||
gb_code = #{params.gbCode},
|
||||
play_idx = #{params.playIdx},
|
||||
remark = #{params.remark}
|
||||
</trim>
|
||||
WHERE id = #{params.id}
|
||||
</if>
|
||||
<if test="type == 3">
|
||||
UPDATE tt_device SET is_active = '0' WHERE id = #{params.id}
|
||||
</if>
|
||||
</insert>
|
||||
|
||||
<!--查询字段是否重复-->
|
||||
<select id="queryValueIsExist" resultType="java.lang.Integer">
|
||||
<if test="params.id==null or params.id==''">
|
||||
SELECT COUNT(1)
|
||||
FROM tt_device
|
||||
WHERE ${columnName} = #{value} AND is_active = '1'
|
||||
</if>
|
||||
<if test="params.id!=null and params.id!=''">
|
||||
SELECT COUNT(1)
|
||||
FROM tt_device
|
||||
WHERE ${columnName} = #{value} AND id != #{params.id} AND is_active = '1'
|
||||
</if>
|
||||
</select>
|
||||
<!--查询设备数据-->
|
||||
<select id="queryDevList" resultType="com.bonus.base.basic.domain.vo.DeviceVo">
|
||||
SELECT td.id,
|
||||
td.dev_name AS unitName,
|
||||
td.mac_id AS macId,
|
||||
td.dev_type_code AS devTypeCode,
|
||||
sdd.dict_label AS devTypeName,
|
||||
td.puid AS puid,
|
||||
td.gb_code AS gbCode,
|
||||
td.play_idx AS playIdx,
|
||||
td.online_status AS onlineStatus,
|
||||
IF(td.online_status = '1','在线','离线') AS onlineStatusName,
|
||||
td.create_time AS createTime,
|
||||
td.update_time AS updateTime,
|
||||
td.remark
|
||||
FROM tt_device td
|
||||
LEFT JOIN sys_dict_data sdd ON td.dev_type_code = sdd.dict_value AND sdd.dict_type = 'video_device'
|
||||
<where>
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
AND (
|
||||
INSTR(td.dev_name,#{keyWord}) > 0 OR
|
||||
INSTR(td.mac_id,#{keyWord}) > 0
|
||||
)
|
||||
</if>
|
||||
<if test="onlineStatus!=null and onlineStatus!=''">
|
||||
AND td.online_status = #{onlineStatus}
|
||||
</if>
|
||||
<if test="devTypeCode!=null and devTypeCode!=''">
|
||||
AND td.dev_type_code = #{devTypeCode}
|
||||
</if>
|
||||
AND td.is_active = '1'
|
||||
</where>
|
||||
</select>
|
||||
<!--查询数据是否重复-共用同一个puid的视频设备-->
|
||||
<select id="queryValueIsExist2" resultType="java.lang.Integer">
|
||||
<if test="params.id==null or params.id==''">
|
||||
SELECT COUNT(1)
|
||||
FROM tt_device
|
||||
WHERE (
|
||||
(${columnName} = #{value} AND INSTR(dev_type_code,'_0') > 0) OR
|
||||
(${columnName} = #{value} AND play_idx = #{params.playIdx} AND INSTR(dev_type_code,'_1') > 0)
|
||||
) AND is_active = '1'
|
||||
</if>
|
||||
<if test="params.id!=null and params.id!=''">
|
||||
SELECT COUNT(1)
|
||||
FROM tt_device
|
||||
WHERE (
|
||||
(${columnName} = #{value} AND INSTR(dev_type_code,'_0') > 0) OR
|
||||
(${columnName} = #{value} AND play_idx = #{params.playIdx} AND id!=#{params.id} AND
|
||||
INSTR(dev_type_code,'_1') > 0)
|
||||
) AND is_active = '1'
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.base.basic.mapper.IUnitMapper">
|
||||
<!--1.新增/2.修改/3.删除单位-->
|
||||
<insert id="addOrUpdateUnit">
|
||||
<if test="type == 1">
|
||||
INSERT INTO tt_sys_unit
|
||||
|
|
@ -58,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</insert>
|
||||
|
||||
<!--查询单位数据-->
|
||||
<select id="queryUnitList" resultType="com.bonus.base.basic.domain.UnitVo">
|
||||
<select id="queryUnitList" resultType="com.bonus.base.basic.domain.vo.UnitVo">
|
||||
SELECT id,
|
||||
unit_name AS unitName,
|
||||
unit_type AS unitType,
|
||||
|
|
@ -73,6 +74,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
register AS register
|
||||
FROM tt_sys_unit
|
||||
<where>
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
AND (
|
||||
INSTR(unit_name,#{keyWord}) > 0 OR
|
||||
INSTR(unit_code,#{keyWord}) > 0 OR
|
||||
INSTR(unit_user,#{keyWord}) > 0 OR
|
||||
INSTR(unit_phone,#{keyWord}) > 0 OR
|
||||
INSTR(suff_user,#{keyWord}) > 0 OR
|
||||
INSTR(suff_phone,#{keyWord}) > 0
|
||||
)
|
||||
</if>
|
||||
AND is_active = '1'
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue