Commit c3611a0f by Ren Ping

fix:自动排班结束时间也需要在时间窗内

1 parent b2ab54aa
......@@ -3,7 +3,7 @@ server:
dispatch:
cron:
expr: 0 35 8-23 * * ?
expr: 0 20 8-23 * * ?
next-day-limit: 2
scheduler:
......
......@@ -16,6 +16,7 @@ import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.VehicleEnum;
import com.dituhui.pea.order.service.ScheduleService;
import com.dituhui.pea.order.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
......@@ -149,7 +150,7 @@ public class ScheduleServiceImpl implements ScheduleService {
child.setOrderDesc(Integer.toString(orders2.size()));
Integer distanceSum = orders2.stream().map(order -> Objects.nonNull(order.getArriveDistance()) ? order.getArriveDistance() : 0).reduce(Integer::sum).orElse(0);
teamDistance += distanceSum;
child.setDistanceDesc(distanceSum/1000.0 + "");
child.setDistanceDesc(CommonUtil.converMToKm(distanceSum));
children.add(child);
......@@ -189,8 +190,8 @@ public class ScheduleServiceImpl implements ScheduleService {
teamEngineers.size() > 0 ? new BigDecimal(teamDistance)
.divide(new BigDecimal(teamEngineers.size()), 2, RoundingMode.HALF_UP)
.stripTrailingZeros() : 0,
minDistance/1000.0,
maxDistance/1000.0));
CommonUtil.converMToKm(minDistance),
CommonUtil.converMToKm(maxDistance)));
teams.add(team);
}
......@@ -267,7 +268,7 @@ public class ScheduleServiceImpl implements ScheduleService {
.divide(new BigDecimal(60), 2, RoundingMode.HALF_UP)
.stripTrailingZeros()
+ "时");
dynamics.setRoadTotalDistance(sumDistance / 1000.0 + "公里");
dynamics.setRoadTotalDistance(CommonUtil.converMToKm(sumDistance) + "公里");
if (Objects.nonNull(engineerBusinessEntity)) {
dynamics.setWorkTime(engineerBusinessEntity.getWorkOn() + "-" + engineerBusinessEntity.getWorkOff());
} else {
......@@ -289,7 +290,7 @@ public class ScheduleServiceImpl implements ScheduleService {
item.setSkill(o.getSkill());
item.setOrderStatus(o.getAppointmentStatus());
item.setOrderStatusName("");
item.setDistance(Objects.nonNull(o.getArriveDistance()) ? o.getArriveDistance() / 1000.0 + "" : null);
item.setDistance(CommonUtil.converMToKm(o.getArriveDistance()));
item.setTimeType("auto");
if (Objects.nonNull(o.getArriveElapsed())) {
......
......@@ -5,6 +5,7 @@ import com.dituhui.pea.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
......@@ -112,6 +113,13 @@ public class CommonUtil {
}
}
public static String converMToKm(Integer m) {
if (Objects.isNull(m)) {
return null;
}
return BigDecimal.valueOf(m / 1000.0).stripTrailingZeros().toString();
}
public static void main(String[] args) {
isCutoff(LocalDateTime.now(), "18:00");
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!