Commit 0770a1aa by 丁伟峰

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

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