|
@@ -214,11 +214,11 @@ public class DeviceCreateIdsServiceImpl extends ServiceImpl<DeviceCreateIdsMappe
|
|
|
|
|
|
@ApiOperation("批量添加自定义机器号")
|
|
@ApiOperation("批量添加自定义机器号")
|
|
@PostMapping("uploadSaveCustom")
|
|
@PostMapping("uploadSaveCustom")
|
|
- public R uploadSaveCustom(@RequestParam("file") MultipartFile file, @RequestParam("deviceType") Integer deviceType, @RequestParam("doorType") String doorType, @RequestParam("createPc") String createPc) {
|
|
|
|
|
|
+ public R uploadSaveCustom(@RequestParam("file") MultipartFile file) {
|
|
ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, 1)
|
|
ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, 1)
|
|
.execute(() -> {
|
|
.execute(() -> {
|
|
try {
|
|
try {
|
|
- EasyExcel.read(file.getInputStream(), UploadSaveCustom.class, new UploadSaveCustomListener(deviceType, doorType, createPc, AuthorizeUtils.getLoginId(Long.class), this)).sheet().doRead();
|
|
|
|
|
|
+ EasyExcel.read(file.getInputStream(), UploadSaveCustom.class, new UploadSaveCustomListener(AuthorizeUtils.getLoginId(Long.class), this)).sheet().doRead();
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
log.error("", e);
|
|
log.error("", e);
|
|
}
|
|
}
|
|
@@ -245,12 +245,6 @@ public class DeviceCreateIdsServiceImpl extends ServiceImpl<DeviceCreateIdsMappe
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
public static class UploadSaveCustomListener implements ReadListener<UploadSaveCustom> {
|
|
public static class UploadSaveCustomListener implements ReadListener<UploadSaveCustom> {
|
|
|
|
|
|
- private final Integer deviceType;
|
|
|
|
-
|
|
|
|
- private final String doorType;
|
|
|
|
-
|
|
|
|
- private final String createPc;
|
|
|
|
-
|
|
|
|
private final Long loginId;
|
|
private final Long loginId;
|
|
|
|
|
|
private final DeviceCreateIdsServiceImpl deviceCreateIdsService;
|
|
private final DeviceCreateIdsServiceImpl deviceCreateIdsService;
|
|
@@ -265,6 +259,23 @@ public class DeviceCreateIdsServiceImpl extends ServiceImpl<DeviceCreateIdsMappe
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void invoke(UploadSaveCustom data, AnalysisContext context) {
|
|
public void invoke(UploadSaveCustom data, AnalysisContext context) {
|
|
|
|
+ String deviceType = data.getDeviceType();
|
|
|
|
+ if (deviceType == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Integer deviceTypeValue = deviceType.equals("动态视觉柜(单门)") ? 1
|
|
|
|
+ : deviceType.equals("动态视觉柜(双门)") ? 2
|
|
|
|
+ : deviceType.equals("重力柜(单门)") ? 3
|
|
|
|
+ : deviceType.equals("重力柜(双门)") ? 4
|
|
|
|
+ : deviceType.equals("支付宝视动态觉柜") ? 5
|
|
|
|
+ : null;
|
|
|
|
+ if (deviceTypeValue == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!Emptys.check(data.getDevicePc())) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ data.setDeviceTypeValue(deviceTypeValue);
|
|
deviceIds.put(data.getDeviceId(), data);
|
|
deviceIds.put(data.getDeviceId(), data);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -284,14 +295,12 @@ public class DeviceCreateIdsServiceImpl extends ServiceImpl<DeviceCreateIdsMappe
|
|
}
|
|
}
|
|
if (Emptys.check(deviceIds)) {
|
|
if (Emptys.check(deviceIds)) {
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
- JList<Long> deviceIds2 = deviceIds.toList().key();
|
|
|
|
- List<DeviceCreateIds> saves = new ArrayList<>(deviceIds2.size());
|
|
|
|
- deviceIds2.forEach(deviceId -> {
|
|
|
|
|
|
+ List<DeviceCreateIds> saves = new ArrayList<>(deviceIds.size());
|
|
|
|
+ deviceIds.forEach((deviceId, uploadSaveCustom) -> {
|
|
DeviceCreateIds deviceCreateIdsInfo = new DeviceCreateIds()
|
|
DeviceCreateIds deviceCreateIdsInfo = new DeviceCreateIds()
|
|
.setDeviceId(deviceId)
|
|
.setDeviceId(deviceId)
|
|
- .setDeviceType(deviceType)
|
|
|
|
- .setDoorType(doorType)
|
|
|
|
- .setCreatePc(createPc)
|
|
|
|
|
|
+ .setDeviceType(uploadSaveCustom.getDeviceTypeValue())
|
|
|
|
+ .setCreatePc(uploadSaveCustom.getDevicePc())
|
|
.setCreateUserId(loginId)
|
|
.setCreateUserId(loginId)
|
|
.setIsCustom(true)
|
|
.setIsCustom(true)
|
|
.setCreateTime(now);
|
|
.setCreateTime(now);
|
|
@@ -306,6 +315,24 @@ public class DeviceCreateIdsServiceImpl extends ServiceImpl<DeviceCreateIdsMappe
|
|
@Data
|
|
@Data
|
|
public static class UploadSaveCustom {
|
|
public static class UploadSaveCustom {
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 设备id
|
|
|
|
+ */
|
|
private Long deviceId;
|
|
private Long deviceId;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设备类型
|
|
|
|
+ */
|
|
|
|
+ private String deviceType;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批次号
|
|
|
|
+ */
|
|
|
|
+ private String devicePc;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设备类型值
|
|
|
|
+ */
|
|
|
|
+ private Integer deviceTypeValue;
|
|
}
|
|
}
|
|
}
|
|
}
|