|
|
|
@ -7,9 +7,10 @@ import cn.hutool.poi.excel.ExcelWriter;
|
|
|
|
|
import jnpf.base.ActionResult;
|
|
|
|
|
import jnpf.controller.UtilsController;
|
|
|
|
|
import jnpf.model.UploaderVO;
|
|
|
|
|
import jnpf.purchaseorder.model.purchaseorder.VehiclePictureFolder;
|
|
|
|
|
import jnpf.purchaseorder.utils.VehiclePictureFolderUtils;
|
|
|
|
|
import jnpf.util.FilePathUtil;
|
|
|
|
|
import jnpf.util.JsonUtil;
|
|
|
|
|
import jnpf.util.StringUtil;
|
|
|
|
|
import jnpf.util.context.SpringContext;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
|
|
@ -23,10 +24,8 @@ import sun.misc.BASE64Encoder;
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author: WangChuang
|
|
|
|
@ -38,10 +37,11 @@ public class FileCopy {
|
|
|
|
|
|
|
|
|
|
public static ArrayList<Object> getInfoAndUpFile(File[] fileList) throws Exception {
|
|
|
|
|
String fileName = "";
|
|
|
|
|
// 榜单图片对应的信息
|
|
|
|
|
// 磅单图片对应的信息
|
|
|
|
|
HashMap<String, Object> fileMap = new HashMap<>();
|
|
|
|
|
// 车辆图片对应的信息
|
|
|
|
|
HashMap<String, Object> carFileMap = new HashMap<>();
|
|
|
|
|
HashMap<String, VehiclePictureFolder> folderHashMap = new HashMap<>();
|
|
|
|
|
ArrayList<Object> resultList = new ArrayList<>();
|
|
|
|
|
File excelFile = null;
|
|
|
|
|
for (int i = 0; i < fileList.length; i++) {
|
|
|
|
@ -61,14 +61,23 @@ public class FileCopy {
|
|
|
|
|
if (resultListt.get(2) != null) {
|
|
|
|
|
fileMap.putAll ((HashMap<String, Object>) resultListt.get(2));
|
|
|
|
|
}
|
|
|
|
|
if (resultListt.get(3)!=null){
|
|
|
|
|
folderHashMap.putAll((HashMap<String,VehiclePictureFolder>) resultListt.get(3));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (file.isFile()) {
|
|
|
|
|
String indexString = name.substring(0, name.lastIndexOf("."));
|
|
|
|
|
String parent = file.getParent();
|
|
|
|
|
String parentName = parent.substring(parent.lastIndexOf("\\") + 1, parent.length());
|
|
|
|
|
|
|
|
|
|
VehiclePictureFolder vehiclePictureFolder = VehiclePictureFolderUtils.getVehiclePictureFolder(parentName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parentName= StringUtil.getCharStr(parentName);
|
|
|
|
|
// 序号
|
|
|
|
|
parentName=vehiclePictureFolder.getSerialNumber();
|
|
|
|
|
if (!folderHashMap.containsKey(parentName)){
|
|
|
|
|
folderHashMap.put(parentName,vehiclePictureFolder);
|
|
|
|
|
}
|
|
|
|
|
// if (parentName.contains("-")){
|
|
|
|
|
// parentName=parentName.substring(0,parentName.lastIndexOf("-"));
|
|
|
|
|
// }
|
|
|
|
@ -96,7 +105,7 @@ public class FileCopy {
|
|
|
|
|
}
|
|
|
|
|
list.add(dataMap);
|
|
|
|
|
|
|
|
|
|
// 将榜单照片存在榜单列表中
|
|
|
|
|
// 将磅单照片存在磅单列表中
|
|
|
|
|
if (indexString.equals("1")||indexString.equals(parentName)) {
|
|
|
|
|
if (fileMap.containsKey(parentName)) {
|
|
|
|
|
List<Object> o = (List<Object>) fileMap.get(parentName);
|
|
|
|
@ -161,6 +170,9 @@ public class FileCopy {
|
|
|
|
|
Cell cell2 = row.createCell(21);
|
|
|
|
|
Cell cell3 = row.createCell(22);
|
|
|
|
|
Cell cell4 = row.createCell(23);
|
|
|
|
|
Cell cell6 = row.createCell(25);
|
|
|
|
|
Cell cell7 = row.createCell(26);
|
|
|
|
|
Cell cell8 = row.createCell(27);
|
|
|
|
|
|
|
|
|
|
Cell cell5 = row.getCell(9);
|
|
|
|
|
Cell strCell1 = row.getCell(8);
|
|
|
|
@ -169,12 +181,13 @@ public class FileCopy {
|
|
|
|
|
Cell strCell4 = row.getCell(5);
|
|
|
|
|
Cell strCell5 = row.getCell(11);
|
|
|
|
|
Cell strCell6 = row.getCell(12);
|
|
|
|
|
Cell strCell7 = row.getCell(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i1 == 0) {
|
|
|
|
|
Row row1 = sheet.getRow(2);
|
|
|
|
|
Cell cell11 = row1.createCell(19);
|
|
|
|
|
cell11.setCellValue("榜单图片地址");
|
|
|
|
|
cell11.setCellValue("磅单图片地址");
|
|
|
|
|
Cell cell22 = row1.createCell(20);
|
|
|
|
|
cell22.setCellValue("客户");
|
|
|
|
|
Cell cell33 = row1.createCell(21);
|
|
|
|
@ -185,12 +198,19 @@ public class FileCopy {
|
|
|
|
|
cell55.setCellValue("车辆图片地址");
|
|
|
|
|
Cell cell66 = row1.createCell(24);
|
|
|
|
|
cell66.setCellValue("错误原因");
|
|
|
|
|
Cell cell77 = row1.createCell(25);
|
|
|
|
|
cell77.setCellValue("司机姓名");
|
|
|
|
|
Cell cell88 = row1.createCell(26);
|
|
|
|
|
cell88.setCellValue("司机联系方式");
|
|
|
|
|
Cell cell99 = row1.createCell(27);
|
|
|
|
|
cell99.setCellValue("司机车牌号");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object o1 = fileMap.get(String.valueOf(o));
|
|
|
|
|
Object o2 = carFileMap.get(String.valueOf(o));
|
|
|
|
|
VehiclePictureFolder vehiclePictureFolder1 = folderHashMap.get(String.valueOf(o));
|
|
|
|
|
|
|
|
|
|
cell.setCellValue(String.valueOf(o1).equals("null") ? "" : JsonUtil.getListToJsonArray((List<Map<String,Object>>)o1).toString());
|
|
|
|
|
cell.setCellValue(String.valueOf(o1).equals("null") ? "" : JsonUtil.getListToJsonArray((List<Map<String,Object>>)o1).toString());
|
|
|
|
|
|
|
|
|
|
cell4.setCellValue(String.valueOf(o2).equals("null") ? "" :JsonUtil.getListToJsonArray((List<Map<String,Object>>)o2).toString());
|
|
|
|
|
cell1.setCellValue(companyStr);
|
|
|
|
@ -198,6 +218,9 @@ public class FileCopy {
|
|
|
|
|
cell3.setCellValue(str3);
|
|
|
|
|
cell5.setCellType(CellType.STRING);
|
|
|
|
|
cell5.setCellValue(FileCopy.setSteColumn(cell5));
|
|
|
|
|
cell6.setCellValue(vehiclePictureFolder1.getDriverName()!=null?vehiclePictureFolder1.getDriverName():"");
|
|
|
|
|
cell7.setCellValue(vehiclePictureFolder1.getPhoneNumber()!=null?vehiclePictureFolder1.getPhoneNumber():"");
|
|
|
|
|
cell8.setCellValue(vehiclePictureFolder1.getCarNumber()!=null?vehiclePictureFolder1.getCarNumber():"");
|
|
|
|
|
strCell1.setCellType(CellType.STRING);
|
|
|
|
|
strCell1.setCellValue(FileCopy.setSteColumn(strCell1));
|
|
|
|
|
strCell2.setCellType(CellType.STRING);
|
|
|
|
@ -210,7 +233,34 @@ public class FileCopy {
|
|
|
|
|
strCell5.setCellValue(FileCopy.setSteColumn(strCell5));
|
|
|
|
|
strCell6.setCellType(CellType.STRING);
|
|
|
|
|
strCell6.setCellValue(FileCopy.setSteColumn(strCell6));
|
|
|
|
|
|
|
|
|
|
// strCell7.setCellType(CellType.STRING);
|
|
|
|
|
|
|
|
|
|
String stringCellValue = VehiclePictureFolderUtils.getValue(strCell7);
|
|
|
|
|
// strCell7.setCellValue(stringCellValue);
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义新的日期格式
|
|
|
|
|
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");//定义新的日期格式
|
|
|
|
|
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy/MM/dd K:mm:ss a");//定义新的日期格式
|
|
|
|
|
SimpleDateFormat formatter3 = new SimpleDateFormat("yyyy.MM.dd");//定义新的日期格式
|
|
|
|
|
//format():将给定的 Date 格式化为日期/时间字符串。即:date--->String
|
|
|
|
|
try {
|
|
|
|
|
if (stringCellValue.contains("/")){
|
|
|
|
|
Date date = formatter2.parse(stringCellValue);//parse():String--->date
|
|
|
|
|
strCell7.setCellValue(formatter.format(date));
|
|
|
|
|
}
|
|
|
|
|
else if (stringCellValue.contains("-")&&stringCellValue.contains(":")){
|
|
|
|
|
Date date = formatter.parse(stringCellValue);//parse():String--->date
|
|
|
|
|
strCell7.setCellValue(formatter.format(date));
|
|
|
|
|
} else if (stringCellValue.contains("-")) {
|
|
|
|
|
Date date = formatter1.parse(stringCellValue);//parse():String--->date
|
|
|
|
|
strCell7.setCellValue(formatter.format(date));
|
|
|
|
|
} else if (stringCellValue.contains(".")) {
|
|
|
|
|
Date date = formatter3.parse(stringCellValue);//parse():String--->date
|
|
|
|
|
strCell7.setCellValue(formatter.format(date));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
writer.flush(excelFile);
|
|
|
|
|
writer.close();
|
|
|
|
@ -228,7 +278,9 @@ public class FileCopy {
|
|
|
|
|
System.out.println(fileLoader.getName());
|
|
|
|
|
resultList.add(fileLoader.getName());
|
|
|
|
|
resultList.add(carFileMap);
|
|
|
|
|
|
|
|
|
|
resultList.add(fileMap);
|
|
|
|
|
resultList.add(folderHashMap);
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
input.close();
|
|
|
|
@ -244,6 +296,7 @@ public class FileCopy {
|
|
|
|
|
resultList.add(fileName);
|
|
|
|
|
resultList.add(carFileMap);
|
|
|
|
|
resultList.add(fileMap);
|
|
|
|
|
resultList.add(folderHashMap);
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|