Commit f6d35dce by chamberone

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

…oject.git into develop
2 parents 318f883a 9db8615e
......@@ -47,14 +47,16 @@ public class OrderAssignCheck {
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){
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;
}
}
......@@ -83,7 +85,7 @@ public class OrderAssignCheck {
int index = SegmentInsertion.insertSegment(takeTime, start, end, segments);
if (index == -1) {
log.info("没有可连续插入的空间");
return new Result(false, "没有连续可插入空间(没计算时间)", 0, 0, null, null);
return new Result(false, "没有连续可插入空间(没计算时间)", 0, 0, null, null, index);
}
log.info("插入位置为第{}单, 已分配单数(不包含本单):{}", index, orderSegments.size());
......@@ -105,7 +107,7 @@ 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);
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
}
else if(index == 0 && !orderSegments.isEmpty()) {
// 第一订单为出发地, 且有其他订单
......@@ -115,7 +117,7 @@ public class OrderAssignCheck {
OrderSegment post = orderSegments.get(0);
OrderSegment pre = new OrderSegment(480, 480, preX, preY);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
}
else if(index == orderSegments.size()) {
// 最后一个订单出发
......@@ -128,12 +130,12 @@ 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);
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
} else {
OrderSegment pre = orderSegments.get(index-1);
OrderSegment post = orderSegments.get(index);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
}
}
......@@ -181,7 +183,7 @@ public class OrderAssignCheck {
return segments;
}
private Result getResult(double curX, double curY, OrderSegment pre, OrderSegment post, int takeTime, LocalDate dt) {
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);
Pair prePostPair = this.getDistanceAndDuration(post.getX(), post.getY(), pre.getX(), pre.getY());
......@@ -190,7 +192,7 @@ public class OrderAssignCheck {
int distance = post.getStart() - postCurPair.getDuration() - (pre.getEnd() + preCurPair.getDuration());
if(distance < takeTime) {
// 不支持插入
return new Result(false, "增加时间路程后,不支持插入", 0, 0, null, null);
return new Result(false, "增加时间路程后,不支持插入", 0, 0, null, null, index);
}
// 插入点(时间点)
int startInsert = pre.getEnd() + preCurPair.getDuration();
......@@ -200,7 +202,7 @@ public class OrderAssignCheck {
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);
return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime, index);
}
private double[] getEngineerDepartureLocation(String engineerCode){
......
......@@ -23,4 +23,8 @@ public interface EngineerInfoMPDao extends BaseMapper<EngineerInfo> {
@Select("select * from engineer_info where group_id = #{groupId}")
List<EngineerInfo> selectByGroupId(String groupId);
@Select("<script> select * from engineer_info where groupId in " +
"<foreach item='groupId' collection='groupIds' open='(' separator=',' close=')'>#{groupId}</foreach></script>")
List<EngineerInfo> selectByGroupIds(@Param("groupIds") List<String> groupIds);
}
\ No newline at end of file
......@@ -12,4 +12,7 @@ import java.util.List;
public interface EngineerSkillGroupMPDao extends BaseMapper<EngineerSkillGroup> {
@Select("select * from engineer_skill_group where engineer_code = #{engineerCode}")
List<EngineerSkillGroup> selectByEngineerCode(String engineerCode);
@Select("select * from engineer_skill_group where skill_group_code = #{skillGroupCode}")
List<EngineerSkillGroup> selectBySkillGroupCode(String skillGroupCode);
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrderEventEntity;
import org.hibernate.annotations.Where;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.time.LocalDate;
import java.util.Date;
@Repository
@Where(clause = "status = 1")
public interface OrderEventDao extends JpaRepository<OrderEventEntity, Integer> {
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and Date(a.createTime) = :date")
Page<OrderEventEntity> findAllByClusterId(String clusterId, LocalDate date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByClusterId(String clusterId, Date date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId and Date(a.createTime) = :date")
Page<OrderEventEntity> findAllByBranchId(String branchId, LocalDate date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByBranchId(String branchId, Date date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId and Date(a.createTime) = :date")
Page<OrderEventEntity> findAllByGroupId(String groupId, LocalDate date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByGroupId(String groupId, Date date, Pageable pageable);
}
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;
......@@ -12,6 +13,8 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATE;
public class OrderChangeListDTO {
......@@ -27,11 +30,7 @@ public class OrderChangeListDTO {
private String levelValue;
private int page = OrderConfig.DEFAULT_PAGE_INDEX;
private int size = OrderConfig.DEFAULT_PAGE_SIZE;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDate date = LocalDate.now();
private String date = DateUtils.formatDate(LocalDate.now(), PATTERN_DATE);
/**
* 排序
*/
......
package com.dituhui.pea.order.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
@Data
@Accessors(chain = true)
@Table(name="order_change")
public class OrderChangeEntity {
/**
* 自增id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 工单id
*/
private String orderId;
/**
* 子工单id
*/
private String suborderId;
/**
* 变更发起源(bean/pea-web/pea-backend)
*/
private String source;
/**
* 发起人
*/
private String operator;
/**
* 操作内容,指派,规划路线
*/
private String content;
/**
* 变更前的信息
*/
private String contentOld;
/**
* 备注
*/
private String memo;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 创建时间
*/
private LocalDateTime updateTime;
public OrderChangeEntity() {}
}
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.dto.OrderChangeListDTO;
import com.dituhui.pea.order.dto.WorkbenchSummaryResp;
import com.dituhui.pea.order.entity.OrderChangeEntity;
import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.entity.OrderRequestEntity;
import com.dituhui.pea.order.service.WorkbenchService;
......@@ -17,10 +18,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Slf4j
@Service
......@@ -47,33 +45,33 @@ public class WorkbenchServiceImpl implements WorkbenchService {
@Override
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Page<?> changes;
Page<OrderEventEntity> page;
String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue();
Date date = DateUtil.parse(reqDTO.getDate());
if ("cluster".equals(levelType)) {
changes = orderEventDao.findAllByClusterId(levelValue, reqDTO.getDate(), pageable);
page = orderEventDao.findAllByClusterId(levelValue, date, pageable);
} else if ("branch".equals(levelType)) {
changes = orderEventDao.findAllByBranchId(levelValue, reqDTO.getDate(), pageable);
page = orderEventDao.findAllByBranchId(levelValue, date, pageable);
} else {
changes = orderEventDao.findAllByGroupId(levelValue, reqDTO.getDate(), pageable);
page = orderEventDao.findAllByGroupId(levelValue, date, pageable);
}
List<OrderChangeListDTO.Content> contents = new ArrayList<>();
for (Object e1 : changes.getContent()) {
OrderChangeEntity e = (OrderChangeEntity) e1;
for (OrderEventEntity entity : page.getContent()) {
OrderChangeListDTO.Content content = new OrderChangeListDTO.Content();
OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(e.getOrderId());
content.setOrderId(e.getOrderId())
OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(entity.getOrderId());
content.setOrderId(entity.getOrderId())
.setCustomerName(orderRequestEntity.getName())
.setOperator(e.getOperator())
.setDescription(e.getContent())
.setMemo(e.getMemo())
.setUpdateTime(e.getUpdateTime());
.setOperator(entity.getOperator())
.setDescription(entity.getDescription())
.setMemo(entity.getMemo())
.setUpdateTime(entity.getUpdateTime());
contents.add(content);
}
OrderChangeListDTO.Result rs = new OrderChangeListDTO.Result();
rs.setTotal(changes.getTotalElements())
.setPages(changes.getTotalPages())
.setPageSize(changes.getSize())
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setContent(contents);
return Result.success(rs);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!