Commit 971dae05 by chamberone

Merge branch 'develop' of https://zhangguoping@gitlab.dituhui.com/bsh/project/pr…

…oject.git into develop
2 parents 010f7290 a0328826
...@@ -2,8 +2,7 @@ package com.alibaba.cloud.integration.order.controller; ...@@ -2,8 +2,7 @@ package com.alibaba.cloud.integration.order.controller;
import com.alibaba.cloud.integration.common.BusinessException; import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.OrderServiceListReq; import com.alibaba.cloud.integration.order.service.OrderServiceListService;
import com.alibaba.cloud.integration.order.service.OrderServiceList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -14,13 +13,23 @@ import org.springframework.web.bind.annotation.*; ...@@ -14,13 +13,23 @@ import org.springframework.web.bind.annotation.*;
public class OrderServiceListController { public class OrderServiceListController {
@Autowired @Autowired
private OrderServiceList orderServiceList; private OrderServiceListService orderServiceListService;
@GetMapping("/order/service/list") @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; Result<?> res = null;
try { try {
res = orderServiceList.GetOrderServiceList(req); res = orderServiceListService.GetOrderServiceList(startDate, endDate, page, size, sort, appointmentType,
appointmentStatus, type, brand, skill);
} }
catch (BusinessException e) { catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
......
package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface OrderReqeustDao extends JpaRepository <OrderRequestEntity, Long> {
}
...@@ -15,5 +15,5 @@ public class OrderCreateReqDTO { ...@@ -15,5 +15,5 @@ public class OrderCreateReqDTO {
private String expectEnd; private String expectEnd;
private String priority; private String priority;
private String orderTags; private String orderTags;
private String memo; private String description;
} }
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package com.alibaba.cloud.integration.order.entity; package com.alibaba.cloud.integration.order.entity;
import lombok.Data;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
...@@ -23,7 +25,8 @@ import javax.persistence.Id; ...@@ -23,7 +25,8 @@ import javax.persistence.Id;
import java.io.Serializable; import java.io.Serializable;
@Entity @Entity
public class OrderRequestEntity implements Serializable { @Data
public class OrderRequestEntity {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -4,8 +4,12 @@ import com.alibaba.cloud.integration.common.BusinessException; ...@@ -4,8 +4,12 @@ import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.OrderServiceListReq; import com.alibaba.cloud.integration.order.dto.OrderServiceListReq;
import com.alibaba.cloud.integration.order.dto.OrderServiceListResp; 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;
} }
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
package com.alibaba.cloud.integration.order.service.impl; package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.OrderReqeustDao;
import com.alibaba.cloud.integration.order.dto.LocationDTO;
import com.alibaba.cloud.integration.order.dto.OrderCreateReqDTO; import com.alibaba.cloud.integration.order.dto.OrderCreateReqDTO;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import com.alibaba.cloud.integration.order.feign.AccountServiceFeignClient; import com.alibaba.cloud.integration.order.feign.AccountServiceFeignClient;
import com.alibaba.cloud.integration.order.feign.StorageServiceFeignClient; import com.alibaba.cloud.integration.order.feign.StorageServiceFeignClient;
import com.alibaba.cloud.integration.order.mapper.OrderMapper; import com.alibaba.cloud.integration.order.mapper.OrderMapper;
...@@ -34,21 +37,36 @@ import org.springframework.stereotype.Service; ...@@ -34,21 +37,36 @@ import org.springframework.stereotype.Service;
public class OrderServiceImpl implements OrderService { public class OrderServiceImpl implements OrderService {
@Autowired @Autowired
private OrderMapper orderMapper; private OrderReqeustDao orderReqeustDao;
@Autowired
private AccountServiceFeignClient accountService;
@Autowired
private StorageServiceFeignClient storageService;
@Override @Override
@GlobalTransactional @GlobalTransactional
public Result<?> createOrder(OrderCreateReqDTO orderCreateReqDTO) { public Result<?> createOrder(OrderCreateReqDTO req) {
log.info("[createOrder] current XID: {}", RootContext.getXID()); log.info("[createOrder] current XID: {}", RootContext.getXID());
OrderRequestEntity entity = new OrderRequestEntity();
return null; entity.setName(req.getName());
entity.setPhone(req.getPhone());
entity.setAddress(req.getAddress());
entity.setBrand(req.getBrand());
entity.setCategoryId(req.getCatalogId());
entity.setFaultDescribe(req.getFaultDescribe());
entity.setExpectTimeBegin(req.getExpectBegin());
entity.setExpectTimeEnd(req.getExpectEnd());
entity.setDescription(req.getDescription());
// location
LocationDTO location = req.getLocation();
entity.setProvince(location.getProvince());
entity.setCity(location.getCity());
entity.setCounty(location.getCountry());
orderReqeustDao.save(entity);
// 根据orderTags, 解析保存到type、skill等字段
String[] l = req.getLocation().getLocation().split(",");
entity.setX(l[0]);
entity.setY(l[1]);
// todo 服务单状态、预约状态等
entity.setStatus("");
entity.setAppointmentStatus("");
return Result.success(null);
} }
} }
...@@ -5,11 +5,10 @@ import com.alibaba.cloud.integration.common.Result; ...@@ -5,11 +5,10 @@ import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.OrderAppointmentDao; import com.alibaba.cloud.integration.order.dao.OrderAppointmentDao;
import com.alibaba.cloud.integration.order.dao.OrderRequestDao; import com.alibaba.cloud.integration.order.dao.OrderRequestDao;
import com.alibaba.cloud.integration.order.dto.OrderServiceList; 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.dto.OrderServiceListResp;
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;
import com.alibaba.cloud.integration.order.service.OrderService; import com.alibaba.cloud.integration.order.service.OrderServiceListService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -23,7 +22,7 @@ import java.util.*; ...@@ -23,7 +22,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class OrderServiceListImpl implements com.alibaba.cloud.integration.order.service.OrderServiceList { public class OrderServiceListServiceImpl implements OrderServiceListService {
@Autowired @Autowired
private OrderRequestDao orderRequestDao; private OrderRequestDao orderRequestDao;
...@@ -31,38 +30,42 @@ public class OrderServiceListImpl implements com.alibaba.cloud.integration.order ...@@ -31,38 +30,42 @@ public class OrderServiceListImpl implements com.alibaba.cloud.integration.order
@Autowired @Autowired
private OrderAppointmentDao orderAppointmentDao; private OrderAppointmentDao orderAppointmentDao;
@Override
@Transactional @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<>(); LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.ge(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(req.getStartDate())); //预约开始日期 lqw.ge(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(startDate)); //预约开始日期
lqw.le(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(req.getEndDate())); //预约结束日期 lqw.le(OrderRequest::getExpectTimeBegin, this.GetTimestampFromDate(endDate)); //预约结束日期
lqw.eq(Strings.isNotEmpty(req.getAppointmentStatus()), OrderRequest::getStatusAppointment, req.getAppointmentStatus()); //指派状态 lqw.eq(Strings.isNotEmpty(appointmentStatus), OrderRequest::getStatusAppointment, appointmentStatus); //指派状态
lqw.eq(Strings.isNotEmpty(req.getType()), OrderRequest::getType, req.getType()); //设备类型 lqw.eq(Strings.isNotEmpty(type), OrderRequest::getType, type); //设备类型
lqw.eq(Strings.isNotEmpty(req.getBrand()), OrderRequest::getBrand, req.getBrand()); //品牌 lqw.eq(Strings.isNotEmpty(brand), OrderRequest::getBrand, brand); //品牌
lqw.eq(Strings.isNotEmpty(req.getSkill()), OrderRequest::getSkill, req.getSkill()); //技能 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<>(); List<String> orderIds = new ArrayList<>();
for(OrderRequest r: records) { for(OrderRequest r: records) {
orderIds.add(r.getOrderId()); orderIds.add(r.getOrderId());
} }
// 获取指派订单列表 // 获取工程师姓名列表
HashMap<String, List<OrderAppointment>> appointOrders = this.PackOrderAppointment(this.GetOrderAppointment(orderIds)); HashMap<String, List<String>> engineerNames = this.GetEngineerNames(this.GetOrderAppointment(orderIds));
List<OrderAppointment> appoint; List<String> names;
List<OrderServiceList> content = new ArrayList<>(); List<OrderServiceList> content = new ArrayList<>();
for (OrderRequest o: records) { for (OrderRequest o: records) {
OrderServiceList record = new OrderServiceList(); OrderServiceList record = new OrderServiceList();
appoint = appointOrders.getOrDefault(o.getOrderId(), List.of()); names = engineerNames.get(o.getOrderId());
record.setOrderId(o.getOrderId()); record.setOrderId(o.getOrderId());
record.setType(o.getType()); record.setType(o.getType());
record.setBrand(o.getBrand()); record.setBrand(o.getBrand());
...@@ -76,18 +79,18 @@ public class OrderServiceListImpl implements com.alibaba.cloud.integration.order ...@@ -76,18 +79,18 @@ public class OrderServiceListImpl implements com.alibaba.cloud.integration.order
record.setSource(o.getSource()); record.setSource(o.getSource());
record.setDescription(o.getDescription()); record.setDescription(o.getDescription());
record.setOrgBranchName(o.getOrgBranchName()); record.setOrgBranchName(o.getOrgBranchName());
record.setEngineerNum(this.getEngNum(appoint)); //工程师数量 record.setEngineerNum(this.getEngNum(names)); //工程师数量
record.setEngineerNames(this.getEngNames(appoint)); //工程师姓名列表 record.setEngineerNames(this.getEngNames(names)); //工程师姓名列表
content.add(record); content.add(record);
} }
// 组装 // 组装
OrderServiceListResp res = new OrderServiceListResp(); OrderServiceListResp res = new OrderServiceListResp();
res.setTotal(page.getTotal()); res.setTotal(pg.getTotal());
res.setPages(page.getPages()); res.setPages(pg.getPages());
res.setPageCurrent(page.getCurrent()); res.setPageCurrent(pg.getCurrent());
res.setPageSize(page.getSize()); res.setPageSize(pg.getSize());
res.setContent(content); res.setContent(content);
return Result.success(res); return Result.success(res);
...@@ -101,42 +104,36 @@ public class OrderServiceListImpl implements com.alibaba.cloud.integration.order ...@@ -101,42 +104,36 @@ public class OrderServiceListImpl implements com.alibaba.cloud.integration.order
return orderAppointmentDao.selectList(lqw); 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> byOrderIdDesc = Comparator.comparing(OrderAppointment::getOrderId, String.CASE_INSENSITIVE_ORDER).reversed();
Comparator<OrderAppointment> bySuborderIdDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed(); Comparator<OrderAppointment> bySuborderIdDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed();
Comparator<OrderAppointment> comp = byOrderIdDesc.thenComparing(bySuborderIdDesc); Comparator<OrderAppointment> comp = byOrderIdDesc.thenComparing(bySuborderIdDesc);
List<OrderAppointment> results = orders.stream().sorted(comp).collect(Collectors.toList()); 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; 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<>(); if (names == null) {
for (OrderAppointment o: orders) { return "";
names.add(o.getEngineerName());
} }
return String.join("、", names); 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!