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