| | |
| | | @Resource |
| | | private TmsShelfMapper tmsShelfMapper; |
| | | |
| | | @Autowired |
| | | private ITmsDispatchOrderImportLogService tmsDispatchOrderImportLogService; |
| | | |
| | | |
| | | /** |
| | | * 查询调度单管理 |
| | |
| | | |
| | | TmsDispatchOrderImport tmsDispatchOrderImport = new TmsDispatchOrderImport(); |
| | | tmsDispatchOrderImport.setProjectName("XXX项目"); |
| | | tmsDispatchOrderImport.setTransportLine("广东省/珠海市/香洲区>香港特别行政区"); |
| | | tmsDispatchOrderImport.setTransportLine("广东省/珠海市/香洲区->香港特别行政区"); |
| | | tmsDispatchOrderImport.setRequiredVehicleTypes("10T"); |
| | | tmsDispatchOrderImport.setOrderType("基础订单"); |
| | | tmsDispatchOrderImport.setIsCustoms("是"); |
| | |
| | | int failureNum = 0; |
| | | StringBuilder successMsg = new StringBuilder(); |
| | | StringBuilder failureMsg = new StringBuilder(); |
| | | StringBuilder failureDescription = new StringBuilder(); |
| | | int line = 1; |
| | | |
| | | // 创建导入日志对象 |
| | | TmsDispatchOrderImportLog importLog = new TmsDispatchOrderImportLog(); |
| | | importLog.setImportTime(DateUtils.getNowDate()); |
| | | importLog.setFileName("调度单导入文件"); // 这里需要根据实际情况获取文件名 |
| | | importLog.setOperator(SecurityUtils.getUsername()); |
| | | importLog.setCreateBy(SecurityUtils.getUsername()); |
| | | importLog.setCreateTime(DateUtils.getNowDate()); |
| | | |
| | | for (TmsDispatchOrderImport tmsDispatchOrderImport : list){ |
| | | try |
| | | { |
| | |
| | | failureNum++; |
| | | String msg = "<br/>" + "调度单第"+line+"行导入失败:"; |
| | | failureMsg.append(msg + e.getMessage()); |
| | | |
| | | // 记录失败说明,包含行号和失败原因 |
| | | failureDescription.append("第" + line + "行:" + e.getMessage()).append("\n"); |
| | | |
| | | log.error(msg, e); |
| | | }finally { |
| | | line++; |
| | | } |
| | | } |
| | | |
| | | // 设置导入日志的统计信息 |
| | | importLog.setSuccessCount(list.size() - failureNum); |
| | | importLog.setFailureCount(failureNum); |
| | | importLog.setFailureDescription(failureDescription.toString()); |
| | | |
| | | // 保存导入日志 |
| | | try { |
| | | tmsDispatchOrderImportLogService.insertTmsDispatchOrderImportLog(importLog); |
| | | } catch (Exception e) { |
| | | log.error("保存导入日志失败:", e); |
| | | } |
| | | |
| | | if (failureNum > 0) |
| | | { |
| | | failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); |