Commit 8008e620048defed8de2cf8795e3618c59ff9997

Authored by guzijian
1 parent d9b31eb7

feat: 修改配置信息

Showing 19 changed files with 141 additions and 72 deletions
trash-garbage/src/main/java/com/trash/garbage/controller/GarbageOrderController.java
@@ -47,7 +47,7 @@ public class GarbageOrderController { @@ -47,7 +47,7 @@ public class GarbageOrderController {
47 private ServerConfig serverConfig; 47 private ServerConfig serverConfig;
48 48
49 @PostMapping("/add") 49 @PostMapping("/add")
50 - @Log(title = "创建单", businessType = BusinessType.INSERT) 50 + @Log(title = "创建单", businessType = BusinessType.INSERT)
51 public Result<?> saveOrder(@Validated @RequestBody OrderDto dto) { 51 public Result<?> saveOrder(@Validated @RequestBody OrderDto dto) {
52 return Result.OK(garOrderService.saveOrder(dto)); 52 return Result.OK(garOrderService.saveOrder(dto));
53 } 53 }
@@ -115,10 +115,10 @@ public class GarbageOrderController { @@ -115,10 +115,10 @@ public class GarbageOrderController {
115 } 115 }
116 116
117 /** 117 /**
118 - * 导出清运单列表 118 + * 导出清运单列表
119 */ 119 */
120 @PreAuthorize("@ss.hasPermi('garbage:order:export')") 120 @PreAuthorize("@ss.hasPermi('garbage:order:export')")
121 - @Log(title = "清运单", businessType = BusinessType.EXPORT) 121 + @Log(title = "清运单", businessType = BusinessType.EXPORT)
122 @GetMapping("/export") 122 @GetMapping("/export")
123 public AjaxResult export(GarOrder garOrder) { 123 public AjaxResult export(GarOrder garOrder) {
124 List<GarOrder> list = garOrderService.queryOrderListByGarOrder(garOrder); 124 List<GarOrder> list = garOrderService.queryOrderListByGarOrder(garOrder);
trash-garbage/src/main/java/com/trash/garbage/mapper/GarOrderCarMapper.java
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
6 /** 6 /**
7 * @author 20412 7 * @author 20412
8 -* @description 针对表【gar_order_car(单车辆信息)】的数据库操作Mapper 8 +* @description 针对表【gar_order_car(单车辆信息)】的数据库操作Mapper
9 * @createDate 2024-01-09 14:26:09 9 * @createDate 2024-01-09 14:26:09
10 * @Entity com.trash.garbage.pojo.domain.GarOrderCar 10 * @Entity com.trash.garbage.pojo.domain.GarOrderCar
11 */ 11 */
trash-garbage/src/main/java/com/trash/garbage/mapper/GarOrderEvaluateMapper.java
@@ -8,7 +8,7 @@ import java.util.List; @@ -8,7 +8,7 @@ import java.util.List;
8 8
9 /** 9 /**
10 * @author 20412 10 * @author 20412
11 -* @description 针对表【gar_order_evaluate(建筑垃圾-单评分)】的数据库操作Mapper 11 +* @description 针对表【gar_order_evaluate(建筑垃圾-单评分)】的数据库操作Mapper
12 * @createDate 2023-11-29 14:19:18 12 * @createDate 2023-11-29 14:19:18
13 * @Entity com.trash.garbage.pojo.domain.GarOrderEvaluate 13 * @Entity com.trash.garbage.pojo.domain.GarOrderEvaluate
14 */ 14 */
trash-garbage/src/main/java/com/trash/garbage/mapper/GarOrderMatchHandlerMapper.java
@@ -10,7 +10,7 @@ import java.util.List; @@ -10,7 +10,7 @@ import java.util.List;
10 10
11 /** 11 /**
12 * @author 20412 12 * @author 20412
13 -* @description 针对表【gar_order_match_handler(单分发处理表)】的数据库操作Mapper 13 +* @description 针对表【gar_order_match_handler(单分发处理表)】的数据库操作Mapper
14 * @createDate 2024-01-09 14:26:09 14 * @createDate 2024-01-09 14:26:09
15 * @Entity com.trash.garbage.pojo.domain.GarOrderMatchHandler 15 * @Entity com.trash.garbage.pojo.domain.GarOrderMatchHandler
16 */ 16 */
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarOrderCar.java
@@ -7,7 +7,7 @@ import java.util.Date; @@ -7,7 +7,7 @@ import java.util.Date;
7 import lombok.Data; 7 import lombok.Data;
8 8
9 /** 9 /**
10 - * 单车辆信息 10 + * 单车辆信息
11 * @TableName gar_order_car 11 * @TableName gar_order_car
12 */ 12 */
13 @TableName(value ="gar_order_car") 13 @TableName(value ="gar_order_car")
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarOrderEvaluate.java
@@ -9,7 +9,7 @@ import java.util.Date; @@ -9,7 +9,7 @@ import java.util.Date;
9 import lombok.Data; 9 import lombok.Data;
10 10
11 /** 11 /**
12 - * 建筑垃圾-单评分 12 + * 建筑垃圾-单评分
13 * @author 20412 13 * @author 20412
14 * @TableName gar_order_evaluate 14 * @TableName gar_order_evaluate
15 */ 15 */
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarOrderMatchHandler.java
@@ -12,7 +12,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder; @@ -12,7 +12,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
12 import org.apache.commons.lang3.builder.HashCodeBuilder; 12 import org.apache.commons.lang3.builder.HashCodeBuilder;
13 13
14 /** 14 /**
15 - * 单分发处理表 15 + * 单分发处理表
16 * @TableName gar_order_match_handler 16 * @TableName gar_order_match_handler
17 */ 17 */
18 @TableName(value ="gar_order_match_handler") 18 @TableName(value ="gar_order_match_handler")
trash-garbage/src/main/java/com/trash/garbage/pojo/dto/EnterpriseDto.java 0 → 100644
  1 +package com.trash.garbage.pojo.dto;
  2 +
  3 +public class EnterpriseDto {
  4 +}
trash-garbage/src/main/java/com/trash/garbage/pojo/vo/GarOrderDriverVo.java
@@ -10,7 +10,7 @@ import lombok.EqualsAndHashCode; @@ -10,7 +10,7 @@ import lombok.EqualsAndHashCode;
10 public class GarOrderDriverVo extends GarOrder { 10 public class GarOrderDriverVo extends GarOrder {
11 11
12 /** 12 /**
13 - * gar_order_status 代表订单的全局状态 员order 的gar_order_handler_status 变为代表分发后驾驶员自己处理单的状态 13 + * gar_order_status 代表订单的全局状态 员order 的gar_order_handler_status 变为代表分发后驾驶员自己处理单的状态
14 */ 14 */
15 private Integer garOrderStatus; 15 private Integer garOrderStatus;
16 16
trash-garbage/src/main/java/com/trash/garbage/pojo/vo/TransportationEnterpriseVo.java
@@ -12,6 +12,8 @@ public class TransportationEnterpriseVo extends TransportationEnterprise { @@ -12,6 +12,8 @@ public class TransportationEnterpriseVo extends TransportationEnterprise {
12 private String score; 12 private String score;
13 13
14 private Integer cleanNumber; 14 private Integer cleanNumber;
  15 + private String distance;
  16 +
15 17
16 public Integer getCleanNumber() { 18 public Integer getCleanNumber() {
17 return cleanNumber; 19 return cleanNumber;
@@ -26,7 +28,20 @@ public class TransportationEnterpriseVo extends TransportationEnterprise { @@ -26,7 +28,20 @@ public class TransportationEnterpriseVo extends TransportationEnterprise {
26 } 28 }
27 29
28 public void setScore(Float score) { 30 public void setScore(Float score) {
29 - DecimalFormat df =new DecimalFormat("#0.0");  
30 - this.score = df.format(score);; 31 + DecimalFormat df = new DecimalFormat("#0.0");
  32 + this.score = df.format(score);
  33 + }
  34 +
  35 + public void setScore(String score) {
  36 + this.score = score;
  37 + }
  38 +
  39 + public String getDistance() {
  40 + return distance;
  41 + }
  42 +
  43 + public void setDistance(double distance) {
  44 + DecimalFormat df = new DecimalFormat("#0.0");
  45 + this.distance = df.format(distance);
31 } 46 }
32 } 47 }
trash-garbage/src/main/java/com/trash/garbage/service/GarOrderCarService.java
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService; @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
5 5
6 /** 6 /**
7 * @author 20412 7 * @author 20412
8 -* @description 针对表【gar_order_car(单车辆信息)】的数据库操作Service 8 +* @description 针对表【gar_order_car(单车辆信息)】的数据库操作Service
9 * @createDate 2024-01-09 14:26:09 9 * @createDate 2024-01-09 14:26:09
10 */ 10 */
11 public interface GarOrderCarService extends IService<GarOrderCar> { 11 public interface GarOrderCarService extends IService<GarOrderCar> {
trash-garbage/src/main/java/com/trash/garbage/service/GarOrderEvaluateService.java
@@ -8,7 +8,7 @@ import java.util.List; @@ -8,7 +8,7 @@ import java.util.List;
8 8
9 /** 9 /**
10 * @author 20412 10 * @author 20412
11 -* @description 针对表【gar_order_evaluate(建筑垃圾-单评分)】的数据库操作Service 11 +* @description 针对表【gar_order_evaluate(建筑垃圾-单评分)】的数据库操作Service
12 * @createDate 2023-11-29 14:19:18 12 * @createDate 2023-11-29 14:19:18
13 */ 13 */
14 public interface GarOrderEvaluateService extends IService<GarOrderEvaluate> { 14 public interface GarOrderEvaluateService extends IService<GarOrderEvaluate> {
trash-garbage/src/main/java/com/trash/garbage/service/GarOrderMatchHandlerService.java
@@ -9,7 +9,7 @@ import java.util.List; @@ -9,7 +9,7 @@ import java.util.List;
9 9
10 /** 10 /**
11 * @author 20412 11 * @author 20412
12 -* @description 针对表【gar_order_match_handler(单分发处理表)】的数据库操作Service 12 +* @description 针对表【gar_order_match_handler(单分发处理表)】的数据库操作Service
13 * @createDate 2024-01-09 14:26:09 13 * @createDate 2024-01-09 14:26:09
14 */ 14 */
15 public interface GarOrderMatchHandlerService extends IService<GarOrderMatchHandler> { 15 public interface GarOrderMatchHandlerService extends IService<GarOrderMatchHandler> {
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderCarServiceImpl.java
@@ -8,7 +8,7 @@ import org.springframework.stereotype.Service; @@ -8,7 +8,7 @@ import org.springframework.stereotype.Service;
8 8
9 /** 9 /**
10 * @author 20412 10 * @author 20412
11 -* @description 针对表【gar_order_car(单车辆信息)】的数据库操作Service实现 11 +* @description 针对表【gar_order_car(单车辆信息)】的数据库操作Service实现
12 * @createDate 2024-01-09 14:26:09 12 * @createDate 2024-01-09 14:26:09
13 */ 13 */
14 @Service 14 @Service
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderEvaluateServiceImpl.java
@@ -12,7 +12,7 @@ import java.util.List; @@ -12,7 +12,7 @@ import java.util.List;
12 12
13 /** 13 /**
14 * @author 20412 14 * @author 20412
15 -* @description 针对表【gar_order_evaluate(建筑垃圾-单评分)】的数据库操作Service实现 15 +* @description 针对表【gar_order_evaluate(建筑垃圾-单评分)】的数据库操作Service实现
16 * @createDate 2023-11-29 14:19:18 16 * @createDate 2023-11-29 14:19:18
17 */ 17 */
18 @Service 18 @Service
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderMatchHandlerServiceImpl.java
@@ -11,7 +11,7 @@ import java.util.List; @@ -11,7 +11,7 @@ import java.util.List;
11 11
12 /** 12 /**
13 * @author 20412 13 * @author 20412
14 - * @description 针对表【gar_order_match_handler(单分发处理表)】的数据库操作Service实现 14 + * @description 针对表【gar_order_match_handler(单分发处理表)】的数据库操作Service实现
15 * @createDate 2024-01-09 14:26:09 15 * @createDate 2024-01-09 14:26:09
16 */ 16 */
17 @Service 17 @Service
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderServiceImpl.java
@@ -13,6 +13,7 @@ import com.trash.garbage.pojo.vo.DispatchDriverVo; @@ -13,6 +13,7 @@ import com.trash.garbage.pojo.vo.DispatchDriverVo;
13 import com.trash.garbage.pojo.vo.GarOrderDriverVo; 13 import com.trash.garbage.pojo.vo.GarOrderDriverVo;
14 import com.trash.garbage.pojo.vo.TransportationEnterpriseVo; 14 import com.trash.garbage.pojo.vo.TransportationEnterpriseVo;
15 import com.trash.garbage.service.*; 15 import com.trash.garbage.service.*;
  16 +import com.trash.garbage.utils.SMSUtils;
16 import org.apache.commons.lang3.StringUtils; 17 import org.apache.commons.lang3.StringUtils;
17 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
@@ -45,6 +46,9 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -45,6 +46,9 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
45 private GarOrderImageService garOrderImageService; 46 private GarOrderImageService garOrderImageService;
46 47
47 @Autowired 48 @Autowired
  49 + private GarAddressService garAddressService;
  50 +
  51 + @Autowired
48 private ITransportationEnterpriseService transportationEnterpriseService; 52 private ITransportationEnterpriseService transportationEnterpriseService;
49 53
50 @Autowired 54 @Autowired
@@ -108,6 +112,8 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -108,6 +112,8 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
108 images.add(image); 112 images.add(image);
109 } 113 }
110 garOrderImageService.saveBatch(images); 114 garOrderImageService.saveBatch(images);
  115 + // TODO 短信提醒 居民下单
  116 + SMSUtils.sendMessage(order.getGarOrderCompanyTel(), "企业收单:您有新的清运订单,请及时查看并处理。");
111 return order.getGarOrderId(); 117 return order.getGarOrderId();
112 } 118 }
113 119
@@ -265,13 +271,14 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -265,13 +271,14 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
265 public String updateOrder(OrderUpdateDto dto) { 271 public String updateOrder(OrderUpdateDto dto) {
266 String userId = SecurityUtils.getLoginUser().getUser().getUserId(); 272 String userId = SecurityUtils.getLoginUser().getUser().getUserId();
267 GarUser user = garUserService.getById(userId); 273 GarUser user = garUserService.getById(userId);
268 - // 处理用户单 居民用户 | 企业负责人 274 + // 处理用户单 居民用户 | 企业负责人
269 if (user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.RESPONSIBLE_USER.getDescription()) 275 if (user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.RESPONSIBLE_USER.getDescription())
270 || user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription())) { 276 || user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription())) {
271 return handlerOrderStatus(dto, user); 277 return handlerOrderStatus(dto, user);
272 } 278 }
273 - // 处理分发单 驾驶员 279 + // 处理分发单 驾驶员
274 else if (user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.DRIVER_USER.getDescription())) { 280 else if (user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.DRIVER_USER.getDescription())) {
  281 + // TODO 后续删除 驾驶员无法取消
275 return handlerDispatchOrderStatus(dto, user); 282 return handlerDispatchOrderStatus(dto, user);
276 } 283 }
277 284
@@ -279,6 +286,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -279,6 +286,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
279 286
280 } 287 }
281 288
  289 + @Deprecated
282 private String handlerDispatchOrderStatus(OrderUpdateDto dto, GarUser user) { 290 private String handlerDispatchOrderStatus(OrderUpdateDto dto, GarUser user) {
283 // GarOrder order = getById(dto.getGarOrderId()); 291 // GarOrder order = getById(dto.getGarOrderId());
284 GarOrderDriverVo order = baseMapper.queryOrderByTelWithType(user.getGarUserTel(), dto.getGarOrderId(), GlobalStatus.GarOrderStatus.CANCEL_FLAG_NO.getValue()); 292 GarOrderDriverVo order = baseMapper.queryOrderByTelWithType(user.getGarUserTel(), dto.getGarOrderId(), GlobalStatus.GarOrderStatus.CANCEL_FLAG_NO.getValue());
@@ -289,7 +297,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -289,7 +297,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
289 .set(GarOrderMatchHandler::getGarReason, dto.getGarReason()) 297 .set(GarOrderMatchHandler::getGarReason, dto.getGarReason())
290 .eq(GarOrderMatchHandler::getGarOrderId, dto.getGarOrderId()); 298 .eq(GarOrderMatchHandler::getGarOrderId, dto.getGarOrderId());
291 handlerService.update(uw); 299 handlerService.update(uw);
292 - return "已取消单"; 300 + return "已取消单";
293 } else { 301 } else {
294 // 公司所属 待清运- 》 清运中 302 // 公司所属 待清运- 》 清运中
295 if (order.getGarOrderHandlerStatus().equals(GlobalStatus.GarOrderStatus.NEW_ORDER.getValue()) 303 if (order.getGarOrderHandlerStatus().equals(GlobalStatus.GarOrderStatus.NEW_ORDER.getValue())
@@ -299,7 +307,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -299,7 +307,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
299 .eq(GarOrderMatchHandler::getGarOrderHandlerTel, user.getGarUserTel()) 307 .eq(GarOrderMatchHandler::getGarOrderHandlerTel, user.getGarUserTel())
300 .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue()); 308 .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue());
301 handlerService.update(uw); 309 handlerService.update(uw);
302 - return "已接受单"; 310 + return "已接受单";
303 } 311 }
304 // 运输驾驶员 清运中 ==》已完成 312 // 运输驾驶员 清运中 ==》已完成
305 if (GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue().equals(order.getGarOrderHandlerStatus()) 313 if (GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue().equals(order.getGarOrderHandlerStatus())
@@ -310,7 +318,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -310,7 +318,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
310 .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue()); 318 .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue());
311 handlerService.update(uw); 319 handlerService.update(uw);
312 } 320 }
313 - return "单已完成"; 321 + return "单已完成";
314 } 322 }
315 } 323 }
316 324
@@ -323,9 +331,15 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -323,9 +331,15 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
323 .set(GarOrder::getGarReason, dto.getGarReason()) 331 .set(GarOrder::getGarReason, dto.getGarReason())
324 .eq(GarOrder::getGarOrderId, dto.getGarOrderId()); 332 .eq(GarOrder::getGarOrderId, dto.getGarOrderId());
325 update(uw); 333 update(uw);
  334 + // TODO 短信提醒 公司 | 居民
  335 + String tel = GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription().equals(user.getGarUserType()) ?
  336 + order.getGarOrderCompanyTel() : order.getGarOrderContactTel();
  337 + String message = GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription().equals(user.getGarUserType()) ?
  338 + "居民取消订单:您的清运订单已取消,详情可在小程序查看" : "企业拒单";
  339 + SMSUtils.sendMessage(tel, message);
326 return "订单取消成功"; 340 return "订单取消成功";
327 } 341 }
328 - // 企业负责人 TODO 342 + // 企业负责人
329 else { 343 else {
330 // 公司所属 待清运- 》 清运中 344 // 公司所属 待清运- 》 清运中
331 if (order.getGarOrderHandlerStatus().equals(GlobalStatus.GarOrderStatus.NEW_ORDER.getValue()) 345 if (order.getGarOrderHandlerStatus().equals(GlobalStatus.GarOrderStatus.NEW_ORDER.getValue())
@@ -338,7 +352,9 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -338,7 +352,9 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
338 .set(GarOrder::getGarOrderHandlerStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue()) 352 .set(GarOrder::getGarOrderHandlerStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue())
339 .set(GarOrder::getGarOrderHandlerId, user.getGarUserId()); 353 .set(GarOrder::getGarOrderHandlerId, user.getGarUserId());
340 update(uw); 354 update(uw);
341 - return "已接受派单"; 355 + // TODO 短信提醒
  356 + SMSUtils.sendMessage(order.getGarOrderContactTel(), "运输公司已接受订单号为 " + order.getGarOrderId() + " 的订单。");
  357 + return "已接受订单";
342 } 358 }
343 // 企业负责人 清运中 ==》已完成 359 // 企业负责人 清运中 ==》已完成
344 if (GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue().equals(order.getGarOrderHandlerStatus()) 360 if (GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue().equals(order.getGarOrderHandlerStatus())
@@ -350,7 +366,9 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -350,7 +366,9 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
350 .set(GarOrder::getGarEvaluateFlag, GlobalStatus.GarOrderStatus.EVALUATE_ORDER_NO.getValue()); 366 .set(GarOrder::getGarEvaluateFlag, GlobalStatus.GarOrderStatus.EVALUATE_ORDER_NO.getValue());
351 update(uw); 367 update(uw);
352 } 368 }
353 - return "派单已完成"; 369 + // TODO 短信提醒
  370 + SMSUtils.sendMessage(order.getGarOrderContactTel(), "运输公司已完成订单号为 " + order.getGarOrderId() + " 的订单。");
  371 + return "订单已完成";
354 } 372 }
355 } 373 }
356 374
@@ -487,15 +505,21 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -487,15 +505,21 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
487 evaluate.add(garOrderEvaluate); 505 evaluate.add(garOrderEvaluate);
488 } 506 }
489 } 507 }
490 - 508 + // 获取当前选中地址计算距离
  509 + LambdaQueryWrapper<GarAddress> qw = new LambdaQueryWrapper<>();
  510 + qw.eq(GarAddress::getGarUserId, SecurityUtils.getLoginUser().getUser().getUserId())
  511 + .eq(GarAddress::getGarUserDefault, GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue());
  512 + GarAddress address = garAddressService.getOne(qw);
491 List<TransportationEnterpriseVo> voList = list.stream().map(item -> { 513 List<TransportationEnterpriseVo> voList = list.stream().map(item -> {
492 TransportationEnterpriseVo vo = new TransportationEnterpriseVo(); 514 TransportationEnterpriseVo vo = new TransportationEnterpriseVo();
493 BeanUtils.copyProperties(item, vo); 515 BeanUtils.copyProperties(item, vo);
494 List<GarOrderEvaluate> evaluate = evaluateMap.get(String.valueOf(item.getId())); 516 List<GarOrderEvaluate> evaluate = evaluateMap.get(String.valueOf(item.getId()));
495 handleCleanNumber(vo, orderList); 517 handleCleanNumber(vo, orderList);
496 handleScore(vo, evaluate); 518 handleScore(vo, evaluate);
  519 + handleKilometre(vo, address);
497 return vo; 520 return vo;
498 }) 521 })
  522 + .sorted(Comparator.comparing(TransportationEnterpriseVo::getDistance))
499 .collect(Collectors.toList()); 523 .collect(Collectors.toList());
500 PageInfo<TransportationEnterpriseVo> pageInfo = new PageInfo<>(); 524 PageInfo<TransportationEnterpriseVo> pageInfo = new PageInfo<>();
501 pageInfo.setList(voList); 525 pageInfo.setList(voList);
@@ -503,6 +527,31 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -503,6 +527,31 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
503 return pageInfo; 527 return pageInfo;
504 } 528 }
505 529
  530 + private void handleKilometre(TransportationEnterpriseVo vo, GarAddress address) {
  531 + String[] params = vo.getOfficeAddressGps().split(",");
  532 + double kilometre = calculateDistance(Double.parseDouble(params[1]), Double.parseDouble(params[0]), address.getGarLatitude(), address.getGarLongitude());
  533 + vo.setDistance(kilometre);
  534 + }
  535 +
  536 + private double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
  537 + // 将经纬度转换为弧度
  538 + double lat1Rad = Math.toRadians(lat1);
  539 + double lon1Rad = Math.toRadians(lon1);
  540 + double lat2Rad = Math.toRadians(lat2);
  541 + double lon2Rad = Math.toRadians(lon2);
  542 +
  543 + // 应用 Haversine 公式计算距离
  544 + double dlon = lon2Rad - lon1Rad;
  545 + double dlat = lat2Rad - lat1Rad;
  546 + double a = Math.sin(dlat / 2) * Math.sin(dlat / 2) +
  547 + Math.cos(lat1Rad) * Math.cos(lat2Rad) *
  548 + Math.sin(dlon / 2) * Math.sin(dlon / 2);
  549 + double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  550 + double radius = 6371; // 地球平均半径(单位:公里)
  551 + double distance = radius * c;
  552 + return distance;
  553 + }
  554 +
506 @Override 555 @Override
507 public List<GarOrderEvaluate> queryEvaluateDetail(String orderId) { 556 public List<GarOrderEvaluate> queryEvaluateDetail(String orderId) {
508 LambdaQueryWrapper<GarOrderEvaluate> qw = new LambdaQueryWrapper<>(); 557 LambdaQueryWrapper<GarOrderEvaluate> qw = new LambdaQueryWrapper<>();
trash-garbage/src/main/java/com/trash/garbage/utils/JwtUtils.java
@@ -8,17 +8,24 @@ import java.util.Date; @@ -8,17 +8,24 @@ import java.util.Date;
8 8
9 /** 9 /**
10 * jwt 工具类 10 * jwt 工具类
  11 + *
11 * @author 20412 12 * @author 20412
12 */ 13 */
13 @Slf4j 14 @Slf4j
14 public class JwtUtils { 15 public class JwtUtils {
15 16
16 - /** 过期时间设置 365天*/ 17 + /**
  18 + * 过期时间设置 最近 365天
  19 + */
17 private final static long tokenExpiration = 365 * 24 * 60 * 60 * 1000; 20 private final static long tokenExpiration = 365 * 24 * 60 * 60 * 1000;
18 - /** jwt密钥*/ 21 + /**
  22 + * jwt密钥
  23 + */
19 private final static String tokenSecret = "guzijian"; 24 private final static String tokenSecret = "guzijian";
20 25
21 - /** 创建token */ 26 + /**
  27 + * 创建token
  28 + */
22 public static String createToken(String id, String tel) { 29 public static String createToken(String id, String tel) {
23 String token = Jwts.builder() 30 String token = Jwts.builder()
24 // 说明 31 // 说明
@@ -26,8 +33,8 @@ public class JwtUtils { @@ -26,8 +33,8 @@ public class JwtUtils {
26 // 过期时间 33 // 过期时间
27 .setExpiration(new Date(System.currentTimeMillis() + tokenExpiration)) 34 .setExpiration(new Date(System.currentTimeMillis() + tokenExpiration))
28 // 加入认证信息 35 // 加入认证信息
29 - .claim("tel",tel)  
30 - .claim("userId",id) 36 + .claim("tel", tel)
  37 + .claim("userId", id)
31 // 加密方式 jwt 密钥方便解密 38 // 加密方式 jwt 密钥方便解密
32 .signWith(SignatureAlgorithm.HS256, tokenSecret) 39 .signWith(SignatureAlgorithm.HS256, tokenSecret)
33 // 压缩方式 40 // 压缩方式
@@ -37,8 +44,10 @@ public class JwtUtils { @@ -37,8 +44,10 @@ public class JwtUtils {
37 return token; 44 return token;
38 } 45 }
39 46
40 - /** 通过token获取user id */  
41 - public static String getUserId(String token){ 47 + /**
  48 + * 通过token获取user id
  49 + */
  50 + public static String getUserId(String token) {
42 Claims claims = null; 51 Claims claims = null;
43 try { 52 try {
44 Jws<Claims> claimsJws = Jwts.parser() 53 Jws<Claims> claimsJws = Jwts.parser()
@@ -46,14 +55,16 @@ public class JwtUtils { @@ -46,14 +55,16 @@ public class JwtUtils {
46 .parseClaimsJws(token); 55 .parseClaimsJws(token);
47 claims = claimsJws.getBody(); 56 claims = claimsJws.getBody();
48 } catch (Exception e) { 57 } catch (Exception e) {
49 - 58 +
50 return null; 59 return null;
51 } 60 }
52 - return (String)claims.get("userId"); 61 + return (String) claims.get("userId");
53 } 62 }
54 63
55 - /** 获取用户id*/  
56 - public static String getUserId(HttpServletRequest request){ 64 + /**
  65 + * 获取用户id
  66 + */
  67 + public static String getUserId(HttpServletRequest request) {
57 String token = request.getHeader("Authority"); 68 String token = request.getHeader("Authority");
58 Claims claims = null; 69 Claims claims = null;
59 try { 70 try {
@@ -64,10 +75,10 @@ public class JwtUtils { @@ -64,10 +75,10 @@ public class JwtUtils {
64 } catch (Exception e) { 75 } catch (Exception e) {
65 throw new RuntimeException("解析失败" + e.getMessage()); 76 throw new RuntimeException("解析失败" + e.getMessage());
66 } 77 }
67 - return (String)claims.get("userId"); 78 + return (String) claims.get("userId");
68 } 79 }
69 80
70 - public static String getUserName(String token){ 81 + public static String getUserName(String token) {
71 Claims claims = null; 82 Claims claims = null;
72 try { 83 try {
73 Jws<Claims> claimsJws = Jwts.parser() 84 Jws<Claims> claimsJws = Jwts.parser()
@@ -77,10 +88,10 @@ public class JwtUtils { @@ -77,10 +88,10 @@ public class JwtUtils {
77 } catch (Exception e) { 88 } catch (Exception e) {
78 throw new RuntimeException("token解析失败" + e.getMessage()); 89 throw new RuntimeException("token解析失败" + e.getMessage());
79 } 90 }
80 - return (String)claims.get("username"); 91 + return (String) claims.get("username");
81 } 92 }
82 93
83 - public static String getUserName(HttpServletRequest request){ 94 + public static String getUserName(HttpServletRequest request) {
84 String token = request.getHeader("Authority"); 95 String token = request.getHeader("Authority");
85 Claims claims = null; 96 Claims claims = null;
86 try { 97 try {
@@ -91,10 +102,10 @@ public class JwtUtils { @@ -91,10 +102,10 @@ public class JwtUtils {
91 } catch (Exception e) { 102 } catch (Exception e) {
92 throw new RuntimeException("token解析失败" + e.getMessage()); 103 throw new RuntimeException("token解析失败" + e.getMessage());
93 } 104 }
94 - return (String)claims.get("username"); 105 + return (String) claims.get("username");
95 } 106 }
96 107
97 - public String getUserIdByRequest(HttpServletRequest request){ 108 + public String getUserIdByRequest(HttpServletRequest request) {
98 String authorization = request.getHeader("Authorization"); 109 String authorization = request.getHeader("Authorization");
99 Claims claims = null; 110 Claims claims = null;
100 try { 111 try {
@@ -105,7 +116,7 @@ public class JwtUtils { @@ -105,7 +116,7 @@ public class JwtUtils {
105 } catch (Exception e) { 116 } catch (Exception e) {
106 throw new RuntimeException("token解析失败" + e.getMessage()); 117 throw new RuntimeException("token解析失败" + e.getMessage());
107 } 118 }
108 - return (String)claims.get("userId"); 119 + return (String) claims.get("userId");
109 } 120 }
110 121
111 // public static void main(String[] args) { 122 // public static void main(String[] args) {
trash-garbage/src/main/java/com/trash/garbage/utils/SMSUtils.java
@@ -7,6 +7,12 @@ import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; @@ -7,6 +7,12 @@ import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
7 import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; 7 import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
8 import com.aliyuncs.exceptions.ClientException; 8 import com.aliyuncs.exceptions.ClientException;
9 import com.aliyuncs.profile.DefaultProfile; 9 import com.aliyuncs.profile.DefaultProfile;
  10 +import com.trash.common.utils.util.PostSms;
  11 +import com.trash.common.utils.vo.mt.JsonSmsSend;
  12 +import com.trash.common.utils.vo.mt.Mobile;
  13 +
  14 +import java.util.ArrayList;
  15 +import java.util.List;
10 16
11 /** 17 /**
12 * 短信发送工具类 18 * 短信发送工具类
@@ -15,34 +21,18 @@ public class SMSUtils { @@ -15,34 +21,18 @@ public class SMSUtils {
15 21
16 /** 22 /**
17 * 发送短信 23 * 发送短信
18 - * @param signName 签名  
19 - * @param templateCode 模板  
20 - * @param phoneNumbers 手机号  
21 - * @param param 参数 24 + *
  25 + * @param tell 手机号
  26 + * @param content 模板
22 */ 27 */
23 - public static void sendMessage(String signName, String templateCode,String phoneNumbers,String param) throws ClientException {  
24 - DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI5tHRxs2FeCu5JcJTGbm2", "v0H4PaJpXSwNr6XChtlVYAgmQWgKRA");  
25 -  
26 - IAcsClient client = new DefaultAcsClient(profile);  
27 -  
28 - SendSmsRequest request = new SendSmsRequest();  
29 -  
30 - request.setSysRegionId("cn-hangzhou");  
31 -// 要发送给那个人的电话号码  
32 - request.setPhoneNumbers(phoneNumbers);  
33 -// 我们在阿里云设置的签名  
34 - request.setSignName(signName);  
35 -// 我们在阿里云设置的模板  
36 - request.setTemplateCode(templateCode);  
37 -// 在设置模板的时候有一个占位符  
38 - request.setTemplateParam("{\"code\":\""+param+"\"}");  
39 -  
40 -// request.setPhoneNumbers("1368846****");//接收短信的手机号码  
41 -// request.setSignName("阿里云");//短信签名名称  
42 -// request.setTemplateCode("SMS_20933****");//短信模板CODE  
43 -// request.setTemplateParam("张三");//短信模板变量对应的实际值  
44 -  
45 - SendSmsResponse response = client.getAcsResponse(request); 28 + public static void sendMessage(String tell, String content) {
  29 + //发送
  30 + Mobile mobile = new Mobile();
  31 + mobile.setMobile(tell);
  32 + List<Mobile> mobileList = new ArrayList<Mobile>();
  33 + mobileList.add(mobile);
  34 + //更新提交信息
  35 + JsonSmsSend jsonSmsSend = PostSms.sendSms(mobileList, content);
46 } 36 }
47 37
48 } 38 }
49 \ No newline at end of file 39 \ No newline at end of file