
18 changed files with 1039 additions and 79 deletions
@ -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 <br/> |
||||
|
* File: GdInventory.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdInventory <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 19:59 <br/> |
||||
|
* |
||||
|
* @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; // 数据日期
|
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdInventoryMapper.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryMapper <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:30 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface GdInventoryMapper extends BaseMapper<GdInventory> { |
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdInventoryOk.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryOk <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:17 <br/> |
||||
|
* |
||||
|
* @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; // 数据日期
|
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdInventoryOkMapper.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryOkMapper <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:31 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface GdInventoryOkMapper extends BaseMapper<GdInventoryOk> { |
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdInventoryOkService.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryOkService <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:35 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class GdInventoryOkService extends ServiceImpl<GdInventoryOkMapper,GdInventoryOk> { |
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdInventoryRest.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryRest <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 18:37 <br/> |
||||
|
* |
||||
|
* @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(); |
||||
|
} |
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdInventoryService.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdInventoryService <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:34 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class GdInventoryService extends ServiceImpl<GdInventoryMapper, GdInventory> { |
||||
|
|
||||
|
private static List<String> codeList = null; |
||||
|
|
||||
|
@Autowired |
||||
|
private GdRescategoryProdService gdRescategoryProdService; |
||||
|
@Autowired |
||||
|
private GdInventoryOkService gdInventoryOkService; |
||||
|
|
||||
|
public void doCheck() { |
||||
|
|
||||
|
if (codeList == null) { |
||||
|
codeList = gdRescategoryProdService.listCode(); |
||||
|
} |
||||
|
|
||||
|
List<GdInventory> list = super.list(); |
||||
|
long ll = list.size(); |
||||
|
int x = 0; |
||||
|
int y = 0; |
||||
|
int num = 0; |
||||
|
List<GdInventoryOk> 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<de.siegmar.fastcsv.reader.CsvRow> iterator = red.stream().iterator(); |
||||
|
int x = 0; |
||||
|
int num = 0; |
||||
|
List<GdInventory> 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<GdInventory> 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<CsvRow> iterator = read.iterator(); |
||||
|
int x = 0; |
||||
|
int num = 0; |
||||
|
List<GdInventory> 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<GdInventory> toInsertList = new ArrayList<>(); |
||||
|
private int x = 0; |
||||
|
private int num = 0; |
||||
|
|
||||
|
@Override |
||||
|
public void handle(int i, long l, List<Object> 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(); |
||||
|
} |
||||
|
}; |
||||
|
} |
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdRescategoryProd.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdRescategoryProd <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:21 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("gd_rescategory_prod") |
||||
|
public class GdRescategoryProd extends EntityWithId { |
||||
|
private String prodCode; |
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdRescategoryProdMapper.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdRescategoryProdMapper <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:32 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface GdRescategoryProdMapper extends BaseMapper<GdRescategoryProd> { |
||||
|
} |
@ -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 <br/> |
||||
|
* File: GdRescategoryProdService.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.biz.gdinventory.GdRescategoryProdService <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/11/30 20:36 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class GdRescategoryProdService extends ServiceImpl<GdRescategoryProdMapper, GdRescategoryProd> { |
||||
|
public List<String> listCode() { |
||||
|
List<String> res = new ArrayList<>(); |
||||
|
List<GdRescategoryProd> list = super.list(); |
||||
|
list.forEach(entity -> res.add(entity.getProdCode().trim())); |
||||
|
return res; |
||||
|
} |
||||
|
} |
@ -0,0 +1,120 @@ |
|||||
|
/********************************************************* |
||||
|
********************************************************* |
||||
|
******************** ******************* |
||||
|
************* ************ |
||||
|
******* _oo0oo_ ******* |
||||
|
*** o8888888o *** |
||||
|
* 88" . "88 * |
||||
|
* (| -_- |) * |
||||
|
* 0\ = /0 * |
||||
|
* ___/`---'\___ * |
||||
|
* .' \\| |// '. *
|
||||
|
* / \\||| : |||// \ *
|
||||
|
* / _||||| -:- |||||- \ * |
||||
|
* | | \\\ - /// | | *
|
||||
|
* | \_| ''\---/'' |_/ | * |
||||
|
* \ .-\__ '-' ___/-. / * |
||||
|
* ___'. .' /--.--\ `. .'___ * |
||||
|
* ."" '< `.___\_<|>_/___.' >' "". * |
||||
|
* | | : `- \`.;`\ _ /`;.`/ - ` : | | * |
||||
|
* \ \ `_. \_ __\ /__ _/ .-` / / * |
||||
|
* =====`-.____`.___ \_____/___.-`___.-'===== * |
||||
|
* `=---=' * |
||||
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * |
||||
|
*********__佛祖保佑__永无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 <br/> |
||||
|
* File: CsvTool.java <br/> |
||||
|
* Class: com.yxt.supervise.portal.extexcel.CsvTool <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2022/12/1 0:33 <br/> |
||||
|
* |
||||
|
* @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; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue