Commit 53cbc50b by 刘鑫

fix: 特殊时间段容量

1 parent b71432b0
...@@ -83,13 +83,13 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ ...@@ -83,13 +83,13 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ
* @param teamId 工作队ID * @param teamId 工作队ID
* @return 工程师信息 * @return 工程师信息
*/ */
@Query(value = "SELECT * FROM org_team_engineer ote " + @Query(value = "SELECT ei.* FROM org_team_engineer ote " +
" LEFT JOIN " + " LEFT JOIN " +
" (SELECT esg.engineer_code AS engineer_code FROM engineer_skill_group esg " + " (SELECT esg.engineer_code AS engineer_code FROM engineer_skill_group esg " +
" WHERE esg.status = 1 AND esg.skill_group_code IN( :skillGroupCodes) group by esg.engineer_code having count(esg.skill_group_code) = :skillGroupNumber " + " WHERE esg.status = 1 AND esg.skill_group_code IN( :skillGroupCodes) group by esg.engineer_code having count(esg.skill_group_code) = :skillGroupNumber " +
" ) AS tabA ON tabA.engineer_code = ote.engineer_code " + " ) AS tabA ON tabA.engineer_code = ote.engineer_code " +
" LEFT JOIN engineer_info ei ON ei.engineer_code = tabA.engineer_code " + " LEFT JOIN engineer_info ei ON ei.engineer_code = tabA.engineer_code " +
" WHERE ote.team_id = :teamId " + " WHERE ote.team_id = :teamId AND ei.id is not null" +
" order by ei.engineer_code desc", nativeQuery = true) " order by ei.engineer_code desc", nativeQuery = true)
Set<EngineerInfoEntity> listBySkillGroupCode( @Param("skillGroupCodes")Collection<String> skillGroupCodes, @Param("skillGroupNumber")int skillGroupNumber, @Param("teamId")String teamId); Set<EngineerInfoEntity> listBySkillGroupCode( @Param("skillGroupCodes")Collection<String> skillGroupCodes, @Param("skillGroupNumber")int skillGroupNumber, @Param("teamId")String teamId);
......
...@@ -215,17 +215,30 @@ public class CapacityQueryServiceImpl implements CapacityQueryService { ...@@ -215,17 +215,30 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
List<TimeSliceEntity> twoHourTimeSlices = sliceTime(LocalDate.now(), sliceStartHour, sliceEndHour); List<TimeSliceEntity> twoHourTimeSlices = sliceTime(LocalDate.now(), sliceStartHour, sliceEndHour);
CopyOnWriteArrayList<TimeSliceEntity> timeSliceEntities = new CopyOnWriteArrayList<>(twoHourTimeSlices); CopyOnWriteArrayList<TimeSliceEntity> timeSliceEntities = new CopyOnWriteArrayList<>(twoHourTimeSlices);
//特殊时间段 //特殊时间段
TimeSliceEntity timeSlice20 = new TimeSliceEntity(); if (teamWorkEndTime.getHour() < 20) {
timeSlice20.setStart(DateTimeUtil.TIME_FORMAT.format(sliceEndHour)); TimeSliceEntity timeSlice20 = new TimeSliceEntity();
timeSlice20.setEnd(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(20, 0))); timeSlice20.setStart(DateTimeUtil.TIME_FORMAT.format(sliceEndHour));
timeSlice20.setName("时间段"); timeSlice20.setEnd(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(20, 0)));
timeSliceEntities.add(timeSlice20); timeSlice20.setName("时间段");
timeSliceEntities.add(timeSlice20);
TimeSliceEntity timeSlice24 = new TimeSliceEntity();
timeSlice24.setStart(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(20, 0))); }
timeSlice24.setEnd(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(23, 59, 59)));
timeSlice24.setName("时间段"); if (teamWorkEndTime.getHour() <= 20) {
timeSliceEntities.add(timeSlice24); TimeSliceEntity timeSlice24 = new TimeSliceEntity();
timeSlice24.setStart(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(20, 0)));
timeSlice24.setEnd(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(23, 59, 59)));
timeSlice24.setName("时间段");
timeSliceEntities.add(timeSlice24);
}
if (teamWorkEndTime.getHour() > 20) {
TimeSliceEntity timeSlice24 = new TimeSliceEntity();
timeSlice24.setStart(DateTimeUtil.TIME_FORMAT.format(sliceEndHour));
timeSlice24.setEnd(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(23, 59, 59)));
timeSlice24.setName("时间段");
timeSliceEntities.add(timeSlice24);
}
TimeSliceEntity timeSlice8 = new TimeSliceEntity(); TimeSliceEntity timeSlice8 = new TimeSliceEntity();
timeSlice8.setStart(DateTimeUtil.TIME_FORMAT.format(LocalTime.MIN)); timeSlice8.setStart(DateTimeUtil.TIME_FORMAT.format(LocalTime.MIN));
......
...@@ -24,10 +24,10 @@ import com.dituhui.pea.common.ResultEnum; ...@@ -24,10 +24,10 @@ import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.CapacityUtils; import com.dituhui.pea.order.common.CapacityUtils;
import com.dituhui.pea.order.common.DateUtils; import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.common.Distance;
import com.dituhui.pea.order.common.EngineerUtils; import com.dituhui.pea.order.common.EngineerUtils;
import com.dituhui.pea.order.common.OrderAssignCheck; import com.dituhui.pea.order.common.OrderAssignCheck;
import com.dituhui.pea.order.common.SaasUtils; import com.dituhui.pea.order.common.SaasUtils;
import com.dituhui.pea.order.common.Stapial4jUtil;
import com.dituhui.pea.order.dao.EngineerBusinessDao; import com.dituhui.pea.order.dao.EngineerBusinessDao;
import com.dituhui.pea.order.dao.EngineerInfoDao; import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.EngineerSkillDao; import com.dituhui.pea.order.dao.EngineerSkillDao;
...@@ -51,7 +51,10 @@ import com.dituhui.pea.order.entity.OrgBranchEntity; ...@@ -51,7 +51,10 @@ import com.dituhui.pea.order.entity.OrgBranchEntity;
import com.dituhui.pea.order.entity.OrgTeamEngineerEntity; import com.dituhui.pea.order.entity.OrgTeamEngineerEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity; import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity; import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.enums.*; import com.dituhui.pea.order.enums.AppointmentMethodEnum;
import com.dituhui.pea.order.enums.OrderEventEnum;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderPeaTagsEnum;
import com.dituhui.pea.order.service.CommonService; import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.FendanService; import com.dituhui.pea.order.service.FendanService;
import com.dituhui.pea.order.service.MsgService; import com.dituhui.pea.order.service.MsgService;
...@@ -61,7 +64,6 @@ import com.dituhui.pea.order.utils.CommonUtil; ...@@ -61,7 +64,6 @@ import com.dituhui.pea.order.utils.CommonUtil;
import com.dituhui.pea.pojo.saas.req.AdministrativeDistrictReq; import com.dituhui.pea.pojo.saas.req.AdministrativeDistrictReq;
import com.dituhui.pea.pojo.saas.resp.AdministrativeDistrictResp; import com.dituhui.pea.pojo.saas.resp.AdministrativeDistrictResp;
import com.dituhui.pea.util.DateUtil; import com.dituhui.pea.util.DateUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -183,13 +185,13 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -183,13 +185,13 @@ public class OrderCreateServiceImpl implements OrderCreateService {
} }
//获取计划上门时间 //获取计划上门时间
final LocalDateTime planStartTime = orderInfo.getPlanStartTime(); final LocalDateTime planStartTime = orderInfo.getPlanStartTime();
Date palnDate = com.dituhui.pea.order.common.jackson.DateUtil.toDate(planStartTime);
stageResult.setPlanVisitTime(palnDate);
if (Objects.isNull(planStartTime) || !LocalDate.now().equals(planStartTime.toLocalDate())) { if (Objects.isNull(planStartTime) || !LocalDate.now().equals(planStartTime.toLocalDate())) {
return stageResult; return stageResult;
} }
//如果计划时间为今天 则返回工程师位置信息 //如果计划时间为今天 则返回工程师位置信息
Date palnDate = com.dituhui.pea.order.common.jackson.DateUtil.toDate(planStartTime);
stageResult.setPlanVisitTime(palnDate);
Location location = engineerDateLocation(engineerCode); Location location = engineerDateLocation(engineerCode);
OrderDTO.RealtimeInfo realtimeInfo = new OrderDTO.RealtimeInfo(); OrderDTO.RealtimeInfo realtimeInfo = new OrderDTO.RealtimeInfo();
...@@ -197,10 +199,10 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -197,10 +199,10 @@ public class OrderCreateServiceImpl implements OrderCreateService {
OrderDTO.Estimate estimate = new OrderDTO.Estimate(); OrderDTO.Estimate estimate = new OrderDTO.Estimate();
// 计算两点间距离 // 计算两点间距离
Pair distanceAndDuration = getDistanceAndDuration(location.getLatitude(), location.getLongitude(), double distance = Stapial4jUtil.getDistance(location.getLatitude(), location.getLongitude(),
Double.parseDouble(orderInfo.getX()), Double.parseDouble(orderInfo.getY())); Double.parseDouble(orderInfo.getX()), Double.parseDouble(orderInfo.getY()));
estimate.setDistance((double) distanceAndDuration.getDistance()); estimate.setDistance(distance);
estimate.setArriveTime(palnDate); estimate.setArriveTime(palnDate);
realtimeInfo.setEstimate(estimate); realtimeInfo.setEstimate(estimate);
stageResult.setRealtimeInfo(realtimeInfo); stageResult.setRealtimeInfo(realtimeInfo);
...@@ -208,24 +210,6 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -208,24 +210,6 @@ public class OrderCreateServiceImpl implements OrderCreateService {
return stageResult; return stageResult;
} }
private Pair getDistanceAndDuration(double x1, double y1, double x2, double y2) {
Distance cal = new Distance();
long distance = Math.round(cal.calculateDistance(x1, y1, x2, y2) * 1.4); // 单位为米
long duration = distance / (19 * 1000 / 60); // 时间为分钟,假设电动车速度为19km/h
return new Pair((int) distance, (int) duration);
}
@Data
class Pair {
private int distance;
private int duration;
public Pair(int distance, int duration) {
this.distance = distance;
this.duration = duration;
}
}
private Location engineerDateLocation(String engineerCode) { private Location engineerDateLocation(String engineerCode) {
final LocalDate currentDate = LocalDate.now(); final LocalDate currentDate = LocalDate.now();
List<OrderInfoEntity> engineerDateOrderList = orderInfoDao.getEngineerDateOrder(engineerCode, DateUtils.formatDate(currentDate)); List<OrderInfoEntity> engineerDateOrderList = orderInfoDao.getEngineerDateOrder(engineerCode, DateUtils.formatDate(currentDate));
...@@ -262,8 +246,8 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -262,8 +246,8 @@ public class OrderCreateServiceImpl implements OrderCreateService {
// 如果都没有, 则获取工程师出发地址 // 如果都没有, 则获取工程师出发地址
EngineerBusinessEntity byEngineerCode = engineerBusinessDao.getByEngineerCode(engineerCode); EngineerBusinessEntity byEngineerCode = engineerBusinessDao.getByEngineerCode(engineerCode);
location.setAddress(byEngineerCode.getAddress()); location.setAddress(byEngineerCode.getAddress());
location.setLongitude(Double.parseDouble(byEngineerCode.getX())); location.setLongitude(StringUtils.isNotBlank(byEngineerCode.getX()) ? Double.parseDouble(byEngineerCode.getX()) : 0.0);
location.setLatitude(Double.parseDouble(byEngineerCode.getY())); location.setLatitude(StringUtils.isNotBlank(byEngineerCode.getY()) ? Double.parseDouble(byEngineerCode.getY()) : 0.0);
} }
return location; return location;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!