优化
This commit is contained in:
@@ -50,7 +50,7 @@ public class MaterialTypeController extends BaseController<MaterialTypeService,
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "下载导入模板", description = "下载导入模板")
|
||||
@SaCheckPermission("admin:materialType:import")
|
||||
@SaCheckPermission("materialType:materialType:import")
|
||||
@GetMapping(value = "/importTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadImportTemplate(HttpServletResponse response) throws IOException {
|
||||
baseService.downloadImportTemplate(response);
|
||||
@@ -58,7 +58,7 @@ public class MaterialTypeController extends BaseController<MaterialTypeService,
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "解析导入数据", description = "解析导入数据")
|
||||
@SaCheckPermission("admin:materialType:import")
|
||||
@SaCheckPermission("materialType:materialType:import")
|
||||
@PostMapping("/parseImport")
|
||||
public MaterialTypeImportParseResp parseImport(@NotNull(message = "文件不能为空") MultipartFile file) {
|
||||
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
|
||||
@@ -66,7 +66,7 @@ public class MaterialTypeController extends BaseController<MaterialTypeService,
|
||||
}
|
||||
|
||||
@Operation(summary = "导入数据", description = "导入数据")
|
||||
@SaCheckPermission("admin:materialType:import")
|
||||
@SaCheckPermission("materialType:materialType:import")
|
||||
@PostMapping(value = "/import")
|
||||
public MaterialTypeImportResp importMaterial(@Validated @RequestBody MaterialTypeImportReq req) {
|
||||
return baseService.importMaterial(req);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class VmCommandController {
|
||||
} catch (NumberFormatException e) {
|
||||
throw new BusinessException("相机识别异常");
|
||||
}
|
||||
|
||||
response = "success";
|
||||
} else if (StrUtil.equals(response, materialCode)) {
|
||||
response = "success";
|
||||
} else {
|
||||
|
||||
@@ -28,9 +28,9 @@ import java.util.regex.Pattern;
|
||||
public class AHDZCConnect {
|
||||
|
||||
//老设备(只能跑jar包的)
|
||||
// private static final String PORT_NAME = "COM12";
|
||||
private static final String PORT_NAME = "COM12";
|
||||
//新设备(环境齐全的)
|
||||
private static final String PORT_NAME = "COM13";
|
||||
// private static final String PORT_NAME = "COM13";
|
||||
private static final int BAUD_RATE = 9600;
|
||||
private static final int DATA_BITS = 8;
|
||||
private static final int STOP_BITS = 1;
|
||||
@@ -55,9 +55,9 @@ public class AHDZCConnect {
|
||||
private ScheduledExecutorService executorService;
|
||||
|
||||
// todo 模拟数据生成
|
||||
// private ScheduledFuture<?> mockDataTask;
|
||||
// private final AtomicBoolean isMockDataRunning = new AtomicBoolean(false);
|
||||
// private final Random random = new Random();
|
||||
// private ScheduledFuture<?> mockDataTask;
|
||||
// private final AtomicBoolean isMockDataRunning = new AtomicBoolean(false);
|
||||
// private final Random random = new Random();
|
||||
|
||||
/**
|
||||
* 初始化并启动电子秤服务
|
||||
@@ -76,8 +76,8 @@ public class AHDZCConnect {
|
||||
start();
|
||||
|
||||
// todo 模拟数据生成
|
||||
// isMockDataRunning.set(true);
|
||||
// startMockData();
|
||||
// isMockDataRunning.set(true);
|
||||
// startMockData();
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
@@ -227,6 +227,7 @@ public class AHDZCConnect {
|
||||
|
||||
// 解析数据,提取数字和重量单位
|
||||
String weightStr = data.trim();
|
||||
log.info("电子称原始数据: {}", weightStr);
|
||||
// 使用正则表达式提取数字(包括小数点)
|
||||
Pattern pattern = Pattern.compile("[-+]?\\d*\\.?\\d+");
|
||||
Matcher matcher = pattern.matcher(weightStr);
|
||||
@@ -339,7 +340,7 @@ public class AHDZCConnect {
|
||||
log.info("========================================");
|
||||
|
||||
// todo 模拟数据生成
|
||||
// stopMockData();
|
||||
// stopMockData();
|
||||
|
||||
try {
|
||||
if (executorService != null && !executorService.isShutdown()) {
|
||||
@@ -361,32 +362,32 @@ public class AHDZCConnect {
|
||||
}
|
||||
|
||||
// todo 模拟数据生成
|
||||
// private void startMockData() {
|
||||
// if (executorService == null || executorService.isShutdown()) {
|
||||
// log.warn("[模拟数据] 线程池未初始化或已关闭");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// mockDataTask = executorService.scheduleAtFixedRate(() -> {
|
||||
// if (!isMockDataRunning.get()) {
|
||||
// private void startMockData() {
|
||||
// if (executorService == null || executorService.isShutdown()) {
|
||||
// log.warn("[模拟数据] 线程池未初始化或已关闭");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// ScaleWebSocketHandler.sendMessage(String.valueOf(random.nextInt(100) + 1));
|
||||
// log.debug("[模拟数据] 发送重量数据: 37.8");
|
||||
// } catch (Exception e) {
|
||||
// log.error("[模拟数据] 发送异常: {}", e.getMessage());
|
||||
// }
|
||||
// }, 0, 1, TimeUnit.SECONDS);
|
||||
// }
|
||||
// mockDataTask = executorService.scheduleAtFixedRate(() -> {
|
||||
// if (!isMockDataRunning.get()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// private void stopMockData() {
|
||||
// if (mockDataTask != null && !mockDataTask.isCancelled()) {
|
||||
// mockDataTask.cancel(false);
|
||||
// mockDataTask = null;
|
||||
// try {
|
||||
// ScaleWebSocketHandler.sendMessage(String.valueOf(random.nextInt(100) + 1));
|
||||
// log.debug("[模拟数据] 发送重量数据: 37.8");
|
||||
// } catch (Exception e) {
|
||||
// log.error("[模拟数据] 发送异常: {}", e.getMessage());
|
||||
// }
|
||||
// }, 0, 3, TimeUnit.SECONDS);
|
||||
// }
|
||||
//
|
||||
// private void stopMockData() {
|
||||
// if (mockDataTask != null && !mockDataTask.isCancelled()) {
|
||||
// mockDataTask.cancel(false);
|
||||
// mockDataTask = null;
|
||||
// }
|
||||
// isMockDataRunning.set(false);
|
||||
// }
|
||||
// isMockDataRunning.set(false);
|
||||
// }
|
||||
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user