Commit 0770a1aa by 丁伟峰

甘特图的要素,面向展示进行了重新定义,与工单信息无关;另外,order_request+order_appointment ===> order_info

1 parent a1fc747a
......@@ -2,6 +2,18 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrderInfoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.time.LocalDate;
import java.util.List;
public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long> {
OrderInfoEntity getByOrderId(String orderId);
List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes);
@Query("SELECT o.orderId, s.skillCategory as skillCaption FROM OrderInfoEntity o JOIN SkillInfoEntity s on o.brand=s.brand and o.type=s.type and o.skill=s.skill WHERE o.orderId = :orderId")
OrderSkillProjection getOrderSkillCaptionByOrderId(String orderId);
List<OrderInfoEntity> findAllByOrderIdIn(List<String> orderIds);
}
......@@ -6,11 +6,11 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.List;
......@@ -24,7 +24,11 @@ public class EngineersGanttDTO {
private String levelValue;
private Integer page = OrderConfig.DEFAULT_PAGE_INDEX;
private Integer size = OrderConfig.DEFAULT_PAGE_SIZE;
private String date;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate date;
private List<String> engineerCodes;
private List<String> branchIds;
private List<String> groupIds;
......@@ -70,43 +74,19 @@ public class EngineersGanttDTO {
* 上班时间
*/
private String startTime;
private List<?> orders;
private List<?> slots;
}
@lombok.Data
@Accessors(chain = true)
public static class Order {
/**
* 工单ID
*/
private String orderId;
private String caption;
/**
* 排班状态
*/
private String preStatus;
/**
* 派单状态
*/
private String appointmentStatus;
/**
* 开始时间
*/
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
/**
* 结束时间
*/
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
/**
* 鼠标悬停提示
*/
private List<?> tips;
@lombok.Data
public static class Slot {
private String bgColor = "blue";
private String borderColor = "blue";
private String borderStyle = "solid";
private String btime;
private String etime;
private String text;
private List<LabelValueDTO> tooltip;
private String url;
}
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Entity
@Data
@Table(name = "order_info")
public class OrderInfoEntity {
......@@ -16,7 +19,7 @@ public class OrderInfoEntity {
@Column(name = "order_id", nullable = false, length = 50)
private String orderId;
@Column(name = "dt", nullable = false)
@Column(name = "dt", columnDefinition = "DATE", nullable = false)
private LocalDate dt;
@Column(name = "sub_id", nullable = false, length = 50)
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.common.EngineerUtils;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.EngineersGanttDTO;
......@@ -12,6 +13,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
......@@ -21,20 +23,19 @@ import java.util.stream.Collectors;
public class EngineerGanttServiceImpl implements EngineerGanttService {
@Autowired
private OrderAppointmentDao orderAppointmentDao;
@Autowired
private CapacityEngineerStatDao capacityEngineerStatDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private OrderRequestDao orderRequestDao;
@Autowired
private EngineerUtils engineerUtils;
@Autowired
private OrderInfoDao orderInfoDao;
private String getHourMinute(LocalDateTime time){
return DateUtils.formatDateTime(time, "HH:mm");
}
@Override
public Result<?> getEngineersGanttList(EngineersGanttDTO.Request reqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
......@@ -46,31 +47,31 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
log.info("根据多条件,查询返回符合条件的技术员列表:{}", engineerCodes);
}
List<OrderAppointmentEntity> orderAppointments = orderAppointmentDao.findByDateAndEngineerCodeIn(reqDTO.getDate(), engineerCodes);
List<String> orderIds = orderAppointments.stream().map(OrderAppointmentEntity::getOrderId).collect(Collectors.toList());
Map<String, OrderRequestEntity> mapOrderRequest = getOrdersByOrderIds(orderIds);
HashMap<String, List<EngineersGanttDTO.Order>> mapEngineers = new HashMap<>();
for (OrderAppointmentEntity e : orderAppointments) {
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(reqDTO.getDate(), engineerCodes);
List<String> orderIds = orders.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
Map<String, OrderInfoEntity> mapOrderRequest = getOrdersByOrderIds(orderIds);
HashMap<String, List<EngineersGanttDTO.Slot>> mapEngineers = new HashMap<>();
for (OrderInfoEntity e : orders) {
// log.info("===== order_id: [{}]", e.getOrderId());
EngineersGanttDTO.Order order = new EngineersGanttDTO.Order();
EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order.setStartTime(e.getExpectStartTime()).setEndTime(e.getExpectEndTime());
order.setOrderId(e.getOrderId()).setPreStatus(e.getPreStatus());
order.setTips(getOrderTips(e.getOrderId()));
slot.setBtime(getHourMinute(e.getExpectTimeBegin()));
slot.setEtime(getHourMinute(e.getExpectTimeEnd()));
slot.setTooltip(getOrderTips(e.getOrderId()));
OrderSkillProjection orderSkill = orderRequestDao.getOrderSkillCaptionByOrderId(e.getOrderId());
OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId());
if (orderSkill != null) {
order.setCaption(orderSkill.getSkillCaption());
slot.setText(orderSkill.getSkillCaption());
}
order.setAppointmentStatus(mapOrderRequest.get(e.getOrderId()).getAppointmentStatus());
List<EngineersGanttDTO.Order> orders = null;
slot.setBgColor(mapOrderRequest.get(e.getOrderId()).getAppointmentStatus().toString());
List<EngineersGanttDTO.Slot> slots = null;
if (mapEngineers.containsKey(e.getEngineerCode())) {
orders = mapEngineers.get(e.getEngineerCode());
slots = mapEngineers.get(e.getEngineerCode());
} else {
orders = new ArrayList<>();
slots = new ArrayList<>();
}
orders.add(order);
mapEngineers.put(e.getEngineerCode(), orders);
slots.add(slot);
mapEngineers.put(e.getEngineerCode(), slots);
}
List<EngineersGanttDTO.GanttChart> engineers = new ArrayList<>();
......@@ -84,7 +85,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByWorkdayAndEngineerCode(reqDTO.getDate(), engineerCode);
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByWorkdayAndEngineerCode(DateUtils.formatDate(reqDTO.getDate()), engineerCode);
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else {
......@@ -92,7 +93,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
}
if (mapEngineers.containsKey(engineerCode)) {
engineer.setOrders(mapEngineers.get(engineerCode));
engineer.setSlots(mapEngineers.get(engineerCode));
}
// engineer.setErrorTip(); todo
engineers.add(engineer);
......@@ -101,7 +102,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
engineers.sort(Comparator.comparing(EngineersGanttDTO.GanttChart::getEngineerName));
EngineersGanttDTO.Result res = new EngineersGanttDTO.Result();
res.setDate(reqDTO.getDate()).setEngineers(engineers);
res.setDate(DateUtils.formatDate(reqDTO.getDate())).setEngineers(engineers);
return Result.success(res);
}
......@@ -135,15 +136,15 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
}
}
public Map<String, OrderRequestEntity> getOrdersByOrderIds(List<String> orderIds) {
List<OrderRequestEntity> orders = orderRequestDao.findAllByOrderIdIn(orderIds);
public Map<String, OrderInfoEntity> getOrdersByOrderIds(List<String> orderIds) {
List<OrderInfoEntity> orders = orderInfoDao.findAllByOrderIdIn(orderIds);
return orders.stream().collect(Collectors.toMap(OrderRequestEntity::getOrderId, order -> order));
return orders.stream().collect(Collectors.toMap(OrderInfoEntity::getOrderId, order -> order));
}
private List<?> getOrderTips(String orderId) {
private List<LabelValueDTO> getOrderTips(String orderId) {
// log.info("==> getOrderTips: orderId[{}]", orderId);
OrderRequestEntity order = orderRequestDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
if (order == null) {
log.error("对应的订单不存在!{}", orderId);
return null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!