Commit 579ef460 by wangli

重命名

1 parent 6e51ec8f
......@@ -2,8 +2,7 @@ package com.alibaba.cloud.integration.order.controller;
import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.OrderServiceListReq;
import com.alibaba.cloud.integration.order.service.OrderServiceList;
import com.alibaba.cloud.integration.order.service.OrderServiceListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -14,13 +13,23 @@ import org.springframework.web.bind.annotation.*;
public class OrderServiceListController {
@Autowired
private OrderServiceList orderServiceList;
private OrderServiceListService orderServiceListService;
@GetMapping("/order/service/list")
public Result<?> GetOrderServiceList(@RequestParam OrderServiceListReq req) {
public Result<?> GetOrderServiceList(@RequestParam("startDate") String startDate,
@RequestParam("endDate") String endDate,
@RequestParam("page") long page,
@RequestParam("size") long size,
@RequestParam("sort") String sort,
@RequestParam("appointmentType") String appointmentType,
@RequestParam("appointmentStatus") String appointmentStatus,
@RequestParam("type") String type,
@RequestParam("brand") String brand,
@RequestParam("skill") String skill) {
Result<?> res = null;
try {
res = orderServiceList.GetOrderServiceList(req);
res = orderServiceListService.GetOrderServiceList(startDate, endDate, page, size, sort, appointmentType,
appointmentStatus, type, brand, skill);
}
catch (BusinessException e) {
return Result.failed(e.getMessage());
......
......@@ -4,8 +4,12 @@ import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.OrderServiceListReq;
import com.alibaba.cloud.integration.order.dto.OrderServiceListResp;
import org.springframework.web.bind.annotation.RequestParam;
public interface OrderServiceList {
public interface OrderServiceListService {
Result<OrderServiceListResp> GetOrderServiceList(OrderServiceListReq req) throws BusinessException;
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;
}
......@@ -5,10 +5,10 @@ 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.OrderServiceListReq;
import com.alibaba.cloud.integration.order.dto.OrderServiceListResp;
import com.alibaba.cloud.integration.order.entity.OrderAppointment;
import com.alibaba.cloud.integration.order.entity.OrderRequest;
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;
......@@ -22,7 +22,7 @@ import java.util.*;
import java.util.stream.Collectors;
@Service
public class OrderServiceListImpl {
public class OrderServiceListServiceImpl implements OrderServiceListService {
@Autowired
private OrderRequestDao orderRequestDao;
......@@ -30,38 +30,42 @@ public class OrderServiceListImpl {
@Autowired
private OrderAppointmentDao orderAppointmentDao;
@Transactional
public Result<OrderServiceListResp> GetOrderServiceList(OrderServiceListReq req) throws BusinessException {
@Override
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 {
//分页
IPage<OrderRequest> page = new Page(req.getPage(), req.getSize());
IPage<OrderRequest> pg = new Page(page, size);
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.ge(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(req.getStartDate())); //预约开始日期
lqw.le(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(req.getEndDate())); //预约结束日期
lqw.eq(Strings.isNotEmpty(req.getAppointmentStatus()), OrderRequest::getStatusAppointment, req.getAppointmentStatus()); //指派状态
lqw.eq(Strings.isNotEmpty(req.getType()), OrderRequest::getType, req.getType()); //设备类型
lqw.eq(Strings.isNotEmpty(req.getBrand()), OrderRequest::getBrand, req.getBrand()); //品牌
lqw.eq(Strings.isNotEmpty(req.getSkill()), OrderRequest::getSkill, req.getSkill()); //技能
lqw.ge(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(startDate)); //预约开始日期
lqw.le(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(endDate)); //预约结束日期
lqw.eq(Strings.isNotEmpty(appointmentStatus), OrderRequest::getStatusAppointment, appointmentStatus); //指派状态
lqw.eq(Strings.isNotEmpty(type), OrderRequest::getType, type); //设备类型
lqw.eq(Strings.isNotEmpty(brand), OrderRequest::getBrand, brand); //品牌
lqw.eq(Strings.isNotEmpty(skill), OrderRequest::getSkill, skill); //技能
// 查询工单表列表
orderRequestDao.selectPage(page, lqw);
orderRequestDao.selectPage(pg, lqw);
List<OrderRequest> records = page.getRecords();
List<OrderRequest> records = pg.getRecords();
//获取工单订单号列表
List<String> orderIds = new ArrayList<>();
for(OrderRequest r: records) {
orderIds.add(r.getOrderId());
}
// 获取指派订单列表
HashMap<String, List<OrderAppointment>> appointOrders = this.PackOrderAppointment(this.GetOrderAppointment(orderIds));
List<OrderAppointment> appoint;
// 获取工程师姓名列表
HashMap<String, List<String>> engineerNames = this.GetEngineerNames(this.GetOrderAppointment(orderIds));
List<String> names;
List<OrderServiceList> content = new ArrayList<>();
for (OrderRequest o: records) {
OrderServiceList record = new OrderServiceList();
appoint = appointOrders.getOrDefault(o.getOrderId(), List.of());
names = engineerNames.get(o.getOrderId());
record.setOrderId(o.getOrderId());
record.setType(o.getType());
record.setBrand(o.getBrand());
......@@ -75,18 +79,18 @@ public class OrderServiceListImpl {
record.setSource(o.getSource());
record.setDescription(o.getDescription());
record.setOrgBranchName(o.getOrgBranchName());
record.setEngineerNum(this.getEngNum(appoint)); //工程师数量
record.setEngineerNames(this.getEngNames(appoint)); //工程师姓名列表
record.setEngineerNum(this.getEngNum(names)); //工程师数量
record.setEngineerNames(this.getEngNames(names)); //工程师姓名列表
content.add(record);
}
// 组装
OrderServiceListResp res = new OrderServiceListResp();
res.setTotal(page.getTotal());
res.setPages(page.getPages());
res.setPageCurrent(page.getCurrent());
res.setPageSize(page.getSize());
res.setTotal(pg.getTotal());
res.setPages(pg.getPages());
res.setPageCurrent(pg.getCurrent());
res.setPageSize(pg.getSize());
res.setContent(content);
return Result.success(res);
......@@ -100,42 +104,36 @@ public class OrderServiceListImpl {
return orderAppointmentDao.selectList(lqw);
}
public HashMap<String, List<OrderAppointment>> PackOrderAppointment(List<OrderAppointment> orders){
HashMap<String, List<OrderAppointment>> map = new HashMap<>();
// 根据订单ID-子订单降序排序
public HashMap<String, List<String>> GetEngineerNames(List<OrderAppointment> orders){
return null;
}
public HashMap<String, List<String>> GetOrderAppointments(List<OrderAppointment> orders){
// 获取指派单工人姓名
HashMap<String, List<String>> map = new HashMap<>();
// 根据orderId+subOrderId降序排序
Comparator<OrderAppointment> byOrderIdDesc = Comparator.comparing(OrderAppointment::getOrderId, String.CASE_INSENSITIVE_ORDER).reversed();
Comparator<OrderAppointment> bySuborderIdDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed();
Comparator<OrderAppointment> comp = byOrderIdDesc.thenComparing(bySuborderIdDesc);
List<OrderAppointment> results = orders.stream().sorted(comp).collect(Collectors.toList());
Set<String> set = new HashSet<>();
for(OrderAppointment o: results){
set.add(o.getOrderId());
}
for (String s: set){
map.put(s, new ArrayList<OrderAppointment>());
}
// 根据订单ID-子订单分组, 只取一组子订单分组
String flagOrderId = "";
String flagSuborderId = "";
for (OrderAppointment o: results) {
}
// TODO
return map;
}
private Integer getEngNum(List<OrderAppointment> orders){
private Integer getEngNum(List<String> names){
/*获取工程师数量*/
return orders.size();
if(names == null) {
return 0;
}
return names.size();
}
private String getEngNames(List<OrderAppointment> orders) {
private String getEngNames(List<String> names) {
/*获取工程师姓名列表*/
List<String> names = new ArrayList<>();
for (OrderAppointment o: orders) {
names.add(o.getEngineerName());
if (names == null) {
return "";
}
return String.join("、", names);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!