| New file |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.system.domain.enums.TaskStatus; |
| | | import com.ruoyi.system.domain.enums.TaskType; |
| | | |
| | | /** |
| | | * 任务管理对象 sys_task |
| | | * |
| | | * @author ruoyi |
| | | * @date 2024-01-15 |
| | | */ |
| | | public class SysTask extends BaseEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 任务ID */ |
| | | private Long taskId; |
| | | |
| | | /** 任务编号 */ |
| | | @Excel(name = "任务编号") |
| | | private String taskCode; |
| | | |
| | | /** 任务类型 */ |
| | | @Excel(name = "任务类型", readConverterExp = "MAINTENANCE=维修保养,FUEL=加油任务,OTHER=其他") |
| | | private String taskType; |
| | | |
| | | /** 任务状态 */ |
| | | @Excel(name = "任务状态", readConverterExp = "PENDING=待开始,IN_PROGRESS=任务中,COMPLETED=已完成,CANCELLED=已取消") |
| | | private String taskStatus; |
| | | |
| | | /** 任务描述 */ |
| | | @Excel(name = "任务描述") |
| | | private String taskDescription; |
| | | |
| | | /** 出发地址 */ |
| | | @Excel(name = "出发地址") |
| | | private String departureAddress; |
| | | |
| | | /** 目的地址 */ |
| | | @Excel(name = "目的地址") |
| | | private String destinationAddress; |
| | | |
| | | /** 出发地经度 */ |
| | | @Excel(name = "出发地经度") |
| | | private java.math.BigDecimal departureLongitude; |
| | | |
| | | /** 出发地纬度 */ |
| | | @Excel(name = "出发地纬度") |
| | | private java.math.BigDecimal departureLatitude; |
| | | |
| | | /** 目的地经度 */ |
| | | @Excel(name = "目的地经度") |
| | | private java.math.BigDecimal destinationLongitude; |
| | | |
| | | /** 目的地纬度 */ |
| | | @Excel(name = "目的地纬度") |
| | | private java.math.BigDecimal destinationLatitude; |
| | | |
| | | /** 预计公里数 */ |
| | | @Excel(name = "预计公里数") |
| | | private java.math.BigDecimal estimatedDistance; |
| | | |
| | | /** 计划开始时间 */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "计划开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date plannedStartTime; |
| | | |
| | | /** 计划结束时间 */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "计划结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date plannedEndTime; |
| | | |
| | | /** 实际开始时间 */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "实际开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date actualStartTime; |
| | | |
| | | /** 实际结束时间 */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "实际结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date actualEndTime; |
| | | |
| | | /** 创建人ID */ |
| | | @Excel(name = "创建人ID") |
| | | private Long creatorId; |
| | | |
| | | /** 执行人ID */ |
| | | @Excel(name = "执行人ID") |
| | | private Long assigneeId; |
| | | |
| | | /** 归属部门ID */ |
| | | @Excel(name = "归属部门ID") |
| | | private Long deptId; |
| | | |
| | | /** 创建人姓名 */ |
| | | @Excel(name = "创建人") |
| | | private String creatorName; |
| | | |
| | | /** 执行人姓名 */ |
| | | @Excel(name = "执行人") |
| | | private String assigneeName; |
| | | |
| | | /** 部门名称 */ |
| | | @Excel(name = "部门名称") |
| | | private String deptName; |
| | | |
| | | /** 删除标志(0代表存在 2代表删除) */ |
| | | private String delFlag; |
| | | |
| | | /** 旧系统同步标记:0-未同步,1-已同步 */ |
| | | private Integer legacySynced; |
| | | |
| | | /** 关联车辆列表 */ |
| | | private List<SysTaskVehicle> assignedVehicles; |
| | | |
| | | /** 附件列表 */ |
| | | private List<SysTaskAttachment> attachments; |
| | | |
| | | /** 操作日志列表 */ |
| | | private List<SysTaskLog> operationLogs; |
| | | |
| | | /** 急救转运扩展信息 */ |
| | | private SysTaskEmergency emergencyInfo; |
| | | |
| | | /** 福祉车扩展信息 */ |
| | | private SysTaskWelfare welfareInfo; |
| | | |
| | | public void setTaskId(Long taskId) { |
| | | this.taskId = taskId; |
| | | } |
| | | |
| | | public Long getTaskId() { |
| | | return taskId; |
| | | } |
| | | |
| | | public void setTaskCode(String taskCode) { |
| | | this.taskCode = taskCode; |
| | | } |
| | | |
| | | public String getTaskCode() { |
| | | return taskCode; |
| | | } |
| | | |
| | | public void setTaskType(String taskType) { |
| | | this.taskType = taskType; |
| | | } |
| | | |
| | | public String getTaskType() { |
| | | return taskType; |
| | | } |
| | | |
| | | public void setTaskStatus(String taskStatus) { |
| | | this.taskStatus = taskStatus; |
| | | } |
| | | |
| | | public String getTaskStatus() { |
| | | return taskStatus; |
| | | } |
| | | |
| | | public void setTaskDescription(String taskDescription) { |
| | | this.taskDescription = taskDescription; |
| | | } |
| | | |
| | | public String getTaskDescription() { |
| | | return taskDescription; |
| | | } |
| | | |
| | | public void setDepartureAddress(String departureAddress) { |
| | | this.departureAddress = departureAddress; |
| | | } |
| | | |
| | | public String getDepartureAddress() { |
| | | return departureAddress; |
| | | } |
| | | |
| | | public void setDestinationAddress(String destinationAddress) { |
| | | this.destinationAddress = destinationAddress; |
| | | } |
| | | |
| | | public String getDestinationAddress() { |
| | | return destinationAddress; |
| | | } |
| | | |
| | | public void setDepartureLongitude(java.math.BigDecimal departureLongitude) { |
| | | this.departureLongitude = departureLongitude; |
| | | } |
| | | |
| | | public java.math.BigDecimal getDepartureLongitude() { |
| | | return departureLongitude; |
| | | } |
| | | |
| | | public void setDepartureLatitude(java.math.BigDecimal departureLatitude) { |
| | | this.departureLatitude = departureLatitude; |
| | | } |
| | | |
| | | public java.math.BigDecimal getDepartureLatitude() { |
| | | return departureLatitude; |
| | | } |
| | | |
| | | public void setDestinationLongitude(java.math.BigDecimal destinationLongitude) { |
| | | this.destinationLongitude = destinationLongitude; |
| | | } |
| | | |
| | | public java.math.BigDecimal getDestinationLongitude() { |
| | | return destinationLongitude; |
| | | } |
| | | |
| | | public void setDestinationLatitude(java.math.BigDecimal destinationLatitude) { |
| | | this.destinationLatitude = destinationLatitude; |
| | | } |
| | | |
| | | public java.math.BigDecimal getDestinationLatitude() { |
| | | return destinationLatitude; |
| | | } |
| | | |
| | | public void setEstimatedDistance(java.math.BigDecimal estimatedDistance) { |
| | | this.estimatedDistance = estimatedDistance; |
| | | } |
| | | |
| | | public java.math.BigDecimal getEstimatedDistance() { |
| | | return estimatedDistance; |
| | | } |
| | | |
| | | public void setPlannedStartTime(Date plannedStartTime) { |
| | | this.plannedStartTime = plannedStartTime; |
| | | } |
| | | |
| | | public Date getPlannedStartTime() { |
| | | return plannedStartTime; |
| | | } |
| | | |
| | | public void setPlannedEndTime(Date plannedEndTime) { |
| | | this.plannedEndTime = plannedEndTime; |
| | | } |
| | | |
| | | public Date getPlannedEndTime() { |
| | | return plannedEndTime; |
| | | } |
| | | |
| | | public void setActualStartTime(Date actualStartTime) { |
| | | this.actualStartTime = actualStartTime; |
| | | } |
| | | |
| | | public Date getActualStartTime() { |
| | | return actualStartTime; |
| | | } |
| | | |
| | | public void setActualEndTime(Date actualEndTime) { |
| | | this.actualEndTime = actualEndTime; |
| | | } |
| | | |
| | | public Date getActualEndTime() { |
| | | return actualEndTime; |
| | | } |
| | | |
| | | public void setCreatorId(Long creatorId) { |
| | | this.creatorId = creatorId; |
| | | } |
| | | |
| | | public Long getCreatorId() { |
| | | return creatorId; |
| | | } |
| | | |
| | | public void setAssigneeId(Long assigneeId) { |
| | | this.assigneeId = assigneeId; |
| | | } |
| | | |
| | | public Long getAssigneeId() { |
| | | return assigneeId; |
| | | } |
| | | |
| | | public void setDeptId(Long deptId) { |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | public Long getDeptId() { |
| | | return deptId; |
| | | } |
| | | |
| | | public void setCreatorName(String creatorName) { |
| | | this.creatorName = creatorName; |
| | | } |
| | | |
| | | public String getCreatorName() { |
| | | return creatorName; |
| | | } |
| | | |
| | | public void setAssigneeName(String assigneeName) { |
| | | this.assigneeName = assigneeName; |
| | | } |
| | | |
| | | public String getAssigneeName() { |
| | | return assigneeName; |
| | | } |
| | | |
| | | public void setDeptName(String deptName) { |
| | | this.deptName = deptName; |
| | | } |
| | | |
| | | public String getDeptName() { |
| | | return deptName; |
| | | } |
| | | |
| | | public void setDelFlag(String delFlag) { |
| | | this.delFlag = delFlag; |
| | | } |
| | | |
| | | public String getDelFlag() { |
| | | return delFlag; |
| | | } |
| | | |
| | | public void setLegacySynced(Integer legacySynced) { |
| | | this.legacySynced = legacySynced; |
| | | } |
| | | |
| | | public Integer getLegacySynced() { |
| | | return legacySynced; |
| | | } |
| | | |
| | | public void setAssignedVehicles(List<SysTaskVehicle> assignedVehicles) { |
| | | this.assignedVehicles = assignedVehicles; |
| | | } |
| | | |
| | | public List<SysTaskVehicle> getAssignedVehicles() { |
| | | return assignedVehicles; |
| | | } |
| | | |
| | | public void setAttachments(List<SysTaskAttachment> attachments) { |
| | | this.attachments = attachments; |
| | | } |
| | | |
| | | public List<SysTaskAttachment> getAttachments() { |
| | | return attachments; |
| | | } |
| | | |
| | | public void setOperationLogs(List<SysTaskLog> operationLogs) { |
| | | this.operationLogs = operationLogs; |
| | | } |
| | | |
| | | public List<SysTaskLog> getOperationLogs() { |
| | | return operationLogs; |
| | | } |
| | | |
| | | public void setEmergencyInfo(SysTaskEmergency emergencyInfo) { |
| | | this.emergencyInfo = emergencyInfo; |
| | | } |
| | | |
| | | public SysTaskEmergency getEmergencyInfo() { |
| | | return emergencyInfo; |
| | | } |
| | | |
| | | public void setWelfareInfo(SysTaskWelfare welfareInfo) { |
| | | this.welfareInfo = welfareInfo; |
| | | } |
| | | |
| | | public SysTaskWelfare getWelfareInfo() { |
| | | return welfareInfo; |
| | | } |
| | | |
| | | /** |
| | | * 判断是否可以变更状态 |
| | | */ |
| | | public boolean canChangeStatus(TaskStatus newStatus) { |
| | | TaskStatus currentStatus = TaskStatus.getByCode(this.taskStatus); |
| | | if (currentStatus == null || newStatus == null) { |
| | | return false; |
| | | } |
| | | |
| | | // 状态流转规则 |
| | | switch (currentStatus) { |
| | | case PENDING: |
| | | // 待处理 -> 出发中、已取消 |
| | | return newStatus == TaskStatus.DEPARTING || newStatus == TaskStatus.CANCELLED; |
| | | case DEPARTING: |
| | | // 出发中 -> 已到达、已取消 |
| | | return newStatus == TaskStatus.ARRIVED || newStatus == TaskStatus.CANCELLED; |
| | | case ARRIVED: |
| | | // 已到达 -> 返程中 |
| | | return newStatus == TaskStatus.RETURNING; |
| | | case RETURNING: |
| | | // 返程中 -> 已完成 |
| | | return newStatus == TaskStatus.COMPLETED; |
| | | case IN_PROGRESS: |
| | | // 兼容旧数据:任务中 -> 已完成、已取消、待处理 |
| | | return newStatus == TaskStatus.COMPLETED || newStatus == TaskStatus.CANCELLED || newStatus == TaskStatus.PENDING; |
| | | case COMPLETED: |
| | | case CANCELLED: |
| | | // 已完成、已取消 -> 不允许任何状态变更 |
| | | return false; |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断是否超时 |
| | | */ |
| | | public boolean isOverdue() { |
| | | if (plannedEndTime == null) { |
| | | return false; |
| | | } |
| | | return new Date().after(plannedEndTime) && !TaskStatus.COMPLETED.getCode().equals(taskStatus); |
| | | } |
| | | |
| | | /** |
| | | * 获取任务持续时间(分钟) |
| | | */ |
| | | public long getDuration() { |
| | | if (actualStartTime != null && actualEndTime != null) { |
| | | return (actualEndTime.getTime() - actualStartTime.getTime()) / (1000 * 60); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * 开始任务 |
| | | */ |
| | | public void start() { |
| | | this.taskStatus = TaskStatus.IN_PROGRESS.getCode(); |
| | | this.actualStartTime = new Date(); |
| | | } |
| | | |
| | | /** |
| | | * 完成任务 |
| | | */ |
| | | public void complete() { |
| | | this.taskStatus = TaskStatus.COMPLETED.getCode(); |
| | | this.actualEndTime = new Date(); |
| | | } |
| | | |
| | | /** |
| | | * 取消任务 |
| | | */ |
| | | public void cancel() { |
| | | this.taskStatus = TaskStatus.CANCELLED.getCode(); |
| | | } |
| | | |
| | | /** |
| | | * 检查是否分配了指定车辆 |
| | | */ |
| | | public boolean hasVehicle(Long vehicleId) { |
| | | if (assignedVehicles == null || vehicleId == null) { |
| | | return false; |
| | | } |
| | | return assignedVehicles.stream().anyMatch(v -> vehicleId.equals(v.getVehicleId())); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "SysTask{" + |
| | | "taskId=" + taskId + |
| | | ", taskCode='" + taskCode + '\'' + |
| | | ", taskType='" + taskType + '\'' + |
| | | ", taskStatus='" + taskStatus + '\'' + |
| | | ", taskDescription='" + taskDescription + '\'' + |
| | | ", departureAddress='" + departureAddress + '\'' + |
| | | ", destinationAddress='" + destinationAddress + '\'' + |
| | | ", plannedStartTime=" + plannedStartTime + |
| | | ", plannedEndTime=" + plannedEndTime + |
| | | ", actualStartTime=" + actualStartTime + |
| | | ", actualEndTime=" + actualEndTime + |
| | | ", creatorId=" + creatorId + |
| | | ", assigneeId=" + assigneeId + |
| | | ", deptId=" + deptId + |
| | | ", creatorName='" + creatorName + '\'' + |
| | | ", assigneeName='" + assigneeName + '\'' + |
| | | ", deptName='" + deptName + '\'' + |
| | | '}'; |
| | | } |
| | | } |