From a7602fd6d6c1301023530cc2a6e59c79642d34f1 Mon Sep 17 00:00:00 2001 From: lzh Date: Thu, 1 Dec 2022 21:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=95=B0=E6=8D=AE=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=8F=8Acsv\xlsx=E6=95=B0=E6=8D=AE=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supervise-portal-biz/pom.xml | 13 +- .../portal/biz/gdinventory/GdInventory.java | 59 ++++ .../biz/gdinventory/GdInventoryMapper.java | 46 +++ .../portal/biz/gdinventory/GdInventoryOk.java | 59 ++++ .../biz/gdinventory/GdInventoryOkMapper.java | 46 +++ .../biz/gdinventory/GdInventoryOkService.java | 46 +++ .../biz/gdinventory/GdInventoryRest.java | 64 ++++ .../biz/gdinventory/GdInventoryService.java | 330 ++++++++++++++++++ .../biz/gdinventory/GdRescategoryProd.java | 49 +++ .../gdinventory/GdRescategoryProdMapper.java | 46 +++ .../gdinventory/GdRescategoryProdService.java | 55 +++ .../storein/StoreInHSSFRowReaderConver.java | 14 +- .../StoreInItemHSSFRowReaderConver.java | 36 +- .../portal/biz/storein/StoreInService.java | 50 +-- .../portal/biz/storeout/StoreOutService.java | 50 +-- .../supervise/portal/extexcel/CsvTool.java | 120 +++++++ .../{ExcelUtil.java => ExcelTool.java} | 33 +- .../src/main/resources/application-devv.yml | 2 +- 18 files changed, 1039 insertions(+), 79 deletions(-) create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventory.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryMapper.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOk.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkMapper.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkService.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryRest.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryService.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProd.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdMapper.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdService.java create mode 100644 yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/CsvTool.java rename yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/{ExcelUtil.java => ExcelTool.java} (71%) diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/pom.xml b/yxt_supervise/supervise-portal/supervise-portal-biz/pom.xml index 607d9855..bf0c5abb 100644 --- a/yxt_supervise/supervise-portal/supervise-portal-biz/pom.xml +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/pom.xml @@ -100,8 +100,17 @@ activation 1.1.1 - - + + + net.sourceforge.javacsv + javacsv + 2.0 + + + de.siegmar + fastcsv + 2.2.1 + diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventory.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventory.java new file mode 100644 index 00000000..95c4e11a --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventory.java @@ -0,0 +1,59 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.yxt.common.core.domain.EntityWithId; +import lombok.Data; + +/** + * Project: yxt_supervise
+ * File: GdInventory.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdInventory
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 19:59
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Data +@TableName("gd_inventory") +public class GdInventory extends EntityWithId { + private String orgCode; // 企业组织机构代码证 + private String warehouseCode; // 仓库/门店编号 + private String warehouseName; // 仓库/门店名称 + private String prodCode; // 商品编码 + private String prodBarCode; // 商品条码 + private String prodName; // 商品名称 + private int warehouseType; // 仓库类型 + private int prodNum; // 商品数量 + private double prodValue; // 商品货值 + private String suppliderName; // 供应商 + private String datadate; // 数据日期 +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryMapper.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryMapper.java new file mode 100644 index 00000000..7d29ce57 --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryMapper.java @@ -0,0 +1,46 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * Project: yxt_supervise
+ * File: GdInventoryMapper.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryMapper
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:30
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Mapper +public interface GdInventoryMapper extends BaseMapper { +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOk.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOk.java new file mode 100644 index 00000000..01f0bfe1 --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOk.java @@ -0,0 +1,59 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.yxt.common.core.domain.EntityWithId; +import lombok.Data; + +/** + * Project: yxt_supervise
+ * File: GdInventoryOk.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryOk
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:17
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Data +@TableName("gd_inventory_ok") +public class GdInventoryOk extends EntityWithId { + private String orgCode; // 企业组织机构代码证 + private String warehouseCode; // 仓库/门店编号 + private String warehouseName; // 仓库/门店名称 + private String prodCode; // 商品编码 + private String prodBarCode; // 商品条码 + private String prodName; // 商品名称 + private int warehouseType; // 仓库类型 + private int prodNum; // 商品数量 + private double prodValue; // 商品货值 + private String suppliderName; // 供应商 + private String datadate; // 数据日期 +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkMapper.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkMapper.java new file mode 100644 index 00000000..b6903fbd --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkMapper.java @@ -0,0 +1,46 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * Project: yxt_supervise
+ * File: GdInventoryOkMapper.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryOkMapper
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:31
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Mapper +public interface GdInventoryOkMapper extends BaseMapper { +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkService.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkService.java new file mode 100644 index 00000000..b3ad0899 --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryOkService.java @@ -0,0 +1,46 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * Project: yxt_supervise
+ * File: GdInventoryOkService.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryOkService
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:35
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Service +public class GdInventoryOkService extends ServiceImpl { +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryRest.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryRest.java new file mode 100644 index 00000000..3af69cae --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryRest.java @@ -0,0 +1,64 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' /| |// '. * + * / /||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | /\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.yxt.common.core.result.ResultBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Project: yxt_supervise
+ * File: GdInventoryRest.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryRest
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 18:37
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@RestController("com.yxt.supervise.portal.biz.gdinventory.GdInventoryRest") +@RequestMapping("/gd") +public class GdInventoryRest { + + @Autowired + private GdInventoryService gdInventoryService; + + @GetMapping("/implInventory") + public ResultBean implInventory() { + + // gdInventoryService.doCheck(); + // gdInventoryService.importFromCsvFilePathHutool("D:/works/projects/javaee/lzh/niejinyi/yunyan/docs/sheji/wx20221130/汇融银行_库存信息查询.csv"); + // gdInventoryService.importFromCsvFilePathFastCsv("D:/works/projects/javaee/lzh/niejinyi/yunyan/docs/sheji/wx20221130/汇融银行_库存信息查询.csv"); + // gdInventoryService.importFromCsvFilePathJavaCsv("D:/works/projects/javaee/lzh/niejinyi/yunyan/docs/sheji/wx20221130/汇融银行_库存信息查询.csv"); + gdInventoryService.importFromXlsx("D:/works/projects/javaee/lzh/niejinyi/yunyan/docs/sheji/wx20221130/汇融银行_库存信息查询.xlsx"); + return ResultBean.fireSuccess(); + } +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryService.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryService.java new file mode 100644 index 00000000..a79b4f7c --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdInventoryService.java @@ -0,0 +1,330 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.text.csv.*; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.sax.handler.RowHandler; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yxt.supervise.portal.extexcel.CsvTool; +import com.yxt.supervise.portal.extexcel.ExcelTool; +import org.apache.poi.ss.usermodel.CellStyle; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Project: yxt_supervise
+ * File: GdInventoryService.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryService
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:34
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Service +public class GdInventoryService extends ServiceImpl { + + private static List codeList = null; + + @Autowired + private GdRescategoryProdService gdRescategoryProdService; + @Autowired + private GdInventoryOkService gdInventoryOkService; + + public void doCheck() { + + if (codeList == null) { + codeList = gdRescategoryProdService.listCode(); + } + + List list = super.list(); + long ll = list.size(); + int x = 0; + int y = 0; + int num = 0; + List okList = new ArrayList<>(); + + for (GdInventory entity : list) { + if (codeList.contains(entity.getProdCode().trim())) { + GdInventoryOk ok = new GdInventoryOk(); + BeanUtil.copyProperties(entity, ok, "id"); + // gdInventoryOkService.save(ok); + + okList.add(ok); + if (500 == num) { + gdInventoryOkService.saveBatch(okList); + num = 0; + okList.clear(); + } else { + num++; + } + + x++; + System.out.println("XX " + entity.getProdCode() + "-" + entity.getProdName() + "size:" + ll + ",X:" + x + ",Y:" + y); + } else { + y++; + System.out.println("-" + entity.getProdCode() + "-" + entity.getProdName() + "size:" + ll + ",X:" + x + ",Y:" + y); + } + + } + if (okList != null && !okList.isEmpty()) { + gdInventoryOkService.saveBatch(okList); + } + } + + public void importFromCsvFilePathFastCsv(String filePath) { + + long millis = System.currentTimeMillis(); + de.siegmar.fastcsv.reader.CsvReader red = null; + try { + red = de.siegmar.fastcsv.reader.CsvReader.builder().build(Paths.get(filePath), Charset.forName("GB2312")); + } catch (IOException e) { + throw new RuntimeException(e); + } + Iterator iterator = red.stream().iterator(); + int x = 0; + int num = 0; + List toInsertList = new ArrayList<>(); + while (iterator.hasNext()) { + de.siegmar.fastcsv.reader.CsvRow r = iterator.next(); + if (x > 0) { + GdInventory gd = createGdInventoryFromRowFastCsv(r); + toInsertList.add(gd); + if (800 == num) { + this.saveBatch(toInsertList); + num = 0; + toInsertList.clear(); + } else { + num++; + } + } + x++; + System.out.println(",X:" + x); + + } + if (toInsertList != null && !toInsertList.isEmpty()) { + this.saveBatch(toInsertList); + } + + System.out.println("用时:" + (System.currentTimeMillis() - millis)); + } + + private GdInventory createGdInventoryFromRowFastCsv(de.siegmar.fastcsv.reader.CsvRow r) { + GdInventory gd = new GdInventory(); + gd.setOrgCode(r.getField(0)); // 企业组织机构代码证 + gd.setWarehouseCode(r.getField(1)); // 仓库/门店编号 + gd.setWarehouseName(r.getField(2)); // 仓库/门店名称 + gd.setProdCode(r.getField(3)); // 商品编码 + gd.setProdBarCode(r.getField(4)); // 商品条码 + gd.setProdName(r.getField(5)); // 商品名称 + gd.setWarehouseType(CsvTool.readIntegerFastCsv(r, 6)); // 仓库类型 + gd.setProdNum(CsvTool.readIntegerFastCsv(r, 7)); // 商品数量 + gd.setProdValue(CsvTool.readDoubleFastCsv(r, 8)); // 商品货值 + gd.setSuppliderName(r.getField(9)); // 供应商 + gd.setDatadate(r.getField(10)); // 数据日期 + return gd; + } + + + public void importFromCsvFilePathJavaCsv(String filePath) { + + long millis = System.currentTimeMillis(); + int x = 0; + int num = 0; + List toInsertList = new ArrayList<>(); + + try { + com.csvreader.CsvReader r = new com.csvreader.CsvReader(filePath, ',', Charset.forName("GBK")); + //读取表头 + r.readHeaders(); + //逐条读取记录,直至读完 + while (r.readRecord()) { + GdInventory gd = createGdInventoryFromRowJavaCsv(r); + toInsertList.add(gd); + if (800 == num) { + this.saveBatch(toInsertList); + num = 0; + toInsertList.clear(); + } else { + num++; + } + x++; + System.out.println(",X:" + x); + + } + r.close(); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + + if (toInsertList != null && !toInsertList.isEmpty()) { + this.saveBatch(toInsertList); + } + + System.out.println("用时:" + (System.currentTimeMillis() - millis)); + } + + private GdInventory createGdInventoryFromRowJavaCsv(com.csvreader.CsvReader r) throws IOException { + GdInventory gd = new GdInventory(); + gd.setOrgCode(r.get(0)); // 企业组织机构代码证 + gd.setWarehouseCode(r.get(1)); // 仓库/门店编号 + gd.setWarehouseName(r.get(2)); // 仓库/门店名称 + gd.setProdCode(r.get(3)); // 商品编码 + gd.setProdBarCode(r.get(4)); // 商品条码 + gd.setProdName(r.get(5)); // 商品名称 + gd.setWarehouseType(CsvTool.readIntegerJavaCsv(r, 6)); // 仓库类型 + gd.setProdNum(CsvTool.readIntegerJavaCsv(r, 7)); // 商品数量 + gd.setProdValue(CsvTool.readDoubleJavaCsv(r, 8)); // 商品货值 + gd.setSuppliderName(r.get(9)); // 供应商 + gd.setDatadate(r.get(10)); // 数据日期 + return gd; + } + + + public void importFromCsvFilePathHutool(String filePath) { + + long millis = System.currentTimeMillis(); + CsvReader red = CsvUtil.getReader(); + CsvData read = red.read(FileUtil.file(filePath)); + // read.getHeader(); + Iterator iterator = read.iterator(); + int x = 0; + int num = 0; + List toInsertList = new ArrayList<>(); + while (iterator.hasNext()) { + CsvRow r = iterator.next(); + if (x > 0) { + GdInventory gd = createGdInventoryFromRowHutool(r); + toInsertList.add(gd); + if (800 == num) { + this.saveBatch(toInsertList); + num = 0; + toInsertList.clear(); + } else { + num++; + } + } + x++; + System.out.println(",X:" + x); + + } + if (toInsertList != null && !toInsertList.isEmpty()) { + this.saveBatch(toInsertList); + } + + System.out.println("用时:" + (System.currentTimeMillis() - millis)); + } + + private GdInventory createGdInventoryFromRowHutool(CsvRow r) { + GdInventory gd = new GdInventory(); + gd.setOrgCode(r.get(0)); // 企业组织机构代码证 + gd.setWarehouseCode(r.get(1)); // 仓库/门店编号 + gd.setWarehouseName(r.get(2)); // 仓库/门店名称 + gd.setProdCode(r.get(3)); // 商品编码 + gd.setProdBarCode(r.get(4)); // 商品条码 + gd.setProdName(r.get(5)); // 商品名称 + gd.setWarehouseType(CsvTool.readInteger(r, 6)); // 仓库类型 + gd.setProdNum(CsvTool.readInteger(r, 7)); // 商品数量 + gd.setProdValue(CsvTool.readDouble(r, 8)); // 商品货值 + gd.setSuppliderName(r.get(9)); // 供应商 + gd.setDatadate(r.get(10)); // 数据日期 + return gd; + } + + public void importFromXlsx(String filePath) { + long millis = System.currentTimeMillis(); + ExcelUtil.readBySax(filePath, 0, createRowHandler()); + System.out.println("用时:" + (System.currentTimeMillis() - millis)); + } + + private RowHandler createRowHandler() { + return new RowHandler() { + + private List toInsertList = new ArrayList<>(); + private int x = 0; + private int num = 0; + + @Override + public void handle(int i, long l, List r) { + if (l > 0) { + GdInventory gd = new GdInventory(); + + gd.setOrgCode((String) r.get(0)); // 企业组织机构代码证 + gd.setWarehouseCode((String) r.get(1)); // 仓库/门店编号 + gd.setWarehouseName((String) r.get(2)); // 仓库/门店名称 + gd.setProdCode((String) r.get(3)); // 商品编码 + gd.setProdBarCode((String) r.get(4)); // 商品条码 + gd.setProdName((String) r.get(5)); // 商品名称 + gd.setWarehouseType(ExcelTool.toInt(r.get(6))); // 仓库类型 + gd.setProdNum(ExcelTool.toInt(r.get(7))); // 商品数量 + gd.setProdValue(ExcelTool.toDouble(r.get(8))); // 商品货值 + gd.setSuppliderName((String) r.get(9)); // 供应商 + gd.setDatadate((String) r.get(10)); // 数据日期 + + toInsertList.add(gd); + if (800 == num) { + GdInventoryService.this.saveBatch(toInsertList); + num = 0; + toInsertList.clear(); + } else { + num++; + } + x++; + System.out.println(",X:" + x); + } + } + + @Override + public void handleCell(int sheetIndex, long rowIndex, int cellIndex, Object value, CellStyle xssfCellStyle) { + RowHandler.super.handleCell(sheetIndex, rowIndex, cellIndex, value, xssfCellStyle); + } + + @Override + public void doAfterAllAnalysed() { + if (toInsertList != null && !toInsertList.isEmpty()) { + GdInventoryService.this.saveBatch(toInsertList); + } + RowHandler.super.doAfterAllAnalysed(); + } + }; + } +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProd.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProd.java new file mode 100644 index 00000000..f2272b96 --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProd.java @@ -0,0 +1,49 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.yxt.common.core.domain.EntityWithId; +import lombok.Data; + +/** + * Project: yxt_supervise
+ * File: GdRescategoryProd.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdRescategoryProd
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:21
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Data +@TableName("gd_rescategory_prod") +public class GdRescategoryProd extends EntityWithId { + private String prodCode; +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdMapper.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdMapper.java new file mode 100644 index 00000000..449cbee6 --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdMapper.java @@ -0,0 +1,46 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * Project: yxt_supervise
+ * File: GdRescategoryProdMapper.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdRescategoryProdMapper
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:32
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Mapper +public interface GdRescategoryProdMapper extends BaseMapper { +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdService.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdService.java new file mode 100644 index 00000000..7762882e --- /dev/null +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdinventory/GdRescategoryProdService.java @@ -0,0 +1,55 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.biz.gdinventory; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Project: yxt_supervise
+ * File: GdRescategoryProdService.java
+ * Class: com.yxt.supervise.portal.biz.gdinventory.GdRescategoryProdService
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/11/30 20:36
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Service +public class GdRescategoryProdService extends ServiceImpl { + public List listCode() { + List res = new ArrayList<>(); + List list = super.list(); + list.forEach(entity -> res.add(entity.getProdCode().trim())); + return res; + } +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInHSSFRowReaderConver.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInHSSFRowReaderConver.java index 269520da..befb927c 100644 --- a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInHSSFRowReaderConver.java +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInHSSFRowReaderConver.java @@ -26,7 +26,7 @@ package com.yxt.supervise.portal.biz.storein; import com.yxt.supervise.portal.api.storein.StoreIn; -import com.yxt.supervise.portal.extexcel.ExcelUtil; +import com.yxt.supervise.portal.extexcel.ExcelTool; import com.yxt.supervise.portal.extexcel.HSSFRowReaderConver; import org.apache.poi.hssf.usermodel.HSSFRow; import org.springframework.stereotype.Component; @@ -55,12 +55,12 @@ public class StoreInHSSFRowReaderConver implements HSSFRowReaderConver // `billNo` VARCHAR(100) NULL DEFAULT NULL COMMENT '单据号', // `billType` VARCHAR(100) NULL DEFAULT NULL COMMENT '单据类型', StoreIn si = new StoreIn(); - si.setOrgCode(ExcelUtil.readStringFromHSSFRow(row, 0)); - si.setStoreCode(ExcelUtil.readStringFromHSSFRow(row, 1)); - si.setStoreName(ExcelUtil.readStringFromHSSFRow(row, 2)); - si.setReceiptTime(ExcelUtil.readDateTimeFromHSSFRow(row, 3)); - si.setBillNo(ExcelUtil.readStringFromHSSFRow(row, 5)); - si.setBillType(ExcelUtil.readStringFromHSSFRow(row, 6)); + si.setOrgCode(ExcelTool.readStringFromHSSFRow(row, 0)); + si.setStoreCode(ExcelTool.readStringFromHSSFRow(row, 1)); + si.setStoreName(ExcelTool.readStringFromHSSFRow(row, 2)); + si.setReceiptTime(ExcelTool.readDateTimeFromHSSFRow(row, 3)); + si.setBillNo(ExcelTool.readStringFromHSSFRow(row, 5)); + si.setBillType(ExcelTool.readStringFromHSSFRow(row, 6)); return si; } diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInItemHSSFRowReaderConver.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInItemHSSFRowReaderConver.java index 72f7add2..9d862be1 100644 --- a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInItemHSSFRowReaderConver.java +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/storein/StoreInItemHSSFRowReaderConver.java @@ -26,7 +26,7 @@ package com.yxt.supervise.portal.biz.storein; import com.yxt.supervise.portal.api.storein.StoreInItem; -import com.yxt.supervise.portal.extexcel.ExcelUtil; +import com.yxt.supervise.portal.extexcel.ExcelTool; import com.yxt.supervise.portal.extexcel.HSSFRowReaderConver; import org.apache.poi.hssf.usermodel.HSSFRow; import org.springframework.stereotype.Component; @@ -69,23 +69,23 @@ public class StoreInItemHSSFRowReaderConver implements HSSFRowReaderConver_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.supervise.portal.extexcel; + +import cn.hutool.core.text.csv.CsvRow; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; + +/** + * Project: yxt_supervise
+ * File: CsvTool.java
+ * Class: com.yxt.supervise.portal.extexcel.CsvTool
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2022/12/1 0:33
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +public class CsvTool { + + public static int readInteger(CsvRow row, int col) { + String s = row.get(col); + if (StringUtils.isBlank(s)) + return 0; + int rs = 0; + try { + rs = Integer.parseInt(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } + public static double readDouble(CsvRow row, int col) { + String s = row.get(col); + if (StringUtils.isBlank(s)) + return 0; + double rs = 0L; + try { + rs = Double.parseDouble(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } + public static int readIntegerFastCsv(de.siegmar.fastcsv.reader.CsvRow row, int col) { + String s = row.getField(col); + if (StringUtils.isBlank(s)) + return 0; + int rs = 0; + try { + rs = Integer.parseInt(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } + public static double readDoubleFastCsv(de.siegmar.fastcsv.reader.CsvRow row, int col) { + String s = row.getField(col); + if (StringUtils.isBlank(s)) + return 0; + double rs = 0L; + try { + rs = Double.parseDouble(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } + public static int readIntegerJavaCsv(com.csvreader.CsvReader row, int col) throws IOException { + String s = row.get(col); + if (StringUtils.isBlank(s)) + return 0; + int rs = 0; + try { + rs = Integer.parseInt(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } + public static double readDoubleJavaCsv(com.csvreader.CsvReader row, int col) throws IOException { + String s = row.get(col); + if (StringUtils.isBlank(s)) + return 0; + double rs = 0L; + try { + rs = Double.parseDouble(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } +} diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/ExcelUtil.java b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/ExcelTool.java similarity index 71% rename from yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/ExcelUtil.java rename to yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/ExcelTool.java index 4f5a0789..9d2f63db 100644 --- a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/ExcelUtil.java +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/extexcel/ExcelTool.java @@ -9,7 +9,7 @@ import org.apache.poi.ss.usermodel.CellType; import java.util.Date; -public class ExcelUtil { +public class ExcelTool { public static String readStringFromHSSFRow(HSSFRow row, int col) { HSSFCell cell = row.getCell(col); @@ -61,4 +61,35 @@ public class ExcelUtil { } return rs; } + + + public static int toInt(Object obj) { + if (obj == null) + return 0; + String s = obj.toString(); + if (StringUtils.isBlank(s)) + return 0; + int rs = 0; + try { + rs = Integer.parseInt(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } + + public static double toDouble(Object obj) { + if (obj == null) + return 0; + String s = obj.toString(); + if (StringUtils.isBlank(s)) + return 0; + double rs = 0; + try { + rs = Double.parseDouble(s); + } catch (Exception e) { + e.printStackTrace(); + } + return rs; + } } diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application-devv.yml b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application-devv.yml index 9851a19e..5567f4f2 100644 --- a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application-devv.yml +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application-devv.yml @@ -17,7 +17,7 @@ spring: max-idle: 8 #连接池中的最大空闲连接 max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) min-idle: 0 # 连接池中的最小空闲连接 - password: 123456 + password: port: 6379 timeout: 0 # 连接超时时间(毫秒)