|
@@ -2,6 +2,9 @@ package cn.com.ctop.toutiao.modules.material.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
|
|
+import cn.com.ctop.common.module.utils.LoadFileUtil;
|
|
|
|
+import cn.com.ctop.shiwan.modules.FileUtil;
|
|
|
|
+import cn.com.ctop.shiwan.modules.entity.ShiwanFileUpload;
|
|
import cn.com.ctop.toutiao.modules.material.entity.FirstDeliveryValidMaterials;
|
|
import cn.com.ctop.toutiao.modules.material.entity.FirstDeliveryValidMaterials;
|
|
import cn.com.ctop.toutiao.modules.material.entity.FirstDeliveryValidRatio;
|
|
import cn.com.ctop.toutiao.modules.material.entity.FirstDeliveryValidRatio;
|
|
import cn.com.ctop.toutiao.modules.material.mapper.FirstDeliveryValidMapper;
|
|
import cn.com.ctop.toutiao.modules.material.mapper.FirstDeliveryValidMapper;
|
|
@@ -10,7 +13,9 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import com.monitorjbl.xlsx.StreamingReader;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
@@ -19,11 +24,18 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileInputStream;
|
|
|
|
+import java.io.InputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
@@ -31,14 +43,17 @@ public class FirstDeliveryValidServiceImpl implements FirstDeliveryValidService
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private FirstDeliveryValidMapper deliveryValidMapper;
|
|
private FirstDeliveryValidMapper deliveryValidMapper;
|
|
-
|
|
|
|
|
|
+ @Value("${zip.local.download-path}")
|
|
|
|
+ private String downloadPath;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result<Object> importExcelMaterials(MultipartFile file) throws Exception {
|
|
public Result<Object> importExcelMaterials(MultipartFile file) throws Exception {
|
|
List<FirstDeliveryValidMaterials> dataList = new ArrayList<>();
|
|
List<FirstDeliveryValidMaterials> dataList = new ArrayList<>();
|
|
|
|
+ StringBuffer path = new StringBuffer();
|
|
try {
|
|
try {
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|
|
List<JSONObject> list = this.analysisFile(file, fileName);
|
|
List<JSONObject> list = this.analysisFile(file, fileName);
|
|
|
|
+ LoadFileUtil.delFile(path.toString());
|
|
for (JSONObject object : list) {
|
|
for (JSONObject object : list) {
|
|
FirstDeliveryValidMaterials material = new FirstDeliveryValidMaterials(object);
|
|
FirstDeliveryValidMaterials material = new FirstDeliveryValidMaterials(object);
|
|
if (!Check.isNull(material.getStatDate())) {
|
|
if (!Check.isNull(material.getStatDate())) {
|
|
@@ -49,6 +64,8 @@ public class FirstDeliveryValidServiceImpl implements FirstDeliveryValidService
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
throw new Exception("导入异常," + e.getMessage());
|
|
throw new Exception("导入异常," + e.getMessage());
|
|
|
|
+ } finally {
|
|
|
|
+ LoadFileUtil.delFile(path.toString());
|
|
}
|
|
}
|
|
if (!Check.isNull(dataList)) {
|
|
if (!Check.isNull(dataList)) {
|
|
//根据当前年份和月份,删除旧数据
|
|
//根据当前年份和月份,删除旧数据
|
|
@@ -191,8 +208,6 @@ public class FirstDeliveryValidServiceImpl implements FirstDeliveryValidService
|
|
page.setTotal(total);
|
|
page.setTotal(total);
|
|
return Result.OK(page);
|
|
return Result.OK(page);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
public static List<JSONObject> analysisFile(MultipartFile file, String fileName) throws Exception {
|
|
public static List<JSONObject> analysisFile(MultipartFile file, String fileName) throws Exception {
|
|
JSONObject returnJson = new JSONObject();
|
|
JSONObject returnJson = new JSONObject();
|
|
Workbook workbook = null;
|
|
Workbook workbook = null;
|