Commit ff17835d by 丁伟峰

日志补充、suborder_id字段补充

1 parent 8bc77898
...@@ -36,6 +36,7 @@ import org.springframework.stereotype.Service; ...@@ -36,6 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
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;
...@@ -168,30 +169,35 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -168,30 +169,35 @@ public class OrderCreateServiceImpl implements OrderCreateService {
commonService.addOrderEvent(orderId, "", req.getSource(), "API", "创建订单", "创建订单", ""); commonService.addOrderEvent(orderId, "", req.getSource(), "API", "创建订单", "创建订单", "");
// 指派检查,简单处理,遇到第一个可以指派的就停止检查 // 指派检查,简单处理,遇到第一个可以指派的就停止检查
tryVirtualAppointment(req, entity, orderId, teamId); tryVirtualAppointment(req, entity, teamId);
return Result.success(null); return Result.success(null);
} }
private void tryVirtualAppointment(OrderCreateReqDTO req, OrderRequestEntity entity, String orderId, String teamId) { private void tryVirtualAppointment(OrderCreateReqDTO req, OrderRequestEntity entity, String teamId) {
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());
List<String> matchEngineerCodes = engineerSkillDao.findAllByBrandAndTypeAndSkillAndEngineerCodeIn(req.getBrand(), req.getType(), req.getSkill(), engineerCodes).stream() List<String> matchEngineerCodes = engineerSkillDao.findAllByBrandAndTypeAndSkillAndEngineerCodeIn(req.getBrand(), req.getType(), req.getSkill(), engineerCodes).stream()
.map(EngineerSkillEntity::getEngineerCode).collect(Collectors.toList()); .map(EngineerSkillEntity::getEngineerCode).collect(Collectors.toList());
String assignEngineerCode = null; String assignEngineerCode = null;
OrderAssignCheck.Result checkResult = null;
log.info("=== 准备调用指派,候选的技术员列表: {}", matchEngineerCodes);
for (String engineerCode : matchEngineerCodes) { for (String engineerCode : matchEngineerCodes) {
OrderAssignCheck.Result checkResult = orderAssignCheck.orderAssignCheck(entity.getOrderId(), engineerCode); checkResult = orderAssignCheck.orderAssignCheck(entity.getOrderId(), engineerCode);
log.info("orderAssignCheck ===> orderId[{}]engineerCode[{}] ==> result[{}]", entity.getOrderId(), engineerCode, checkResult);
if (checkResult.getCanAssign()) { if (checkResult.getCanAssign()) {
assignEngineerCode = engineerCode; assignEngineerCode = engineerCode;
break; break;
} }
} }
log.info("=== 指派尝试调用完成,选定的技术员 ==> {}, {}", assignEngineerCode, checkResult);
// 虚拟指派登记 // 虚拟指派登记
if (StringUtils.isNotBlank(assignEngineerCode)) { if (StringUtils.isNotBlank(assignEngineerCode)) {
OrderAppointmentEntity oa = new OrderAppointmentEntity(); OrderAppointmentEntity oa = new OrderAppointmentEntity();
oa.setDt(entity.getDt()); oa.setDt(entity.getDt());
oa.setOrderId(entity.getOrderId()); oa.setOrderId(entity.getOrderId());
oa.setSuborderId(newSuborderId(entity.getOrderId()));
oa.setMainSub(true); // 总是主单 oa.setMainSub(true); // 总是主单
oa.setIsWorkshop(false); oa.setIsWorkshop(false);
oa.setEngineerCode(assignEngineerCode); oa.setEngineerCode(assignEngineerCode);
...@@ -213,12 +219,15 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -213,12 +219,15 @@ public class OrderCreateServiceImpl implements OrderCreateService {
oa.setUpdateTime(LocalDateTime.now()); oa.setUpdateTime(LocalDateTime.now());
orderAppointmentDao.save(oa); orderAppointmentDao.save(oa);
// 登记 // 登记
commonService.addOrderEvent(orderId, "", req.getSource(), "API", "虚拟指派", "虚拟指派", ""); commonService.addOrderEvent(entity.getOrderId(), "", req.getSource(), "API", "虚拟指派", "虚拟指派", "");
} }
log.info("==== 已经完成虚拟指派 ===="); log.info("==== 已经完成虚拟指派 ====");
} catch (Exception e) { } catch (Exception e) {
log.error("虚拟指派错误: {}", e.getMessage()); log.error("虚拟指派错误: {}", e.getMessage());
} }
} }
private String newSuborderId(String orderId) {
return String.format("%s_%s", orderId, DateUtils.formatDateTime(LocalDateTime.now(), "yyyyMMddHHmmss"));
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!