|
@@ -3,6 +3,7 @@ package org.jeecg.modules.spapl.controller;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -20,6 +21,8 @@ import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.modules.documents.letterDeposit.entity.SyLetterDepositItem;
|
|
|
import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
|
|
@@ -752,7 +755,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
@AutoLog(value = "导出")
|
|
|
@ApiOperation(value="导出", notes="导出")
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
- public Result<SyPreAssembledPackingList> exportXls3(HttpServletRequest request,HttpServletResponse response,String id) {
|
|
|
+ public Result<SyPreAssembledPackingList> exportXls3(HttpServletRequest request,HttpServletResponse response,String id,String status) {
|
|
|
SyPreAssembledPackingList syPreAssembledPackingList=new SyPreAssembledPackingList();
|
|
|
if(oConvertUtils.isNotEmpty(id)){
|
|
|
syPreAssembledPackingList.setId(id);
|
|
@@ -781,6 +784,9 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
temps.add(preAssembledPackingList);
|
|
|
}
|
|
|
String load="D:\\单证模板\\test2.xlsx";
|
|
|
+ if(status.equals("1")){
|
|
|
+ load="D:\\单证模板\\预装箱单成衣.xlsx";
|
|
|
+ }
|
|
|
int count = temps.size();//分几条sheet
|
|
|
File file=new File(load);
|
|
|
TemplateExportParams templateExcelConstants=new TemplateExportParams(file.getAbsolutePath(),true,"预装箱单");
|
|
@@ -797,7 +803,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
maps.put(0,listMap);
|
|
|
templateExcelConstants.setColForEach(true);
|
|
|
Workbook workbook = ExcelExportUtil.exportExcelClone(maps,templateExcelConstants);
|
|
|
- refreshSheet(workbook,temps);//配置某列数据
|
|
|
+ refreshSheet(workbook,temps,status);//配置某列数据
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
workbook.write(outputStream);
|
|
|
|
|
@@ -815,7 +821,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
|
|
|
}
|
|
|
|
|
|
- protected static void refreshSheet(Workbook workbook,List<SyPreAssembledPackingList> items) {
|
|
|
+ protected static void refreshSheet(Workbook workbook,List<SyPreAssembledPackingList> items,String name) {
|
|
|
CellStyle cellStyle = workbook.createCellStyle();//设置单元格样式
|
|
|
|
|
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);//左右居中
|
|
@@ -849,32 +855,68 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
for (SizeTable size : sypres.getSizeTables()){
|
|
|
strs+=size.getSize()+",";
|
|
|
}
|
|
|
- String[] params=("序号,H/D,PO,款号,订单号,UNIT PRICE(单价),分销点,ITEMCODE,启始箱号,结束箱号,颜色(中英文),"+strs+"件数/每箱,箱数,总件数,外箱长度,外箱宽度,外箱高度,总体积,外箱净重,总净重,外箱毛重,总毛重,NN.W,总价,Lot NO,Packs CODE,DC NO,SKU号码,LABEL(标签),ORDER NO,Pre-Pack SKU Number").split(",");
|
|
|
- Row row2 = sheet.createRow(3);
|
|
|
- for (int x=0;x<params.length;x++){
|
|
|
- Cell cell = row2.createCell(x);//横向
|
|
|
- if(x>10&&x<params.length-20){
|
|
|
- cell.setCellStyle(cellStyle);
|
|
|
- }else{
|
|
|
- cell.setCellStyle(cellStyle2);
|
|
|
+ String[] params;
|
|
|
+ if(name.equals("1")){
|
|
|
+ params=("序号,账套号,成衣工厂,H/D,PO,款号,订单号,UNIT PRICE(单价),分销点,ITEMCODE,PREPACK SKU,启始箱号,结束箱号," +
|
|
|
+ "颜色(中英文),配码,"+strs+"件数/每箱,箱数,总件数,外箱长度,外箱宽度,外箱高度,总体积,外箱净重,总净重," +
|
|
|
+ "外箱毛重,总毛重,NN.W,总价,业务员,业务部门,采购委外订单号,主表id,子表id").split(",");
|
|
|
+ Row row2 = sheet.createRow(3);
|
|
|
+ for (int x=0;x<params.length;x++){
|
|
|
+ Cell cell = row2.createCell(x);//横向
|
|
|
+ if(x>14&&x<params.length-18){
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }else{
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ }
|
|
|
+ cell.setCellValue(params[x]);//比例
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ params=("序号,H/D,PO,款号,订单号,UNIT PRICE(单价),分销点,ITEMCODE,启始箱号,结束箱号," +
|
|
|
+ "颜色(中英文),"+strs+"件数/每箱,箱数,总件数,外箱长度,外箱宽度,外箱高度,总体积,外箱净重,总净重," +
|
|
|
+ "外箱毛重,总毛重,NN.W,总价,Lot NO,Packs CODE,DC NO,SKU号码,LABEL(标签),ORDER NO,Pre-Pack SKU Number").split(",");
|
|
|
+ Row row2 = sheet.createRow(3);
|
|
|
+ for (int x=0;x<params.length;x++){
|
|
|
+ Cell cell = row2.createCell(x);//横向
|
|
|
+ if(x>10&&x<params.length-20){
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }else{
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ }
|
|
|
+ cell.setCellValue(params[x]);//比例
|
|
|
}
|
|
|
- cell.setCellValue(params[x]);//比例
|
|
|
}
|
|
|
List<SizeTable> sizes=list.get(i).getSizeTables();
|
|
|
SyPreAssembledPackingListItem itemN=list.get(0);
|
|
|
- params=list.get(i).toString().replace("null","").split(",");
|
|
|
- for (int y=0;y<params.length;y++){
|
|
|
- Cell cell = row.createCell(y);//横向
|
|
|
- if(y==0){
|
|
|
- cell.setCellStyle(cellStyle2);
|
|
|
- cell.setCellValue(i+1);//比例
|
|
|
- continue;
|
|
|
- } else if(y>10&&y<params.length-20){
|
|
|
- cell.setCellStyle(cellStyle);
|
|
|
- }else{
|
|
|
- cell.setCellStyle(cellStyle2);
|
|
|
+ if(name.equals("1")){
|
|
|
+ params=list.get(i).toString3().replace("null","").split(",");
|
|
|
+ for (int y=0;y<params.length;y++){
|
|
|
+ Cell cell = row.createCell(y);//横向
|
|
|
+ if(y==0){
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ cell.setCellValue(i+1);//比例
|
|
|
+ continue;
|
|
|
+ } else if(y>14&&y<params.length-18){
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }else{
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ }
|
|
|
+ cell.setCellValue(params[y]);//比例
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ params=list.get(i).toString2().replace("null","").split(",");
|
|
|
+ for (int y=0;y<params.length;y++){
|
|
|
+ Cell cell = row.createCell(y);//横向
|
|
|
+ if(y==0){
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ cell.setCellValue(i+1);//比例
|
|
|
+ continue;
|
|
|
+ } else if(y>10&&y<params.length-20){
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }else{
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ }
|
|
|
+ cell.setCellValue(params[y]);//比例
|
|
|
}
|
|
|
- cell.setCellValue(params[y]);//比例
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -968,4 +1010,102 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
public SyLetterDepositItem typeConversion(@RequestBody SyPreAssembledPackingListItem syPreAssembledPackingListItem) {
|
|
|
return syPreAssembledPackingListService.typeConversion(syPreAssembledPackingListItem);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/importExcel3", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel2(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
+ Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
+ try{
|
|
|
+ for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
+ MultipartFile file = entity.getValue();// 获取上传文件对象
|
|
|
+ System.out.println("文件是否为空--isfile\t"+file.isEmpty());
|
|
|
+ System.out.println("文件全称--fileName\t"+file.getOriginalFilename());
|
|
|
+ System.out.println("文件类型--fileType\t"+file.getContentType());
|
|
|
+ System.out.println("文件大小--fileSize\t"+file.getSize()/1024+"KB");
|
|
|
+ InputStream inputStream=file.getInputStream();
|
|
|
+ ImportParams params = new ImportParams();
|
|
|
+ System.out.println("inputSream:\t"+inputStream);
|
|
|
+ Workbook workbook=new XSSFWorkbook(inputStream);
|
|
|
+ refreshSheet(workbook);
|
|
|
+ params.setTitleRows(2);
|
|
|
+ params.setHeadRows(1);
|
|
|
+ params.setNeedSave(true);
|
|
|
+ }
|
|
|
+ return Result.OK("文件传输成功!");
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ System.err.println("抛出"+e.getMessage());
|
|
|
+ return Result.error("文件导入失败"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void refreshSheet(Workbook workbook1) {
|
|
|
+ //String load="C:\\Users\\admin\\Downloads\\装箱单测试.xls";
|
|
|
+ //头表目前固定七个字段数据
|
|
|
+ List <SyPreAssembledPackingList> mains=new ArrayList<>();
|
|
|
+ Iterator sheets=workbook1.sheetIterator();
|
|
|
+ int num=0;
|
|
|
+ while (sheets.hasNext()){
|
|
|
+ num++;
|
|
|
+ SyPreAssembledPackingList main=new SyPreAssembledPackingList();
|
|
|
+ List<SyPreAssembledPackingListItem> items=new ArrayList<SyPreAssembledPackingListItem>();
|
|
|
+ Sheet sheet=(Sheet) sheets.next();
|
|
|
+ List<String> strs3=new ArrayList<String>();//获取尺码名称
|
|
|
+ for (int x=0;x<=sheet.getLastRowNum();x++){
|
|
|
+ Row row=sheet.getRow(x);//列
|
|
|
+ Cell cell2=row.getCell(0);
|
|
|
+ if(cell2==null){//如果这一列为空就退出
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> strs=new ArrayList<String>();//装主要数据
|
|
|
+ List<String> strs2=new ArrayList<String>();//获取尺码的信息
|
|
|
+ for (int i=0;i<row.getLastCellNum();i++){
|
|
|
+ Cell cell=row.getCell(i);
|
|
|
+ if(cell==null){
|
|
|
+ throw new JeecgBootException("第"+num+"页的"+"第"+(x+1)+"行的"+
|
|
|
+ sheet.getRow(0).getCell(i).getStringCellValue()+"未填值!");
|
|
|
+ }
|
|
|
+ cell.setCellType(CellType.STRING);//获取的都转换成String
|
|
|
+ if(x==0){
|
|
|
+ if((i>9&&i<row.getLastCellNum()-28)||i==row.getLastCellNum()-9){
|
|
|
+ strs3.add(cell.getStringCellValue());
|
|
|
+ System.out.print(String.format("\033[%dm%s\033[0m", 31, cell.getStringCellValue())+"\t");//颜色
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if((i>9&&i<row.getLastCellNum()-28)||i==row.getLastCellNum()-9){
|
|
|
+ strs2.add(cell.getStringCellValue());
|
|
|
+ System.out.print(String.format("\033[%dm%s\033[0m", 31, cell.getStringCellValue())+"\t");//颜色
|
|
|
+ }else{
|
|
|
+ strs.add(cell.getStringCellValue());
|
|
|
+ System.out.print(cell.getStringCellValue()+"\t");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println();
|
|
|
+ if(x>0){
|
|
|
+ SyPreAssembledPackingListItem item=
|
|
|
+ new SyPreAssembledPackingListItem(strs.toArray(new String[strs.size()]),
|
|
|
+ strs2.toArray(new String[strs2.size()]),
|
|
|
+ strs3.toArray(new String[strs3.size()]));
|
|
|
+ items.add(item);
|
|
|
+ main=new SyPreAssembledPackingList(strs.toArray(new String[strs.size()]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ main.setSyPreAssembledPackingListItemList(items);//获取集合
|
|
|
+ mains.add(main);
|
|
|
+ //break;
|
|
|
+ }
|
|
|
+ System.out.println("\nmains\t"+mains);
|
|
|
+ boolean bool= syPreAssembledPackingListService.add(mains);
|
|
|
+ // System.out.println("bool\t"+bool);
|
|
|
+ }
|
|
|
}
|