优化
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package top.wms.admin.materialProcess.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
import top.continew.starter.extension.crud.service.BaseService;
|
||||
import top.wms.admin.material.model.req.MaterialInfoImportReq;
|
||||
import top.wms.admin.material.model.resp.MaterialImportParseResp;
|
||||
import top.wms.admin.material.model.resp.MaterialInfoImportResp;
|
||||
import top.wms.admin.materialProcess.model.query.MaterialProcessQuery;
|
||||
import top.wms.admin.materialProcess.model.req.MaterialProcessReq;
|
||||
import top.wms.admin.materialProcess.model.resp.MaterialProcessResp;
|
||||
@@ -16,5 +21,29 @@ import java.util.List;
|
||||
*/
|
||||
public interface MaterialProcessService extends BaseService<MaterialProcessResp, MaterialProcessResp, MaterialProcessQuery, MaterialProcessReq> {
|
||||
|
||||
/**
|
||||
* 获取流程下拉列表
|
||||
* @return 流程下拉列表
|
||||
*/
|
||||
List<LabelValueResp> getSelectList();
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
* @param response 响应对象
|
||||
*/
|
||||
void downloadImportTemplate(HttpServletResponse response) throws Exception;
|
||||
|
||||
/**
|
||||
* 解析导入文件
|
||||
* @param file 导入文件
|
||||
* @param file 导入文件
|
||||
*/
|
||||
MaterialImportParseResp parseImport(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 导入物料信息
|
||||
* @param req 导入请求
|
||||
* @return 导入响应
|
||||
*/
|
||||
MaterialInfoImportResp importMaterial(MaterialInfoImportReq req);
|
||||
}
|
||||
@@ -1,10 +1,21 @@
|
||||
package top.wms.admin.materialProcess.service.impl;
|
||||
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.ContentType;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.dreamlu.mica.core.result.R;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
import top.continew.starter.extension.crud.service.BaseServiceImpl;
|
||||
import top.continew.starter.web.util.FileUploadUtils;
|
||||
import top.wms.admin.material.model.req.MaterialInfoImportReq;
|
||||
import top.wms.admin.material.model.resp.MaterialImportParseResp;
|
||||
import top.wms.admin.material.model.resp.MaterialInfoImportResp;
|
||||
import top.wms.admin.materialProcess.mapper.MaterialProcessMapper;
|
||||
import top.wms.admin.materialProcess.mapstruct.MaterialProcessConvert;
|
||||
import top.wms.admin.materialProcess.model.entity.MaterialProcessDO;
|
||||
@@ -32,4 +43,27 @@ public class MaterialProcessServiceImpl extends BaseServiceImpl<MaterialProcessM
|
||||
List<MaterialProcessDO> materialProcessDOS = baseMapper.selectList(new QueryWrapper<>());
|
||||
return materialProcessConvert.labelValueList(materialProcessDOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadImportTemplate(HttpServletResponse response) throws Exception {
|
||||
try {
|
||||
FileUploadUtils.download(response, ResourceUtil
|
||||
.getStream("templates/import/materialProcess.xlsx"), "物料流程导入模板.xlsx");
|
||||
} catch (Exception e) {
|
||||
log.error("下载用户导入模板失败:", e);
|
||||
response.setCharacterEncoding(CharsetUtil.UTF_8);
|
||||
response.setContentType(ContentType.JSON.toString());
|
||||
response.getWriter().write(JSONUtil.toJsonStr(R.fail("下载用户导入模板失败")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialImportParseResp parseImport(MultipartFile file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialInfoImportResp importMaterial(MaterialInfoImportReq req) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
package top.wms.admin.controller.materialProcess;
|
||||
|
||||
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;
|
||||
@@ -11,11 +19,15 @@ import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
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.material.model.req.MaterialInfoImportReq;
|
||||
import top.wms.admin.material.model.resp.MaterialImportParseResp;
|
||||
import top.wms.admin.material.model.resp.MaterialInfoImportResp;
|
||||
import top.wms.admin.materialProcess.model.query.MaterialProcessQuery;
|
||||
import top.wms.admin.materialProcess.model.req.MaterialProcessReq;
|
||||
import top.wms.admin.materialProcess.model.resp.MaterialProcessResp;
|
||||
import top.wms.admin.materialProcess.service.MaterialProcessService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -37,4 +49,28 @@ public class MaterialProcessController extends BaseController<MaterialProcessSer
|
||||
return baseService.getSelectList();
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "下载导入模板", description = "下载导入模板")
|
||||
@SaCheckPermission("materialProcess:materialProcess:import")
|
||||
@GetMapping(value = "/import/template", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadImportTemplate(HttpServletResponse response) throws Exception {
|
||||
baseService.downloadImportTemplate(response);
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "解析导入数据", description = "解析导入数据")
|
||||
@SaCheckPermission("materialProcess:materialProcess:import")
|
||||
@PostMapping("/import/parse")
|
||||
public MaterialImportParseResp parseImport(@NotNull(message = "文件不能为空") MultipartFile file) {
|
||||
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
|
||||
return baseService.parseImport(file);
|
||||
}
|
||||
|
||||
@Operation(summary = "导入数据", description = "导入数据")
|
||||
@SaCheckPermission("materialProcess:materialProcess:import")
|
||||
@PostMapping(value = "/import")
|
||||
public MaterialInfoImportResp importUser(@Validated @RequestBody MaterialInfoImportReq req) {
|
||||
return baseService.importMaterial(req);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
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.entity.MaterialInfoDO;
|
||||
@@ -59,6 +60,7 @@ public class MaterialInfoController extends BaseController<MaterialInfoService,
|
||||
return materialInfoResp;
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "下载导入模板", description = "下载导入模板")
|
||||
@SaCheckPermission("admin:materialInfo:import")
|
||||
@GetMapping(value = "/import/template", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@@ -66,6 +68,7 @@ public class MaterialInfoController extends BaseController<MaterialInfoService,
|
||||
baseService.downloadImportTemplate(response);
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "解析导入数据", description = "解析导入数据")
|
||||
@SaCheckPermission("admin:materialInfo:import")
|
||||
@PostMapping("/import/parse")
|
||||
@@ -92,6 +95,7 @@ public class MaterialInfoController extends BaseController<MaterialInfoService,
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "照片抓取", description = "照片抓取")
|
||||
@PostMapping("/import/catch")
|
||||
public String catchPhoto(@RequestParam("file") MultipartFile file) {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user