|
@@ -1,18 +1,21 @@
|
|
package org.jeecg.modules.oa.controller;
|
|
package org.jeecg.modules.oa.controller;
|
|
|
|
|
|
import java.io.Serializable;
|
|
import java.io.Serializable;
|
|
-import java.io.UnsupportedEncodingException;
|
|
+import java.io.InputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.net.URLDecoder;
|
|
+import java.text.ParseException;
|
|
-import java.util.ArrayList;
|
|
+import java.util.*;
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+
|
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
import org.jeecg.modules.oa.vo.SyCarryPage;
|
|
import org.jeecg.modules.oa.vo.SyCarryPage;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
@@ -22,7 +25,6 @@ import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
|
import org.jeecg.modules.oa.entity.SyCarryB;
|
|
import org.jeecg.modules.oa.entity.SyCarryB;
|
|
import org.jeecg.modules.oa.entity.SyCarry;
|
|
import org.jeecg.modules.oa.entity.SyCarry;
|
|
import org.jeecg.modules.oa.service.ISyCarryService;
|
|
import org.jeecg.modules.oa.service.ISyCarryService;
|
|
@@ -37,7 +39,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
|
|
|
|
* @Description: 搬运装卸费用-搬运工对账单-主表
|
|
* @Description: 搬运装卸费用-搬运工对账单-主表
|
|
@@ -202,17 +203,13 @@ public class SyCarryController {
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
- MultipartFile file = entity.getValue();
|
|
+ MultipartFile file = entity.getValue();
|
|
- ImportParams params = new ImportParams();
|
|
|
|
- params.setTitleRows(2);
|
|
|
|
- params.setHeadRows(1);
|
|
|
|
- params.setNeedSave(true);
|
|
|
|
try {
|
|
try {
|
|
- List<SyCarryPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyCarryPage.class, params);
|
|
+ InputStream inputStream=file.getInputStream();
|
|
- Result<List<SyCarryPage>> result = new Result<>();
|
|
+ Workbook workbook=new XSSFWorkbook(inputStream);
|
|
- result.setMessage("文件导入成功!数据行数:" + list.size());
|
|
+
|
|
- result.setResult(list);
|
|
+ SyCarryPage syCarryPage = refreshSheet2(workbook);
|
|
- return result;
|
|
+ return Result.ok(syCarryPage);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage(),e);
|
|
log.error(e.getMessage(),e);
|
|
return Result.error("文件导入失败:"+e.getMessage());
|
|
return Result.error("文件导入失败:"+e.getMessage());
|
|
@@ -227,6 +224,87 @@ public class SyCarryController {
|
|
return Result.ok("文件导入失败!");
|
|
return Result.ok("文件导入失败!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public SyCarryPage refreshSheet2(Workbook workbook1) throws ParseException {
|
|
|
|
+ Sheet sheet = workbook1.getSheet("Sheet1");
|
|
|
|
+ SyCarryPage syCarryPage = new SyCarryPage();
|
|
|
|
+ List<SyCarryB> syCarryBList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ int endX = 0;
|
|
|
|
+
|
|
|
|
+ for (int x=0;x<=sheet.getLastRowNum();x++){
|
|
|
|
+ Row row=sheet.getRow(x);
|
|
|
|
+ SyCarryB syCarryB = new SyCarryB();
|
|
|
|
+ if(x>=3){
|
|
|
|
+ if(row==null || row.getCell(0)==null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(row.getCell(0).toString().equals("合计:")){
|
|
|
|
+ endX=x;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ syCarryB.setOrderDate(row.getCell(0).getDateCellValue());
|
|
|
|
+ syCarryB.setAllNum(row.getCell(1).getNumericCellValue());
|
|
|
|
+ syCarryB.setDetailedNum(row.getCell(2).getNumericCellValue());
|
|
|
|
+ syCarryB.setCoatHanger(row.getCell(3)==null?0:row.getCell(3).getNumericCellValue());
|
|
|
|
+ syCarryB.setContainerNo(row.getCell(4).getStringCellValue());
|
|
|
|
+ syCarryB.setInvoiceNo(row.getCell(5).getStringCellValue());
|
|
|
|
+ syCarryB.setPrice(row.getCell(6).getNumericCellValue());
|
|
|
|
+ syCarryB.setJhyByData(row.getCell(7).getStringCellValue());
|
|
|
|
+ syCarryB.setJhyNameData(row.getCell(8)==null?"":row.getCell(8).getStringCellValue());
|
|
|
|
+ syCarryB.setDemo(row.getCell(9)==null?"":row.getCell(9).getStringCellValue());
|
|
|
|
+ syCarryBList.add(syCarryB);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ syCarryPage.setSyCarryBList(syCarryBList);
|
|
|
|
+ String demo = sheet.getRow(endX+1).getCell(0).getStringCellValue()+" || "+
|
|
|
|
+ sheet.getRow(endX+2).getCell(0).getStringCellValue()+" || "+
|
|
|
|
+ sheet.getRow(endX+3).getCell(0).getStringCellValue()+" || "+
|
|
|
|
+ sheet.getRow(endX+4).getCell(0).getStringCellValue();
|
|
|
|
+ syCarryPage.setDemo(demo);
|
|
|
|
+ syCarryPage.setTotalNum(sheet.getRow(endX).getCell(3).getNumericCellValue());
|
|
|
|
+ return syCarryPage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
* 通过excel导入数据
|
|
* 通过excel导入数据
|