| | |
| | | import com.ruoyi.approve.mapper.ApprovalInstanceMapper; |
| | | import com.ruoyi.approve.mapper.ApprovalTemplateNodeApproverMapper; |
| | | import com.ruoyi.approve.mapper.FinReimbursementMapper; |
| | | import com.ruoyi.approve.mapper.VehicleBorrowRecordMapper; |
| | | import com.ruoyi.approve.mapper.VehicleMapper; |
| | | import com.ruoyi.approve.pojo.*; |
| | | import com.ruoyi.approve.service.*; |
| | | import com.ruoyi.approve.utils.ApproveProcessConfigNodeUtils; |
| | |
| | | private final SalesQuotationMapper salesQuotationMapper; |
| | | private final ShippingInfoMapper shippingInfoMapper; |
| | | private final QualityInspectHelper qualityInspectHelper; |
| | | private final VehicleBorrowRecordMapper vehicleBorrowRecordMapper; |
| | | private final VehicleMapper vehicleMapper; |
| | | private final EnterpriseNewsScopeUserMapper enterpriseNewsScopeUserMapper; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final SysUserDeptMapper sysUserDeptMapper; |
| | |
| | | .eq(FinReimbursement::getId, instance.getBusinessId()) |
| | | .set(FinReimbursement::getBillStatus, "REJECTED") |
| | | ); |
| | | } else if (TypeEnums.VEHICLE_BORROW_APPROVAL.getCode().equals(instance.getBusinessType())) { |
| | | vehicleBorrowRecordMapper.update( |
| | | null, |
| | | new LambdaUpdateWrapper<VehicleBorrowRecord>() |
| | | .eq(VehicleBorrowRecord::getId, instance.getBusinessId()) |
| | | .set(VehicleBorrowRecord::getBorrowStatus, "REJECTED") |
| | | .set(VehicleBorrowRecord::getApprovalInstanceId, instance.getId()) |
| | | ); |
| | | VehicleBorrowRecord borrowRecord = vehicleBorrowRecordMapper.selectById(instance.getBusinessId()); |
| | | if (borrowRecord != null) { |
| | | syncVehicleBorrowStatus(borrowRecord.getVehicleId()); |
| | | } |
| | | } else if (TypeEnums.VEHICLE_DELAY_APPROVAL.getCode().equals(instance.getBusinessType())) { |
| | | vehicleBorrowRecordMapper.update( |
| | | null, |
| | | new LambdaUpdateWrapper<VehicleBorrowRecord>() |
| | | .eq(VehicleBorrowRecord::getId, instance.getBusinessId()) |
| | | .set(VehicleBorrowRecord::getExtendStatus, "REJECTED") |
| | | .set(VehicleBorrowRecord::getExtendApprovalInstanceId, null) |
| | | ); |
| | | } |
| | | return R.ok("审批已驳回"); |
| | | } |
| | |
| | | } |
| | | if (TypeEnums.ENTERPRISE_NEWS_APPROVAL.getCode().equals(businessType)) { |
| | | handleNewsApprovalFinished(instance, status); |
| | | return; |
| | | } |
| | | if (TypeEnums.VEHICLE_BORROW_APPROVAL.getCode().equals(businessType) |
| | | || TypeEnums.VEHICLE_DELAY_APPROVAL.getCode().equals(businessType)) { |
| | | handleVehicleBorrowApprovalFinished(instance, status); |
| | | } |
| | | } |
| | | |
| | |
| | | shippingInfoMapper.updateById(shippingInfo); |
| | | } |
| | | |
| | | private void handleVehicleBorrowApprovalFinished(ApprovalInstance instance, String status) { |
| | | if (instance == null || instance.getBusinessId() == null) { |
| | | return; |
| | | } |
| | | |
| | | VehicleBorrowRecord record = vehicleBorrowRecordMapper.selectById(instance.getBusinessId()); |
| | | if (record == null || Integer.valueOf(1).equals(record.getDeleted())) { |
| | | return; |
| | | } |
| | | |
| | | if (TypeEnums.VEHICLE_BORROW_APPROVAL.getCode().equals(instance.getBusinessType())) { |
| | | if ("APPROVED".equals(status)) { |
| | | Vehicle vehicle = vehicleMapper.selectById(record.getVehicleId()); |
| | | if (vehicle == null) { |
| | | throw new ServiceException("车辆不存在"); |
| | | } |
| | | VehicleBorrowRecord update = new VehicleBorrowRecord(); |
| | | update.setId(record.getId()); |
| | | update.setBorrowStatus("BORROWING"); |
| | | update.setApprovedTime(instance.getFinishTime()); |
| | | update.setApprovalInstanceId(instance.getId()); |
| | | vehicleBorrowRecordMapper.updateById(update); |
| | | syncVehicleBorrowStatus(vehicle.getId()); |
| | | return; |
| | | } |
| | | if ("REJECTED".equals(status)) { |
| | | VehicleBorrowRecord update = new VehicleBorrowRecord(); |
| | | update.setId(record.getId()); |
| | | update.setBorrowStatus("REJECTED"); |
| | | update.setApprovalInstanceId(instance.getId()); |
| | | vehicleBorrowRecordMapper.updateById(update); |
| | | syncVehicleBorrowStatus(record.getVehicleId()); |
| | | return; |
| | | } |
| | | if ("PENDING".equals(status)) { |
| | | VehicleBorrowRecord update = new VehicleBorrowRecord(); |
| | | update.setId(record.getId()); |
| | | update.setBorrowStatus("IN_APPROVAL"); |
| | | update.setApprovalInstanceId(instance.getId()); |
| | | vehicleBorrowRecordMapper.updateById(update); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | if (TypeEnums.VEHICLE_DELAY_APPROVAL.getCode().equals(instance.getBusinessType())) { |
| | | if ("APPROVED".equals(status)) { |
| | | vehicleBorrowRecordMapper.update( |
| | | null, |
| | | new LambdaUpdateWrapper<VehicleBorrowRecord>() |
| | | .eq(VehicleBorrowRecord::getId, record.getId()) |
| | | .set(VehicleBorrowRecord::getBorrowStatus, "BORROWING") |
| | | .set(VehicleBorrowRecord::getExtendStatus, "APPROVED") |
| | | .set(VehicleBorrowRecord::getExtendApprovedTime, instance.getFinishTime()) |
| | | .set(VehicleBorrowRecord::getPlannedReturnTime, record.getExtendTargetReturnTime()) |
| | | .set(VehicleBorrowRecord::getExtendApprovalInstanceId, null) |
| | | ); |
| | | return; |
| | | } |
| | | if ("REJECTED".equals(status)) { |
| | | vehicleBorrowRecordMapper.update( |
| | | null, |
| | | new LambdaUpdateWrapper<VehicleBorrowRecord>() |
| | | .eq(VehicleBorrowRecord::getId, record.getId()) |
| | | .set(VehicleBorrowRecord::getExtendStatus, "REJECTED") |
| | | .set(VehicleBorrowRecord::getExtendApprovalInstanceId, null) |
| | | ); |
| | | return; |
| | | } |
| | | if ("PENDING".equals(status)) { |
| | | VehicleBorrowRecord update = new VehicleBorrowRecord(); |
| | | update.setId(record.getId()); |
| | | update.setExtendStatus("PENDING"); |
| | | update.setExtendApprovalInstanceId(instance.getId()); |
| | | vehicleBorrowRecordMapper.updateById(update); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void syncVehicleBorrowStatus(Long vehicleId) { |
| | | if (vehicleId == null) { |
| | | return; |
| | | } |
| | | long activeBorrowCount = vehicleBorrowRecordMapper.selectCount( |
| | | new LambdaQueryWrapper<VehicleBorrowRecord>() |
| | | .eq(VehicleBorrowRecord::getVehicleId, vehicleId) |
| | | .eq(VehicleBorrowRecord::getDeleted, 0) |
| | | .in(VehicleBorrowRecord::getBorrowStatus, "IN_APPROVAL", "BORROWING") |
| | | ); |
| | | Vehicle vehicle = vehicleMapper.selectById(vehicleId); |
| | | if (vehicle == null) { |
| | | throw new ServiceException("车辆不存在"); |
| | | } |
| | | Vehicle vehicleUpdate = new Vehicle(); |
| | | vehicleUpdate.setId(vehicleId); |
| | | vehicleUpdate.setStatus(activeBorrowCount > 0 ? "IN_USE" : "IDLE"); |
| | | vehicleMapper.updateById(vehicleUpdate); |
| | | } |
| | | |
| | | private List<ApprovalTask> createNodeAndTasks(ApprovalInstance instance, ApprovalTemplateNode templateNode) { |
| | | List<ApprovalTemplateNodeApprover> approvers = approvalTemplateNodeApproverMapper.selectList( |
| | | new LambdaQueryWrapper<ApprovalTemplateNodeApprover>() |