From 2d221ef42fca5011b9256758642d9710e8ef6fcd Mon Sep 17 00:00:00 2001 From: MrZhai Date: Tue, 8 Mar 2022 16:08:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E4=BB=93=E5=BA=93=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3=202.=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=BE=9B=E5=BA=94=E5=95=86=E4=BF=A1=E6=81=AF=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=B8=8B=E8=BD=BD,=E5=8C=BB=E7=96=97=E5=99=A8?= =?UTF-8?q?=E6=A2=B0=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=87=BA=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?/=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/basic/CorpExportLogController.java | 2 +- .../controller/basic/CorpImportLogController.java | 2 +- .../basic/UdiInfoExportLogController.java | 2 +- .../inventory/InvWarehouseController.java | 15 ++++++++------- .../sale/admin/dao/inventory/InvWarehouseDao.java | 8 ++++++++ .../service/inventory/InvWarehouseService.java | 8 +++++++- .../inventory/impl/InvWarehouseServiceImpl.java | 10 ++++++++-- .../mybatis/mapper/inventory/InvWarehouseDao.xml | 14 ++++++++++++++ 8 files changed, 48 insertions(+), 13 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpExportLogController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpExportLogController.java index 72eba35..e7f18a5 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpExportLogController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpExportLogController.java @@ -71,7 +71,7 @@ public class CorpExportLogController { } //往来单位excel文件下载 - @AuthRuleAnnotation("") + //@AuthRuleAnnotation("") @GetMapping("/udiwms/corps/exportLog/download") public void download(FilterUdiEpLogRequest filterUdiEpLogRequest, HttpServletResponse res) { diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpImportLogController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpImportLogController.java index 11efe28..924661d 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpImportLogController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/CorpImportLogController.java @@ -113,7 +113,7 @@ public class CorpImportLogController { //往来单位信息文件导入 - @AuthRuleAnnotation("") + //@AuthRuleAnnotation("") @PostMapping("/udiwms/corps/importLog/upload") public BaseResponse uploadProducts(@RequestParam("file") List files, @RequestParam("thirdSys") String thirdSys) { diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoExportLogController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoExportLogController.java index 5e8d720..2108546 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoExportLogController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/basic/UdiInfoExportLogController.java @@ -75,7 +75,7 @@ public class UdiInfoExportLogController { } //产品信息excel文件下载 - @AuthRuleAnnotation("") + //@AuthRuleAnnotation("") @GetMapping("/udiwms/products/exportLog/download") public void download(FilterUdiEpLogRequest filterUdiEpLogRequest, HttpServletResponse res) { diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java index f73c439..5a3e711 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvWarehouseController.java @@ -134,7 +134,7 @@ public class InvWarehouseController { InvWarehouseExportResponse invWarehouseExportResponse = new InvWarehouseExportResponse(); invWarehouseExportResponse.setInvWarehouseEntities(invWarehouseEntities); String json = JSONObject.toJSON(invWarehouseExportResponse).toString(); - String fileName = "仓库信息导出_" + DateUtil.getDate() + ".json"; + String fileName = "仓库信息导出_" + DateUtil.getDate() + ".udi"; res.setHeader("Content-disposition", "attachment;fileName=" + fileName); res.setContentType("text/plain;charset=UTF-8"); try { @@ -154,23 +154,24 @@ public class InvWarehouseController { if (file.isEmpty()) { return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败"); } + String filename = file.getOriginalFilename(); + String fileType = filename.substring(filename.lastIndexOf(".")); + if (!".udi".equals(fileType)) { + return ResultVOUtils.error(500, "请上传udi格式文件!"); + } try { InputStream inputStream = file.getInputStream(); String json = FileUtils.readStream(inputStream); InvWarehouseExportResponse invWarehouseExportResponse = (InvWarehouseExportResponse) JSON.parseObject(json, InvWarehouseExportResponse.class); List invWarehouseEntities = invWarehouseExportResponse.getInvWarehouseEntities(); if (invWarehouseEntities != null) { - for (InvWarehouseEntity invWarehouseEntity : invWarehouseEntities) { - invWarehouseService.insertInvWarehouse(invWarehouseEntity); - } + invWarehouseService.importInvWarehouse(invWarehouseEntities); } - - } catch (IOException e) { e.printStackTrace(); } } - return ResultVOUtils.success("后台正在生成导入生成订单,请稍后查看!"); + return ResultVOUtils.success("后台正在导入仓库信息,请稍后查看!"); } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java index bb6eb07..e4ab70c 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvWarehouseDao.java @@ -21,4 +21,12 @@ public interface InvWarehouseDao { boolean deleteById(@Param("id") String id); String getNameByCode(@Param("fromCorpId") String fromCorpId); + + /** + * 批量导入仓库信息 + * + * @param invWarehouseEntities + */ + void importInvWarehouse(@Param("invWarehouseEntities") List invWarehouseEntities); + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java index 857c918..8faa997 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvWarehouseService.java @@ -2,7 +2,6 @@ package com.glxp.sale.admin.service.inventory; import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity; import com.glxp.sale.admin.req.inventory.FilterInvWarehouseRequest; -import org.apache.ibatis.annotations.Param; import java.util.List; @@ -25,4 +24,11 @@ public interface InvWarehouseService { boolean deleteById(String id); + /** + * 批量导入仓库信息 + * + * @param invWarehouseEntities + */ + void importInvWarehouse(List invWarehouseEntities); + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java index 6808e3d..642f729 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvWarehouseServiceImpl.java @@ -1,11 +1,10 @@ package com.glxp.sale.admin.service.inventory.impl; +import cn.hutool.core.collection.CollUtil; import com.github.pagehelper.PageHelper; import com.glxp.sale.admin.dao.inventory.InvWarehouseDao; -import com.glxp.sale.admin.entity.inventory.InvProductEntity; import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity; import com.glxp.sale.admin.req.inventory.FilterInvWarehouseRequest; -import com.glxp.sale.admin.res.inventory.InvProductResponse; import com.glxp.sale.admin.service.inventory.InvWarehouseService; import org.springframework.stereotype.Service; @@ -87,4 +86,11 @@ public class InvWarehouseServiceImpl implements InvWarehouseService { public boolean deleteById(String id) { return invWarehouseDao.deleteById(id); } + + @Override + public void importInvWarehouse(List invWarehouseEntities) { + if (CollUtil.isNotEmpty(invWarehouseEntities)) { + invWarehouseDao.importInvWarehouse(invWarehouseEntities); + } + } } diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml index 423949a..497a29a 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/InvWarehouseDao.xml @@ -108,4 +108,18 @@ WHERE id = #{id} + + replace into inv_warehouse (id, pId, code, name, advanceType, isDefault, status, updateTime, remark) values + + (#{item.id}, + #{item.pid}, + #{item.code}, + #{item.name}, + #{item.advanceType}, + #{item.isDefault}, + #{item.status}, + #{item.updateTime}, + #{item.remark}) + + \ No newline at end of file