优化
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
package top.wms.admin.controller.materialType;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -12,10 +20,14 @@ import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
import top.continew.starter.log.annotation.Log;
|
||||
import top.wms.admin.common.controller.BaseController;
|
||||
import top.wms.admin.materialType.model.query.MaterialTypeQuery;
|
||||
import top.wms.admin.materialType.model.req.MaterialTypeImportReq;
|
||||
import top.wms.admin.materialType.model.req.MaterialTypeReq;
|
||||
import top.wms.admin.materialType.model.resp.MaterialTypeImportParseResp;
|
||||
import top.wms.admin.materialType.model.resp.MaterialTypeImportResp;
|
||||
import top.wms.admin.materialType.model.resp.MaterialTypeResp;
|
||||
import top.wms.admin.materialType.service.MaterialTypeService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -35,4 +47,28 @@ public class MaterialTypeController extends BaseController<MaterialTypeService,
|
||||
public List<LabelValueResp> getSelectList() {
|
||||
return baseService.getSelectList();
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "下载导入模板", description = "下载导入模板")
|
||||
@SaCheckPermission("admin:materialType:import")
|
||||
@GetMapping(value = "/importTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadImportTemplate(HttpServletResponse response) throws IOException {
|
||||
baseService.downloadImportTemplate(response);
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "解析导入数据", description = "解析导入数据")
|
||||
@SaCheckPermission("admin:materialType:import")
|
||||
@PostMapping("/parseImport")
|
||||
public MaterialTypeImportParseResp parseImport(@NotNull(message = "文件不能为空") MultipartFile file) {
|
||||
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
|
||||
return baseService.parseImport(file);
|
||||
}
|
||||
|
||||
@Operation(summary = "导入数据", description = "导入数据")
|
||||
@SaCheckPermission("admin:materialType:import")
|
||||
@PostMapping(value = "/import")
|
||||
public MaterialTypeImportResp importMaterial(@Validated @RequestBody MaterialTypeImportReq req) {
|
||||
return baseService.importMaterial(req);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import top.continew.starter.log.annotation.Log;
|
||||
import top.continew.starter.web.model.R;
|
||||
import top.wms.admin.common.controller.BaseController;
|
||||
import top.wms.admin.material.model.query.MaterialInfoQuery;
|
||||
import top.wms.admin.material.model.req.BatchImportReq;
|
||||
import top.wms.admin.material.model.req.MaterialInfoImportReq;
|
||||
import top.wms.admin.material.model.req.MaterialInfoReq;
|
||||
import top.wms.admin.material.model.resp.MaterialImportParseResp;
|
||||
@@ -100,4 +101,28 @@ public class MaterialInfoController extends BaseController<MaterialInfoService,
|
||||
CheckUtils.throwIfEmpty(file, "照片抓取失败,请重新抓取");
|
||||
return baseService.catchPhoto(file);
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "批次下载导入模板", description = "批次下载导入模板")
|
||||
@SaCheckPermission("admin:materialInfo:import")
|
||||
@GetMapping(value = "/batch/import/template", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadBatchImportTemplate(HttpServletResponse response) throws IOException {
|
||||
baseService.downloadBatchImportTemplate(response);
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "批次解析导入数据", description = "批次解析导入数据")
|
||||
@SaCheckPermission("admin:materialInfo:import")
|
||||
@PostMapping("/batch/import/parse")
|
||||
public MaterialImportParseResp parseBatchImport(@NotNull(message = "文件不能为空") MultipartFile file) {
|
||||
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
|
||||
return baseService.parseBatchImport(file);
|
||||
}
|
||||
|
||||
@Operation(summary = "批次导入数据", description = "批次导入数据")
|
||||
@SaCheckPermission("admin:materialInfo:import")
|
||||
@PostMapping(value = "/batch/import")
|
||||
public MaterialInfoImportResp importBatchUser(@Validated @RequestBody BatchImportReq req) {
|
||||
return baseService.importBatchMaterial(req);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,13 +215,12 @@ public class AHDZCConnect {
|
||||
// 解析数据,提取数字和重量单位
|
||||
String weightStr = data.trim();
|
||||
// 使用正则表达式提取数字(包括小数点)
|
||||
Pattern pattern = java.util.regex.Pattern.compile("[-+]?\\d*\\.?\\d+");
|
||||
Pattern pattern = Pattern.compile("[-+]?\\d*\\.?\\d+");
|
||||
Matcher matcher = pattern.matcher(weightStr);
|
||||
|
||||
if (matcher.find()) {
|
||||
try {
|
||||
String weightWithUnit = matcher.group().trim();
|
||||
log.info("[解析后] 重量: {}", weightWithUnit);
|
||||
// 发送提取的数字和重量单位给前端
|
||||
ScaleWebSocketHandler.sendMessage(weightWithUnit);
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
@@ -155,14 +155,14 @@ public class NetCommon {
|
||||
// 设置通道为1
|
||||
ChannelID = 1;
|
||||
if (StrUtil.isBlank(strPicPath)) {
|
||||
strPicPath = "D:\\test\\ys\\carousel";
|
||||
strPicPath = "E:\\img\\ys\\carousel";
|
||||
// 创建保存目录
|
||||
File picDir = new File("D:\\test\\ys");
|
||||
File picDir = new File("E:\\img\\ys");
|
||||
if (!picDir.exists()) {
|
||||
picDir.mkdir();
|
||||
}
|
||||
} else {
|
||||
File picDir = new File("D:\\test\\ys\\workOrder");
|
||||
File picDir = new File("E:\\img\\ys\\workOrder");
|
||||
if (!picDir.exists()) {
|
||||
picDir.mkdir();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ysNetController {
|
||||
// 执行抓图
|
||||
long l = System.currentTimeMillis();
|
||||
imgName = imgName + "_" + l;
|
||||
boolean success = NetCommon.captureImage("D:\\test\\ys\\workOrder\\" + imgName);
|
||||
boolean success = NetCommon.captureImage("E:\\img\\ys\\workOrder\\" + imgName);
|
||||
if (success) {
|
||||
return R.ok("http://localhost:6609/file/ys/workOrder/" + imgName + ".jpg");
|
||||
} else {
|
||||
|
||||
BIN
wms-webapi/src/main/resources/templates/import/batch.xlsx
Normal file
BIN
wms-webapi/src/main/resources/templates/import/batch.xlsx
Normal file
Binary file not shown.
BIN
wms-webapi/src/main/resources/templates/import/materialType.xlsx
Normal file
BIN
wms-webapi/src/main/resources/templates/import/materialType.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user