大屏接口,枚举类定义

This commit is contained in:
syruan 2024-09-18 18:19:12 +08:00
parent 02219cd8e4
commit 9385f88ae4
17 changed files with 468 additions and 15 deletions

View File

@ -1,4 +1,4 @@
package com.bonus.base; package com.bonus;
import com.bonus.common.security.annotation.EnableCustomConfig; import com.bonus.common.security.annotation.EnableCustomConfig;
import com.bonus.common.security.annotation.EnableRyFeignClients; import com.bonus.common.security.annotation.EnableRyFeignClients;
@ -16,7 +16,6 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@EnableCustomSwagger2 @EnableCustomSwagger2
@EnableRyFeignClients @EnableRyFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class BonusBaseApplication { public class BonusBaseApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(BonusBaseApplication.class, args); SpringApplication.run(BonusBaseApplication.class, args);

View File

@ -0,0 +1,30 @@
package com.bonus.base.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.base.config
* @CreateTime: 2024-09-18 14:18
* @Description: 设备类型枚举
*/
@Getter
@AllArgsConstructor
public enum DeviceTypeEnum {
BASE_SAFETY_HAT(123, "安全帽"),
BASE_ENVIRONMENT_MONITOR(116, "环境监测"),
BASE_PIT_MONITOR(119, "基坑监测"),
TOWER_RAKE_MONITOR(117, "组塔倾角监测"),
TOWER_WATER_MONITOR(118, "组塔拉力监测"),
LEAD_STRAIN_MONITOR(120, "牵张引线拉力监测");
private final Integer code;
private final String label;
}

View File

@ -5,7 +5,7 @@ import lombok.Getter;
/** /**
* 返回异常枚举类 * 返回异常枚举类
* @Author ma_sh * @author ma_sh
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@ -30,15 +30,10 @@ public enum ExceptionEnum {
INVALID_PHONE_NUMBER_FORMAT(501, "手机号格式不正确"), INVALID_PHONE_NUMBER_FORMAT(501, "手机号格式不正确"),
DELETE_PROJECT_ERROR(502, "该工程关联相应杆塔,无法删除"); DELETE_PROJECT_ERROR(502, "该工程关联相应杆塔,无法删除");
private Integer code;
private String msg; private final Integer code;
private final String msg;
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
} }

View File

@ -0,0 +1,23 @@
package com.bonus.base.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author : 阮世耀
* @version : 1.0
* @CreateTime: 2024-09-18 10:34
* @Description: 工程类型枚举
*/
@Getter
@AllArgsConstructor
public enum ProjectTypeEnum {
PROJECT_TYPE_LINE(108, "线路工程"),
PROJECT_TYPE_POWER(109, "变电工程");
private final Integer code;
private final String label;
}

View File

@ -1,6 +1,8 @@
package com.bonus.base.mapper; package com.bonus.base.mapper;
import com.bonus.base.config.DeviceTypeEnum;
import com.bonus.base.domain.TbDevice; import com.bonus.base.domain.TbDevice;
import com.bonus.screen.vo.DeviceViewVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@ -19,19 +21,25 @@ public interface TbDeviceMapper {
*/ */
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
int deleteByPrimaryKeyIn(List<Long> list);
/** /**
* 新增 * 新增
* @param record * @param record
* @return * @return
*/ */
int insert(TbDevice record);
int insertSelective(TbDevice record); int insertSelective(TbDevice record);
int updateByPrimaryKeySelective(TbDevice record);
/** /**
* 根据主键修改 * 根据主键修改
* @param record * @param record
* @return * @return
*/ */
int updateByPrimaryKeySelective(TbDevice record); int updateByPrimaryKey(TbDevice record);
/** /**
* 根据条件查询 * 根据条件查询
@ -40,6 +48,8 @@ public interface TbDeviceMapper {
*/ */
List<TbDevice> getAll(TbDevice record); List<TbDevice> getAll(TbDevice record);
int updateBatch(List<TbDevice> list);
/** /**
* 根据设备编码查询设备信息 * 根据设备编码查询设备信息
* @param record * @param record
@ -53,4 +63,15 @@ public interface TbDeviceMapper {
* @return * @return
*/ */
TbDevice selectByPrimaryKey(Long id); TbDevice selectByPrimaryKey(Long id);
DeviceViewVo getDeviceView();
DeviceViewVo getSensingDevice(DeviceTypeEnum baseSafetyHat,
DeviceTypeEnum baseEnvironmentMonitor,
DeviceTypeEnum basePitMonitor,
DeviceTypeEnum towerRakeMonitor,
DeviceTypeEnum towerWaterMonitor,
DeviceTypeEnum leadStrainMonitor);
} }

View File

@ -2,8 +2,11 @@ package com.bonus.base.mapper;
import com.bonus.base.domain.TbProject; import com.bonus.base.domain.TbProject;
import com.bonus.base.vo.TbProjectVo; import com.bonus.base.vo.TbProjectVo;
import com.bonus.screen.vo.ProjectAreaGroupVo;
import com.bonus.screen.vo.ProjectViewVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
/** /**
@ -12,6 +15,7 @@ import java.util.List;
* @author makejava * @author makejava
* @since 2024-09-09 14:56:50 * @since 2024-09-09 14:56:50
*/ */
@Mapper
public interface TbProjectMapper { public interface TbProjectMapper {
/** /**
@ -59,5 +63,16 @@ public interface TbProjectMapper {
* @return * @return
*/ */
TbProjectVo selectByName(TbProject tbProject); TbProjectVo selectByName(TbProject tbProject);
/**
* 查询工程总览--by大屏
*
* @param powerCode 变电code编码
* @param lineCode 线路code编码
*/
ProjectViewVo getProjectView(@Param("powerCode") Integer powerCode, @Param("lineCode") Integer lineCode);
List<ProjectAreaGroupVo> getProjectListGroupArea();
} }

View File

@ -0,0 +1,58 @@
package com.bonus.screen.controller;
import com.bonus.base.config.ProjectTypeEnum;
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.screen.service.impl.ProjectViewServiceImpl;
import com.bonus.screen.vo.DeviceWarnRecordVo;
import com.bonus.screen.vo.ProjectViewVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @model 工程模块by工作台
*/
@RestController
@RequestMapping("/screen/home")
public class ProjectViewController extends BaseController {
@Autowired
private ProjectViewServiceImpl projectViewService;
@GetMapping("/getProjectModelData")
public AjaxResult getProjectModelData() {
return success(projectViewService.getProjectView());
}
@GetMapping("/getDeviceModelData")
public AjaxResult getDeviceModelData() {
return success(projectViewService.getTbDeviceMapper());
}
@GetMapping("/getSensingDeviceModelData")
public AjaxResult getSensingDeviceModelData() {
return success(projectViewService.getSensingDevice());
}
@GetMapping("/getDeviceWarnRecord")
public AjaxResult getDeviceWarnRecord(DeviceWarnRecordVo deviceWarnRecordVo) {
return success(projectViewService.getDeviceWarnRecord(deviceWarnRecordVo));
}
@GetMapping("/getDeviceWarnRecordPage")
public TableDataInfo getDeviceWarnRecordPage(DeviceWarnRecordVo deviceWarnRecordVo) {
startPage();
List<DeviceWarnRecordVo> list = projectViewService.getDeviceWarnRecord(deviceWarnRecordVo);
return getDataTable(list);
}
}

View File

@ -0,0 +1,20 @@
package com.bonus.screen.mapper;
import com.bonus.screen.vo.DeviceWarnRecordVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.screen.mapper
* @CreateTime: 2024-09-18 15:39
* @Description: 描述
*/
@Mapper
public interface TbDeviceDataRecord {
List<DeviceWarnRecordVo> getDeviceWarnRecord(DeviceWarnRecordVo deviceWarnRecordVo);
}

View File

@ -0,0 +1,73 @@
package com.bonus.screen.service.impl;
import com.bonus.base.config.DeviceTypeEnum;
import com.bonus.base.config.ProjectTypeEnum;
import com.bonus.base.mapper.TbDeviceMapper;
import com.bonus.base.mapper.TbProjectMapper;
import com.bonus.screen.mapper.TbDeviceDataRecord;
import com.bonus.screen.vo.DeviceViewVo;
import com.bonus.screen.vo.DeviceWarnRecordVo;
import com.bonus.screen.vo.ProjectAreaGroupVo;
import com.bonus.screen.vo.ProjectViewVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author : 阮世耀
* @version : 1.0
*/
@Service
public class ProjectViewServiceImpl {
@Autowired
private TbProjectMapper tbProjectMapper;
@Autowired
private TbDeviceMapper tbDeviceMapper;
@Autowired
private TbDeviceDataRecord tbDeviceDataRecord;
public ProjectViewVo getProjectView() {
return tbProjectMapper.getProjectView(
ProjectTypeEnum.PROJECT_TYPE_POWER.getCode(),
ProjectTypeEnum.PROJECT_TYPE_LINE.getCode()
);
}
public DeviceViewVo getTbDeviceMapper() {
return tbDeviceMapper.getDeviceView();
}
public DeviceViewVo getSensingDevice() {
return tbDeviceMapper.getSensingDevice(
DeviceTypeEnum.BASE_SAFETY_HAT,
DeviceTypeEnum.BASE_ENVIRONMENT_MONITOR,
DeviceTypeEnum.BASE_PIT_MONITOR,
DeviceTypeEnum.TOWER_RAKE_MONITOR,
DeviceTypeEnum.TOWER_WATER_MONITOR,
DeviceTypeEnum.LEAD_STRAIN_MONITOR
);
}
public List<DeviceWarnRecordVo> getDeviceWarnRecord(DeviceWarnRecordVo deviceWarnRecordVo) {
return tbDeviceDataRecord.getDeviceWarnRecord(deviceWarnRecordVo);
}
public List<ProjectAreaGroupVo> getProjectListGroupArea() {
List<ProjectAreaGroupVo> projectAreaList = tbProjectMapper.getProjectListGroupArea();
if (projectAreaList != null && !projectAreaList.isEmpty()) {
Map<Integer, List<ProjectAreaGroupVo>> collect = projectAreaList.stream().collect(
Collectors.groupingBy(ProjectAreaGroupVo::getAreaId)
);
}
return projectAreaList;
}
}

View File

@ -0,0 +1,35 @@
package com.bonus.screen.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.screen.vo
* @CreateTime: 2024-09-18 13:52
* @Description: 大屏设备展示模块Vo
*/
@Data
public class DeviceViewVo implements Serializable {
@ApiModelProperty(value = "设备总数")
private Integer deviceTotal;
@ApiModelProperty(value = "设备在线总数")
private Integer deviceOnlineTotal;
private Integer baseSafetyHat;
private Integer baseEnvironmentMonitor;
private Integer basePitMonitor;
private Integer towerRakeMonitor;
private Integer towerWaterMonitor;
private Integer leadStrainMonitor;
}

View File

@ -0,0 +1,51 @@
package com.bonus.screen.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.screen.vo
* @CreateTime: 2024-09-18 15:31
* @Description: 设备异常记录展示层Vo
*/
@Data
public class DeviceWarnRecordVo implements Serializable {
private Long id;
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "设备状态")
private Integer deviceStatus;
@ApiModelProperty(value = "设备类型Code")
private String deviceTypeCode;
@ApiModelProperty(value = "设备类型名称")
private String deviceTypeName;
@ApiModelProperty(value = "工程名称")
private String projectName;
@ApiModelProperty(value = "告警内容")
private String warnContent;
@ApiModelProperty(value = "告警时间")
private String warnTime;
@ApiModelProperty(value = "告警值")
private String warnValue;
@ApiModelProperty(value = "告警类型")
private String warnType;
}

View File

@ -0,0 +1,41 @@
package com.bonus.screen.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.screen.vo
* @CreateTime: 2024-09-18 17:43
* @Description: 工程区域分组视图Vo
*/
@Data
public class ProjectAreaGroupVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "区域名称")
private String areaName;
@ApiModelProperty(value = "区域id")
private Integer areaId;
@ApiModelProperty(value = "区域工程数量")
private Integer areaProjectCount;
@ApiModelProperty(value = "区域内工程列表")
private List<ProjectAreaGroupVo> projectList;
@ApiModelProperty(value = "工程id")
private Integer projectId;
@ApiModelProperty(value = "工程名称")
private String projectName;
}

View File

@ -0,0 +1,28 @@
package com.bonus.screen.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author : 阮世耀
* @version : 1.0
* @CreateTime: 2024-09-18 10:10
* @Description: 工程总览展示
*/
@Data
public class ProjectViewVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "工程总数")
private Integer projectTotal;
@ApiModelProperty(value = "变电工程数量")
private Integer projectPowerTotal;
@ApiModelProperty(value = "线路工程数量")
private Integer projectLineTotal;
}

View File

@ -219,10 +219,30 @@
#{item.id,jdbcType=BIGINT} #{item.id,jdbcType=BIGINT}
</foreach> </foreach>
</update> </update>
<delete id="deleteByPrimaryKeyIn"> <delete id="deleteByPrimaryKeyIn">
delete from tb_device where id in update tb_device set del_flag = 1 where id in
<foreach close=")" collection="list" item="id" open="(" separator=", "> <foreach close=")" collection="list" item="id" open="(" separator=", ">
#{id,jdbcType=BIGINT} #{id,jdbcType=BIGINT}
</foreach> </foreach>
</delete> </delete>
<select id="getDeviceView" resultType="com.bonus.screen.vo.DeviceViewVo">
select count(1) as deviceTotal,
count(dev_status = 1) as deviceOnlineTotal
from tb_device
where del_flag = 0
</select>
<select id="getSensingDevice" resultType="com.bonus.screen.vo.DeviceViewVo">
select count(1) as deviceTotal,
count(dev_type = #{param1.code}) as baseSafetyHat,
count(dev_type = #{param2.code}) as baseEnvironmentMonitor,
count(dev_type = #{param3.code}) as basePitMonitor,
count(dev_type = #{param4.code}) as towerRakeMonitor,
count(dev_type = #{param5.code}) as towerWaterMonitor,
count(dev_type = #{param6.code}) as leadStrainMonitor
from tb_device
where del_flag = 0
</select>
</mapper> </mapper>

View File

@ -57,7 +57,7 @@
<select id="getAreaList" resultType="com.bonus.base.domain.TbArea"> <select id="getAreaList" resultType="com.bonus.base.domain.TbArea">
select id as areaId, area_name as areaName, area_type as areaType, p_id as pId select id as areaId, area_name as areaName, area_type as areaType, p_id as pId
from tb_area from tb_area
where del_flag = '0' where del_flag = 0 and area_type = 0 and p_id = 0
<if test="areaType != null and areaType != ''"> <if test="areaType != null and areaType != ''">
and area_type = #{areaType} and area_type = #{areaType}
</if> </if>

View File

@ -168,5 +168,24 @@
where id = #{id} where id = #{id}
</update> </update>
<select id="getProjectView" resultType="com.bonus.screen.vo.ProjectViewVo">
select count(1) as projectTotal,
count(case when tb.pro_type = #{powerCode} then 1 end) as projectPowerTotal,
count(case when tb.pro_type = #{lineCode} then 1 end) as projectLineTotal
from tb_project tb
where tb.del_flag = '0'
</select>
<select id="getProjectListGroupArea" resultType="com.bonus.screen.vo.ProjectAreaGroupVo">
SELECT
a.id AS areaId,
a.area_name as areaName,
p.id AS projectId,
p.pro_name AS projectName
FROM
tb_area a
LEFT JOIN
tb_project p ON a.id = p.area_id;
</select>
</mapper> </mapper>

View File

@ -0,0 +1,25 @@
<?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.screen.mapper.TbDeviceDataRecord">
<select id="getDeviceWarnRecord" resultType="com.bonus.screen.vo.DeviceWarnRecordVo">
SELECT
tddr.id,
tddr.dev_name AS deviceName,
tddr.create_time AS warnTime,
tddr.attribute_name AS warnType,
tddr.attribute_val AS warnValue,
tddr.dev_json AS warnContent,
tp.pro_name AS projectName,
td.dev_code AS deviceCode
FROM tb_dev_data_record tddr
LEFT JOIN tb_device td ON tddr.dev_id = td.id
LEFT JOIN tb_bd_device_record tbdr ON td.dev_code = tbdr.dev_code
LEFT JOIN tb_project tp ON tbdr.pro_id = tp.id
WHERE tddr.is_warn = 1
<if test="projectName != null and projectName != ''">
and tp.pro_name like concat('%',#{projectName},'%')
</if>
GROUP BY tddr.id
</select>
</mapper>