Commit 13906767 by 丁伟峰

修改了原先的OrderRequest和OrderAppointment相关的代码

1 parent 78cd8dd4
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrderAppointmentEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface OrderAppointmentDao extends JpaRepository<OrderAppointmentEntity, Integer> {
@Query("from OrderAppointmentEntity a where DATE_FORMAT(a.expectStartTime, '%Y-%m-%d') = :date and a.engineerCode in :engineerCodes")
List<OrderAppointmentEntity> findByDateAndEngineerCodeIn(String date, List<?> engineerCodes);
}
...@@ -12,13 +12,13 @@ import java.util.Date; ...@@ -12,13 +12,13 @@ import java.util.Date;
@Repository @Repository
public interface OrderEventDao extends JpaRepository<OrderEventEntity, Integer> { 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") @Query("select a from OrderEventEntity a join OrderInfoEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByClusterId(String clusterId, Date date, Pageable pageable); 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") @Query("select a from OrderEventEntity a join OrderInfoEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByBranchId(String branchId, Date date, Pageable pageable); 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") @Query("select a from OrderEventEntity a join OrderInfoEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByGroupId(String groupId, Date date, Pageable pageable); Page<OrderEventEntity> findAllByGroupId(String groupId, Date date, Pageable pageable);
} }
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.OrderRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrderRequestDao extends JpaRepository<OrderRequestEntity, Long> {
OrderRequestEntity getByOrderId(String orderId);
List<OrderRequestEntity> findAllByOrderIdIn(List<String> orderIds);
@Query("SELECT o.orderId, s.skillCategory as skillCaption FROM OrderRequestEntity 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(@Param("orderId") String orderId);
}
package com.dituhui.pea.order.dto;
import lombok.Data;
@Data
public class OrderAssignCheckDTO {
// 待插入的位置
private int index;
private boolean isHead;
private boolean isTail;
private String curOrderId;
private String postOrderId;
// 当前工单
private OrderNode curOrderNode;
// 插入后的工单
private OrderNode postOrderNode;
// 插入后的工单在改变前的数据值
private OrderNode postOrderNodeOrg;
@Data
public static class OrderNode {
private String orderId;
private int takeTime;
private int arriveDistance;
private int arriveElapsed;
}
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import javax.persistence.*;
@Data
@Entity
@Table(name = "order_appointment")
public class OrderAppointmentEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "order_id", nullable = false)
private String orderId;
@Column(name = "suborder_id", nullable = false)
private String suborderId;
@Column(name = "main_sub", nullable = false)
private Boolean mainSub;
@Column(name = "engineer_code", nullable = false)
private String engineerCode;
@Column(name = "engineer_name", nullable = false)
private String engineerName;
@Column(name = "engineer_phone", nullable = false)
private String engineerPhone;
@Column(name = "engineer_age", nullable = false)
private Integer engineerAge;
@Column(name = "is_workshop", nullable = false)
private Boolean isWorkshop;
@Column
private LocalDate dt;
@Column(name = "expect_start_time")
private LocalDateTime expectStartTime;
@Column(name = "expect_end_time")
private LocalDateTime expectEndTime;
@Column(name = "actual_time")
private LocalDateTime actualTime;
@Column(name = "actual_start_time")
private LocalDateTime actualStartTime;
@Column(name = "actual_end_time")
private LocalDateTime actualEndTime;
@Column(name = "pre_status")
private String preStatus;
@Column(nullable = false)
private String status;
@Column(length = 100, nullable = false)
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
// Getters and Setters
// ...
}
...@@ -11,18 +11,45 @@ import java.time.LocalDateTime; ...@@ -11,18 +11,45 @@ import java.time.LocalDateTime;
@Accessors(chain = true) @Accessors(chain = true)
@Table(name="order_event") @Table(name="order_event")
public class OrderEventEntity { public class OrderEventEntity {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, columnDefinition = "int(11)")
private Integer id; private Integer id;
@Column(name = "order_id", nullable = false, length = 50)
private String orderId; private String orderId;
@Column(name = "suborder_id", nullable = false, length = 50, columnDefinition = "varchar(50) default ''")
private String suborderId; private String suborderId;
@Column(name = "happen", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime happen; private LocalDateTime happen;
@Column(name = "event", nullable = false, length = 50, columnDefinition = "varchar(50) default ''")
private String event; private String event;
@Column(name = "description", nullable = false, length = 100, columnDefinition = "varchar(100) default ''")
private String description;
@Column(name = "operator", nullable = false, length = 50, columnDefinition = "varchar(50) default ''")
private String operator; private String operator;
@Column(name = "operator_name", nullable = false, length = 50, columnDefinition = "varchar(50) default 'PEA-WEB'")
private String operatorName; private String operatorName;
@Column(name = "source", nullable = false, length = 20, columnDefinition = "varchar(20) default ''")
private String source; private String source;
private String description;
@Column(name = "memo", nullable = false, length = 100, columnDefinition = "varchar(100) default ''")
private String memo; private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "datetime default current_timestamp")
private LocalDateTime createTime; private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "datetime default current_timestamp")
private LocalDateTime updateTime; private LocalDateTime updateTime;
// Getters and setters (省略)
} }
...@@ -44,10 +44,10 @@ public class OrderInfoEntity { ...@@ -44,10 +44,10 @@ public class OrderInfoEntity {
private String address; private String address;
@Column(name = "x", nullable = false, length = 20) @Column(name = "x", nullable = false, length = 20)
private String x; private String x="0";
@Column(name = "y", nullable = false, length = 20) @Column(name = "y", nullable = false, length = 20)
private String y; private String y="0";
@Column(name = "brand", nullable = false, length = 20) @Column(name = "brand", nullable = false, length = 20)
private String brand; private String brand;
...@@ -79,7 +79,7 @@ public class OrderInfoEntity { ...@@ -79,7 +79,7 @@ public class OrderInfoEntity {
@Column(name = "expect_time_desc", length = 50, columnDefinition = "varchar(50) default ''") @Column(name = "expect_time_desc", length = 50, columnDefinition = "varchar(50) default ''")
private String expectTimeDesc; private String expectTimeDesc;
@Column(name = "source", nullable = false, length = 10, columnDefinition = "varchar(10) default ''") @Column(name = "source", nullable = true, length = 10, columnDefinition = "varchar(10) default ''")
private String source; private String source;
@Column(name = "bean_priority", length = 10) @Column(name = "bean_priority", length = 10)
...@@ -88,11 +88,11 @@ public class OrderInfoEntity { ...@@ -88,11 +88,11 @@ public class OrderInfoEntity {
@Column(name = "bean_tags", length = 200) @Column(name = "bean_tags", length = 200)
private String beanTags; private String beanTags;
@Column(name = "bean_status", nullable = false, length = 20, columnDefinition = "varchar(20) default 'OPEN'") @Column(name = "bean_status", nullable = true, length = 20, columnDefinition = "varchar(20) default 'OPEN'")
private String beanStatus; private String beanStatus = "OPEN";
@Column(name = "bean_sub_status", nullable = false, length = 20, columnDefinition = "varchar(20) default ''") @Column(name = "bean_sub_status", nullable = true, length = 20, columnDefinition = "varchar(20) default ''")
private String beanSubStatus; private String beanSubStatus = "";
@Column(name = "area_id", length = 32) @Column(name = "area_id", length = 32)
private String areaId; private String areaId;
...@@ -118,26 +118,26 @@ public class OrderInfoEntity { ...@@ -118,26 +118,26 @@ public class OrderInfoEntity {
@Column(name = "appointment_method", length = 20, columnDefinition = "varchar(20) default 'AUTO_BATCH'") @Column(name = "appointment_method", length = 20, columnDefinition = "varchar(20) default 'AUTO_BATCH'")
private String appointmentMethod; private String appointmentMethod;
@Column(name = "appointment_status", nullable = false, length = 20, columnDefinition = "varchar(20) default 'INIT'") @Column(name = "appointment_status", nullable = true, length = 20, columnDefinition = "varchar(20) default 'INIT'")
private String appointmentStatus; private String appointmentStatus;
@Column(name = "order_status", length = 20, columnDefinition = "varchar(20) default 'NORMAL'") @Column(name = "order_status", length = 20, columnDefinition = "varchar(20) default 'NORMAL'")
private String orderStatus; private String orderStatus = "NORMAL";
@Column(name = "service_status", nullable = false, length = 20, columnDefinition = "varchar(20) default 'INIT'") @Column(name = "service_status", nullable = true, length = 20, columnDefinition = "varchar(20) default 'INIT'")
private String serviceStatus; private String serviceStatus = "INIT";
@Column(name = "engineer_code", nullable = false, length = 32, columnDefinition = "varchar(32) default ''") @Column(name = "engineer_code", nullable = true, length = 32, columnDefinition = "varchar(32) default ''")
private String engineerCode; private String engineerCode = "";
@Column(name = "engineer_name", nullable = false, length = 20, columnDefinition = "varchar(20) default ''") @Column(name = "engineer_name", nullable = true, length = 20, columnDefinition = "varchar(20) default ''")
private String engineerName; private String engineerName = "";
@Column(name = "engineer_phone", nullable = false, length = 20, columnDefinition = "varchar(20) default ''") @Column(name = "engineer_phone", nullable = true, length = 20, columnDefinition = "varchar(20) default ''")
private String engineerPhone; private String engineerPhone = "";
@Column(name = "engineer_code_sub", nullable = false, length = 32, columnDefinition = "varchar(32) default ''") @Column(name = "engineer_code_sub", nullable = true, length = 32, columnDefinition = "varchar(32) default ''")
private String engineerCodeSub; private String engineerCodeSub = "";
@Column(name = "plan_start_time") @Column(name = "plan_start_time")
private LocalDateTime planStartTime; private LocalDateTime planStartTime;
...@@ -145,10 +145,10 @@ public class OrderInfoEntity { ...@@ -145,10 +145,10 @@ public class OrderInfoEntity {
@Column(name = "plan_end_time") @Column(name = "plan_end_time")
private LocalDateTime planEndTime; private LocalDateTime planEndTime;
@Column(name = "arrive_elapsed", nullable = false, columnDefinition = "int(11) default '0'") @Column(name = "arrive_elapsed", nullable = true, columnDefinition = "int(11) default '0'")
private int arriveElapsed; private int arriveElapsed;
@Column(name = "arrive_distance", nullable = false, columnDefinition = "int(11) default '0'") @Column(name = "arrive_distance", nullable = true, columnDefinition = "int(11) default '0'")
private int arriveDistance; private int arriveDistance;
@Column(name = "actual_start_time") @Column(name = "actual_start_time")
...@@ -163,10 +163,10 @@ public class OrderInfoEntity { ...@@ -163,10 +163,10 @@ public class OrderInfoEntity {
@Column(name = "extra_info", columnDefinition = "json") @Column(name = "extra_info", columnDefinition = "json")
private String extraInfo; private String extraInfo;
@Column(name = "create_time", nullable = false, columnDefinition = "timestamp default current_timestamp") @Column(name = "create_time", nullable = true, columnDefinition = "timestamp default current_timestamp")
private LocalDateTime createTime; private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp") @Column(name = "update_time", nullable = true, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime updateTime; private LocalDateTime updateTime;
// Getters and setters (omitted for brevity) // Getters and setters (omitted for brevity)
......
/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dituhui.pea.order.mapper;
import com.dituhui.pea.order.entity.OrderRequestEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.springframework.stereotype.Repository;
/**
* @author TrevorLink
*/
@Mapper
@Repository
public interface OrderMapper {
@Insert("INSERT INTO `order` (user_id, commodity_code,money,create_time,update_time) VALUES (#{userId}, #{commodityCode},#{money},#{createTime},#{updateTime})")
@Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
int saveOrder(OrderRequestEntity orderRequestEntity);
}
...@@ -40,18 +40,6 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -40,18 +40,6 @@ public class EngineerServiceImpl implements EngineerService {
@Autowired @Autowired
private EngineerBusinessMPDao engineerBusinessDao; private EngineerBusinessMPDao engineerBusinessDao;
@Autowired
private OrderRequestDao orderRequestDao;
@Autowired
private OrderAppointmentDao orderAppointmentDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private CapacityEngineerStatDao capacityEngineerStatDao;
@Transactional @Transactional
@Override @Override
......
...@@ -35,8 +35,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -35,8 +35,8 @@ 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.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -50,28 +50,35 @@ import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATETIME; ...@@ -50,28 +50,35 @@ import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATETIME;
public class OrderCreateServiceImpl implements OrderCreateService { public class OrderCreateServiceImpl implements OrderCreateService {
@Autowired @Autowired
private OrderRequestDao orderRequestDao;
@Autowired
private OrgTeamDao orgTeamDao; private OrgTeamDao orgTeamDao;
@Autowired @Autowired
private CommonService commonService; private CommonService commonService;
@Autowired @Autowired
private CapacityUtils capacityUtils; private CapacityUtils capacityUtils;
@Autowired @Autowired
private SaasUtils saasUtils; private SaasUtils saasUtils;
@Autowired @Autowired
private EngineerUtils engineerUtils; private EngineerUtils engineerUtils;
@Autowired @Autowired
private EngineerSkillDao engineerSkillDao; private EngineerSkillDao engineerSkillDao;
@Autowired @Autowired
private OrderAssignCheck orderAssignCheck; private OrderAssignCheck orderAssignCheck;
@Autowired
private OrderAppointmentDao orderAppointmentDao;
@Autowired @Autowired
private EngineerInfoDao engineerInfoDao; private EngineerInfoDao engineerInfoDao;
@Autowired
private OrderInfoDao orderInfoDao;
@Autowired
private SkillInfoDao skillInfoDao;
private List<LabelValueDTO> getPriorities() { private List<LabelValueDTO> getPriorities() {
String[] priorities = {"紧急", "正常"}; String[] priorities = {"紧急", "正常"};
List<LabelValueDTO> listPriorities = new ArrayList<>(); List<LabelValueDTO> listPriorities = new ArrayList<>();
...@@ -102,33 +109,51 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -102,33 +109,51 @@ public class OrderCreateServiceImpl implements OrderCreateService {
@Transactional @Transactional
public Result<?> createOrder(OrderCreateReqDTO req) { public Result<?> createOrder(OrderCreateReqDTO req) {
log.info("[createOrder] current XID: {}", RootContext.getXID()); log.info("[createOrder] current XID: {}", RootContext.getXID());
OrderRequestEntity entity = new OrderRequestEntity(); OrderInfoEntity entity = new OrderInfoEntity();
entity.setId(IdUtil.getSnowflake().nextIdStr());
String orderId = req.getOrderId(); String orderId = req.getOrderId();
if (StringUtils.isEmpty(orderId)) { if (StringUtils.isEmpty(orderId)) {
String s = UUID.randomUUID().toString().replace("-", ""); String s = UUID.randomUUID().toString().replace("-", "");
orderId = s.substring(s.length() - 9); orderId = s.substring(s.length() - 9);
} }
entity.setSource("PEA");
entity.setOrderId(orderId); entity.setOrderId(orderId);
entity.setName(req.getName()); entity.setName(req.getName());
entity.setPhone(req.getPhone()); entity.setPhone(req.getPhone());
entity.setBrand(req.getBrand()); entity.setBrand(req.getBrand());
entity.setType(req.getType()); entity.setType(req.getType());
entity.setSkill(req.getSkill()); entity.setSkill(req.getSkill());
entity.setFaultDescribe(req.getFaultDescribe()); entity.setFaultDescribe(req.getFaultDescribe());
entity.setExpectTimeBegin(LocalDateTimeUtil.parse(req.getExpectBegin(), PATTERN_DATETIME)); entity.setExpectTimeBegin(LocalDateTimeUtil.parse(req.getExpectBegin(), PATTERN_DATETIME));
entity.setExpectTimeEnd(LocalDateTimeUtil.parse(req.getExpectEnd(), PATTERN_DATETIME)); entity.setExpectTimeEnd(LocalDateTimeUtil.parse(req.getExpectEnd(), PATTERN_DATETIME));
entity.setExpectTimeDesc(req.getExpectDesc()); entity.setExpectTimeDesc(req.getExpectDesc());
entity.setApplyNote(req.getDescription()); // order_request的description字段,仅仅用于内部备注,不对外 entity.setApplyNote(req.getDescription()); // order_request的description字段,仅仅用于内部备注,不对外
entity.setDt(LocalDateTimeUtil.parseDate(req.getExpectBegin().substring(0, 10), PATTERN_DATE)); entity.setDt(LocalDateTimeUtil.parseDate(req.getExpectBegin().substring(0, 10), PATTERN_DATE));
entity.setSubId(newSubId(entity.getOrderId(), entity.getDt()));
// location // location
LocationDTO location = req.getLocation(); LocationDTO location = req.getLocation();
entity.setProvince(location.getProvince()); entity.setProvince(location.getProvince());
entity.setCity(location.getCity()); entity.setCity(location.getCity());
entity.setCounty(location.getDistrict()); entity.setCounty(location.getDistrict());
if (req.getAddress() != null) {
entity.setAddress(req.getAddress());
} else {
entity.setAddress(location.getFormattedAddress()); entity.setAddress(location.getFormattedAddress());
}
// 默认值
entity.setAppointmentStatus("INIT");
entity.setBeanStatus("OPEN");
entity.setBeanSubStatus("");
entity.setAppointmentStatus("NOT_ASSIGNED");
entity.setAppointmentMethod("AUTO_NOW");
entity.setWorkshop(false);
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(req.getBrand(), req.getType(), req.getSkill());
assert skillInfoEntity != null;
entity.setTakeTime(skillInfoEntity.getTakeTime());
// 基础保存
orderInfoDao.save(entity);
// 分单处理
List<String> blockIds = null; List<String> blockIds = null;
List<String> layerIds = capacityUtils.getLayers(req.getBrand(), req.getType(), req.getSkill()); List<String> layerIds = capacityUtils.getLayers(req.getBrand(), req.getType(), req.getSkill());
if (req.getLocation() != null) { if (req.getLocation() != null) {
...@@ -139,14 +164,12 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -139,14 +164,12 @@ public class OrderCreateServiceImpl implements OrderCreateService {
} }
if (blockIds.size() == 0) { if (blockIds.size() == 0) {
log.error("分单接口没有查到对应的结果"); log.error("分单接口没有查到对应的结果");
Result.failed(String.format("分单接口(address:%s)(location:%s) 没有查到配置区块", req.getAddress(), req.getLocation())); return Result.failed(String.format("分单接口(address:%s)(location:%s) 没有查到配置区块", req.getAddress(), req.getLocation()));
} }
List<String> teamIds = capacityUtils.getTeamIdsByBlockIdsAndLayerIds(blockIds, layerIds); List<String> teamIds = capacityUtils.getTeamIdsByBlockIdsAndLayerIds(blockIds, layerIds);
if (teamIds == null || teamIds.size() == 0) { if (teamIds == null || teamIds.size() == 0) {
Result.failed("没有找到匹配的工作队"); return Result.failed("没有找到匹配的工作队");
} }
// 选择一个工作队(理论上,只有1个合适的工作队),然后遍历下面的各个技术员,从符合技能的技术员中,汇总相关的容量 // 选择一个工作队(理论上,只有1个合适的工作队),然后遍历下面的各个技术员,从符合技能的技术员中,汇总相关的容量
// 遍历工作队,每个工作队 // 遍历工作队,每个工作队
String teamId = teamIds.get(0); String teamId = teamIds.get(0);
...@@ -158,13 +181,10 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -158,13 +181,10 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setOrgTeamId(teamId); entity.setOrgTeamId(teamId);
entity.setX(req.getLocation().getLng().toString()); entity.setX(req.getLocation().getLng().toString());
entity.setY(req.getLocation().getLat().toString()); entity.setY(req.getLocation().getLat().toString());
entity.setOrderTags(String.join(",", req.getOrderTags())); entity.setBeanTags(String.join(",", req.getOrderTags()));
entity.setOrderPriority(req.getPriority()); entity.setBeanPriority(req.getPriority());
// todo 服务单状态、预约状态等 // todo 服务单状态、预约状态等
entity.setStatus("OPEN"); orderInfoDao.save(entity);
entity.setAppointmentStatus("NOT_ASSIGNED");
entity.setAppointmentMethod("AUTO_NOW");
orderRequestDao.save(entity);
// 登记 // 登记
commonService.addOrderEvent(orderId, "", req.getSource(), "API", "创建订单", "创建订单", ""); commonService.addOrderEvent(orderId, "", req.getSource(), "API", "创建订单", "创建订单", "");
...@@ -174,7 +194,8 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -174,7 +194,8 @@ public class OrderCreateServiceImpl implements OrderCreateService {
return Result.success(null); return Result.success(null);
} }
private void tryVirtualAppointment(OrderCreateReqDTO req, OrderRequestEntity entity, String teamId) { private void tryVirtualAppointment(OrderCreateReqDTO req, OrderInfoEntity entity, String teamId) {
// todo 等王力那边修改后,这边再进行整合,需要返回当前工单、后面的一个工单的数据情况,这边再进行修改
try { try {
List<String> engineerCodes = engineerUtils.getEngineersByLevel("team", teamId).stream() List<String> engineerCodes = engineerUtils.getEngineersByLevel("team", teamId).stream()
.map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList()); .map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList());
...@@ -192,34 +213,24 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -192,34 +213,24 @@ public class OrderCreateServiceImpl implements OrderCreateService {
} }
} }
log.info("=== 指派尝试调用完成,选定的技术员 ==> {}, {}", assignEngineerCode, checkResult); log.info("=== 指派尝试调用完成,选定的技术员 ==> {}, {}", assignEngineerCode, checkResult);
// 虚拟指派登记 // 虚拟指派
if (StringUtils.isNotBlank(assignEngineerCode)) { if (StringUtils.isNotBlank(assignEngineerCode)) {
OrderAppointmentEntity oa = new OrderAppointmentEntity(); // 修改当前工单
oa.setDt(entity.getDt()); entity.setEngineerCode(assignEngineerCode);
oa.setOrderId(entity.getOrderId());
oa.setSuborderId(newSuborderId(entity.getOrderId()));
oa.setMainSub(true); // 总是主单
oa.setIsWorkshop(false);
oa.setEngineerCode(assignEngineerCode);
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(assignEngineerCode); EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(assignEngineerCode);
oa.setEngineerName(engineerInfo.getName()); entity.setEngineerName(engineerInfo.getName());
if (StringUtils.isNotBlank(engineerInfo.getBirth())) { entity.setEngineerPhone(engineerInfo.getPhone());
int age = (int) DateUtils.getAge(engineerInfo.getBirth()); entity.setAppointmentStatus("VIRTUAL");
oa.setEngineerAge(age); entity.setPlanStartTime(checkResult.getStart());
} else { entity.setPlanEndTime(checkResult.getEnd());
oa.setEngineerAge(0); entity.setArriveDistance(checkResult.getDistanceAddition());
} entity.setArriveElapsed(checkResult.getMinuteAddition());
oa.setEngineerPhone(engineerInfo.getPhone()); orderInfoDao.save(entity);
oa.setPreStatus("VIRTUAL");
oa.setStatus("ASSIGNED"); // 如果影响到原有工单,修改原有工单
oa.setMemo("创建订单,虚拟指派");
oa.setExpectStartTime(entity.getExpectTimeBegin());
oa.setExpectEndTime(entity.getExpectTimeEnd());
oa.setCreateTime(LocalDateTime.now());
oa.setUpdateTime(LocalDateTime.now());
orderAppointmentDao.save(oa);
// 登记 // 登记
commonService.addOrderEvent(entity.getOrderId(), "", req.getSource(), "API", "虚拟指派", "虚拟指派", ""); commonService.addOrderEvent(entity.getOrderId(), entity.getSubId(), req.getSource(), "API", "虚拟指派", "虚拟指派", "");
} }
log.info("==== 已经完成虚拟指派 ===="); log.info("==== 已经完成虚拟指派 ====");
} catch (Exception e) { } catch (Exception e) {
...@@ -227,7 +238,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -227,7 +238,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
} }
} }
private String newSuborderId(String orderId) { private String newSubId(String orderId, LocalDate date) {
return String.format("%s_%s", orderId, DateUtils.formatDateTime(LocalDateTime.now(), "yyyyMMddHHmmss")); return String.format("%s_%s", orderId, DateUtils.formatDateTime(LocalDateTime.now(), "MMdd"));
} }
} }
...@@ -7,8 +7,8 @@ import com.dituhui.pea.order.dao.*; ...@@ -7,8 +7,8 @@ import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.OrderChangeListDTO; 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.OrderRequest; import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.entity.OrderRequestEntity;
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;
...@@ -25,23 +25,14 @@ import java.util.*; ...@@ -25,23 +25,14 @@ import java.util.*;
public class WorkbenchServiceImpl implements WorkbenchService { public class WorkbenchServiceImpl implements WorkbenchService {
@Autowired @Autowired
private OrderRequestDao orderRequestDao;
@Autowired
private OrderAppointmentDao orderAppointmentDao;
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private CapacityEngineerStatDao capacityEngineerStatDao;
@Autowired
private OrderEventDao orderEventDao; private OrderEventDao orderEventDao;
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao; private OrderRequestMPDao orderRequestMPDao;
@Autowired
private OrderInfoDao orderInfoDao;
@Override @Override
public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) { public Result<?> getOrderChangeList(OrderChangeListDTO.Request reqDTO) {
Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize()); Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
...@@ -59,9 +50,9 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -59,9 +50,9 @@ public class WorkbenchServiceImpl implements WorkbenchService {
List<OrderChangeListDTO.Content> contents = new ArrayList<>(); List<OrderChangeListDTO.Content> contents = new ArrayList<>();
for (OrderEventEntity entity : page.getContent()) { for (OrderEventEntity entity : page.getContent()) {
OrderChangeListDTO.Content content = new OrderChangeListDTO.Content(); OrderChangeListDTO.Content content = new OrderChangeListDTO.Content();
OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(entity.getOrderId()); OrderInfoEntity orderInfoEntity = orderInfoDao.getByOrderId(entity.getOrderId());
content.setOrderId(entity.getOrderId()) content.setOrderId(entity.getOrderId())
.setCustomerName(orderRequestEntity.getName()) .setCustomerName(orderInfoEntity.getName())
.setOperator(entity.getOperator()) .setOperator(entity.getOperator())
.setDescription(entity.getDescription()) .setDescription(entity.getDescription())
.setMemo(entity.getMemo()) .setMemo(entity.getMemo())
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!