首页接口
This commit is contained in:
parent
94533eff7c
commit
3f112396d1
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.aqd.base.controller;
|
package com.bonus.aqd.base.controller;
|
||||||
|
|
||||||
import com.bonus.aqd.base.entity.dto.ParamsDto;
|
import com.bonus.aqd.base.entity.dto.ParamsDto;
|
||||||
|
import com.bonus.aqd.base.entity.vo.DeviceInfoVo;
|
||||||
import com.bonus.aqd.base.service.IndexService;
|
import com.bonus.aqd.base.service.IndexService;
|
||||||
import com.bonus.aqd.manager.annotation.DecryptAndVerify;
|
import com.bonus.aqd.manager.annotation.DecryptAndVerify;
|
||||||
import com.bonus.aqd.manager.core.entity.EncryptedReq;
|
import com.bonus.aqd.manager.core.entity.EncryptedReq;
|
||||||
|
|
@ -30,6 +31,7 @@ public class IndexController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全带设备列表
|
* 安全带设备列表
|
||||||
|
*
|
||||||
* @param dto
|
* @param dto
|
||||||
* @return ServerResponse
|
* @return ServerResponse
|
||||||
* @author cwchen
|
* @author cwchen
|
||||||
|
|
@ -40,4 +42,73 @@ public class IndexController {
|
||||||
public ServerResponse getDevicesInfo(EncryptedReq<ParamsDto> dto) {
|
public ServerResponse getDevicesInfo(EncryptedReq<ParamsDto> dto) {
|
||||||
return service.getDevicesInfo(dto.getData());
|
return service.getDevicesInfo(dto.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:36
|
||||||
|
*/
|
||||||
|
@PostMapping("addDevice")
|
||||||
|
@DecryptAndVerify(decryptedClass = DeviceInfoVo.class)
|
||||||
|
public ServerResponse addDevice(EncryptedReq<DeviceInfoVo> dto) {
|
||||||
|
return service.addDevice(dto.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:55
|
||||||
|
*/
|
||||||
|
@PostMapping("editDevice")
|
||||||
|
@DecryptAndVerify(decryptedClass = DeviceInfoVo.class)
|
||||||
|
public ServerResponse editDevice(EncryptedReq<DeviceInfoVo> dto) {
|
||||||
|
return service.editDevice(dto.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备详情
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:55
|
||||||
|
*/
|
||||||
|
@PostMapping("getDeviceInfo")
|
||||||
|
@DecryptAndVerify(decryptedClass = ParamsDto.class)
|
||||||
|
public ServerResponse getDeviceInfo(EncryptedReq<ParamsDto> dto) {
|
||||||
|
return service.getDeviceInfo(dto.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:55
|
||||||
|
*/
|
||||||
|
@PostMapping("delDevice")
|
||||||
|
@DecryptAndVerify(decryptedClass = ParamsDto.class)
|
||||||
|
public ServerResponse delDevice(EncryptedReq<ParamsDto> dto) {
|
||||||
|
return service.delDevice(dto.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备分析
|
||||||
|
* @param dto
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 16:41
|
||||||
|
*/
|
||||||
|
@PostMapping("deviceAnalysis")
|
||||||
|
@DecryptAndVerify(decryptedClass = ParamsDto.class)
|
||||||
|
public ServerResponse deviceAnalysis(EncryptedReq<ParamsDto> dto) {
|
||||||
|
return service.deviceAnalysis(dto.getData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,80 @@ import java.util.List;
|
||||||
public interface IndexMapper {
|
public interface IndexMapper {
|
||||||
/**
|
/**
|
||||||
* 安全带设备列表
|
* 安全带设备列表
|
||||||
|
*
|
||||||
* @param dto
|
* @param dto
|
||||||
* @return List<DeviceInfoVo>
|
* @return List<DeviceInfoVo>
|
||||||
* @author cwchen
|
* @author cwchen
|
||||||
* @date 2024/7/29 14:37
|
* @date 2024/7/29 14:37
|
||||||
*/
|
*/
|
||||||
List<DeviceInfoVo> getDevicesInfo(ParamsDto dto);
|
List<DeviceInfoVo> getDevicesInfo(ParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备编码是否重复
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return int
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:43
|
||||||
|
*/
|
||||||
|
int devCodeIsExist(DeviceInfoVo vo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return void
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:44
|
||||||
|
*/
|
||||||
|
void addDevice(DeviceInfoVo vo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return void
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:51
|
||||||
|
*/
|
||||||
|
void editDevice(DeviceInfoVo vo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备详情
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return DeviceInfolVo
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:57
|
||||||
|
*/
|
||||||
|
DeviceInfoVo getDeviceInfo(ParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return void
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 16:00
|
||||||
|
*/
|
||||||
|
void delDevice(ParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备状态数量
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return List<Integer>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 17:01
|
||||||
|
*/
|
||||||
|
List<Integer> getDeviceStatusNum(ParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当天、本周、本月 单钩、双钩告警数量
|
||||||
|
* @param dto
|
||||||
|
* @return List<Integer>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 17:45
|
||||||
|
*/
|
||||||
|
List<Integer> getWarnNum(ParamsDto dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,16 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ParamsDto {
|
public class ParamsDto {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String nowDate;
|
||||||
|
|
||||||
|
private String startWeekTime;
|
||||||
|
|
||||||
|
private String endWeekTime;
|
||||||
|
|
||||||
|
private String startMonthTime;
|
||||||
|
|
||||||
|
private String endMonthTime;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.bonus.aqd.base.entity.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:DeviceAnalysisVo
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2024-07-29-16:43
|
||||||
|
* @version:1.0
|
||||||
|
* @description:设备分析-vo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceAnalysisVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备总数
|
||||||
|
*/
|
||||||
|
private int totalDeviceNum;
|
||||||
|
/**
|
||||||
|
* 在线总数
|
||||||
|
*/
|
||||||
|
private int onlineDeviceNum;
|
||||||
|
/**
|
||||||
|
* 离线设备
|
||||||
|
*/
|
||||||
|
private int offlineDeviceNum;
|
||||||
|
/**
|
||||||
|
* 单钩松动报警次数-天
|
||||||
|
*/
|
||||||
|
private int oneLoosenDayWarnNum;
|
||||||
|
/**
|
||||||
|
* 双钩松动报警次数-天
|
||||||
|
*/
|
||||||
|
private int twoLoosenDayWarnNum;
|
||||||
|
/**
|
||||||
|
* 单钩松动报警次数-周
|
||||||
|
*/
|
||||||
|
private int oneLoosenWeekWarnNum;
|
||||||
|
/**
|
||||||
|
* 双钩松动报警次数-周
|
||||||
|
*/
|
||||||
|
private int twoLoosenWeekWarnNum;
|
||||||
|
/**
|
||||||
|
* 单钩松动报警次数-月
|
||||||
|
*/
|
||||||
|
private int oneLoosenMonthWarnNum;
|
||||||
|
/**
|
||||||
|
* 单钩松动报警次数-月
|
||||||
|
*/
|
||||||
|
private int twoLoosenMonthWarnNum;
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,9 @@ package com.bonus.aqd.base.entity.vo;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -23,26 +25,34 @@ public class DeviceInfoVo {
|
||||||
/**
|
/**
|
||||||
* 设备名称
|
* 设备名称
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "设备名称不能为空", groups = {Query.class})
|
||||||
|
@Length(max = 255, message = "设备名称字符长度不能超过255", groups = {Query.class})
|
||||||
private String devName;
|
private String devName;
|
||||||
/**
|
/**
|
||||||
* 设备编码
|
* 设备编码
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "设备编码不能为空", groups = {Query.class})
|
||||||
|
@Length(max = 255, message = "设备编码字符长度不能超过255", groups = {Query.class})
|
||||||
private String devCode;
|
private String devCode;
|
||||||
/**
|
/**
|
||||||
* 设备型号
|
* 设备型号
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "设备型号不能为空", groups = {Query.class})
|
||||||
|
@Length(max = 255, message = "设备型号字符长度不能超过255", groups = {Query.class})
|
||||||
private String devModu;
|
private String devModu;
|
||||||
/**
|
/**
|
||||||
* A钩状态 0脱落 1正常
|
* A钩状态 0脱落 1正常
|
||||||
*/
|
*/
|
||||||
private Integer devA;
|
private Integer devA = 1;
|
||||||
/**
|
/**
|
||||||
* B钩状态 0脱落 1正常
|
* B钩状态 0脱落 1正常
|
||||||
*/
|
*/
|
||||||
private Integer devB;
|
private Integer devB = 1;
|
||||||
/**
|
/**
|
||||||
* 球机设备编码
|
* 球机设备编码
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "球机编码不能为空", groups = {Query.class})
|
||||||
|
@Length(max = 32, message = "球机编码字符长度不能超过32", groups = {Query.class})
|
||||||
private String puid;
|
private String puid;
|
||||||
/**
|
/**
|
||||||
* B钩脱落时间
|
* B钩脱落时间
|
||||||
|
|
@ -57,11 +67,17 @@ public class DeviceInfoVo {
|
||||||
/**
|
/**
|
||||||
* 设备状态 1 在线 0离线
|
* 设备状态 1 在线 0离线
|
||||||
*/
|
*/
|
||||||
private Long devStatus;
|
private Long devStatus = 0L;
|
||||||
/**
|
/**
|
||||||
* 数据检测时间
|
* 数据检测时间
|
||||||
*/
|
*/
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date devTime;
|
private Date devTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询条件限制
|
||||||
|
*/
|
||||||
|
public interface Query {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.aqd.base.service;
|
package com.bonus.aqd.base.service;
|
||||||
|
|
||||||
import com.bonus.aqd.base.entity.dto.ParamsDto;
|
import com.bonus.aqd.base.entity.dto.ParamsDto;
|
||||||
|
import com.bonus.aqd.base.entity.vo.DeviceInfoVo;
|
||||||
import com.bonus.aqd.manager.webResult.ServerResponse;
|
import com.bonus.aqd.manager.webResult.ServerResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -13,10 +14,60 @@ import com.bonus.aqd.manager.webResult.ServerResponse;
|
||||||
public interface IndexService {
|
public interface IndexService {
|
||||||
/**
|
/**
|
||||||
* 安全带设备列表
|
* 安全带设备列表
|
||||||
|
*
|
||||||
* @param data
|
* @param data
|
||||||
* @return ServerResponse
|
* @return ServerResponse
|
||||||
* @author cwchen
|
* @author cwchen
|
||||||
* @date 2024/7/29 14:34
|
* @date 2024/7/29 14:34
|
||||||
*/
|
*/
|
||||||
ServerResponse getDevicesInfo(ParamsDto data);
|
ServerResponse getDevicesInfo(ParamsDto data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:36
|
||||||
|
*/
|
||||||
|
ServerResponse addDevice(DeviceInfoVo data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:50
|
||||||
|
*/
|
||||||
|
ServerResponse editDevice(DeviceInfoVo data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备详情
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:55
|
||||||
|
*/
|
||||||
|
ServerResponse getDeviceInfo(ParamsDto data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 15:59
|
||||||
|
*/
|
||||||
|
ServerResponse delDevice(ParamsDto data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备分析
|
||||||
|
* @param data
|
||||||
|
* @return ServerResponse
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/29 16:41
|
||||||
|
*/
|
||||||
|
ServerResponse deviceAnalysis(ParamsDto data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,25 @@ package com.bonus.aqd.base.service.impl;
|
||||||
|
|
||||||
import com.bonus.aqd.base.dao.IndexMapper;
|
import com.bonus.aqd.base.dao.IndexMapper;
|
||||||
import com.bonus.aqd.base.entity.dto.ParamsDto;
|
import com.bonus.aqd.base.entity.dto.ParamsDto;
|
||||||
|
import com.bonus.aqd.base.entity.vo.DeviceAnalysisVo;
|
||||||
import com.bonus.aqd.base.entity.vo.DeviceInfoVo;
|
import com.bonus.aqd.base.entity.vo.DeviceInfoVo;
|
||||||
import com.bonus.aqd.base.service.IndexService;
|
import com.bonus.aqd.base.service.IndexService;
|
||||||
import com.bonus.aqd.manager.advice.ValidatorsUtils;
|
import com.bonus.aqd.manager.advice.ValidatorsUtils;
|
||||||
|
import com.bonus.aqd.manager.common.util.DateTimeHelper;
|
||||||
|
import com.bonus.aqd.manager.webResult.HttpStatus;
|
||||||
import com.bonus.aqd.manager.webResult.ServerResponse;
|
import com.bonus.aqd.manager.webResult.ServerResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @className:IndexServiceImpl
|
* @className:IndexServiceImpl
|
||||||
|
|
@ -40,4 +49,109 @@ public class IndexServiceImpl implements IndexService {
|
||||||
}
|
}
|
||||||
return ServerResponse.createSuccess(list);
|
return ServerResponse.createSuccess(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ServerResponse addDevice(DeviceInfoVo vo) {
|
||||||
|
try {
|
||||||
|
String validResult = validatorsUtils.valid(vo, DeviceInfoVo.Query.class);
|
||||||
|
if (StringUtils.isNotBlank(validResult)) {
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, validResult);
|
||||||
|
}
|
||||||
|
int result = mapper.devCodeIsExist(vo);
|
||||||
|
if(result > 0){
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "设备编码重复");
|
||||||
|
}
|
||||||
|
mapper.addDevice(vo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "操作失败");
|
||||||
|
}
|
||||||
|
return ServerResponse.createBySuccessMsg("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ServerResponse editDevice(DeviceInfoVo vo) {
|
||||||
|
try {
|
||||||
|
String validResult = validatorsUtils.valid(vo, DeviceInfoVo.Query.class);
|
||||||
|
if (StringUtils.isNotBlank(validResult)) {
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, validResult);
|
||||||
|
}
|
||||||
|
int result = mapper.devCodeIsExist(vo);
|
||||||
|
if(result > 0){
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "设备编码重复");
|
||||||
|
}
|
||||||
|
mapper.editDevice(vo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "操作失败");
|
||||||
|
}
|
||||||
|
return ServerResponse.createBySuccessMsg("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerResponse getDeviceInfo(ParamsDto dto) {
|
||||||
|
DeviceInfoVo vo = new DeviceInfoVo();
|
||||||
|
try {
|
||||||
|
vo = mapper.getDeviceInfo(dto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return ServerResponse.createSuccess(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ServerResponse delDevice(ParamsDto dto) {
|
||||||
|
try {
|
||||||
|
mapper.delDevice(dto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "操作失败");
|
||||||
|
}
|
||||||
|
return ServerResponse.createBySuccessMsg("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerResponse deviceAnalysis(ParamsDto dto) {
|
||||||
|
DeviceAnalysisVo vo = new DeviceAnalysisVo();
|
||||||
|
try {
|
||||||
|
List<Integer> deviceStatusNum = mapper.getDeviceStatusNum(dto);
|
||||||
|
if(CollectionUtils.isNotEmpty(deviceStatusNum)){
|
||||||
|
vo.setTotalDeviceNum(deviceStatusNum.get(0));
|
||||||
|
vo.setOnlineDeviceNum(deviceStatusNum.get(1));
|
||||||
|
vo.setOfflineDeviceNum(deviceStatusNum.get(2));
|
||||||
|
}
|
||||||
|
// 当天、本周、本月 单钩、双钩告警数量
|
||||||
|
dto.setNowDate(DateTimeHelper.getNowDate());
|
||||||
|
String weekStr = DateTimeHelper.getCurrentWeekTime();
|
||||||
|
String[] weekArr = weekStr.split(",");
|
||||||
|
dto.setStartWeekTime(weekArr[0]);
|
||||||
|
dto.setStartWeekTime(weekArr[1]);
|
||||||
|
Map<String, String> nowOneMonthDay = DateTimeHelper.getNowOneMonthDay();
|
||||||
|
dto.setStartMonthTime(nowOneMonthDay.get("beginDate"));
|
||||||
|
dto.setEndMonthTime(nowOneMonthDay.get("endDate"));
|
||||||
|
List<Integer> warnNums= mapper.getWarnNum(dto);
|
||||||
|
if(CollectionUtils.isNotEmpty(warnNums)){
|
||||||
|
vo.setOneLoosenDayWarnNum(warnNums.get(0));
|
||||||
|
vo.setTwoLoosenDayWarnNum(warnNums.get(1));
|
||||||
|
vo.setOneLoosenWeekWarnNum(warnNums.get(2));
|
||||||
|
vo.setTwoLoosenWeekWarnNum(warnNums.get(3));
|
||||||
|
vo.setOneLoosenMonthWarnNum(warnNums.get(4));
|
||||||
|
vo.setTwoLoosenMonthWarnNum(warnNums.get(5));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "查询失败");
|
||||||
|
}
|
||||||
|
return ServerResponse.createSuccess("查询成功",vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.err.println(DateTimeHelper.getCurrentWeekTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,42 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper 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.bonus.aqd.base.dao.IndexMapper">
|
<mapper namespace="com.bonus.aqd.base.dao.IndexMapper">
|
||||||
|
<!--新增设备-->
|
||||||
|
<insert id="addDevice">
|
||||||
|
INSERT INTO tb_device
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="devName != null and devName!=''">dev_name,</if>
|
||||||
|
<if test="devCode != null and devCode != ''">dev_code,</if>
|
||||||
|
<if test="devModu != null and devModu != ''">dev_modu,</if>
|
||||||
|
<if test="devA != null">dev_a,</if>
|
||||||
|
<if test="devB != null">dev_b,</if>
|
||||||
|
<if test="puid != null and puid!=''">puid,</if>
|
||||||
|
<if test="devStatus != null">dev_status,</if>
|
||||||
|
del_flag
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="devName != null and devName!=''">#{devName},</if>
|
||||||
|
<if test="devCode != null and devCode != ''">#{devCode},</if>
|
||||||
|
<if test="devModu != null and devModu != ''">#{devModu},</if>
|
||||||
|
<if test="devA != null">#{devA},</if>
|
||||||
|
<if test="devB != null">#{devB},</if>
|
||||||
|
<if test="puid != null and puid!=''">#{puid},</if>
|
||||||
|
<if test="devStatus != null">#{devStatus},</if>
|
||||||
|
0
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<!--修改设备-->
|
||||||
|
<update id="editDevice">
|
||||||
|
UPDATE tb_device SET dev_name = #{devName},
|
||||||
|
dev_code = #{devCode},
|
||||||
|
dev_modu = #{devModu},
|
||||||
|
puid = #{puid}
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
<!--删除设备-->
|
||||||
|
<update id="delDevice">
|
||||||
|
UPDATE tb_device SET del_flag = 1 WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
<!--安全带设备列表-->
|
<!--安全带设备列表-->
|
||||||
<select id="getDevicesInfo" resultType="com.bonus.aqd.base.entity.vo.DeviceInfoVo">
|
<select id="getDevicesInfo" resultType="com.bonus.aqd.base.entity.vo.DeviceInfoVo">
|
||||||
|
|
@ -20,4 +56,63 @@
|
||||||
WHERE del_flag = 0
|
WHERE del_flag = 0
|
||||||
ORDER BY dev_time DESC
|
ORDER BY dev_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
<!--设备编码是否重复-->
|
||||||
|
<select id="devCodeIsExist" resultType="java.lang.Integer">
|
||||||
|
<if test="id==null">
|
||||||
|
SELECT COUNT(*) FROM tb_device WHERE dev_code = #{devCode} AND del_flag = 0
|
||||||
|
</if>
|
||||||
|
<if test="id!=null">
|
||||||
|
SELECT COUNT(*) FROM tb_device WHERE dev_code = #{devCode} AND id != #{id} AND del_flag = 0
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<!--设备详情-->
|
||||||
|
<select id="getDeviceInfo" resultType="com.bonus.aqd.base.entity.vo.DeviceInfoVo">
|
||||||
|
SELECT id,
|
||||||
|
dev_name AS devName,
|
||||||
|
dev_code AS devCode,
|
||||||
|
dev_modu AS devModu,
|
||||||
|
puid
|
||||||
|
FROM tb_device WHERE id = #{id}
|
||||||
|
</select>
|
||||||
|
<!--查询设备状态数量-->
|
||||||
|
<select id="getDeviceStatusNum" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(*) FROM tb_device WHERE del_flag = 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(*) FROM tb_device WHERE dev_status = 1 AND del_flag = 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(*) FROM tb_device WHERE dev_status = 0 AND del_flag = 0
|
||||||
|
</select>
|
||||||
|
<!--当天、本周、本月 单钩、双钩告警数量-->
|
||||||
|
<select id="getWarnNum" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM tb_warn tw
|
||||||
|
LEFT JOIN tb_device td ON tw.dev_code = td.dev_code
|
||||||
|
WHERE DATE_FORMAT(tw.warn_time, '%Y-%m-%d') = #{nowDate} AND INSTR(dev_module,'单双') > 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM tb_warn tw
|
||||||
|
LEFT JOIN tb_device td ON tw.dev_code = td.dev_code
|
||||||
|
WHERE DATE_FORMAT(tw.warn_time, '%Y-%m-%d') = #{nowDate} AND INSTR(dev_module,'双钩') > 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM tb_warn tw
|
||||||
|
LEFT JOIN tb_device td ON tw.dev_code = td.dev_code
|
||||||
|
WHERE DATE_FORMAT(tw.warn_time, '%Y-%m-%d') BETWEEN #{startWeekTime} AND #{endWeekTime} AND INSTR(dev_module,'单双') > 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM tb_warn tw
|
||||||
|
LEFT JOIN tb_device td ON tw.dev_code = td.dev_code
|
||||||
|
WHERE DATE_FORMAT(tw.warn_time, '%Y-%m-%d') BETWEEN #{startWeekTime} AND #{endWeekTime} AND INSTR(dev_module,'双钩') > 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM tb_warn tw
|
||||||
|
LEFT JOIN tb_device td ON tw.dev_code = td.dev_code
|
||||||
|
WHERE DATE_FORMAT(tw.warn_time, '%Y-%m-%d') BETWEEN #{startMonthTime} AND #{endMonthTime} AND INSTR(dev_module,'单双') > 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM tb_warn tw
|
||||||
|
LEFT JOIN tb_device td ON tw.dev_code = td.dev_code
|
||||||
|
WHERE DATE_FORMAT(tw.warn_time, '%Y-%m-%d') BETWEEN #{startMonthTime} AND #{endMonthTime} AND INSTR(dev_module,'双钩') > 0
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue