diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/mobilePort/utils/FileCopy.java b/SC-boot/linkage-scm/src/main/java/jnpf/mobilePort/utils/FileCopy.java index bdfdd156..18c4f578 100644 --- a/SC-boot/linkage-scm/src/main/java/jnpf/mobilePort/utils/FileCopy.java +++ b/SC-boot/linkage-scm/src/main/java/jnpf/mobilePort/utils/FileCopy.java @@ -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 getInfoAndUpFile(File[] fileList) throws Exception { String fileName = ""; -// 榜单图片对应的信息 +// 磅单图片对应的信息 HashMap fileMap = new HashMap<>(); // 车辆图片对应的信息 HashMap carFileMap = new HashMap<>(); + HashMap folderHashMap = new HashMap<>(); ArrayList 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) resultListt.get(2)); } + if (resultListt.get(3)!=null){ + folderHashMap.putAll((HashMap) 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 o = (List) 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>)o1).toString()); + cell.setCellValue(String.valueOf(o1).equals("null") ? "" : JsonUtil.getListToJsonArray((List>)o1).toString()); cell4.setCellValue(String.valueOf(o2).equals("null") ? "" :JsonUtil.getListToJsonArray((List>)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; } diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/model/purchaseorder/PurchaseorderDTO.java b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/model/purchaseorder/PurchaseorderDTO.java index 5fb5f214..accd272f 100644 --- a/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/model/purchaseorder/PurchaseorderDTO.java +++ b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/model/purchaseorder/PurchaseorderDTO.java @@ -80,11 +80,14 @@ public class PurchaseorderDTO { private String purchaseId; @Excel(name = "客户") private String customerId; - @Excel(name = "司机名称") + @Excel(name = "司机姓名") private String driverName; - @Excel(name = "联系方式") + @Excel(name = "司机联系方式") private String contact; + @Excel(name = "司机车牌号") + private String driverVehicleId; + private String supplierId; private String id; diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/model/purchaseorder/VehiclePictureFolder.java b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/model/purchaseorder/VehiclePictureFolder.java new file mode 100644 index 00000000..67028953 --- /dev/null +++ b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/model/purchaseorder/VehiclePictureFolder.java @@ -0,0 +1,23 @@ +package jnpf.purchaseorder.model.purchaseorder; + +import lombok.Data; + +/** + * @Author: WangChuang + * @Date: 3/4/2023 下午1:50 + * @Description //注释: 车辆图片的文件夹获取的信息 + * @Version 1.0 + */ +@Data +public class VehiclePictureFolder { + /**序号 **/ + private String serialNumber; + /**车牌号**/ + private String carNumber; + /**司机名字**/ + private String driverName; + + /**手机号**/ + private String phoneNumber; + +} diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/service/impl/PurchaseorderitemServiceImpl.java b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/service/impl/PurchaseorderitemServiceImpl.java index 7b505885..d75b6242 100644 --- a/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/service/impl/PurchaseorderitemServiceImpl.java +++ b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/service/impl/PurchaseorderitemServiceImpl.java @@ -73,7 +73,6 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URLEncoder; import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.List; import java.util.*; import java.util.concurrent.CountDownLatch; @@ -1457,6 +1456,8 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(VehicleEntity::getTicketno, model.getVehicleId()); + if (!String.valueOf(model.getDriverName()).equals("null")){ + wrapper.eq(VehicleEntity::getDrivername,model.getDriverName()); + } + + List vehicleEntityList = vehicleMapper.selectList(wrapper); + if (vehicleEntityList != null && vehicleEntityList.size() > 0) { + model.setVehicleId(vehicleEntityList.get(0).getId()); + VehicleEntity vehicleEntity = vehicleEntityList.get(0); +// 车辆照片 + vehicleEntity.setVehiclephotos(model.getCarPictures()); +// 联系信息 + if (!String.valueOf(model.getContact()).equals("null")&&!model.getContact().isEmpty()) { + vehicleEntity.setContact(model.getContact()); + } + vehicleMapper.updateById(vehicleEntity); + } else { +// 添加车牌号 +// id + Long aLong = new DefaultIdentifierGenerator().nextId(VehicleEntity.class); + VehicleEntity vehicleEntity = new VehicleEntity(); + vehicleEntity.setId(aLong.toString()); +// 车辆照片 + vehicleEntity.setVehiclephotos(model.getCarPictures()); +// 车牌号 + vehicleEntity.setTicketno(model.getVehicleId()); +// 联系方式 + if (!String.valueOf(model.getContact()).equals("null")&&!model.getContact().isEmpty()){ + vehicleEntity.setContact(model.getContact()); + } +// 司机名称 + if (!String.valueOf(model.getDriverName()).equals("null")&&!model.getDriverName().isEmpty()){ + + vehicleEntity.setDrivername(model.getDriverName()); + } + vehicleMapper.insert(vehicleEntity); + model.setVehicleId(aLong.toString()); + } + }else { + model.setCauseError("车牌号不存在!请添加车辆信息在尝试添加!"); + errList.add(model); + ints.add(i); + continue; + } } // 货物 if (model.getMaterialId() != null) { diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/utils/VehiclePictureFolderUtils.java b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/utils/VehiclePictureFolderUtils.java new file mode 100644 index 00000000..26a41e6e --- /dev/null +++ b/SC-boot/linkage-scm/src/main/java/jnpf/purchaseorder/utils/VehiclePictureFolderUtils.java @@ -0,0 +1,105 @@ +package jnpf.purchaseorder.utils; + +import jnpf.purchaseorder.model.purchaseorder.VehiclePictureFolder; +import jnpf.util.StringUtil; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.junit.jupiter.api.Test; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.regex.Pattern; + +/** + * @Author: WangChuang + * @Date: 3/4/2023 下午2:01 + * @Description //注释: + * @Version 1.0 + */ +public class VehiclePictureFolderUtils { + /** + * 根据字符串获取相应的数据 + * @param str + * @return + */ + + public static VehiclePictureFolder getVehiclePictureFolder(String str){ + str=str.trim(); + VehiclePictureFolder vehiclePictureFolder = new VehiclePictureFolder(); + String charStr = StringUtil.getCharStr(str); + vehiclePictureFolder.setSerialNumber(charStr); + String substring = str.substring(str.indexOf(vehiclePictureFolder.getSerialNumber()) + vehiclePictureFolder.getSerialNumber().length(), str.length() ); + String carRegex="^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[警京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]{0,1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$"; + String phoneRegex="0?(13|14|15|16|18|17|19)[0-9]{9}"; + if (substring.length()>=7){ + for (int i = 0; i <= substring.length()-7; i++) { + String carNumber = StringUtil.substring(substring, i, i + 7); + if ( Pattern.matches(carRegex, carNumber)){ + vehiclePictureFolder.setCarNumber(carNumber); + break; + } + } + if (vehiclePictureFolder.getCarNumber()!=null){ + String substring1 = substring.substring(0, substring.indexOf(vehiclePictureFolder.getCarNumber())); + String substring2 = substring.substring(substring.indexOf(vehiclePictureFolder.getCarNumber()) + vehiclePictureFolder.getCarNumber().length(), substring.length() ); + substring=substring1+substring2; + if (substring1.length()>0){ + substring=substring.replaceAll(substring1,""); + } + } + if (substring.length()>=11){ + for (int i = 0; i <= substring.length()-11; i++) { + String phone = StringUtil.substring(substring, i, i + 11); + if ( Pattern.matches(phoneRegex, phone)){ + vehiclePictureFolder.setPhoneNumber(phone); + break; + } + } + if (vehiclePictureFolder.getPhoneNumber()!=null){ + String substring1 = substring.substring(0, substring.indexOf(vehiclePictureFolder.getPhoneNumber())); + String substring2 = substring.substring(substring.indexOf(vehiclePictureFolder.getPhoneNumber()) + vehiclePictureFolder.getPhoneNumber().length(), substring.length() ); + substring=substring1+substring2; + } + if (substring.length()>=2){ + vehiclePictureFolder.setDriverName(substring); + } + } + + } + return vehiclePictureFolder; + } + + @Test + public void test1(){ System.out.println( + VehiclePictureFolderUtils.getVehiclePictureFolder("1豫AS0K91李高洋15797755804")); + } + + + + public static String getValue(Cell cell) { + if (cell.getCellType() == CellType.BOOLEAN) { + return String.valueOf(cell.getBooleanCellValue()); + } else if (cell.getCellType() == CellType.NUMERIC) { + //20180622,支持日期格式 + if(HSSFDateUtil.isCellDateFormatted(cell)){ + Date d = (Date) cell.getDateCellValue(); + DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//HH:mm:ss + return df2.format(d); + } +//数字 + else{ + //使用DecimalFormat对double进行了格式化,随后使用format方法获得的String就是你想要的值了。 + DecimalFormat df = new DecimalFormat("0"); + return String.valueOf(df.format(cell.getNumericCellValue())); + } + + } else { + return String.valueOf(cell.getStringCellValue()); + } + } + + +}