Commit a98de2b6 by huangjinxin

fix:G改约原因增加技能变更,

1 parent 04cc1926
package com.dituhui.pea.order.constant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 改约原因常量
*/
public class OrderReschedulingReason {
public static Map<String, List<String>> ReschedulingReasonMap = new HashMap<>() {
{
put("服务设备/工具相关", new ArrayList<>() {
{
add("缺少常用必备工具");
add("交通工具不可用");
}
});
put("服务物料/配件相关", new ArrayList<>() {
{
add("配件准备错误");
add("配件未到货");
add("加单服务,没有所需配件");
add("缺少可用的安装类附件");
add("缺少可用的清洁类产品");
add("缺少可用的清洁类产品");
add("缺少可用的消耗品(生料带、鞋套等)");
add("缺少服务所需纸质工单");
}
});
put("服务政策/流程相关", new ArrayList<>() {
{
add("超派");
add("重复单(工程师发起申请按钮,由CC校验取消)");
add("服务指派不准确");
add("转入车间服务流程");
add("退换机方案沟通中");
add("不接受退换机政策");
add("用户考虑费用问题");
add("用户不认可收费标准");
add("用户考虑安装/维修方案");
add("用户不接受维修标准");
add("用户考虑软性故障相关解释");
add("没有相关安装/维修操作指导(不提供此服务)");
}
});
put("安装、维修环境(极端天气)", new ArrayList<>() {
{
add("安装、维修环境不符");
add("极端天气,无法正常上门");
}
});
put("服务关联人员相关", new ArrayList<>() {
{
add("预约排期问题");
add("用户希望更换其他工程师上门");
add("服务工程师技能不符");
add("突发的事件导致工程师无法上门(如请假、生病、事故)");
add("等待支持岗位(投诉组、分部、技术支持)提供方案");
add("拉修/退换机的物流服务不到位");
add("售前送货的物流服务不到位");
}
});
put("暂无法关单,初始服务已完成", new ArrayList<>() {
{
add("用户希望观察使用一段时间");
add("用户本人不在现场");
add("TSS软件系统故障");
add("配件代码未维护进系统");
}
});
put("用户相关", new ArrayList<>() {
{
add("用户不接电话且已短信通知用户(改约3次以内)");
add("3天6次未联系上用户");
add("无法满足消费者夜间上门需求(非加单)");
add("用户期望的服务时间与其他用户冲突");
add("上门前得知外部人员已服务");
add("用户要求自行来分部购买配/附件(仅仓管可选)");
add("机器已退/换,不再需要上门服务(仅行政/用户/CC可选)");
add("非BSH产品");
add("用户主动提出往后改约(必须短信通知用户)");
add("机器故障已消除(仅行政/用户/CC可选)");
add("消费者希望提前上门");
}
});
put("其它原因", new ArrayList<>() {
{
}
});
}
};
}
...@@ -3,6 +3,8 @@ package com.dituhui.pea.order.dto; ...@@ -3,6 +3,8 @@ package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.dto.param.Location; import com.dituhui.pea.order.dto.param.Location;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data @Data
public class OrderReschedule { public class OrderReschedule {
private String orderId; private String orderId;
...@@ -23,4 +25,27 @@ public class OrderReschedule { ...@@ -23,4 +25,27 @@ public class OrderReschedule {
* 备注 * 备注
*/ */
private String description; private String description;
/**
* 设备品牌(博世/西门子)
*/
private String brand;
/**
* 产品类别
*/
private String productType;
/**
* 服务类型
*/
private String serviceType;
/**
* 改约原因
*/
private String reschedulingReason;
} }
...@@ -199,6 +199,26 @@ public class OrderDTO { ...@@ -199,6 +199,26 @@ public class OrderDTO {
*/ */
private Location happenLocation; private Location happenLocation;
/**
* 设备品牌(博世/西门子)
*/
private String brand;
/**
* 产品类别
*/
private String productType;
/**
* 服务类型
*/
private String serviceType;
/**
* 改约原因
*/
private String reschedulingReason;
} }
/** /**
......
...@@ -240,4 +240,10 @@ public class OrderInfoEntity { ...@@ -240,4 +240,10 @@ public class OrderInfoEntity {
*/ */
@Column(name = "is_cutoff") @Column(name = "is_cutoff")
private Integer isCutoff = 0; private Integer isCutoff = 0;
/**
* 改约原因
*/
@Column(name = "rescheduling_reason")
private String reschedulingReason;
} }
...@@ -234,49 +234,50 @@ public class BeanRemoteServiceImpl { ...@@ -234,49 +234,50 @@ public class BeanRemoteServiceImpl {
} }
Department data = departmentBeanR.getData(); Department data = departmentBeanR.getData();
//处理大区,分部数据 //处理大区,分部数据
if (StringUtils.isNotBlank(data.getDeptLevel())) { if (StringUtils.isBlank(data.getDeptLevel())) {
if (data.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) { return Result.failed("组织级别不能为空");
OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getId()); }
if (ObjUtil.isNull(clusterEntity)) { if (data.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) {
clusterEntity = new OrgClusterEntity(); OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getId());
} if (ObjUtil.isNull(clusterEntity)) {
clusterEntity.setName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName()); clusterEntity = new OrgClusterEntity();
clusterEntity.setClusterId(data.getId()); }
clusterEntity.setAbbreviation(data.getAbbreviation()); clusterEntity.setName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
clusterEntity.setStatus(data.getEnable()); clusterEntity.setClusterId(data.getId());
clusterEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList())); clusterEntity.setAbbreviation(data.getAbbreviation());
clusterEntity.setMemo(data.getDesc()); clusterEntity.setStatus(data.getEnable());
clusterEntity.setCode(data.getCode()); clusterEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
clusterEntity.setPhone(data.getPhone()); clusterEntity.setMemo(data.getDesc());
clusterEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled()); clusterEntity.setCode(data.getCode());
clusterEntity.setReserveTimeMax(data.getPartReserveTimeMax()); clusterEntity.setPhone(data.getPhone());
clusterEntity.setBsDeptId(data.getBsDeptId()); clusterEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
orgClusterDao.save(clusterEntity); clusterEntity.setReserveTimeMax(data.getPartReserveTimeMax());
} else if (data.getDeptLevel().equals(BeanOrgLevelEnum.BRANCH.getCode())) { clusterEntity.setBsDeptId(data.getBsDeptId());
OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getId()); orgClusterDao.save(clusterEntity);
if (ObjUtil.isNull(branchEntity)) { }
branchEntity = new OrgBranchEntity(); if (data.getDeptLevel().equals(BeanOrgLevelEnum.BRANCH.getCode())) {
} OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getId());
// branchEntity.setBranchName(data.getTagName()); if (ObjUtil.isNull(branchEntity)) {
branchEntity.setBranchName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName()); branchEntity = new OrgBranchEntity();
branchEntity.setBranchId(data.getId());
branchEntity.setAbbreviation(data.getAbbreviation());
branchEntity.setStatus(data.getEnable());
branchEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
branchEntity.setMemo(data.getDesc());
branchEntity.setCode(data.getCode());
branchEntity.setPhone(data.getPhone());
branchEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
branchEntity.setReserveTimeMax(data.getPartReserveTimeMax());
branchEntity.setClusterId(data.getParentId());
branchEntity.setBsDeptId(data.getBsDeptId());
orgBranchDao.save(branchEntity);
branchMap.put(data.getBsDeptId(), branchEntity);
} }
// branchEntity.setBranchName(data.getTagName());
branchEntity.setBranchName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
branchEntity.setBranchId(data.getId());
branchEntity.setAbbreviation(data.getAbbreviation());
branchEntity.setStatus(data.getEnable());
branchEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
branchEntity.setMemo(data.getDesc());
branchEntity.setCode(data.getCode());
branchEntity.setPhone(data.getPhone());
branchEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
branchEntity.setReserveTimeMax(data.getPartReserveTimeMax());
branchEntity.setClusterId(data.getParentId());
branchEntity.setBsDeptId(data.getBsDeptId());
orgBranchDao.save(branchEntity);
branchMap.put(data.getBsDeptId(), branchEntity);
} }
//处理分站外围数据 if ((data.getDeptLevel().equalsIgnoreCase(BeanOrgLevelEnum.STATION.getCode()))) {
if (StringUtils.isNotBlank(data.getDeptType()) && (data.getDeptType().equals(BeanOrgLevelEnum.STATION.getCode()) //处理分站外围数据
|| data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode()))) {
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getId()); OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getId());
if (ObjUtil.isNull(groupEntity)) { if (ObjUtil.isNull(groupEntity)) {
groupEntity = new OrgGroupEntity(); groupEntity = new OrgGroupEntity();
...@@ -371,7 +372,7 @@ public class BeanRemoteServiceImpl { ...@@ -371,7 +372,7 @@ public class BeanRemoteServiceImpl {
//处理分站外围 //处理分站外围
groupEntity.setKind(CollectionUtils.isEmpty(data.getType()) ? 4 : BeanPointTypeEnum.getTypeByClazz(data.getType().get(0))); groupEntity.setKind(CollectionUtils.isEmpty(data.getType()) ? 4 : BeanPointTypeEnum.getTypeByClazz(data.getType().get(0)));
groupEntity.setCategory(2); groupEntity.setCategory(2);
groupEntity.setAddress(data.getBusinessAddress().getAddress()); groupEntity.setAddress(data.getBusinessAddress().getAll());
groupEntity.setX(data.getBusinessAddress().getLongitude()); groupEntity.setX(data.getBusinessAddress().getLongitude());
groupEntity.setY(data.getBusinessAddress().getLatitude()); groupEntity.setY(data.getBusinessAddress().getLatitude());
orgGroupDao.save(groupEntity); orgGroupDao.save(groupEntity);
......
...@@ -141,11 +141,14 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -141,11 +141,14 @@ public class OrderCreateServiceImpl implements OrderCreateService {
orderId = s.substring(s.length() - 9); orderId = s.substring(s.length() - 9);
} }
OrderInfoEntity byOrderId = orderInfoDao.getByOrderId(req.getOrderId()); OrderInfoEntity byOrderId = orderInfoDao.getByOrderId(req.getOrderId());
String peaBrand = fixBrand(req.getBrand());
if (ObjectUtil.isNotNull(byOrderId)) { if (ObjectUtil.isNotNull(byOrderId)) {
return Result.failed(StatusCodeEnum.ORDER_EXISTS); return Result.failed(StatusCodeEnum.ORDER_EXISTS);
} }
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(peaBrand, req.getProductType(), req.getServiceType());
String peaBrand = fixBrand(req.getBrand()); if (ObjectUtil.isNull(skillInfoEntity)) {
return Result.failed(StatusCodeEnum.ORDER_SKILL_NOT_EXISTS);
}
Location location = req.getLocation(); Location location = req.getLocation();
//预处理字段 //预处理字段
entity.setExpectTimeBegin(DateUtil.fromDate(req.getExpectBegin())); entity.setExpectTimeBegin(DateUtil.fromDate(req.getExpectBegin()));
...@@ -179,7 +182,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -179,7 +182,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
engineerName = engineerInfo.getName(); engineerName = engineerInfo.getName();
entity.setEngineerName(engineerInfo.getName()); entity.setEngineerName(engineerInfo.getName());
entity.setEngineerPhone(engineerInfo.getPhone()); entity.setEngineerPhone(engineerInfo.getPhone());
entity.setEngineerPhone(engineerInfo.getPhone()); entity.setEngineerCode(engineerInfo.getEngineerCode());
entity.setOrgClusterId(byTeamId.getClusterId()); entity.setOrgClusterId(byTeamId.getClusterId());
entity.setOrgBranchId(byTeamId.getBranchId()); entity.setOrgBranchId(byTeamId.getBranchId());
entity.setOrgGroupId(byTeamId.getGroupId()); entity.setOrgGroupId(byTeamId.getGroupId());
...@@ -189,7 +192,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -189,7 +192,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
//特殊时间段 //特殊时间段
Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(), Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(),
entity.getExpectTimeEnd().toLocalTime(), byTeamId.getWorkOn(), byTeamId.getWorkOff()); entity.getExpectTimeEnd().toLocalTime(), byTeamId.getWorkOn(), byTeamId.getWorkOff());
Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), byTeamId.getWorkOff()); Integer cutoff = CommonUtil.isCutoff(entity.getExpectTimeBegin(), byTeamId.getWorkOff());
entity.setIsCutoff(cutoff); entity.setIsCutoff(cutoff);
entity.setIsSpecialTime(special); entity.setIsSpecialTime(special);
} else { } else {
...@@ -210,7 +213,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -210,7 +213,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
//发送通知分部消息 //发送通知分部消息
sendMsg(branchEntity.getBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate()); sendMsg(branchEntity.getBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate());
Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), null); Integer cutoff = CommonUtil.isCutoff(entity.getExpectTimeBegin(), null);
entity.setIsCutoff(cutoff); entity.setIsCutoff(cutoff);
} else { } else {
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等 // 根据分单工作队,填写clusterId/branchId/groupId/teamId等
...@@ -223,7 +226,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -223,7 +226,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
//特殊时间段 //特殊时间段
Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(), Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(),
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(entity.getExpectTimeBegin(), teamInfo.getWorkOff());
// 处理cutoff 动态排班结束后创建的当日单和次日单 // 处理cutoff 动态排班结束后创建的当日单和次日单
boolean isTomorrow = DateUtil.judgeTimeIsisTomorrow(entity.getExpectTimeBegin()); boolean isTomorrow = DateUtil.judgeTimeIsisTomorrow(entity.getExpectTimeBegin());
//次日单自动批量 //次日单自动批量
...@@ -272,8 +275,6 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -272,8 +275,6 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setWorkshop(false); entity.setWorkshop(false);
// 处理技能和标签 // 处理技能和标签
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(peaBrand, req.getProductType(), req.getServiceType());
assert skillInfoEntity != null;
entity.setTakeTime(skillInfoEntity.getTakeTime()); entity.setTakeTime(skillInfoEntity.getTakeTime());
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);
......
...@@ -7,17 +7,11 @@ import com.dituhui.pea.common.Result; ...@@ -7,17 +7,11 @@ import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum; import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.OrderInfoDao; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dao.OrgBranchDao;
import com.dituhui.pea.order.dao.OrgGroupDao;
import com.dituhui.pea.order.dao.SkillInfoDao;
import com.dituhui.pea.order.dto.MsgDTO; import com.dituhui.pea.order.dto.MsgDTO;
import com.dituhui.pea.order.dto.OrderReschedule; import com.dituhui.pea.order.dto.OrderReschedule;
import com.dituhui.pea.order.dto.param.*; import com.dituhui.pea.order.dto.param.*;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.entity.OrgBranchEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.enums.AppointmentMethodEnum; import com.dituhui.pea.order.enums.AppointmentMethodEnum;
import com.dituhui.pea.order.enums.BeanServiceFlowEnum; import com.dituhui.pea.order.enums.BeanServiceFlowEnum;
import com.dituhui.pea.order.enums.OrderStatusEnum; import com.dituhui.pea.order.enums.OrderStatusEnum;
...@@ -70,6 +64,9 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -70,6 +64,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Autowired @Autowired
private OrgGroupDao orgGroupDao; private OrgGroupDao orgGroupDao;
@Autowired
private OrgTeamDao orgTeamDao;
/** /**
* 新增订单处理一家多单逻辑 * 新增订单处理一家多单逻辑
...@@ -168,7 +165,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -168,7 +165,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
orderInfo.setDescription(request.getDescription()); orderInfo.setDescription(request.getDescription());
} }
//处理一家多单逻辑 //处理一家多单逻辑
Result<String> deleteMultipleOrders = this.deleteMultipleOrders(orderInfo.getMultipleOrders(), orderInfo.getAddressId()); Result<String> deleteMultipleOrders = this.deleteMultipleOrders(orderInfo.getMultipleOrders(), orderInfo.getOrderId());
if (!deleteMultipleOrders.getCode().equals(ResultEnum.SUCCESS.getCode())) { if (!deleteMultipleOrders.getCode().equals(ResultEnum.SUCCESS.getCode())) {
throw new BusinessException("改约日期失败"); throw new BusinessException("改约日期失败");
} }
...@@ -179,24 +176,16 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -179,24 +176,16 @@ public class OrderInfoServiceImpl implements OrderInfoService {
//组装改约接口 //组装改约接口
OrderReschedule reschedule = new OrderReschedule(); OrderReschedule reschedule = new OrderReschedule();
reschedule.setOrderId(orderInfo.getOrderId()); reschedule.setOrderId(orderInfo.getOrderId());
reschedule.setHappenLocation(request.getHappenLocation());
reschedule.setOrderId(orderInfo.getOrderId());
reschedule.setBrand(request.getBrand());
reschedule.setProductType(request.getProductType());
reschedule.setServiceType(request.getServiceType());
reschedule.setReschedulingReason(request.getReschedulingReason());
reschedule.setExpectBegin(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeBegin())); reschedule.setExpectBegin(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeBegin()));
reschedule.setExpectEnd(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeEnd())); reschedule.setExpectEnd(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeEnd()));
Location location = request.getHappenLocation();
if (ObjectUtil.isNull(location)) {
location = new Location();
location.setLongitude(Double.valueOf(orderInfo.getX()));
location.setLatitude(Double.valueOf(orderInfo.getY()));
location.setAddress(orderInfo.getAddress());
location.setAddressId(orderInfo.getAddressId());
} else {
orderInfo.setX(location.getLongitude().toString());
orderInfo.setY(location.getLatitude().toString());
orderInfo.setAddress(location.getAddress());
orderInfo.setAddressId(location.getAddressId());
}
reschedule.setHappenLocation(location);
if (StringUtils.isNotBlank(request.getDescription())) { if (StringUtils.isNotBlank(request.getDescription())) {
orderInfo.setDescription(request.getDescription()); reschedule.setDescription(request.getDescription());
} }
return this.orderReschedule(reschedule); return this.orderReschedule(reschedule);
...@@ -221,139 +210,212 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -221,139 +210,212 @@ public class OrderInfoServiceImpl implements OrderInfoService {
} }
LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd()); LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd());
OrderInfoEntity order = orderInfoDao.getByOrderId(req.getOrderId()); OrderInfoEntity order = orderInfoDao.getByOrderId(req.getOrderId());
if (ObjectUtil.isNull(order)) {
throw new BusinessException("订单不存在");
}
LocalDate orderDt = order.getDt(); LocalDate orderDt = order.getDt();
order.setDt(expectBegin.toLocalDate()); order.setDt(expectBegin.toLocalDate());
order.setExpectTimeBegin(expectBegin); order.setExpectTimeBegin(expectBegin);
order.setExpectTimeEnd(expectEnd); order.setExpectTimeEnd(expectEnd);
order.setExpectTimeDesc(req.getExpectDesc()); order.setExpectTimeDesc(req.getExpectDesc());
order.setOrderStatus(OrderStatusEnum.RESCHEDULED.getCode()); order.setOrderStatus(OrderStatusEnum.RESCHEDULED.getCode());
if (order == null) { boolean skillUpdate = false;
throw new BusinessException("订单不存在"); if (StringUtils.isNotBlank(req.getBrand()) && !CommonUtil.fixBrand(req.getBrand()).equals(order.getBrand())) {
order.setBrand(CommonUtil.fixBrand(req.getBrand()));
skillUpdate = true;
}
if (StringUtils.isNotBlank(req.getServiceType()) && !req.getServiceType().equals(order.getType())) {
order.setSkill(req.getServiceType());
skillUpdate = true;
} }
if (StringUtils.isNotBlank(req.getProductType()) && !req.getProductType().equals(order.getSkill())) {
order.setType(req.getProductType());
skillUpdate = true;
}
//渲染地址,判断地址是否变更
Location location = req.getHappenLocation();
if (ObjectUtil.isNull(location)) {
location = new Location();
location.setLongitude(Double.valueOf(order.getX()));
location.setLatitude(Double.valueOf(order.getY()));
location.setAddress(order.getAddress());
location.setAddressId(order.getAddressId());
} else {
order.setX(location.getLongitude().toString());
order.setY(location.getLatitude().toString());
order.setAddress(location.getAddress());
order.setAddressId(location.getAddressId());
if (!order.getAddressId().equals(location.getAddressId())) {
skillUpdate = true;
//更正省市区
AdministrativeDistrictReq administrativeDistrictReq = new AdministrativeDistrictReq();
administrativeDistrictReq.setPoints(location.getLongitude() + "," + location.getLatitude());
Result<AdministrativeDistrictResp> adminDistrict = fendanService.getAdminDistrict(administrativeDistrictReq);
if (ObjectUtil.isNotEmpty(adminDistrict) && ObjectUtil.isNotEmpty(adminDistrict.getResult())) {
order.setProvince(adminDistrict.getResult().getSubNames().getProvince());
order.setCity(adminDistrict.getResult().getSubNames().getCity());
order.setCounty(adminDistrict.getResult().getSubNames().getCounty());
}
}
}
order.setReschedulingReason(StringUtils.isNotBlank(req.getReschedulingReason()) ? req.getReschedulingReason() : order.getReschedulingReason());
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(order.getOrgGroupId()); OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(order.getOrgGroupId());
//是否今天 //是否今天
boolean isToday = DateUtil.judgeTimeIsToday(expectBegin); boolean isToday = DateUtil.judgeTimeIsToday(expectBegin);
//是否到人 //是否到人
boolean isBelong = StringUtils.isNotEmpty(order.getEngineerCode()); boolean isBelong = StringUtils.isNotEmpty(order.getEngineerCode());
// 是否网点 // 是否网点
//网点都需要重新指派
boolean isNetwork = ObjectUtil.isNull(groupEntity) ? false : groupEntity.getCategory() == 2; boolean isNetwork = ObjectUtil.isNull(groupEntity) ? false : groupEntity.getCategory() == 2;
String branchId = order.getOrgBranchId(); String branchId = order.getOrgBranchId();
String clusterId = order.getOrgClusterId(); String clusterId = order.getOrgClusterId();
//网点都需要重新指派
// a.已派人-改约到未来 String teamId = order.getOrgTeamId();
// i.自有:优先改约指派给当前工程师 // 当天单变更技能直接人工指派
// ii.网点:优先改约指派给当前网点 if (isToday && skillUpdate) {
// (不给当前工程师) order.setOrgTeamId(null);
if (!isToday && isBelong) { order.setOrgGroupId(null);
} else if (isToday && isBelong) { order.setEngineerPhone(null);
// b.已派人-改约到当天 order.setEngineerName(null);
order.setEngineerCode(null);
order.setEngineerPhone(null);
teamId = null;
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin());
} else {
// a.已派人-改约到未来
// i.自有:优先改约指派给当前工程师 // i.自有:优先改约指派给当前工程师
// (会影响该工程师当天后续工单的时
// 间窗),若超派则人工改派其他工程
// 师,辅助工程师同样需要人工重新指
// 派
// ii.网点:优先改约指派给当前网点 // ii.网点:优先改约指派给当前网点
// (不给当前工程师) // (不给当前工程师)
if (!isNetwork) { if (!isToday && isBelong && skillUpdate) {
order.setServiceStatus(ServiceStatusEnum.INIT.getCode()); //地址变更需要从新分单
CapacityQueryDTO.Service service = new CapacityQueryDTO.Service(); order = orderFendan(order, req, location);
service.setBrand(order.getBrand()); clusterId = order.getOrgClusterId();
service.setProductType(order.getType()); branchId = order.getOrgBranchId();
service.setServiceType(order.getSkill()); } else if (isToday && isBelong && order.getIsAppointEngineer() != 1) {
CapacityQueryDTO.Segment capacity = capacityQueryService.queryEngineerCapacity(order.getEngineerCode(), service, order.getDt(), expectBegin.toLocalTime(), expectEnd.toLocalTime()); // b.已派人-改约到当天
SkillInfoEntity skillInfo = skillInfoDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill()); // i.自有:优先改约指派给当前工程师
if (ObjectUtil.isNull(capacity) || capacity.getStatus() != 1 || capacity.getMaxDuration() > skillInfo.getTakeTime()) { // (会影响该工程师当天后续工单的时
order.setTranscend(1); // 间窗),若超派则人工改派其他工程
order.setOrgGroupId(null); // 师,辅助工程师同样需要人工重新指
order.setOrgTeamId(null); // 派
order.setEngineerCode(null); // ii.网点:优先改约指派给当前网点
clusterId = order.getOrgClusterId(); // (不给当前工程师)
branchId = order.getOrgBranchId(); if (!isNetwork) {
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin()); order.setServiceStatus(ServiceStatusEnum.INIT.getCode());
} CapacityQueryDTO.Service service = new CapacityQueryDTO.Service();
} service.setBrand(order.getBrand());
} else if (!isToday && !isBelong) { service.setProductType(order.getType());
// a.未派人-改约到未来 service.setServiceType(order.getSkill());
// i.动态排班 CapacityQueryDTO.Segment capacity = capacityQueryService.queryEngineerCapacity(order.getEngineerCode(), service, order.getDt(), expectBegin.toLocalTime(), expectEnd.toLocalTime());
order.setServiceStatus(ServiceStatusEnum.INIT.getCode()); SkillInfoEntity skillInfo = skillInfoDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill());
if (StringUtils.isBlank(req.getDescription())) { if (ObjectUtil.isNull(capacity) || capacity.getStatus() != 1 || capacity.getMaxDuration() > skillInfo.getTakeTime()) {
order.setDescription(order.getDescription()); order.setTranscend(1);
} order.setOrgGroupId(null);
Location location = req.getHappenLocation(); order.setOrgTeamId(null);
if (ObjectUtil.isNull(location)) { order.setEngineerCode(null);
location = new Location(); clusterId = order.getOrgClusterId();
location.setLongitude(Double.valueOf(order.getX())); branchId = order.getOrgBranchId();
location.setLatitude(Double.valueOf(order.getY())); teamId = null;
location.setAddress(order.getAddress()); sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin());
location.setAddressId(order.getAddressId()); }
} else {
order.setX(location.getLongitude().toString());
order.setY(location.getLongitude().toString());
order.setAddress(location.getAddress());
order.setAddressId(location.getAddressId());
}
//获取省市区
AdministrativeDistrictReq administrativeDistrictReq = new AdministrativeDistrictReq();
administrativeDistrictReq.setPoints(location.getLongitude() + "," + location.getLatitude());
Result<AdministrativeDistrictResp> adminDistrict = fendanService.getAdminDistrict(administrativeDistrictReq);
if (ObjectUtil.isNotEmpty(adminDistrict) && ObjectUtil.isNotEmpty(adminDistrict.getResult())) {
order.setProvince(adminDistrict.getResult().getSubNames().getProvince());
order.setCity(adminDistrict.getResult().getSubNames().getCity());
order.setCounty(adminDistrict.getResult().getSubNames().getCounty());
}
// 分单处理
String peaBrand = CommonUtil.fixBrand(order.getBrand());
OrderDTO.OrderCreateRequest fendanReq = new OrderDTO.OrderCreateRequest();
fendanReq.setBrand(peaBrand);
fendanReq.setProductType(order.getType());
fendanReq.setServiceType(order.getSkill());
fendanReq.setLocation(location);
Result<OrgTeamInfo> fendanResult = fendanService.fendanToGroupCapacity(fendanReq, 2, order.getDt(), expectBegin.toLocalTime(), expectEnd.toLocalTime());
if (!fendanResult.getCode().equals(ResultEnum.SUCCESS.getCode()) || ObjectUtil.isNull(fendanResult.getResult())) {
if (fendanResult.getCode().equals(StatusCodeEnum.FENDAN_IS_TRANSCEND.getCode())) {
order.setTranscend(1);
} }
OrgBranchEntity branchEntity = orgBranchDao.findByCitycodeListLike("%" + adminDistrict.getResult().getSubNames().getCity() + "%"); } else if (!isToday && !isBelong) {
clusterId = branchEntity.getClusterId(); // a.未派人-改约到未来
branchId = branchEntity.getBranchId(); // i.动态排班
sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin()); order = orderFendan(order, req, location);
} else { clusterId = order.getOrgClusterId();
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等 branchId = order.getOrgBranchId();
OrgTeamInfo teamInfo = fendanResult.getResult(); } else if (isToday && !isBelong) {
clusterId = teamInfo.getClusterId(); // b.未派人-改约到当天
branchId = teamInfo.getBranchId(); // i.人工指派
order.setOrgGroupId(teamInfo.getGroupId()); order.setOrgTeamId(null);
order.setOrgTeamId(teamInfo.getTeamId()); order.setOrgGroupId(null);
//处理超派,特殊时间段 order.setEngineerPhone(null);
order.setIsSpecialTime(CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(), order.setEngineerName(null);
order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff())); order.setEngineerCode(null);
teamId = null;
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin());
} }
} else if (isToday && !isBelong) {
// b.未派人-改约到当天
// i.人工指派
OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(order.getOrgBranchId());
clusterId = branchEntity.getClusterId();
branchId = branchEntity.getBranchId();
order.setOrgTeamId(null);
order.setOrgGroupId(null);
sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin());
} }
//处理一家多单 //处理一家多单
// order = handleMultipleOrders(order); // order = handleMultipleOrders(order);
if (!orderDt.isEqual(expectBegin.toLocalDate())) { if (!orderDt.isEqual(expectBegin.toLocalDate())) {
order = handleMultipleOrders(order); order = handleMultipleOrders(order);
} }
// 处理特殊时间,cutoff
Integer special = 0;
Integer cutoff = 0;
if (StringUtils.isNotBlank(teamId)) {
OrgTeamEntity teamInfo = orgTeamDao.getByTeamId(teamId);
special = CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(),
order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
cutoff = CommonUtil.isCutoff(order.getExpectTimeBegin(), teamInfo.getWorkOff());
} else {
cutoff = CommonUtil.isCutoff(order.getExpectTimeBegin(), null);
}
order.setIsCutoff(cutoff);
order.setIsSpecialTime(special);
order.setOrgClusterId(clusterId); order.setOrgClusterId(clusterId);
order.setOrgBranchId(branchId); order.setOrgBranchId(branchId);
orderInfoDao.save(order); orderInfoDao.save(order);
// 登记事件 // 登记事件
commonService.addOrderEvent(req.getOrderId(), "", "PEA-WEB", req.getOperator(), OrderStatusEnum.RESCHEDULED.getDescription(), OrderStatusEnum.RESCHEDULED.getDescription(), ""); commonService.addOrderEvent(req.getOrderId(), "", "PEA", req.getOperator(), OrderStatusEnum.RESCHEDULED.getDescription(), OrderStatusEnum.RESCHEDULED.getDescription(), "");
return Result.success(null); return Result.success(null);
} }
/**
* 订单重新分单
*
* @param order
* @param req
* @param location
* @return
*/
private OrderInfoEntity orderFendan(OrderInfoEntity order, OrderReschedule req, Location location) {
order.setServiceStatus(ServiceStatusEnum.INIT.getCode());
if (StringUtils.isBlank(req.getDescription())) {
order.setDescription(order.getDescription());
}
//获取省市区
AdministrativeDistrictReq administrativeDistrictReq = new AdministrativeDistrictReq();
administrativeDistrictReq.setPoints(location.getLongitude() + "," + location.getLatitude());
Result<AdministrativeDistrictResp> adminDistrict = fendanService.getAdminDistrict(administrativeDistrictReq);
if (ObjectUtil.isNotEmpty(adminDistrict) && ObjectUtil.isNotEmpty(adminDistrict.getResult())) {
order.setProvince(adminDistrict.getResult().getSubNames().getProvince());
order.setCity(adminDistrict.getResult().getSubNames().getCity());
order.setCounty(adminDistrict.getResult().getSubNames().getCounty());
}
// 分单处理
String peaBrand = CommonUtil.fixBrand(order.getBrand());
OrderDTO.OrderCreateRequest fendanReq = new OrderDTO.OrderCreateRequest();
fendanReq.setBrand(peaBrand);
fendanReq.setProductType(order.getType());
fendanReq.setServiceType(order.getSkill());
fendanReq.setLocation(location);
Result<OrgTeamInfo> fendanResult = fendanService.fendanToGroupCapacity(fendanReq, 2, order.getDt(), order.getExpectTimeBegin().toLocalTime(), order.getExpectTimeEnd().toLocalTime());
if (!fendanResult.getCode().equals(ResultEnum.SUCCESS.getCode()) || ObjectUtil.isNull(fendanResult.getResult())) {
if (fendanResult.getCode().equals(StatusCodeEnum.FENDAN_IS_TRANSCEND.getCode())) {
order.setTranscend(1);
}
OrgBranchEntity branchEntity = orgBranchDao.findByCitycodeListLike("%" + adminDistrict.getResult().getSubNames().getCity() + "%");
sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin());
} else {
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等
OrgTeamInfo teamInfo = fendanResult.getResult();
order.setOrgGroupId(teamInfo.getGroupId());
order.setOrgTeamId(teamInfo.getTeamId());
//处理超派,特殊时间段
// order.setIsSpecialTime(CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(),
// order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff()));
}
return order;
}
private void sendMsg(String branchId, String orderId, String reservationTime) { private void sendMsg(String branchId, String orderId, String reservationTime) {
//发送通知分部消息 //发送通知分部消息
MsgDTO msgDTO = new MsgDTO(); MsgDTO msgDTO = new MsgDTO();
......
...@@ -85,6 +85,7 @@ public class CommonUtil { ...@@ -85,6 +85,7 @@ public class CommonUtil {
/** /**
* 判断是否cutoff * 判断是否cutoff
* 今日单或今日cutoff之后的次日单
* *
* @return * @return
*/ */
...@@ -96,7 +97,7 @@ public class CommonUtil { ...@@ -96,7 +97,7 @@ public class CommonUtil {
return 0; 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 (LocalDateTime.now().isAfter(workOff) && DateUtil.judgeTimeIsisTomorrow(localTime)) {
return 1; return 1;
} }
return 0; return 0;
...@@ -111,4 +112,8 @@ public class CommonUtil { ...@@ -111,4 +112,8 @@ public class CommonUtil {
} }
} }
public static void main(String[] args) {
isCutoff(LocalDateTime.now(), "18:00");
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!