初始化提交
This commit is contained in:
parent
1956337ff2
commit
f525ac3511
|
|
@ -0,0 +1,39 @@
|
|||
package com.bonus.common.core.utils;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
public class IDUtils {
|
||||
private static final byte[] LOCK = new byte[0];
|
||||
|
||||
// 位数,默认是8位
|
||||
private final static long W = 100000000;
|
||||
|
||||
/**
|
||||
* 传入文件 名称
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
public static String getSuffix(String fileName){
|
||||
return fileName.substring(fileName.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.err.println(createId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取id
|
||||
* @return
|
||||
*/
|
||||
public static String createId() {
|
||||
long r = 0;
|
||||
synchronized (LOCK) {
|
||||
r = (long) ((Math.random() + 1) * W);
|
||||
}
|
||||
|
||||
return System.currentTimeMillis() + String.valueOf(r).substring(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.bonus.base.basic.controller;
|
||||
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Api(tags = "施工信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/constInfo")
|
||||
public class ConstInfoController extends BaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package com.bonus.base.basic.controller;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
public class DevController {
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.bonus.base.basic.controller;
|
||||
|
||||
import com.bonus.base.basic.domain.BmProjectWorksite;
|
||||
import com.bonus.base.basic.domain.DeviceAttrVo;
|
||||
import com.bonus.base.basic.domain.DeviceVo;
|
||||
import com.bonus.base.basic.service.DeviceService;
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Api(tags = "工程项目管理接口")
|
||||
@RestController
|
||||
@RequestMapping("/bm_project")
|
||||
public class DeviceController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private DeviceService service;
|
||||
|
||||
/**
|
||||
* 查询作业现场列表
|
||||
*/
|
||||
@ApiOperation(value = "查询感知设备信息列表")
|
||||
@RequiresPermissions("tb:device:list")
|
||||
@GetMapping("/list")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.INSERT, logType = 1,module = "设备管理->查询感知设备信息列表")
|
||||
public TableDataInfo getPageList(DeviceVo deviceVo) {
|
||||
startPage();
|
||||
List<DeviceVo> list = service.getPageList(deviceVo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询作业现场列表
|
||||
*/
|
||||
@ApiOperation(value = "查询感知设备属性信息")
|
||||
@RequiresPermissions("tb:device:attr")
|
||||
@GetMapping("/list")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.INSERT, logType = 1,module = "设备管理->查询设备属性")
|
||||
public TableDataInfo getAttrPageList(DeviceAttrVo vo) {
|
||||
startPage();
|
||||
List<DeviceAttrVo> list = service.getAttrPageList(vo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ApiOperation(value = "新增设备管理")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("tb:device:add")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.INSERT, logType = 1,module = "设备管理->新增感知设备")
|
||||
@PostMapping
|
||||
public AjaxResult addDevice(@RequestBody DeviceVo deviceVo) {
|
||||
return service.addDevice(deviceVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增设备管理")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("tb:attr:add")
|
||||
@SysLog(title = "设备管理", businessType = OperaType.INSERT, logType = 1,module = "设备管理->新增设备属性")
|
||||
@PostMapping
|
||||
public AjaxResult addDeviceAttr(@RequestBody DeviceAttrVo vo) {
|
||||
return service.addDeviceAttr(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.bonus.base.basic.controller;
|
||||
|
||||
import com.bonus.base.basic.domain.DeviceTypeVo;
|
||||
import com.bonus.base.basic.domain.DeviceVo;
|
||||
import com.bonus.base.basic.service.DeviceTypeService;
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Api(tags = "设备类型控制层管理")
|
||||
@RestController
|
||||
@RequestMapping("/devType")
|
||||
public class DeviceTypeController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private DeviceTypeService service;
|
||||
/**
|
||||
* 查询作业现场列表
|
||||
*/
|
||||
@ApiOperation(value = "查询设备类型")
|
||||
@RequiresPermissions("tb:type:list")
|
||||
@GetMapping("/list")
|
||||
@SysLog(title = "设备类型管理", businessType = OperaType.QUERY, logType = 1,module = "设备类型管理->查询设备类型")
|
||||
public TableDataInfo getPageList(DeviceTypeVo vo) {
|
||||
startPage();
|
||||
List<DeviceTypeVo> list = service.getPageList(vo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "新增设备类型")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("tb:type:add")
|
||||
@SysLog(title = "设备类型管理", businessType = OperaType.INSERT, logType = 1,module = "设备类型管理->新增设备类型")
|
||||
@PostMapping
|
||||
public AjaxResult insertData(@RequestBody DeviceTypeVo vo) {
|
||||
return service.insertData(vo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "修改设备类型")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("tb:type:update")
|
||||
@SysLog(title = "设备类型管理", businessType = OperaType.UPDATE, logType = 1,module = "设备类型管理->修改设备类型")
|
||||
@PostMapping
|
||||
public AjaxResult updateData(@RequestBody DeviceTypeVo vo) {
|
||||
return service.updateData(vo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "删除设备类型")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("tb:type:del")
|
||||
@SysLog(title = "设备类型管理", businessType = OperaType.UPDATE, logType = 1,module = "设备类型管理->删除设备类型")
|
||||
@PostMapping
|
||||
public AjaxResult deleteData(@RequestBody DeviceTypeVo vo) {
|
||||
return service.deleteData(vo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.bonus.base.basic.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.naming.ldap.PagedResultsControl;
|
||||
|
||||
/**
|
||||
* 设备属性信息集合
|
||||
* @author 黑子
|
||||
*/
|
||||
@Data
|
||||
public class DeviceAttrVo {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private String devId;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String devName;
|
||||
/**
|
||||
* 属性id
|
||||
*/
|
||||
private String attrName;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String attrUnit;
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private String attrValue;
|
||||
/**
|
||||
* 阈值max
|
||||
*/
|
||||
private String maxValue;
|
||||
/**
|
||||
* 阈值max
|
||||
*/
|
||||
private String minValue;
|
||||
/**
|
||||
* 变化值
|
||||
*/
|
||||
private String changeVal;
|
||||
/**
|
||||
* 是否告警
|
||||
*/
|
||||
private String isWarn;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* 采集时间
|
||||
*/
|
||||
private String updateTime;
|
||||
/**
|
||||
* 级联编码
|
||||
*/
|
||||
private String relCode;
|
||||
/**
|
||||
* 数据了下
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.bonus.base.basic.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Data
|
||||
public class DeviceTypeVo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String typeCode;
|
||||
|
||||
private String typeName;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String createTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.bonus.base.basic.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Data
|
||||
public class DeviceVo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String devName;
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String devCode;
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String devType;
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String typeCode;
|
||||
/**
|
||||
* 级联编码
|
||||
*/
|
||||
private String relCode;
|
||||
/**
|
||||
* 设备状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 边带id
|
||||
*/
|
||||
private String bdId;
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private String areaId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
private String updateTime;
|
||||
/**
|
||||
* 删除状态
|
||||
*/
|
||||
private String delFlag;
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
private String keyWord;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bonus.base.basic.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Mapper
|
||||
public interface ConstInfoMapper {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.bonus.base.basic.mapper;
|
||||
|
||||
import com.bonus.base.basic.domain.DeviceAttrVo;
|
||||
import com.bonus.base.basic.domain.DeviceVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceMapper {
|
||||
|
||||
/**
|
||||
* 分页查询 感知设备
|
||||
* @param deviceVo
|
||||
* @return
|
||||
*/
|
||||
List<DeviceVo> getPageList(DeviceVo deviceVo);
|
||||
|
||||
/**
|
||||
* 查询设备属性值数据
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
List<DeviceAttrVo> getAttrPageList(DeviceAttrVo vo);
|
||||
|
||||
int getDevNumByRelCode(@Param("param") DeviceVo deviceVo,@Param("type") String number);
|
||||
|
||||
/**
|
||||
* 新增设备信息
|
||||
* @param deviceVo
|
||||
* @return
|
||||
*/
|
||||
int insertDevice(DeviceVo deviceVo);
|
||||
|
||||
/**
|
||||
* 查询 属性编码是否重复
|
||||
* @param vo
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
int getDevAttrNumByRelCode(@Param("param")DeviceAttrVo vo,@Param("type") String number);
|
||||
|
||||
/**
|
||||
* 新增设备属性成功
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
int insertDeviceAttr(DeviceAttrVo vo);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.bonus.base.basic.mapper;
|
||||
|
||||
import com.bonus.base.basic.domain.DeviceTypeVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
* 设备类型 数据层
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceTypeMapper {
|
||||
/**
|
||||
* 分页查询 设备类型 管理
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
List<DeviceTypeVo> getPageList(DeviceTypeVo vo);
|
||||
|
||||
int getDataInfo(@Param("param") DeviceTypeVo vo,@Param("type") String number);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
int insertData(DeviceTypeVo vo);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
int updateData(DeviceTypeVo vo);
|
||||
|
||||
/**
|
||||
* 查询设备类型是否被使用
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
int getTypeUsed(DeviceTypeVo vo);
|
||||
|
||||
/**
|
||||
* 删除设备类型
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
int deleteData(DeviceTypeVo vo);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.bonus.base.basic.service;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
public interface ConstInfoService {
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.bonus.base.basic.service;
|
||||
|
||||
import com.bonus.base.basic.domain.DeviceAttrVo;
|
||||
import com.bonus.base.basic.domain.DeviceVo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
public interface DeviceService {
|
||||
|
||||
/**
|
||||
* 设备管理查询
|
||||
* @param deviceVo
|
||||
* @return
|
||||
*/
|
||||
List<DeviceVo> getPageList(DeviceVo deviceVo);
|
||||
|
||||
/**
|
||||
* 设备属性分页查询
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
List<DeviceAttrVo> getAttrPageList(DeviceAttrVo vo);
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
* @param deviceVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult addDevice(DeviceVo deviceVo);
|
||||
|
||||
/**
|
||||
* 新增感知设备属性
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult addDeviceAttr(DeviceAttrVo vo);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.bonus.base.basic.service;
|
||||
|
||||
import com.bonus.base.basic.domain.DeviceTypeVo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
* 设备类型管理业务层
|
||||
*/
|
||||
public interface DeviceTypeService {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param deviceVo
|
||||
* @return
|
||||
*/
|
||||
List<DeviceTypeVo> getPageList(DeviceTypeVo deviceVo);
|
||||
|
||||
/**
|
||||
* 新增设备类型
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult insertData(DeviceTypeVo vo);
|
||||
|
||||
/**
|
||||
* 修改设备类型
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult updateData(DeviceTypeVo vo);
|
||||
|
||||
/**
|
||||
* 删除设备类型
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult deleteData(DeviceTypeVo vo);
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.bonus.base.basic.service.impl;
|
||||
|
||||
import com.bonus.base.basic.service.ConstInfoService;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ConstInfoServiceImpl implements ConstInfoService {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
package com.bonus.base.basic.service.impl;
|
||||
|
||||
import com.bonus.base.basic.domain.DeviceAttrVo;
|
||||
import com.bonus.base.basic.domain.DeviceVo;
|
||||
import com.bonus.base.basic.mapper.DeviceMapper;
|
||||
import com.bonus.base.basic.service.DeviceService;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.hibernate.validator.internal.util.StringHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
@Autowired
|
||||
private DeviceMapper mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param deviceVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceVo> getPageList(DeviceVo deviceVo) {
|
||||
List<DeviceVo> list=new ArrayList<>();
|
||||
try{
|
||||
list= mapper.getPageList(deviceVo);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceAttrVo> getAttrPageList(DeviceAttrVo vo) {
|
||||
List<DeviceAttrVo> list=new ArrayList<>();
|
||||
try{
|
||||
list= mapper.getAttrPageList(vo);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
* @param deviceVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult addDevice(DeviceVo deviceVo) {
|
||||
try{
|
||||
if(StringHelper.isNullOrEmptyString(deviceVo.getDevName())){
|
||||
return AjaxResult.error("请填写设备名称");
|
||||
}
|
||||
if(StringHelper.isNullOrEmptyString(deviceVo.getDevType())){
|
||||
return AjaxResult.error("请选择设备类型");
|
||||
}
|
||||
|
||||
if(StringHelper.isNullOrEmptyString(deviceVo.getDevCode())){
|
||||
return AjaxResult.error("请填写设备编码");
|
||||
}
|
||||
if(!StringHelper.isNullOrEmptyString(deviceVo.getRelCode())){
|
||||
int num =mapper.getDevNumByRelCode(deviceVo,"1");
|
||||
if(num>0){
|
||||
return AjaxResult.error("级联编码已存在");
|
||||
}
|
||||
}
|
||||
int num =mapper.getDevNumByRelCode(deviceVo,"2");
|
||||
if(num>0){
|
||||
return AjaxResult.error("设备编码已存在");
|
||||
}
|
||||
|
||||
num =mapper.getDevNumByRelCode(deviceVo,"3");
|
||||
if(num>0){
|
||||
return AjaxResult.error("设备名称已存在");
|
||||
}
|
||||
int success=mapper.insertDevice(deviceVo);
|
||||
if(success>0 ){
|
||||
return AjaxResult.success("新增成功");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("系统异常,新增失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备属性
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult addDeviceAttr(DeviceAttrVo vo) {
|
||||
try{
|
||||
if(StringHelper.isNullOrEmptyString(vo.getDevId())){
|
||||
return AjaxResult.error("请选择设备");
|
||||
}
|
||||
if(StringHelper.isNullOrEmptyString(vo.getAttrName())){
|
||||
return AjaxResult.error("请填写属性名称");
|
||||
}
|
||||
if(!StringHelper.isNullOrEmptyString(vo.getRelCode())){
|
||||
int num =mapper.getDevAttrNumByRelCode(vo,"1");
|
||||
if(num>0){
|
||||
return AjaxResult.error("级联编码已存在");
|
||||
}
|
||||
}
|
||||
int num =mapper.getDevAttrNumByRelCode(vo,"2");
|
||||
if(num>0){
|
||||
return AjaxResult.error("属性名称已存在");
|
||||
}
|
||||
int success=mapper.insertDeviceAttr(vo);
|
||||
if(success>0 ){
|
||||
return AjaxResult.success("新增成功");
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
||||
return AjaxResult.error("系统异常,新增失败");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package com.bonus.base.basic.service.impl;
|
||||
|
||||
import com.bonus.base.basic.domain.DeviceTypeVo;
|
||||
import com.bonus.base.basic.mapper.DeviceTypeMapper;
|
||||
import com.bonus.base.basic.service.DeviceTypeService;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.IDUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备类型管理 接口层
|
||||
* @author 黑子
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DeviceTypeServiceImpl implements DeviceTypeService {
|
||||
|
||||
@Autowired
|
||||
private DeviceTypeMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<DeviceTypeVo> getPageList(DeviceTypeVo vo) {
|
||||
List<DeviceTypeVo> list=new ArrayList<>();
|
||||
try{
|
||||
list=mapper.getPageList(vo);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备类型
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult insertData(DeviceTypeVo vo) {
|
||||
try{
|
||||
int num=mapper.getDataInfo(vo,"1");
|
||||
if(num>0){
|
||||
return AjaxResult.error("设备类型已存在");
|
||||
}
|
||||
num=mapper.getDataInfo(vo,"2");
|
||||
if(num>0){
|
||||
return AjaxResult.error("设备类型编码已存在");
|
||||
}
|
||||
vo.setId(IDUtils.createId());
|
||||
vo.setCreateTime(DateUtils.getTime());
|
||||
num=mapper.insertData(vo);
|
||||
if(num>0){
|
||||
return AjaxResult.success("添加成功");
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("添加失败,系统异常");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult updateData(DeviceTypeVo vo) {
|
||||
try{
|
||||
int num=mapper.getDataInfo(vo,"1");
|
||||
if(num>0){
|
||||
return AjaxResult.error("设备类型已存在");
|
||||
}
|
||||
num=mapper.getDataInfo(vo,"2");
|
||||
if(num>0){
|
||||
return AjaxResult.error("设备类型编码已存在");
|
||||
}
|
||||
num=mapper.updateData(vo);
|
||||
if(num>0){
|
||||
return AjaxResult.success("修改成功");
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("修改失败,系统异常");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult deleteData(DeviceTypeVo vo) {
|
||||
try{
|
||||
int num=mapper.getTypeUsed(vo);
|
||||
if(num>0){
|
||||
return AjaxResult.error("该设备类型下存在设备不允许删除");
|
||||
}
|
||||
num=mapper.deleteData(vo);
|
||||
if(num>0){
|
||||
return AjaxResult.success("修改成功");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("删除失败,系统异常");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?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.ConstInfoMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<?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.DeviceMapper">
|
||||
<insert id="insertDevice">
|
||||
insert into tb_device(
|
||||
dev_name,dev_code, dev_type,type_code, rel_code,
|
||||
status, bd_id,area_id,create_time,update_time,del_flag
|
||||
)values (#{devName},#{devCode},#{devType},#{typeCode},#{relCode},#{status},#{bdId}
|
||||
#{areaId},now(),now(),0)
|
||||
</insert>
|
||||
<insert id="insertDeviceAttr">
|
||||
insert into tb_device_attr(
|
||||
id, dev_id, att_name, att_value, att_unit,create_time,update_time, rel_code, change_val,
|
||||
is_warn, max_value,min_value, data_type
|
||||
)values (#{devId},#{attrName},#{attrValue},#{attrUnit},now(),now(),#{relCode},#{changeVal},
|
||||
#{isWarn},#{maxValue},#{minValue},#{dataType}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getPageList" resultType="com.bonus.base.basic.domain.DeviceVo">
|
||||
select td.id,td.dev_name devName , td.dev_code devCode, td.dev_type devType, td.type_code typeCode, td.rel_code relCode, td.status,
|
||||
td.bd_id bdId, td.area_id areaId, td.create_time createTime, td.update_time updateTime
|
||||
FROM tb_device td
|
||||
WHERE td.del_flag=0
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
and (
|
||||
td.dev_name LIKE concat('%',#{keyWord},'%') or
|
||||
td.dev_code LIKE concat('%',#{keyWord},'%') or
|
||||
td.rel_code LIKE concat('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="status!=null and status!=''">
|
||||
and td.status=#{status}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getAttrPageList" resultType="com.bonus.base.basic.domain.DeviceAttrVo">
|
||||
select tda.id,tda.dev_id devId,tda.att_name attrName,tda.att_value attrValue,tda.att_unit attrUnit,
|
||||
tda.create_time createTime,tda.update_time updateTime,tda.rel_code relCode,tda.change_val changeVal,
|
||||
tda.is_warn isWarn,tda.max_value maxValue,tda.min_value minValue,tda.data_type dataType
|
||||
from tb_device_attr tda
|
||||
WHERE tda.dev_id=#{devId}
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
and (
|
||||
tda.att_name LIKE concat('%',#{keyWord},'%') or
|
||||
tda.data_type LIKE concat('%',#{keyWord},'%') or
|
||||
tda.rel_code LIKE concat('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
<select id="getDevNumByRelCode" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from tb_device td where td.del_flag=0
|
||||
<if test="param.id!=null and param.id!=''">
|
||||
and td.id!=#{param.id}
|
||||
</if>
|
||||
<if test='type=="1"'>
|
||||
and td.rel_code=#{param.relCode}
|
||||
</if>
|
||||
<if test='type=="2"'>
|
||||
and td.dev_code=#{param.devCode}
|
||||
</if>
|
||||
<if test='type=="3"'>
|
||||
and td.dev_name=#{param.devName}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getDevAttrNumByRelCode" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from tb_device_attr tda
|
||||
WHERE tda.dev_id=#{devId}
|
||||
<if test="param.id!=null and param.id!=''">
|
||||
and tda.id!=#{param.id}
|
||||
</if>
|
||||
<if test='type=="1"'>
|
||||
and tda.rel_code=#{param.relCode}
|
||||
</if>
|
||||
<if test='type=="2"'>
|
||||
and tda.att_name=#{param.attrName}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?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.DeviceTypeMapper">
|
||||
|
||||
<insert id="insertData">
|
||||
insert into tb_dev_type (id, type_name, type_code, remark,create_time,
|
||||
update_time, del_flag)values (#{id},#{typeName},#{typeCode},#{remark},#{createTime},now(),0)
|
||||
</insert>
|
||||
<update id="updateData">
|
||||
update tb_dev_type set
|
||||
type_name=#{typeName},
|
||||
type_code=#{typeCode},
|
||||
remark=#{remark}
|
||||
where id=#{id}
|
||||
</update>
|
||||
<update id="deleteData">
|
||||
update tb_dev_type set del_flag=1
|
||||
where id=#{id}
|
||||
</update>
|
||||
<select id="getPageList" resultType="com.bonus.base.basic.domain.DeviceTypeVo">
|
||||
select id,type_name typeName,type_code typeCode,remark
|
||||
from tb_dev_type
|
||||
where del_flag=0
|
||||
<if test="typeCode!=null and typeCode!=''">
|
||||
and type_code like concat('%',#{typeCode},'%')
|
||||
</if>
|
||||
<if test="typeName!=null and typeName!=''">
|
||||
and type_name like concat('%',#{typeName},'%')
|
||||
</if>
|
||||
</select>
|
||||
<select id="getDataInfo" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from tb_dev_type
|
||||
<where>
|
||||
<if test="param.id!=null and param.id!=''">
|
||||
and id!={param.id}
|
||||
</if>
|
||||
<if test='type=="1"'>
|
||||
and type_name=#{param.typeName}
|
||||
</if>
|
||||
<if test='type=="2"'>
|
||||
and type_code=#{param.typeCode}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
</select>
|
||||
<select id="getTypeUsed" resultType="java.lang.Integer">
|
||||
SELECT sum(num) num
|
||||
from(
|
||||
select count(1) num
|
||||
from tb_collect_device
|
||||
where del_flag=0 AND dev_type_id=#{id}
|
||||
UNION ALL
|
||||
select count(1)
|
||||
from tb_const_info
|
||||
where del_flag=0 AND type_id=#{id}
|
||||
)b
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue