根据派单规则调整派单类

This commit is contained in:
曹磊 2025-12-03 16:59:31 +08:00
parent 2996cb6844
commit f281fd86b7
2 changed files with 92 additions and 43 deletions

View File

@ -109,30 +109,31 @@ public class CareOrdersServiceImpl extends ServiceImpl<CareOrdersMapper, CareOrd
private void generateOrdersSub(CareOrders orders){
System.out.println("护理单元:"+orders.getNuId()+",服务时间"+orders.getStartTime());
List<CareOrdersSub> ordersSubList = ordersSubService.queryDataPoolSubList(orders);
String directiveIds = ordersSubList.stream().map(CareOrdersSub::getDirectiveId).collect(Collectors.joining(","));
if(orders.getIzPackage().equals("N")){
CareOrdersSub ordersSub = ordersSubList.get(0);
//获取满足条件的员工
CareOrders employee = employeeScreening(ordersSub.getDirectiveId(),orders.getCustomerId(),null,orders.getStartTime());
CareOrders employee = employeeScreening(directiveIds,orders.getCustomerId(),null,orders.getStartTime());
if(employee!=null){
orders.setEmployeeId(employee.getEmployeeId());
orders.setEmployeeName(employee.getEmployeeName());
orders.setIzStart("N");
orders.setIzFinish("N");
this.save(orders);//生成工单主表
for(int i=0;i<ordersSubList.size();i++){
CareOrdersSub ordersSub = ordersSubList.get(i);
ordersSub.setMainId(orders.getId());
ordersSub.setEmployeeId(employee.getEmployeeId());
ordersSub.setEmployeeName(employee.getEmployeeName());
ordersSub.setIzStart("N");
ordersSub.setIzFinish("N");
ordersSubService.save(ordersSub);//生成工单子表
}
System.out.println("护理单元:"+orders.getNuId()+",服务时间:"+orders.getStartTime()+",服务员工:"+employee.getEmployeeName()+",获得积分:"+employee.getLevel());
System.out.println("");
System.out.println("");
System.out.println("");
}
}else{
String directiveIds = ordersSubList.stream().map(CareOrdersSub::getDirectiveId).collect(Collectors.joining(","));
List<CareOrders> emps = baseMapper.getPermissionEmps(directiveIds);//获取服务标签中的员工和数量
emps.removeIf(data -> data.getOwnCn() < ordersSubList.size());//删除没有权限的数据
String employeeIds = emps.stream().map(CareOrders::getEmployeeId).collect(Collectors.joining(","));
@ -172,13 +173,9 @@ public class CareOrdersServiceImpl extends ServiceImpl<CareOrdersMapper, CareOrd
return getByPriority(directiveIds, customerId, startTime, employeeIds);
}
if (sendOrderRule.getPriorityCode().equals("2")) {
//按人头
//专项按人头可1v1可NvN全看长者配置专项护理员的设置
return getByHeadCount(directiveIds, customerId, startTime, employeeIds);
}
if (sendOrderRule.getPriorityCode().equals("3")) {
//1v1特殊
return getBySpecial();
}
return null;
}
@ -251,8 +248,10 @@ public class CareOrdersServiceImpl extends ServiceImpl<CareOrdersMapper, CareOrd
CareOrders emp = empList.get(i);
System.out.println("员工信息:"+emp.getEmployeeName()+","+emp.getOrderCap()+","+emp.getOrderNum()+","+emp.getTotalDuration()+","+emp.getTotalComPrice()+","+emp.getMaxTime()+","+emp.getOwnCn()+","+emp.getIzFree());
}
//获取指定护理员工列表不指定的排除掉
//****************获取指定护理员工列表不指定的排除掉=============================>
getByOrderly(empList,customerId);
if(ruleSubList.size()>0){
for(SendOrderRuleSub ruleSub : ruleSubList){
switch (ruleSub.getPriorityCode()) {
@ -294,16 +293,6 @@ public class CareOrdersServiceImpl extends ServiceImpl<CareOrdersMapper, CareOrd
return null;
}
/**
* 1V1派单
*
* @return
*/
private CareOrders getBySpecial() {
//获取长者指定的员工如在线直接派单
return null;
}
/**
* 通过员工空闲状态来设置优先级
*
@ -487,7 +476,6 @@ public class CareOrdersServiceImpl extends ServiceImpl<CareOrdersMapper, CareOrd
}
}
/**
* 获取指定护理员工列表
*

View File

@ -3,6 +3,7 @@ package com.nu.modules.biz.logistics.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nu.modules.biz.care.order.entity.CareOrders;
import com.nu.modules.biz.logistics.order.entity.LogisticsOrders;
import com.nu.modules.biz.logistics.order.mapper.LogisticsOrdersMapper;
import com.nu.modules.biz.logistics.order.service.ILogisticsOrdersService;
@ -101,7 +102,7 @@ public class LogisticsOrdersServiceImpl extends ServiceImpl<LogisticsOrdersMappe
LogisticsOrders orders = ordersList.get(i);
generateOrders(orders);
}
return null;
return Result.OK();
}
/**
@ -133,11 +134,7 @@ public class LogisticsOrdersServiceImpl extends ServiceImpl<LogisticsOrdersMappe
}
if (sendOrderRule.getPriorityCode().equals("2")) {
//按人头
return getByHeadCount();
}
if (sendOrderRule.getPriorityCode().equals("3")) {
//1v1特殊
return getBySpecial();
return getByHeadCount(directiveId, customerId, startTime);
}
return null;
}
@ -200,18 +197,55 @@ public class LogisticsOrdersServiceImpl extends ServiceImpl<LogisticsOrdersMappe
*
* @return
*/
private LogisticsOrders getByHeadCount() {
return null;
private LogisticsOrders getByHeadCount(String directiveId, String customerId, Date startTime) {
List<LogisticsOrders> empList = getEmpPermissionAndOnline(directiveId,startTime);
if (empList.size() > 0) {
for(int i=0;i<empList.size();i++){
LogisticsOrders emp = empList.get(i);
System.out.println("员工信息:"+emp.getEmployeeName()+","+emp.getOrderCap()+","+emp.getOrderNum()+","+emp.getTotalDuration()+","+emp.getTotalComPrice()+","+emp.getMaxTime()+","+emp.getOwnCn()+","+emp.getIzFree());
}
/**
* 1V1派单
*
* @return
*/
private LogisticsOrders getBySpecial() {
//****************获取指定护理员工列表不指定的排除掉=============================>
getByOrderly(empList,customerId);
if(ruleSubList.size()>0){
for(SendOrderRuleSub ruleSub : ruleSubList){
switch (ruleSub.getPriorityCode()) {
case 1:
//空闲积分
sortByIzFree(empList,ruleSub.getCoefficient());
break;
case 2:
//单次积分
sortByNumAndSetLevel(empList,ruleSub.getCoefficient());
break;
case 3:
//收益积分
sortByPriceAndSetLevel(empList,ruleSub.getCoefficient());
break;
case 4:
//服务时长积分
sortByDurationAndSetLevel(empList,ruleSub.getCoefficient());
break;
case 5:
//最后接单时间积分
sortByMaxTimeAndSetLevel(empList,ruleSub.getCoefficient());
break;
case 6:
//超出上限积分
sortByLimit(empList,ruleSub.getCoefficient());
break;
}
}
//获取员工信息
sortEmpList(empList);
return empList.get(0);
}else{
//随机获取一个员工
Random random = new Random();
return empList.get(random.nextInt(empList.size()));
}
}
return null;
}
@ -377,4 +411,31 @@ public class LogisticsOrdersServiceImpl extends ServiceImpl<LogisticsOrdersMappe
empList.clear();
empList.addAll(sortedEmployees);
}
/**
* 获取指定护理员工列表
*
* @param empList
*/
public void getByOrderly(List<LogisticsOrders> empList,String customerId) {
List<LogisticsOrders> newList = new ArrayList();
for (int i = 0; i < empList.size(); i++) {
LogisticsOrders emp = empList.get(i);
String employeeId = emp.getEmployeeId();
Map<String, String> orderlyMap = getEmpOrderly(customerId);
if (orderlyMap != null) {
String orderlyId = orderlyMap.get(employeeId);
if (orderlyId != null && !orderlyId.equals("")) {
newList.add(emp);
}
}
}
empList.clear();
empList.addAll(newList);
for(int i=0;i<empList.size();i++){
LogisticsOrders emp = empList.get(i);
System.out.println("获取指定护理员工信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName());
}
}
}