|
@@ -22,6 +22,7 @@ import com.xy.mapper.*;
|
|
|
import com.xy.utils.*;
|
|
|
import com.xy.utils.consts.CommConsts;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Data;
|
|
@@ -35,6 +36,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
@@ -260,11 +262,11 @@ public class DeviceRegisterServiceImpl extends ServiceImpl<DeviceRegisterMapper,
|
|
|
|
|
|
@ApiOperation("上传sn注册设备")
|
|
|
@PostMapping("uploadSaveBySn")
|
|
|
- public R uploadSaveBySn(@RequestParam("file") MultipartFile file, @RequestParam("deviceType") Integer deviceType) {
|
|
|
+ public R uploadSaveBySn(@RequestParam("file") MultipartFile file, @RequestParam("deviceType") Integer deviceType, @RequestParam("devicePc") String devicePc, @RequestParam("assetNo") String assetNo) {
|
|
|
ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, 1)
|
|
|
.execute(() -> {
|
|
|
try {
|
|
|
- EasyExcel.read(file.getInputStream(), UploadSaveBySn.class, new UploadSaveBySnListener(deviceCreateIdsService, this, deviceType)).sheet().doRead();
|
|
|
+ EasyExcel.read(file.getInputStream(), UploadSaveBySn.class, new UploadSaveBySnListener(deviceCreateIdsService, this, deviceType, devicePc, assetNo)).sheet().doRead();
|
|
|
} catch (IOException e) {
|
|
|
log.error("", e);
|
|
|
}
|
|
@@ -282,6 +284,10 @@ public class DeviceRegisterServiceImpl extends ServiceImpl<DeviceRegisterMapper,
|
|
|
|
|
|
private final Integer deviceType;
|
|
|
|
|
|
+ private final String devicePc;
|
|
|
+
|
|
|
+ private final String assetNo;
|
|
|
+
|
|
|
private List<UploadSaveBySn> sns = new ArrayList<>();
|
|
|
|
|
|
/**
|
|
@@ -302,13 +308,12 @@ public class DeviceRegisterServiceImpl extends ServiceImpl<DeviceRegisterMapper,
|
|
|
*/
|
|
|
@Override
|
|
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
|
|
- String pc = DataTime.getSring("yyyyMMddHHmmss");
|
|
|
- log.info("上传sn注册设备文件解析完毕,总数量:{},批次:{}", sns.size(), pc);
|
|
|
+ log.info("上传sn注册设备文件解析完毕,总数量:{},批次:{}", sns.size(), devicePc);
|
|
|
//生成设备号
|
|
|
JList<DeviceCreateIds> deviceCreateIds = deviceCreateIdsService.save(new DeviceCreateIdsDto.Save()
|
|
|
.setDeviceType(deviceType)
|
|
|
.setDoorType("1")
|
|
|
- .setCreatePc(pc)
|
|
|
+ .setCreatePc(devicePc)
|
|
|
.setNum(sns.size())
|
|
|
).getData();
|
|
|
JList<Long> deviceIds = deviceCreateIds.getProperty(DeviceCreateIds::getDeviceId);
|
|
@@ -321,8 +326,8 @@ public class DeviceRegisterServiceImpl extends ServiceImpl<DeviceRegisterMapper,
|
|
|
DeviceRegisterDto.Save save = new DeviceRegisterDto.Save()
|
|
|
.setDeviceId(deviceId)
|
|
|
.setDeviceSn(sn.getSn())
|
|
|
- .setDevicePc(pc)
|
|
|
- .setAssetNo(pc);
|
|
|
+ .setDevicePc(devicePc)
|
|
|
+ .setAssetNo(assetNo);
|
|
|
R r = deviceRegisterService.save(save);
|
|
|
if (r.getCode() == R.Enum.FAIL.getCode()) {
|
|
|
log.error("{},{}", sn.getSn(), r.getMsg());
|
|
@@ -330,7 +335,7 @@ public class DeviceRegisterServiceImpl extends ServiceImpl<DeviceRegisterMapper,
|
|
|
});
|
|
|
}
|
|
|
execute.end();
|
|
|
- log.info("上传sn注册设备注册完毕,批次:{}", pc);
|
|
|
+ log.info("上传sn注册设备注册完毕,批次:{}", devicePc);
|
|
|
}
|
|
|
}
|
|
|
|