Explorar el Código

行程周期已用时

guoyong hace 4 años
padre
commit
f363cb6df0

+ 13 - 1
src/main/java/com/aoyang/tms/controller/WorkCycleController.java

@@ -3,7 +3,10 @@ package com.aoyang.tms.controller;
 
 import com.alibaba.fastjson.JSON;
 import com.aoyang.tms.common.ErrCodeEnum;
+import com.aoyang.tms.controller.param.WorkCycleVO;
+import com.aoyang.tms.util.DateUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.web.bind.annotation.RestController;
@@ -11,7 +14,6 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.*;
 import lombok.extern.slf4j.Slf4j;
 
-import java.util.*;
 import javax.annotation.Resource;
 
 import com.aoyang.tms.service.WorkCycleService;
@@ -22,6 +24,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.aoyang.common.param.PageParam;
 
+import java.time.LocalDateTime;
+
 
 /**
  * <p>
@@ -47,7 +51,15 @@ public class WorkCycleController {
         if (workCycleParam == null || workCycleParam.getTruckId() == null) {
             return new Result(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
         }
+        WorkCycleVO workCycleVo = new WorkCycleVO();
         WorkCycle workCycle = workCycleService.findCurrentWorkCycle(workCycleParam.getTruckId());
+        BeanUtils.copyProperties(workCycle, workCycleVo);
+        if (workCycle.getStatus() == 1) {
+            workCycleVo.setTime(DateUtils.betweenTime(workCycle.getStartTime(), LocalDateTime.now()));
+        }
+        if (workCycle.getStatus() == 2) {
+            workCycleVo.setTime(DateUtils.betweenTime(workCycle.getStartTime(), workCycle.getEndTime()));
+        }
         return new Result<>(workCycle);
     }
 

+ 16 - 0
src/main/java/com/aoyang/tms/controller/param/WorkCycleVO.java

@@ -0,0 +1,16 @@
+package com.aoyang.tms.controller.param;
+
+import com.aoyang.tms.entity.WorkCycle;
+import lombok.Data;
+
+/**
+ * @Description: ${DESCRIPTION}
+ * @Author guoyong
+ * @Date 2022/4/28 11:48
+ * @Version 1.0
+ */
+@Data
+public class WorkCycleVO extends WorkCycle {
+
+    private String time;
+}