提交 8be70f65 作者: chaining

feat: 增加剩余时间和是否超时信息

父级 266729b1
...@@ -36,10 +36,9 @@ import javax.servlet.http.HttpServletResponse; ...@@ -36,10 +36,9 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.time.ZoneId;
import java.util.HashMap; import java.time.temporal.ChronoUnit;
import java.util.List; import java.util.*;
import java.util.Map;
/** /**
* <p> * <p>
...@@ -78,24 +77,27 @@ public class WallboxApplyController { ...@@ -78,24 +77,27 @@ public class WallboxApplyController {
} }
Integer status = order.getStatus(); Integer status = order.getStatus();
// 检查订单状态是否在0-43之间 // 检查订单状态是否在0-43之间
if (status >= OrderStatus.DISPATCHING.getType() && status <= OrderStatus.INSTALLING.getType()) { boolean allowed = status >= OrderStatus.DISPATCHING.getType() && status <= OrderStatus.INSTALLING.getType();
SessionInfo loginUser = tokenService.getUser(); // if (!allowed) {
String userId = loginUser.getUserId(); // throw new ServiceException("订单已在安装中,无法申请");
SupplierStaff infoByAccount = supplierStaffService.getByAccountId(Integer.valueOf(userId)); // }
Supplier supplier = supplierService.getById(infoByAccount.getSupplierId());
if (supplier == null) { SessionInfo loginUser = tokenService.getUser();
throw new ServiceException("供应商不存在"); String userId = loginUser.getUserId();
} // SupplierStaff infoByAccount = supplierStaffService.getByAccountId(Integer.valueOf(userId));
WallboxApply wa = new WallboxApply(); // Supplier supplier = supplierService.getById(infoByAccount.getSupplierId());
wa.setSupplierId(Long.valueOf(supplier.getId())); // if (supplier == null) {
wa.setSupplierTeam(supplier.getName()); // throw new ServiceException("供应商不存在");
wa.setOrderId(orderId); // }
wa.setIfEmergency(ifEmergency); WallboxApply wa = new WallboxApply();
wa.setCreateAccount(tokenService.getUser().getUserId()); wa.setSupplierId(2L);
wallboxApplyService.insertWallboxApply(wa); wa.setSupplierTeam("服务商-万帮云安装");
return new BaseResponse<>(true); wa.setOrderId(orderId);
} wa.setIfEmergency(ifEmergency);
throw new ServiceException("订单已在安装中,无法申请"); wa.setCreateAccount(tokenService.getUser().getUserId());
wallboxApplyService.insertWallboxApply(wa);
return new BaseResponse<>(true);
} }
/** /**
...@@ -109,6 +111,21 @@ public class WallboxApplyController { ...@@ -109,6 +111,21 @@ public class WallboxApplyController {
public BaseResponse<List<WallboxApplyInstallListVO>> list(WallboxApplyReqVO req) { public BaseResponse<List<WallboxApplyInstallListVO>> list(WallboxApplyReqVO req) {
List<WallboxApplyInstallListVO> list = List<WallboxApplyInstallListVO> list =
wallboxApplyService.selectWallboxApplyListFromOrder(WallboxApplyConvert.INSTANCE.convert(req)); wallboxApplyService.selectWallboxApplyListFromOrder(WallboxApplyConvert.INSTANCE.convert(req));
LocalDateTime currentTime = LocalDateTime.now();
for (WallboxApplyInstallListVO apply : list) {
Date createdDate = apply.getCreatedTime();
LocalDateTime createdTime = LocalDateTime.ofInstant(createdDate.toInstant(), ZoneId.systemDefault());
LocalDateTime endTime = createdTime.plusHours(24);
long remainingHours = currentTime.until(endTime, ChronoUnit.HOURS);
remainingHours = Math.max(remainingHours, 0); // 将剩余小时数限制在0-24之间
if (remainingHours == 0) {
apply.setIfTimeout(1L);
} else {
apply.setIfTimeout(0L);
}
apply.setTimeRemaining(Long.toString(remainingHours));
}
return new BaseResponse<>(list); return new BaseResponse<>(list);
} }
...@@ -184,7 +201,7 @@ public class WallboxApplyController { ...@@ -184,7 +201,7 @@ public class WallboxApplyController {
@ApiOperation(value = "批量新增") @ApiOperation(value = "批量新增")
@PostMapping @PostMapping
public BaseResponse<Object> add(@RequestBody List<WallboxApply> tWallboxApply) { public BaseResponse<Object> add(@RequestBody List<WallboxApply> tWallboxApply) {
tWallboxApply.forEach(t->{ tWallboxApply.forEach(t -> {
wallboxApplyService.insertWallboxApply(t); wallboxApplyService.insertWallboxApply(t);
}); });
return new BaseResponse<>(); return new BaseResponse<>();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论