From 5c0e055917e34df48eae19535ff51a38eb5bef1e Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期二, 27 五月 2025 16:13:43 +0800 Subject: [PATCH] 设备工作状态统计 --- src/main/java/com/whyc/dto/Statistic/DeviceStateStic.java | 15 +++++++ src/main/java/com/whyc/pojo/db_ram_db/DeviceState.java | 14 +++++++ src/main/java/com/whyc/service/DeviceStateService.java | 14 +++++++ src/main/resources/mapper/BatttestdataInfMapper.xml | 4 + src/main/java/com/whyc/controller/StatisticController.java | 13 ++++++ src/main/resources/mapper/DeviceStateMapper.xml | 37 ++++++++++++++++++ src/main/resources/mapper/StationInfMapper.xml | 1 src/main/java/com/whyc/mapper/DeviceStateMapper.java | 6 +++ src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java | 9 ++++ 9 files changed, 112 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/whyc/controller/StatisticController.java b/src/main/java/com/whyc/controller/StatisticController.java index 130ac3a..0b5bc82 100644 --- a/src/main/java/com/whyc/controller/StatisticController.java +++ b/src/main/java/com/whyc/controller/StatisticController.java @@ -2,9 +2,11 @@ import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattTinfStic; +import com.whyc.dto.Statistic.DeviceStateStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.pojo.db_user.User; import com.whyc.service.BatttestdataInfService; +import com.whyc.service.DeviceStateService; import com.whyc.service.StationInfService; import com.whyc.util.ActionUtil; import io.swagger.annotations.Api; @@ -25,6 +27,9 @@ @Autowired private BatttestdataInfService battTinfService; + @Autowired + private DeviceStateService deviceStateService; + @ApiOperation(value = "绔欑偣淇℃伅缁熻") @PostMapping("getStationStatistic") public Response getStationStatistic(@RequestBody StationStic stic){ @@ -40,4 +45,12 @@ stic.setUid(uinf.getId()); return battTinfService.getBattTinfStatistic(stic); } + + @ApiOperation(value = "璁惧宸ヤ綔鐘舵�佺粺璁�") + @PostMapping("getDeviceStateStatistic") + public Response getDeviceStateStatistic(@RequestBody DeviceStateStic stic){ + User uinf= ActionUtil.getUser(); + stic.setUid(uinf.getId()); + return deviceStateService.getDeviceStateStatistic(stic); + } } \ No newline at end of file diff --git a/src/main/java/com/whyc/dto/Statistic/DeviceStateStic.java b/src/main/java/com/whyc/dto/Statistic/DeviceStateStic.java new file mode 100644 index 0000000..8a7eadb --- /dev/null +++ b/src/main/java/com/whyc/dto/Statistic/DeviceStateStic.java @@ -0,0 +1,15 @@ +package com.whyc.dto.Statistic; + +import lombok.Data; + +@Data +public class DeviceStateStic { + private String provice; + private String city; + private String country; + private String stationName; + private Integer uid; + private Integer pageNum; + private Integer pageSize; + private Integer devWorkstate; +} \ No newline at end of file diff --git a/src/main/java/com/whyc/mapper/DeviceStateMapper.java b/src/main/java/com/whyc/mapper/DeviceStateMapper.java index 1990c87..8270098 100644 --- a/src/main/java/com/whyc/mapper/DeviceStateMapper.java +++ b/src/main/java/com/whyc/mapper/DeviceStateMapper.java @@ -1,6 +1,12 @@ package com.whyc.mapper; +import com.whyc.dto.Statistic.DeviceStateStic; import com.whyc.pojo.db_ram_db.DeviceState; +import org.apache.ibatis.annotations.Param; + +import java.util.List; public interface DeviceStateMapper extends CustomMapper<DeviceState>{ + //璁惧宸ヤ綔鐘舵�佺粺璁� + List<DeviceState> getDeviceStateStatistic(@Param("stic") DeviceStateStic stic); } \ No newline at end of file diff --git a/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java b/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java index ef20cef..4880964 100644 --- a/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java +++ b/src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java @@ -110,5 +110,14 @@ @TableField(exist = false) private String battgroupName; + @TableField(exist = false) + private String provice; + @TableField(exist = false) + private String city; + @TableField(exist = false) + private String country; + @TableField(exist = false) + private String fullName; + } diff --git a/src/main/java/com/whyc/pojo/db_ram_db/DeviceState.java b/src/main/java/com/whyc/pojo/db_ram_db/DeviceState.java index e571e9c..2527914 100644 --- a/src/main/java/com/whyc/pojo/db_ram_db/DeviceState.java +++ b/src/main/java/com/whyc/pojo/db_ram_db/DeviceState.java @@ -1,6 +1,7 @@ package com.whyc.pojo.db_ram_db; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -127,5 +128,18 @@ @ApiModelProperty(value = "鍏呮斁鐢典竴浣撴満缁�2缁勭鐢垫祦") private Float groupCurr2; + @TableField(exist = false) + private String stationName; + @TableField(exist = false) + private String devName; + + @TableField(exist = false) + private String provice; + @TableField(exist = false) + private String city; + @TableField(exist = false) + private String country; + @TableField(exist = false) + private String fullName; } diff --git a/src/main/java/com/whyc/service/DeviceStateService.java b/src/main/java/com/whyc/service/DeviceStateService.java index 5ec9046..cb3dfc3 100644 --- a/src/main/java/com/whyc/service/DeviceStateService.java +++ b/src/main/java/com/whyc/service/DeviceStateService.java @@ -1,11 +1,18 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.whyc.dto.Response; +import com.whyc.dto.Statistic.DeviceStateStic; import com.whyc.mapper.DeviceStateMapper; +import com.whyc.pojo.db_batt_testdata.BatttestdataInf; import com.whyc.pojo.db_ram_db.BattRtstate; import com.whyc.pojo.db_ram_db.DeviceState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.List; @Service public class DeviceStateService { @@ -19,4 +26,11 @@ DeviceState dev=mapper.selectOne(wrapper); return dev; } + //璁惧宸ヤ綔鐘舵�佺粺璁� + public Response getDeviceStateStatistic(DeviceStateStic stic) { + PageHelper.startPage(stic.getPageNum(),stic.getPageSize()); + List<DeviceState> list=mapper.getDeviceStateStatistic(stic); + PageInfo pageInfo=new PageInfo(list); + return new Response().setII(1,list.size()>0,pageInfo,"璁惧宸ヤ綔鐘舵�佺粺璁�"); + } } \ No newline at end of file diff --git a/src/main/resources/mapper/BatttestdataInfMapper.xml b/src/main/resources/mapper/BatttestdataInfMapper.xml index 0dd9d60..2a04d22 100644 --- a/src/main/resources/mapper/BatttestdataInfMapper.xml +++ b/src/main/resources/mapper/BatttestdataInfMapper.xml @@ -3,7 +3,8 @@ <mapper namespace="com.whyc.mapper.BatttestdataInfMapper"> <select id="getBattTinfStatistic" resultType="com.whyc.pojo.db_batt_testdata.BatttestdataInf"> - select tb_batttestdata_inf.*,tb_station_inf.station_name,tb_batt_inf.battgroup_name + select tb_batttestdata_inf.* + ,tb_station_inf.station_name,tb_station_inf.provice,tb_station_inf.city,tb_station_inf.country,tb_station_inf.full_name,tb_batt_inf.battgroup_name from db_batt_testdata.tb_batttestdata_inf,db_station.tb_station_inf,db_station.tb_batt_inf <where> tb_batttestdata_inf.battgroup_id=tb_batt_inf.battgroup_id @@ -37,5 +38,6 @@ ) </if> </where> + order by tb_batttestdata_inf.battgroup_id asc, tb_batttestdata_inf.test_record_count asc </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/DeviceStateMapper.xml b/src/main/resources/mapper/DeviceStateMapper.xml new file mode 100644 index 0000000..8dc0277 --- /dev/null +++ b/src/main/resources/mapper/DeviceStateMapper.xml @@ -0,0 +1,37 @@ +<?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.whyc.mapper.DeviceStateMapper"> + + <select id="getDeviceStateStatistic" resultType="com.whyc.pojo.db_ram_db.DeviceState"> + select tb_device_state.* + ,tb_station_inf.station_name,tb_station_inf.provice,tb_station_inf.city,tb_station_inf.country,tb_station_inf.full_name,tb_batt_inf.dev_name + from db_ram_db.tb_device_state,db_station.tb_station_inf,db_station.tb_batt_inf + <where> + tb_device_state.dev_id=tb_batt_inf.dev_id + and tb_batt_inf.station_id=tb_station_inf.station_id + <if test="stic.provice!=null"> + and tb_station_inf.provice=#{stic.provice} + </if> + <if test="stic.city!=null"> + and tb_station_inf.city= #{stic.city} + </if> + <if test="stic.country!=null"> + and tb_station_inf.country= #{stic.country} + </if> + <if test="stic.stationName!=null"> + and tb_station_inf.station_name= #{stic.stationName} + </if> + <if test="stic.devWorkstate!=null"> + and tb_device_state.dev_workstate= #{stic.devWorkstate} + </if> + <if test="stic.uid>100"> + and tb_station_inf.station_id in( + select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{stic.uid} + ) + </if> + order by tb_device_state.dev_id asc + </where> + </select> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/StationInfMapper.xml b/src/main/resources/mapper/StationInfMapper.xml index b60baaa..d196d81 100644 --- a/src/main/resources/mapper/StationInfMapper.xml +++ b/src/main/resources/mapper/StationInfMapper.xml @@ -204,6 +204,7 @@ and tb_baojigroup_usr.uid=#{stic.uid} ) </if> + order by station_id asc </where> </select> -- Gitblit v1.9.1