diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/BonusBaseApplication.java b/bonus-modules/bonus-base/src/main/java/com/bonus/BonusBaseApplication.java similarity index 98% rename from bonus-modules/bonus-base/src/main/java/com/bonus/base/BonusBaseApplication.java rename to bonus-modules/bonus-base/src/main/java/com/bonus/BonusBaseApplication.java index 69b5210..6b03bb0 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/BonusBaseApplication.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/BonusBaseApplication.java @@ -1,4 +1,4 @@ -package com.bonus.base; +package com.bonus; import com.bonus.common.security.annotation.EnableCustomConfig; import com.bonus.common.security.annotation.EnableRyFeignClients; @@ -16,7 +16,6 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @EnableCustomSwagger2 @EnableRyFeignClients @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) - public class BonusBaseApplication { public static void main(String[] args) { SpringApplication.run(BonusBaseApplication.class, args); diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/DeviceTypeEnum.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/DeviceTypeEnum.java new file mode 100644 index 0000000..ee89a42 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/DeviceTypeEnum.java @@ -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; +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/ExceptionEnum.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/ExceptionEnum.java index e36198f..139f053 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/ExceptionEnum.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/ExceptionEnum.java @@ -5,7 +5,7 @@ import lombok.Getter; /** * 返回异常枚举类 - * @Author ma_sh + * @author ma_sh */ @Getter @AllArgsConstructor @@ -30,15 +30,10 @@ public enum ExceptionEnum { INVALID_PHONE_NUMBER_FORMAT(501, "手机号格式不正确"), 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; - } } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/ProjectTypeEnum.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/ProjectTypeEnum.java new file mode 100644 index 0000000..e8f58b6 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/ProjectTypeEnum.java @@ -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; +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java index 0128038..388330b 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java @@ -1,6 +1,8 @@ package com.bonus.base.mapper; +import com.bonus.base.config.DeviceTypeEnum; import com.bonus.base.domain.TbDevice; +import com.bonus.screen.vo.DeviceViewVo; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -19,19 +21,25 @@ public interface TbDeviceMapper { */ int deleteByPrimaryKey(Long id); + int deleteByPrimaryKeyIn(List list); + /** * 新增 * @param record * @return */ + int insert(TbDevice record); + int insertSelective(TbDevice record); + int updateByPrimaryKeySelective(TbDevice record); + /** * 根据主键修改 * @param record * @return */ - int updateByPrimaryKeySelective(TbDevice record); + int updateByPrimaryKey(TbDevice record); /** * 根据条件查询 @@ -40,6 +48,8 @@ public interface TbDeviceMapper { */ List getAll(TbDevice record); + int updateBatch(List list); + /** * 根据设备编码查询设备信息 * @param record @@ -53,4 +63,15 @@ public interface TbDeviceMapper { * @return */ TbDevice selectByPrimaryKey(Long id); + + DeviceViewVo getDeviceView(); + + DeviceViewVo getSensingDevice(DeviceTypeEnum baseSafetyHat, + DeviceTypeEnum baseEnvironmentMonitor, + DeviceTypeEnum basePitMonitor, + DeviceTypeEnum towerRakeMonitor, + DeviceTypeEnum towerWaterMonitor, + DeviceTypeEnum leadStrainMonitor); + + } \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbProjectMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbProjectMapper.java index 3f60b38..22f9391 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbProjectMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbProjectMapper.java @@ -2,8 +2,11 @@ package com.bonus.base.mapper; import com.bonus.base.domain.TbProject; 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.springframework.data.domain.Pageable; + import java.util.List; /** @@ -12,6 +15,7 @@ import java.util.List; * @author makejava * @since 2024-09-09 14:56:50 */ +@Mapper public interface TbProjectMapper { /** @@ -59,5 +63,16 @@ public interface TbProjectMapper { * @return */ TbProjectVo selectByName(TbProject tbProject); + + /** + * 查询工程总览--by大屏 + * + * @param powerCode 变电code编码 + * @param lineCode 线路code编码 + */ + ProjectViewVo getProjectView(@Param("powerCode") Integer powerCode, @Param("lineCode") Integer lineCode); + + + List getProjectListGroupArea(); } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/screen/controller/ProjectViewController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/controller/ProjectViewController.java new file mode 100644 index 0000000..26a2ce7 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/controller/ProjectViewController.java @@ -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 list = projectViewService.getDeviceWarnRecord(deviceWarnRecordVo); + return getDataTable(list); + } + +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/screen/mapper/TbDeviceDataRecord.java b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/mapper/TbDeviceDataRecord.java new file mode 100644 index 0000000..d9660a7 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/mapper/TbDeviceDataRecord.java @@ -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 getDeviceWarnRecord(DeviceWarnRecordVo deviceWarnRecordVo); + +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/screen/service/impl/ProjectViewServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/service/impl/ProjectViewServiceImpl.java new file mode 100644 index 0000000..1da5b95 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/service/impl/ProjectViewServiceImpl.java @@ -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 getDeviceWarnRecord(DeviceWarnRecordVo deviceWarnRecordVo) { + return tbDeviceDataRecord.getDeviceWarnRecord(deviceWarnRecordVo); + } + + public List getProjectListGroupArea() { + List projectAreaList = tbProjectMapper.getProjectListGroupArea(); + if (projectAreaList != null && !projectAreaList.isEmpty()) { + Map> collect = projectAreaList.stream().collect( + Collectors.groupingBy(ProjectAreaGroupVo::getAreaId) + ); + } + + + return projectAreaList; + } +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/DeviceViewVo.java b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/DeviceViewVo.java new file mode 100644 index 0000000..0aaf843 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/DeviceViewVo.java @@ -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; +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/DeviceWarnRecordVo.java b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/DeviceWarnRecordVo.java new file mode 100644 index 0000000..870a0ed --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/DeviceWarnRecordVo.java @@ -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; + +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/ProjectAreaGroupVo.java b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/ProjectAreaGroupVo.java new file mode 100644 index 0000000..7aed4a2 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/ProjectAreaGroupVo.java @@ -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 projectList; + + @ApiModelProperty(value = "工程id") + private Integer projectId; + + @ApiModelProperty(value = "工程名称") + private String projectName; + +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/ProjectViewVo.java b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/ProjectViewVo.java new file mode 100644 index 0000000..1c4c231 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/screen/vo/ProjectViewVo.java @@ -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; + +} diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml index 1183e30..a8d0267 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml @@ -219,10 +219,30 @@ #{item.id,jdbcType=BIGINT} + - delete from tb_device where id in + update tb_device set del_flag = 1 where id in #{id,jdbcType=BIGINT} + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml index 0fdf823..6133675 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml @@ -57,7 +57,7 @@ + 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' + + + diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/screen/TbDeviceDataRecordMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/screen/TbDeviceDataRecordMapper.xml new file mode 100644 index 0000000..84a04bf --- /dev/null +++ b/bonus-modules/bonus-base/src/main/resources/mapper/screen/TbDeviceDataRecordMapper.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file