Commit b594780d by wangli

修改

1 parent b9826003
...@@ -5,6 +5,7 @@ import com.alibaba.cloud.integration.common.Result; ...@@ -5,6 +5,7 @@ import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.EngineerInfoMPDao; import com.alibaba.cloud.integration.order.dao.EngineerInfoMPDao;
import com.alibaba.cloud.integration.order.dao.OrderAppointmentMPDao; import com.alibaba.cloud.integration.order.dao.OrderAppointmentMPDao;
import com.alibaba.cloud.integration.order.dao.OrderRequestMPDao; import com.alibaba.cloud.integration.order.dao.OrderRequestMPDao;
import com.alibaba.cloud.integration.order.dto.OrderAssignRecommendResp;
import com.alibaba.cloud.integration.order.entity.EngineerInfo; import com.alibaba.cloud.integration.order.entity.EngineerInfo;
import com.alibaba.cloud.integration.order.entity.OrderAppointment; import com.alibaba.cloud.integration.order.entity.OrderAppointment;
import com.alibaba.cloud.integration.order.entity.OrderRequest; import com.alibaba.cloud.integration.order.entity.OrderRequest;
...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
...@@ -38,7 +40,50 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -38,7 +40,50 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) { public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) {
// 服务单指派-推荐技术员列表 // 服务单指派-推荐技术员列表
return null; OrderRequest order = this.queryOrderRequest(orderId);
if (order == null) {
throw new BusinessException("订单不存在");
}
String date = this.Timestamp2Datetime(order.getExpectTimeBegin(), "yyyy-MM-dd");
// 获取group内的小组成员
List<EngineerInfo> engineers = this.queryEngineerInfoByGroupId(order.getOrgGroupId());
List<OrderAssignRecommendResp.Engineer> items = new ArrayList<>();
OrderRecommend or = new OrderRecommend();
for (EngineerInfo engineer : engineers) {
List<OrderAppointment> orderAppointments = this.queryOrderAppointments(engineer.getEngineerCode(), date);
RecommendResult rr = or.recommend(order, orderAppointments);
if (rr.getIndex() == -1) {
continue;
}
OrderAssignRecommendResp.Engineer item = new OrderAssignRecommendResp.Engineer();
OrderAssignRecommendResp.InsertInfo insertInfo = new OrderAssignRecommendResp.InsertInfo();
insertInfo.setNumber(String.format("%d/%d", rr.index+1, orderAppointments.size() + 1));
insertInfo.setTimeDesc("+30分钟");
insertInfo.setTimeDesc("+4公里");
item.setEngineerCode(engineer.getEngineerCode());
item.setEngineerName(engineer.getName());
item.setLocation("");
item.setInsertInfo(insertInfo);
item.setDistanceDesc("15.5公里");
item.setTimeDesc("520分钟");
item.setDesc(String.format("将被插入在第%d单,受此影响原第%d单变化第%d单,第3单将增加5公里路程,比预计晚到30分钟,建议调整;", rr.index+1, rr.index + 1, rr.index + 2));
item.setStartTime("");
item.setStartTime("");
item.setTimelines(this.packTimelines(orderAppointments));
items.add(item);
}
OrderAssignRecommendResp res = new OrderAssignRecommendResp();
res.setEngineers(items);
return Result.success(res);
} }
@Transactional @Transactional
...@@ -52,7 +97,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -52,7 +97,7 @@ public class OrderAssignImpl implements OrderAssign {
EngineerInfo engineer = this.queryEngineerInfo(engineerCode); EngineerInfo engineer = this.queryEngineerInfo(engineerCode);
String date = ""; String date = this.Timestamp2Datetime(order.getExpectTimeBegin(), "yyyy-MM-dd");
List<OrderAppointment> orderAppointments = this.queryOrderAppointments(engineerCode, date); List<OrderAppointment> orderAppointments = this.queryOrderAppointments(engineerCode, date);
OrderRecommend recommend = new OrderRecommend(); OrderRecommend recommend = new OrderRecommend();
...@@ -107,6 +152,30 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -107,6 +152,30 @@ public class OrderAssignImpl implements OrderAssign {
lqw.eq(EngineerInfo::getEngineerCode, engineerCode); lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
return engineerInfoMPDao.selectOne(lqw); return engineerInfoMPDao.selectOne(lqw);
} }
private List<EngineerInfo> queryEngineerInfoByGroupId(String groupId) {
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(EngineerInfo::getGroupId, groupId);
return engineerInfoMPDao.selectList(lqw);
}
private List<OrderAssignRecommendResp.Timeline> packTimelines(List<OrderAppointment> orders) {
List<OrderAssignRecommendResp.Timeline> items = new ArrayList<>();
for(OrderAppointment order: orders){
OrderAssignRecommendResp.Timeline item = new OrderAssignRecommendResp.Timeline();
item.setStartTime("");
item.setEndTime("");
item.setType("");
items.add(item);
}
return items;
}
private String Timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
} }
@Data @Data
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!