监控电量订单结束时间
This commit is contained in:
parent
8070a2a7e6
commit
0a144abd3e
|
@ -332,4 +332,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||
}
|
||||
return LocalDateTime.parse(time, DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
|
||||
public static LocalDateTime toLocalDateTime(String time) {
|
||||
return toLocalDateTime(time, YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.ruoyi.iot.service.IotReceiveService;
|
|||
import com.ruoyi.iot.service.IotService;
|
||||
import com.ruoyi.ss.device.domain.Device;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceOutageWay;
|
||||
import com.ruoyi.ss.device.domain.enums.DevicePowerStatus;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
|
||||
|
@ -67,12 +68,41 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
// 恢复总用电量
|
||||
this.recoverTotalEle(msg);
|
||||
}
|
||||
// 开关状态
|
||||
else if (ReceiveConstants.DS_S.equals(msg.getDsId())) {
|
||||
// 同步订单状态
|
||||
this.syncOrderStatus(msg);
|
||||
}
|
||||
}
|
||||
// 生命周期
|
||||
else if (ReceiveType.DEVICE_STATUS.getType().equals(msg.getType())) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当开关状态为关闭,则同步订单状态
|
||||
*/
|
||||
private void syncOrderStatus(ReceiveMsg msg) {
|
||||
if (msg == null || StringUtils.isBlank(msg.getDevName())) {
|
||||
return;
|
||||
}
|
||||
// 开关不是断电状态,则忽略
|
||||
if (!DevicePowerStatus.OFF.getStatus().equals(msg.getValue())) {
|
||||
return;
|
||||
}
|
||||
log.info("{} 开关状态为 {}", msg.getDevName(), msg.getValue());
|
||||
|
||||
DeviceVO device = deviceService.selectByAnyMac(msg.getDevName());
|
||||
if (device == null) {
|
||||
log.error("设备:{} 不存在", msg.getDevName());
|
||||
return;
|
||||
}
|
||||
// 拉取一下设备信息
|
||||
deviceService.pullDeviceInfo(device);
|
||||
|
||||
// 查询
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复异常的总用电量
|
||||
* @param msg
|
||||
|
@ -81,7 +111,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
// 查询设备
|
||||
DeviceVO device = deviceService.selectByAnyMac(msg.getDevName());
|
||||
if (device == null) {
|
||||
log.info("设备:{} 不存在", msg.getDevName());
|
||||
log.error("设备:{} 不存在", msg.getDevName());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -215,4 +215,5 @@ public interface TransactionBillMapper
|
|||
* 按日查询金额
|
||||
*/
|
||||
List<TransactionDailyAmountVO> selectDailyAmount(@Param("query") TransactionBillQuery query);
|
||||
|
||||
}
|
||||
|
|
|
@ -346,4 +346,9 @@ public interface TransactionBillService
|
|||
* 按日查询订单金额
|
||||
*/
|
||||
List<TransactionDailyAmountVO> selectDailyAmount(TransactionBillQuery query);
|
||||
|
||||
/**
|
||||
* 更新结束时间
|
||||
*/
|
||||
int batchUpdateSuitEndTime(List<Long> billIds, LocalDateTime time);
|
||||
}
|
||||
|
|
|
@ -442,6 +442,11 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
return transactionBillMapper.selectDailyAmount(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchUpdateSuitEndTime(List<Long> billIds, LocalDateTime time) {
|
||||
return transactionBillMapper.batchUpdateSuitEndTime(billIds, time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> selectCountGroupBy(TransactionBillQuery query, String groupBy) {
|
||||
return transactionBillMapper.selectCountGroupBy(query, groupBy);
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package com.ruoyi.task.bill;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.iot.domain.IotDeviceInfo;
|
||||
import com.ruoyi.iot.service.IotService;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus;
|
||||
import com.ruoyi.ss.suit.domain.enums.SuitFeeMode;
|
||||
import com.ruoyi.ss.suit.domain.enums.SuitFeeType;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.bo.EndUseBO;
|
||||
import com.ruoyi.ss.transactionBill.domain.dto.EndUseDTO;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
import com.ruoyi.system.domain.enums.config.ConfigKey;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -22,6 +20,8 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BillLowPowerTask {
|
||||
public class BillMonitorTask {
|
||||
|
||||
@Autowired
|
||||
private TransactionBillService transactionBillService;
|
||||
|
@ -43,7 +43,7 @@ public class BillLowPowerTask {
|
|||
/**
|
||||
* 关闭低功率的订单
|
||||
*/
|
||||
public void autoClose() {
|
||||
public void autoCloseLowPower() {
|
||||
// 获取关闭冷却时间
|
||||
int cd = sysConfigService.getInt(ConfigKey.ORDER_AUTO_CLOSE_CD);
|
||||
LocalDateTime createTimeEnd = LocalDateTime.now().minusMinutes(cd); // 获取冷却时间之前的时间
|
||||
|
@ -90,4 +90,26 @@ public class BillLowPowerTask {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新电量订单结束时间
|
||||
*/
|
||||
public void updateEleFinishTime(String startTime) {
|
||||
// 查询指定时间后已结束的电量订单
|
||||
TransactionBillQuery query = new TransactionBillQuery();
|
||||
query.setType(TransactionBillType.RECHARGE.getType());
|
||||
query.setCreateTimeStart(DateUtils.toLocalDateTime(startTime));
|
||||
query.setIsFinished(true);
|
||||
query.setSuitFeeType(SuitFeeType.COUNT.getType());
|
||||
List<TransactionBillVO> list = transactionBillService.selectSmTransactionBillList(query);
|
||||
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
log.info("暂无结束的电量订单");
|
||||
return;
|
||||
}
|
||||
// 更新结束时间
|
||||
List<Long> billIds = list.stream().map(TransactionBillVO::getBillId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
int update = transactionBillService.batchUpdateSuitEndTime(billIds, LocalDateTime.now());
|
||||
log.info("更新结束时间: update= {}" , update);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user