Commit b0ff6148 by huangjinxin

feat:工单改约,指派相关

1 parent 33cb9c35
Showing with 139 additions and 75 deletions
...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.common; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.common;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -70,7 +71,7 @@ public class OrderAssignCheck { ...@@ -70,7 +71,7 @@ public class OrderAssignCheck {
int index = SegmentInsertion.insertSegment(takeTime, start, end, segments); int index = SegmentInsertion.insertSegment(takeTime, start, end, segments);
if (index == -1) { if (index == -1) {
log.info("没有可连续插入的空间"); log.info("没有可连续插入的空间");
return new Result(-1, false, false, orderId, null,0,0, null, null, null); return new Result(-1, false, false, orderId, null, 0, 0, null, null, null);
} }
log.info("插入位置为第{}单, 已分配单数(不包含本单):{}", index, orderSegments.size()); log.info("插入位置为第{}单, 已分配单数(不包含本单):{}", index, orderSegments.size());
...@@ -148,7 +149,7 @@ public class OrderAssignCheck { ...@@ -148,7 +149,7 @@ public class OrderAssignCheck {
private List<OrderSegment> getEngineerOrderSegments(String engineerCode, LocalDate dt) { private List<OrderSegment> getEngineerOrderSegments(String engineerCode, LocalDate dt) {
List<OrderSegment> orderSegments = new ArrayList<>(); List<OrderSegment> orderSegments = new ArrayList<>();
List<String> appointmentStatusList = Arrays.asList("PRE", "CONFIRM"); List<String> appointmentStatusList = Arrays.asList(OrderFlowEnum.PRE.name(), OrderFlowEnum.CONFIRM.name());
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<OrderInfoEntity> criteriaQuery = criteriaBuilder.createQuery(OrderInfoEntity.class); CriteriaQuery<OrderInfoEntity> criteriaQuery = criteriaBuilder.createQuery(OrderInfoEntity.class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class); Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
......
...@@ -29,7 +29,7 @@ public class OrderAssignController { ...@@ -29,7 +29,7 @@ public class OrderAssignController {
Result<?> res = null; Result<?> res = null;
try { try {
res = orderAssign.getOrderAssignRecommendEngineers(orderId, key, distance, recommend); res = orderAssign.getOrderAssignRecommendEngineers(orderId, key, distance, recommend);
}catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
return res; return res;
...@@ -40,34 +40,32 @@ public class OrderAssignController { ...@@ -40,34 +40,32 @@ public class OrderAssignController {
// 服务单指派-指派提交 // 服务单指派-指派提交
Result<?> res = null; Result<?> res = null;
try { try {
res = orderAssign.orderAssign(req.getOrderId(), req.getEngineerCode()); res = orderAssign.orderAssign(req);
}catch (BusinessException e) { } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
return res; return res;
} }
@PostMapping("/order/revoke/assign") @PostMapping("/order/revoke/assign")
public Result<?> orderRevokeAssign(@RequestBody OrderRevokeAssign req){ public Result<?> orderRevokeAssign(@RequestBody OrderRevokeAssign req) {
// 放回工单池 // 放回工单池
Result<?> res = null; Result<?> res = null;
try{ try {
res = orderAssign.orderRevokeAssign(req.getOrderId()); res = orderAssign.orderRevokeAssign(req.getOrderId());
} catch (BusinessException e){ } catch (BusinessException e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
return res; return res;
} }
@PostMapping("/order/rescheduling") @PostMapping("/order/rescheduling")
public Result<?> orderRescheduling(@RequestBody OrderReschedule req){ public Result<?> orderRescheduling(@RequestBody OrderReschedule req) {
// 订单改约 // 订单改约
Result<?> res = null; Result<?> res = null;
LocalDateTime expectBegin = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectBegin()); try {
LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd()); res = orderAssign.orderReschedule(req);
try{ } catch (BusinessException e) {
res = orderAssign.orderReschedule(req.getOrderId(), expectBegin, expectEnd, req.getExpectDesc());
} catch (BusinessException e){
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
return res; return res;
......
...@@ -34,7 +34,7 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS ...@@ -34,7 +34,7 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByServiceStatusAndEngineerCode(String serviceStatus, String engineerCode); List<OrderInfoEntity> findByServiceStatusAndEngineerCode(String serviceStatus, String engineerCode);
List<OrderInfoEntity> findByDtAndAddressId(String dt, String addressId); List<OrderInfoEntity> findByDtAndAddressId(LocalDate dt, String addressId);
List<OrderInfoEntity> findByMultipleOrders(String multipleOrders); List<OrderInfoEntity> findByMultipleOrders(String multipleOrders);
} }
...@@ -6,4 +6,9 @@ import lombok.Data; ...@@ -6,4 +6,9 @@ import lombok.Data;
public class OrderAssignReq { public class OrderAssignReq {
private String engineerCode; private String engineerCode;
private String orderId; private String orderId;
/**
* 操作员
*/
private String operator;
} }
...@@ -8,4 +8,9 @@ public class OrderReschedule { ...@@ -8,4 +8,9 @@ public class OrderReschedule {
private String expectBegin; private String expectBegin;
private String expectEnd; private String expectEnd;
private String expectDesc; private String expectDesc;
/**
* 操作员
*/
private String operator;
} }
package com.dituhui.pea.order.entity; package com.dituhui.pea.order.entity;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import lombok.Data; import lombok.Data;
import javax.persistence.*; import javax.persistence.*;
...@@ -131,7 +132,7 @@ public class OrderInfoEntity { ...@@ -131,7 +132,7 @@ public class OrderInfoEntity {
private String orderStatus = "NORMAL"; private String orderStatus = "NORMAL";
@Column(name = "service_status", nullable = true, length = 20, columnDefinition = "varchar(20) default 'INIT'") @Column(name = "service_status", nullable = true, length = 20, columnDefinition = "varchar(20) default 'INIT'")
private String serviceStatus = "INIT"; private String serviceStatus = OrderFlowEnum.INIT.name();
@Column(name = "engineer_code", nullable = true, length = 32, columnDefinition = "varchar(32) default ''") @Column(name = "engineer_code", nullable = true, length = 32, columnDefinition = "varchar(32) default ''")
private String engineerCode = ""; private String engineerCode = "";
......
package com.dituhui.pea.order.enums;
/**
* 订单流程枚举类
*/
public enum OrderFlowEnum {
// 指派状态: INIT-待指派/PRE-预指派/CONFIRM-确认指派(通知BEAN)
INIT, PRE, CONFIRM,
}
...@@ -3,7 +3,8 @@ package com.dituhui.pea.order.enums; ...@@ -3,7 +3,8 @@ package com.dituhui.pea.order.enums;
public enum OrderStatus { public enum OrderStatus {
NORMAL("正常"), NORMAL("正常"),
CANCELED("已取消"), CANCELED("已取消"),
RESCHEDULED("已改约"); RESCHEDULED("已改约"),
ASSIGN("工单指派");
private final String description; private final String description;
OrderStatus(String description){ OrderStatus(String description){
......
package com.dituhui.pea.order.enums; package com.dituhui.pea.order.enums;
public enum ServiceStatus { public enum ServiceStatus {
// 服务状态:INIT-初始化/PENDING待服务/CONTACTED已排期/STARTED-已开始/FINISHED已完成/UNFINISHED-已上门未完成
INIT("待服务"), INIT("待服务"),
PENDING("待服务"), PENDING("待服务"),
CONTACTED("已排期"), CONTACTED("已排期"),
......
package com.dituhui.pea.order.service; package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.OrderAssignReq;
import com.dituhui.pea.order.dto.OrderReschedule;
import org.bouncycastle.asn1.cms.TimeStampAndCRL; import org.bouncycastle.asn1.cms.TimeStampAndCRL;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -13,9 +15,9 @@ public interface OrderAssign { ...@@ -13,9 +15,9 @@ public interface OrderAssign {
Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend); Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend);
// 服务单指派-指派提交 // 服务单指派-指派提交
Result<?> orderAssign(String orderId, String engineerCode); Result<?> orderAssign(OrderAssignReq req);
Result<?> orderRevokeAssign(String orderId); Result<?> orderRevokeAssign(String orderId);
Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc); Result<?> orderReschedule(OrderReschedule req);
} }
...@@ -2,6 +2,8 @@ package com.dituhui.pea.order.service; ...@@ -2,6 +2,8 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import java.time.LocalDate;
/** /**
* 订单相关 * 订单相关
*/ */
...@@ -14,7 +16,7 @@ public interface OrderInfoService { ...@@ -14,7 +16,7 @@ public interface OrderInfoService {
* @param addressId 地址id * @param addressId 地址id
* @return 有则返回多条订单关联id,没有则不是一家多单 * @return 有则返回多条订单关联id,没有则不是一家多单
*/ */
Result<String> addMultipleOrders(String dt, String addressId); Result<String> addMultipleOrders(LocalDate dt, String addressId, String orderId);
/** /**
* 取消指定订单一家多台 * 取消指定订单一家多台
......
...@@ -10,6 +10,7 @@ import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp; ...@@ -10,6 +10,7 @@ import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp;
import com.dituhui.pea.order.dto.DispatchOrderListReq; import com.dituhui.pea.order.dto.DispatchOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderListResp; import com.dituhui.pea.order.dto.DispatchOrderListResp;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderGroupEnum; import com.dituhui.pea.order.enums.OrderGroupEnum;
import com.dituhui.pea.order.enums.OrderStatus; import com.dituhui.pea.order.enums.OrderStatus;
import com.dituhui.pea.order.service.DispatchService; import com.dituhui.pea.order.service.DispatchService;
...@@ -298,7 +299,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -298,7 +299,7 @@ public class DispatchServiceImpl implements DispatchService {
Root<OrderInfoEntity> root = update.from(OrderInfoEntity.class); Root<OrderInfoEntity> root = update.from(OrderInfoEntity.class);
update.set(root.get("planStartTime"), planStartTime); update.set(root.get("planStartTime"), planStartTime);
update.set(root.get("planEndTime"), planEndTime); update.set(root.get("planEndTime"), planEndTime);
update.set(root.get("appointmentStatus"), "CONFIRM"); update.set(root.get("appointmentStatus"), OrderFlowEnum.CONFIRM.name());
update.set(root.get("appointmentMethod"), "MANUAL"); update.set(root.get("appointmentMethod"), "MANUAL");
update.set(root.get("engineerCode"), engineerCode); update.set(root.get("engineerCode"), engineerCode);
update.where( update.where(
...@@ -441,7 +442,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -441,7 +442,7 @@ public class DispatchServiceImpl implements DispatchService {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
predicates.add(criteriaBuilder.equal(root.get("dt"), TimeUtils.IsoDate2LocalDate(reqDTO.getDate()))); predicates.add(criteriaBuilder.equal(root.get("dt"), TimeUtils.IsoDate2LocalDate(reqDTO.getDate())));
predicates.add(criteriaBuilder.equal(root.get("appointmentStatus"), "INIT")); predicates.add(criteriaBuilder.equal(root.get("appointmentStatus"), OrderFlowEnum.INIT.name()));
String levelType = reqDTO.getLevelType(); String levelType = reqDTO.getLevelType();
String levelValue = reqDTO.getLevelValue(); String levelValue = reqDTO.getLevelValue();
...@@ -775,7 +776,7 @@ class OrderRequestScheduler { ...@@ -775,7 +776,7 @@ class OrderRequestScheduler {
List<Line> newTasks = new ArrayList<>(); List<Line> newTasks = new ArrayList<>();
for (OrderInfoEntity o : orderRequests) { for (OrderInfoEntity o : orderRequests) {
if (!o.getAppointmentStatus().equals("INIT")) { if (!o.getAppointmentStatus().equals(OrderFlowEnum.INIT.name())) {
continue; continue;
} }
Line t = new Line(o.getOrderId(), 30); Line t = new Line(o.getOrderId(), 30);
......
...@@ -7,6 +7,7 @@ import com.dituhui.pea.order.dao.*; ...@@ -7,6 +7,7 @@ import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.EngineersGanttDTO; import com.dituhui.pea.order.dto.EngineersGanttDTO;
import com.dituhui.pea.order.dto.LabelValueDTO; import com.dituhui.pea.order.dto.LabelValueDTO;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.service.EngineerGanttService; import com.dituhui.pea.order.service.EngineerGanttService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -84,7 +85,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -84,7 +85,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
slots = new ArrayList<>(); slots = new ArrayList<>();
} }
slot.setBgColor(getColor(order.getServiceStatus())); slot.setBgColor(getColor(order.getServiceStatus()));
if (!order.getAppointmentStatus().equals("CONFIRM")) { if (!order.getAppointmentStatus().equals(OrderFlowEnum.CONFIRM.name())) {
slot.setBorderStyle("dashed"); // 未确认的指派,统一加上虚框 slot.setBorderStyle("dashed"); // 未确认的指派,统一加上虚框
} }
slots.add(slot); slots.add(slot);
......
...@@ -12,6 +12,7 @@ import com.dituhui.pea.order.entity.OrderEventEntity; ...@@ -12,6 +12,7 @@ import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity; import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.entity.OrgWarehouseInfoEntity; import com.dituhui.pea.order.entity.OrgWarehouseInfoEntity;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.service.EngineerTimelineService; import com.dituhui.pea.order.service.EngineerTimelineService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -88,7 +89,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService { ...@@ -88,7 +89,7 @@ public class EngineerTimelineServiceImpl implements EngineerTimelineService {
private List<OrderInfoEntity> selectEngineerOrders(String engineerCode, LocalDate dt){ private List<OrderInfoEntity> selectEngineerOrders(String engineerCode, LocalDate dt){
List<OrderInfoEntity> orders = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn( List<OrderInfoEntity> orders = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineerCode, dt, List.of("PRE", "CONFIRM")); engineerCode, dt, List.of(OrderFlowEnum.PRE.name(), OrderFlowEnum.CONFIRM.name()));
return orders.stream().filter(o -> !o.getOrderStatus().equals("CANCEL")).collect(Collectors.toList()); return orders.stream().filter(o -> !o.getOrderStatus().equals("CANCEL")).collect(Collectors.toList());
} }
......
...@@ -3,15 +3,18 @@ package com.dituhui.pea.order.service.impl; ...@@ -3,15 +3,18 @@ package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.OrderAssignCheck; import com.dituhui.pea.order.common.OrderAssignCheck;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.LabelValueDTO; import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.dto.OrderAssignRecommendResp;
import com.dituhui.pea.order.dto.TimeLineDTO;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderStatus;
import com.dituhui.pea.order.service.CommonService; import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.OrderAssign; import com.dituhui.pea.order.service.OrderAssign;
import com.dituhui.pea.order.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -61,6 +64,9 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -61,6 +64,9 @@ public class OrderAssignImpl implements OrderAssign {
@Autowired @Autowired
private EntityManager entityManager; private EntityManager entityManager;
@Autowired
private OrderInfoService orderInfoService;
@Transactional @Transactional
@Override @Override
public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) { public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) {
...@@ -86,7 +92,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -86,7 +92,7 @@ public class OrderAssignImpl implements OrderAssign {
// 获取已技术员已指派订单列表 // 获取已技术员已指派订单列表
List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn( List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineer.getEngineerCode(), order.getDt(), List.of("CONFIRM")); engineer.getEngineerCode(), order.getDt(), List.of(OrderFlowEnum.CONFIRM.name()));
// 获取订单tips // 获取订单tips
HashMap<String, List<LabelValueDTO>> orderTips = new HashMap<>(); HashMap<String, List<LabelValueDTO>> orderTips = new HashMap<>();
...@@ -126,45 +132,46 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -126,45 +132,46 @@ public class OrderAssignImpl implements OrderAssign {
@Transactional @Transactional
@Override @Override
public Result<?> orderAssign(String orderId, String engineerCode) throws BusinessException { public Result<?> orderAssign(OrderAssignReq req) throws BusinessException {
// 服务单指派-指派提交 // 服务单指派-指派提交
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId); OrderInfoEntity order = orderInfoDao.getByOrderId(req.getOrderId());
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(engineerCode); EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(req.getEngineerCode());
boolean record = false; boolean record = false;
OrderInfoEntity op = orderInfoDao.getByOrderIdAndDt(orderId, order.getDt()); OrderInfoEntity op = orderInfoDao.getByOrderIdAndDt(req.getOrderId(), order.getDt());
if (op != null) { if (op != null) {
record = true; record = true;
} }
if (op != null && !order.getAppointmentStatus().equals("NOT_ASSIGNED") && op.getEngineerCode().equals(engineerCode)) { if (op != null && !order.getAppointmentStatus().equals("NOT_ASSIGNED") && op.getEngineerCode().equals(req.getEngineerCode())) {
throw new BusinessException(String.format("订单已指派个技术员[%s], 不必重复指派给同一个技术员", engineer.getName())); throw new BusinessException(String.format("订单已指派个技术员[%s], 不必重复指派给同一个技术员", engineer.getName()));
} }
OrderAssignCheck.Result result = orderAssignCheck.orderAssignCheck(orderId, order.getDt(), engineerCode); // OrderAssignCheck.Result result = orderAssignCheck.orderAssignCheck(orderId, order.getDt(), engineerCode);
log.info("指派检查结果:{}", result); // log.info("指派检查结果:{}", result);
if (result.getIndex() < 0) { // if (result.getIndex() < 0) {
throw new BusinessException("指派失败, 未能找到合适的时间段, 请选择其他技术员"); // throw new BusinessException("指派失败, 未能找到合适的时间段, 请选择其他技术员");
} // }
OrderAssignCheck.OrderNode insertNode = result.getCurOrderNode(); // OrderAssignCheck.OrderNode insertNode = result.getCurOrderNode();
Timestamp planStartTime = Timestamp.valueOf(insertNode.getPlanStartTime()); // Timestamp planStartTime = Timestamp.valueOf(insertNode.getPlanStartTime());
Timestamp planEndTime = Timestamp.valueOf(insertNode.getPlanEndTime()); // Timestamp planEndTime = Timestamp.valueOf(insertNode.getPlanEndTime());
// 更新order_info表状态 // 更新order_info表状态
String sql = "UPDATE OrderInfo e SET e.appointmentStatus = 'CONFIRM', e.appointmentMethod='MANUAL', e.planStartTime = :planStartTime, e.planEndTime = :panEndTime WHERE e.orderId = :orderId"; // 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 query = entityManager.createQuery(sql);
query.setParameter("planStartTime", planStartTime); // query.setParameter("planStartTime", planStartTime);
query.setParameter("planEndTime", planEndTime); // query.setParameter("planEndTime", planEndTime);
query.setParameter("orderId", orderId); // query.setParameter("orderId", orderId);
query.executeUpdate(); // query.executeUpdate();
order.setEngineerCode(engineer.getEngineerCode());
orderInfoDao.save(order);
// 工单变更登记 // 工单变更登记
commonService.addOrderEvent(orderId, "", "PEA-WEB", "API", "工单指派", "工单指派", ""); commonService.addOrderEvent(req.getOrderId(), "", "PEA-WEB", req.getOperator(), OrderStatus.ASSIGN.getDescription(), OrderStatus.ASSIGN.getDescription(), "");
return Result.success(null); return Result.success(null);
} }
...@@ -179,7 +186,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -179,7 +186,7 @@ public class OrderAssignImpl implements OrderAssign {
} }
// 更新order_request表为未指派 // 更新order_request表为未指派
order.setAppointmentStatus("INIT"); order.setAppointmentStatus(OrderFlowEnum.INIT.name());
entityManager.merge(order); entityManager.merge(order);
// 操作员ID TODO-用户系统 // 操作员ID TODO-用户系统
...@@ -190,10 +197,12 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -190,10 +197,12 @@ public class OrderAssignImpl implements OrderAssign {
} }
@Override @Override
public Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc) throws BusinessException { public Result<?> orderReschedule(OrderReschedule req) throws BusinessException {
// 工单改约接口(当前同放回工单池处理) // 工单改约接口(当前同放回工单池处理)
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId); LocalDateTime expectBegin = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectBegin());
LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd());
OrderInfoEntity order = orderInfoDao.getByOrderId(req.getOrderId());
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
...@@ -207,18 +216,33 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -207,18 +216,33 @@ public class OrderAssignImpl implements OrderAssign {
LocalDate originDate = order.getDt(); // 改约前的日期 LocalDate originDate = order.getDt(); // 改约前的日期
// 更新order_info表 // 更新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"; // 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 query = entityManager.createQuery(sql);
query.setParameter("dt", expectBegin.toLocalDate()); // query.setParameter("dt", expectBegin.toLocalDate());
query.setParameter("expectTimeBegin", expectBegin); // query.setParameter("expectTimeBegin", expectBegin);
query.setParameter("expectTimeEnd", expectEnd); // query.setParameter("expectTimeEnd", expectEnd);
query.setParameter("expectTimeDesc", expectDesc); // query.setParameter("expectTimeDesc", expectDesc);
query.setParameter("orderId", orderId); // query.setParameter("orderId", orderId);
query.executeUpdate(); // query.executeUpdate();
order.setAppointmentStatus(OrderFlowEnum.INIT.name());
order.setDt(expectBegin.toLocalDate());
order.setExpectTimeBegin(expectBegin);
order.setExpectTimeEnd(expectEnd);
order.setExpectTimeDesc(req.getExpectDesc());
//处理一家多单逻辑
Result<String> deleteMultipleOrders = orderInfoService.deleteMultipleOrders(order.getMultipleOrders(), order.getAddressId());
if (!deleteMultipleOrders.getCode().equals(ResultEnum.SUCCESS.getCode())) {
throw new BusinessException("改约日期失败");
}
Result<String> multipleOrdersResult = orderInfoService.addMultipleOrders(expectBegin.toLocalDate(), order.getAddressId(), req.getOrderId());
if (!multipleOrdersResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
throw new BusinessException("改约日期失败");
}
order.setMultipleOrders(multipleOrdersResult.getResult());
orderInfoDao.save(order);
// 操作员ID TODO-用户系统 // 操作员ID TODO-用户系统
// 登记事件 // 登记事件
commonService.addOrderEvent(orderId, "", "PEA-WEB", "123", "已改约", "已改约", ""); commonService.addOrderEvent(req.getOrderId(), "", "PEA-WEB", req.getOperator(), OrderStatus.RESCHEDULED.getDescription(), OrderStatus.RESCHEDULED.getDescription(), "");
return Result.success(null); return Result.success(null);
} }
...@@ -288,13 +312,13 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -288,13 +312,13 @@ public class OrderAssignImpl implements OrderAssign {
} }
List<OrgTeamEntity> teams = new ArrayList<>(); List<OrgTeamEntity> teams = new ArrayList<>();
if(levelType.equals("cluster")){ if (levelType.equals("cluster")) {
teams = orgTeamDao.findAllByClusterId(levelValue); teams = orgTeamDao.findAllByClusterId(levelValue);
} else if (levelType.equals("branch")){ } else if (levelType.equals("branch")) {
teams = orgTeamDao.findAllByBranchId(levelValue); teams = orgTeamDao.findAllByBranchId(levelValue);
} else if (levelType.equals("group")){ } else if (levelType.equals("group")) {
teams = orgTeamDao.findAllByGroupId(levelValue); teams = orgTeamDao.findAllByGroupId(levelValue);
} else if (levelType.equals("team")){ } else if (levelType.equals("team")) {
teams = orgTeamDao.findAllByTeamId(levelValue); teams = orgTeamDao.findAllByTeamId(levelValue);
} }
List<String> groupIds = teams.stream().map(OrgTeamEntity::getGroupId).collect(Collectors.toList()); List<String> groupIds = teams.stream().map(OrgTeamEntity::getGroupId).collect(Collectors.toList());
......
...@@ -26,6 +26,7 @@ import com.dituhui.pea.order.dto.LocationDTO; ...@@ -26,6 +26,7 @@ import com.dituhui.pea.order.dto.LocationDTO;
import com.dituhui.pea.order.dto.OrderCreateReqDTO; import com.dituhui.pea.order.dto.OrderCreateReqDTO;
import com.dituhui.pea.order.dto.ParameterRespDTO; import com.dituhui.pea.order.dto.ParameterRespDTO;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.service.CommonService; import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.OrderCreateService; import com.dituhui.pea.order.service.OrderCreateService;
import io.seata.core.context.RootContext; import io.seata.core.context.RootContext;
...@@ -145,7 +146,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -145,7 +146,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setAddress(location.getFormattedAddress()); entity.setAddress(location.getFormattedAddress());
} }
// 默认值 // 默认值
entity.setAppointmentStatus("INIT"); entity.setAppointmentStatus(OrderFlowEnum.INIT.name());
entity.setBeanStatus("OPEN"); entity.setBeanStatus("OPEN");
entity.setBeanSubStatus(""); entity.setBeanSubStatus("");
entity.setAppointmentStatus("NOT_ASSIGNED"); entity.setAppointmentStatus("NOT_ASSIGNED");
...@@ -226,7 +227,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -226,7 +227,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(assignEngineerCode); EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(assignEngineerCode);
thisOrderEntity.setEngineerName(engineerInfo.getName()); thisOrderEntity.setEngineerName(engineerInfo.getName());
thisOrderEntity.setEngineerPhone(engineerInfo.getPhone()); thisOrderEntity.setEngineerPhone(engineerInfo.getPhone());
thisOrderEntity.setAppointmentStatus("PRE"); thisOrderEntity.setAppointmentStatus(OrderFlowEnum.PRE.name());
thisOrderEntity.setDispatcher("AUTO_NOW"); thisOrderEntity.setDispatcher("AUTO_NOW");
thisOrderEntity.setPlanStartTime(insertNode.getPlanStartTime()); thisOrderEntity.setPlanStartTime(insertNode.getPlanStartTime());
thisOrderEntity.setPlanEndTime(insertNode.getPlanEndTime()); thisOrderEntity.setPlanEndTime(insertNode.getPlanEndTime());
......
...@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -32,12 +33,16 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -32,12 +33,16 @@ public class OrderInfoServiceImpl implements OrderInfoService {
*/ */
@Override @Override
@Transactional @Transactional
public Result<String> addMultipleOrders(String dt, String addressId) { public Result<String> addMultipleOrders(LocalDate dt, String addressId, String orderId) {
List<OrderInfoEntity> infoList = orderInfoDao.findByDtAndAddressId(dt, addressId); List<OrderInfoEntity> infoList = orderInfoDao.findByDtAndAddressId(dt, addressId);
if (CollectionUtils.isEmpty(infoList)) { if (CollectionUtils.isEmpty(infoList)) {
return Result.success(null); return Result.success(null);
} }
List<String> multipleOrdersList = infoList.stream().filter(e -> StringUtils.isNotEmpty(e.getMultipleOrders())).map(OrderInfoEntity::getMultipleOrders).distinct().collect(Collectors.toList()); List<String> multipleOrdersList = infoList.stream().filter(e -> StringUtils.isNotEmpty(e.getMultipleOrders()) && !e.getOrderId().equals(orderId))
.map(OrderInfoEntity::getMultipleOrders).distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(multipleOrdersList)) {
return Result.success(null);
}
if (CollectionUtils.isNotEmpty(multipleOrdersList)) { if (CollectionUtils.isNotEmpty(multipleOrdersList)) {
return Result.success(multipleOrdersList.get(0)); return Result.success(multipleOrdersList.get(0));
} }
...@@ -59,6 +64,9 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -59,6 +64,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Override @Override
@Transactional @Transactional
public Result deleteMultipleOrders(String multipleOrders, String orderId) { public Result deleteMultipleOrders(String multipleOrders, String orderId) {
if (StringUtils.isBlank(multipleOrders)) {
return Result.success();
}
List<OrderInfoEntity> infoList = orderInfoDao.findByMultipleOrders(multipleOrders); List<OrderInfoEntity> infoList = orderInfoDao.findByMultipleOrders(multipleOrders);
for (OrderInfoEntity infoEntity : infoList) { for (OrderInfoEntity infoEntity : infoList) {
if (infoEntity.getOrderId().equals(orderId)) { if (infoEntity.getOrderId().equals(orderId)) {
......
...@@ -9,6 +9,7 @@ import com.dituhui.pea.order.dto.param.Order; ...@@ -9,6 +9,7 @@ import com.dituhui.pea.order.dto.param.Order;
import com.dituhui.pea.order.dto.param.OrderDTO; import com.dituhui.pea.order.dto.param.OrderDTO;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity; import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.service.PeaOuterAPIService; import com.dituhui.pea.order.service.PeaOuterAPIService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -61,7 +62,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService { ...@@ -61,7 +62,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
@Override @Override
public Order orderIncreaseQuery(String engineerCode, Location location, Integer idleDuration) { public Order orderIncreaseQuery(String engineerCode, Location location, Integer idleDuration) {
OrderInfoEntity sss = orderInfoDao.findTopBySkillAndAppointmentStatus("标准安装", "INIT"); OrderInfoEntity sss = orderInfoDao.findTopBySkillAndAppointmentStatus("标准安装", OrderFlowEnum.INIT.name());
Order order = new Order(); Order order = new Order();
order.setOrderId(sss.getOrderId()); order.setOrderId(sss.getOrderId());
......
...@@ -8,6 +8,7 @@ import com.dituhui.pea.order.common.TimeUtils; ...@@ -8,6 +8,7 @@ import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*; import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.service.ScheduleService; import com.dituhui.pea.order.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -94,7 +95,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -94,7 +95,7 @@ public class ScheduleServiceImpl implements ScheduleService {
team.setLevel("team"); team.setLevel("team");
// 获取改team订单列表 // 获取改team订单列表
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndOrgTeamIdAndAppointmentStatusIn(date, t.getTeamId(), List.of("PRE", "CONFIRM")); List<OrderInfoEntity> orders = orderInfoDao.findByDtAndOrgTeamIdAndAppointmentStatusIn(date, t.getTeamId(), List.of(OrderFlowEnum.PRE.name(), OrderFlowEnum.CONFIRM.name()));
team.setOrder(this.getTeamOrderSum(orders, skillMapping)); team.setOrder(this.getTeamOrderSum(orders, skillMapping));
// 技术员指派单列表 // 技术员指派单列表
...@@ -159,7 +160,7 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -159,7 +160,7 @@ public class ScheduleServiceImpl implements ScheduleService {
List<LabelValueDTO> emptyTips = new ArrayList<>(); List<LabelValueDTO> emptyTips = new ArrayList<>();
List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn( List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineerCode, date, List.of("PRE", "CONFIRM")); engineerCode, date, List.of(OrderFlowEnum.PRE.name(), OrderFlowEnum.CONFIRM.name()));
List<TimeLineDTO> timelines = new ArrayList<>(); List<TimeLineDTO> timelines = new ArrayList<>();
for (OrderInfoEntity o : orderAppointments) { for (OrderInfoEntity o : orderAppointments) {
TimeLineDTO item = new TimeLineDTO(); TimeLineDTO item = new TimeLineDTO();
......
...@@ -10,6 +10,7 @@ import com.dituhui.pea.order.dto.OrderChangeListDTO; ...@@ -10,6 +10,7 @@ import com.dituhui.pea.order.dto.OrderChangeListDTO;
import com.dituhui.pea.order.dto.WorkbenchSummaryResp; import com.dituhui.pea.order.dto.WorkbenchSummaryResp;
import com.dituhui.pea.order.entity.OrderEventEntity; import com.dituhui.pea.order.entity.OrderEventEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.service.WorkbenchService; import com.dituhui.pea.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -240,7 +241,7 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -240,7 +241,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
Long autoTotal = summary.getOrDefault("autoTotal", 0L); Long autoTotal = summary.getOrDefault("autoTotal", 0L);
Long total = summary.getOrDefault("total", 0L); Long total = summary.getOrDefault("total", 0L);
HashMap<String, List<String>> p = this.packParams("appointmentStatus", "INIT"); HashMap<String, List<String>> p = this.packParams("appointmentStatus", OrderFlowEnum.INIT.name());
HashMap<String, List<String>> p1 = this.packParams("appointmentType", "MANUAL"); HashMap<String, List<String>> p1 = this.packParams("appointmentType", "MANUAL");
p1.putAll(p); p1.putAll(p);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!