Commit a2fe7924 by 丁伟峰

Merge remote-tracking branch 'origin/develop' into develop

2 parents a17822ee 5c7d47dd
package com.dituhui.pea.dispatch.dao;
import java.util.List;
import com.dituhui.pea.dispatch.entity.OrderEvent;
import org.springframework.data.repository.CrudRepository;
import com.fasterxml.jackson.annotation.JsonFormat;
public interface OrderEventRepository extends CrudRepository<OrderEvent, Long> {
}
package com.dituhui.pea.dispatch.dao;
import java.util.List;
import com.dituhui.pea.dispatch.entity.OrderLog;
import org.springframework.data.repository.CrudRepository;
import com.fasterxml.jackson.annotation.JsonFormat;
public interface OrderLogRepository extends CrudRepository<OrderLog, Long> {
}
package com.dituhui.pea.dispatch.entity;
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.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.*;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@Data
@Entity
@Table(name = "order_event")
public class OrderEvent implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "order_id")
private String orderId;
@Column(name = "suborder_id")
private String suborderId;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime happen;
private String event;
private String operator;
@Column(name = "operator_name")
private String operatorName;
private String source;
private String description;
private String memo;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private LocalDateTime createTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private LocalDateTime updateTime;
}
package com.dituhui.pea.dispatch.entity;
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.Data;
import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.*;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@Data
@Entity
@Table(name = "order_log")
public class OrderLog implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
@Column(name = "order_id")
private String orderId;
@Column(name = "suborder_id")
private String suborderId;
private String source;
private String operator;
private String content;
@Column(name = "content_old")
private String contentOld;
private String memo;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private LocalDateTime createTime;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private LocalDateTime updateTime;
}
......@@ -84,10 +84,10 @@ public class BatchScheduler {
if (null == dispatchBatch.getCutoffedTime()) {
log.info("dispatchRun 已过cutoff时间,更新pre状态为confirm, 执行首次confirm----- group:{}, day:{}", groupId, currDay);
this.extractService.extractDispatchToOrder(groupId, dispatchBatch.getBatchNo(), true);
dispatchBatch.setCutoffedTime(LocalDateTime.now());
batchService.saveDispatchBatch(dispatchBatch);
} else {
log.info("dispatchRun 已过cutoff时间,更新pre状态为confirm, 已经执行confirm,跳过当次计算 ----- group:{}, day:{}", groupId, currDay);
}
......
......@@ -3,13 +3,11 @@ package com.dituhui.pea.dispatch.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.dituhui.pea.dispatch.dao.*;
import com.dituhui.pea.dispatch.entity.DispatchOrder;
import com.dituhui.pea.dispatch.entity.EngineerInfo;
import com.dituhui.pea.dispatch.entity.OrderAppointment;
import com.dituhui.pea.dispatch.entity.OrderRequest;
import com.dituhui.pea.dispatch.entity.*;
import com.dituhui.pea.dispatch.service.ExtractService;
import com.mysql.cj.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
......@@ -51,6 +49,12 @@ public class ExtractServiceImpl implements ExtractService {
OrderAppointmentRepository orderAppointmentRepo;
@Autowired
OrderLogRepository orderLogRepo;
@Autowired
OrderEventRepository orderEventRepo;
@Autowired
private EntityManager entityManager;
@Autowired
......@@ -80,8 +84,8 @@ public class ExtractServiceImpl implements ExtractService {
int idx = atomicInteger.getAndIncrement();
String orderId = dispatchOrder.getOrderId();
String engCode = dispatchOrder.getEngineerCode();
log.info("算法结果更新到工单, step1.1-loop, groupId:{}, batchNo:{}, {}/{}, orderId:{}, engCode:{}",
groupId, batchNo, idx, dispatchOrderList.size(), orderId, engCode);
log.info("算法结果更新到工单, step1.1-loop, {}/{}, groupId:{}, batchNo:{}, orderId:{}, engCode:{}",
idx, dispatchOrderList.size(), groupId, batchNo, orderId, engCode);
Optional<OrderRequest> orderOpt = orderRequestRepo.findByOrderId(orderId);
if (!orderOpt.isPresent()) {
......@@ -123,8 +127,8 @@ public class ExtractServiceImpl implements ExtractService {
if (appointmentOpt.isEmpty()) {
// 没有则插入一条
OrderAppointment appointment = new OrderAppointment();
appointment.setOrderId(dispatchOrder.getOrderId());
String subId = String.format("%s_%s", dispatchOrder.getOrderId(), DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss"));
appointment.setOrderId(orderId);
String subId = String.format("%s_%s", orderId, DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss"));
appointment.setSuborderId(subId);
appointment.setMainSub(1);
appointment.setEngineerCode(engCode);
......@@ -143,11 +147,26 @@ public class ExtractServiceImpl implements ExtractService {
orderAppointmentRepo.save(appointment);
// 写order_log
OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(subId).setSource("PEA-BACKEND").setOperator("DISPATCH")
.setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld("")
.setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderLogRepo.save(orderLog);
if (isConfirm) {
OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(subId).setHappen(LocalDateTime.now())
.setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-BACKEND")
.setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("")
.setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderEventRepo.save(orderEvent);
}
} else {
// 如果有记录:1虚拟指派 2排量预派 3
if (Set.of("PRE", "VIRTUAL").contains(appointmentOpt.get().getPreStatus()) &&
Set.of("NOT_ASSIGNED", "ASSIGNED").contains(appointmentOpt.get().getStatus())) {
OrderAppointment appointment = appointmentOpt.get();
String lastContent = String.format("批量自动指派:<%s,%s>", appointment.getEngineerCode(), appointment.getEngineerName());
appointment.setStatus("ASSIGNED");
appointment.setPreStatus(isConfirm ? "CONFIRM" : "PRE");
appointment.setEngineerCode(engCode);
......@@ -159,6 +178,20 @@ public class ExtractServiceImpl implements ExtractService {
appointment.setExpectEndTime(dispatchOrder.getTimeEnd());
appointment.setUpdateTime(LocalDateTime.now());
orderAppointmentRepo.save(appointment);
OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(appointment.getSuborderId()).setSource("PEA-BACKEND").setOperator("DISPATCH")
.setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld(lastContent)
.setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderLogRepo.save(orderLog);
if (isConfirm) {
OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(appointment.getSuborderId()).setHappen(LocalDateTime.now())
.setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-BACKEND")
.setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("")
.setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderEventRepo.save(orderEvent);
}
} else {
// 其它情况待补充(改约) todo
if (Set.of("CONFIRM").contains(appointmentOpt.get().getPreStatus()) &&
......@@ -169,6 +202,7 @@ public class ExtractServiceImpl implements ExtractService {
}
});
log.info("算法结果更新到工单完成, groupId:{}, batchNo:{}", groupId, batchNo);
......
......@@ -7,8 +7,10 @@ import com.dituhui.pea.dispatch.common.GeoDistanceCalculator;
import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider;
import com.dituhui.pea.dispatch.dao.DispatchEngineerRepository;
import com.dituhui.pea.dispatch.dao.DispatchOrderRepository;
import com.dituhui.pea.dispatch.dao.OrderLogRepository;
import com.dituhui.pea.dispatch.dao.OrgGroupRepository;
import com.dituhui.pea.dispatch.entity.DispatchOrder;
import com.dituhui.pea.dispatch.entity.OrderLog;
import com.dituhui.pea.dispatch.entity.OrgGroup;
import com.dituhui.pea.dispatch.pojo.*;
import com.dituhui.pea.dispatch.service.ExtractService;
......@@ -59,9 +61,12 @@ public class SolveServiceImpl implements SolveService {
@Autowired
OrgGroupRepository groupRepository;
@Autowired
private EntityManager entityManager;
@Autowired
ExtractService extractService;
......
......@@ -40,7 +40,7 @@ class SolveServiceTest {
ExtractService extractService;
String groupId = "gsuzhou";
String day = "2023-03-20";
String day = "2023-07-11";
private SolverManager<DispatchSolution, UUID> solverManager;
......@@ -76,7 +76,7 @@ class SolveServiceTest {
DispatchSolution solution = solver.solve(problem);
solveService.saveSolutionWrp(solution);
extractService.extractDispatchToOrder(groupId, batchNo, false);
extractService.extractDispatchToOrder(groupId, batchNo, true);
log.info("testAsync done");
......
......@@ -20,9 +20,9 @@ public class EngineerBusinessListResp {
private String kind;
private Integer maxNum;
private Integer maxMinute;
private String priority;
private Integer priority;
private String address;
private String location;
private String departure;
private Integer departure;
}
}
......@@ -7,6 +7,6 @@ public class EngineerBusinessUpdateReqDTO {
private String engineerCode;
private Integer maxNum;
private Integer maxMinute;
private String departure;
private String priority;
private Integer departure;
private Integer priority;
}
......@@ -20,5 +20,5 @@ public interface EngineerService {
Result<?> getEngineerBusinessDetail(String engineerCode);
// 技术员业务属性配置修改
Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMutine, String departure, String priority);
Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, Integer departure, Integer priority);
}
......@@ -202,27 +202,15 @@ public class EngineerServiceImpl implements EngineerService {
@Transactional
@Override
public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, String departure, String priority) {
public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, Integer departure, Integer priority) {
// 技术员业务属性配置修改
LambdaUpdateWrapper<EngineerBusiness> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(EngineerBusiness::getEngineerCode, engineerCode);
wrapper.set(maxNum >= 0, EngineerBusiness::getMaxNum, maxNum);
wrapper.set(maxMinute >= 0, EngineerBusiness::getMaxMinute, maxMinute);
Integer dep = (departure.equals("配件仓")) ? 1 : 2;
wrapper.set(EngineerBusiness::getDeparture, dep);
int pri;
if (priority.equals("高")) {
pri = 3;
} else if (priority.equals("中")) {
pri = 2;
} else {
pri = 1;
}
wrapper.set(EngineerBusiness::getPriority, pri);
wrapper.set(EngineerBusiness::getDeparture, departure);
wrapper.set(EngineerBusiness::getPriority, priority);
// 更新字段
engineerBusinessDao.update(null, wrapper);
......@@ -420,26 +408,17 @@ public class EngineerServiceImpl implements EngineerService {
if (b == null) {
item.setAddress("");
item.setLocation("");
item.setDeparture("");
item.setDeparture(1);
item.setMaxMinute(0);
item.setMaxNum(0);
item.setPriority("低");
item.setPriority(1);
} else {
item.setAddress(b.getAddress());
item.setLocation(String.format("%s,%s", b.getX(), b.getY()));
item.setDeparture((b.getDeparture() == 1) ? "配件仓" : "住址");
item.setDeparture(b.getDeparture());
item.setMaxMinute(b.getMaxMinute());
item.setMaxNum(b.getMaxNum());
String priority;
if (b.getPriority() == 3) {
priority = "高";
} else if (b.getPriority() == 2) {
priority = "中";
} else {
priority = "低";
}
item.setPriority(priority);
item.setPriority(b.getPriority());
}
items.add(item);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!