灌溉器历史数据和流量计历史数据的列表接口和导出接口添加时间筛选;添加灌溉控制器瞬时流量和累计流量的图表接口

This commit is contained in:
童丽然 2025-01-02 14:12:48 +08:00
parent 24344e870a
commit 17dadbf393
18 changed files with 405 additions and 18 deletions

View File

@ -3,6 +3,7 @@ package com.fastbee.data.controller.userRecharge;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.fastbee.iot.domain.dto.NgFlowDeviceDataDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -41,10 +42,10 @@ public class NgFlowDeviceDataController extends BaseController
// @PreAuthorize("@ss.hasPermi('rechargecard:data:list')")
@GetMapping("/list")
@ApiOperation("查询流量计设备数据列表")
public TableDataInfo list(NgFlowDeviceData ngFlowDeviceData)
public TableDataInfo list(NgFlowDeviceDataDto ngFlowDeviceData)
{
startPage();
List<NgFlowDeviceData> list = ngFlowDeviceDataService.selectNgFlowDeviceDataList(ngFlowDeviceData);
List<NgFlowDeviceData> list = ngFlowDeviceDataService.selectNgFlowDeviceDataListByTime(ngFlowDeviceData);
return getDataTable(list);
}
@ -54,9 +55,9 @@ public class NgFlowDeviceDataController extends BaseController
@ApiOperation("导出流量计设备数据列表")
// @PreAuthorize("@ss.hasPermi('rechargecard:data:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, NgFlowDeviceData ngFlowDeviceData)
public void export(HttpServletResponse response, NgFlowDeviceDataDto ngFlowDeviceData)
{
List<NgFlowDeviceData> list = ngFlowDeviceDataService.selectNgFlowDeviceDataList(ngFlowDeviceData);
List<NgFlowDeviceData> list = ngFlowDeviceDataService.selectNgFlowDeviceDataListByTime(ngFlowDeviceData);
ExcelUtil<NgFlowDeviceData> util = new ExcelUtil<NgFlowDeviceData>(NgFlowDeviceData.class);
util.exportExcel(response, list, "流量计设备数据数据");
}

View File

@ -1,8 +1,11 @@
package com.fastbee.data.controller.userRecharge;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.fastbee.rechargecard.domain.dto.NgWaterPumpUsageRecordsChartsDto;
import com.fastbee.rechargecard.domain.dto.NgWaterPumpUsageRecordsDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@ -38,16 +41,27 @@ public class NgWaterPumpUsageRecordsController extends BaseController
@Autowired
private INgWaterPumpUsageRecordsService ngWaterPumpUsageRecordsService;
/**
* 灌溉控制器瞬时流量的图表
*/
// @PreAuthorize("@ss.hasPermi('rechargecard:records:list')")
@GetMapping("/charts/insFlow")
@ApiOperation("灌溉控制器瞬时流量的图表")
public AjaxResult insFlowCharts(@RequestBody NgWaterPumpUsageRecordsChartsDto ngWaterPumpUsageRecordsChartsDto)
{
return success(ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageRecordsInsFlowCharts(ngWaterPumpUsageRecordsChartsDto.getDeviceNumber(),ngWaterPumpUsageRecordsChartsDto.getStartTime(),ngWaterPumpUsageRecordsChartsDto.getEndTime()));
}
/**
* 查询水泵设备使用记录列表
*/
// @PreAuthorize("@ss.hasPermi('rechargecard:records:list')")
@GetMapping("/list")
@ApiOperation("查询水泵设备使用记录列表")
public TableDataInfo list(NgWaterPumpUsageRecords ngWaterPumpUsageRecords)
public TableDataInfo list(NgWaterPumpUsageRecordsDto ngWaterPumpUsageRecords)
{
startPage();
List<NgWaterPumpUsageRecords> list = ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageRecordsList(ngWaterPumpUsageRecords);
List<NgWaterPumpUsageRecords> list = ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageRecordsListByTime(ngWaterPumpUsageRecords);
return getDataTable(list);
}
@ -55,11 +69,11 @@ public class NgWaterPumpUsageRecordsController extends BaseController
* 导出水泵设备使用记录列表
*/
@ApiOperation("导出水泵设备使用记录列表")
@PreAuthorize("@ss.hasPermi('rechargecard:records:export')")
//@PreAuthorize("@ss.hasPermi('rechargecard:records:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, NgWaterPumpUsageRecords ngWaterPumpUsageRecords)
public void export(HttpServletResponse response, NgWaterPumpUsageRecordsDto ngWaterPumpUsageRecords)
{
List<NgWaterPumpUsageRecords> list = ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageRecordsList(ngWaterPumpUsageRecords);
List<NgWaterPumpUsageRecords> list = ngWaterPumpUsageRecordsService.selectNgWaterPumpUsageRecordsListByTime(ngWaterPumpUsageRecords);
ExcelUtil<NgWaterPumpUsageRecords> util = new ExcelUtil<NgWaterPumpUsageRecords>(NgWaterPumpUsageRecords.class);
util.exportExcel(response, list, "水泵设备使用记录数据");
}

View File

@ -84,7 +84,7 @@ public class UserIrrigationRecordController extends BaseController
userIrrigationRecord.setSearchEndTime(calendar.getTime());
}
List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordListByTime(userIrrigationRecord);
List<UserIrrigationRecordListDto> list = userIrrigationRecordService.selectUserIrrigationRecordListByTime(userIrrigationRecord);
return getDataTable(list);
}
@ -159,9 +159,9 @@ public class UserIrrigationRecordController extends BaseController
userIrrigationRecord.setSearchEndTime(calendar.getTime());
}
List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordListByTime(userIrrigationRecord);
List<UserIrrigationRecordListDto> list = userIrrigationRecordService.selectUserIrrigationRecordListByTime(userIrrigationRecord);
//List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordList(userIrrigationRecord);
ExcelUtil<UserIrrigationRecord> util = new ExcelUtil<UserIrrigationRecord>(UserIrrigationRecord.class);
ExcelUtil<UserIrrigationRecordListDto> util = new ExcelUtil<UserIrrigationRecordListDto>(UserIrrigationRecordListDto.class);
util.exportExcel(response, list, "灌溉记录数据");
}

View File

@ -0,0 +1,54 @@
package com.fastbee.iot.domain.dto;
import com.fastbee.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class NgFlowDeviceDataDto {
private Long id;
/** shun'shi */
@Excel(name = "shun'shi")
@ApiModelProperty("shun'shi")
private String inFlow;
/** 累计流量 */
@Excel(name = "累计流量")
@ApiModelProperty("累计流量")
private String sumFlow;
/** 设备编码 */
@Excel(name = "设备编码")
@ApiModelProperty("设备编码")
private String deviceNumber;
/** 实时时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "实时时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("实时时间")
private Date realTime;
/** 设备状态 0未启用1离线2在线 */
@Excel(name = "设备状态 0未启用1离线2在线")
@ApiModelProperty("设备状态 0未启用1离线2在线")
private Long status;
/** 保存时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "保存时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("保存时间")
private Date saveTime;
/** ji'gou */
@Excel(name = "ji'gou")
@ApiModelProperty("ji'gou")
private Long deptId;
/** 时间选择器开始时间*/
private Date startTime;
/**时间选择器结束时间*/
private Date endTime;
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.iot.domain.NgFlowDeviceData;
import com.fastbee.iot.domain.dto.NgFlowDeviceDataDto;
import org.apache.ibatis.annotations.Mapper;
/**
@ -15,6 +16,13 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface NgFlowDeviceDataMapper extends BaseMapper<NgFlowDeviceData>
{
/**
* 根据时间查询流量计历史数据
* @param ngFlowDeviceDataDto
* @return
*/
public List<NgFlowDeviceData> selectNgFlowDeviceDataListByTime(NgFlowDeviceDataDto ngFlowDeviceDataDto);
/**
* 查询流量计设备数据
*

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fastbee.iot.domain.NgFlowDeviceData;
import com.fastbee.iot.domain.dto.NgFlowDeviceDataDto;
/**
* 流量计设备数据Service接口
@ -13,6 +14,14 @@ import com.fastbee.iot.domain.NgFlowDeviceData;
*/
public interface INgFlowDeviceDataService extends IService<NgFlowDeviceData>
{
/**
* 查询流量计设备数据列表
*
* @param ngFlowDeviceData 流量计设备数据
* @return 流量计设备数据集合
*/
public List<NgFlowDeviceData> selectNgFlowDeviceDataListByTime(NgFlowDeviceDataDto ngFlowDeviceData);
/**
* 查询流量计设备数据
*

View File

@ -1,10 +1,13 @@
package com.fastbee.iot.service.impl;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fastbee.deviceData.domain.DeviceRealtimedataMeteorology;
import com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper;
import com.fastbee.iot.domain.dto.NgFlowDeviceDataDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.iot.mapper.NgFlowDeviceDataMapper;
@ -23,6 +26,28 @@ public class NgFlowDeviceDataServiceImpl extends ServiceImpl<NgFlowDeviceDataMap
@Autowired
private NgFlowDeviceDataMapper ngFlowDeviceDataMapper;
/**
* 根据时间查询流量计历史数据
* @param ngFlowDeviceData 流量计设备数据
* @return
*/
@Override
public List<NgFlowDeviceData> selectNgFlowDeviceDataListByTime(NgFlowDeviceDataDto ngFlowDeviceData) {
if(ngFlowDeviceData.getStartTime() != null && ngFlowDeviceData.getEndTime() != null)
{
//设置结束时间加一天
Date searchEndTime = ngFlowDeviceData.getEndTime();
// 使用 Calendar 给日期加一天
Calendar calendar = Calendar.getInstance();
calendar.setTime(searchEndTime);
calendar.add(Calendar.DATE, 1); // 给日期加一天
// 将计算后的日期设置回 userIrrigationRecord 对象
ngFlowDeviceData.setEndTime(calendar.getTime());
}
return ngFlowDeviceDataMapper.selectNgFlowDeviceDataListByTime(ngFlowDeviceData);
}
/**
* 查询流量计设备数据
*

View File

@ -19,6 +19,21 @@
select id, in_flow, sum_flow, device_number, real_time, status, save_time, dept_id from ng_flow_device_data
</sql>
<select id="selectNgFlowDeviceDataListByTime" parameterType="NgFlowDeviceDataDto" resultMap="NgFlowDeviceDataResult">
<include refid="selectNgFlowDeviceDataVo"/>
<where>
<if test="startTime != null and endTime != null"> and real_time between #{startTime} and #{endTime}</if>
<if test="inFlow != null "> and in_flow = #{inFlow}</if>
<if test="sumFlow != null and sumFlow != ''"> and sum_flow = #{sumFlow}</if>
<if test="deviceNumber != null and deviceNumber != ''"> and device_number = #{deviceNumber}</if>
<if test="realTime != null "> and real_time = #{realTime}</if>
<if test="status != null "> and status = #{status}</if>
<if test="saveTime != null "> and save_time = #{saveTime}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
</where>
order by real_time desc
</select>
<select id="selectNgFlowDeviceDataList" parameterType="NgFlowDeviceData" resultMap="NgFlowDeviceDataResult">
<include refid="selectNgFlowDeviceDataVo"/>
<where>

View File

@ -0,0 +1,11 @@
package com.fastbee.rechargecard.domain.dto;
import lombok.Data;
import java.util.Date;
@Data
public class NgWaterPumpUsageRecordsChartsDto {
private String deviceNumber;
private Date startTime;
private Date endTime;
}

View File

@ -0,0 +1,71 @@
package com.fastbee.rechargecard.domain.dto;
import com.fastbee.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class NgWaterPumpUsageRecordsDto {
private Long id;
/** 开泵时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "开泵时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("开泵时间")
private Date pumpStartTime;
/** 关泵时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "关泵时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("关泵时间")
private Date pumpStopTime;
/** 设备编号 */
@Excel(name = "设备编号")
@ApiModelProperty("设备编号")
private String deviceNumber;
/** 报文内容 */
@Excel(name = "报文内容")
@ApiModelProperty("报文内容")
private String messageContent;
/** 瞬时流量 */
@Excel(name = "瞬时流量")
@ApiModelProperty("瞬时流量")
private String insFlow;
/** 累计流量 */
@Excel(name = "累计流量")
@ApiModelProperty("累计流量")
private String sumFlow;
/** 实时时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "实时时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("实时时间")
private Date realTime;
/** 保存时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "保存时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("保存时间")
private Date saveTime;
/** 累计用电量 */
@Excel(name = "累计用电量")
@ApiModelProperty("累计用电量")
private String sumEle;
/** 瞬时功率 */
@Excel(name = "瞬时功率")
@ApiModelProperty("瞬时功率")
private String insPower;
//时间筛选开始时间
private Date startTime;
//时间筛选结束时间
private Date endTime;
}

View File

@ -18,4 +18,5 @@ public class UserIrrigationRecordDto
public Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:MM:SS")
public Date endTime;
public String deviceNumber;
}

View File

@ -110,4 +110,5 @@ public class UserIrrigationRecordListDto {
*/
private Date searchStartTime;
private Date searchEndTime;
private String userName;
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
import com.fastbee.rechargecard.domain.dto.NgWaterPumpUsageRecordsDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@ -16,6 +17,13 @@ import org.apache.ibatis.annotations.Select;
@Mapper
public interface NgWaterPumpUsageRecordsMapper extends BaseMapper<NgWaterPumpUsageRecords>
{
/**
* 查询水泵设备使用记录列表
*
* @param ngWaterPumpUsageRecords 水泵设备使用记录
* @return 水泵设备使用记录集合
*/
public List<NgWaterPumpUsageRecords> selectNgWaterPumpUsageRecordsListByTime(NgWaterPumpUsageRecordsDto ngWaterPumpUsageRecords);
/**
* 查询水泵设备使用记录
*

View File

@ -1,8 +1,12 @@
package com.fastbee.rechargecard.service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
import com.fastbee.rechargecard.domain.dto.NgWaterPumpUsageRecordsDto;
/**
* 水泵设备使用记录Service接口
@ -12,6 +16,20 @@ import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
*/
public interface INgWaterPumpUsageRecordsService
{
/**
* 灌溉控制器瞬时流量图表
* @param deviceNumber
* @return
*/
public Map<String,Object> selectNgWaterPumpUsageRecordsInsFlowCharts(String deviceNumber, Date startTime,Date endTime);
/**
* 可根据时间段 查询水泵设备使用记录列表
*
* @param ngWaterPumpUsageRecords 水泵设备使用记录
* @return 水泵设备使用记录集合
*/
public List<NgWaterPumpUsageRecords> selectNgWaterPumpUsageRecordsListByTime(NgWaterPumpUsageRecordsDto ngWaterPumpUsageRecords);
/**
* 查询水泵设备使用记录
*

View File

@ -29,7 +29,7 @@ public interface IUserIrrigationRecordService
* @param userIrrigationRecord 灌溉记录
* @return 灌溉记录集合
*/
public List<UserIrrigationRecord> selectUserIrrigationRecordListByTime(UserIrrigationRecordListDto userIrrigationRecord);
public List<UserIrrigationRecordListDto> selectUserIrrigationRecordListByTime(UserIrrigationRecordListDto userIrrigationRecord);
/**

View File

@ -1,14 +1,21 @@
package com.fastbee.rechargecard.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.common.utils.json.JsonStrUtil;
import com.fastbee.common.utils.json.JsonUtils;
import com.fastbee.iot.mapper.DeviceMapper;
import com.fastbee.rechargecard.domain.NgUserRechargeRecords;
import com.fastbee.rechargecard.domain.dto.NgWaterPumpUsageRecordsDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper;
@ -29,6 +36,98 @@ public class NgWaterPumpUsageRecordsServiceImpl implements INgWaterPumpUsageReco
@Autowired
private DeviceMapper deviceMapper;
@Override
public Map<String, Object> selectNgWaterPumpUsageRecordsInsFlowCharts(String deviceNumber,Date startTime,Date endTime) {
QueryWrapper<NgWaterPumpUsageRecords> queryWrapper=new QueryWrapper<>();
Map<String,Object> resultMap=new HashMap<>();
List<BigDecimal> insList=new ArrayList<>();
List<BigDecimal> sumList=new ArrayList<>();
List<String> timeList=new ArrayList<>();
Date start = DateUtil.beginOfDay(DateUtil.date());// 获取今日零点时间
Date now = DateUtil.date();// 获取当前时间
// 获取当前整点时刻的时间
Date end = DateUtil.beginOfHour(now);//用当前整点时刻时间作为结束时间
if (startTime != null && endTime != null) {
//如果有时间筛选按照时间筛选为起止时间
start=startTime;
end=endTime;
}
queryWrapper.between("real_time", start, end);
queryWrapper.eq("device_number",deviceNumber);
List<NgWaterPumpUsageRecords> list=ngWaterPumpUsageRecordsMapper.selectList(queryWrapper);//获取根据时间和设备编码筛选后的数据
while(start.compareTo(end) <=0 )//start<=end
{
//整点时间数据=前半个小时到后半个小时的平均数据即12点数据=11:30到1230的平均值
Date tempStart=DateUtil.offsetMinute(start,-30);//前半个小时时间
Date tempEnd=DateUtil.offsetMinute(start,30);//后半个小时时间
if(tempEnd.after(now))
{
tempEnd=now;//用来处理当前是1210但需要获取12点数据的情况
}
BigDecimal insData=new BigDecimal("0");//瞬时流量总和
BigDecimal sumData=new BigDecimal("0");//累计流量总和
int num=0;
for(int i=0;i<list.size();i++)
{
NgWaterPumpUsageRecords temp=list.get(i);
//如果时间符合条件
if(temp.getRealTime().compareTo(tempStart)>=0 && temp.getRealTime().compareTo(tempEnd)<=0)
{
BigDecimal insFlow=new BigDecimal(temp.getInsFlow());//瞬时流量
insData=insData.add(insFlow);
BigDecimal sumFlow=new BigDecimal(temp.getSumFlow());//累计流量
sumData=sumData.add(sumFlow);
num++;
}
}
BigDecimal insResult=new BigDecimal("0");
BigDecimal sumResult=new BigDecimal("0");
if(num>0)
{
insResult = insData.divide(new BigDecimal(String.valueOf(num)), 2, RoundingMode.HALF_UP);//计算瞬时流量平均值
sumResult=sumData.divide(new BigDecimal(String.valueOf(num)),2,RoundingMode.HALF_UP);//计算累计流量平均值
}
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");//格式化为时
String formattedDate = sdf.format(start);
timeList.add(formattedDate);
insList.add(insResult);
sumList.add(sumResult);
start=DateUtil.offsetHour(start,1);//start添加一个小时
}
resultMap.put("time",timeList);
resultMap.put("insFlow",insList);
resultMap.put("sumFlow",sumList);
return resultMap;
}
/**
* 可根据时间段筛选灌溉控制器历史数据
* @param ngWaterPumpUsageRecords 水泵设备使用记录
* @return
*/
@Override
public List<NgWaterPumpUsageRecords> selectNgWaterPumpUsageRecordsListByTime(NgWaterPumpUsageRecordsDto ngWaterPumpUsageRecords) {
if(ngWaterPumpUsageRecords.getStartTime() != null && ngWaterPumpUsageRecords.getEndTime() != null)
{
//设置结束时间加一天
Date searchEndTime = ngWaterPumpUsageRecords.getEndTime();
// 使用 Calendar 给日期加一天
Calendar calendar = Calendar.getInstance();
calendar.setTime(searchEndTime);
calendar.add(Calendar.DATE, 1); // 给日期加一天
// 将计算后的日期设置回 userIrrigationRecord 对象
ngWaterPumpUsageRecords.setEndTime(calendar.getTime());
}
return ngWaterPumpUsageRecordsMapper.selectNgWaterPumpUsageRecordsListByTime(ngWaterPumpUsageRecords);
}
/**
* 查询水泵设备使用记录
*

View File

@ -89,8 +89,42 @@ public class UserIrrigationRecordServiceImpl implements IUserIrrigationRecordSer
}
@Override
public List<UserIrrigationRecord> selectUserIrrigationRecordListByTime(UserIrrigationRecordListDto userIrrigationRecord) {
return userIrrigationRecordMapper.selectUserIrrigationRecordListByTime(userIrrigationRecord);
public List<UserIrrigationRecordListDto> selectUserIrrigationRecordListByTime(UserIrrigationRecordListDto userIrrigationRecord) {
List<UserIrrigationRecord> list = userIrrigationRecordMapper.selectUserIrrigationRecordListByTime(userIrrigationRecord);
List<UserIrrigationRecordListDto> result=new ArrayList<>();
for(int i=0;i<list.size();i++)
{
UserIrrigationRecordListDto temp=new UserIrrigationRecordListDto();
temp.setId(list.get(i).getId());
if(list.get(i).getUserId()!=null)
{
temp.setUserId(list.get(i).getUserId());
temp.setUserName(sysUserMapper.selectUserById(list.get(i).getUserId()).getUserName()==null ? "" :sysUserMapper.selectUserById(list.get(i).getUserId()).getUserName());
}
temp.setDeviceNumber(list.get(i).getDeviceNumber());
temp.setProjectId(list.get(i).getProjectId());
temp.setDeptId(list.get(i).getDeptId());
temp.setCardNumber(list.get(i).getCardNumber());
temp.setAreaCode(list.get(i).getAreaCode());
temp.setCurFlow(list.get(i).getCurFlow());
temp.setCurEle(list.get(i).getCurEle());
temp.setBalance(list.get(i).getBalance());
temp.setStartTime(list.get(i).getStartTime());
temp.setEndTime(list.get(i).getEndTime());
temp.setDuration(list.get(i).getDuration());
temp.setUnit(list.get(i).getUnit());
temp.setLastTime(list.get(i).getLastTime());
temp.setStatus(list.get(i).getStatus());
temp.setRemarks(list.get(i).getRemarks());
temp.setOpenCumFlow(list.get(i).getOpenCumFlow());
temp.setCloseCumFlow(list.get(i).getCloseCumFlow());
result.add(temp);
}
return result;
}
@Override
@ -145,6 +179,7 @@ public class UserIrrigationRecordServiceImpl implements IUserIrrigationRecordSer
temp.deviceName=ngIrrigationControllersMapper.selectNgIrrigationControllersBySerialNumber(list.get(i).getDeviceNumber()).getControllerName() == null ? "":ngIrrigationControllersMapper.selectNgIrrigationControllersBySerialNumber(list.get(i).getDeviceNumber()).getControllerName();
}
temp.deviceNumber=list.get(i).getDeviceNumber();
temp.cardNumber=list.get(i).getCardNumber() == null ? "" : list.get(i).getCardNumber();
temp.flow=list.get(i).getCurFlow()==null ? BigDecimal.valueOf(0) :list.get(i).getCurFlow();
temp.startTime=list.get(i).getStartTime()==null ? null : list.get(i).getStartTime();

View File

@ -22,6 +22,23 @@
select id, pump_start_time, pump_stop_time, device_number, message_content, ins_flow, sum_flow, real_time, save_time, sum_ele, ins_power from ng_water_pump_usage_records
</sql>
<select id="selectNgWaterPumpUsageRecordsListByTime" parameterType="NgWaterPumpUsageRecordsDto" resultMap="NgWaterPumpUsageRecordsResult">
<include refid="selectNgWaterPumpUsageRecordsVo"/>
<where>
<if test="startTime != null and endTime != null"> and real_time between #{startTime} and #{endTime}</if>
<if test="pumpStartTime != null "> and pump_start_time = #{pumpStartTime}</if>
<if test="pumpStopTime != null "> and pump_stop_time = #{pumpStopTime}</if>
<if test="deviceNumber != null and deviceNumber != ''"> and device_number = #{deviceNumber}</if>
<if test="messageContent != null and messageContent != ''"> and message_content = #{messageContent}</if>
<if test="insFlow != null and insFlow != ''"> and ins_flow = #{insFlow}</if>
<if test="sumFlow != null and sumFlow != ''"> and sum_flow = #{sumFlow}</if>
<if test="realTime != null "> and real_time = #{realTime}</if>
<if test="saveTime != null "> and save_time = #{saveTime}</if>
<if test="sumEle != null and sumEle != ''"> and sum_ele = #{sumEle}</if>
<if test="insPower != null and insPower != ''"> and ins_power = #{insPower}</if>
</where>
</select>
<select id="selectNgWaterPumpUsageRecordsList" parameterType="NgWaterPumpUsageRecords" resultMap="NgWaterPumpUsageRecordsResult">
<include refid="selectNgWaterPumpUsageRecordsVo"/>
<where>