Commit 15e1d11b by chamberone

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

…oject.git into develop
2 parents b78322c4 da048815
Showing with 685 additions and 437 deletions
package com.dituhui.pea.order.common;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.entity.*;
import lombok.Data;
......@@ -9,14 +8,19 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
......@@ -24,55 +28,37 @@ import java.util.stream.Collectors;
public class OrderAssignCheck {
@Autowired
SkillInfoMPDao skillInfoMPDao;
private SkillInfoDao skillInfoDao;
@Autowired
EngineerBusinessMPDao engineerBusinessMPDao;
private EngineerBusinessDao engineerBusinessDao;
@Autowired
EngineerInfoMPDao engineerInfoMPDao;
private EngineerInfoDao engineerInfoDao;
@Autowired
OrgGroupMPDao orgGroupMPDao;
private OrgGroupDao orgGroupDao;
@Autowired
OrderInfoMPDao orderInfoMPDao;
private OrderInfoDao orderInfoDao;
@Data
public class Result {
private Boolean canAssign;
private String message;
private int minuteAddition;
private int distanceAddition;
private LocalDateTime start;
private LocalDateTime end;
private int index;
public Result(boolean canAssign, String message, int minuteAddition, int distanceAddition, LocalDateTime start, LocalDateTime end, int index){
this.canAssign = canAssign;
this.message = message;
this.minuteAddition = minuteAddition;
this.distanceAddition = distanceAddition;
this.start = start;
this.end = end;
this.index = index;
}
}
@Autowired
private EntityManager entityManager;
public Result orderAssignCheck(String orderId, String engineerCode) {
public Result orderAssignCheck(String orderId, LocalDate dt, String engineerCode) {
log.info("begin orderAssignCheck:orderId={}, engineerCode={}", orderId, engineerCode);
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderIdAndDt(orderId, dt);
double curX = Double.parseDouble(order.getX());
double curY = Double.parseDouble(order.getY());
// 获取技能需要的时长(分钟)
SkillInfo skillInfo = skillInfoMPDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill());
SkillInfoEntity skillInfo = skillInfoDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill());
int takeTime = skillInfo.getTakeTime();
// 获取客户期望时间段
int start = this.timestamp2Point(order.getExpectTimeBegin());
int end = this.timestamp2Point(order.getExpectTimeEnd());
int start = this.timestamp2Point(Timestamp.valueOf(order.getExpectTimeBegin()));
int end = this.timestamp2Point(Timestamp.valueOf(order.getExpectTimeEnd()));
log.info("客户期望的时间段:{}-{}, 技能所需时长:{}, 坐标:{},{}", start, end, takeTime, curX, curY);
// 获取技术员的已分配订单的时间段, 根据时间段排序
......@@ -84,18 +70,20 @@ public class OrderAssignCheck {
int index = SegmentInsertion.insertSegment(takeTime, start, end, segments);
if (index == -1) {
log.info("没有可连续插入的空间");
return new Result(false, "没有连续可插入空间(没计算时间)", 0, 0, null, null, index);
return new Result(-1, false, false, orderId, null,0,0, null, null, null);
}
log.info("插入位置为第{}单, 已分配单数(不包含本单):{}", index, orderSegments.size());
// 计算距离 & 时间
if(index == 0 && orderSegments.isEmpty()) {
if (index == 0 && orderSegments.isEmpty()) {
// 第一订单为出发地, 没有其他订单
// 技术员出发地
double[] location = this.getEngineerDepartureLocation(engineerCode);
double preX = location[0];
double preY = location[1];
OrderSegment pre = new OrderSegment(480, 480, preX, preY);
OrderSegment pre = new OrderSegment(480, 480, preX, preY, 0, 0, 0);
Pair p = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
// 最早可插入位置为技术员出发时间+行程时间
......@@ -106,21 +94,29 @@ public class OrderAssignCheck {
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
}
else if(index == 0 && !orderSegments.isEmpty()) {
// 当前节点信息
OrderNode curOrder = new OrderNode();
curOrder.setOrderId(orderId);
curOrder.setArriveElapsed(p.getDuration());
curOrder.setArriveDistance(p.getDistance());
curOrder.setTakeTime(takeTime);
curOrder.setPlanStartTime(startDateTime);
curOrder.setPlanEndTime(endDateTime);
return new Result(index, true, true, orderId, "", p.getDistance(), p.getDuration(), curOrder, null, null);
} else if (index == 0 && !orderSegments.isEmpty()) {
// 第一订单为出发地, 且有其他订单
double[] location = this.getEngineerDepartureLocation(engineerCode);
double preX = location[0];
double preY = location[1];
OrderSegment pre = new OrderSegment(480, 480, preX, preY, 0, 0, 0);
OrderSegment cur = new OrderSegment(-1, -1, curX, curY, takeTime, -1, -1);
OrderSegment post = orderSegments.get(0);
OrderSegment pre = new OrderSegment(480, 480, preX, preY);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
}
else if(index == orderSegments.size()) {
// 最后一个订单出发
OrderSegment pre = orderSegments.get(index-1);
return this.getResult(index, cur, pre, post, order.getDt());
} else if (index == orderSegments.size()) {
// 有其他订单,最后一个订单出发
OrderSegment pre = orderSegments.get(index - 1);
Pair p = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
// 最早可插入位置为技术员上一单出发时间+行程时间
int startPos = pre.getEnd() + p.getDuration();
......@@ -129,83 +125,134 @@ public class OrderAssignCheck {
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
// 当前节点信息
OrderNode curOrder = new OrderNode();
curOrder.setOrderId(orderId);
curOrder.setArriveElapsed(p.getDuration());
curOrder.setArriveDistance(p.getDistance());
curOrder.setTakeTime(takeTime);
curOrder.setPlanStartTime(startDateTime);
curOrder.setPlanEndTime(endDateTime);
return new Result(index, false, true, orderId, "", p.getDistance(), p.getDuration(), curOrder, null, null);
} else {
OrderSegment pre = orderSegments.get(index-1);
// 插入中间位置
OrderSegment pre = orderSegments.get(index - 1);
OrderSegment cur = new OrderSegment(-1, -1, curX, curY, takeTime, -1, -1);
OrderSegment post = orderSegments.get(index);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
return this.getResult(index, cur, pre, post, order.getDt());
}
}
private List<OrderSegment> getEngineerOrderSegments(String engineerCode, LocalDate dt) {
List<OrderSegment> orderSegments = new ArrayList<>();
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, dt);
lqw.eq(OrderInfo::getEngineerCode, engineerCode);
lqw.eq(OrderInfo::getOrderStatus, "NORMAL");
lqw.in(OrderInfo::getAppointmentStatus, List.of("PRE", "CONFIRM"));
List<OrderInfo> appointments = orderInfoMPDao.selectList(lqw);
if(appointments.isEmpty()){
List<String> appointmentStatusList = Arrays.asList("PRE", "CONFIRM");
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<OrderInfoEntity> criteriaQuery = criteriaBuilder.createQuery(OrderInfoEntity.class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
Predicate dtPredicate = criteriaBuilder.equal(root.get("dt"), dt);
Predicate engineerCodePredicate = criteriaBuilder.equal(root.get("engineerCode"), engineerCode);
Predicate orderStatusPredicate = criteriaBuilder.equal(root.get("orderStatus"), "NORMAL");
Predicate appointmentStatusPredicate = root.get("appointmentStatus").in(appointmentStatusList);
criteriaQuery.where(dtPredicate, engineerCodePredicate, orderStatusPredicate, appointmentStatusPredicate);
List<OrderInfoEntity> appointments = entityManager.createQuery(criteriaQuery).getResultList();
if (appointments.isEmpty()) {
return orderSegments;
}
for(OrderInfo o: appointments) {
for (OrderInfoEntity o : appointments) {
OrderSegment seg = new OrderSegment();
seg.setOrderId(o.getOrderId());
seg.setX(Double.parseDouble(o.getX()));
seg.setY(Double.parseDouble(o.getY()));
seg.setStart(this.timestamp2Point(o.getPlanStartTime()));
seg.setEnd(this.timestamp2Point(o.getPlanEndTime()));
seg.setStart(this.timestamp2Point(Timestamp.valueOf(o.getPlanStartTime())));
seg.setEnd(this.timestamp2Point(Timestamp.valueOf(o.getPlanEndTime())));
seg.setElapsed(o.getArriveElapsed());
seg.setDistance(o.getArriveDistance());
orderSegments.add(seg);
}
return orderSegments.stream().sorted(Comparator.comparing(OrderSegment::getStart)).collect(Collectors.toList());
}
private List<SegmentInsertion.Segment> orderSegment2Segment(List<OrderSegment> orderSegments) {
List<SegmentInsertion.Segment> segments = new ArrayList<>();
for (OrderSegment s: orderSegments) {
for (OrderSegment s : orderSegments) {
segments.add(new SegmentInsertion.Segment(s.getOrderId(), s.getStart(), s.getEnd()));
}
return segments;
}
private Result getResult(double curX, double curY, OrderSegment pre, OrderSegment post, int takeTime, LocalDate dt, int index) {
Pair preCurPair = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
Pair postCurPair = this.getDistanceAndDuration(post.getX(), post.getY(), curX, curY);
private Result getResult(int index, OrderSegment cur, OrderSegment pre, OrderSegment post, LocalDate dt) {
Pair preCurPair = this.getDistanceAndDuration(pre.getX(), pre.getY(), cur.getX(), cur.getY());
Pair postCurPair = this.getDistanceAndDuration(post.getX(), post.getY(), cur.getX(), cur.getY());
Pair prePostPair = this.getDistanceAndDuration(post.getX(), post.getY(), pre.getX(), pre.getY());
log.info("pre-cur{}, post-cur:{}, pre-post:{}", preCurPair, postCurPair, prePostPair);
// 判断增加时间+距离后,时间是否重叠了
int distance = post.getStart() - postCurPair.getDuration() - (pre.getEnd() + preCurPair.getDuration());
if(distance < takeTime) {
if (distance < cur.getTakeTime()) {
// 不支持插入
return new Result(false, "增加时间路程后,不支持插入", 0, 0, null, null, index);
return new Result(-1, false, false, "", "", 0, 0, null, null, null);
}
// 插入点(时间点)
int startInsert = pre.getEnd() + preCurPair.getDuration();
int endInsert = startInsert + takeTime;
int endInsert = startInsert + cur.getTakeTime();
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, dt);
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, dt);
int minuteAddition = preCurPair.getDuration() + postCurPair.getDuration() - prePostPair.getDuration();
int distanceAddition = preCurPair.getDistance() + postCurPair.getDistance() - prePostPair.getDistance();
return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime, index);
// 当前节点
OrderNode curOrder = new OrderNode();
curOrder.setOrderId(cur.getOrderId());
curOrder.setArriveElapsed(cur.getElapsed());
curOrder.setArriveDistance(cur.getDistance());
curOrder.setTakeTime(cur.getTakeTime());
curOrder.setPlanStartTime(startDateTime);
curOrder.setPlanEndTime(endDateTime);
//后一个节点最新变更情况
OrderNode postOrder = new OrderNode();
postOrder.setOrderId(post.getOrderId());
postOrder.setTakeTime(post.getTakeTime());
postOrder.setPlanStartTime(this.point2LocalDateTime(post.getStart(), dt));
postOrder.setPlanEndTime(this.point2LocalDateTime(post.getEnd(), dt));
postOrder.setArriveDistance(postCurPair.getDistance());
postOrder.setArriveElapsed(postCurPair.getDuration());
// 后一个节点之前的情况
OrderNode postOrderOrg = new OrderNode();
postOrder.setOrderId(post.getOrderId());
postOrder.setTakeTime(post.getTakeTime());
postOrder.setPlanStartTime(this.point2LocalDateTime(post.getStart(), dt));
postOrder.setPlanEndTime(this.point2LocalDateTime(post.getEnd(), dt));
postOrder.setArriveDistance(post.getDistance());
postOrder.setArriveElapsed(post.getElapsed());
int additionDistance = preCurPair.getDistance() + postCurPair.getDistance() - prePostPair.getDistance();
int additionElapsed = preCurPair.getDuration() + postCurPair.getDuration() - prePostPair.getDuration();
return new Result(index, false, false, cur.getOrderId(), post.getOrderId(), additionDistance, additionElapsed, curOrder, postOrder, postOrderOrg);
}
private double[] getEngineerDepartureLocation(String engineerCode){
private double[] getEngineerDepartureLocation(String engineerCode) {
// 获取技术员出发坐标
// 从技术员配置中获取
EngineerBusiness b = engineerBusinessMPDao.getByEngineerCode(engineerCode);
if( b != null && StringUtils.isNotEmpty(b.getX()) && StringUtils.isNotEmpty(b.getY())){
EngineerBusinessEntity b = engineerBusinessDao.getByEngineerCode(engineerCode);
if (b != null && StringUtils.isNotEmpty(b.getX()) && StringUtils.isNotEmpty(b.getY())) {
return new double[]{Double.parseDouble(b.getX()), Double.parseDouble(b.getY())};
}
//从org_group中获取
EngineerInfo e = engineerInfoMPDao.getByEngineerCode(engineerCode);
OrgGroup g = orgGroupMPDao.getByGroupId(e.getGroupId());
EngineerInfoEntity e = engineerInfoDao.getByEngineerCode(engineerCode);
OrgGroupEntity g = orgGroupDao.getByGroupId(e.getGroupId());
return new double[]{Double.parseDouble(g.getX()), Double.parseDouble(g.getY())};
}
......@@ -224,40 +271,82 @@ public class OrderAssignCheck {
return LocalDateTime.of(dt, this.point2LocalTime(point));
}
private Pair getDistanceAndDuration(double x1, double y1, double x2, double y2){
Distance cal= new Distance();
private Pair getDistanceAndDuration(double x1, double y1, double x2, double y2) {
Distance cal = new Distance();
long distance = Math.round(cal.calculateDistance(x1, y1, x2, y2) * 1.4); // 单位为米
long duration = distance / (19 * 1000 / 60); // 时间为分钟,假设电动车速度为19km/h
return new Pair((int)distance, (int)duration);
return new Pair((int) distance, (int) duration);
}
@Data
public static class OrderNode {
private String orderId;
private LocalDateTime planStartTime;
private LocalDateTime planEndTime;
private int takeTime;
private int arriveDistance;
private int arriveElapsed;
}
@Data
public class Result {
private int index;
private boolean isHead;
private boolean isTail;
private String curOrderId;
private String postOrderId;
private int additionDistance;
private int additionElapsed;
private OrderNode curOrderNode;
private OrderNode postOrderNode;
private OrderNode postOrderNodeOrg;
public Result(int index, boolean isHead, boolean isTail, String curOrderId, String postOrderId, int additionDistance, int additionElapsed, OrderNode curOrderNode, OrderNode postOrderNode, OrderNode postOrderNodeOrg) {
this.index = index;
this.isHead = isHead;
this.isTail = isTail;
this.curOrderId = curOrderId;
this.postOrderId = postOrderId;
this.additionDistance = additionDistance;
this.additionElapsed = additionElapsed;
this.curOrderNode = curOrderNode;
this.postOrderNode = postOrderNode;
this.postOrderNodeOrg = postOrderNodeOrg;
}
}
}
@Data
class OrderSegment{
class OrderSegment {
private String orderId;
private int start;
private int end;
private double x;
private double y;
private int takeTime;
private int elapsed;
private int distance;
public OrderSegment(){
public OrderSegment() {
}
public OrderSegment(int start, int end, double x, double y){
public OrderSegment(int start, int end, double x, double y, int takeTime, int elapsed, int distance) {
this.start = start;
this.end = end;
this.x = x;
this.y = y;
this.takeTime = takeTime;
this.elapsed = elapsed;
this.distance = distance;
}
}
@Data
class Pair{
class Pair {
private int distance;
private int duration;
public Pair(int distance, int duration){
public Pair(int distance, int duration) {
this.distance = distance;
this.duration = duration;
}
......
......@@ -2,13 +2,13 @@ package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.CalendarDetailDTO;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.service.EngineerCalendarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -46,11 +46,54 @@ public class EngineerCalendarController {
public Result<?> getCalendarPlanDetail(@Validated CalendarDetailDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.getCalendarPlanDetail(reqDTO);
res = engineerCalendarService.getPlanDetail(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/calendar/plan/update")
public Result<?> updateCalendarPlan(@Validated CalendarUpdateDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.updatePlan(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/calendar/plan/delete")
public Result<?> deleteCalendarPlan(@Validated CalendarDeleteDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.deletePlan(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/calendar/batch/add")
public Result<?> BatchAddPlan(@Validated CalendarBatAddDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.batchAddPlan(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@GetMapping("/engineer/calendar/plan/num")
public Result<?> getEngineerPlanNum(@Validated CalendarQueryNumDTO.Request reqDTO) {
Result<?> res = null;
try {
res = engineerCalendarService.queryEngineerPlanNum(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
......@@ -4,10 +4,17 @@ import com.dituhui.pea.order.entity.CapacityEngineerCalendarEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
public interface CapacityEngineerCalendarDao extends JpaRepository<CapacityEngineerCalendarEntity, Integer> {
@Query("select a from CapacityEngineerCalendarEntity a where a.engineerCode=:engineerCode and a.workday between :beginDate and :endDate")
List<CapacityEngineerCalendarEntity> findCalendarByEngineerCodeAndDateBetween(String engineerCode, String beginDate, String endDate);
CapacityEngineerCalendarEntity getByPlanId(String planId);
@Query("select count(*) from CapacityEngineerCalendarEntity a where a.type = :type and a.startTime >= :startDate and a.endTime <= :endDate and a.engineerCode in :engineers")
Integer queryEngineerPlanNum(List<String> engineers, LocalDateTime startDate, LocalDateTime endDate, String type);
}
......@@ -10,13 +10,12 @@ import java.util.List;
public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long> {
OrderInfoEntity getByOrderId(String orderId);
OrderInfoEntity getByOrderIdAndDt(String orderId, LocalDate dt);
List<OrderInfoEntity> findByOrderId(String orderId);
List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode);
@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);
List<OrderInfoEntity> findAllByDtAndOrderIdIn(LocalDate dt, List<String> orderIds);
List<OrderInfoEntity> findByEngineerCodeAndDtAndAppointmentStatusIn(String engineerCode, LocalDate dt, List<String> appointmentStatus);
}
......@@ -15,6 +15,8 @@ public interface OrgGroupDao extends JpaRepository<OrgGroupEntity, Integer> {
List<OrgGroupEntity> findAllByClusterId(String clusterId);
List<OrgGroupEntity> findAllByGroupId(String groupId);
OrgGroupEntity getByGroupId(String groupId);
public List<OrgGroupEntity> findByGroupIdIn(List<String> ids);
......
......@@ -22,6 +22,9 @@ public interface OrgTeamDao extends JpaRepository<OrgTeamEntity, Integer> {
@Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1")
List<OrgTeamEntity> findAllByGroupId(String groupId);
@Query("select t from OrgTeamEntity t where t.teamId = :teamId and t.status=1")
List<OrgTeamEntity> findAllByTeamId(String teamId);
@Query("select t from OrgTeamEntity t where t.groupId = :groupId and t.status=1")
Page<OrgTeamEntity> findAllByGroupId(String groupId, Pageable pageable);
......
......@@ -23,4 +23,6 @@ public interface WarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntity,
OrgWarehouseInfoEntity getOrgWarehouseInfoEntityByWarehouseId(String wareHouseId);
List<OrgWarehouseInfoEntity> findByBranchId(String branchId);
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
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 lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
import static com.dituhui.pea.order.config.OrderConfig.DEFAULT_PAGE_SIZE;
......@@ -44,10 +39,8 @@ public class BusinessSkillListDTO {
public static class Content {
private String brand;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
private String createTime;
private Boolean gasCert;
private String layerId;
private String layerName;
......@@ -64,9 +57,7 @@ public class BusinessSkillListDTO {
private String type;
private String typeCategory;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String updateTime;
}
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
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 lombok.experimental.Accessors;
import java.time.LocalDateTime;
public class CalendarDetailDTO {
@lombok.Data
......@@ -30,20 +24,14 @@ public class CalendarDetailDTO {
private String type;
private String typeName;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
private String startTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
private String endTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String updateTime;
}
}
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.List;
public class CalendarQueryNumDTO {
@lombok.Data
public static class Request {
private String code;
private String message;
private Result result;
private List<String> engineerCodes;
private String type;
@JsonFormat(pattern = "yyyy-MM-dd")
private String startDate;
@JsonFormat(pattern = "yyyy-MM-dd")
private String endDate;
}
@lombok.Data
......
package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
public class CapacityAdjustDTO {
......@@ -20,15 +13,11 @@ public class CapacityAdjustDTO {
@NotNull(message = "teamId不能为空")
private String teamId;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate;
private String startDate;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate;
private String endDate;
private Integer capAdjust;
}
......
package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.config.OrderConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
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 lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
......@@ -54,10 +51,8 @@ public class CapacityStatQueryDTO {
private long capUsed;
private long capLeft;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String updateTime;
private String date;
private long engineerNum;
......@@ -67,7 +62,7 @@ public class CapacityStatQueryDTO {
private String showName;
public Content(){
updateTime = LocalDateTime.now();
updateTime = DateUtils.formatDateTime(LocalDateTime.now());
}
}
}
......@@ -4,13 +4,8 @@ package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.config.OrderConfig;
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.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import lombok.experimental.Accessors;
import java.time.LocalDate;
import java.util.List;
......@@ -25,10 +20,8 @@ public class EngineersGanttDTO {
private Integer page = OrderConfig.DEFAULT_PAGE_INDEX;
private Integer size = OrderConfig.DEFAULT_PAGE_SIZE;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate date;
private String date;
private List<String> engineerCodes;
private List<String> branchIds;
private List<String> groupIds;
......
......@@ -3,14 +3,9 @@ package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.config.OrderConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
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 lombok.experimental.Accessors;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATE;
......@@ -30,7 +25,7 @@ public class OrderChangeListDTO {
private String levelValue;
private int page = OrderConfig.DEFAULT_PAGE_INDEX;
private int size = OrderConfig.DEFAULT_PAGE_SIZE;
private String date = DateUtils.formatDate(LocalDate.now(), PATTERN_DATE);
private String date = DateUtils.formatDate(LocalDate.now());
/**
* 排序
*/
......@@ -73,9 +68,7 @@ public class OrderChangeListDTO {
/**
* 更新时间
*/
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String updateTime;
}
}
......@@ -27,6 +27,10 @@ public class CapacityEngineerCalendarEntity {
@Column(name = "end_time", nullable = false)
private LocalDateTime endTime;
@Column(name = "plan_id")
private String planId;
@Column(nullable = false)
private String type;
......
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.CalendarDetailDTO;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.dto.*;
public interface EngineerCalendarService {
......@@ -10,5 +9,13 @@ public interface EngineerCalendarService {
Result<?> getCalendarTypeList();
Result<?> getCalendarPlanDetail(CalendarDetailDTO.Request reqDTO);
Result<?> getPlanDetail(CalendarDetailDTO.Request reqDTO);
Result<?> updatePlan(CalendarUpdateDTO.Request reqDTO);
Result<?> deletePlan(CalendarDeleteDTO.Request reqDTO);
Result<?> batchAddPlan(CalendarBatAddDTO.Request reqDTO);
Result<?> queryEngineerPlanNum(CalendarQueryNumDTO.Request reqDTO);
}
......@@ -5,9 +5,7 @@ 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.CalendarDetailDTO;
import com.dituhui.pea.order.dto.CalendarTypeDTO;
import com.dituhui.pea.order.dto.EngineerCalendarDTO;
import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.CapacityEngineerCalendarEntity;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
......@@ -99,8 +97,8 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
}
@Override
public Result<?> getCalendarPlanDetail(CalendarDetailDTO.Request reqDTO) {
CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getById(Integer.parseInt(reqDTO.getPlanId()));
public Result<?> getPlanDetail(CalendarDetailDTO.Request reqDTO) {
CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getByPlanId(reqDTO.getPlanId());
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(entity.getEngineerCode());
CalendarDetailDTO.Result rs = new CalendarDetailDTO.Result();
rs.setPlanId(entity.getId().toString());
......@@ -108,11 +106,71 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
rs.setEngineerName(engineerInfo.getName());
rs.setType(entity.getType());
rs.setTypeName(entity.getReason());
rs.setStartTime(entity.getStartTime());
rs.setEndTime(entity.getEndTime());
rs.setStartTime(DateUtils.formatDateTime(entity.getStartTime()));
rs.setEndTime(DateUtils.formatDateTime(entity.getEndTime()));
return Result.success(rs);
}
@Override
public Result<?> updatePlan(CalendarUpdateDTO.Request reqDTO) {
CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getByPlanId(reqDTO.getPlanId());
if (entity == null) {
return Result.failed("日历配置信息不存在");
}
// todo 业务检查,暂时只需要检查日期时间必须为将来; 后面还需要检查配置项是否与其他配置项在时间上有交叉
LocalDateTime time1 = fixFrontDatetime(reqDTO.getStartTime());
LocalDateTime time2 = fixFrontDatetime(reqDTO.getEndTime());
if (time1.isAfter(time2)) {
return Result.failed("开始/结束时间输入错误");
}
if (time1.isBefore(LocalDateTime.now()) || time2.isBefore(LocalDateTime.now())) {
return Result.failed("只能更新未来时间");
}
entity.setStartTime(time1);
entity.setEndTime(time2);
entity.setMemo(reqDTO.getRemark());
// todo 操作员信息
capacityEngineerCalendarDao.save(entity);
return Result.success(null);
}
@Override
public Result<?> deletePlan(CalendarDeleteDTO.Request reqDTO) {
CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getByPlanId(reqDTO.getPlanId());
if (entity == null) {
return Result.failed("日历配置信息不存在");
}
capacityEngineerCalendarDao.delete(entity);
return Result.success(null);
}
@Override
public Result<?> batchAddPlan(CalendarBatAddDTO.Request reqDTO) {
if (reqDTO.getIsAllday() == 1) {
// 如果是全天只需要填写日期yyyy-MM-dd;否则填写日期+时间 yyyy-MM-dd HH:mm
}
return null;
}
@Override
public Result<?> queryEngineerPlanNum(CalendarQueryNumDTO.Request reqDTO) {
if (reqDTO.getEngineerCodes().isEmpty()) {
return Result.failed("没有选中工程师");
}
LocalDateTime startDate = LocalDate.parse(reqDTO.getStartDate()).atTime(LocalTime.MIDNIGHT);
LocalDateTime endDate = LocalDate.parse(reqDTO.getEndDate()).atTime(LocalTime.MIDNIGHT);
Integer num = capacityEngineerCalendarDao.queryEngineerPlanNum(reqDTO.getEngineerCodes(), startDate, endDate, reqDTO.getType());
CalendarQueryNumDTO.Result rs = new CalendarQueryNumDTO.Result();
rs.setPlanNum(num);
return Result.success(rs);
}
private LocalDateTime fixFrontDatetime(String s) {
return LocalDateTime.parse(s);
}
private List<EngineerCalendarDTO.Calendar> getOneEngineerCalendars(String engineerCode, String bdate, String edate) {
// 返回某一个技术员,日期范围内的日历列表
......@@ -139,6 +197,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
// 有配置
for (CapacityEngineerCalendarEntity e : configs.get(sDate)) {
EngineerCalendarDTO.Content content = new EngineerCalendarDTO.Content();
content.setPlanId(e.getPlanId());
content.setType("LEAVE");
content.setTitle(e.getType());
content.setValue(getCalendarDuration(e.getStartTime(), e.getEndTime()));
......@@ -186,17 +245,11 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
calendar.setWeek(DateUtils.toWeekChinese(dayOfWeek));
EngineerCalendarDTO.Content content = new EngineerCalendarDTO.Content();
List<String> workdays = Arrays.asList(e.getWorkdays().split(","));
if (workdays.contains(String.valueOf(dayOfWeek))) {
content.setType("WORKING");
content.setTitle(String.format("%s-%s", e.getWorkOn(), e.getWorkOff()));
content.setValue(getCalendarDuration(e.getWorkOn(), e.getWorkOff()));
} else {
if (!workdays.contains(String.valueOf(dayOfWeek))) {
content.setType("REST");
content.setTitle("休息");
}
calendar.setContent(Collections.singletonList(content));
return calendar;
}
}
......@@ -13,6 +13,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
......@@ -46,13 +47,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log.info("getEngineersGanttList: {}", reqDTO);
List<String> engineerCodes = reqDTO.getEngineerCodes();
if (engineerCodes == null || engineerCodes.size() == 0) {
if (engineerCodes == null || engineerCodes.isEmpty()) {
// 需要根据levelType/levelValue/brandIds/branchIds/groupIds/teamIds/key,后端查询匹配
engineerCodes = findEngineers(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getBranchIds(), reqDTO.getGroupIds(), reqDTO.getTeamIds(), reqDTO.getKey());
log.info("根据多条件,查询返回符合条件的技术员列表:{}", engineerCodes);
}
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(reqDTO.getDate(), engineerCodes);
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(LocalDate.parse(reqDTO.getDate()), engineerCodes);
HashMap<String, List<EngineersGanttDTO.Slot>> mapEngineers = new HashMap<>();
for (OrderInfoEntity order : orders) {
// 服务工单本体
......@@ -117,7 +118,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByWorkdayAndEngineerCode(DateUtils.formatDate(reqDTO.getDate()), engineerCode);
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByWorkdayAndEngineerCode(reqDTO.getDate(), engineerCode);
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else {
......@@ -133,7 +134,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
engineers.sort(Comparator.comparing(EngineersGanttDTO.GanttChart::getEngineerName));
EngineersGanttDTO.Result res = new EngineersGanttDTO.Result();
res.setDate(DateUtils.formatDate(reqDTO.getDate())).setEngineers(engineers);
res.setDate(reqDTO.getDate()).setEngineers(engineers);
return Result.success(res);
}
......
......@@ -11,6 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -21,19 +27,19 @@ import java.util.stream.Stream;
public class EngineerTimelineServiceImpl implements EngineerTimelineService {
@Autowired
private OrderInfoMPDao orderInfoMPDao;
private OrderInfoDao orderInfoDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private EngineerInfoDao engineerInfoDao;
@Autowired
private WarehouseInfoMPDao warehouseInfoMPDao;
private WarehouseInfoDao warehouseInfoDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
private OrgGroupDao orgGroupDao;
@Autowired
private OrderEventMPDao orderEventMPDao;
private EntityManager entityManager;
@Transactional
@Override
......@@ -42,14 +48,14 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
// 工程師信息
EngineerInfo engineerInfo = engineerInfoMPDao.getByEngineerCode(engineerCode);
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
// 获取工程师date日的订单数据
List<OrderInfo> orders = this.selectEngineerOrders(engineerCode, localDate);
List<OrderInfoEntity> orders = this.selectEngineerOrders(engineerCode, localDate);
// 获取工程师已完成的timeline数据
List<String> orderIds = orders.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<OrderEvent> timelines = this.engineerTimelines(orderIds, date);
List<String> orderIds = orders.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
List<OrderEventEntity> timelines = this.engineerTimelines(orderIds, date);
// 获取客户地址
HashMap<String, String> orderLocations = this.orderRequestsLocation(orders);
......@@ -67,30 +73,39 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
return Result.success(res);
}
private List<OrderInfo> selectEngineerOrders(String engineerCode, LocalDate dt){
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, dt);
lqw.eq(OrderInfo::getEngineerCode, engineerCode);
lqw.ne(OrderInfo::getAppointmentStatus, "INIT");
lqw.ne(OrderInfo::getOrderStatus, "CANCEL");
return orderInfoMPDao.selectList(lqw);
private List<OrderInfoEntity> selectEngineerOrders(String engineerCode, LocalDate dt){
List<OrderInfoEntity> orders = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineerCode, dt, List.of("PRE", "CONFIRM"));
return orders.stream().filter(o -> !o.getOrderStatus().equals("CANCEL")).collect(Collectors.toList());
}
private List<OrderEvent> engineerTimelines(List<String> orderIds, String date){
// 获取工程师timeline
List<String> events = Stream.of("分站取还配件", "已出发", "加单").collect(Collectors.toList());
LambdaQueryWrapper<OrderEvent> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderEvent::getOrderId, orderIds);
lqw.ge(OrderEvent::getHappen, date+" 00:00:00");
lqw.le(OrderEvent::getHappen, date + " 23:59:59");
lqw.in(OrderEvent::getEvent, events);
return orderEventMPDao.selectList(lqw);
public List<OrderEventEntity> engineerTimelines(List<String> orderIds, String date) {
List<String> events = Arrays.asList("分站取还配件", "已出发", "加单");
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<OrderEventEntity> criteriaQuery = criteriaBuilder.createQuery(OrderEventEntity.class);
Root<OrderEvent> root = criteriaQuery.from(OrderEvent.class);
List<Predicate> predicates = new ArrayList<>();
predicates.add(root.get("orderId").in(orderIds));
predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("happen"), date + " 00:00:00"));
predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("happen"), date + " 23:59:59"));
predicates.add(root.get("event").in(events));
criteriaQuery.where(predicates.toArray(new Predicate[0]));
TypedQuery<OrderEventEntity> typedQuery = entityManager.createQuery(criteriaQuery);
List<OrderEventEntity> result = typedQuery.getResultList();
return result;
}
private HashMap<String, String> orderRequestsLocation(List<OrderInfo> orders) {
private HashMap<String, String> orderRequestsLocation(List<OrderInfoEntity> orders) {
// 获取客户地址location
HashMap<String, String> map = new HashMap<>();
for(OrderInfo o: orders){
for(OrderInfoEntity o: orders){
map.put(o.getOrderId(), String.format("%s,%s", o.getX(), o.getY()));
}
return map;
......@@ -98,38 +113,30 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
private String getWarehouseLocation(String branchId) {
// 获取配送站location
LambdaQueryWrapper<OrgWarehouseInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrgWarehouseInfo::getBranchId, branchId);
List<OrgWarehouseInfo> wares = warehouseInfoMPDao.selectList(lqw);
OrgWarehouseInfo w = wares.get(0);
List<OrgWarehouseInfoEntity> wares = warehouseInfoDao.findByBranchId(branchId);
OrgWarehouseInfoEntity w = wares.get(0);
return String.format("%s,%s", w.getX(), w.getY());
}
private String getEngineerBranchId(String engineerCode) {
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.select(EngineerInfo::getGroupId);
lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
EngineerInfo e = engineerInfoMPDao.selectOne(lqw);
EngineerInfoEntity e = engineerInfoDao.getByEngineerCode(engineerCode);
if (e == null) {
return "";
}
LambdaQueryWrapper<OrgGroup> lqw2 = new LambdaQueryWrapper<>();
lqw2.select(OrgGroup::getBranchId);
lqw2.eq(OrgGroup::getGroupId, e.getGroupId());
OrgGroup g = orgGroupMPDao.selectOne(lqw2);
OrgGroupEntity g = orgGroupDao.getByGroupId(e.getGroupId());
return (g==null)? "": g.getBranchId();
}
private List<EngineerTimelineResp.DynamicItem> packItems(List<OrderEvent> timelines, List<OrderInfo> orders, HashMap<String, String> locations, String warehouseLocation) {
private List<EngineerTimelineResp.DynamicItem> packItems(List<OrderEventEntity> timelines, List<OrderInfoEntity> orders,
HashMap<String, String> locations, String warehouseLocation) {
int index = 0;
String order_id, title, type, text, location;
List<EngineerTimelineResp.DynamicItem> items = new ArrayList<>();
Set<String> s = new HashSet<>();
for (OrderEvent t: timelines){
for (OrderEventEntity t: timelines){
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
if (t.getEvent().equals("分站取还配件")) {
......@@ -146,7 +153,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
continue;
}
item.setTitle(title);
item.setTime(TimeUtils.IsoTimestamp2DateTime(t.getHappen()));
item.setTime(TimeUtils.IsoLocalDateTime2String(t.getHappen()));
item.setStatus(1);
item.setText(text);
......@@ -157,8 +164,8 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
s.add(t.getOrderId() + t.getSuborderId());
}
List<OrderInfo> records = orders.stream().sorted(Comparator.comparing(OrderInfo::getPlanStartTime)).collect(Collectors.toList());
for(OrderInfo o: records){
List<OrderInfoEntity> records = orders.stream().sorted(Comparator.comparing(OrderInfoEntity::getPlanStartTime)).collect(Collectors.toList());
for(OrderInfoEntity o: records){
order_id = o.getOrderId() + o.getSubId();
if (s.contains(order_id)) {
continue;
......@@ -166,7 +173,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
index += 1;
EngineerTimelineResp.DynamicItem item = new EngineerTimelineResp.DynamicItem();
item.setTitle(String.format("第%d单出发", index));
item.setTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanStartTime()));
item.setTime(TimeUtils.IsoLocalDateTime2String(o.getPlanStartTime()));
item.setStatus(0);
item.setText(String.format("%d", index));
item.setLocation(locations.get(o.getOrderId()));
......
package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.OrderAssignCheck;
......@@ -19,6 +18,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
......@@ -30,64 +35,64 @@ import java.util.stream.Collectors;
public class OrderAssignImpl implements OrderAssign {
@Autowired
private OrderInfoMPDao orderInfoMPDao;
private OrderInfoDao orderInfoDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private EngineerInfoDao engineerInfoDao;
@Autowired
private CommonService commonService;
@Autowired
private OrderEventMPDao orderEventMPDao;
private OrderAssignCheck orderAssignCheck;
@Autowired
private OrderAssignCheck orderAssignCheck;
private OrgTeamDao orgTeamDao;
@Autowired
private OrgTeamMPDao orgTeamMPDao;
private OrgTeamEngineerDao orgTeamEngineerDao;
@Autowired
private OrgTeamEngineerMPDao orgTeamEngineerMPDao;
private SkillInfoDao skillInfoDao;
@Autowired
private SkillInfoMPDao skillInfoMPDao;
private EngineerSkillGroupDao engineerSkillGroupDao;
@Autowired
private EngineerSkillGroupMPDao engineerSkillGroupMPDao;
private EntityManager entityManager;
@Transactional
@Override
public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) {
// 服务单指派-推荐技术员列表
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
if (order == null) {
throw new BusinessException("订单不存在");
}
String date = TimeUtils.timestamp2DateTime(order.getExpectTimeBegin(), TimeUtils.DATE_GAP_FORMAT);
String date = TimeUtils.IsoLocalDate2String(order.getDt());
// 获取符合筛选条件的技术员
List<String> engineerCodes = this.searchEngineerCodes(order, distance, key, recommend);
List<EngineerInfo> engineers = engineerInfoMPDao.selectByEngineerCodes(engineerCodes);
List<EngineerInfoEntity> engineers = engineerInfoDao.findByEngineerCodeIn(engineerCodes);
List<OrderAssignRecommendResp.Engineer> items = new ArrayList<>();
for (EngineerInfo engineer : engineers) {
OrderAssignCheck.Result result = orderAssignCheck.orderAssignCheck(orderId, engineer.getEngineerCode());
for (EngineerInfoEntity engineer : engineers) {
OrderAssignCheck.Result result = orderAssignCheck.orderAssignCheck(orderId, order.getDt(), engineer.getEngineerCode());
log.info("指派检查结果:{}", result);
if (!result.getCanAssign()) {
if (result.getIndex() < 0) {
continue;
}
// 获取已技术员已指派订单列表
List<OrderInfo> orderAppointments = orderInfoMPDao.selectByEngineerCodeAndDtAndAppointmentStatus(engineer.getEngineerCode(), order.getDt(), "CONFIRM");
List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineer.getEngineerCode(), order.getDt(), List.of("CONFIRM"));
// 获取订单tips
HashMap<String, List<LabelValueDTO>> orderTips = new HashMap<>();
List<String> orderIds = orderAppointments.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<String> orderIds = orderAppointments.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
if (!orderIds.isEmpty()) {
List<OrderInfo> orders = orderInfoMPDao.selectByDtAndOrderIds(TimeUtils.IsoDate2LocalDate(date), orderIds);
List<OrderInfoEntity> orders = orderInfoDao.findAllByDtAndOrderIdIn(order.getDt(), orderIds);
orderTips = this.packOrderTips(orders);
}
......@@ -95,8 +100,8 @@ public class OrderAssignImpl implements OrderAssign {
OrderAssignRecommendResp.InsertInfo insertInfo = new OrderAssignRecommendResp.InsertInfo();
insertInfo.setNumber(String.format("%d/%d", result.getIndex(), orderAppointments.size() + 1));
insertInfo.setTimeDesc(String.format("+%d分钟", result.getMinuteAddition()));
insertInfo.setDistanceDesc(String.format("+%d公里", result.getDistanceAddition() / 1000));
insertInfo.setTimeDesc(String.format("+%d分钟", result.getAdditionElapsed()));
insertInfo.setDistanceDesc(String.format("+%d公里", result.getAdditionDistance() / 1000));
item.setEngineerCode(engineer.getEngineerCode());
item.setEngineerName(engineer.getName());
......@@ -106,7 +111,7 @@ public class OrderAssignImpl implements OrderAssign {
item.setTimeDesc("");
int index = result.getIndex() + 1;
item.setDesc(String.format("将被插入在第%d单,受此影响原第%d单变化第%d单,第%d单将增加%d公里路程,比预计晚到%d分钟,建议调整;", index, index, index + 1, index + 1, result.getDistanceAddition() / 1000, result.getMinuteAddition()));
item.setDesc(String.format("将被插入在第%d单,受此影响原第%d单变化第%d单,第%d单将增加%d公里路程,比预计晚到%d分钟,建议调整;", index, index, index + 1, index + 1, result.getAdditionDistance() / 1000, result.getAdditionElapsed()));
item.setStartTime(String.format("%s 08:00:00", date));
item.setEndTime(String.format("%s 18:00:00", date));
item.setOrders(this.packTimelines(orderAppointments, orderTips));
......@@ -124,15 +129,15 @@ public class OrderAssignImpl implements OrderAssign {
public Result<?> orderAssign(String orderId, String engineerCode) throws BusinessException {
// 服务单指派-指派提交
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
if (order == null) {
throw new BusinessException("订单不存在");
}
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(engineerCode);
boolean record = false;
OrderInfo op = orderInfoMPDao.getByOrderIdAndDt(orderId, order.getDt());
OrderInfoEntity op = orderInfoDao.getByOrderIdAndDt(orderId, order.getDt());
if (op != null) {
record = true;
}
......@@ -141,22 +146,22 @@ public class OrderAssignImpl implements OrderAssign {
throw new BusinessException(String.format("订单已指派个技术员[%s], 不必重复指派给同一个技术员", engineer.getName()));
}
OrderAssignCheck.Result result = orderAssignCheck.orderAssignCheck(orderId, engineerCode);
OrderAssignCheck.Result result = orderAssignCheck.orderAssignCheck(orderId, order.getDt(), engineerCode);
log.info("指派检查结果:{}", result);
if (!result.getCanAssign()) {
if (result.getIndex() < 0) {
throw new BusinessException("指派失败, 未能找到合适的时间段, 请选择其他技术员");
}
Timestamp planStartTime = Timestamp.valueOf(result.getStart());
Timestamp planEndTime = Timestamp.valueOf(result.getEnd());
OrderAssignCheck.OrderNode insertNode = result.getCurOrderNode();
Timestamp planStartTime = Timestamp.valueOf(insertNode.getPlanStartTime());
Timestamp planEndTime = Timestamp.valueOf(insertNode.getPlanEndTime());
// 更新order_info表状态
LambdaUpdateWrapper<OrderInfo> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(OrderInfo::getAppointmentStatus, "CONFIRM");
wrapper.set(OrderInfo::getAppointmentMethod, "MANUAL");
wrapper.set(OrderInfo::getPlanStartTime, planStartTime);
wrapper.set(OrderInfo::getPlanEndTime, planEndTime);
wrapper.eq(OrderInfo::getOrderId, orderId);
orderInfoMPDao.update(null, wrapper);
String sql = "UPDATE OrderInfo e SET e.appointmentStatus = 'CONFIRM', e.appointmentMethod='MANUAL', e.planStartTime = :planStartTime, e.planEndTime = :panEndTime WHERE e.orderId = :orderId";
Query query = entityManager.createQuery(sql);
query.setParameter("planStartTime", planStartTime);
query.setParameter("planEndTime", planEndTime);
query.setParameter("orderId", orderId);
query.executeUpdate();
// 工单变更登记
commonService.addOrderEvent(orderId, "", "PEA-WEB", "API", "工单指派", "工单指派", "");
......@@ -168,28 +173,18 @@ public class OrderAssignImpl implements OrderAssign {
public Result<?> orderRevokeAssign(String orderId) throws BusinessException {
// 放回工单池
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
if (order == null) {
throw new BusinessException("订单不存在");
}
// 更新order_request表为未指派
order.setAppointmentStatus("INIT");
orderInfoMPDao.updateById(order);
entityManager.merge(order);
// 操作员ID TODO-用户系统
// 登记事件
OrderEvent oe = new OrderEvent();
oe.setOrderId(orderId);
oe.setSuborderId("");
oe.setHappen(new Timestamp(System.currentTimeMillis()));
oe.setEvent("放回工单池");
oe.setOperator("123"); // 操作员ID TODO-用户系统
oe.setOperatorName("测试用户"); // 操作员姓名 TODO-用户系统
oe.setSource("PEA");
oe.setDescription("返回工单池");
oe.setMemo("");
oe.setCreateTime(new Timestamp(System.currentTimeMillis()));
orderEventMPDao.insert(oe);
commonService.addOrderEvent(orderId, "", "PEA-WEB", "123", "放回工单池", "放回工单池", "");
return Result.success(null);
}
......@@ -198,7 +193,7 @@ public class OrderAssignImpl implements OrderAssign {
public Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc) throws BusinessException {
// 工单改约接口(当前同放回工单池处理)
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
if (order == null) {
throw new BusinessException("订单不存在");
}
......@@ -211,32 +206,24 @@ public class OrderAssignImpl implements OrderAssign {
LocalDate originDate = order.getDt(); // 改约前的日期
// 更新order_request表为未指派
order.setAppointmentStatus("INIT");
order.setDt(expectBegin.toLocalDate());
order.setExpectTimeBegin(Timestamp.valueOf(expectBegin));
order.setExpectTimeEnd(Timestamp.valueOf(expectEnd));
order.setExpectTimeDesc(expectDesc);
orderInfoMPDao.updateById(order);
// 更新order_info表
String sql = "UPDATE OrderInfo e SET e.appointmentStatus = 'INIT', e.dt=:dt, e.expectTimeBegin = :expectTimeBegin, e.expectTimeEnd = :expectTimeEnd, e.expectTimeDesc = :expectTimeDesc WHERE e.orderId = :orderId";
Query query = entityManager.createQuery(sql);
query.setParameter("dt", expectBegin.toLocalDate());
query.setParameter("expectTimeBegin", expectBegin);
query.setParameter("expectTimeEnd", expectEnd);
query.setParameter("expectTimeDesc", expectDesc);
query.setParameter("orderId", orderId);
query.executeUpdate();
// 操作员ID TODO-用户系统
// 登记事件
OrderEvent oe = new OrderEvent();
oe.setOrderId(orderId);
oe.setSuborderId("");
oe.setHappen(new Timestamp(System.currentTimeMillis()));
oe.setEvent("已改约");
oe.setOperator("123"); // 操作员ID TODO-用户系统
oe.setOperatorName("测试用户"); // 操作员姓名 TODO-用户系统
oe.setSource("PEA");
oe.setDescription("已改约");
oe.setMemo("");
oe.setCreateTime(new Timestamp(System.currentTimeMillis()));
orderEventMPDao.insert(oe);
commonService.addOrderEvent(orderId, "", "PEA-WEB", "123", "已改约", "已改约", "");
return Result.success(null);
}
private List<String> searchEngineerCodes(OrderInfo order, String distance, String key, String recommend) {
private List<String> searchEngineerCodes(OrderInfoEntity order, String distance, String key, String recommend) {
Set<String> engineerCodes1 = this.searchEngineerByRecommend(order, recommend);
if (engineerCodes1.isEmpty()) {
log.info("recommend:{}筛选条件未找到技术员", recommend);
......@@ -256,13 +243,13 @@ public class OrderAssignImpl implements OrderAssign {
}
}
// 匹配技能
SkillInfo skill = skillInfoMPDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill());
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill());
if (skill == null) {
log.info("skill_info表没有匹配到技能配置:{}-{}-{}", order.getBrand(), order.getY(), order.getSkill());
return new ArrayList<>();
}
Set<String> engineerCodes3 = engineerSkillGroupMPDao.selectBySkillGroupCode(skill.getSkillGroupCode()).stream().map(
EngineerSkillGroup::getEngineerCode).collect(Collectors.toSet());
Set<String> engineerCodes3 = engineerSkillGroupDao.findBySkillGroupCode(skill.getSkillGroupCode()).stream().map(
EngineerSkillGroupEntity::getEngineerCode).collect(Collectors.toSet());
if (engineerCodes3.isEmpty()) {
log.info("没有匹配到技能相匹配的技术员:{}-{}-{}", order.getBrand(), order.getType(), order.getSkill());
return new ArrayList<>();
......@@ -283,9 +270,10 @@ public class OrderAssignImpl implements OrderAssign {
return new ArrayList<>(engineerCodes1);
}
private Set<String> searchEngineerByRecommend(OrderInfo order, String recommend) {
private Set<String> searchEngineerByRecommend(OrderInfoEntity order, String recommend) {
if (StringUtils.isNotEmpty(recommend) && recommend.equals("team")) {
return orgTeamEngineerMPDao.selectByTeamId(order.getOrgTeamId()).stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toSet());
return orgTeamEngineerDao.findAllByTeamId(order.getOrgTeamId()).stream().map(
OrgTeamEngineerEntity::getEngineerCode).collect(Collectors.toSet());
}
String levelType;
String levelValue;
......@@ -298,41 +286,53 @@ public class OrderAssignImpl implements OrderAssign {
} else {
return new HashSet<>();
}
LambdaQueryWrapper<OrgTeam> lqw = new LambdaQueryWrapper<>();
lqw.eq(levelType.equals("cluster"), OrgTeam::getClusterId, levelValue);
lqw.eq(levelType.equals("branch"), OrgTeam::getBranchId, levelValue);
lqw.eq(levelType.equals("group"), OrgTeam::getGroupId, levelValue);
lqw.eq(levelType.equals("team"), OrgTeam::getTeamId, levelValue);
List<String> groupIds = orgTeamMPDao.selectList(lqw).stream().map(OrgTeam::getGroupId).collect(Collectors.toList());
return engineerInfoMPDao.selectByGroupIds(groupIds).stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toSet());
List<OrgTeamEntity> teams = new ArrayList<>();
if(levelType.equals("cluster")){
teams = orgTeamDao.findAllByClusterId(levelValue);
} else if (levelType.equals("branch")){
teams = orgTeamDao.findAllByBranchId(levelValue);
} else if (levelType.equals("group")){
teams = orgTeamDao.findAllByGroupId(levelValue);
} else if (levelType.equals("team")){
teams = orgTeamDao.findAllByTeamId(levelValue);
}
List<String> groupIds = teams.stream().map(OrgTeamEntity::getGroupId).collect(Collectors.toList());
return engineerInfoDao.findByGroupIdIn(groupIds).stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toSet());
}
private Set<String> searchEngineerByKey(String key) {
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(EngineerInfo::getBeanStatus, 1);
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<EngineerInfoEntity> criteriaQuery = criteriaBuilder.createQuery(EngineerInfoEntity.class);
Root<EngineerInfoEntity> root = criteriaQuery.from(EngineerInfoEntity.class);
Predicate predicate = criteriaBuilder.equal(root.get("beanStatus"), 1);
if (StringUtils.isNotEmpty(key)) {
lqw.and(w ->
w.like(EngineerInfo::getPhone, key)
.or()
.like(EngineerInfo::getName, key)
.or()
.like(EngineerInfo::getEngineerCode, key)
Predicate keyPredicate = criteriaBuilder.or(
criteriaBuilder.like(root.get("phone"), "%" + key + "%"),
criteriaBuilder.like(root.get("name"), "%" + key + "%"),
criteriaBuilder.like(root.get("engineerCode"), "%" + key + "%")
);
predicate = criteriaBuilder.and(predicate, keyPredicate);
}
return engineerInfoMPDao.selectList(lqw).stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toSet());
criteriaQuery.where(predicate);
CriteriaQuery<EngineerInfoEntity> selectQuery = criteriaQuery.select(root);
return entityManager.createQuery(selectQuery).getResultList().stream().map(
EngineerInfoEntity::getEngineerCode).collect(Collectors.toSet());
}
private List<TimeLineDTO> packTimelines(List<OrderInfo> orders, HashMap<String, List<LabelValueDTO>> orderTips) {
private List<TimeLineDTO> packTimelines(List<OrderInfoEntity> orders, HashMap<String, List<LabelValueDTO>> orderTips) {
List<LabelValueDTO> empty = new ArrayList<>();
List<TimeLineDTO> items = new ArrayList<>();
for (OrderInfo order : orders) {
for (OrderInfoEntity order : orders) {
TimeLineDTO item = new TimeLineDTO();
item.setOrderId(order.getOrderId());
item.setAppointmentStatus(order.getAppointmentStatus());
item.setStartTime(TimeUtils.IsoTimestamp2DateTime(order.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoTimestamp2DateTime(order.getPlanEndTime()));
item.setStartTime(TimeUtils.IsoLocalDateTime2String(order.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoLocalDateTime2String(order.getPlanEndTime()));
item.setTips(orderTips.getOrDefault(order.getOrderId(), empty));
items.add(item);
......@@ -340,12 +340,12 @@ public class OrderAssignImpl implements OrderAssign {
return items;
}
private HashMap<String, List<LabelValueDTO>> packOrderTips(List<OrderInfo> orders) {
private HashMap<String, List<LabelValueDTO>> packOrderTips(List<OrderInfoEntity> orders) {
return orders.stream().collect(Collectors.toMap(
OrderInfo::getOrderId, this::packOrderTip, (l1, l2) -> l1, HashMap::new));
OrderInfoEntity::getOrderId, this::packOrderTip, (l1, l2) -> l1, HashMap::new));
}
private List<LabelValueDTO> packOrderTip(OrderInfo order) {
private List<LabelValueDTO> packOrderTip(OrderInfoEntity order) {
// pack订单tips
List<LabelValueDTO> items = new ArrayList<>();
items.add(new LabelValueDTO("类型/品牌", String.format("%s %s %s", order.getSkill(), order.getType(), order.getBrand())));
......
......@@ -210,9 +210,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
OrderAssignCheck.Result checkResult = null;
log.info("=== 准备调用指派,候选的技术员列表: {}", matchEngineerCodes);
for (String engineerCode : matchEngineerCodes) {
checkResult = orderAssignCheck.orderAssignCheck(entity.getOrderId(), engineerCode);
checkResult = orderAssignCheck.orderAssignCheck(entity.getOrderId(), entity.getDt(), engineerCode);
log.info("orderAssignCheck ===> orderId[{}]engineerCode[{}] ==> result[{}]", entity.getOrderId(), engineerCode, checkResult);
if (checkResult.getCanAssign()) {
if (checkResult.getIndex() < 0) {
assignEngineerCode = engineerCode;
break;
}
......@@ -221,16 +221,18 @@ public class OrderCreateServiceImpl implements OrderCreateService {
// 虚拟指派
if (StringUtils.isNotBlank(assignEngineerCode)) {
// 修改当前工单
OrderAssignCheck.OrderNode insertNode = checkResult.getCurOrderNode();
entity.setEngineerCode(assignEngineerCode);
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(assignEngineerCode);
entity.setEngineerName(engineerInfo.getName());
entity.setEngineerPhone(engineerInfo.getPhone());
entity.setAppointmentStatus("PRE");
entity.setDispatcher("AUTO_NOW");
entity.setPlanStartTime(checkResult.getStart());
entity.setPlanEndTime(checkResult.getEnd());
entity.setArriveDistance(checkResult.getDistanceAddition());
entity.setArriveElapsed(checkResult.getMinuteAddition());
entity.setPlanStartTime(insertNode.getPlanStartTime());
entity.setPlanEndTime(insertNode.getPlanEndTime());
entity.setArriveDistance(checkResult.getAdditionDistance());
entity.setArriveElapsed(checkResult.getAdditionElapsed());
orderInfoDao.save(entity);
// 如果影响到原有工单,修改原有工单
......
......@@ -28,10 +28,10 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
private OrderInfoMPDao orderInfoMPDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private EngineerInfoDao engineerInfoDao;
@Autowired
private OrgBranchMPDao orgBranchMPDao;
private OrgBranchDao orgBranchDao;
@Transactional
@Override
......@@ -167,8 +167,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
if(engineerCodes.isEmpty()){
return new HashMap<>();
}
List<EngineerInfo> engineers = engineerInfoMPDao.selectByEngineerCodes(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerInfo::getEngineerCode, EngineerInfo::getName));
List<EngineerInfoEntity> engineers = engineerInfoDao.findByEngineerCodeIn(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, EngineerInfoEntity::getName));
}
private Map<String, String> getBranchNames(List<OrderInfo> orders){
......@@ -182,10 +182,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
if(branches.isEmpty()){
return new HashMap<>();
}
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));
List<OrgBranchEntity> records = orgBranchDao.findByBranchIdIn(new ArrayList<>(branches));
return records.stream().collect(Collectors.toMap(OrgBranchEntity::getBranchId, OrgBranchEntity::getBranchName));
}
private List<String> getOrderEngineerNames(String engineerCode, String engineerCodeSub, Map<String,String> engineerNames){
......
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.dao.*;
import com.dituhui.pea.order.dto.CapacityAdjustDTO;
import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
......@@ -87,7 +88,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
.setCapUsed(e.getCapUsedTotal())
.setCapLeft(e.getCapLeft())
.setEngineerNum(e.getEngineerCount())
.setUpdateTime(e.getUpdateTime());
.setUpdateTime(DateUtils.formatDateTime(e.getUpdateTime()));
} else {
// group查询,是capacity_team_stat
CapacityTeamStatEntity e = (CapacityTeamStatEntity) item;
......@@ -102,7 +103,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
.setCapLeft(e.getCapLeft())
.setCapAdjust(e.getCapAdjust())
.setEngineerNum(e.getEngineerCount())
.setUpdateTime(e.getUpdateTime());
.setUpdateTime(DateUtils.formatDateTime(e.getUpdateTime()));
}
contents.add(content);
}
......@@ -115,12 +116,13 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
@Override
public Result<?> adjustCapacity(CapacityAdjustDTO.Request reqDTO) {
if (reqDTO.getStartDate().isBefore(LocalDate.now())) {
if (LocalDate.parse(reqDTO.getStartDate()).isBefore(LocalDate.now())) {
return Result.failed("日期不能小于当天");
}
// 遍历 startDate 到 endDate 之间的所有日期
LocalDate currentDate = reqDTO.getStartDate();
while (!currentDate.isAfter(reqDTO.getEndDate())) {
LocalDate currentDate = LocalDate.parse(reqDTO.getStartDate());
LocalDate endDate = LocalDate.parse(reqDTO.getEndDate());
while (!currentDate.isAfter(endDate)) {
float adjuest = (float) (reqDTO.getCapAdjust() / 100.0);
ajustCapacityByDate(reqDTO.getTeamId(), currentDate, adjuest);
currentDate = currentDate.plusDays(1); // 增加一天
......
......@@ -27,16 +27,22 @@ public class ScheduleServiceImpl implements ScheduleService {
private OrderInfoMPDao orderInfoMPDao;
@Autowired
private OrderInfoDao orderInfoDao;
@Autowired
private OrgTeamMPDao orgTeamMPDao;
@Autowired
private OrgTeamEngineerMPDao orgTeamEngineerMPDao;
private OrgTeamEngineerDao orgTeamEngineerDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
private OrgGroupDao orgGroupDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private SkillInfoMPDao skillInfoMPDao;
......@@ -97,21 +103,22 @@ public class ScheduleServiceImpl implements ScheduleService {
}
// 获取team技术员列表
List<OrgTeamEngineer> teamEngineers = this.queryOrgTeamEngineers(t.getTeamId());
List<String> engineerCodes = teamEngineers.stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toList());
List<EngineerInfo> engineerInfoList = engineerInfoMPDao.selectByEngineerCodes(engineerCodes);
Map<String, List<EngineerInfo>> engineers = engineerInfoList.stream().collect(Collectors.groupingBy(EngineerInfo::getEngineerCode));
List<OrgTeamEngineerEntity> teamEngineers = orgTeamEngineerDao.findAllByTeamId(t.getTeamId());
List<String> engineerCodes = teamEngineers.stream().map(OrgTeamEngineerEntity::getEngineerCode).collect(Collectors.toList());
List<EngineerInfoEntity> engineerInfoList = engineerInfoDao.findByEngineerCodeIn(engineerCodes);
Map<String, List<EngineerInfoEntity>> engineers = engineerInfoList.stream().collect(
Collectors.groupingBy(EngineerInfoEntity::getEngineerCode));
List<ScheduleOverviewResp.Item> children = new ArrayList<>();
for (Map.Entry<String, List<EngineerInfo>> entry : engineers.entrySet()) {
for (Map.Entry<String, List<EngineerInfoEntity>> entry : engineers.entrySet()) {
ScheduleOverviewResp.Item child = new ScheduleOverviewResp.Item();
//技术员信息
String engineerCode = entry.getKey();
EngineerInfo engineerInfo = entry.getValue().get(0);
EngineerInfoEntity engineerInfo = entry.getValue().get(0);
// 获取技术员已经指派的订单列表
List<OrderInfo> orders2 = engineerOrders.getOrDefault(engineerCode, new ArrayList<>());
List<OrderInfo> orders2 = engineerOrders.getOrDefault(engineerCode, new ArrayList<>());
child.setName(engineerInfo.getName());
child.setValue(engineerCode);
......@@ -144,28 +151,27 @@ public class ScheduleServiceImpl implements ScheduleService {
public Result<?> getScheduleEngineerOverview(LocalDate date, String engineerCode) throws BusinessException {
// 获取技术员已排班概况
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(engineerCode);
if (engineer == null) {
throw new BusinessException("分销员不存在");
}
List<LabelValueDTO> emptyTips = new ArrayList<>();
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, date).eq(OrderInfo::getEngineerCode, engineerCode).in(OrderInfo::getAppointmentStatus, List.of("PRE", "CONFIRM"));
List<OrderInfo> orderAppointments = orderInfoMPDao.selectList(lqw);
List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineerCode, date, List.of("PRE", "CONFIRM"));
List<TimeLineDTO> timelines = new ArrayList<>();
for (OrderInfo o : orderAppointments) {
for (OrderInfoEntity o : orderAppointments) {
TimeLineDTO item = new TimeLineDTO();
item.setOrderId(o.getOrderId());
item.setAppointmentStatus(o.getAppointmentStatus());
item.setStartTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoTimestamp2DateTime(o.getPlanEndTime()));
item.setStartTime(TimeUtils.IsoLocalDateTime2String(o.getPlanStartTime()));
item.setEndTime(TimeUtils.IsoLocalDateTime2String(o.getPlanEndTime()));
item.setTips(emptyTips);
timelines.add(item);
}
Map<String, List<OrderInfo>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfo::getServiceStatus));
List<OrderInfo> empty = new ArrayList<>();
Map<String, List<OrderInfoEntity>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfoEntity::getServiceStatus));
List<OrderInfoEntity> empty = new ArrayList<>();
Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size();
List<LabelValueDTO> dynamics = new ArrayList<>();
......@@ -182,13 +188,13 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics.add(new LabelValueDTO("工作时间", "08:00-18:00"));
dynamics.add(new LabelValueDTO("交通工具", "电动车"));
List<String> orderIds = orderAppointments.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
List<OrderInfo> orderRequests = new ArrayList<>();
List<String> orderIds = orderAppointments.stream().map(OrderInfoEntity::getOrderId).collect(Collectors.toList());
List<OrderInfoEntity> orderRequests = new ArrayList<>();
if (orderIds != null && !orderIds.isEmpty()) {
orderRequests = orderInfoMPDao.selectByDtAndOrderIds(date, orderIds);
orderRequests = orderInfoDao.findAllByDtAndOrderIdIn(date, orderIds);
}
List<ScheduleEngineerOverviewResp.Order> orders = new ArrayList<>();
for (OrderInfo o : orderRequests) {
for (OrderInfoEntity o : orderRequests) {
ScheduleEngineerOverviewResp.Order item = new ScheduleEngineerOverviewResp.Order();
item.setOrderId(o.getOrderId());
item.setLocation(String.format("%s,%s", o.getX(), o.getY()));
......@@ -207,7 +213,7 @@ public class ScheduleServiceImpl implements ScheduleService {
}
String groupName = "";
OrgGroup group = orgGroupMPDao.getByGroupId(engineer.getGroupId());
OrgGroupEntity group = orgGroupDao.getByGroupId(engineer.getGroupId());
if (group != null) {
groupName = group.getGroupName();
}
......@@ -240,13 +246,6 @@ public class ScheduleServiceImpl implements ScheduleService {
return pg;
}
private List<OrgTeamEngineer> queryOrgTeamEngineers(String teamId) {
LambdaQueryWrapper<OrgTeamEngineer> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrgTeamEngineer::getTeamId, teamId);
lqw.eq(OrgTeamEngineer::getStatus, 1);
return orgTeamEngineerMPDao.selectList(lqw);
}
private List<OrderInfo> queryOrderRequests(String teamId, LocalDate date) {
LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(OrderInfo::getDt, date);
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.SkillGroupMPDao;
import com.dituhui.pea.order.entity.SkillGroup;
import com.dituhui.pea.order.dao.SkillGroupDao;
import com.dituhui.pea.order.entity.SkillGroupEntity;
import com.dituhui.pea.order.service.SkillGroupCategoryService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,15 +17,15 @@ import java.util.stream.Collectors;
public class SkillGroupCategoryServiceImpl implements SkillGroupCategoryService {
@Autowired
SkillGroupMPDao skillGroupMPDao;
SkillGroupDao skillGroupDao;
@Override
public Result<?> querySkillGroupCategoryService() {
List<SkillGroup> records = skillGroupMPDao.selectList(null).stream().sorted(
Comparator.comparing(SkillGroup::getCategory)).collect(Collectors.toList());
List<SkillGroupEntity> records = skillGroupDao.findAll().stream().sorted(
Comparator.comparing(SkillGroupEntity::getCategory)).collect(Collectors.toList());
List<Category> items = new ArrayList<>();
for (SkillGroup r : records) {
for (SkillGroupEntity r : records) {
items.add(new Category(r.getSkillGroupCode(), r.getSkillGroup(), r.getCategory()));
}
Response res = new Response();
......
......@@ -3,12 +3,13 @@ package com.dituhui.pea.order.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.dao.OrderEventDao;
import com.dituhui.pea.order.dao.OrderInfoDao;
import com.dituhui.pea.order.dto.OrderChangeListDTO;
import com.dituhui.pea.order.dto.WorkbenchSummaryResp;
import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrderInfo;
import com.dituhui.pea.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,8 +18,15 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -28,44 +36,44 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private OrderEventDao orderEventDao;
@Autowired
private OrderInfoMPDao orderInfoMPDao;
private OrderInfoDao orderInfoDao;
@Autowired
private OrderInfoDao orderInfoDao;
private EntityManager entityManager;
@Override
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Page<OrderEventEntity> page;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Page<OrderEventEntity> page;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
Date date = DateUtil.parse(reqDTO.getDate());
if ("cluster".equals(levelType)) {
page = orderEventDao.findAllByClusterId(levelValue, date, pageable);
} else if ("branch".equals(levelType)) {
page = orderEventDao.findAllByBranchId(levelValue, date, pageable);
} else {
page = orderEventDao.findAllByGroupId(levelValue, date, pageable);
}
List<OrderChangeListDTO.Content> contents = new ArrayList<>();
for (OrderEventEntity entity : page.getContent()) {
OrderChangeListDTO.Content content = new OrderChangeListDTO.Content();
OrderInfoEntity orderInfoEntity = orderInfoDao.getByOrderId(entity.getOrderId());
content.setOrderId(entity.getOrderId())
.setCustomerName(orderInfoEntity.getName())
.setOperator(entity.getOperator())
.setDescription(entity.getDescription())
.setMemo(entity.getMemo())
.setUpdateTime(entity.getUpdateTime());
contents.add(content);
}
OrderChangeListDTO.Result rs = new OrderChangeListDTO.Result();
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setContent(contents);
return Result.success(rs);
}
if ("cluster".equals(levelType)) {
page = orderEventDao.findAllByClusterId(levelValue, date, pageable);
} else if ("branch".equals(levelType)) {
page = orderEventDao.findAllByBranchId(levelValue, date, pageable);
} else {
page = orderEventDao.findAllByGroupId(levelValue, date, pageable);
}
List<OrderChangeListDTO.Content> contents = new ArrayList<>();
for (OrderEventEntity entity : page.getContent()) {
OrderChangeListDTO.Content content = new OrderChangeListDTO.Content();
OrderInfoEntity orderInfoEntity = orderInfoDao.getByOrderId(entity.getOrderId());
content.setOrderId(entity.getOrderId())
.setCustomerName(orderInfoEntity.getName())
.setOperator(entity.getOperator())
.setDescription(entity.getDescription())
.setMemo(entity.getMemo())
.setUpdateTime(DateUtils.formatDateTime(entity.getUpdateTime()));
contents.add(content);
}
OrderChangeListDTO.Result rs = new OrderChangeListDTO.Result();
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setContent(contents);
return Result.success(rs);
}
@Override
public Result<?> getWorkbenchSummary(String levelType, String levelValue, LocalDate dt) {
......@@ -89,27 +97,95 @@ public class WorkbenchServiceImpl implements WorkbenchService {
}
private List<Map<String, Object>> queryCountByAppointmentMethod(String levelType, String levelValue, LocalDate dt) {
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("appointment_method, appointment_status, COUNT(*) as count")
.lambda()
.eq(OrderInfo::getDt, dt)
.eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderInfo::getAppointmentMethod, OrderInfo::getAppointmentStatus);
return orderInfoMPDao.selectMaps(wrapper);
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
criteriaQuery.multiselect(
root.get("appointmentMethod"),
root.get("appointmentStatus"),
criteriaBuilder.count(root).alias("count")
);
Predicate datePredicate = criteriaBuilder.equal(root.get("dt"), dt);
Predicate levelPredicate = null;
if ("cluster".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgClusterId"), levelValue);
} else if ("branch".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgBranchId"), levelValue);
} else if ("group".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgGroupId"), levelValue);
}
if (levelPredicate != null) {
criteriaQuery.where(datePredicate, levelPredicate);
} else {
criteriaQuery.where(datePredicate);
}
criteriaQuery.groupBy(root.get("appointmentMethod"), root.get("appointmentStatus"));
TypedQuery<Object[]> typedQuery = entityManager.createQuery(criteriaQuery);
List<Object[]> results = typedQuery.getResultList();
List<Map<String, Object>> mappedResults = results.stream()
.map(result -> {
Map<String, Object> map = Map.of(
"appointmentMethod", result[0],
"appointmentStatus", result[1],
"count", result[2]
);
return map;
})
.collect(Collectors.toList());
return mappedResults;
}
private List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) {
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.select("service_status, COUNT(*) as count")
.lambda()
.eq(OrderInfo::getDt, dt)
.eq(levelType.equals("cluster"), OrderInfo::getOrgClusterId, levelValue)
.eq(levelType.equals("branch"), OrderInfo::getOrgBranchId, levelValue)
.eq(levelType.equals("group"), OrderInfo::getOrgGroupId, levelValue)
.groupBy(OrderInfo::getServiceStatus);
return orderInfoMPDao.selectMaps(wrapper);
public List<Map<String, Object>> queryCountByOrderStatus(String levelType, String levelValue, LocalDate dt) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
criteriaQuery.multiselect(
root.get("serviceStatus"),
criteriaBuilder.count(root).alias("count")
);
Predicate datePredicate = criteriaBuilder.equal(root.get("dt"), dt);
Predicate levelPredicate = null;
if ("cluster".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgClusterId"), levelValue);
} else if ("branch".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgBranchId"), levelValue);
} else if ("group".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgGroupId"), levelValue);
}
if (levelPredicate != null) {
criteriaQuery.where(datePredicate, levelPredicate);
} else {
criteriaQuery.where(datePredicate);
}
criteriaQuery.groupBy(root.get("serviceStatus"));
TypedQuery<Object[]> typedQuery = entityManager.createQuery(criteriaQuery);
List<Object[]> results = typedQuery.getResultList();
List<Map<String, Object>> mappedResults = results.stream()
.map(result -> {
Map<String, Object> map = Map.of(
"serviceStatus", result[0],
"count", result[1]
);
return map;
})
.collect(Collectors.toList());
return mappedResults;
}
private HashMap<String, Long> transAppointmentMethod(List<Map<String, Object>> results) {
......@@ -119,8 +195,8 @@ public class WorkbenchServiceImpl implements WorkbenchService {
Long autoTotal = 0L;
Long total = 0L;
for (Map<String, Object> result : results) {
String method = (String) result.get("appointment_method");
String status = (String) result.get("appointment_status");
String method = (String) result.get("appointmentMethod");
String status = (String) result.get("appointmentStatus");
Long count = (long) result.get("count");
total += count;
......@@ -147,7 +223,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
HashMap<String, Long> map = new HashMap<>();
for (Map<String, Object> result : results) {
String status = (String) result.get("service_status");
String status = (String) result.get("serviceStatus");
Long count = (long) result.get("count");
map.put(status, count);
}
......@@ -211,12 +287,10 @@ public class WorkbenchServiceImpl implements WorkbenchService {
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<>();
List<T> value = new ArrayList<>();
for(T v: values){
value.add(v);
}
Collections.addAll(value, values);
map.put(key, value);
return map;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!