From ebf8ca0158a27c14fb9151da6e5c8f2fd6148ce2 Mon Sep 17 00:00:00 2001 From: 79493 <794930212@qq.com> Date: Wed, 14 Dec 2022 16:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=AB=AF-=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=8E=A5=E5=8F=A3=E5=92=8C=E8=B0=83=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/rzyc/model/ent/InList.java | 2 ++ inventory-ent/pom.xml | 8 +++++ .../com/rzyc/controller/BaseController.java | 5 ++++ .../com/rzyc/controller/UploadController.java | 29 +++++++++++++++++++ .../com/rzyc/service/PcBusinessService.java | 17 +++++++---- .../controller/ent/PcCompanyController.java | 2 +- 6 files changed, 57 insertions(+), 6 deletions(-) diff --git a/inventory-dao/src/main/java/com/rzyc/model/ent/InList.java b/inventory-dao/src/main/java/com/rzyc/model/ent/InList.java index 2705979..c4069cf 100644 --- a/inventory-dao/src/main/java/com/rzyc/model/ent/InList.java +++ b/inventory-dao/src/main/java/com/rzyc/model/ent/InList.java @@ -8,6 +8,7 @@ import java.io.Serializable; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; + /** *

* 行业清单 @@ -16,6 +17,7 @@ import io.swagger.annotations.ApiModelProperty; * @author * @since 2022-09-20 */ + @TableName("in_list") @ApiModel(value="InList对象", description="行业清单") public class InList implements Serializable { diff --git a/inventory-ent/pom.xml b/inventory-ent/pom.xml index 8846fc7..db0314f 100644 --- a/inventory-ent/pom.xml +++ b/inventory-ent/pom.xml @@ -221,6 +221,14 @@ commons-pool2 + + + com.alibaba + easyexcel + 3.1.3 + + + diff --git a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java index 22fe1ee..48810d6 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/BaseController.java @@ -550,6 +550,11 @@ public class BaseController { @Autowired protected EntPostListDetailMapper entPostListDetailMapper; + @Autowired + protected InListMapper inListMapper; + @Autowired + protected InListItemMapper inListItemMapper; + /** * 新都文件地址处理 diff --git a/inventory-ent/src/main/java/com/rzyc/controller/UploadController.java b/inventory-ent/src/main/java/com/rzyc/controller/UploadController.java index 685ecd6..ed3dca8 100644 --- a/inventory-ent/src/main/java/com/rzyc/controller/UploadController.java +++ b/inventory-ent/src/main/java/com/rzyc/controller/UploadController.java @@ -1,5 +1,8 @@ package com.rzyc.controller; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.read.listener.PageReadListener; +import com.alibaba.fastjson.JSON; import com.common.utils.RandomNumber; import com.common.utils.StringUtils; import com.common.utils.model.*; @@ -7,10 +10,13 @@ import com.common.utils.upload.FileUpload; import com.rzyc.bean.file.FileResult; import com.rzyc.bean.file.FileResults; import com.rzyc.model.Sysdocument; +import com.rzyc.model.ent.InList; +import com.rzyc.service.PcBusinessService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -23,6 +29,14 @@ public class UploadController extends com.rzyc.controller.BaseController { private static Map mFileTypes = new HashMap(); + + private PcBusinessService pcBusinessService; + + @Autowired + public UploadController(PcBusinessService pcBusinessService) { + this.pcBusinessService = pcBusinessService; + } + static { /* 图片文件 start */ mFileTypes.put("jpg", "1"); @@ -291,5 +305,20 @@ public class UploadController extends com.rzyc.controller.BaseController { + /** + * EasyExcel读取 + * @return + * @throws Exception + */ + @ApiOperation(value = "EasyExcel读取", notes = "EasyExcel读取") + @ResponseBody + @RequestMapping(value = "/readEasyExcel", method = RequestMethod.GET) + public String readEasyExcel(MultipartFile file)throws Exception{ + pcBusinessService.repeatedRead(file); + return "success"; + } + + + } diff --git a/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java b/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java index 9edabfc..22c35e3 100644 --- a/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java +++ b/inventory-ent/src/main/java/com/rzyc/service/PcBusinessService.java @@ -1,5 +1,6 @@ package com.rzyc.service; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.common.utils.*; @@ -14,7 +15,6 @@ import com.rzyc.config.RedisUtil; import com.rzyc.controller.BaseController; import com.rzyc.enums.DelState; import com.rzyc.enums.RedisKeys; -import com.rzyc.mapper.EntPostTaskMapper; import com.rzyc.model.*; import com.rzyc.model.dto.*; import com.rzyc.model.ent.EntPost; @@ -23,14 +23,14 @@ import com.rzyc.model.dto.SparePartDto; import com.rzyc.model.ent.InEntList; import com.rzyc.model.ent.SysEnterprise; -import org.apache.commons.math3.analysis.function.Sin; -import org.junit.Test; +import com.rzyc.utils.easyexcel.EasyExcelInList; +import com.rzyc.utils.easyexcel.InListListener; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; -import java.text.ParseException; -import java.text.SimpleDateFormat; +import java.io.IOException; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1195,4 +1195,11 @@ public class PcBusinessService extends BaseController { singleResult.setData(list); return singleResult; } + + public SingleResult repeatedRead(MultipartFile file) throws IOException { + SingleResult singleResult = new SingleResult(); + EasyExcel.read(file.getInputStream(), EasyExcelInList.class, new InListListener(inListMapper,inListItemMapper,baseInClassMapper)).doReadAll(); + return singleResult; + } + } diff --git a/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java b/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java index 25eead7..10e41d1 100644 --- a/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java +++ b/inventory-gov/src/main/java/com/rzyc/controller/ent/PcCompanyController.java @@ -292,7 +292,7 @@ public class PcCompanyController extends com.rzyc.controller.BaseController { SingleResult singleResult = new SingleResult(); Pager pager = new Pager<>(); PageHelper.startPage(page, pageSize); - ListbookEntHTS = bookEntHTMapper.dangerDetailByCompanyId(SysEnterpriseId); + ListbookEntHTS = bookEntHTMapper.dangerDetailByCompanyId(SysEnterpriseId,null); PagebookEnt =(Page) bookEntHTS; getDatePage(pager,bookEnt); if (bookEntHTS != null){