Commit eef0845d by 丁伟峰

增加了工作台/技术员工单甘特图

1 parent d327c81e
package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.OrderAppointmentEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface OrderAppointmentDao extends JpaRepository<OrderAppointmentEntity, Integer> {
@Query("from OrderAppointmentEntity a where DATE(a.expectTime) = :date and a.engineerCode in :engineerCodes")
List<?> findByDateAndEngineerCodeIn(String date, String[] engineerCodes);
}
package com.alibaba.cloud.integration.order.dto; package com.alibaba.cloud.integration.order.dto;
import lombok.experimental.Accessors;
import java.util.List;
@lombok.Data @lombok.Data
@Accessors(chain = true)
public class WorkbenchEngineersGanttRespDTO { public class WorkbenchEngineersGanttRespDTO {
private String date; private String date;
private GanttChart[] engineers; private List<?> engineers;
/** /**
* GanttChart * GanttChart
*/ */
@lombok.Data @lombok.Data
@Accessors(chain = true)
public static class GanttChart { public static class GanttChart {
/** /**
* 下班时间 * 下班时间
...@@ -31,10 +37,11 @@ public class WorkbenchEngineersGanttRespDTO { ...@@ -31,10 +37,11 @@ public class WorkbenchEngineersGanttRespDTO {
* 上班时间 * 上班时间
*/ */
private String startTime; private String startTime;
private Timeline[] timeline; private List<?> timeline;
} }
@lombok.Data @lombok.Data
@Accessors(chain = true)
public static class Timeline { public static class Timeline {
/** /**
* 结束时间 * 结束时间
...@@ -52,10 +59,11 @@ public class WorkbenchEngineersGanttRespDTO { ...@@ -52,10 +59,11 @@ public class WorkbenchEngineersGanttRespDTO {
* 开始时间 * 开始时间
*/ */
private String startTime; private String startTime;
private Tip[] tips; private List<?> tips;
} }
@lombok.Data @lombok.Data
@Accessors(chain = true)
public static class Tip { public static class Tip {
private String desc; private String desc;
private String title; private String title;
......
package com.alibaba.cloud.integration.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Data
@Entity
@Table(name="order_appointment")
public class OrderAppointmentEntity {
/**
* 自增id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 服务单id
*/
private String orderId;
/**
* 子工单id
*/
private String suborderId;
/**
* 多人单标识(1主单 2副单)
*/
private int mainSub;
/**
* 工程师工号
*/
private String engineerCode;
/**
* 工程师姓名
*/
private String engineerName;
/**
* 工程师电话(快照)
*/
private String engineerPhone;
/**
* 工程师年龄(快照)
*/
private Integer engineerAge;
/**
* 是否车间单(0否 1是)
*/
private int isWorkshop;
/**
* 客户预约上门时间
*/
private Date expectTime;
/**
* 实际上门时间
*/
private Date actualTime;
/**
* 开始服务时间
*/
private Date startTime;
/**
* 结束服务时间
*/
private Date endTime;
/**
* pre-预排班/confirm-已确认
*/
private String preState;
/**
* bean预约单状态(pre-预指派/虚拟指派 contact-已联系 depart-已出发 start-已开始 finish-已完成 undone-已上门未完成 reschedule-已改约)
*/
private String status;
/**
* 备注
*/
private String memo;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
package com.alibaba.cloud.integration.order.service; package com.alibaba.cloud.integration.order.service;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.WorkbenchEngineersGanttReqDTO;
import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListReqDTO; import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListReqDTO;
public interface WorkbenchService { public interface WorkbenchService {
Result<?> getOrderChangeList(WorkbenchOrderChangeListReqDTO orderChangeListReqDTO); Result<?> getOrderChangeList(WorkbenchOrderChangeListReqDTO orderChangeListReqDTO);
Result<?> getEngineersGanttList(WorkbenchEngineersGanttReqDTO ganttReqDTO);
} }
package com.alibaba.cloud.integration.order.service.impl; package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.OrderAppointmentDao;
import com.alibaba.cloud.integration.order.dao.OrderChangeDao; import com.alibaba.cloud.integration.order.dao.OrderChangeDao;
import com.alibaba.cloud.integration.order.dao.OrderRequestDao; import com.alibaba.cloud.integration.order.dao.OrderRequestDao;
import com.alibaba.cloud.integration.order.dto.WorkbenchEngineersGanttReqDTO;
import com.alibaba.cloud.integration.order.dto.WorkbenchEngineersGanttRespDTO;
import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListReqDTO; import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListReqDTO;
import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListRespDTO; import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListRespDTO;
import com.alibaba.cloud.integration.order.entity.OrderAppointmentEntity;
import com.alibaba.cloud.integration.order.entity.OrderChangeEntity; import com.alibaba.cloud.integration.order.entity.OrderChangeEntity;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity; import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import com.alibaba.cloud.integration.order.service.WorkbenchService; import com.alibaba.cloud.integration.order.service.WorkbenchService;
...@@ -16,6 +20,7 @@ import org.springframework.stereotype.Service; ...@@ -16,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
...@@ -28,6 +33,9 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -28,6 +33,9 @@ public class WorkbenchServiceImpl implements WorkbenchService {
@Autowired @Autowired
private OrderRequestDao orderRequestDao; private OrderRequestDao orderRequestDao;
@Autowired
private OrderAppointmentDao orderAppointmentDao;
@Override @Override
public Result<?> getOrderChangeList(WorkbenchOrderChangeListReqDTO orderChangeListReqDTO) { public Result<?> getOrderChangeList(WorkbenchOrderChangeListReqDTO orderChangeListReqDTO) {
Pageable pageable = PageRequest.of(orderChangeListReqDTO.getPage() - 1, orderChangeListReqDTO.getSize()); Pageable pageable = PageRequest.of(orderChangeListReqDTO.getPage() - 1, orderChangeListReqDTO.getSize());
...@@ -61,4 +69,46 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -61,4 +69,46 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.setContent(contents); .setContent(contents);
return Result.success(resp); return Result.success(resp);
} }
@Override
public Result<?> getEngineersGanttList(WorkbenchEngineersGanttReqDTO ganttReqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
List<?> orderAppointments = orderAppointmentDao.findByDateAndEngineerCodeIn(ganttReqDTO.getDate(), ganttReqDTO.getEngineerCodes());
HashMap<String, List<?>> mapEngineers = new HashMap<>();
for (Object e : orderAppointments) {
OrderAppointmentEntity entity = (OrderAppointmentEntity) e;
if (!mapEngineers.containsKey(entity.getEngineerCode())) {
mapEngineers.put(entity.getEngineerCode(), new ArrayList<>());
}
WorkbenchEngineersGanttRespDTO.Timeline timeline = new WorkbenchEngineersGanttRespDTO.Timeline();
timeline.setStartTime(entity.getStartTime().toString()).setEndTime(entity.getEndTime().toString())
.setServiceOrderId(entity.getOrderId()).setServiceOrderStatus(entity.getStatus());
timeline.setTips(getOrderTips(entity.getOrderId()));
}
List<WorkbenchEngineersGanttRespDTO.GanttChart> engineers = new ArrayList<>();
for (String e : mapEngineers.keySet()) {
WorkbenchEngineersGanttRespDTO.GanttChart engineer = new WorkbenchEngineersGanttRespDTO.GanttChart();
engineer.setEngineerCode(e);
engineer.setStartTime(String.format("%s 00:00", ganttReqDTO.getDate())).setEndTime(String.format("%s 23:59", ganttReqDTO.getDate()));
engineer.setHoliday(false); // todo
engineer.setTimeline(mapEngineers.get(e));
// engineer.setErrorTip(); todo
engineers.add(engineer);
}
WorkbenchEngineersGanttRespDTO data = new WorkbenchEngineersGanttRespDTO().setDate(ganttReqDTO.getDate()).setEngineers(engineers);
return Result.success(data);
}
private List<?> getOrderTips(String orderId) {
OrderRequestEntity order = orderRequestDao.getByOrderId(orderId);
List<WorkbenchEngineersGanttRespDTO.Tip> tips = new ArrayList<>();
tips.add(new WorkbenchEngineersGanttRespDTO.Tip().setTitle("类型/品牌").setDesc(String.format("%s %s", order.getBrand(), order.getType())));
tips.add(new WorkbenchEngineersGanttRespDTO.Tip().setTitle("电话/地址").setDesc(String.format("%s %s\n %s", order.getName(), order.getPhone(), order.getAddress())));
if (!order.getApplyNote().isBlank()) {
tips.add(new WorkbenchEngineersGanttRespDTO.Tip().setTitle("备注").setDesc(order.getApplyNote()));
}
tips.add(new WorkbenchEngineersGanttRespDTO.Tip().setTitle("标签").setDesc(order.getTags()));
return tips;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!