Commit 915fee62 by chamberone

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

…oject.git into develop
2 parents 3495104d 730790c9
...@@ -50,7 +50,7 @@ public class DispatchController { ...@@ -50,7 +50,7 @@ public class DispatchController {
// 派工台确认派单 // 派工台确认派单
Result<?> res = null; Result<?> res = null;
try { try {
res = dispatchService.dispatchOrderConfirm(req.getEngineerCode(), req.getOrderIds()); res = dispatchService.dispatchOrderConfirm(req.getEngineerCode(), req.getDate(), req.getOrderIds());
}catch (BusinessException e){ }catch (BusinessException e){
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
......
package com.dituhui.pea.order.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dituhui.pea.order.entity.OrderInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDate;
import java.util.List;
@Mapper
public interface OrderInfoMPDao extends BaseMapper<OrderInfo> {
@Select("select * from order_info where order_id=#{orderId} order by dt desc")
OrderInfo getByOrderId(String orderId);
@Select("select * from order_info where order_id=#{orderId} and dt=#{dt}")
OrderInfo getByOrderIdAndDt(String orderId, LocalDate dt);
@Select("select * from order_info where order_id=#{orderId}")
List<OrderInfo> selectByOrderId(String orderId);
@Select("<script> select * from order_request where dt=#{dt} and order_id in " +
"<foreach item='orderId' index='index' collection='orderIds' open='(' separator=',' close=')'>#{orderId}</foreach></script>")
List<OrderInfo> selectByDtAndOrderIds(@Param("dt") LocalDate dt, @Param("orderIds") List<String> orderIds);
@Select("select * from order_info where dt=#{dt} and engineerCode=#{engineerCode}")
List<OrderInfo> selectByEngineerCodeAndDt(String engineerCode, LocalDate dt);
@Select("select * from order_info where dt=#{dt} and engineerCode=#{engineerCode} and appointment_status=#{appointmentStatus}")
List<OrderInfo> selectByEngineerCodeAndDtAndAppointmentStatus(String engineerCode, LocalDate dt, String appointmentStatus);
}
...@@ -7,5 +7,6 @@ import java.util.List; ...@@ -7,5 +7,6 @@ import java.util.List;
@Data @Data
public class DispatchOrderConfirmReqDTO { public class DispatchOrderConfirmReqDTO {
private String engineerCode; private String engineerCode;
private String date;
private List<String> orderIds; private List<String> orderIds;
} }
package com.dituhui.pea.order.entity;
import lombok.Data;
import java.sql.Timestamp;
import java.time.LocalDate;
@Data
public class OrderInfo {
private Long id;
private String orderId;
private LocalDate dt;
private String subId;
private String name;
private String phone;
private String address;
private String x;
private String y;
private String province;
private String city;
private String county;
private String brand;
private String type;
private String skill;
private String applyNote;
private String faultDescribe;
private Timestamp expectTimeBegin;
private Timestamp expectTimeEnd;
private String expectTimeDesc;
private String source;
private String beanPriority;
private String beanTags;
private String beanStatus;
private String beanSubStatus;
private String areaId;
private String orgClusterId;
private String orgBranchId;
private String orgGroupId;
private String orgTeamId;
private Integer priority;
private String tags;
private String appointmentStatus;
private String appointmentMethod;
private String orderStatus;
private String serviceStatus;
private String engineerCode;
private String engineerName;
private String engineerPhone;
private String engineerCodeSub;
private Timestamp planStartTime;
private Timestamp planEndTime;
private Integer arriveElapsed;
private Integer arriveDistance;
private Timestamp actualStartTime;
private Timestamp actualEndTime;
private String description;
private Timestamp createTime;
private Timestamp updateTime;
}
\ No newline at end of file
...@@ -12,5 +12,5 @@ public interface DispatchService { ...@@ -12,5 +12,5 @@ public interface DispatchService {
Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO); Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO);
Result<?> dispatchOrderConfirm(String engineerCode, List<String> orderIds); Result<?> dispatchOrderConfirm(String engineerCode, String date, List<String> orderIds);
} }
...@@ -19,25 +19,23 @@ import org.springframework.stereotype.Service; ...@@ -19,25 +19,23 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
interface GroupTag { interface GroupTag {
// 订单分类tag // 订单分类tag
String getGroupTag(OrderRequest order); String getGroupTag(OrderInfo order);
} }
@Service @Service
public class DispatchServiceImpl implements DispatchService { public class DispatchServiceImpl implements DispatchService {
@Autowired
private OrderRequestMPDao orderRequestMPDao;
@Autowired @Autowired
private OrderAppointmentMPDao orderAppointmentMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired @Autowired
private OrgTeamMPDao orgTeamMPDao; private OrgTeamMPDao orgTeamMPDao;
...@@ -54,18 +52,19 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -54,18 +52,19 @@ public class DispatchServiceImpl implements DispatchService {
@Transactional @Transactional
@Override @Override
public Result<?> getDispatchOrderList(DispatchOrderListReq reqDTO) { public Result<?> getDispatchOrderList(DispatchOrderListReq reqDTO) {
// 获取派工台订单列表
// 获取技能信息 // 获取技能信息
HashMap<String, SkillInfo> skillInfo = this.querySkillInfo(); HashMap<String, SkillInfo> skillInfo = this.querySkillInfo();
// 获取工单列表 // 获取工单列表
List<OrderRequest> orders = this.queryOrderRequests(reqDTO); List<OrderInfo> orders = this.queryOrders(reqDTO);
// 获取分组标签 // 获取分组标签
GroupTag gt = new GroupTagFactory().getGroupTag(reqDTO.getGroupTagId()); GroupTag gt = new GroupTagFactory().getGroupTag(reqDTO.getGroupTagId());
List<DispatchOrderListResp.Order> items = new ArrayList<>(); List<DispatchOrderListResp.Order> items = new ArrayList<>();
for (OrderRequest o : orders) { for (OrderInfo o : orders) {
DispatchOrderListResp.Order item = new DispatchOrderListResp.Order(); DispatchOrderListResp.Order item = new DispatchOrderListResp.Order();
item.setOrderId(o.getOrderId()); item.setOrderId(o.getOrderId());
...@@ -84,7 +83,6 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -84,7 +83,6 @@ public class DispatchServiceImpl implements DispatchService {
item.setSkillCategory(skill.getSkillCategory()); item.setSkillCategory(skill.getSkillCategory());
item.setTypeCategory(skill.getTypeCategory()); item.setTypeCategory(skill.getTypeCategory());
} }
item.setName(o.getName()); item.setName(o.getName());
item.setPhone(o.getPhone()); item.setPhone(o.getPhone());
item.setCity(o.getCity()); item.setCity(o.getCity());
...@@ -105,14 +103,6 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -105,14 +103,6 @@ public class DispatchServiceImpl implements DispatchService {
item.setGroupTag(tags[0]); // 设置tag名称 item.setGroupTag(tags[0]); // 设置tag名称
item.setGroupWeight(Integer.parseInt(tags[1])); // 设置tag权重 item.setGroupWeight(Integer.parseInt(tags[1])); // 设置tag权重
// 暂时兼容待删除 TODO
String time = TimeUtils.timestamp2DateTime(o.getExpectTimeBegin(), "HH:mm");
String timeSlot = this.parseTimeSlot(o.getExpectTimeBegin());
item.setIntentionTime(String.format("%s/%s", time, timeSlot));
item.setCustomerName(o.getName());
item.setRemark(o.getApplyNote());
item.setCategory(String.format("%s-%s", o.getType(), o.getBrand()));
items.add(item); items.add(item);
} }
...@@ -126,10 +116,12 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -126,10 +116,12 @@ public class DispatchServiceImpl implements DispatchService {
public Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO) throws BusinessException { public Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO) throws BusinessException {
// 派工台技术员预约单列表 // 派工台技术员预约单列表
LocalDate date = TimeUtils.IsoDate2LocalDate(reqDTO.getDate());
// 获取技能信息 // 获取技能信息
HashMap<String, SkillInfo> skillInfo = this.querySkillInfo(); HashMap<String, SkillInfo> skillInfo = this.querySkillInfo();
// 获取groupIds // 获取teamIds
List<String> teamIds = this.queryOrgTeamIds(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getBranchIds(), List<String> teamIds = this.queryOrgTeamIds(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getBranchIds(),
reqDTO.getGroupIds(), reqDTO.getTeamIds()); reqDTO.getGroupIds(), reqDTO.getTeamIds());
if (teamIds.isEmpty()) { if (teamIds.isEmpty()) {
...@@ -150,7 +142,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -150,7 +142,7 @@ public class DispatchServiceImpl implements DispatchService {
List<String> engineerCodes = engineers.stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toList()); List<String> engineerCodes = engineers.stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toList());
// 获取技术员已指派单列表 // 获取技术员已指派单列表
Map<String, List<OrderAppointment>> engineerOrders = this.queryEngineerOrders(engineerCodes, reqDTO.getDate()); Map<String, List<OrderInfo>> engineerOrders = this.queryEngineerOrders(engineerCodes, date);
// 获取技术员的容量 // 获取技术员的容量
HashMap<String, CapacityEngineerStat> engineerCap = this.queryCapacityEngineerStat(engineerCodes, reqDTO.getDate()); HashMap<String, CapacityEngineerStat> engineerCap = this.queryCapacityEngineerStat(engineerCodes, reqDTO.getDate());
...@@ -158,16 +150,16 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -158,16 +150,16 @@ public class DispatchServiceImpl implements DispatchService {
// 获取订单ID // 获取订单ID
Set<String> orderIds = new HashSet<>(); Set<String> orderIds = new HashSet<>();
for (String k : engineerOrders.keySet()) { for (String k : engineerOrders.keySet()) {
for (OrderAppointment o : engineerOrders.get(k)) { for (OrderInfo o : engineerOrders.get(k)) {
orderIds.add(o.getOrderId()); orderIds.add(o.getOrderId());
} }
} }
// 获取服务单/工单列表 // 获取服务单/工单列表
Map<String, List<OrderRequest>> orders = new HashMap<>(); Map<String, List<OrderInfo>> orders = new HashMap<>();
if (!orderIds.isEmpty()) { if (!orderIds.isEmpty()) {
orders = orderRequestMPDao.selectByOrderIds(new ArrayList<>(orderIds)).stream().collect( orders = orderInfoMPDao.selectByDtAndOrderIds(date, new ArrayList<>(orderIds)).stream().collect(
Collectors.groupingBy(OrderRequest::getOrderId)); Collectors.groupingBy(OrderInfo::getOrderId));
} }
// 获取技术员已指派单列表 // 获取技术员已指派单列表
...@@ -177,13 +169,13 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -177,13 +169,13 @@ public class DispatchServiceImpl implements DispatchService {
List<DispatchEngineerOrderListResp.OrderInfo> items = new ArrayList<>(); List<DispatchEngineerOrderListResp.OrderInfo> items = new ArrayList<>();
// 技术员已指派的订单列表 // 技术员已指派的订单列表
List<OrderAppointment> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>()); List<OrderInfo> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
for (OrderAppointment r : records) { for (OrderInfo r : records) {
// 获取对应的工单信息 // 获取对应的工单信息
if (ListUtils.isEmpty(orders.get(r.getOrderId()))) { if (ListUtils.isEmpty(orders.get(r.getOrderId()))) {
continue; continue;
} }
OrderRequest o = orders.get(r.getOrderId()).get(0); OrderInfo o = orders.get(r.getOrderId()).get(0);
DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo(); DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo();
...@@ -215,23 +207,17 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -215,23 +207,17 @@ public class DispatchServiceImpl implements DispatchService {
item.setName(o.getName()); item.setName(o.getName());
item.setPhone(o.getPhone()); item.setPhone(o.getPhone());
String time = TimeUtils.timestamp2DateTime(r.getExpectStartTime(), "HH:mm"); String time = TimeUtils.timestamp2DateTime(r.getPlanStartTime(), "HH:mm");
String timeSlot = this.parseTimeSlot(r.getExpectStartTime()); String timeSlot = this.parseTimeSlot(r.getPlanStartTime());
item.setExpectTimeDesc(String.format("%s/%s", time, timeSlot)); item.setExpectTimeDesc(String.format("%s/%s", time, timeSlot));
item.setSource(o.getSource()); item.setSource(o.getSource());
item.setAppointmentStatus(o.getAppointmentStatus()); item.setAppointmentStatus(o.getAppointmentStatus());
item.setAppointmentType(o.getAppointmentMethod()); item.setAppointmentType(o.getAppointmentMethod());
item.setOrderStatus(r.getStatus()); // 预约单状态 item.setOrderStatus(r.getOrderStatus()); // 预约单状态
item.setOrderStatusDesc(r.getStatus()); // 预约单状态描述, TODO item.setOrderStatusDesc(r.getOrderStatus()); // 预约单状态描述, TODO
item.setCreateTime(TimeUtils.IsoTimestamp2DateTime(o.getCreateTime())); item.setCreateTime(TimeUtils.IsoTimestamp2DateTime(o.getCreateTime()));
// 暂时兼容待删除 TODO
item.setCategory(String.format("%s-%s", o.getType(), o.getBrand()));
item.setRemark(o.getApplyNote());
item.setCustomerName(o.getName());
item.setIntentionTime(String.format("%s/%s", time, timeSlot));
items.add(item); items.add(item);
} }
...@@ -264,135 +250,125 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -264,135 +250,125 @@ public class DispatchServiceImpl implements DispatchService {
} }
@Override @Override
public Result<?> dispatchOrderConfirm(String engineerCode, List<String> orderIds) throws BusinessException { public Result<?> dispatchOrderConfirm(String engineerCode, String date, List<String> orderIds) throws BusinessException {
// 派工台确认派单 // 派工台确认派单
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode); EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
if (engineer == null) { if (engineer == null) {
throw new BusinessException("技术员不存在"); throw new BusinessException("技术员不存在");
} }
List<OrderRequest> orders = orderRequestMPDao.selectByOrderIds(orderIds); LambdaQueryWrapper<OrderInfo> wrapper = new LambdaQueryWrapper<>();
if (orders.isEmpty()) { wrapper.eq(OrderInfo::getDt, localDate);
throw new BusinessException("订单号错误"); wrapper.in(OrderInfo::getOrderId, orderIds);
List<OrderInfo> orders = orderInfoMPDao.selectList(wrapper);
if (ListUtils.isEmpty(orders)) {
throw new BusinessException("订单不存在");
} }
// 通过订单获取日期 // 已经指派的订单
Timestamp t = orders.get(0).getExpectTimeBegin(); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
String date = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(t.toLocalDateTime()); lqw.eq(OrderInfo::getEngineerCode, engineerCode);
lqw.eq(OrderInfo::getDt, date);
lqw.orderByAsc(OrderInfo::getPlanStartTime);
List<OrderInfo> orderAppointments = orderInfoMPDao.selectList(lqw);
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderAppointment::getEngineerCode, engineerCode);
lqw.ge(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date)));
lqw.le(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date)));
lqw.orderByAsc(OrderAppointment::getExpectStartTime);
List<OrderAppointment> orderAppointments = orderAppointmentMPDao.selectList(lqw);
// TODO,临时处理方案,后续调用派单引擎处理 // TODO,临时处理方案,后续调用派单引擎处理
OrderRequestScheduler scheduler = new OrderRequestScheduler(); OrderRequestScheduler scheduler = new OrderRequestScheduler();
List<LineSegment> results = scheduler.scheduler(orders, orderAppointments); List<LineSegment> results = scheduler.scheduler(orders, orderAppointments);
for (LineSegment r : results) { for (LineSegment r : results) {
String orderId = r.id; String orderId = r.id;
Timestamp expectStartTime = scheduler.linePoint2Timestamp(r.start, date); Timestamp planStartTime = scheduler.linePoint2Timestamp(r.start, date);
Timestamp expectEndTime = scheduler.linePoint2Timestamp(r.end, date); Timestamp planEndTime = scheduler.linePoint2Timestamp(r.end, date);
OrderAppointment op = new OrderAppointment();
op.setOrderId(orderId);
op.setSuborderId(Long.toString(System.currentTimeMillis()));
op.setMainSub(1);
op.setEngineerCode(engineerCode);
op.setEngineerName(engineer.getName());
op.setEngineerAge(0);
op.setEngineerPhone(engineer.getPhone());
op.setIsWorkshop(0);
op.setExpectStartTime(expectStartTime);
op.setExpectEndTime(expectEndTime);
op.setPreStatus("PRE");
op.setStatus("ASSIGNED");
orderAppointmentMPDao.insert(op);
// 更新order request表状态 // 更新order request表状态
LambdaUpdateWrapper<OrderRequest> wrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<OrderInfo> updateWrapper = new LambdaUpdateWrapper<>();
wrapper.set(OrderRequest::getAppointmentStatus, "ASSIGNED"); updateWrapper.set(OrderInfo::getPlanStartTime, planStartTime);
wrapper.set(OrderRequest::getAppointmentMethod, "MANUAL"); updateWrapper.set(OrderInfo::getPlanEndTime, planEndTime);
wrapper.eq(OrderRequest::getOrderId, orderId); updateWrapper.set(OrderInfo::getAppointmentStatus, "CONFIRM");
orderRequestMPDao.update(null, wrapper); updateWrapper.set(OrderInfo::getAppointmentMethod, "MANUAL");
updateWrapper.eq(OrderInfo::getOrderId, orderId);
updateWrapper.eq(OrderInfo::getDt, localDate);
orderInfoMPDao.update(null, updateWrapper);
} }
return Result.success(null); return Result.success(null);
} }
private List<OrderRequest> queryOrderRequests(DispatchOrderListReq reqDTO) { private List<OrderInfo> queryOrders(DispatchOrderListReq reqDTO) {
// 获取服务单列表 // 获取服务单列表
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderRequest::getAppointmentStatus, "NOT_ASSIGNED"); lqw.eq(OrderInfo::getAppointmentStatus, "NOT_ASSIGNED"); // 明确未派工订单
lqw.eq(reqDTO.getLevelType().equals("cluster"), OrderRequest::getOrgClusterId, reqDTO.getLevelValue()); lqw.eq(reqDTO.getLevelType().equals("cluster"), OrderInfo::getOrgClusterId, reqDTO.getLevelValue());
lqw.eq(reqDTO.getLevelType().equals("branch"), OrderRequest::getOrgBranchId, reqDTO.getLevelValue()); lqw.eq(reqDTO.getLevelType().equals("branch"), OrderInfo::getOrgBranchId, reqDTO.getLevelValue());
lqw.eq(reqDTO.getLevelType().equals("group"), OrderRequest::getOrgGroupId, reqDTO.getLevelValue()); lqw.eq(reqDTO.getLevelType().equals("group"), OrderInfo::getOrgGroupId, reqDTO.getLevelValue());
lqw.eq(OrderRequest::getDt, TimeUtils.IsoDate2LocalDate(reqDTO.getDate())); lqw.eq(OrderInfo::getDt, TimeUtils.IsoDate2LocalDate(reqDTO.getDate()));
//筛选项 //筛选项
lqw.eq(StringUtils.isNotEmpty(reqDTO.getPhone()), OrderRequest::getPhone, reqDTO.getPhone()); lqw.eq(StringUtils.isNotEmpty(reqDTO.getPhone()), OrderInfo::getPhone, reqDTO.getPhone());
lqw.eq(StringUtils.isNotEmpty(reqDTO.getOrderId()), OrderRequest::getOrderId, reqDTO.getOrderId()); lqw.eq(StringUtils.isNotEmpty(reqDTO.getOrderId()), OrderInfo::getOrderId, reqDTO.getOrderId());
lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderRequest::getOrgBranchId, reqDTO.getBranchIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderInfo::getOrgBranchId, reqDTO.getBranchIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderInfo::getOrgGroupId, reqDTO.getGroupIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderInfo::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderInfo::getAppointmentMethod, reqDTO.getAppointmentType());
if (ListUtils.isNotEmpty(reqDTO.getPriorities())) { if (ListUtils.isNotEmpty(reqDTO.getPriorities())) {
List<Integer> p = reqDTO.getPriorities(); List<Integer> p = reqDTO.getPriorities();
if (p.contains(0) && p.contains(1)) { if (p.contains(0) && p.contains(1)) {
lqw.ge(OrderRequest::getPriority, 1); lqw.ge(OrderInfo::getPriority, 1);
} else if (p.contains(0) && !p.contains(1)) { } else if (p.contains(0) && !p.contains(1)) {
lqw.le(OrderRequest::getPriority, 1); lqw.le(OrderInfo::getPriority, 1);
} else if (p.contains(1) && !p.contains(0)) { } else if (p.contains(1) && !p.contains(0)) {
lqw.ge(OrderRequest::getPriority, 5); lqw.ge(OrderInfo::getPriority, 5);
} }
} }
if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
lqw.and(w ->
w.in(OrderInfo::getEngineerCode, reqDTO.getEngineerCodes())
.or()
.in(OrderInfo::getEngineerCodeSub, reqDTO.getEngineerCodes())
);
}
if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) { if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) {
String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'"; String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types); String sql = String.format("select 1 from skill_info sk where sk.brand = order_info.brand and sk.type = order_info.type and sk.skill = order_info.skill and type_category in (%s)", types);
lqw.exists(sql); lqw.exists(sql);
} }
if (ListUtils.isNotEmpty(reqDTO.getSkillCategory())) { if (ListUtils.isNotEmpty(reqDTO.getSkillCategory())) {
String skills = "'" + String.join("','", reqDTO.getSkillCategory()) + "'"; String skills = "'" + String.join("','", reqDTO.getSkillCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and skill_category in (%s)", skills); String sql = String.format("select 1 from skill_info sk where sk.brand = order_info.brand and sk.type = order_info.type and sk.skill = order_info.skill and skill_category in (%s)", skills);
lqw.exists(sql); lqw.exists(sql);
} }
if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
String engineerCodes = "'" + String.join("','", reqDTO.getEngineerCodes()) + "'";
String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes);
lqw.exists(sql);
}
if (ListUtils.isNotEmpty(reqDTO.getGroupCategory())) { if (ListUtils.isNotEmpty(reqDTO.getGroupCategory())) {
String groupCategory = reqDTO.getGroupCategory().stream().map(Object::toString).collect(Collectors.joining(",")); String groupCategory = reqDTO.getGroupCategory().stream().map(Object::toString).collect(Collectors.joining(","));
String sql = String.format("select 1 from org_group g where g.group_id = order_request.org_group_id and g.category in (%s)", groupCategory); String sql = String.format("select 1 from org_group g where g.group_id = order_info.org_group_id and g.category in (%s)", groupCategory);
lqw.exists(sql); lqw.exists(sql);
} }
return orderRequestMPDao.selectList(lqw); return orderInfoMPDao.selectList(lqw);
} }
private Map<String, List<OrderAppointment>> queryEngineerOrders(List<String> engineerCodes, String date) { private Map<String, List<OrderInfo>> queryEngineerOrders(List<String> engineerCodes, LocalDate date) {
// 获取工程师服务单列表 // 获取工程师服务单列表
Map<String, List<OrderAppointment>> map = new HashMap<>(); Map<String, List<OrderInfo>> map = new HashMap<>();
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderAppointment::getEngineerCode, engineerCodes);
lqw.ge(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 00:00:00", date))); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.le(OrderAppointment::getExpectStartTime, TimeUtils.IsoDateTime2Timestamp(String.format("%s 23:59:59", date))); lqw.eq(OrderInfo::getDt, date);
lqw.in(OrderInfo::getEngineerCode, engineerCodes);
lqw.orderByAsc(OrderAppointment::getEngineerCode); lqw.orderByAsc(OrderInfo::getEngineerCode);
lqw.orderByAsc(OrderAppointment::getExpectStartTime); lqw.orderByAsc(OrderInfo::getPlanStartTime);
List<OrderAppointment> records = orderAppointmentMPDao.selectList(lqw); List<OrderInfo> records = orderInfoMPDao.selectList(lqw);
return records.stream().collect(Collectors.groupingBy(OrderAppointment::getEngineerCode)); return records.stream().collect(Collectors.groupingBy(OrderInfo::getEngineerCode));
} }
...@@ -492,7 +468,7 @@ class GroupTagFactory { ...@@ -492,7 +468,7 @@ class GroupTagFactory {
class GroupTagUrgency implements GroupTag { class GroupTagUrgency implements GroupTag {
// 根据紧急程度来分组 // 根据紧急程度来分组
public String getGroupTag(OrderRequest order) { public String getGroupTag(OrderInfo order) {
String s = order.getTags(); String s = order.getTags();
if (s == null) { if (s == null) {
return "正常#1"; return "正常#1";
...@@ -511,7 +487,7 @@ class GroupTagUrgency implements GroupTag { ...@@ -511,7 +487,7 @@ class GroupTagUrgency implements GroupTag {
class GroupTagOmit implements GroupTag { class GroupTagOmit implements GroupTag {
public String getGroupTag(OrderRequest order) { public String getGroupTag(OrderInfo order) {
return "默认分类#5"; return "默认分类#5";
} }
} }
...@@ -590,18 +566,18 @@ class LineSegmentScheduler { ...@@ -590,18 +566,18 @@ class LineSegmentScheduler {
class OrderRequestScheduler { class OrderRequestScheduler {
public List<LineSegment> scheduler(List<OrderRequest> orderRequests, List<OrderAppointment> orderAppointments) { public List<LineSegment> scheduler(List<OrderInfo> orderRequests, List<OrderInfo> orderAppointments) {
List<LineSegment> used = new ArrayList<>(); List<LineSegment> used = new ArrayList<>();
for (OrderAppointment o : orderAppointments) { for (OrderInfo o : orderAppointments) {
LineSegment s = new LineSegment(o.getOrderId(), LineSegment s = new LineSegment(o.getOrderId(),
this.Timestamp2LinePoint(o.getExpectStartTime()), this.Timestamp2LinePoint(o.getPlanStartTime()),
this.Timestamp2LinePoint(o.getExpectEndTime())); this.Timestamp2LinePoint(o.getPlanEndTime()));
used.add(s); used.add(s);
} }
List<Line> newTasks = new ArrayList<>(); List<Line> newTasks = new ArrayList<>();
for (OrderRequest o : orderRequests) { for (OrderInfo o : orderRequests) {
if (!o.getAppointmentStatus().equals("NOT_ASSIGNED")) { if (!o.getAppointmentStatus().equals("NOT_ASSIGNED")) {
continue; continue;
} }
......
...@@ -59,8 +59,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -59,8 +59,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot(); EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX // todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
slot.setOrderId(e.getOrderId()); slot.setOrderId(e.getOrderId());
slot.setBtime(getHourMinute(e.getExpectTimeBegin())); slot.setBtime(getHourMinute(e.getPlanStartTime()));
slot.setEtime(getHourMinute(e.getExpectTimeEnd())); slot.setEtime(getHourMinute(e.getPlanEndTime()));
slot.setTooltip(getOrderTips(e.getOrderId())); slot.setTooltip(getOrderTips(e.getOrderId()));
OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId()); OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId());
if (orderSkill != null) { if (orderSkill != null) {
...@@ -78,8 +78,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -78,8 +78,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
if(e.getArriveElapsed() > 0) { if(e.getArriveElapsed() > 0) {
// 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间 // 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间
slot = new EngineersGanttDTO.Slot(); slot = new EngineersGanttDTO.Slot();
slot.setBtime(getHourMinute(e.getExpectTimeBegin(), -e.getArriveElapsed())); slot.setBtime(getHourMinute(e.getPlanStartTime(), -e.getArriveElapsed()));
slot.setEtime(getHourMinute(e.getExpectTimeBegin())); slot.setEtime(getHourMinute(e.getPlanStartTime()));
slot.setShapeSize("mini"); slot.setShapeSize("mini");
slot.setBgColor(getColor("ONWAY")); slot.setBgColor(getColor("ONWAY"));
slots.add(slot); slots.add(slot);
......
...@@ -30,10 +30,7 @@ import java.util.stream.Collectors; ...@@ -30,10 +30,7 @@ import java.util.stream.Collectors;
public class OrderAssignImpl implements OrderAssign { public class OrderAssignImpl implements OrderAssign {
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired
private OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
...@@ -63,7 +60,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -63,7 +60,7 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) { public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) {
// 服务单指派-推荐技术员列表 // 服务单指派-推荐技术员列表
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
...@@ -84,13 +81,13 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -84,13 +81,13 @@ public class OrderAssignImpl implements OrderAssign {
} }
// 获取已技术员已指派订单列表 // 获取已技术员已指派订单列表
List<OrderAppointment> orderAppointments = orderAppointmentMPDao.selectByEngineerCodeAndDt(engineer.getEngineerCode(), order.getDt()); List<OrderInfo> orderAppointments = orderInfoMPDao.selectByEngineerCodeAndDtAndAppointmentStatus(engineer.getEngineerCode(), order.getDt(), "CONFIRM");
// 获取订单tips // 获取订单tips
HashMap<String, List<LabelValueDTO>> orderTips = new HashMap<>(); HashMap<String, List<LabelValueDTO>> orderTips = new HashMap<>();
List<String> orderIds = orderAppointments.stream().map(OrderAppointment::getOrderId).collect(Collectors.toList()); List<String> orderIds = orderAppointments.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
if (!orderIds.isEmpty()) { if (!orderIds.isEmpty()) {
List<OrderRequest> orders = orderRequestMPDao.selectByOrderIds(orderIds); List<OrderInfo> orders = orderInfoMPDao.selectByDtAndOrderIds(TimeUtils.IsoDate2LocalDate(date), orderIds);
orderTips = this.packOrderTips(orders); orderTips = this.packOrderTips(orders);
} }
...@@ -126,7 +123,8 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -126,7 +123,8 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> orderAssign(String orderId, String engineerCode) throws BusinessException { public Result<?> orderAssign(String orderId, String engineerCode) throws BusinessException {
// 服务单指派-指派提交 // 服务单指派-指派提交
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
...@@ -134,7 +132,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -134,7 +132,7 @@ public class OrderAssignImpl implements OrderAssign {
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode); EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
boolean record = false; boolean record = false;
OrderAppointment op = orderAppointmentMPDao.getByOrderIdAndDt(orderId, order.getDt()); OrderInfo op = orderInfoMPDao.getByOrderIdAndDt(orderId, order.getDt());
if (op != null) { if (op != null) {
record = true; record = true;
} }
...@@ -148,39 +146,17 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -148,39 +146,17 @@ public class OrderAssignImpl implements OrderAssign {
if (!result.getCanAssign()) { if (!result.getCanAssign()) {
throw new BusinessException("指派失败, 未能找到合适的时间段, 请选择其他技术员"); throw new BusinessException("指派失败, 未能找到合适的时间段, 请选择其他技术员");
} }
Timestamp expectStartTime = Timestamp.valueOf(result.getStart()); Timestamp planStartTime = Timestamp.valueOf(result.getStart());
Timestamp expectEndTime = Timestamp.valueOf(result.getEnd()); Timestamp planEndTime = Timestamp.valueOf(result.getEnd());
// 更新或插入指派单
if (!record) {
op = new OrderAppointment();
}
op.setOrderId(orderId);
op.setSuborderId(Long.toString(System.currentTimeMillis()));
op.setMainSub(1);
op.setEngineerCode(engineerCode);
op.setEngineerName(engineer.getName());
op.setEngineerAge(0);
op.setEngineerPhone(engineer.getPhone());
op.setIsWorkshop(0);
op.setDt(order.getDt());
op.setExpectStartTime(expectStartTime);
op.setExpectEndTime(expectEndTime);
op.setPreStatus("CONFIRM");
op.setStatus("ASSIGNED");
if (!record) {
orderAppointmentMPDao.insert(op);
} else {
orderAppointmentMPDao.updateById(op);
}
// 更新order_request表状态 // 更新order_request表状态
LambdaUpdateWrapper<OrderRequest> wrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<OrderInfo> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(OrderRequest::getAppointmentStatus, "ASSIGNED"); wrapper.set(OrderInfo::getAppointmentStatus, "CONFIRM");
wrapper.set(OrderRequest::getAppointmentMethod, "MANUAL"); wrapper.set(OrderInfo::getAppointmentMethod, "MANUAL");
wrapper.eq(OrderRequest::getOrderId, orderId); wrapper.set(OrderInfo::getPlanStartTime, planStartTime);
orderRequestMPDao.update(null, wrapper); wrapper.set(OrderInfo::getPlanEndTime, planEndTime);
wrapper.eq(OrderInfo::getOrderId, orderId);
orderInfoMPDao.update(null, wrapper);
// 工单变更登记 // 工单变更登记
commonService.addOrderEvent(orderId, "", "PEA-WEB", "API", "工单指派", "工单指派", ""); commonService.addOrderEvent(orderId, "", "PEA-WEB", "API", "工单指派", "工单指派", "");
...@@ -190,20 +166,16 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -190,20 +166,16 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> orderRevokeAssign(String orderId) throws BusinessException { public Result<?> orderRevokeAssign(String orderId) throws BusinessException {
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); // 放回工单池
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
// 更新order_request表为未指派 // 更新order_request表为未指派
order.setAppointmentStatus("NOT_ASSIGNED"); order.setAppointmentStatus("INIT");
orderRequestMPDao.updateById(order); orderInfoMPDao.updateById(order);
// 更新order_appointment表为未指派
LambdaUpdateWrapper<OrderAppointment> appWrapper = new LambdaUpdateWrapper<>();
appWrapper.set(OrderAppointment::getStatus, "NOT_ASSIGNED")
.eq(OrderAppointment::getOrderId, orderId).eq(OrderAppointment::getDt, order.getDt());
orderAppointmentMPDao.update(null, appWrapper);
// 登记事件 // 登记事件
OrderEvent oe = new OrderEvent(); OrderEvent oe = new OrderEvent();
...@@ -225,7 +197,8 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -225,7 +197,8 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc) throws BusinessException { public Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc) throws BusinessException {
// 工单改约接口(当前同放回工单池处理) // 工单改约接口(当前同放回工单池处理)
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
...@@ -239,18 +212,12 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -239,18 +212,12 @@ public class OrderAssignImpl implements OrderAssign {
LocalDate originDate = order.getDt(); // 改约前的日期 LocalDate originDate = order.getDt(); // 改约前的日期
// 更新order_request表为未指派 // 更新order_request表为未指派
order.setAppointmentStatus("NOT_ASSIGNED"); order.setAppointmentStatus("INIT");
order.setDt(expectBegin.toLocalDate()); order.setDt(expectBegin.toLocalDate());
order.setExpectTimeBegin(Timestamp.valueOf(expectBegin)); order.setExpectTimeBegin(Timestamp.valueOf(expectBegin));
order.setExpectTimeEnd(Timestamp.valueOf(expectEnd)); order.setExpectTimeEnd(Timestamp.valueOf(expectEnd));
order.setExpectTimeDesc(expectDesc); order.setExpectTimeDesc(expectDesc);
orderRequestMPDao.updateById(order); orderInfoMPDao.updateById(order);
// 更新order_appointment表为未指派
LambdaUpdateWrapper<OrderAppointment> appWrapper = new LambdaUpdateWrapper<>();
appWrapper.set(OrderAppointment::getStatus, "RESCHEDULED")
.eq(OrderAppointment::getOrderId, orderId).eq(OrderAppointment::getDt, originDate);
orderAppointmentMPDao.update(null, appWrapper);
// 登记事件 // 登记事件
OrderEvent oe = new OrderEvent(); OrderEvent oe = new OrderEvent();
...@@ -269,7 +236,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -269,7 +236,7 @@ public class OrderAssignImpl implements OrderAssign {
return Result.success(null); return Result.success(null);
} }
private List<String> searchEngineerCodes(OrderRequest order, String distance, String key, String recommend) { private List<String> searchEngineerCodes(OrderInfo order, String distance, String key, String recommend) {
Set<String> engineerCodes1 = this.searchEngineerByRecommend(order, recommend); Set<String> engineerCodes1 = this.searchEngineerByRecommend(order, recommend);
if (engineerCodes1.isEmpty()) { if (engineerCodes1.isEmpty()) {
log.info("recommend:{}筛选条件未找到技术员", recommend); log.info("recommend:{}筛选条件未找到技术员", recommend);
...@@ -316,7 +283,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -316,7 +283,7 @@ public class OrderAssignImpl implements OrderAssign {
return new ArrayList<>(engineerCodes1); return new ArrayList<>(engineerCodes1);
} }
private Set<String> searchEngineerByRecommend(OrderRequest order, String recommend) { private Set<String> searchEngineerByRecommend(OrderInfo order, String recommend) {
if (StringUtils.isNotEmpty(recommend) && recommend.equals("team")) { if (StringUtils.isNotEmpty(recommend) && recommend.equals("team")) {
return orgTeamEngineerMPDao.selectByTeamId(order.getOrgTeamId()).stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toSet()); return orgTeamEngineerMPDao.selectByTeamId(order.getOrgTeamId()).stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toSet());
} }
...@@ -355,18 +322,17 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -355,18 +322,17 @@ public class OrderAssignImpl implements OrderAssign {
return engineerInfoMPDao.selectList(lqw).stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toSet()); return engineerInfoMPDao.selectList(lqw).stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toSet());
} }
private List<TimeLineDTO> packTimelines(List<OrderAppointment> orders, HashMap<String, List<LabelValueDTO>> orderTips) { private List<TimeLineDTO> packTimelines(List<OrderInfo> orders, HashMap<String, List<LabelValueDTO>> orderTips) {
List<LabelValueDTO> empty = new ArrayList<>(); List<LabelValueDTO> empty = new ArrayList<>();
List<TimeLineDTO> items = new ArrayList<>(); List<TimeLineDTO> items = new ArrayList<>();
for (OrderAppointment order : orders) { for (OrderInfo order : orders) {
TimeLineDTO item = new TimeLineDTO(); TimeLineDTO item = new TimeLineDTO();
item.setOrderId(order.getOrderId()); item.setOrderId(order.getOrderId());
item.setPreStatus(order.getPreStatus()); item.setAppointmentStatus(order.getAppointmentStatus());
item.setAppointmentStatus(order.getStatus()); item.setStartTime(TimeUtils.IsoTimestamp2DateTime(order.getPlanStartTime()));
item.setStartTime(TimeUtils.IsoTimestamp2DateTime(order.getExpectStartTime())); item.setEndTime(TimeUtils.IsoTimestamp2DateTime(order.getPlanEndTime()));
item.setEndTime(TimeUtils.IsoTimestamp2DateTime(order.getExpectEndTime()));
item.setTips(orderTips.getOrDefault(order.getOrderId(), empty)); item.setTips(orderTips.getOrDefault(order.getOrderId(), empty));
items.add(item); items.add(item);
...@@ -374,12 +340,12 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -374,12 +340,12 @@ public class OrderAssignImpl implements OrderAssign {
return items; return items;
} }
private HashMap<String, List<LabelValueDTO>> packOrderTips(List<OrderRequest> orders) { private HashMap<String, List<LabelValueDTO>> packOrderTips(List<OrderInfo> orders) {
return orders.stream().collect(Collectors.toMap( return orders.stream().collect(Collectors.toMap(
OrderRequest::getOrderId, this::packOrderTip, (l1, l2) -> l1, HashMap::new)); OrderInfo::getOrderId, this::packOrderTip, (l1, l2) -> l1, HashMap::new));
} }
private List<LabelValueDTO> packOrderTip(OrderRequest order) { private List<LabelValueDTO> packOrderTip(OrderInfo order) {
// pack订单tips // pack订单tips
List<LabelValueDTO> items = new ArrayList<>(); List<LabelValueDTO> items = new ArrayList<>();
items.add(new LabelValueDTO("类型/品牌", String.format("%s %s %s", order.getSkill(), order.getType(), order.getBrand()))); items.add(new LabelValueDTO("类型/品牌", String.format("%s %s %s", order.getSkill(), order.getType(), order.getBrand())));
......
...@@ -126,6 +126,9 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -126,6 +126,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setExpectTimeBegin(LocalDateTimeUtil.parse(req.getExpectBegin(), PATTERN_DATETIME)); entity.setExpectTimeBegin(LocalDateTimeUtil.parse(req.getExpectBegin(), PATTERN_DATETIME));
entity.setExpectTimeEnd(LocalDateTimeUtil.parse(req.getExpectEnd(), PATTERN_DATETIME)); entity.setExpectTimeEnd(LocalDateTimeUtil.parse(req.getExpectEnd(), PATTERN_DATETIME));
entity.setExpectTimeDesc(req.getExpectDesc()); entity.setExpectTimeDesc(req.getExpectDesc());
// 使用期望时间来初始化计划时间,后面在指派环节更新为真正的有效的计划时间
entity.setPlanStartTime(entity.getExpectTimeBegin());
entity.setPlanEndTime(entity.getExpectTimeEnd());
entity.setApplyNote(req.getDescription()); // order_request的description字段,仅仅用于内部备注,不对外 entity.setApplyNote(req.getDescription()); // order_request的description字段,仅仅用于内部备注,不对外
entity.setDt(LocalDateTimeUtil.parseDate(req.getExpectBegin().substring(0, 10), PATTERN_DATE)); entity.setDt(LocalDateTimeUtil.parseDate(req.getExpectBegin().substring(0, 10), PATTERN_DATE));
entity.setSubId(newSubId(entity.getOrderId(), entity.getDt())); entity.setSubId(newSubId(entity.getOrderId(), entity.getDt()));
......
...@@ -22,10 +22,7 @@ import java.util.stream.Collectors; ...@@ -22,10 +22,7 @@ import java.util.stream.Collectors;
public class OrderServiceDetailImpl implements OrderServiceDetail { public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired
private OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
...@@ -45,11 +42,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -45,11 +42,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired @Autowired
private SkillInfoMPDao skillInfoMPDao; private SkillInfoMPDao skillInfoMPDao;
@Transactional @Transactional
@Override @Override
public Result<?> getOrderServiceDetail(String orderId) { public Result<?> getOrderServiceDetail(String orderId) {
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
List<KV> items = this.packOrderDetail(order); List<KV> items = this.packOrderDetail(order);
...@@ -66,8 +64,8 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -66,8 +64,8 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setOrderId(orderId); res.setOrderId(orderId);
res.setRisk(""); res.setRisk("");
res.setRiskDesc(""); res.setRiskDesc("");
res.setStatusDesc("打开"); res.setStatusDesc("正常");
res.setStatus(order.getStatus()); res.setStatus(order.getOrderStatus());
res.setAppointmentStatus(order.getAppointmentStatus()); res.setAppointmentStatus(order.getAppointmentStatus());
res.setLocation(String.format("%s,%s", order.getX(), order.getY())); res.setLocation(String.format("%s,%s", order.getX(), order.getY()));
res.setReschedulingParams(detail); res.setReschedulingParams(detail);
...@@ -94,52 +92,44 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -94,52 +92,44 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Transactional @Transactional
@Override @Override
public Result<?> getOrderAppointmentList(String orderId) throws BusinessException{ public Result<?> getOrderAppointmentList(String orderId) throws BusinessException {
// 获取预约单里列表 // 获取预约单里列表
OrderAppointmentListResp res = new OrderAppointmentListResp(); OrderAppointmentListResp res = new OrderAppointmentListResp();
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
if(order == null){
throw new BusinessException("订单不存在");
}
LocalDate curDate = order.getDt();
// 查询预约单列表 // 查询预约单列表
List<OrderAppointment> appoints = orderAppointmentMPDao.selectByOrderId(orderId); List<OrderInfo> orders = orderInfoMPDao.selectByOrderId(orderId);
if (appoints.isEmpty()) { if (orders.isEmpty()) {
// 没有指派单列表,返回 // 没有指派单列表,返回
res.setOrderId(orderId); res.setOrderId(orderId);
res.setOrders(new ArrayList<>()); res.setOrders(new ArrayList<>());
return Result.success(res); return Result.success(res);
} }
// 工程师ID列表
List<String> egCodes = appoints.stream().map(OrderAppointment::getEngineerCode).collect(Collectors.toList());
// 获取工程师基础信息列表 // 获取工程师基础信息列表
HashMap<String, EngineerInfo> egInfo = this.getEngineerInfos(egCodes); Set<String> set = new HashSet<>();
orders.stream().map(OrderInfo::getEngineerCode).forEach(set::add);
orders.stream().map(OrderInfo::getEngineerCodeSub).forEach(set::add);
List<String> engineerCodes = new ArrayList<>(set);
HashMap<String, EngineerInfo> egInfo = this.getEngineerInfos(engineerCodes);
// 获取groupIds 和 group信息 // 获取groupIds 和 group信息
List<String> groupIds = egInfo.values().stream().map(EngineerInfo::getGroupId).collect(Collectors.toList()); List<String> groupIds = egInfo.values().stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
HashMap<String, OrgGroup> groups = this.queryOrgGroups(groupIds); HashMap<String, OrgGroup> groups = this.queryOrgGroups(groupIds);
// 获取工程师技能列表<engineerCode, skills> // 获取工程师技能列表<engineerCode, skills>
Map<String, String> egSkill = this.getEngineerSkills(egCodes); Map<String, String> egSkill = this.getEngineerSkills(engineerCodes);
// 获取subOrder订单timeline // 获取subOrder订单timeline
Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId); Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId);
// 对指派单列表按照subOrderId降序排序, 获取排序的subOrderId列表, 然后根据subOrderId分组 Comparator<OrderInfo> dtDesc = Comparator.comparing(OrderInfo::getDt).reversed();
Comparator<OrderAppointment> sbDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed(); List<OrderInfo> results = orders.stream().sorted(dtDesc).collect(Collectors.toList());
List<OrderAppointment> results = appoints.stream().sorted(sbDesc).collect(Collectors.toList());
String lastSubOrderId = results.get(0).getSuborderId(); LocalDate lastDt = results.get(0).getDt();
List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>(); List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>();
for (OrderAppointment o : results) { for (OrderInfo o : results) {
String subOrderId = o.getSuborderId();
EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null); EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null);
String skill = egSkill.getOrDefault(o.getEngineerCode(), null); String skill = egSkill.getOrDefault(o.getEngineerCode(), null);
...@@ -148,15 +138,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -148,15 +138,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 获取title // 获取title
String title = engineerName; String title = engineerName;
if (!lastSubOrderId.equals(subOrderId) || o.getDt().isBefore(curDate)) { if (o.getDt().isBefore(lastDt)) {
title = String.format("%s_%s", engineerName, TimeUtils.IsoLocalDate2String(o.getDt())); title = String.format("%s_%s", engineerName, TimeUtils.IsoLocalDate2String(o.getDt()));
} }
OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment(); OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment();
item.setTitle(title); item.setTitle(title);
item.setEngineerCode(o.getEngineerCode()); item.setEngineerCode(o.getEngineerCode());
item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectStartTime())); item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin()));
item.setTimelines(this.packOrderTimeline(timelines.get(subOrderId))); item.setTimelines(this.packOrderTimeline(timelines.get(o.getSubId())));
item.setItems(this.packEngineerItems(eg, skill, groups.get(eg.getGroupId()))); item.setItems(this.packEngineerItems(eg, skill, groups.get(eg.getGroupId())));
items.add(item); items.add(item);
...@@ -173,7 +163,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -173,7 +163,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
List<String> block = new ArrayList<>(); List<String> block = new ArrayList<>();
// 获取订单详情 // 获取订单详情
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderTeamBlockResp res = new OrderTeamBlockResp(); OrderTeamBlockResp res = new OrderTeamBlockResp();
res.setOrderId(orderId); res.setOrderId(orderId);
...@@ -236,7 +226,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -236,7 +226,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
Comparator<EngineerSkillGroup> cmp = Comparator.comparing(EngineerSkillGroup::getEngineerCode); Comparator<EngineerSkillGroup> cmp = Comparator.comparing(EngineerSkillGroup::getEngineerCode);
List<EngineerSkillGroup> sortedResults = rows.stream().sorted(cmp).collect(Collectors.toList()); List<EngineerSkillGroup> sortedResults = rows.stream().sorted(cmp).collect(Collectors.toList());
// 根据engineerCode分组 // 根据engineerCode分组
Map<String, List<EngineerSkillGroup>> results = sortedResults.stream().collect(Collectors.groupingBy(EngineerSkillGroup::getEngineerCode)); Map<String, List<EngineerSkillGroup>> results = sortedResults.stream().collect(Collectors.groupingBy(EngineerSkillGroup::getEngineerCode));
...@@ -339,11 +328,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -339,11 +328,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return items; return items;
} }
private List<KV> packOrderDetail(OrderRequest order) { private List<KV> packOrderDetail(OrderInfo order) {
List<KV> items = new ArrayList<>(); List<KV> items = new ArrayList<>();
items.add(this.packOrderItem("客户姓名", order.getName())); items.add(this.packOrderItem("客户姓名", order.getName()));
items.add(this.packOrderItem("客户电话", order.getPhone())); items.add(this.packOrderItem("客户电话", order.getPhone()));
items.add(this.packOrderItem("客户地址", String.format("%s%s%s",order.getCity(), order.getCounty(), order.getAddress()))); items.add(this.packOrderItem("客户地址", String.format("%s%s%s", order.getCity(), order.getCounty(), order.getAddress())));
items.add(this.packOrderItem("品牌", order.getBrand())); items.add(this.packOrderItem("品牌", order.getBrand()));
items.add(this.packOrderItem("设备", order.getType())); items.add(this.packOrderItem("设备", order.getType()));
items.add(this.packOrderItem("服务", order.getSkill())); items.add(this.packOrderItem("服务", order.getSkill()));
......
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.ListUtils; import com.dituhui.pea.order.common.ListUtils;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.OrderAppointmentMPDao; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dao.OrderRequestMPDao;
import com.dituhui.pea.order.dto.OrderServiceList; import com.dituhui.pea.order.dto.OrderServiceList;
import com.dituhui.pea.order.dto.OrderServiceListReq; import com.dituhui.pea.order.dto.OrderServiceListReq;
import com.dituhui.pea.order.dto.OrderServiceListResp; import com.dituhui.pea.order.dto.OrderServiceListResp;
import com.dituhui.pea.order.entity.OrderAppointment; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.service.OrderServiceListService; import com.dituhui.pea.order.service.OrderServiceListService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -28,90 +25,90 @@ import java.util.stream.Collectors; ...@@ -28,90 +25,90 @@ import java.util.stream.Collectors;
public class OrderServiceListServiceImpl implements OrderServiceListService { public class OrderServiceListServiceImpl implements OrderServiceListService {
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired @Autowired
private OrderAppointmentMPDao orderAppointmentMPDao; private EngineerInfoMPDao engineerInfoMPDao;
@Autowired
private OrgBranchMPDao orgBranchMPDao;
@Transactional @Transactional
@Override @Override
public Result<OrderServiceListResp> getOrderServiceList(OrderServiceListReq reqDTO) throws BusinessException { public Result<OrderServiceListResp> getOrderServiceList(OrderServiceListReq reqDTO) throws BusinessException {
//分页 //分页
Page<OrderRequest> pg = new Page(reqDTO.getPage(), reqDTO.getSize()); Page<OrderInfo> pg = new Page(reqDTO.getPage(), reqDTO.getSize());
LocalDate startDate = TimeUtils.IsoDate2LocalDate(reqDTO.getStartDate()); LocalDate startDate = TimeUtils.IsoDate2LocalDate(reqDTO.getStartDate());
LocalDate endDate = TimeUtils.IsoDate2LocalDate(reqDTO.getEndDate()); LocalDate endDate = TimeUtils.IsoDate2LocalDate(reqDTO.getEndDate());
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(reqDTO.getLevelType().equals("cluster"), OrderRequest::getOrgClusterId, reqDTO.getLevelValue()); lqw.eq(reqDTO.getLevelType().equals("cluster"), OrderInfo::getOrgClusterId, reqDTO.getLevelValue());
lqw.eq(reqDTO.getLevelType().equals("branch"), OrderRequest::getOrgBranchId, reqDTO.getLevelValue()); lqw.eq(reqDTO.getLevelType().equals("branch"), OrderInfo::getOrgBranchId, reqDTO.getLevelValue());
lqw.eq(reqDTO.getLevelType().equals("group"), OrderRequest::getOrgGroupId, reqDTO.getLevelValue()); lqw.eq(reqDTO.getLevelType().equals("group"), OrderInfo::getOrgGroupId, reqDTO.getLevelValue());
lqw.ge(OrderRequest::getDt, startDate); //预约开始日期 lqw.ge(OrderInfo::getDt, startDate); //预约开始日期
lqw.le(OrderRequest::getDt, endDate); //预约开始日期 lqw.le(OrderInfo::getDt, endDate); //预约开始日期
//筛选项 //筛选项
lqw.eq(StringUtils.isNotEmpty(reqDTO.getPhone()), OrderRequest::getPhone, reqDTO.getPhone()); lqw.eq(StringUtils.isNotEmpty(reqDTO.getPhone()), OrderInfo::getPhone, reqDTO.getPhone());
lqw.eq(StringUtils.isNotEmpty(reqDTO.getOrderId()), OrderRequest::getOrderId, reqDTO.getOrderId()); lqw.eq(StringUtils.isNotEmpty(reqDTO.getOrderId()), OrderInfo::getOrderId, reqDTO.getOrderId());
lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderRequest::getOrgBranchId, reqDTO.getBranchIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderInfo::getOrgBranchId, reqDTO.getBranchIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderInfo::getOrgGroupId, reqDTO.getGroupIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderInfo::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderInfo::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderInfo::getAppointmentStatus, reqDTO.getAppointmentStatus());
if (ListUtils.isNotEmpty(reqDTO.getPriorities())) { if (ListUtils.isNotEmpty(reqDTO.getPriorities())) {
List<Integer> p = reqDTO.getPriorities(); List<Integer> p = reqDTO.getPriorities();
if (p.contains(0) && p.contains(1)) { if (p.contains(0) && p.contains(1)) {
lqw.ge(OrderRequest::getPriority, 1); lqw.ge(OrderInfo::getPriority, 1);
} else if (p.contains(0) && !p.contains(1)) { } else if (p.contains(0) && !p.contains(1)) {
lqw.le(OrderRequest::getPriority, 1); lqw.le(OrderInfo::getPriority, 1);
} else if (p.contains(1) && !p.contains(0)) { } else if (p.contains(1) && !p.contains(0)) {
lqw.ge(OrderRequest::getPriority, 5); lqw.ge(OrderInfo::getPriority, 5);
} }
} }
if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())){
lqw.and(w ->
w.in(OrderInfo::getEngineerCode, reqDTO.getEngineerCodes())
.or()
.in(OrderInfo::getEngineerCodeSub, reqDTO.getEngineerCodes())
);
}
if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) { if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) {
String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'"; String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types); String sql = String.format("select 1 from skill_info sk where sk.brand = order_info.brand and sk.type = order_info.type and sk.skill = order_info.skill and type_category in (%s)", types);
lqw.exists(sql); lqw.exists(sql);
} }
if (ListUtils.isNotEmpty(reqDTO.getSkillCategory())) { if (ListUtils.isNotEmpty(reqDTO.getSkillCategory())) {
String skills = "'" + String.join("','", reqDTO.getSkillCategory()) + "'"; String skills = "'" + String.join("','", reqDTO.getSkillCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and skill_category in (%s)", skills); String sql = String.format("select 1 from skill_info sk where sk.brand = order_info.brand and sk.type = order_info.type and sk.skill = order_info.skill and skill_category in (%s)", skills);
lqw.exists(sql); lqw.exists(sql);
} }
if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
String engineerCodes = "'" + String.join("','", reqDTO.getEngineerCodes()) + "'";
String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes);
lqw.exists(sql);
}
if (ListUtils.isNotEmpty(reqDTO.getGroupCategory())) { if (ListUtils.isNotEmpty(reqDTO.getGroupCategory())) {
String groupCategory = reqDTO.getGroupCategory().stream().map(Object::toString).collect(Collectors.joining(",")); String groupCategory = reqDTO.getGroupCategory().stream().map(Object::toString).collect(Collectors.joining(","));
String sql = String.format("select 1 from org_group g where g.group_id = order_request.org_group_id and g.category in (%s)", groupCategory); String sql = String.format("select 1 from org_group g where g.group_id = order_info.org_group_id and g.category in (%s)", groupCategory);
lqw.exists(sql); lqw.exists(sql);
} }
// 查询工单表列表 // 查询工单表列表
orderRequestMPDao.selectPage(pg, lqw); orderInfoMPDao.selectPage(pg, lqw);
List<OrderInfo> orders = pg.getRecords();
List<OrderRequest> records = pg.getRecords();
//获取工单订单号列表 // 获取技术员姓名
List<String> orderIds = new ArrayList<>(); Map<String, String> engineerNames = this.getEngineerNames(orders);
for (OrderRequest r : records) { // 获取branch
orderIds.add(r.getOrderId()); Map<String, String> branchNames = this.getBranchNames(orders);
}
// 获取工程师姓名列表
HashMap<String, List<String>> engineerNames = this.getEngineerNames(this.getOrderAppointments(orderIds));
List<String> names;
// 获取工程师工号列表
List<OrderServiceList> content = new ArrayList<>(); List<OrderServiceList> content = new ArrayList<>();
for (OrderRequest o : records) { for (OrderInfo o : orders) {
OrderServiceList record = new OrderServiceList(); OrderServiceList record = new OrderServiceList();
names = engineerNames.getOrDefault(o.getOrderId(), null);
record.setOrderId(o.getOrderId()); record.setOrderId(o.getOrderId());
record.setType(o.getType()); record.setType(o.getType());
record.setBrand(o.getBrand()); record.setBrand(o.getBrand());
...@@ -125,12 +122,14 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -125,12 +122,14 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
record.setSource(o.getSource()); record.setSource(o.getSource());
record.setDescription(o.getDescription()); record.setDescription(o.getDescription());
record.setPriority(o.getPriority()); record.setPriority(o.getPriority());
record.setOrgBranchName(o.getOrgBranchName()); record.setOrgBranchName(branchNames.getOrDefault(o.getOrgBranchId(), ""));
record.setEngineerNum(this.getEngNum(names)); //工程师数量 // 获取工程师信息
record.setEngineerNames(this.getEngNames(names)); //工程师姓名列表 List<String> names = this.getOrderEngineerNames(o.getEngineerCode(), o.getEngineerCodeSub(), engineerNames);
record.setEngineerNum(names.size()); //工程师数量
record.setEngineerNames(String.join("、", names)); //工程师姓名列表
record.setExpectTimeBegin(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin())); record.setExpectTimeBegin(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin()));
record.setExpectTimeEnd(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeEnd())); record.setExpectTimeEnd(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeEnd()));
record.setAppointmentTime(null);
record.setAppointmentStatus(o.getAppointmentStatus()); record.setAppointmentStatus(o.getAppointmentStatus());
record.setAppointmentType(o.getAppointmentMethod()); record.setAppointmentType(o.getAppointmentMethod());
record.setCreateTime(TimeUtils.IsoTimestamp2DateTime(o.getCreateTime())); record.setCreateTime(TimeUtils.IsoTimestamp2DateTime(o.getCreateTime()));
...@@ -149,73 +148,50 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -149,73 +148,50 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return Result.success(res); return Result.success(res);
} }
private Map<String, String> getEngineerNames(List<OrderInfo> orders) {
public List<OrderAppointment> getOrderAppointments(List<String> orderIds) { // 获取技术员姓名
// 获取指派单列表 Set<String> engineerCodes = new HashSet<>();
if (CollectionUtil.isEmpty(orderIds)) { for(OrderInfo r: orders){
return new ArrayList<>(); if(StringUtils.isNotEmpty(r.getEngineerCode())){
} engineerCodes.add(r.getEngineerCode());
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>(); }
lqw.in(OrderAppointment::getOrderId, orderIds); if(StringUtils.isNotEmpty(r.getEngineerCodeSub())){
return orderAppointmentMPDao.selectList(lqw); engineerCodes.add(r.getEngineerCodeSub());
}
public HashMap<String, List<String>> getEngineerNames(List<OrderAppointment> orders) {
// 获取orderId最新订单对应的工程师姓名列表
HashMap<String, List<String>> engineerNames = 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());
} }
engineerNames.put(orderId, names);
} }
return engineerNames; if(engineerCodes.isEmpty()){
return new HashMap<>();
}
List<EngineerInfo> engineers = engineerInfoMPDao.selectByEngineerCodes(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerInfo::getEngineerCode, EngineerInfo::getName));
} }
public Map<String, List<OrderAppointment>> groupOrderAppointments(List<OrderAppointment> orders) { private Map<String, String> getBranchNames(List<OrderInfo> orders){
// 获取orderId对应的最新的subOrderId的订单列表 // 获取branch名称
Set<String> branches = new HashSet<>();
// 根据orderId+subOrderId降序排序 for(OrderInfo r: orders){
Comparator<OrderAppointment> byOrderIdDesc = Comparator.comparing(OrderAppointment::getOrderId, String.CASE_INSENSITIVE_ORDER).reversed(); if(StringUtils.isNotEmpty(r.getOrgBranchId())){
Comparator<OrderAppointment> bySuborderIdDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed(); branches.add(r.getOrgBranchId());
Comparator<OrderAppointment> comp = byOrderIdDesc.thenComparing(bySuborderIdDesc);
List<OrderAppointment> results = orders.stream().sorted(comp).collect(Collectors.toList());
//获取orderId对应的最新的subOrderId的订单列表
String orderId = "";
String subOrderId = "";
List<OrderAppointment> items = new ArrayList<>();
for (OrderAppointment o : results) {
if (!orderId.equals(o.getOrderId())) {
orderId = o.getOrderId();
subOrderId = o.getSuborderId();
items.add(o);
continue;
}
if (subOrderId.equals(o.getSuborderId())) {
items.add(o);
} }
} }
return items.stream().collect(Collectors.groupingBy(OrderAppointment::getOrderId)); if(branches.isEmpty()){
} return new HashMap<>();
private Integer getEngNum(List<String> names) {
/*获取工程师数量*/
if (names == null) {
return 0;
} }
return names.size(); LambdaQueryWrapper<OrgBranch> lqw = new LambdaQueryWrapper<>();
lqw.in(OrgBranch::getBranchId, new ArrayList<>(branches));
List<OrgBranch> records = orgBranchMPDao.selectList(lqw);
return records.stream().collect(Collectors.toMap(OrgBranch::getBranchId, OrgBranch::getBranchName));
} }
private String getEngNames(List<String> names) { private List<String> getOrderEngineerNames(String engineerCode, String engineerCodeSub, Map<String,String> engineerNames){
/*获取工程师姓名列表*/ // 获取订单技术员姓名信息
if (names == null) { List<String> names = new ArrayList<>();
return ""; for(String code: List.of(engineerCode, engineerCodeSub)){
String name = engineerNames.getOrDefault(code, "");
if(StringUtils.isNotEmpty(name)){
names.add(name);
}
} }
return String.join("、", names); return names;
} }
} }
...@@ -3,7 +3,6 @@ package com.dituhui.pea.order.service.impl; ...@@ -3,7 +3,6 @@ package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
...@@ -25,6 +24,9 @@ import java.util.stream.Collectors; ...@@ -25,6 +24,9 @@ import java.util.stream.Collectors;
public class ScheduleServiceImpl implements ScheduleService { public class ScheduleServiceImpl implements ScheduleService {
@Autowired @Autowired
private OrderInfoMPDao orderInfoMPDao;
@Autowired
private OrgTeamMPDao orgTeamMPDao; private OrgTeamMPDao orgTeamMPDao;
@Autowired @Autowired
...@@ -34,12 +36,6 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -34,12 +36,6 @@ public class ScheduleServiceImpl implements ScheduleService {
private OrgGroupMPDao orgGroupMPDao; private OrgGroupMPDao orgGroupMPDao;
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao;
@Autowired
private OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
@Autowired @Autowired
...@@ -71,6 +67,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -71,6 +67,7 @@ public class ScheduleServiceImpl implements ScheduleService {
@Override @Override
public Result<?> getScheduleOverview(long page, long size, LocalDate date, String levelType, List<String> levelIds) { public Result<?> getScheduleOverview(long page, long size, LocalDate date, String levelType, List<String> levelIds) {
// 排班结果
// 获取team列表, 以team排序分页 // 获取team列表, 以team排序分页
IPage<OrgTeam> pg = this.queryOrgTeams(page, size, levelType, levelIds); IPage<OrgTeam> pg = this.queryOrgTeams(page, size, levelType, levelIds);
...@@ -89,15 +86,16 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -89,15 +86,16 @@ public class ScheduleServiceImpl implements ScheduleService {
team.setLevel("team"); team.setLevel("team");
// 获取改team订单列表 // 获取改team订单列表
List<OrderRequest> orders = this.queryOrderRequests(t.getTeamId(), date); List<OrderInfo> orders = this.queryOrderRequests(t.getTeamId(), date);
team.setOrder(this.getTeamOrderSum(orders, skillMapping)); team.setOrder(this.getTeamOrderSum(orders, skillMapping));
// 技术员指派单列表 // 技术员指派单列表
Map<String, List<OrderAppointment>> engineerOrders = new HashMap<>(); Map<String, List<OrderInfo>> engineerOrders = new HashMap<>();
if (ListUtils.isNotEmpty(orders)) { if (ListUtils.isNotEmpty(orders)) {
List<String> orderRequestIds = orders.stream().map(OrderRequest::getOrderId).collect(Collectors.toList()); List<String> orderRequestIds = orders.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<OrderAppointment> orderAppointments = this.queryOrderAppointments(orderRequestIds, date); List<OrderInfo> orderAppointments = orderInfoMPDao.selectByDtAndOrderIds(date, orderRequestIds);
engineerOrders = orderAppointments.stream().collect(Collectors.groupingBy(OrderAppointment::getEngineerCode)); orderAppointments.sort(Comparator.comparing(OrderInfo::getEngineerCode));
engineerOrders = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfo::getEngineerCode));
} }
// 获取team技术员列表 // 获取team技术员列表
...@@ -115,10 +113,10 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -115,10 +113,10 @@ public class ScheduleServiceImpl implements ScheduleService {
String engineerCode = entry.getKey(); String engineerCode = entry.getKey();
EngineerInfo engineerInfo = entry.getValue().get(0); EngineerInfo engineerInfo = entry.getValue().get(0);
List<String> orderIds = engineerOrders.getOrDefault(engineerCode, new ArrayList<>()).stream().map(OrderAppointment::getOrderId).collect(Collectors.toList()); List<String> orderIds = engineerOrders.getOrDefault(engineerCode, new ArrayList<>()).stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<OrderRequest> orders2 = new ArrayList<>(); List<OrderInfo> orders2 = new ArrayList<>();
for (OrderRequest o : orders) { for (OrderInfo o : orders) {
if (orderIds.contains(o.getOrderId())) { if (orderIds.contains(o.getOrderId())) {
orders2.add(o); orders2.add(o);
} }
...@@ -153,28 +151,29 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -153,28 +151,29 @@ public class ScheduleServiceImpl implements ScheduleService {
@Override @Override
public Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode) throws BusinessException { public Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode) throws BusinessException {
// 获取技术员已排班概况
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode); EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
if (engineer == null) { if (engineer == null) {
throw new BusinessException("分销员不存在"); throw new BusinessException("分销员不存在");
} }
List<LabelValueDTO> emptyTips = new ArrayList<>(); List<LabelValueDTO> emptyTips = new ArrayList<>();
List<OrderAppointment> orderAppointments = orderAppointmentMPDao.selectByEngineerCodeAndDt(engineerCode, date);
List<OrderInfo> orderAppointments = orderInfoMPDao.selectByEngineerCodeAndDtAndAppointmentStatus(engineerCode, date, "CONFIRM");
List<TimeLineDTO> timelines = new ArrayList<>(); List<TimeLineDTO> timelines = new ArrayList<>();
for (OrderAppointment o : orderAppointments) { for (OrderInfo o : orderAppointments) {
TimeLineDTO item = new TimeLineDTO(); TimeLineDTO item = new TimeLineDTO();
item.setOrderId(o.getOrderId()); item.setOrderId(o.getOrderId());
item.setPreStatus(o.getPreStatus()); item.setAppointmentStatus(o.getAppointmentStatus());
item.setAppointmentStatus(o.getStatus()); item.setStartTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanStartTime()));
item.setStartTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectStartTime())); item.setEndTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanEndTime()));
item.setEndTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectEndTime()));
item.setTips(emptyTips); item.setTips(emptyTips);
timelines.add(item); timelines.add(item);
} }
Map<String, List<OrderAppointment>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderAppointment::getStatus)); Map<String, List<OrderInfo>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfo::getServiceStatus));
List<OrderAppointment> empty = new ArrayList<>(); List<OrderInfo> empty = new ArrayList<>();
Integer countPending = statusGroup.getOrDefault("ASSIGNED", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("DEPARTED", empty).size(); Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size();
List<LabelValueDTO> dynamics = new ArrayList<>(); List<LabelValueDTO> dynamics = new ArrayList<>();
dynamics.add(new LabelValueDTO("姓名", engineer.getName())); dynamics.add(new LabelValueDTO("姓名", engineer.getName()));
...@@ -190,13 +189,13 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -190,13 +189,13 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics.add(new LabelValueDTO("工作时间", "08:00-18:00")); dynamics.add(new LabelValueDTO("工作时间", "08:00-18:00"));
dynamics.add(new LabelValueDTO("交通工具", "电动车")); dynamics.add(new LabelValueDTO("交通工具", "电动车"));
List<String> orderIds = orderAppointments.stream().map(OrderAppointment::getOrderId).collect(Collectors.toList()); List<String> orderIds = orderAppointments.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<OrderRequest> orderRequests = new ArrayList<>(); List<OrderInfo> orderRequests = new ArrayList<>();
if (orderIds != null && !orderIds.isEmpty()) { if (orderIds != null && !orderIds.isEmpty()) {
orderRequests = orderRequestMPDao.selectByOrderIds(orderIds); orderRequests = orderInfoMPDao.selectByDtAndOrderIds(date, orderIds);
} }
List<ScheduleEngineerOverviewResp.Order> orders = new ArrayList<>(); List<ScheduleEngineerOverviewResp.Order> orders = new ArrayList<>();
for (OrderRequest o : orderRequests) { for (OrderInfo o : orderRequests) {
ScheduleEngineerOverviewResp.Order item = new ScheduleEngineerOverviewResp.Order(); ScheduleEngineerOverviewResp.Order item = new ScheduleEngineerOverviewResp.Order();
item.setOrderId(o.getOrderId()); item.setOrderId(o.getOrderId());
item.setLocation(String.format("%s,%s", o.getX(), o.getY())); item.setLocation(String.format("%s,%s", o.getX(), o.getY()));
...@@ -255,31 +254,23 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -255,31 +254,23 @@ public class ScheduleServiceImpl implements ScheduleService {
return orgTeamEngineerMPDao.selectList(lqw); return orgTeamEngineerMPDao.selectList(lqw);
} }
private List<OrderRequest> queryOrderRequests(String teamId, LocalDate date) { private List<OrderInfo> queryOrderRequests(String teamId, LocalDate date) {
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderRequest::getDt, date); lqw.eq(OrderInfo::getDt, date);
lqw.in(OrderRequest::getOrgTeamId, teamId); lqw.in(OrderInfo::getOrgTeamId, teamId);
lqw.eq(OrderRequest::getAppointmentStatus, "ASSIGNED"); lqw.eq(OrderInfo::getAppointmentStatus, "CONFIRM");
return orderRequestMPDao.selectList(lqw); return orderInfoMPDao.selectList(lqw);
} }
private List<OrderAppointment> queryOrderAppointments(List<String> orderIds, LocalDate date) { private ScheduleOverviewResp.OrderSum getTeamOrderSum(List<OrderInfo> orders, HashMap<String, String> skillMapping) {
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderAppointment::getOrderId, orderIds);
lqw.eq(OrderAppointment::getDt, date);
lqw.orderByAsc(OrderAppointment::getEngineerCode);
return orderAppointmentMPDao.selectList(lqw);
}
private ScheduleOverviewResp.OrderSum getTeamOrderSum(List<OrderRequest> orders, HashMap<String, String> skillMapping) {
ScheduleOverviewResp.OrderSum s = new ScheduleOverviewResp.OrderSum(); ScheduleOverviewResp.OrderSum s = new ScheduleOverviewResp.OrderSum();
List<OrderRequest> emtpy = new ArrayList<>(); List<OrderInfo> emtpy = new ArrayList<>();
HashMap<String, Integer> skillCounter = new HashMap<>(); HashMap<String, Integer> skillCounter = new HashMap<>();
Map<String, List<OrderRequest>> cc = orders.stream().collect(Collectors.groupingBy(OrderRequest::getSkill)); Map<String, List<OrderInfo>> cc = orders.stream().collect(Collectors.groupingBy(OrderInfo::getSkill));
for(Map.Entry<String, List<OrderRequest>> entry: cc.entrySet()){ for (Map.Entry<String, List<OrderInfo>> entry : cc.entrySet()) {
String skill = entry.getKey(); String skill = entry.getKey();
Integer count = entry.getValue().size(); Integer count = entry.getValue().size();
String skillCategory = skillMapping.get(skill); String skillCategory = skillMapping.get(skill);
...@@ -313,15 +304,15 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -313,15 +304,15 @@ public class ScheduleServiceImpl implements ScheduleService {
// 获取skill映射 // 获取skill映射
HashMap<String, String> skillMap = this.getSkillCategoryMapping(); HashMap<String, String> skillMap = this.getSkillCategoryMapping();
QueryWrapper<OrderRequest> wrapper = new QueryWrapper<>(); QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("skill, COUNT(*) as count") wrapper.select("skill, COUNT(*) as count")
.lambda() .lambda()
.eq(OrderRequest::getDt, date) .eq(OrderInfo::getDt, date)
.in(levelType.equals("cluster"), OrderRequest::getOrgClusterId, levelValue) .in(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.in(levelType.equals("branch"), OrderRequest::getOrgBranchId, levelValue) .in(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.in(levelType.equals("group"), OrderRequest::getOrgGroupId, levelValue) .in(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderRequest::getSkill); .groupBy(OrderInfo::getSkill);
List<Map<String, Object>> results = orderRequestMPDao.selectMaps(wrapper); List<Map<String, Object>> results = orderInfoMPDao.selectMaps(wrapper);
for (Map<String, Object> result : results) { for (Map<String, Object> result : results) {
String skill = (String) result.get("skill"); String skill = (String) result.get("skill");
Long countValue = (Long) result.get("count"); Long countValue = (Long) result.get("count");
...@@ -340,15 +331,15 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -340,15 +331,15 @@ public class ScheduleServiceImpl implements ScheduleService {
HashMap<String, Integer> groupCategoryMapping = this.getGroupCategoryMapping(levelType, levelValue); HashMap<String, Integer> groupCategoryMapping = this.getGroupCategoryMapping(levelType, levelValue);
QueryWrapper<OrderRequest> wrapper = new QueryWrapper<>(); QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("org_group_id, COUNT(*) as count") wrapper.select("org_group_id, COUNT(*) as count")
.lambda() .lambda()
.eq(OrderRequest::getDt, date) .eq(OrderInfo::getDt, date)
.in(levelType.equals("cluster"), OrderRequest::getOrgClusterId, levelValue) .in(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.in(levelType.equals("branch"), OrderRequest::getOrgBranchId, levelValue) .in(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.in(levelType.equals("group"), OrderRequest::getOrgGroupId, levelValue) .in(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderRequest::getOrgGroupId); .groupBy(OrderInfo::getOrgGroupId);
List<Map<String, Object>> results = orderRequestMPDao.selectMaps(wrapper); List<Map<String, Object>> results = orderInfoMPDao.selectMaps(wrapper);
for (Map<String, Object> result : results) { for (Map<String, Object> result : results) {
String groupId = (String) result.get("org_group_id"); String groupId = (String) result.get("org_group_id");
Long countValue = (Long) result.get("count"); Long countValue = (Long) result.get("count");
...@@ -364,15 +355,15 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -364,15 +355,15 @@ public class ScheduleServiceImpl implements ScheduleService {
private HashMap<String, Integer> queryCountByAppointment(LocalDate date, String levelType, List<String> levelValue) { private HashMap<String, Integer> queryCountByAppointment(LocalDate date, String levelType, List<String> levelValue) {
HashMap<String, Integer> map = new HashMap<>(); HashMap<String, Integer> map = new HashMap<>();
QueryWrapper<OrderRequest> wrapper = new QueryWrapper<>(); QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("appointment_method, appointment_status, COUNT(*) as count") wrapper.select("appointment_method, appointment_status, COUNT(*) as count")
.lambda() .lambda()
.eq(OrderRequest::getDt, date) .eq(OrderInfo::getDt, date)
.in(levelType.equals("cluster"), OrderRequest::getOrgClusterId, levelValue) .in(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.in(levelType.equals("branch"), OrderRequest::getOrgBranchId, levelValue) .in(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.in(levelType.equals("group"), OrderRequest::getOrgGroupId, levelValue) .in(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderRequest::getAppointmentMethod, OrderRequest::getAppointmentStatus); .groupBy(OrderInfo::getAppointmentMethod, OrderInfo::getAppointmentStatus);
List<Map<String, Object>> results = orderRequestMPDao.selectMaps(wrapper); List<Map<String, Object>> results = orderInfoMPDao.selectMaps(wrapper);
Integer autoTotal = 0; Integer autoTotal = 0;
Integer manualTotal = 0; Integer manualTotal = 0;
...@@ -480,12 +471,10 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -480,12 +471,10 @@ public class ScheduleServiceImpl implements ScheduleService {
return items; return items;
} }
private <T> HashMap<String, List<T>> packParams(String key, T ...values) { private <T> HashMap<String, List<T>> packParams(String key, T... values) {
HashMap<String, List<T>> map = new HashMap<>(); HashMap<String, List<T>> map = new HashMap<>();
List<T> value = new ArrayList<>(); List<T> value = new ArrayList<>();
for(T v: values){ Collections.addAll(value, values);
value.add(v);
}
map.put(key, value); map.put(key, value);
return map; return map;
} }
......
...@@ -8,7 +8,7 @@ import com.dituhui.pea.order.dto.OrderChangeListDTO; ...@@ -8,7 +8,7 @@ import com.dituhui.pea.order.dto.OrderChangeListDTO;
import com.dituhui.pea.order.dto.WorkbenchSummaryResp; import com.dituhui.pea.order.dto.WorkbenchSummaryResp;
import com.dituhui.pea.order.entity.OrderEventEntity; import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrderRequest; import com.dituhui.pea.order.entity.OrderInfo;
import com.dituhui.pea.order.service.WorkbenchService; import com.dituhui.pea.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -28,7 +28,7 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -28,7 +28,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private OrderEventDao orderEventDao; private OrderEventDao orderEventDao;
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired @Autowired
private OrderInfoDao orderInfoDao; private OrderInfoDao orderInfoDao;
...@@ -89,27 +89,27 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -89,27 +89,27 @@ public class WorkbenchServiceImpl implements WorkbenchService {
} }
private List<Map<String, Object>> queryCountByAppointmentMethod(String levelType, String levelValue, LocalDate dt) { private List<Map<String, Object>> queryCountByAppointmentMethod(String levelType, String levelValue, LocalDate dt) {
QueryWrapper<OrderRequest> wrapper = new QueryWrapper<>(); QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("appointment_method, appointment_status, COUNT(*) as count") wrapper.select("appointment_method, appointment_status, COUNT(*) as count")
.lambda() .lambda()
.eq(OrderRequest::getDt, dt) .eq(OrderInfo::getDt, dt)
.eq(levelType.equals("cluster"), OrderRequest::getOrgClusterId, levelValue) .eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.eq(levelType.equals("branch"), OrderRequest::getOrgBranchId, levelValue) .eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.eq(levelType.equals("group"), OrderRequest::getOrgGroupId, levelValue) .eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderRequest::getAppointmentMethod, OrderRequest::getAppointmentStatus); .groupBy(OrderInfo::getAppointmentMethod, OrderInfo::getAppointmentStatus);
return orderRequestMPDao.selectMaps(wrapper); return orderInfoMPDao.selectMaps(wrapper);
} }
private List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) { private List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) {
QueryWrapper<OrderRequest> wrapper = new QueryWrapper<>(); QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("appointment_status, COUNT(*) as count") wrapper.select("appointment_status, COUNT(*) as count")
.lambda() .lambda()
.eq(OrderRequest::getDt, dt) .eq(OrderInfo::getDt, dt)
.eq(levelType.equals("cluster"), OrderRequest::getOrgClusterId, levelValue) .eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.eq(levelType.equals("branch"), OrderRequest::getOrgBranchId, levelValue) .eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.eq(levelType.equals("group"), OrderRequest::getOrgGroupId, levelValue) .eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderRequest::getAppointmentStatus); .groupBy(OrderInfo::getAppointmentStatus);
return orderRequestMPDao.selectMaps(wrapper); return orderInfoMPDao.selectMaps(wrapper);
} }
private HashMap<String, Long> transAppointmentMethod(List<Map<String, Object>> results) { private HashMap<String, Long> transAppointmentMethod(List<Map<String, Object>> results) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!