刷卡-灌溉逻辑+修改灌溉记录和充值记录的导出接口

This commit is contained in:
童丽然 2024-12-31 18:26:05 +08:00
parent aba6f51ea7
commit b5f1ec63d0
8 changed files with 94 additions and 12 deletions

View File

@ -6,6 +6,7 @@ import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.fastbee.common.constant.FastBeeConstant;
import com.fastbee.common.core.mq.DeviceReportBo;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.iot.domain.DeviceReportInfo;
import com.fastbee.iot.mapper.DeviceReportInfoMapper;
import com.fastbee.mq.redischannel.producer.IssueInstructionsProducer;
@ -14,6 +15,7 @@ import com.fastbee.mqttclient.PubMqttClient;
import com.fastbee.rechargecard.domain.NgUserRechargeRecords;
import com.fastbee.rechargecard.domain.NgWaterPumpUsageRecords;
import com.fastbee.rechargecard.domain.UserIrrigationRecord;
import com.fastbee.rechargecard.domain.UserRechargeCards;
import com.fastbee.rechargecard.mapper.NgUserRechargeRecordsMapper;
import com.fastbee.rechargecard.mapper.NgWaterPumpUsageRecordsMapper;
import com.fastbee.rechargecard.mapper.UserIrrigationRecordMapper;
@ -141,6 +143,8 @@ public class DeviceOtherMsgConsumer {
userIrrigationRecord.setCardNumber(cardNumber);//卡号
System.err.println("cardNumber"+cardNumber);
/*Long userId=null;
System.err.println("userId");
if(userRechargeCardsMapper.selectUserRechargeCardsByCardNumber(cardNumber)==null)
@ -166,7 +170,26 @@ public class DeviceOtherMsgConsumer {
userIrrigationRecord.setStatus(1);//状态改为灌溉中
userIrrigationRecordMapper.insertUserIrrigationRecord(userIrrigationRecord);//开阀时添加一条灌溉记录
System.out.println(userIrrigationRecord);
userIrrigationRecord.setCreateTime(DateUtils.getNowDate());
//对充值卡余额的操作
UserRechargeCards userRechargeCards = userRechargeCardsMapper.selectUserRechargeCardsByCardNumber(cardNumber);//获取充值卡信息
BigDecimal balance=dataJson.getBigDecimal("userBalance");//获取当前用户金额
userRechargeCards.setBalance(balance);//同步用户余额
int flag=userIrrigationRecordMapper.insertUserIrrigationRecord(userIrrigationRecord);//开阀时添加一条灌溉记录
if(flag<1)
{
System.err.println("灌溉记录添加失败");
}else{
flag=userRechargeCardsMapper.updateUserRechargeCards(userRechargeCards);//同步充值卡余额
if(flag<1)
{
System.err.println("充值卡金额同步失败");
}
}
}else{
System.err.println("关阀");
//关阀-修改灌溉记录修改结束时间灌溉用水量做差 关阀-开阀用户总累计流量查卡号最新一条记录
@ -192,7 +215,22 @@ public class DeviceOtherMsgConsumer {
userIrrigationRecord.setStatus(2);//灌溉状态更改为结束灌溉
userIrrigationRecordMapper.updateUserIrrigationRecord(userIrrigationRecord);
//对充值卡余额的操作
UserRechargeCards userRechargeCards = userRechargeCardsMapper.selectUserRechargeCardsByCardNumber(cardNumber);//获取充值卡信息
BigDecimal balance=dataJson.getBigDecimal("userBalance");//获取当前用户金额
userRechargeCards.setBalance(balance);//同步用户余额
int flag=userIrrigationRecordMapper.updateUserIrrigationRecord(userIrrigationRecord);//关阀时修改一条灌溉记录
if(flag<1)
{
System.err.println("灌溉记录修改失败");
}else{
flag=userRechargeCardsMapper.updateUserRechargeCards(userRechargeCards);//同步充值卡余额
if(flag<1)
{
System.err.println("充值卡金额同步失败");
}
}
}
}
@ -385,7 +423,7 @@ public class DeviceOtherMsgConsumer {
+ " \"meterStatus\": 1,"
+ " \"userSumFlow\": 640000,"
+ " \"cardId\": 402,"
+ " \"action\": \"stopPump\","
+ " \"action\": \"startPump\","
+ " \"meterSum\": 6400,"
+ " \"pumpState\": 0,"
+ " \"mcuSn\": 2147483647,"

View File

@ -65,9 +65,10 @@ public class NgUserRechargeRecordsController extends BaseController
@ApiOperation("导出用户充值记录列表")
// @PreAuthorize("@ss.hasPermi('rechargecard:records:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, NgUserRechargeRecords ngUserRechargeRecords)
public void export(HttpServletResponse response, NgUserRechargeRecordsDto ngUserRechargeRecords)
{
List<NgUserRechargeRecords> list = ngUserRechargeRecordsService.selectNgUserRechargeRecordsList(ngUserRechargeRecords);
// List<NgUserRechargeRecords> list = ngUserRechargeRecordsService.selectNgUserRechargeRecordsList(ngUserRechargeRecords);
List<NgUserRechargeRecords> list = ngUserRechargeRecordsService.selectNgUserRechargeRecordsListByTime(ngUserRechargeRecords);
ExcelUtil<NgUserRechargeRecords> util = new ExcelUtil<NgUserRechargeRecords>(NgUserRechargeRecords.class);
util.exportExcel(response, list, "用户充值记录数据");
}

View File

@ -3,8 +3,10 @@ package com.fastbee.data.controller.userRecharge;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.fastbee.common.core.domain.entity.SysUser;
import com.fastbee.rechargecard.domain.UserConsumptionDetails;
import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordDto;
import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordListDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@ -46,10 +48,10 @@ public class UserIrrigationRecordController extends BaseController
// @PreAuthorize("@ss.hasPermi('rechargecard:record:list')")
@GetMapping("/list")
@ApiOperation("查询灌溉记录列表")
public TableDataInfo list(UserIrrigationRecord userIrrigationRecord)
public TableDataInfo list(UserIrrigationRecordListDto userIrrigationRecord)
{
startPage();
List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordList(userIrrigationRecord);
List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordListByTime(userIrrigationRecord);
return getDataTable(list);
}
@ -110,9 +112,10 @@ public class UserIrrigationRecordController extends BaseController
@ApiOperation("导出灌溉记录列表")
// @PreAuthorize("@ss.hasPermi('rechargecard:record:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, UserIrrigationRecord userIrrigationRecord)
public void export(HttpServletResponse response, UserIrrigationRecordListDto userIrrigationRecord)
{
List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordList(userIrrigationRecord);
List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordListByTime(userIrrigationRecord);
//List<UserIrrigationRecord> list = userIrrigationRecordService.selectUserIrrigationRecordList(userIrrigationRecord);
ExcelUtil<UserIrrigationRecord> util = new ExcelUtil<UserIrrigationRecord>(UserIrrigationRecord.class);
util.exportExcel(response, list, "灌溉记录数据");
}

View File

@ -3,10 +3,11 @@ 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.math.BigDecimal;
import java.util.Date;
@Data
public class UserIrrigationRecordListDto {
/** 序号 */
private Long id;

View File

@ -2,6 +2,7 @@ package com.fastbee.rechargecard.mapper;
import java.util.List;
import com.fastbee.rechargecard.domain.UserIrrigationRecord;
import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordListDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@ -14,6 +15,12 @@ import org.apache.ibatis.annotations.Select;
@Mapper
public interface UserIrrigationRecordMapper
{
/**
* 根据时间段获取灌溉记录列表
* @param userIrrigationRecordListDto
* @return
*/
public List<UserIrrigationRecord> selectUserIrrigationRecordListByTime(UserIrrigationRecordListDto userIrrigationRecordListDto);
/**
* 根据卡号和设备编码获取最新的灌溉中的灌溉记录
* @param cardNumber

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.fastbee.rechargecard.domain.UserConsumptionDetails;
import com.fastbee.rechargecard.domain.UserIrrigationRecord;
import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordDto;
import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordListDto;
/**
* 灌溉记录Service接口
@ -19,8 +20,8 @@ public interface IUserIrrigationRecordService
*
* @param userIrrigationRecord 灌溉记录
* @return 灌溉记录集合
*//*
public List<UserIrrigationRecord> selectUserIrrigationRecordListByTime(UserIrrigationRecord userIrrigationRecord);*/
*/
public List<UserIrrigationRecord> selectUserIrrigationRecordListByTime(UserIrrigationRecordListDto userIrrigationRecord);
/**

View File

@ -8,6 +8,7 @@ import com.fastbee.iot.mapper.DeviceMapper;
import com.fastbee.rechargecard.domain.NgIrrigationControllers;
import com.fastbee.rechargecard.domain.UserConsumptionDetails;
import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordDto;
import com.fastbee.rechargecard.domain.dto.UserIrrigationRecordListDto;
import com.fastbee.rechargecard.mapper.NgIrrigationControllersMapper;
import com.fastbee.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,6 +34,10 @@ public class UserIrrigationRecordServiceImpl implements IUserIrrigationRecordSer
private NgIrrigationControllersMapper ngIrrigationControllersMapper;
@Override
public List<UserIrrigationRecord> selectUserIrrigationRecordListByTime(UserIrrigationRecordListDto userIrrigationRecord) {
return userIrrigationRecordMapper.selectUserIrrigationRecordListByTime(userIrrigationRecord);
}
@Override
public List<UserIrrigationRecordDto> selectUserIrrigationRecordShowListByCardNumber(UserIrrigationRecord userIrrigationRecord) {

View File

@ -34,6 +34,32 @@
select id, user_id, device_number, project_id, dept_id, card_number, area_code, cur_flow, cur_ele, balance, start_time, end_time, duration, unit, last_time, status, remarks, create_time, update_time, create_by, update_by,open_cum_flow,close_cum_flow from user_irrigation_record
</sql>
<select id="selectUserIrrigationRecordListByTime" parameterType="UserIrrigationRecordDto" resultMap="UserIrrigationRecordResult">
<include refid="selectUserIrrigationRecordVo"/>
<where>
<if test="searchStartTime !=null and searchEndTime !=null"> end_time between #{searchStartTime} and #{searchEndTime}</if>
<if test="id != null "> and id = #{id}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="deviceNumber != null and deviceNumber != ''"> and device_number = #{deviceNumber}</if>
<if test="projectId != null "> and project_id = #{projectId}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="cardNumber != null and cardNumber != ''"> and card_number = #{cardNumber}</if>
<if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode}</if>
<if test="curFlow != null "> and cur_flow = #{curFlow}</if>
<if test="curEle != null "> and cur_ele = #{curEle}</if>
<if test="balance != null "> and balance = #{balance}</if>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<if test="duration != null "> and duration = #{duration}</if>
<if test="unit != null "> and unit = #{unit}</if>
<if test="lastTime != null "> and last_time = #{lastTime}</if>
<if test="status != null "> and status = #{status}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
<if test="openCumFlow != null "> and open_cum_flow = #{openCumFlow}</if>
<if test="closeCumFlow != null "> and close_cum_flow = #{closeCumFlow}</if>
</where>
</select>
<select id="selectUserIrrigationRecordList" parameterType="UserIrrigationRecord" resultMap="UserIrrigationRecordResult">
<include refid="selectUserIrrigationRecordVo"/>
<where>