Commit 02558695 by chamberone

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

…oject.git into develop
2 parents 7ad7074c 942ae4d6
......@@ -16,7 +16,7 @@ public class EngineerTimelineController {
@Autowired
private EngineerTimelineService engineerTimelineService;
@GetMapping("/engineer/work/trace")
@GetMapping("/engineer/work/dynamics")
public Result<?> GetEngineerTimeline(@RequestParam String engineerCode, String date) {
return engineerTimelineService.getEngineerTimelines(engineerCode, date);
}
......
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.WarehouseInfo;
import com.dituhui.pea.order.entity.OrgWarehouseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WarehouseInfoMPDao extends BaseMapper<WarehouseInfo> {
public interface WarehouseInfoMPDao extends BaseMapper<OrgWarehouseInfo> {
}
......@@ -3,7 +3,7 @@ package com.dituhui.pea.order.dto;
import lombok.Data;
@Data
public class EnginnerTimelineReq {
private String enginnerCode;
public class EngineerTimelineReq {
private String engineerCode;
private String date;
}
......@@ -5,7 +5,7 @@ import lombok.Data;
import java.util.List;
@Data
public class EnginnerTimelineResp {
public class EngineerTimelineResp {
private String engineerCode;
private String engineerName;
......
......@@ -3,9 +3,10 @@ package com.dituhui.pea.order.entity;
import lombok.Data;
@Data
public class WarehouseInfo {
private Integer warehouseId;
private String warehouseNname;
public class OrgWarehouseInfo {
private long id;
private String warehouseId;
private String warehouseName;
private String branchId;
private String cityCode;
private String address;
......
......@@ -3,7 +3,7 @@ package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.EnginnerTimelineResp;
import com.dituhui.pea.order.dto.EngineerTimelineResp;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.EngineerTimelineService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -11,8 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -39,67 +38,54 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
@Autowired
private OrgGroupMPDao orgGroupMPDao;
@Autowired
private OrderEventMPDao orderEventMPDao;
@Transactional
@Override
public Result<?> getEngineerTimelines(String engineerCode, String date){
// 工程师姓名
String name = this.getEngineerName(engineerCode);
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
// 工程師信息
EngineerInfo engineerInfo = engineerInfoMPDao.getByEngineerCode(engineerCode);
// 获取工程师已完成的timeline数据
List<EngineerTimeline> timelines = this.engineerTimelines(engineerCode, date);
// 获取工程师date日的订单数据
List<OrderAppointment> orders = this.orderAppointments(engineerCode, date);
List<OrderAppointment> orders = orderAppointmentMPDao.selectByEngineerCodeAndDt(engineerCode, localDate);
// 获取工程师已完成的timeline数据
List<String> orderIds = orders.stream().map(OrderAppointment::getOrderId).collect(Collectors.toList());
List<OrderEvent> timelines = this.engineerTimelines(orderIds, date);
// 获取客户地址
List<String> orderIds = new ArrayList<>();
for(OrderAppointment o: orders) {
orderIds.add(o.getOrderId());
}
HashMap<String, String> orderLocations = this.orderRequestsLocation(orderIds);
// 获取配送站地址
String branchId = this.getEngineerBranchId(engineerCode);
String warehouseLocation = this.getWarehouseLocation(branchId);
List<EnginnerTimelineResp.DynamicItem> dynamics = this.packItems(timelines, orders, orderLocations, warehouseLocation);
List<EngineerTimelineResp.DynamicItem> dynamics = this.packItems(timelines, orders, orderLocations, warehouseLocation);
EnginnerTimelineResp res = new EnginnerTimelineResp();
EngineerTimelineResp res = new EngineerTimelineResp();
res.setEngineerCode(engineerCode);
res.setEngineerName(name);
res.setEngineerName(engineerInfo.getName());
res.setDynamics(dynamics);
return Result.success(res);
}
private String getEngineerName(String engineerCode){
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
EngineerInfo e = engineerInfoMPDao.selectOne(lqw);
return e.getName();
}
private List<OrderAppointment> orderAppointments(String engineerCode, String date){
// 获取指派单列表
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderAppointment::getEngineerCode, engineerCode);
lqw.ge(OrderAppointment::getExpectStartTime, date + " 00:00:00");
lqw.le(OrderAppointment::getExpectStartTime, date + " 23:59:59");
return orderAppointmentMPDao.selectList(lqw);
}
private List<EngineerTimeline> engineerTimelines(String engineerCode, String date){
private List<OrderEvent> engineerTimelines(List<String> orderIds, String date){
// 获取工程师timeline
List<String> events = Stream.of("分站取还配件", "已出发", "加单").collect(Collectors.toList());
LambdaQueryWrapper<EngineerTimeline> lqw = new LambdaQueryWrapper<>();
lqw.eq(EngineerTimeline::getEngineerCode, engineerCode);
lqw.ge(EngineerTimeline::getHappen, date+" 00:00:00");
lqw.le(EngineerTimeline::getHappen, date + " 23:59:59");
lqw.in(EngineerTimeline::getEvent, events);
return engineerTimelineMPDao.selectList(lqw);
LambdaQueryWrapper<OrderEvent> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderEvent::getOrderId, orderIds);
lqw.ge(OrderEvent::getHappen, date+" 00:00:00");
lqw.le(OrderEvent::getHappen, date + " 23:59:59");
lqw.in(OrderEvent::getEvent, events);
return orderEventMPDao.selectList(lqw);
}
private HashMap<String, String> orderRequestsLocation(List<String> orderIds) {
// 获取客户地址location
HashMap<String, String> map = new HashMap<>();
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderRequest::getOrderId, orderIds);
......@@ -112,9 +98,10 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
private String getWarehouseLocation(String branchId) {
// 获取配送站location
LambdaQueryWrapper<WarehouseInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(WarehouseInfo::getBranchId, branchId);
WarehouseInfo w = warehouseInfoMPDao.selectOne(lqw);
LambdaQueryWrapper<OrgWarehouseInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrgWarehouseInfo::getBranchId, branchId);
List<OrgWarehouseInfo> wares = warehouseInfoMPDao.selectList(lqw);
OrgWarehouseInfo w = wares.get(0);
return String.format("%s,%s", w.getX(), w.getY());
}
......@@ -135,15 +122,15 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
}
private List<EnginnerTimelineResp.DynamicItem> packItems(List<EngineerTimeline> timelines, List<OrderAppointment> orders, HashMap<String, String> locations, String warehouseLocation) {
private List<EngineerTimelineResp.DynamicItem> packItems(List<OrderEvent> timelines, List<OrderAppointment> orders, HashMap<String, String> locations, String warehouseLocation) {
int index = 1;
int index = 0;
String order_id, title, type, text, location;
List<EnginnerTimelineResp.DynamicItem> items = new ArrayList<>();
List<EngineerTimelineResp.DynamicItem> items = new ArrayList<>();
Set<String> s = new HashSet<>();
for (EngineerTimeline t: timelines){
EnginnerTimelineResp.DynamicItem item = new EnginnerTimelineResp.DynamicItem();
for (OrderEvent t: timelines){
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
if (t.getEvent().equals("分站取还配件")) {
title = t.getEvent();
......@@ -180,7 +167,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
continue;
}
index += 1;
EnginnerTimelineResp.DynamicItem item = new EnginnerTimelineResp.DynamicItem();
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
item.setTitle(String.format("第%d单出发", index));
item.setTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectStartTime()));
item.setStatus(0);
......@@ -190,6 +177,6 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
items.add(item);
}
// 根据items的time升序排序
return items.stream().sorted(Comparator.comparing(EnginnerTimelineResp.DynamicItem::getTime)).collect(Collectors.toList());
return items.stream().sorted(Comparator.comparing(EngineerTimelineResp.DynamicItem::getTime)).collect(Collectors.toList());
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!