| | |
| | | package com.ruoyi.web.controller.task; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Anonymous; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.SysTaskEmergency; |
| | | import com.ruoyi.system.service.*; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | |
| | | @Log(title = "任务管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/admin") |
| | | public AjaxResult adminAdd(@RequestBody TaskCreateVO createVO) { |
| | | return toAjax(sysTaskService.insertSysTask(createVO)); |
| | | Long taskId = sysTaskService.insertSysTask(createVO); |
| | | return taskId > 0 ? AjaxResult.success("新增成功").put("taskId", taskId) : AjaxResult.error("新增失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 新增任务(APP端) |
| | |
| | | @Log(title = "任务创建", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult appAdd(@RequestBody TaskCreateVO createVO) { |
| | | return toAjax(sysTaskService.insertSysTask(createVO)); |
| | | Long taskId = sysTaskService.insertSysTask(createVO); |
| | | return taskId > 0 ? AjaxResult.success("新增成功").put("taskId", taskId) : AjaxResult.error("新增失败"); |
| | | } |
| | | |
| | | /** |
| | |
| | | sysTaskService.saveCancelInfo(taskId, request.getCancelReason()); |
| | | } |
| | | |
| | | // 如果是强制完成,更新实际开始时间和结束时间 |
| | | if (newStatus == TaskStatus.COMPLETED && request.getActualStartTime() != null && request.getActualEndTime() != null) { |
| | | SysTask task = new SysTask(); |
| | | task.setTaskId(taskId); |
| | | task.setTaskStatus(newStatus.getCode()); |
| | | //将String转成Date |
| | | |
| | | task.setActualStartTime(DateUtils.parseDate(request.getActualStartTime())); |
| | | task.setActualEndTime(DateUtils.parseDate(request.getActualEndTime())); |
| | | task.setRemark(request.getRemark()); |
| | | task.setUpdateBy(SecurityUtils.getUsername()); |
| | | task.setUpdateTime(DateUtils.getNowDate()); |
| | | |
| | | int result = sysTaskService.forceCompleteTask(task); |
| | | return toAjax(result); |
| | | } |
| | | |
| | | // 如果包含GPS位置信息,使用带位置的方法 |
| | | if (request.getLatitude() != null && request.getLongitude() != null) { |
| | | String address= mapService.reverseGeocoding(request.getLongitude(), request.getLatitude()); |
| | | request.setLocationAddress(address); |
| | | SysTaskLog locationLog = new SysTaskLog(); |
| | | locationLog.setLatitude(request.getLatitude()); |
| | | locationLog.setLongitude(request.getLongitude()); |
| | | locationLog.setLocationAddress(request.getLocationAddress()); |
| | | locationLog.setLocationProvince(request.getLocationProvince()); |
| | | locationLog.setLocationCity(request.getLocationCity()); |
| | | locationLog.setLocationDistrict(request.getLocationDistrict()); |
| | | locationLog.setGpsAccuracy(request.getGpsAccuracy()); |
| | | locationLog.setAltitude(request.getAltitude()); |
| | | locationLog.setSpeed(request.getSpeed()); |
| | | locationLog.setHeading(request.getHeading()); |
| | | SysTaskLog locationLog = getLocationLog(request); |
| | | |
| | | return toAjax(sysTaskService.changeTaskStatusWithLocation(taskId, newStatus, request.getRemark(), locationLog)); |
| | | } |
| | | |
| | | return toAjax(sysTaskService.changeTaskStatus(taskId, newStatus, request.getRemark())); |
| | | } |
| | | |
| | | private static SysTaskLog getLocationLog(ChangeStatusRequest request) { |
| | | SysTaskLog locationLog = new SysTaskLog(); |
| | | locationLog.setLatitude(request.getLatitude()); |
| | | locationLog.setLongitude(request.getLongitude()); |
| | | locationLog.setLocationAddress(request.getLocationAddress()); |
| | | locationLog.setLocationProvince(request.getLocationProvince()); |
| | | locationLog.setLocationCity(request.getLocationCity()); |
| | | locationLog.setLocationDistrict(request.getLocationDistrict()); |
| | | locationLog.setGpsAccuracy(request.getGpsAccuracy()); |
| | | locationLog.setAltitude(request.getAltitude()); |
| | | locationLog.setSpeed(request.getSpeed()); |
| | | locationLog.setHeading(request.getHeading()); |
| | | return locationLog; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // 取消相关字段 |
| | | private String cancelReason; // 取消原因(关联数据字典task_cancel_reason) |
| | | |
| | | // 强制完成相关字段 |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | private String actualStartTime; // 实际开始时间 |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | private String actualEndTime; // 实际结束时间 |
| | | |
| | | public String getTaskStatus() { |
| | | return taskStatus; |
| | |
| | | public void setCancelReason(String cancelReason) { |
| | | this.cancelReason = cancelReason; |
| | | } |
| | | |
| | | public String getActualStartTime() { |
| | | return actualStartTime; |
| | | } |
| | | |
| | | public void setActualStartTime(String actualStartTime) { |
| | | this.actualStartTime = actualStartTime; |
| | | } |
| | | |
| | | public String getActualEndTime() { |
| | | return actualEndTime; |
| | | } |
| | | |
| | | public void setActualEndTime(String actualEndTime) { |
| | | this.actualEndTime = actualEndTime; |
| | | } |
| | | } |
| | | } |