|
@@ -1,5 +1,6 @@
|
|
package com.xy.service;
|
|
package com.xy.service;
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -8,11 +9,9 @@ import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.list.JList;
|
|
import com.xy.collections.list.JList;
|
|
import com.xy.collections.map.JHashMap;
|
|
import com.xy.collections.map.JHashMap;
|
|
import com.xy.collections.map.JMap;
|
|
import com.xy.collections.map.JMap;
|
|
|
|
+import com.xy.config.DeviceThreadPoolConfig;
|
|
import com.xy.device.*;
|
|
import com.xy.device.*;
|
|
-import com.xy.dto.DeviceAlgorithmChargingDto;
|
|
|
|
-import com.xy.dto.DeviceChargingConfigDto;
|
|
|
|
-import com.xy.dto.DeviceChargingDto;
|
|
|
|
-import com.xy.dto.DeviceInfoDto;
|
|
|
|
|
|
+import com.xy.dto.*;
|
|
import com.xy.entity.*;
|
|
import com.xy.entity.*;
|
|
import com.xy.mapper.DeviceChargingMapper;
|
|
import com.xy.mapper.DeviceChargingMapper;
|
|
import com.xy.utils.*;
|
|
import com.xy.utils.*;
|
|
@@ -26,7 +25,6 @@ import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
-import javax.validation.constraints.NotEmpty;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -64,6 +62,10 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
|
|
|
|
private DeviceStatusServiceImpl deviceStatusService;
|
|
private DeviceStatusServiceImpl deviceStatusService;
|
|
|
|
|
|
|
|
+ private DeviceSysinfoServiceImpl deviceSysinfoService;
|
|
|
|
+
|
|
|
|
+ private AlipayDeviceService alipayDeviceService;
|
|
|
|
+
|
|
@PostMapping("init")
|
|
@PostMapping("init")
|
|
@ApiOperation("初始化")
|
|
@ApiOperation("初始化")
|
|
public R init() {
|
|
public R init() {
|
|
@@ -301,9 +303,13 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
}
|
|
}
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
JList<DeviceChargingHistory> deviceChargingHistories = new JArrayList<>(list);
|
|
JList<DeviceChargingHistory> deviceChargingHistories = new JArrayList<>(list);
|
|
|
|
+ int aliDeviceType = SysDictUtils.getValue(EnumDeviceType.Code.CODE.getCode(), EnumDeviceType.N_5.getCode(), Integer.class);
|
|
//查询设备信息
|
|
//查询设备信息
|
|
List<DeviceInfo> deviceInfos = deviceInfoService.list(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, deviceChargingHistories.getProperty(DeviceChargingHistory::getDeviceId)));
|
|
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();
|
|
JMap<Long, DeviceInfo> deviceInfoJMap = new JArrayList<>(deviceInfos).toMap(DeviceInfo::getDeviceId).cover();
|
|
|
|
+ //查询设备系统信息
|
|
|
|
+ List<DeviceSysinfoDto.Vo> deviceSysinfos = deviceSysinfoService.list(new DeviceSysinfoDto.SelectList().setDeviceIds(deviceChargingHistories.getProperty(DeviceChargingHistory::getDeviceId))).getData();
|
|
|
|
+ JMap<Long, DeviceSysinfoDto.Vo> deviceSysinfosJMaps = new JArrayList<>(deviceSysinfos).toMap(DeviceSysinfoDto.Vo::getDeviceId).cover();
|
|
//查询设备计费表
|
|
//查询设备计费表
|
|
List<DeviceCharging> deviceChargings = list(new LambdaQueryWrapper<DeviceCharging>().in(DeviceCharging::getDeviceId, deviceChargingHistories.getProperty(DeviceChargingHistory::getDeviceId)));
|
|
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();
|
|
JMap<Long, DeviceCharging> deviceChargingsJMaps = new JArrayList<>(deviceChargings).toMap(DeviceCharging::getDeviceId).cover();
|
|
@@ -312,7 +318,9 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
JList<DeviceCharging> updateDeviceCharging = new JArrayList<>();
|
|
JList<DeviceCharging> updateDeviceCharging = new JArrayList<>();
|
|
JList<DeviceInfoDto.Update> updateDeviceInfos = new JArrayList<>();
|
|
JList<DeviceInfoDto.Update> updateDeviceInfos = new JArrayList<>();
|
|
JList<DeviceChargingHistory> updateDeviceChargingHistory = new JArrayList<>();
|
|
JList<DeviceChargingHistory> updateDeviceChargingHistory = new JArrayList<>();
|
|
|
|
+ JList<Tuple.Tuple2<BindDeviceDTO, BindActiveDTO>> ailiActive = new JArrayList<>();
|
|
for (DeviceChargingHistory deviceChargingHistory : deviceChargingHistories) {
|
|
for (DeviceChargingHistory deviceChargingHistory : deviceChargingHistories) {
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoJMap.get(deviceChargingHistory.getDeviceId());
|
|
DeviceCharging deviceCharging = deviceChargingsJMaps.get(deviceChargingHistory.getDeviceId())
|
|
DeviceCharging deviceCharging = deviceChargingsJMaps.get(deviceChargingHistory.getDeviceId())
|
|
.setLastChargingPayType(deviceChargingHistory.getChargingType())
|
|
.setLastChargingPayType(deviceChargingHistory.getChargingType())
|
|
.setLastChargingMoney(deviceChargingHistory.getChargingMoney())
|
|
.setLastChargingMoney(deviceChargingHistory.getChargingMoney())
|
|
@@ -336,7 +344,6 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
updateDeviceInfo.setBusyState(1);
|
|
updateDeviceInfo.setBusyState(1);
|
|
//激活设备
|
|
//激活设备
|
|
if (deviceChargingHistory.getChargingType() != 100) {
|
|
if (deviceChargingHistory.getChargingType() != 100) {
|
|
- DeviceInfo deviceInfo = deviceInfoJMap.get(deviceChargingHistory.getDeviceId());
|
|
|
|
if (deviceInfo.getActiveState() == 2) {
|
|
if (deviceInfo.getActiveState() == 2) {
|
|
updateDeviceInfo.setActiveState(1);
|
|
updateDeviceInfo.setActiveState(1);
|
|
}
|
|
}
|
|
@@ -346,6 +353,21 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
}
|
|
}
|
|
updateDeviceInfos.add(updateDeviceInfo);
|
|
updateDeviceInfos.add(updateDeviceInfo);
|
|
}
|
|
}
|
|
|
|
+ //支付宝设备
|
|
|
|
+ if (deviceInfo.getDeviceType() == aliDeviceType) {
|
|
|
|
+ if (deviceChargingHistory.getChargingType() != 100 && deviceInfo.getActiveState() == 2) {
|
|
|
|
+ //支付宝绑定
|
|
|
|
+ DeviceSysinfoDto.Vo deviceSysinfo = deviceSysinfosJMaps.get(deviceChargingHistory.getDeviceId());
|
|
|
|
+ BindDeviceDTO bindDeviceDTO = new BindDeviceDTO().setTerminalId(String.valueOf(deviceInfo.getDeviceId()))
|
|
|
|
+ .setBoardSn(deviceSysinfo.getDeviceSn());
|
|
|
|
+ //支付宝激活
|
|
|
|
+ BindActiveDTO bindActiveDTO = new BindActiveDTO()
|
|
|
|
+ .setTerminalId(String.valueOf(deviceInfo.getDeviceId()))
|
|
|
|
+ .setBoardSn(deviceSysinfo.getDeviceSn())
|
|
|
|
+ .setDeviceName(StrUtil.isNotEmpty(deviceInfo.getDeviceName()) ? deviceInfo.getDeviceName() : String.valueOf(deviceInfo.getDeviceId()));
|
|
|
|
+ ailiActive.add(new Tuple.Tuple2<>(bindDeviceDTO, bindActiveDTO));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
updateDeviceCharging.add(deviceCharging);
|
|
updateDeviceCharging.add(deviceCharging);
|
|
updateDeviceChargingHistory.add(deviceChargingHistory);
|
|
updateDeviceChargingHistory.add(deviceChargingHistory);
|
|
}
|
|
}
|
|
@@ -365,6 +387,16 @@ public class DeviceChargingServiceImpl extends ServiceImpl<DeviceChargingMapper,
|
|
JList<JList<DeviceInfoDto.Update>> partition = updateDeviceInfos.partition(size);
|
|
JList<JList<DeviceInfoDto.Update>> partition = updateDeviceInfos.partition(size);
|
|
partition.forEach(data -> deviceInfoService.updateBatch(data));
|
|
partition.forEach(data -> deviceInfoService.updateBatch(data));
|
|
}
|
|
}
|
|
|
|
+ //支付宝刷脸柜激活请求
|
|
|
|
+ if (Emptys.check(ailiActive)) {
|
|
|
|
+ ThreadPoolUtils.Execute execute = ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.ALI_DEVICE_ACTIVE, ailiActive.size());
|
|
|
|
+ ailiActive.forEach(bindDeviceDTOBindActiveDTOTuple2 -> execute.execute(() -> {
|
|
|
|
+ //调用支付宝绑定
|
|
|
|
+ R.feignCheckData(alipayDeviceService.deviceBind(bindDeviceDTOBindActiveDTOTuple2.getV1()));
|
|
|
|
+ //调用支付宝激活
|
|
|
|
+ R.feignCheckData(alipayDeviceService.deviceActive(bindDeviceDTOBindActiveDTOTuple2.getV2()));
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
}
|
|
}
|