public List<DeliveryOrder> saveMultiFile(InputStream inputStream, InboundLog inboundLog) { try { ManifestFile order = unmarshalOrder(inputStream); List<DeliveryOrder> doList = ManifestFileToDo(order); if (inboundLog.getPlantSupplier() == null) { inboundLog.setPlantSupplier(doList.get(0).getPlantSupplier()); } inboundLog.setInboundResult("success"); return doList; } catch (JAXBException jaxbException) { log.error("Error occur when unmarshal ORDERS.", jaxbException); inboundLog.setInboundResult("fail"); inboundLog.setMemo(jaxbException.getMessage()); } catch (DataConvertException dataConvertException) { log.error("Error occur when convert ORDERS to PO.", dataConvertException); inboundLog.setInboundResult("fail"); DeliveryOrder deliveryOrder = (DeliveryOrder) dataConvertException.getObject(); if (deliveryOrder != null && deliveryOrder.getPlantSupplier() != null) { inboundLog.setPlantSupplier(deliveryOrder.getPlantSupplier()); } inboundLog.setMemo(dataConvertException.getMessage()); } catch (Exception exception) { log.error("Error occur.", exception); inboundLog.setInboundResult("fail"); inboundLog.setMemo(exception.getMessage()); } return null; }
public void reloadFile(InboundLog inboundLog, String userCode, String archiveFolder) { try { File file = new File(inboundLog.getFullFilePath()); FileInputStream stream = new FileInputStream(file); this.saveMultiFile(stream, inboundLog); FileUtils.forceMkdir(new File(archiveFolder)); File backupFile = new File(archiveFolder + File.separator + file.getName()); FileUtils.copyFile(file, backupFile); inboundLog.setFullFilePath(backupFile.getAbsolutePath()); inboundLog.setInboundResult("success"); FileUtils.forceDelete(file); } catch (Exception ex) { inboundLog.setMemo(ex.getMessage()); } finally { inboundLog.setLastModifyDate(new Date()); inboundLog.setLastModifyUser(userCode); this.inboundLogManager.save(inboundLog); } }