| | |
| | | |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | |
| | | task.setUpdateTime(DateUtils.getNowDate()); |
| | | task.setRemark(updateVO.getRemark()); |
| | | |
| | | // 如果更新了部门ID |
| | | if (updateVO.getDeptId() != null) { |
| | | task.setDeptId(updateVO.getDeptId()); |
| | | } |
| | | |
| | | // 重新计算预计公里数 |
| | | calculateEstimatedDistance(task); |
| | | |
| | | int result = sysTaskMapper.updateSysTask(task); |
| | | |
| | | // 更新车辆关联 |
| | | if (result > 0 && updateVO.getVehicleIds() != null && !updateVO.getVehicleIds().isEmpty()) { |
| | | // 查询现有的车辆关联 |
| | | List<SysTaskVehicle> existingVehicles = sysTaskVehicleMapper.selectSysTaskVehicleByTaskId(updateVO.getTaskId()); |
| | | List<Long> existingVehicleIds = existingVehicles.stream() |
| | | .map(SysTaskVehicle::getVehicleId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 比较新旧车辆ID列表,判断是否有变化 |
| | | boolean vehiclesChanged = !new HashSet<>(existingVehicleIds).equals(new HashSet<>(updateVO.getVehicleIds())); |
| | | |
| | | // 只有车辆发生变化时才更新 |
| | | if (vehiclesChanged) { |
| | | // 删除旧的车辆关联 |
| | | sysTaskVehicleMapper.deleteSysTaskVehicleByTaskId(updateVO.getTaskId()); |
| | | |
| | | // 添加新的车辆关联 |
| | | Date now = DateUtils.getNowDate(); |
| | | String currentUser = SecurityUtils.getUsername(); |
| | | for (Long vehicleId : updateVO.getVehicleIds()) { |
| | | SysTaskVehicle taskVehicle = new SysTaskVehicle(); |
| | | taskVehicle.setTaskId(updateVO.getTaskId()); |
| | | taskVehicle.setVehicleId(vehicleId); |
| | | taskVehicle.setAssignTime(now); |
| | | taskVehicle.setAssignBy(currentUser); |
| | | taskVehicle.setCreateTime(now); |
| | | sysTaskVehicleMapper.insertSysTaskVehicle(taskVehicle); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 更新急救转运扩展信息 |
| | | if (result > 0 && "EMERGENCY_TRANSFER".equals(oldTask.getTaskType()) && updateVO.getEmergencyInfo() != null) { |
| | | updateEmergencyInfo(updateVO.getTaskId(), updateVO); |
| | | } |
| | | |
| | | // 记录操作日志 |
| | | if (result > 0) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 更新急救转运任务扩展信息 |
| | | * |
| | | * @param taskId 任务ID |
| | | * @param updateVO 任务更新对象 |
| | | */ |
| | | private void updateEmergencyInfo(Long taskId, TaskUpdateVO updateVO) { |
| | | // 查询现有的扩展信息 |
| | | SysTaskEmergency existingInfo = sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(taskId); |
| | | if (existingInfo == null) { |
| | | // 如果不存在,则创建新的 |
| | | existingInfo = new SysTaskEmergency(); |
| | | existingInfo.setTaskId(taskId); |
| | | existingInfo.setCreateTime(DateUtils.getNowDate()); |
| | | existingInfo.setCreateBy(SecurityUtils.getUsername()); |
| | | } |
| | | |
| | | TaskUpdateVO.EmergencyInfoVO emergencyInfo = updateVO.getEmergencyInfo(); |
| | | |
| | | // 更新患者信息 |
| | | if (emergencyInfo.getPatientContact() != null) { |
| | | existingInfo.setPatientContact(emergencyInfo.getPatientContact()); |
| | | } |
| | | if (emergencyInfo.getPatientPhone() != null) { |
| | | existingInfo.setPatientPhone(emergencyInfo.getPatientPhone()); |
| | | } |
| | | if (emergencyInfo.getPatientName() != null) { |
| | | existingInfo.setPatientName(emergencyInfo.getPatientName()); |
| | | } |
| | | if (emergencyInfo.getPatientGender() != null) { |
| | | existingInfo.setPatientGender(emergencyInfo.getPatientGender()); |
| | | } |
| | | if (emergencyInfo.getPatientIdCard() != null) { |
| | | existingInfo.setPatientIdCard(emergencyInfo.getPatientIdCard()); |
| | | } |
| | | if (emergencyInfo.getPatientCondition() != null) { |
| | | existingInfo.setPatientCondition(emergencyInfo.getPatientCondition()); |
| | | } |
| | | |
| | | // 更新转出医院信息 |
| | | if (emergencyInfo.getHospitalOutId() != null) { |
| | | existingInfo.setHospitalOutId(emergencyInfo.getHospitalOutId()); |
| | | } |
| | | if (emergencyInfo.getHospitalOutName() != null) { |
| | | existingInfo.setHospitalOutName(emergencyInfo.getHospitalOutName()); |
| | | } |
| | | if (emergencyInfo.getHospitalOutDepartment() != null) { |
| | | existingInfo.setHospitalOutDepartment(emergencyInfo.getHospitalOutDepartment()); |
| | | } |
| | | if (emergencyInfo.getHospitalOutDepartmentId() != null) { |
| | | existingInfo.setHospitalOutDepartmentId(emergencyInfo.getHospitalOutDepartmentId()); |
| | | } |
| | | if (emergencyInfo.getHospitalOutBedNumber() != null) { |
| | | existingInfo.setHospitalOutBedNumber(emergencyInfo.getHospitalOutBedNumber()); |
| | | } |
| | | if (emergencyInfo.getHospitalOutAddress() != null) { |
| | | existingInfo.setHospitalOutAddress(emergencyInfo.getHospitalOutAddress()); |
| | | } |
| | | if (emergencyInfo.getHospitalOutLongitude() != null) { |
| | | existingInfo.setHospitalOutLongitude(emergencyInfo.getHospitalOutLongitude()); |
| | | } |
| | | if (emergencyInfo.getHospitalOutLatitude() != null) { |
| | | existingInfo.setHospitalOutLatitude(emergencyInfo.getHospitalOutLatitude()); |
| | | } |
| | | |
| | | // 更新转入医院信息 |
| | | if (emergencyInfo.getHospitalInId() != null) { |
| | | existingInfo.setHospitalInId(emergencyInfo.getHospitalInId()); |
| | | } |
| | | if (emergencyInfo.getHospitalInName() != null) { |
| | | existingInfo.setHospitalInName(emergencyInfo.getHospitalInName()); |
| | | } |
| | | if (emergencyInfo.getHospitalInDepartment() != null) { |
| | | existingInfo.setHospitalInDepartment(emergencyInfo.getHospitalInDepartment()); |
| | | } |
| | | if (emergencyInfo.getHospitalInDepartmentId() != null) { |
| | | existingInfo.setHospitalInDepartmentId(emergencyInfo.getHospitalInDepartmentId()); |
| | | } |
| | | if (emergencyInfo.getHospitalInBedNumber() != null) { |
| | | existingInfo.setHospitalInBedNumber(emergencyInfo.getHospitalInBedNumber()); |
| | | } |
| | | if (emergencyInfo.getHospitalInAddress() != null) { |
| | | existingInfo.setHospitalInAddress(emergencyInfo.getHospitalInAddress()); |
| | | } |
| | | if (emergencyInfo.getHospitalInLongitude() != null) { |
| | | existingInfo.setHospitalInLongitude(emergencyInfo.getHospitalInLongitude()); |
| | | } |
| | | if (emergencyInfo.getHospitalInLatitude() != null) { |
| | | existingInfo.setHospitalInLatitude(emergencyInfo.getHospitalInLatitude()); |
| | | } |
| | | |
| | | // 更新费用信息 |
| | | if (emergencyInfo.getTransferDistance() != null) { |
| | | existingInfo.setTransferDistance(emergencyInfo.getTransferDistance()); |
| | | } |
| | | if (emergencyInfo.getTransferPrice() != null) { |
| | | existingInfo.setTransferPrice(emergencyInfo.getTransferPrice()); |
| | | } |
| | | |
| | | // 更新病情ID列表 |
| | | if (updateVO.getDiseaseIds() != null && !updateVO.getDiseaseIds().isEmpty()) { |
| | | String diseaseIdsStr = updateVO.getDiseaseIds().stream() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(",")); |
| | | existingInfo.setDiseaseIds(diseaseIdsStr); |
| | | } else { |
| | | // 如果病情ID列表为空,清空该字段 |
| | | existingInfo.setDiseaseIds(null); |
| | | } |
| | | |
| | | // 系统字段 |
| | | existingInfo.setUpdateTime(DateUtils.getNowDate()); |
| | | existingInfo.setUpdateBy(SecurityUtils.getUsername()); |
| | | |
| | | // 执行更新 |
| | | sysTaskEmergencyMapper.updateSysTaskEmergency(existingInfo); |
| | | } |
| | | |
| | | /** |
| | | * 保存福祉车任务扩展信息 |
| | | * |
| | | * @param taskId 任务ID |