|
@@ -1,5 +1,6 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -9,16 +10,14 @@ import com.xy.collections.list.JArrayList;
|
|
|
import com.xy.collections.list.JList;
|
|
|
import com.xy.collections.map.JHashMap;
|
|
|
import com.xy.collections.map.JMap;
|
|
|
+import com.xy.config.DeviceThreadPoolConfig;
|
|
|
import com.xy.device.EnumAlgorithmPayConfig;
|
|
|
import com.xy.device.EnumDeviceAlgorithmChargingHistoryStatus;
|
|
|
import com.xy.device.EnumDeviceAlgorithmChargingType;
|
|
|
-import com.xy.dto.DeviceAlgorithmChargingDto;
|
|
|
-import com.xy.dto.DeviceInfoDto;
|
|
|
+import com.xy.device.EnumDeviceType;
|
|
|
+import com.xy.dto.*;
|
|
|
import com.xy.dto.be.MercDto;
|
|
|
-import com.xy.entity.DeviceAlgorithmCharging;
|
|
|
-import com.xy.entity.DeviceAlgorithmChargingHistory;
|
|
|
-import com.xy.entity.DeviceInfo;
|
|
|
-import com.xy.entity.SysDictRedis;
|
|
|
+import com.xy.entity.*;
|
|
|
import com.xy.mapper.DeviceAlgorithmChargingMapper;
|
|
|
import com.xy.mapper.entity.DeviceAlgorithmChargingChargingQueryParams;
|
|
|
import com.xy.service.be.MercService;
|
|
@@ -26,6 +25,7 @@ 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.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -47,6 +47,7 @@ import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
* @author lijin
|
|
|
* @since 2023-06-29
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
@Api(tags = "设备算法计费表")
|
|
@@ -58,6 +59,10 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
|
|
|
private MercService mercService;
|
|
|
|
|
|
+ private DeviceSysinfoServiceImpl deviceSysinfoService;
|
|
|
+
|
|
|
+ private AlipayDeviceService alipayDeviceService;
|
|
|
+
|
|
|
@PostMapping("page")
|
|
|
@ApiOperation("分页查询")
|
|
|
public R<PageBean<DeviceAlgorithmChargingDto.Vo>> page(@RequestBody @Validated DeviceAlgorithmChargingDto.Page page) {
|
|
@@ -135,6 +140,9 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
//查询设备信息
|
|
|
List<DeviceInfo> deviceInfos = deviceInfoService.list(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, deviceAlgorithmChargingHistories.getProperty(DeviceAlgorithmChargingHistory::getDeviceId)));
|
|
|
JMap<Long, DeviceInfo> deviceInfoJMap = new JArrayList<>(deviceInfos).toMap(DeviceInfo::getDeviceId).cover();
|
|
|
+ //查询设备系统信息
|
|
|
+ List<DeviceSysinfoDto.Vo> deviceSysinfos = deviceSysinfoService.list(new DeviceSysinfoDto.SelectList().setDeviceIds(deviceAlgorithmChargingHistories.getProperty(DeviceAlgorithmChargingHistory::getDeviceId))).getData();
|
|
|
+ JMap<Long, DeviceSysinfoDto.Vo> deviceSysinfosJMaps = new JArrayList<>(deviceSysinfos).toMap(DeviceSysinfoDto.Vo::getDeviceId).cover();
|
|
|
//获取算法包月字典
|
|
|
Map<String, SysDictRedis> algorithmMoonConfigMaps = SysDictUtils.get(EnumAlgorithmPayConfig.Code.CODE.getCode());
|
|
|
//获取类型字典
|
|
@@ -143,6 +151,8 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
List<MercDto.Vo> mercs = mercService.list(new MercDto.SelectList().setMercIds(deviceAlgorithmChargingHistories.getProperty(DeviceAlgorithmChargingHistory::getMercId))).getData();
|
|
|
JMap<Long, MercDto.Vo> mercsMaps = new JArrayList<>(mercs).toMap(MercDto.Vo::getId).cover();
|
|
|
JList<DeviceInfoDto.Update> updateDeviceInfos = new JArrayList<>();
|
|
|
+ JList<Tuple.Tuple2<BindDeviceDTO, BindActiveDTO>> ailiActive = new JArrayList<>();
|
|
|
+ int aliDeviceType = SysDictUtils.getValue(EnumDeviceType.Code.CODE.getCode(), EnumDeviceType.N_5.getCode(), Integer.class);
|
|
|
//处理有效期
|
|
|
deviceAlgorithmChargingHistories.forEach(deviceAlgorithmChargingHistory -> {
|
|
|
//解冻设备 激活设备
|
|
@@ -212,6 +222,22 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
.setUpdateTime(now);
|
|
|
save(deviceAlgorithmChargingInfo);
|
|
|
}
|
|
|
+ //支付宝设备
|
|
|
+ DeviceInfo deviceInfo = deviceInfoJMap.get(deviceAlgorithmChargingHistory.getDeviceId());
|
|
|
+ if (deviceInfo.getDeviceType() == aliDeviceType) {
|
|
|
+ if (deviceAlgorithmChargingHistory.getChargingType() != 100 && deviceInfo.getActiveState() == 2) {
|
|
|
+ //支付宝绑定
|
|
|
+ DeviceSysinfoDto.Vo deviceSysinfo = deviceSysinfosJMaps.get(deviceAlgorithmChargingHistory.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));
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
//处理无期限
|
|
|
infs.forEach(deviceAlgorithmChargingHistory -> {
|
|
@@ -255,6 +281,17 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
if (Emptys.check(updateDeviceInfos)) {
|
|
|
deviceInfoService.updateBatch(updateDeviceInfos);
|
|
|
}
|
|
|
+ //支付宝刷脸柜激活请求
|
|
|
+ log.info("支付宝刷脸柜激活请求参数:{}", ailiActive.toString());
|
|
|
+ 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();
|
|
|
}
|
|
|
|