| | |
| | | |
| | | @Autowired |
| | | private ITaskAttachmentService taskAttachmentService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 同步急救转运任务到旧系统 |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | // ====== 前置校验:确保任务数据完整 ====== |
| | | |
| | | // 1. 检查是否已分配车辆 |
| | | List<SysTaskVehicle> taskVehicles = sysTaskVehicleMapper.selectSysTaskVehicleByTaskId(taskId); |
| | | if (taskVehicles == null || taskVehicles.isEmpty()) { |
| | | log.warn("任务未分配车辆,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | // 2. 检查是否已分配执行人员 |
| | | List<SysTaskAssignee> taskAssignees = sysTaskAssigneeMapper.selectSysTaskAssigneeByTaskId(taskId); |
| | | if (taskAssignees == null || taskAssignees.isEmpty()) { |
| | | log.warn("任务未分配执行人员,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | // 3. 检查预约时间是否有效(必须大于1970年) |
| | | if (task.getPlannedStartTime() == null) { |
| | | log.warn("任务未设置预约时间,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | // 检查预约时间是否大于1970-01-01(时间戳0对应1970-01-01 00:00:00) |
| | | long timestamp1970 = 0L; |
| | | if (task.getPlannedStartTime().getTime() <= timestamp1970) { |
| | | log.warn("任务预约时间无效(小于等于1970年),跳过调度单同步,任务ID: {}, 预约时间: {}", |
| | | taskId, task.getPlannedStartTime()); |
| | | return null; |
| | | } |
| | | |
| | | // 4. 检查转出医院信息 |
| | | if (StringUtils.isEmpty(emergency.getHospitalOutName())) { |
| | | log.warn("任务未设置转出医院,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(emergency.getHospitalOutAddress())) { |
| | | log.warn("任务未设置转出医院地址,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | // 5. 检查转入医院信息 |
| | | if (StringUtils.isEmpty(emergency.getHospitalInName())) { |
| | | log.warn("任务未设置转入医院,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(emergency.getHospitalInAddress())) { |
| | | log.warn("任务未设置转入医院地址,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | // 6. 检查患者基本信息 |
| | | if (StringUtils.isEmpty(emergency.getPatientName())) { |
| | | log.warn("任务未设置患者姓名,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(emergency.getPatientPhone())) { |
| | | log.warn("任务未设置患者电话,跳过调度单同步,任务ID: {}", taskId); |
| | | return null; |
| | | } |
| | | |
| | | log.info("任务数据校验通过,开始同步调度单,任务ID: {}", taskId); |
| | | |
| | | // 更新同步状态为同步中 |
| | | emergency.setDispatchSyncStatus(1); |
| | |
| | | // 操作命令 |
| | | params.put("DispatchOrd_Check", "0"); // 3=直接强制完成 |
| | | |
| | | // 绩效和费用 |
| | | params.put("DispatchOrdPerfomance", emergency.getTransferPrice() != null ? emergency.getTransferPrice().toString() : "0"); |
| | | // 绩效和费用:确保数值字段不为null |
| | | String transferPrice = "0"; |
| | | if (emergency.getTransferPrice() != null) { |
| | | try { |
| | | transferPrice = emergency.getTransferPrice().toString(); |
| | | if (transferPrice.contains(".")) { |
| | | transferPrice = new java.math.BigDecimal(transferPrice).stripTrailingZeros().toPlainString(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("转换转运价格失败,任务ID: {}, 使用默认值0", task.getTaskId(), e); |
| | | transferPrice = "0"; |
| | | } |
| | | } |
| | | params.put("DispatchOrdPerfomance", transferPrice); |
| | | params.put("StretcherMoney", "0"); // 抬担架费 |
| | | params.put("AddMoneyType", ""); // 附加项目 |
| | | params.put("AddMoney", "0"); // 附加项目费用 |
| | |
| | | params.put("ServiceOrdPtDoctorPhone", ""); // 患者医生电话 |
| | | params.put("TransferModeID", ""); // 转运方式 |
| | | params.put("ServiceOrdVIP", "0"); // VIP客户 |
| | | params.put("ServiceOrdTraTxnPrice", emergency.getTransferPrice() != null ? emergency.getTransferPrice().toString() : "0"); // 成交价 |
| | | // 价格字段复用,确保一致性 |
| | | params.put("ServiceOrdTraTxnPrice", transferPrice); // 成交价 |
| | | params.put("ServiceOrdTraPrePayment", "0"); // 需预付款 |
| | | params.put("SettlementPrice", "0"); // 结算价 |
| | | params.put("ServiceOrdTraPriceReason", ""); // 差价原因 |
| | |
| | | params.put("ServiceOrdEstimatedOrderDate", ""); // 预计派单时间 |
| | | params.put("ServiceOrdEstimatedOrderDateOld", ""); // 原预计派单时间 |
| | | params.put("ServiceOrdViaDistance", "0"); // 中途距离 |
| | | params.put("ServiceOrdTraDistance", emergency.getTransferDistance() != null ? emergency.getTransferDistance().toString() : "0"); // 距离 |
| | | // 距离字段:确保不为空,避免旧系统接口报错 |
| | | String transferDistance = "0"; |
| | | if (emergency.getTransferDistance() != null) { |
| | | try { |
| | | transferDistance = emergency.getTransferDistance().toString(); |
| | | // 去除可能的小数点后多余的0 |
| | | if (transferDistance.contains(".")) { |
| | | transferDistance = new java.math.BigDecimal(transferDistance).stripTrailingZeros().toPlainString(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("转换转运距离失败,任务ID: {}, 使用默认值0", task.getTaskId(), e); |
| | | transferDistance = "0"; |
| | | } |
| | | } |
| | | params.put("ServiceOrdTraDistance", transferDistance); |
| | | params.put("OrderLevel", "0"); // 查看等级 |
| | | params.put("ServiceOrdDepartureType", "1"); // 预约类型 |
| | | params.put("ConditionLevel", "0"); // 病重级别 |
| | |
| | | return false; |
| | | } |
| | | |
| | | log.info("开始重新同步调度单,任务ID: {}, DispatchOrdID: {}", taskId, emergency.getLegacyDispatchOrdId()); |
| | | // ====== 前置校验:确保任务数据完整 ====== |
| | | |
| | | // 1. 检查是否已分配车辆 |
| | | List<SysTaskVehicle> taskVehicles = sysTaskVehicleMapper.selectSysTaskVehicleByTaskId(taskId); |
| | | if (taskVehicles == null || taskVehicles.isEmpty()) { |
| | | log.warn("任务未分配车辆,跳过调度单重新同步,任务ID: {}", taskId); |
| | | return false; |
| | | } |
| | | |
| | | // 2. 检查是否已分配执行人员 |
| | | List<SysTaskAssignee> taskAssignees = sysTaskAssigneeMapper.selectSysTaskAssigneeByTaskId(taskId); |
| | | if (taskAssignees == null || taskAssignees.isEmpty()) { |
| | | log.warn("任务未分配执行人员,跳过调度单重新同步,任务ID: {}", taskId); |
| | | return false; |
| | | } |
| | | |
| | | // 3. 检查预约时间是否有效 |
| | | if (task.getPlannedStartTime() == null || task.getPlannedStartTime().getTime() <= 0L) { |
| | | log.warn("任务预约时间无效,跳过调度单重新同步,任务ID: {}", taskId); |
| | | return false; |
| | | } |
| | | |
| | | // 4. 检查转出医院信息 |
| | | if (StringUtils.isEmpty(emergency.getHospitalOutName()) || StringUtils.isEmpty(emergency.getHospitalOutAddress())) { |
| | | log.warn("任务转出医院信息不完整,跳过调度单重新同步,任务ID: {}", taskId); |
| | | return false; |
| | | } |
| | | |
| | | // 5. 检查转入医院信息 |
| | | if (StringUtils.isEmpty(emergency.getHospitalInName()) || StringUtils.isEmpty(emergency.getHospitalInAddress())) { |
| | | log.warn("任务转入医院信息不完整,跳过调度单重新同步,任务ID: {}", taskId); |
| | | return false; |
| | | } |
| | | |
| | | // 6. 检查患者基本信息 |
| | | if (StringUtils.isEmpty(emergency.getPatientName()) || StringUtils.isEmpty(emergency.getPatientPhone())) { |
| | | log.warn("任务患者信息不完整,跳过调度单重新同步,任务ID: {}", taskId); |
| | | return false; |
| | | } |
| | | |
| | | log.info("任务数据校验通过,开始重新同步调度单,任务ID: {}, DispatchOrdID: {}", taskId, emergency.getLegacyDispatchOrdId()); |
| | | |
| | | // 构建请求参数(使用相同的参数构建方法) |
| | | Map<String, String> params = buildDispatchOrderParams(task, emergency); |