Commit 7c817036 by 王力

Merge branch 'feature_OrderServiceList_wangl' into 'develop'

Feature order service list wangl

See merge request !9
2 parents fc1e436a f44d7e8f
......@@ -16,7 +16,7 @@ public class OrderServiceListController {
private OrderServiceListService orderServiceListService;
@GetMapping("/order/service/list")
public Result<?> GetOrderServiceList(@RequestParam("startDate") String startDate,
public Result<?> getOrderServiceList(@RequestParam("startDate") String startDate,
@RequestParam("endDate") String endDate,
@RequestParam("page") long page,
@RequestParam("size") long size,
......@@ -28,7 +28,7 @@ public class OrderServiceListController {
@RequestParam("skill") String skill) {
Result<?> res = null;
try {
res = orderServiceListService.GetOrderServiceList(startDate, endDate, page, size, sort, appointmentType,
res = orderServiceListService.getOrderServiceList(startDate, endDate, page, size, sort, appointmentType,
appointmentStatus, type, brand, skill);
}
catch (BusinessException e) {
......
......@@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam;
public interface OrderServiceListService {
Result<OrderServiceListResp> GetOrderServiceList(
Result<OrderServiceListResp> getOrderServiceList(
String startDate, String endDate, long page, long size, String sort,
String appointmentType, String appointmentStatus, String type, String brand,
String skill) throws BusinessException;
......
package com.alibaba.cloud.integration.order.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.OrderAppointmentDao;
import com.alibaba.cloud.integration.order.dao.OrderRequestDao;
import com.alibaba.cloud.integration.order.dto.OrderServiceList;
import com.alibaba.cloud.integration.order.dto.OrderServiceListResp;
import com.alibaba.cloud.integration.order.entity.Order;
import com.alibaba.cloud.integration.order.entity.OrderAppointment;
import com.alibaba.cloud.integration.order.entity.OrderRequest;
import com.alibaba.cloud.integration.order.entity.OrderTimeline;
import com.alibaba.cloud.integration.order.service.OrderServiceListService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.antlr.v4.runtime.atn.SemanticContext;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -32,7 +36,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
@Transactional
@Override
public Result<OrderServiceListResp> GetOrderServiceList(
public Result<OrderServiceListResp> getOrderServiceList(
String startDate, String endDate, long page, long size, String sort,
String appointmentType, String appointmentStatus, String type, String brand,
String skill) throws BusinessException {
......@@ -41,8 +45,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
IPage<OrderRequest> pg = new Page(page, size);
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.ge(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(startDate)); //预约开始日期
lqw.le(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(endDate)); //预约结束日期
lqw.ge(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(startDate)); //预约开始日期
lqw.le(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(endDate)); //预约结束日期
lqw.eq(Strings.isNotEmpty(appointmentStatus), OrderRequest::getAppointmentStatus, appointmentStatus); //指派状态
lqw.eq(Strings.isNotEmpty(type), OrderRequest::getType, type); //设备类型
lqw.eq(Strings.isNotEmpty(brand), OrderRequest::getBrand, brand); //品牌
......@@ -59,7 +63,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
orderIds.add(r.getOrderId());
}
// 获取工程师姓名列表
HashMap<String, List<String>> engineerNames = this.GetEngineerNames(this.GetOrderAppointment(orderIds));
HashMap<String, List<String>> engineerNames = this.getEngineerNames(this.getOrderAppointments(orderIds));
List<String> names;
List<OrderServiceList> content = new ArrayList<>();
......@@ -97,21 +101,34 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
}
public List<OrderAppointment> GetOrderAppointment(List<String> orderIds) {
public List<OrderAppointment> getOrderAppointments(List<String> orderIds) {
// 获取指派单列表
if(CollectionUtil.isEmpty(orderIds)) {
return new ArrayList<OrderAppointment>();
}
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderAppointment::getOrderId, orderIds);
return orderAppointmentDao.selectList(lqw);
}
public HashMap<String, List<String>> GetEngineerNames(List<OrderAppointment> orders){
return null;
public HashMap<String, List<String>> getEngineerNames(List<OrderAppointment> orders){
// 获取orderId最新订单对应的工程师姓名列表
HashMap<String, List<String>> enginnerNames = new HashMap<>();
Map<String, List<OrderAppointment>> g =this.groupOrderAppointments(orders);
for(String orderId: g.keySet()) {
List<String> names = new ArrayList<>();
for(OrderAppointment o: g.get(orderId)) {
names.add(o.getEngineerName());
}
enginnerNames.put(orderId, names);
}
return enginnerNames;
}
public HashMap<String, List<String>> GetOrderAppointments(List<OrderAppointment> orders){
// 获取指派单工人姓名
HashMap<String, List<String>> map = new HashMap<>();
public Map<String, List<OrderAppointment>> groupOrderAppointments(List<OrderAppointment> orders){
// 获取orderId对应的最新的subOrderId的订单列表
// 根据orderId+subOrderId降序排序
Comparator<OrderAppointment> byOrderIdDesc = Comparator.comparing(OrderAppointment::getOrderId, String.CASE_INSENSITIVE_ORDER).reversed();
......@@ -119,7 +136,22 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
Comparator<OrderAppointment> comp = byOrderIdDesc.thenComparing(bySuborderIdDesc);
List<OrderAppointment> results = orders.stream().sorted(comp).collect(Collectors.toList());
return map;
//获取orderId对应的最新的subOrderId的订单列表
String orderId = "";
String subOrderId = "";
List<OrderAppointment> items = new ArrayList<>();
for (OrderAppointment o: results) {
if (orderId != o.getOrderId()) {
orderId = o.getOrderId();
subOrderId = o.getSuborderId();
items.add(o);
continue;
}
if (subOrderId == o.getSuborderId()) {
items.add(o);
}
}
return items.stream().collect(Collectors.groupingBy(OrderAppointment::getOrderId));
}
private Integer getEngNum(List<String> names){
......@@ -138,7 +170,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return String.join("、", names);
}
public Timestamp GetTimestampFromDate(String date){
public Timestamp getTimestampFromDate(String date){
return Timestamp.valueOf(date + " 00:00:00");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!