Commit eb8eeb00 by 王力

Merge branch 'feature_OrderServiceList_wangl' into 'develop'

Feature order service list wangl

See merge request !16
2 parents 43c74076 c10c1782
package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.OrderEvent;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface OrderEventDao extends BaseMapper<OrderEvent> {
}
package com.alibaba.cloud.integration.order.dto;
import lombok.Data;
import java.util.List;
@Data
public class OrderServiceDynamicsResp {
private String orderId;
private List<Dynamics> dynamics;
@Data
public static class Dynamics{
private String title;
private String subTitle;
private String time;
private String memo;
}
}
package com.alibaba.cloud.integration.order.entity;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class OrderEvent {
private Integer id;
private String orderId;
private String suborderId;
private Timestamp happen;
private String event;
private String operator;
private String operatorName;
private String source;
private String desc;
private String memo;
private Timestamp createTime;
private Timestamp updateTime;
}
\ No newline at end of file
......@@ -2,9 +2,7 @@ package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.*;
import com.alibaba.cloud.integration.order.dto.KV;
import com.alibaba.cloud.integration.order.dto.OrderAppointmentListResp;
import com.alibaba.cloud.integration.order.dto.OrderServiceDetailResp;
import com.alibaba.cloud.integration.order.dto.*;
import com.alibaba.cloud.integration.order.entity.*;
import com.alibaba.cloud.integration.order.service.OrderServiceDetail;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -12,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
......@@ -33,6 +33,9 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired
private OrderTimelineDao orderTimelineDao;
@Autowired
private OrderEventDao orderEventDao;
@Transactional
@Override
public Result<?> getOrderServiceDetail(String orderId) {
......@@ -55,7 +58,17 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Transactional
@Override
public Result<?> getOrderServiceDynamics(String orderId) {
return null;
// 获取服务单动态
List<OrderEvent> events = this.queryOrderEvents(orderId);
// pack 动态items
List<OrderServiceDynamicsResp.Dynamics> dynamics = this.packOrderDynamics(events);
OrderServiceDynamicsResp res = new OrderServiceDynamicsResp();
res.setOrderId(orderId);
res.setDynamics(dynamics);
return Result.success(res);
}
@Transactional
......@@ -130,8 +143,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return orderRequestDao.selectOne(lqw);
}
private List<OrderAppointment> queryOrderAppointments(String orderId) {
// 获取指派单记录列表
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
......@@ -139,6 +150,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return orderAppointmentDao.selectList(lqw);
}
private List<OrderEvent> queryOrderEvents(String orderId) {
LambdaQueryWrapper<OrderEvent> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderEvent::getOrderId, orderId);
return orderEventDao.selectList(lqw);
}
private HashMap<String, EngineerInfo> getEngineerInfos(List<String> egCodes){
// 获取工程师信息列表
HashMap<String, EngineerInfo> map = new HashMap<>();
......@@ -226,6 +243,23 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return items;
}
private List<OrderServiceDynamicsResp.Dynamics> packOrderDynamics(List<OrderEvent> events){
List<OrderServiceDynamicsResp.Dynamics> dynamics = new ArrayList<>();
// 根据happen排序
Comparator<OrderEvent> happen = Comparator.comparing(OrderEvent::getHappen);
List<OrderEvent> results = events.stream().sorted(happen).collect(Collectors.toList());
for(OrderEvent o: results) {
OrderServiceDynamicsResp.Dynamics d = new OrderServiceDynamicsResp.Dynamics();
d.setTitle(o.getEvent());
d.setSubTitle(String.format("操作人: %s", o.getOperatorName()));
d.setTime(this.Timestamp2Datetime(o.getHappen(), "yyyy-mm-dd HH:MM"));
d.setMemo(o.getMemo());
dynamics.add(d);
}
return dynamics;
}
private List<KV> packOrderTimeline(List<OrderTimeline> timelines) {
List<KV> items = new ArrayList<>();
if (timelines == null) {
......@@ -258,4 +292,9 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
item.setParams(params);
return item;
}
private String Timestamp2Datetime(Timestamp t, String pattern) {
DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
return df.format(t.toLocalDateTime());
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!