Commit 4e612c11 by huangjinxin

fix:创单优化

1 parent ab627f1b
package com.dituhui.pea.order.enums;
public enum OrderEventEnum {
// 建单,首次指派,改派,取消,改约,放回工单池
createOrder("建单", "%s通过%s创建服务工单:%s"),
firstAssignment("首次指派", "通过PEA派工给工程师%s"),
reassignment("改派", "通过PEA派工给工程师%s"),
cancel("取消", "%s在线指导解决"),
recontracting("改约", "工程师%s/%s已改约,改约时间%s,改约原因:%s"),
backOrderPool("放回工单池", "取消派工"),
;
private String event;
private String msg;
OrderEventEnum(String event, String msg) {
this.event = event;
this.msg = msg;
}
public String getEvent() {
return event;
}
public String getMsg() {
return msg;
}
}
...@@ -161,7 +161,7 @@ public class BeanRemoteServiceImpl { ...@@ -161,7 +161,7 @@ public class BeanRemoteServiceImpl {
return Result.failed(beanR.getMessage()); return Result.failed(beanR.getMessage());
} }
for (Department department : beanR.getData()) { for (Department department : beanR.getData()) {
if (StringUtils.isBlank(department.getBsDeptId())) { if (StringUtils.isNotBlank(department.getCode()) && department.getCode().contains("beanTest")) {
continue; continue;
} }
log.info("处理部门详情---->{}", department.getBsDeptId()); log.info("处理部门详情---->{}", department.getBsDeptId());
...@@ -193,8 +193,8 @@ public class BeanRemoteServiceImpl { ...@@ -193,8 +193,8 @@ public class BeanRemoteServiceImpl {
*/ */
private void disposeChildren(Department departments, String accessToken, Boolean isDisposeData, String parentId) { private void disposeChildren(Department departments, String accessToken, Boolean isDisposeData, String parentId) {
for (Department department : departments.getChildren()) { for (Department department : departments.getChildren()) {
if (StringUtils.isBlank(department.getBsDeptId())) { if (StringUtils.isNotBlank(department.getCode()) && department.getCode().contains("beanTest")) {
return; continue;
} }
log.info("处理部门详情---->{}", department.getBsDeptId()); log.info("处理部门详情---->{}", department.getBsDeptId());
if (!BeanRegionIdEnum.getEnumByRegionId(department.getBsDeptId())) { if (!BeanRegionIdEnum.getEnumByRegionId(department.getBsDeptId())) {
...@@ -212,7 +212,7 @@ public class BeanRemoteServiceImpl { ...@@ -212,7 +212,7 @@ public class BeanRemoteServiceImpl {
} }
disposeChildren(department, accessToken, isDisposeData, departments.getBsDeptId()); disposeChildren(department, accessToken, isDisposeData, departments.getBsDeptId());
//大区数据处理完重置 //大区数据处理完重置
if (department.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) { if (StringUtils.isBlank(department.getDeptLevel()) || department.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) {
isDisposeData = false; isDisposeData = false;
} }
} }
...@@ -293,15 +293,15 @@ public class BeanRemoteServiceImpl { ...@@ -293,15 +293,15 @@ public class BeanRemoteServiceImpl {
groupEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled()); groupEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
groupEntity.setReserveTimeMax(data.getPartReserveTimeMax()); groupEntity.setReserveTimeMax(data.getPartReserveTimeMax());
//处理clusterId和branchId //处理clusterId和branchId
OrgBranchEntity branchEntity = branchMap.get(data.getParentId()); OrgBranchEntity branchEntity = branchMap.get(data.getBelongedBranch());
if (ObjUtil.isNull(branchEntity)) { if (ObjUtil.isNull(branchEntity)) {
branchEntity = orgBranchDao.getByBranchId(data.getParentId()); branchEntity = orgBranchDao.getByBranchId(data.getBelongedBranch());
if (ObjUtil.isNull(branchEntity)) { if (ObjUtil.isNull(branchEntity)) {
return Result.failed(); return Result.failed();
} }
branchMap.put(data.getParentId(), branchEntity); branchMap.put(data.getBelongedBranch(), branchEntity);
} }
groupEntity.setBranchId(data.getParentId()); groupEntity.setBranchId(data.getBelongedBranch());
groupEntity.setClusterId(branchEntity.getClusterId()); groupEntity.setClusterId(branchEntity.getClusterId());
//处理分站外围 //处理分站外围
if (data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode())) { if (data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode())) {
......
...@@ -29,6 +29,7 @@ import com.dituhui.pea.order.dto.param.OrderDTO; ...@@ -29,6 +29,7 @@ import com.dituhui.pea.order.dto.param.OrderDTO;
import com.dituhui.pea.order.dto.param.OrgTeamInfo; import com.dituhui.pea.order.dto.param.OrgTeamInfo;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.AppointmentMethodEnum; import com.dituhui.pea.order.enums.AppointmentMethodEnum;
import com.dituhui.pea.order.enums.OrderEventEnum;
import com.dituhui.pea.order.enums.OrderFlowEnum; import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderStatusEnum; import com.dituhui.pea.order.enums.OrderStatusEnum;
import com.dituhui.pea.order.service.*; import com.dituhui.pea.order.service.*;
...@@ -165,14 +166,17 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -165,14 +166,17 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setIsAppointEngineer(req.getIsAppointEngineer()); entity.setIsAppointEngineer(req.getIsAppointEngineer());
String appointEngineerCodes = CollectionUtils.isEmpty(req.getAppointEngineerCodes()) ? null : String.join(",", req.getAppointEngineerCodes()); String appointEngineerCodes = CollectionUtils.isEmpty(req.getAppointEngineerCodes()) ? null : String.join(",", req.getAppointEngineerCodes());
entity.setAppointEngineerCodes(appointEngineerCodes); entity.setAppointEngineerCodes(appointEngineerCodes);
OrgTeamEntity byTeamId = null;
String engineerName = null;
if (req.getIsAppointEngineer() == 1) { if (req.getIsAppointEngineer() == 1) {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(req.getAppointEngineerCodes().get(0)); EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(req.getAppointEngineerCodes().get(0));
List<OrgTeamEngineerEntity> orgTeamEngineers = orgTeamEngineerDao.findByEngineerCode(req.getAppointEngineerCodes().get(0)); List<OrgTeamEngineerEntity> orgTeamEngineers = orgTeamEngineerDao.findByEngineerCode(req.getAppointEngineerCodes().get(0));
if (CollectionUtils.isEmpty(orgTeamEngineers)) { if (CollectionUtils.isEmpty(orgTeamEngineers)) {
return Result.failed(StatusCodeEnum.FENDAN_TEAM_UNMATCHED); return Result.failed(StatusCodeEnum.FENDAN_TEAM_UNMATCHED);
} }
OrgTeamEntity byTeamId = orgTeamDao.getByTeamId(orgTeamEngineers.get(0).getTeamId()); byTeamId = orgTeamDao.getByTeamId(orgTeamEngineers.get(0).getTeamId());
entity.setEngineerCode(engineerInfo.getEngineerCode()); entity.setEngineerCode(engineerInfo.getEngineerCode());
engineerName = engineerInfo.getName();
entity.setEngineerName(engineerInfo.getName()); entity.setEngineerName(engineerInfo.getName());
entity.setEngineerPhone(engineerInfo.getPhone()); entity.setEngineerPhone(engineerInfo.getPhone());
entity.setEngineerPhone(engineerInfo.getPhone()); entity.setEngineerPhone(engineerInfo.getPhone());
...@@ -205,6 +209,9 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -205,6 +209,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); entity.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
//发送通知分部消息 //发送通知分部消息
sendMsg(branchEntity.getBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate()); sendMsg(branchEntity.getBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate());
Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), null);
entity.setIsCutoff(cutoff);
} else { } else {
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等 // 根据分单工作队,填写clusterId/branchId/groupId/teamId等
OrgTeamInfo teamInfo = fendanResult.getResult(); OrgTeamInfo teamInfo = fendanResult.getResult();
...@@ -218,10 +225,13 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -218,10 +225,13 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff()); entity.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), teamInfo.getWorkOff()); Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), teamInfo.getWorkOff());
// 处理cutoff 动态排班结束后创建的当日单和次日单 // 处理cutoff 动态排班结束后创建的当日单和次日单
boolean isToday = DateUtil.judgeTimeIsToday(entity.getExpectTimeBegin());
boolean isTomorrow = DateUtil.judgeTimeIsisTomorrow(entity.getExpectTimeBegin()); boolean isTomorrow = DateUtil.judgeTimeIsisTomorrow(entity.getExpectTimeBegin());
//次日单自动批量
if (isTomorrow) {
entity.setAppointmentMethod(AppointmentMethodEnum.AUTO_BATCH.name());
}
// 特殊时间段,当天单,cutoff需要人工处理 // 特殊时间段,当天单,cutoff需要人工处理
if (isToday || (isTomorrow && cutoff == 1) || special == 1) { if (cutoff == 1 || special == 1) {
//判断是否在今天cutoff之后 //判断是否在今天cutoff之后
entity.setIsCutoff(cutoff); entity.setIsCutoff(cutoff);
entity.setIsSpecialTime(special); entity.setIsSpecialTime(special);
...@@ -268,10 +278,10 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -268,10 +278,10 @@ public class OrderCreateServiceImpl implements OrderCreateService {
String joinTags = CollectionUtils.isEmpty(req.getOrderTags()) ? "" : String.join(",", req.getOrderTags()); String joinTags = CollectionUtils.isEmpty(req.getOrderTags()) ? "" : String.join(",", req.getOrderTags());
entity.setBeanTags(joinTags); entity.setBeanTags(joinTags);
entity.setBeanPriority(req.getPriority()); entity.setBeanPriority(req.getPriority());
if (req.getPriority().equals("1")){ if (req.getPriority().equals("1")) {
entity.setAppointmentMethod(AppointmentMethodEnum.AUTO_NOW.name()); entity.setAppointmentMethod(AppointmentMethodEnum.AUTO_NOW.name());
//发送通知分部消息 //发送通知分部消息
sendMsg(entity.getOrgBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate()); // sendMsg(entity.getOrgBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate());
} }
entity.setIsMultiple(joinTags.contains("重物搬运") ? 1 : 0); entity.setIsMultiple(joinTags.contains("重物搬运") ? 1 : 0);
...@@ -281,7 +291,11 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -281,7 +291,11 @@ public class OrderCreateServiceImpl implements OrderCreateService {
// 记录订单和节点 // 记录订单和节点
orderInfoDao.save(entity); orderInfoDao.save(entity);
commonService.addOrderEvent(orderId, "", req.getSource(), "API", OrderStatusEnum.CREATE.getDescription(), OrderStatusEnum.CREATE.getDescription(), ""); commonService.addOrderEvent(orderId, "", req.getSource(), "API", OrderEventEnum.createOrder.getEvent(), String.format(OrderEventEnum.createOrder.getMsg(), req.getSource(), "BEAN", req.getOrderId()), "");
if (req.getIsAppointEngineer() == 1) {
commonService.addOrderEvent(orderId, "", req.getSource(), "PEA", OrderEventEnum.firstAssignment.getEvent(), String.format(OrderEventEnum.firstAssignment.getMsg(), engineerName + "-" + byTeamId.getTeamName()), "");
}
return Result.success(null); return Result.success(null);
} }
......
...@@ -3,6 +3,7 @@ package com.dituhui.pea.order.utils; ...@@ -3,6 +3,7 @@ package com.dituhui.pea.order.utils;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.dituhui.pea.util.DateUtil; import com.dituhui.pea.util.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -88,6 +89,12 @@ public class CommonUtil { ...@@ -88,6 +89,12 @@ public class CommonUtil {
* @return * @return
*/ */
public static Integer isCutoff(LocalDateTime localTime, String strOff) { public static Integer isCutoff(LocalDateTime localTime, String strOff) {
if (DateUtil.judgeTimeIsToday(localTime)) {
return 1;
}
if (StringUtils.isBlank(strOff)) {
return 0;
}
LocalDateTime workOff = LocalDate.now().atTime(Integer.parseInt(strOff.split(":")[0]), Integer.parseInt(strOff.split(":")[1]), 0); LocalDateTime workOff = LocalDate.now().atTime(Integer.parseInt(strOff.split(":")[0]), Integer.parseInt(strOff.split(":")[1]), 0);
if (localTime.isAfter(workOff)) { if (localTime.isAfter(workOff)) {
return 1; return 1;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!