Quellcode durchsuchen

作业点添加location,运单详情添加耗时

guoyong vor 4 Jahren
Ursprung
Commit
4a65d50da6

+ 10 - 2
src/main/java/com/aoyang/tms/controller/WorkerController.java

@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON;
 import com.aoyang.common.param.PageParam;
 import com.aoyang.common.result.Result;
 import com.aoyang.tms.common.ErrCodeEnum;
+import com.aoyang.tms.controller.vo.LocationVO;
 import com.aoyang.tms.controller.vo.WorkOrderVO;
 import com.aoyang.tms.controller.vo.WorkerInfo;
 import com.aoyang.tms.entity.*;
 import com.aoyang.tms.service.*;
+import com.aoyang.tms.util.DateUtils;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -74,14 +76,20 @@ public class WorkerController {
     @ApiOperation(value = "运单详情", notes = "必传参数:订单id")
     @PostMapping("/find_order_info")
     public Result<WorkOrderVO> findOrderInfo(@RequestHeader(value = "orgId") Long orgId,
-                                           @RequestHeader(value = "userId") Long userId, @RequestBody WorkOrder workOrder) {
+                                             @RequestHeader(value = "userId") Long userId, @RequestBody WorkOrder workOrder) {
         log.info("运单详情,/tms/worker/find_order_info,参数:{}", JSON.toJSONString(workOrder));
         if (workOrder == null || workOrder.getId() == null) {
             return new Result(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
         }
         WorkOrderVO vo = new WorkOrderVO();
         WorkOrder workerInfo1 = workOrderService.getById(workOrder.getId());
-        BeanUtils.copyProperties(workerInfo1,vo);
+        if (workerInfo1 != null) {
+            LocationVO locationVO = commonService.getLocationByDate(workerInfo1.getTruckId(), workerInfo1.getExecuteTime());
+            if (locationVO != null) {
+                vo.setTime(DateUtils.betweenTime(locationVO.getDate(), LocalDateTime.now()));
+            }
+        }
+        BeanUtils.copyProperties(workerInfo1, vo);
 
         return new Result<>(vo);
     }

+ 5 - 5
src/main/java/com/aoyang/tms/controller/vo/WorkOrderVO.java

@@ -17,8 +17,8 @@ import java.time.LocalDateTime;
 
 /**
  * <p>
-    * 运单运单表
-    * </p>
+ * 运单运单表
+ * </p>
  *
  * @author guoyong
  * @since 2022-04-20
@@ -26,7 +26,7 @@ import java.time.LocalDateTime;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@ApiModel(value="WorkOrder对象", description="运单运单表")
+@ApiModel(value = "WorkOrder对象", description = "运单运单表")
 public class WorkOrderVO extends WorkOrder implements Serializable {
 
     @ApiModelProperty(value = "已读未读状态,0未读,1已读")
@@ -35,8 +35,8 @@ public class WorkOrderVO extends WorkOrder implements Serializable {
     @ApiModelProperty(value = "车辆状态,已收车0,出车前检查1,出车作业中2,收车中3,收车后检查4")
     private Integer truckStatus;
 
-    @ApiModelProperty(value = "已用时,单位分钟")
-    private int time;
+    @ApiModelProperty(value = "已用时,如1天1小时16分钟")
+    private String time;
 
     @ApiModelProperty(value = "装卸车点经度")
     @TableField("longitude")

+ 4 - 0
src/main/java/com/aoyang/tms/entity/WorkSpot.java

@@ -60,6 +60,10 @@ public class WorkSpot implements Serializable {
     @TableField("type")
     private Integer type;
 
+    @ApiModelProperty(value = "精确地点经纬度")
+    @TableField("location")
+    private String location;
+
     @ApiModelProperty(value = "作业点经纬度数据集")
     @TableField("region_data")
     private String regionData;

+ 7 - 4
src/main/java/com/aoyang/tms/util/DateUtils.java

@@ -155,10 +155,10 @@ public class DateUtils {
 
 
     /**
-     * 计算两个日期相差多少小时,分钟,毫
+     * 计算两个日期相差多少天、小时、分钟、
      */
 
-    public static String betweenDay(LocalDateTime startTime, LocalDateTime endTime) {
+    public static String betweenTime(LocalDateTime startTime, LocalDateTime endTime) {
         java.time.Duration duration = java.time.Duration.between(startTime, endTime);
         //总秒
         long seconds = duration.toMillis() / 1000;
@@ -183,14 +183,17 @@ public class DateUtils {
         if (minutes > 0) {
             last = last + minutes % 60 + "分钟";
         }
+        if (seconds > 0) {
+            last = last + seconds % 60 + "秒";
+        }
         return last;
 
     }
 
     public static void main(String[] args) {
         LocalDateTime now = LocalDateTime.of(2022, 4, 24, 11, 9, 38);
-        LocalDateTime end = LocalDateTime.of(2022, 4, 25, 14, 8, 38);
-        String last = betweenDay(now, end);
+        LocalDateTime end = LocalDateTime.of(2022, 4, 25, 14, 12, 32);
+        String last = betweenTime(now, end);
         System.out.println(last);
     }
 

+ 33 - 16
src/main/resources/mapper/WorkSpotMapper.xml

@@ -4,26 +4,43 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.aoyang.tms.entity.WorkSpot">
-        <id column="spot_id" property="spotId" />
-        <result column="spot_name" property="spotName" />
-        <result column="org_id" property="orgId" />
-        <result column="org_name" property="orgName" />
-        <result column="org_short_name" property="orgShortName" />
-        <result column="adress" property="adress" />
-        <result column="type" property="type" />
-        <result column="region_data" property="regionData" />
-        <result column="note" property="note" />
-        <result column="creater" property="creater" />
-        <result column="creater_name" property="createrName" />
-        <result column="create_date" property="createDate" />
-        <result column="updater" property="updater" />
-        <result column="updater_name" property="updaterName" />
-        <result column="update_date" property="updateDate" />
+        <id column="spot_id" property="spotId"/>
+        <result column="spot_name" property="spotName"/>
+        <result column="org_id" property="orgId"/>
+        <result column="org_name" property="orgName"/>
+        <result column="org_short_name" property="orgShortName"/>
+        <result column="adress" property="adress"/>
+        <result column="type" property="type"/>
+        <result column="location" property="location"/>
+        <result column="region_data" property="regionData"/>
+        <result column="note" property="note"/>
+        <result column="creater" property="creater"/>
+        <result column="creater_name" property="createrName"/>
+        <result column="create_date" property="createDate"/>
+        <result column="updater" property="updater"/>
+        <result column="updater_name" property="updaterName"/>
+        <result column="update_date" property="updateDate"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        spot_id, spot_name, org_id, org_name, org_short_name, adress, type, region_data, note, creater, creater_name, create_date, updater, updater_name, update_date
+        spot_id
+        ,
+        spot_name,
+        org_id,
+        org_name,
+        org_short_name,
+        adress,
+        type,
+        region_data,
+        location,
+        note,
+        creater,
+        creater_name,
+        create_date,
+        updater,
+        updater_name,
+        update_date
     </sql>
 
 </mapper>