提交代码

This commit is contained in:
qinjie 2024-12-27 15:24:41 +08:00
parent 3f6f29f4da
commit 78be71b699
13 changed files with 54 additions and 20 deletions

View File

@ -40,8 +40,9 @@ public class DeviceController {
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false) String gasWellName,
@RequestParam(required = false) String gasStationName,
@RequestParam(required = false) Integer product,
@RequestParam Long deviceTypeId,@RequestParam Long blockId) {
return Response.succeed(deviceService.page(currentPage, pageSize, gasWellName,gasStationName,deviceTypeId,blockId));
return Response.succeed(deviceService.page(currentPage, pageSize, gasWellName,gasStationName,deviceTypeId,blockId,product));
}
/**

View File

@ -21,7 +21,8 @@ public interface DeviceDao extends BaseMapper<Device> {
@Param("gasWellName") String gasWellName,
@Param("gasStationName") String gasStationName,
@Param("deviceTypeId") Long deviceTypeId,
@Param("blockId") Long blockId);
@Param("blockId") Long blockId,
@Param("product") Integer product);
DeviceVO getDeviceById(@Param("id") Long id);

View File

@ -14,6 +14,6 @@ public interface SwitchStatusExportDao extends BaseMapper<SwitchStatusExport> {
void deleteData();
List<SwitchStatusExport> getSwitchStatusExport(@Param("startTime")String startTime, @Param("endTime")String endTime);
List<SwitchStatusExport> getSwitchStatusExport(@Param("startTime")String startTime, @Param("endTime")String endTime,@Param("departmentId") Long departmentId);
}

View File

@ -91,6 +91,9 @@ public class BusinessMessageHandlerListener implements BatchMessageListener {
if (oldObject.getString(wellStatusKey) != null && (!oldObject.getString(wellStatusKey).equals(newObject.getString(wellStatusKey)))) {
deviceWellStatusMap.put(Long.valueOf(deviceId), newObject.getInteger(wellStatusKey));
if(null==newObject.getInteger(wellStatusKey)){
continue;
}
//记录开关井状态及对应的套压油压数据
SwitchStatusExport switchStatusExport = new SwitchStatusExport();
switchStatusExport.setId(snowflakeConfig.snowflakeId());
@ -98,6 +101,7 @@ public class BusinessMessageHandlerListener implements BatchMessageListener {
switchStatusExport.setProductName(device.getProduct().getName());
switchStatusExport.setCasPressure(newObject.getString("casPressure"));
switchStatusExport.setOilPressure(newObject.getString("oilPressure"));
switchStatusExport.setBlockId(device.getGasWell().getBlockId());
if (newObject.getInteger(wellStatusKey)!=null){
switchStatusExport.setSwitchStatus(newObject.getInteger(wellStatusKey) == 1 ? "开井" : "关井");
}

View File

@ -16,7 +16,7 @@ import java.util.Map;
public interface DeviceService extends IService<Device> {
Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId);
Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product);
void add(DeviceCreateDTO deviceCreateDTO);

View File

@ -7,6 +7,6 @@ import java.util.List;
public interface SwitchStatusExportService extends IService<SwitchStatusExport> {
List<SwitchStatusExport> getSwitchStatusExport(String startTime, String endTime);
List<SwitchStatusExport> getSwitchStatusExport(String startTime, String endTime, Long departmentId);
}

View File

@ -1,11 +1,13 @@
package com.isu.gaswellwatch.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isu.gaswellwatch.config.SnowflakeConfig;
import com.isu.gaswellwatch.constants.UserConstant;
import com.isu.gaswellwatch.dao.DeviceDao;
import com.isu.gaswellwatch.dto.DeviceCreateDTO;
import com.isu.gaswellwatch.dto.DeviceEditDTO;
@ -59,10 +61,12 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
private CacheService cacheService;
@Resource
private SwitchStatusExportService switchStatusExportService;
@Resource
private UserService userService;
@Override
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId) {
Page<DeviceVO> page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, deviceTypeId, blockId);
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product) {
Page<DeviceVO> page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, deviceTypeId, blockId,product);
List<DeviceVO> deviceVOList = page.getRecords();
// 从Redis获取设备运行数据
if (CollectionUtil.isNotEmpty(deviceVOList)) {
@ -83,6 +87,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
Object prePressure = this.redisTemplate.opsForHash().get(deviceKey, "prePressure");
deviceVO.setPrePressure(prePressure == null ? "" : prePressure.toString());
Object voltage = this.redisTemplate.opsForHash().get(deviceKey, "batteryVoltage");
deviceVO.setVoltage(voltage == null ? "" : voltage.toString());
Object online = this.redisTemplate.opsForHash().get(deviceKey, "online");
deviceVO.setOnline(online == null ? "" : online.toString());
@ -278,7 +285,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
@Override
public void exportSwitchStatusData(HttpServletResponse response, String startTime, String endTime) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<SwitchStatusExport> list = switchStatusExportService.getSwitchStatusExport(startTime, endTime);
UserLoginInfoVO userLoginInfoVO = (UserLoginInfoVO) StpUtil.getTokenSession().get(UserConstant.TOKEN_SESSION);
UserVO userVO = userService.selectUserInfo(userLoginInfoVO.getUserVO().getUsername());
List<SwitchStatusExport> list = switchStatusExportService.getSwitchStatusExport(startTime, endTime,userVO.getDepartment().getId());
List<SwitchStatusExportVO> export = ConverterUtil.convert(list, SwitchStatusExportVO.class);

View File

@ -80,7 +80,10 @@ public class SummaryServiceImpl implements SummaryService {
Integer onLineCount = 0;
Integer offLineCount = 0;
for(DeviceVO deviceVO : deviceVOList){
List<DeviceVO> allDeviceVOList = deviceService.getDeviceVOByIds(null);
for(DeviceVO deviceVO : allDeviceVOList){
if("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))){
onLineCount++;
}else {

View File

@ -5,7 +5,6 @@ import com.isu.gaswellwatch.dao.SwitchStatusExportDao;
import com.isu.gaswellwatch.service.SwitchStatusExportService;
import com.isu.gaswellwatch.vo.SwitchStatusExport;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -19,8 +18,8 @@ public class SwitchStatusExportServiceImpl extends ServiceImpl<SwitchStatusExpor
private SwitchStatusExportDao switchStatusExportDao;
@Override
public List<SwitchStatusExport> getSwitchStatusExport(String startTime, String endTime) {
return switchStatusExportDao.getSwitchStatusExport(startTime, endTime);
public List<SwitchStatusExport> getSwitchStatusExport(String startTime, String endTime, Long departmentId) {
return switchStatusExportDao.getSwitchStatusExport(startTime, endTime,departmentId);
}
}

View File

@ -73,5 +73,7 @@ public class DeviceVO extends Model<DeviceVO> {
/** 生产状态 */
private String wellStatus;
/** 电压 */
private String voltage;
}

View File

@ -51,6 +51,11 @@ public class SwitchStatusExport extends Model<SwitchStatusExport> {
*/
private String switchStatus;
/**
* 区块ID
*/
private Long blockId;
/**
* 创建时间
*/

View File

@ -48,6 +48,9 @@
<if test="deviceTypeId!=null and deviceTypeId!='' ">
and u.device_type = #{deviceTypeId}
</if>
<if test="product!=null">
and u.product = #{product}
</if>
<if test="blockId!=null and blockId!='' ">
and g.block_id = #{blockId}
</if>
@ -102,10 +105,14 @@
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
u.gas_well, u.details, u.create_time, u.update_time
from device u
where u.id in
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
<where>
<if test="idList!=null and idList.size()>0">
u.id in
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</select>
<select id="getPressureChartData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">

View File

@ -10,15 +10,16 @@
</where>
</delete>
<select id="getSwitchStatusExport" resultType="com.isu.gaswellwatch.vo.SwitchStatusExport">
select * from switch_status_export
select s.* from switch_status_export s join block_department b on s.block_id = b.block_id
<where>
b.department_id = #{departmentId}
<if test="startTime != null and startTime != ''">
and create_time &gt;= #{startTime}
and s.create_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and create_time &lt;= #{endTime}
and s.create_time &lt;= #{endTime}
</if>
</where> order by create_time desc
</where> order by s.create_time desc
</select>
</mapper>