|
@@ -11,16 +11,14 @@ import com.xy.device.*;
|
|
|
import com.xy.dto.DeviceAlgorithmChargingDto;
|
|
|
import com.xy.dto.DeviceChargingDto;
|
|
|
import com.xy.dto.DeviceInfoDto;
|
|
|
-import com.xy.entity.DeviceCharging;
|
|
|
-import com.xy.entity.DeviceChargingHistory;
|
|
|
-import com.xy.entity.DeviceTypeAlgorithmBeforConfig;
|
|
|
-import com.xy.entity.SysDictRedis;
|
|
|
+import com.xy.entity.*;
|
|
|
import com.xy.error.CommRuntimeException;
|
|
|
import com.xy.mapper.DeviceChargingMapper;
|
|
|
import com.xy.utils.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -44,6 +42,7 @@ import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
* @author lijin
|
|
|
* @since 2023-04-14
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@Api(tags = "设备计费表")
|
|
|
@AllArgsConstructor(onConstructor_ = @Lazy)
|
|
@@ -111,11 +110,11 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
|
.setTimeout(now)
|
|
|
.setCreateTime(now)
|
|
|
);
|
|
|
- throw new CommRuntimeException("管理费欠费");
|
|
|
+ throw new CommRuntimeException(R.Enum.CHARGING.getCode(), R.Enum.CHARGING.getMsg());
|
|
|
}
|
|
|
int contrast = DataTime.stringContrast(DataTime.toString(deviceCharging.getTimeout()), DataTime.toString(now));
|
|
|
if (deviceCharging.getChargingX() == 0 && contrast <= 0) {
|
|
|
- throw new CommRuntimeException("管理费欠费");
|
|
|
+ throw new CommRuntimeException(R.Enum.CHARGING.getCode(), R.Enum.CHARGING.getMsg());
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -189,8 +188,11 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
|
if (!Emptys.check(list)) {
|
|
|
return R.ok();
|
|
|
}
|
|
|
- JList<DeviceChargingHistory> deviceChargingHistories = new JArrayList<>(list);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
+ JList<DeviceChargingHistory> deviceChargingHistories = new JArrayList<>(list);
|
|
|
+ //查询设备信息
|
|
|
+ List<DeviceInfo> deviceInfos = deviceInfoService.list(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, deviceChargingHistories.getProperty(DeviceChargingHistory::getDeviceId)));
|
|
|
+ JMap<Long, DeviceInfo> deviceInfoJMap = new JArrayList<>(deviceInfos).toMap(DeviceInfo::getDeviceId).cover();
|
|
|
//查询设备计费表
|
|
|
List<DeviceCharging> deviceChargings = list(new LambdaQueryWrapper<DeviceCharging>().in(DeviceCharging::getDeviceId, deviceChargingHistories.getProperty(DeviceChargingHistory::getDeviceId)));
|
|
|
JMap<Long, DeviceCharging> deviceChargingsJMaps = new JArrayList<>(deviceChargings).toMap(DeviceCharging::getDeviceId).cover();
|
|
@@ -225,20 +227,21 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
|
//设备重新计费
|
|
|
deviceCharging.setIsJob(true);
|
|
|
//解冻设备
|
|
|
- DeviceInfoDto.Update deviceInfo = new DeviceInfoDto.Update()
|
|
|
+ DeviceInfoDto.Update updateDeviceInfo = new DeviceInfoDto.Update()
|
|
|
.setDeviceId(deviceChargingHistory.getDeviceId());
|
|
|
- deviceInfo.setFreezeStatus(1);
|
|
|
- deviceInfo.setBusyState(1);
|
|
|
+ updateDeviceInfo.setFreezeStatus(1);
|
|
|
+ updateDeviceInfo.setBusyState(1);
|
|
|
//激活设备
|
|
|
if (deviceChargingHistory.getChargingType() != 100) {
|
|
|
+ DeviceInfo deviceInfo = deviceInfoJMap.get(deviceChargingHistory.getDeviceId());
|
|
|
if (deviceInfo.getActiveState() == 2) {
|
|
|
- deviceInfo.setActiveState(1);
|
|
|
+ updateDeviceInfo.setActiveState(1);
|
|
|
}
|
|
|
if (!Emptys.check(deviceInfo.getActiveTime())) {
|
|
|
- deviceInfo.setActiveTime(now);
|
|
|
+ updateDeviceInfo.setActiveTime(now);
|
|
|
}
|
|
|
}
|
|
|
- updateDeviceInfos.add(deviceInfo);
|
|
|
+ updateDeviceInfos.add(updateDeviceInfo);
|
|
|
}
|
|
|
updateDeviceCharging.add(deviceCharging);
|
|
|
updateDeviceChargingHistory.add(deviceChargingHistory);
|