|
@@ -14,12 +14,12 @@ 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.config.DeviceThreadPoolConfig;
|
|
import com.xy.device.EnumDeviceQrCode;
|
|
import com.xy.device.EnumDeviceQrCode;
|
|
|
|
+import com.xy.device.EnumDeviceType;
|
|
import com.xy.dto.DeviceCreateIdsDto;
|
|
import com.xy.dto.DeviceCreateIdsDto;
|
|
|
|
+import com.xy.dto.DeviceQualityDto;
|
|
import com.xy.dto.SysWorkUser.ListDto;
|
|
import com.xy.dto.SysWorkUser.ListDto;
|
|
import com.xy.dto.SysWorkUser.SysWorkVo;
|
|
import com.xy.dto.SysWorkUser.SysWorkVo;
|
|
import com.xy.entity.DeviceCreateIds;
|
|
import com.xy.entity.DeviceCreateIds;
|
|
-import com.xy.entity.SysDictRedis;
|
|
|
|
-import com.xy.error.CommRuntimeException;
|
|
|
|
import com.xy.mapper.DeviceCreateIdsMapper;
|
|
import com.xy.mapper.DeviceCreateIdsMapper;
|
|
import com.xy.utils.*;
|
|
import com.xy.utils.*;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -166,42 +166,56 @@ public class DeviceCreateIdsServiceImpl extends ServiceImpl<DeviceCreateIdsMappe
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
- @PostMapping("exportQrCode")
|
|
|
|
- @ApiOperation("导出二维码")
|
|
|
|
- public void exportQrCode(@RequestBody DeviceCreateIdsDto.ExportQrCode exportQrCode) {
|
|
|
|
- SysDictRedis sysDictRedis = SysDictUtils.get(EnumDeviceQrCode.Code.CODE.getCode(), EnumDeviceQrCode.URL.getCode());
|
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
|
- Boolean isWhere = exportQrCode.getIsWhere() == null ? false : exportQrCode.getIsWhere();
|
|
|
|
- if (!isWhere) {
|
|
|
|
- List<Long> deviceIds = exportQrCode.getDeviceIds();
|
|
|
|
- if (Emptys.check(deviceIds)) {
|
|
|
|
- deviceIds.forEach(deviceId -> list.add(deviceId.toString()));
|
|
|
|
|
|
+ @PostMapping("getQrCode")
|
|
|
|
+ @ApiOperation("获取二维码")
|
|
|
|
+ public R<List<String>> getQrCode(@RequestBody @Validated DeviceQualityDto.Qrcode qrcode) {
|
|
|
|
+ //查询设备类型
|
|
|
|
+ DeviceCreateIds deviceCreateIds = getById(qrcode.getDeviceId());
|
|
|
|
+ String qrUrl = SysDictUtils.getValue(EnumDeviceQrCode.Code.CODE.getCode(), EnumDeviceQrCode.URL.getCode(), String.class);
|
|
|
|
+ //验证是否是双门柜
|
|
|
|
+ int deviceType = SysDictUtils.getValue(EnumDeviceType.Code.CODE.getCode(), EnumDeviceType.N_2.getCode(), Integer.class);
|
|
|
|
+ String deviceId = qrcode.getDeviceId().toString();
|
|
|
|
+ JList<String> deviceIds = new JArrayList<String>()
|
|
|
|
+ .set(qrUrl + deviceId);
|
|
|
|
+ JList<String> deviceIdInfos = new JArrayList<String>()
|
|
|
|
+ .set(deviceId);
|
|
|
|
+ if (deviceCreateIds.getDeviceType() == deviceType) {
|
|
|
|
+ deviceIds.clear();
|
|
|
|
+ deviceIdInfos.clear();
|
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
|
+ deviceIds.add(String.format("%s%s&door=%d", qrUrl, deviceId, i));
|
|
|
|
+ deviceIdInfos.add(String.format("%s-%d", deviceId, i));
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- LambdaQueryWrapper<DeviceCreateIds> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(exportQrCode, DeviceCreateIds.class)
|
|
|
|
- .ge(DeviceCreateIds::getCreateTime, exportQrCode.getBeginCreateTime())
|
|
|
|
- .le(DeviceCreateIds::getCreateTime, exportQrCode.getEndCreateTime())
|
|
|
|
- .ge(DeviceCreateIds::getBindTime, exportQrCode.getBeginBindTime())
|
|
|
|
- .le(DeviceCreateIds::getBindTime, exportQrCode.getEndBindTime())
|
|
|
|
- .build();
|
|
|
|
- List<DeviceCreateIds> deviceCreateIds = list(lambdaQueryWrapper);
|
|
|
|
- deviceCreateIds.forEach(deviceCreateIds1 -> list.add(String.valueOf(deviceCreateIds1.getDeviceId())));
|
|
|
|
}
|
|
}
|
|
- if (!Emptys.check(list)) {
|
|
|
|
- throw new CommRuntimeException("没有导出的数据");
|
|
|
|
- }
|
|
|
|
- List<String> infos = new ArrayList<>();
|
|
|
|
|
|
+ List<String> base64s = QRCodeUtils.create(deviceIds, 400, 400, "back1.png", deviceIdInfos).base64();
|
|
|
|
+ return R.ok(base64s);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("exportQrCode")
|
|
|
|
+ @ApiOperation("导出二维码")
|
|
|
|
+ public void exportQrCode(@RequestBody @Validated DeviceCreateIdsDto.ExportQrCode exportQrCode) {
|
|
|
|
+ String qrUrl = SysDictUtils.getValue(EnumDeviceQrCode.Code.CODE.getCode(), EnumDeviceQrCode.URL.getCode(), String.class);
|
|
|
|
+ int deviceType = SysDictUtils.getValue(EnumDeviceType.Code.CODE.getCode(), EnumDeviceType.N_2.getCode(), Integer.class);
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
- List<DeviceCreateIds> updateDeviceCreateIds = new ArrayList<>(list.size());
|
|
|
|
- for (String deviceId : list) {
|
|
|
|
- infos.add(sysDictRedis.getValue() + deviceId);
|
|
|
|
- DeviceCreateIds deviceCreateIds = new DeviceCreateIds()
|
|
|
|
- .setDeviceId(Long.valueOf(deviceId))
|
|
|
|
- .setLastExportQrCodeTime(now);
|
|
|
|
- updateDeviceCreateIds.add(deviceCreateIds);
|
|
|
|
- }
|
|
|
|
|
|
+ JList<String> deviceIds = new JArrayList<>();
|
|
|
|
+ List<String> deviceIdInfos = new ArrayList<>();
|
|
|
|
+ List<DeviceCreateIds> updateDeviceCreateIds = new ArrayList<>();
|
|
|
|
+ List<DeviceCreateIds> deviceCreateIdss = listByIds(exportQrCode.getDeviceIds());
|
|
|
|
+ deviceCreateIdss.forEach(deviceCreateIds -> {
|
|
|
|
+ //验证是否是双门柜
|
|
|
|
+ if (deviceCreateIds.getDeviceType() == deviceType) {
|
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
|
+ deviceIds.add(String.format("%s%s&door=%d", qrUrl, deviceCreateIds.getDeviceId(), i));
|
|
|
|
+ deviceIdInfos.add(String.format("%s-%d", deviceCreateIds.getDeviceId(), i));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ deviceIds.add(qrUrl + deviceCreateIds.getDeviceId());
|
|
|
|
+ deviceIdInfos.add(String.valueOf(deviceCreateIds.getDeviceId()));
|
|
|
|
+ }
|
|
|
|
+ updateDeviceCreateIds.add(deviceCreateIds.setLastExportQrCodeTime(now));
|
|
|
|
+ });
|
|
updateBatchById(updateDeviceCreateIds);
|
|
updateBatchById(updateDeviceCreateIds);
|
|
- QRCodeUtils.create(infos, 400, 400, "back1.png", list).download(list);
|
|
|
|
|
|
+ QRCodeUtils.create(deviceIds, 400, 400, "back1.png", deviceIdInfos).download(deviceIds);
|
|
}
|
|
}
|
|
|
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|