后勤类派单
This commit is contained in:
parent
100ae92557
commit
824bfd9140
|
|
@ -256,7 +256,7 @@
|
|||
start_time,
|
||||
end_time,
|
||||
iz_start
|
||||
from nu_biz_nu_care_directive_order
|
||||
from nu_biz_nu_logistics_directive_order
|
||||
where pool_id = #{id}
|
||||
AND iz_start = #{izStart}
|
||||
</select>
|
||||
|
|
@ -264,12 +264,12 @@
|
|||
<update id="addOrdersLog">
|
||||
insert into ${tableName}
|
||||
select a.*,#{remarks}
|
||||
from nu_biz_nu_care_directive_order a
|
||||
from nu_biz_nu_logistics_directive_order a
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteOrders">
|
||||
delete from nu_biz_nu_care_directive_order
|
||||
delete from nu_biz_nu_logistics_directive_order
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ import java.util.List;
|
|||
@Service
|
||||
@Slf4j
|
||||
public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolMapper, LogisticsDataPool> implements ILogisticsDataPoolService {
|
||||
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
private String serverNetUrl;
|
||||
|
||||
/**
|
||||
* 批量生成数据池
|
||||
|
|
@ -87,7 +83,8 @@ public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolM
|
|||
if(typeId.equals("2")){
|
||||
//周期,先判断是星期还是月份,再判断当前时间是否命中周期
|
||||
String cycleValue = dataPool.getCycleValue();
|
||||
if(cycleValue.length()>1){
|
||||
String[] values = cycleValue.split(",");
|
||||
if(values[0].length()>1){
|
||||
//月周期
|
||||
addMonthDay(dataPool);
|
||||
}else{
|
||||
|
|
@ -113,20 +110,25 @@ public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolM
|
|||
*/
|
||||
private void addWeekDay(LogisticsDataPool dataPool){
|
||||
String cycleValue = dataPool.getCycleValue();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); //1周日 2周一 3周二 4周三 5周四 6周五 7周六
|
||||
String[] values = cycleValue.split(",");
|
||||
for(int i=0;i<values.length;i++){
|
||||
String value = values[i];
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); //1周日 2周一 3周二 4周三 5周四 6周五 7周六
|
||||
// cycleValue 存js的星期 0周一 1周二 2周三 3周四 4周五 5周六 6周日 js +2 2 3 4 5 6 7 8 /7 %
|
||||
Integer cv = Integer.valueOf(cycleValue);
|
||||
//处理js星期,使其能和java的星期进行比较
|
||||
cv = cv + 2;
|
||||
if(cv-7>0){
|
||||
cv = cv -7;
|
||||
}
|
||||
//计划执行星期几是当天,则入指令池
|
||||
if(dayOfWeek == cv){
|
||||
//入指令池主表
|
||||
this.save(dataPool);
|
||||
Integer cv = Integer.valueOf(value);
|
||||
//处理js星期,使其能和java的星期进行比较
|
||||
cv = cv + 2;
|
||||
if(cv-7>0){
|
||||
cv = cv -7;
|
||||
}
|
||||
//计划执行星期几是当天,则入指令池
|
||||
if(dayOfWeek == cv){
|
||||
//入指令池主表
|
||||
this.save(dataPool);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -134,18 +136,20 @@ public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolM
|
|||
*/
|
||||
private void addMonthDay(LogisticsDataPool dataPool){
|
||||
String cycleValue = dataPool.getCycleValue();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
Integer cv = Integer.valueOf(cycleValue);
|
||||
//计划执行月中的几号是当天,则入指令池
|
||||
if(dayOfMonth == cv){
|
||||
//入指令池主表
|
||||
this.save(dataPool);
|
||||
String[] values = cycleValue.split(",");
|
||||
for(int i=0;i<values.length;i++){
|
||||
String value = values[i];
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
Integer cv = Integer.valueOf(value);
|
||||
//计划执行月中的几号是当天,则入指令池
|
||||
if(dayOfMonth == cv){
|
||||
//入指令池主表
|
||||
this.save(dataPool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 单一指令生成到数据池
|
||||
* @param planBizNuCustomerServer
|
||||
|
|
@ -245,7 +249,7 @@ public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolM
|
|||
* 创建工单日志表
|
||||
*/
|
||||
private void addOrdersLog(String dateStr, LogisticsDataPool dataPool){
|
||||
String tableName = "nu_biz_nu_care_directive_order_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
String tableName = "nu_biz_nu_logistics_directive_order_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
dataPool.setTableName(tableName);
|
||||
baseMapper.createOrdersLog(dataPool);//创建日志主表
|
||||
dataPool.setRemarks("计划删除,删除未开始工单");
|
||||
|
|
@ -271,7 +275,7 @@ public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolM
|
|||
* 创建日志表
|
||||
*/
|
||||
private void addDataPoolLog(String dateStr,String id){
|
||||
String tableName = "nu_biz_nu_care_directive_data_pool_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
String tableName = "nu_biz_nu_logistics_directive_data_pool_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
LogisticsDataPool dataPool = new LogisticsDataPool();
|
||||
dataPool.setTableName(tableName);
|
||||
baseMapper.createDataPoolLog(dataPool);//创建日志主表
|
||||
|
|
@ -299,7 +303,7 @@ public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolM
|
|||
* 创建日志表
|
||||
*/
|
||||
private void addDataPoolLogByClean(String dateStr){
|
||||
String tableName = "nu_biz_nu_care_directive_data_pool_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
String tableName = "nu_biz_nu_logistics_directive_data_pool_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
LogisticsDataPool dataPool = new LogisticsDataPool();
|
||||
dataPool.setTableName(tableName);
|
||||
baseMapper.createDataPoolLog(dataPool);//创建日志主表
|
||||
|
|
@ -337,26 +341,4 @@ public class LogisticsDataPoolServiceImpl extends ServiceImpl<LogisticsDataPoolM
|
|||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取管理平台静态资源路径
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void getOpeMediaAddress() {
|
||||
if (serverNetUrl == null || serverNetUrl.equals("")) {
|
||||
JSONObject json = sysConfigApi.getByKey("ope_media_address");
|
||||
if (json != null) {
|
||||
String configValue = json.getString("configValue");
|
||||
if (!configValue.endsWith("/")) {
|
||||
configValue += "/";
|
||||
}
|
||||
serverNetUrl = configValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getImageNetUrl(String imageUrl) {
|
||||
getOpeMediaAddress();
|
||||
return serverNetUrl + imageUrl;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,155 @@
|
|||
package com.nu.modules.biz.logistics.order.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 后勤类服务指令工单表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-12-1
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_biz_nu_logistics_directive_order")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_biz_nu_logistics_directive_order对象", description="后勤类服务指令工单表")
|
||||
public class LogisticsOrders implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**数据池子表ID*/
|
||||
private String poolId;
|
||||
/**主表id*/
|
||||
private String bizId;
|
||||
/**护理单元id*/
|
||||
private String nuId;
|
||||
/**护理单元名称*/
|
||||
private String nuName;
|
||||
/**客户id*/
|
||||
private String customerId;
|
||||
/**客户姓名*/
|
||||
private String customerName;
|
||||
/**员工ID*/
|
||||
private String employeeId;
|
||||
/**员工姓名*/
|
||||
private String employeeName;
|
||||
/**服务指令id*/
|
||||
private String directiveId;
|
||||
/**服务指令名称*/
|
||||
private String directiveName;
|
||||
/**周期类型ID*/
|
||||
private String cycleTypeId;
|
||||
/**周期类型*/
|
||||
private String cycleType;
|
||||
/**周期值*/
|
||||
private String cycleValue;
|
||||
/**服务指令图片大图*/
|
||||
private String previewFile;
|
||||
/**服务指令图片大图-网络地址*/
|
||||
private String netPreviewFile;
|
||||
/**服务指令图片小图*/
|
||||
private String previewFileSmall;
|
||||
/**服务指令图片小图-网络地址*/
|
||||
private String netPreviewFileSmall;
|
||||
/**指令音频文件*/
|
||||
private String mp3File;
|
||||
/**指令音频文件-网络地址*/
|
||||
private String netMp3File;
|
||||
/**指令视频文件*/
|
||||
private String mp4File;
|
||||
/**指令视频文件-网络地址*/
|
||||
private String netMp4File;
|
||||
/**服务时长(分钟)*/
|
||||
private String serviceDuration;
|
||||
/**服务描述*/
|
||||
private String serviceContent;
|
||||
/**开始时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
/**结束时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
/**实际开始时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date beginTime;
|
||||
/**实际结束时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date finishTime;
|
||||
/**是否开始 Y是 N否*/
|
||||
private String izStart;
|
||||
/**是否完成 Y是 N否*/
|
||||
private String izFinish;
|
||||
/**创建人*/
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**是否删除 0未删除 1删除*/
|
||||
private String delFlag;
|
||||
|
||||
/**接单上限*/
|
||||
@TableField(exist = false)
|
||||
private Integer orderCap;
|
||||
|
||||
/**最大时间*/
|
||||
@TableField(exist = false)
|
||||
private Date maxTime;
|
||||
|
||||
/**单次*/
|
||||
@TableField(exist = false)
|
||||
private Integer orderNum;
|
||||
|
||||
/**总服务时长*/
|
||||
@TableField(exist = false)
|
||||
private Integer totalDuration;
|
||||
|
||||
/**总服务收益*/
|
||||
@TableField(exist = false)
|
||||
private BigDecimal totalComPrice;
|
||||
|
||||
/**是否空闲 1空闲 0非空闲*/
|
||||
@TableField(exist = false)
|
||||
private Integer izFree;
|
||||
|
||||
/**员工身上挂载的工单数,未完成工单即为挂单*/
|
||||
@TableField(exist = false)
|
||||
private Integer ownCn;
|
||||
|
||||
/**员工id集合逗号分隔*/
|
||||
@TableField(exist = false)
|
||||
private String employeeIds;
|
||||
|
||||
/**服务指令id集合逗号分隔*/
|
||||
@TableField(exist = false)
|
||||
private String directiveIds;
|
||||
|
||||
/**优先级 数值越高优先级越高*/
|
||||
//空闲状态提高3级 指定护理员提高2级
|
||||
@TableField(exist = false)
|
||||
private Integer level;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.nu.modules.biz.logistics.order.job;
|
||||
|
||||
import com.nu.modules.biz.logistics.order.service.ILogisticsOrdersService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 指令池批量生成工单
|
||||
*/
|
||||
@Slf4j
|
||||
public class LogisticsOrdersJob implements Job {
|
||||
|
||||
@Autowired
|
||||
ILogisticsOrdersService service;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
log.error("OrdersJob:{}-{}", DateUtils.now(),"后勤类指令池批量生成工单开始");
|
||||
Result<?> result = service.generateOrdersBatch();
|
||||
log.error("OrdersJob:{}-{}", DateUtils.now(),result.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.nu.modules.biz.logistics.order.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.biz.logistics.order.entity.LogisticsOrders;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 后勤类服务指令工单主表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface LogisticsOrdersMapper extends BaseMapper<LogisticsOrders> {
|
||||
List<LogisticsOrders> queryDataPoolList(LogisticsOrders orders);
|
||||
List<LogisticsOrders> getEmpPermissionAndOnline(@Param("directiveId") String directiveId, @Param("startTime") Date startTime);
|
||||
LogisticsOrders getEmpOrderly(@Param("customerId") String customerId);
|
||||
List<LogisticsOrders> getPermissionEmps(@Param("directiveIds") String directiveIds);
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.biz.logistics.order.mapper.LogisticsOrdersMapper">
|
||||
|
||||
<select id="queryDataPoolList" resultType="com.nu.modules.biz.logistics.order.entity.LogisticsOrders">
|
||||
select
|
||||
a.id as poolId,
|
||||
a.biz_id as bizId,
|
||||
a.nu_id as nuId,
|
||||
a.nu_name as nuName,
|
||||
a.customer_id as customerId,
|
||||
a.customer_name as customerName,
|
||||
a.directive_id as directiveId,
|
||||
a.directive_name as directiveName,
|
||||
a.cycle_type_id as cycleTypeId,
|
||||
a.cycle_type as cycleType,
|
||||
a.cycle_value as cycleValue,
|
||||
a.preview_file as previewFile,
|
||||
a.net_preview_file as netPeviewFile,
|
||||
a.preview_file_small as previewFileSmall,
|
||||
a.net_preview_file_small as netPreviewFileSmall,
|
||||
a.mp3_file as mp3File,
|
||||
a.net_mp3_file as netMp3File,
|
||||
a.mp4_file as mp4File,
|
||||
a.net_mp4_file as netMp4File,
|
||||
a.service_duration as serviceDuration,
|
||||
a.service_content as serviceContent,
|
||||
a.package_id as packageId,
|
||||
a.package_name as packageName,
|
||||
a.iz_package as izPackage,
|
||||
a.start_time as startTime,
|
||||
a.end_time as endTime,
|
||||
(case when b.orderly is null then 2 else 1 end) as orderEmp
|
||||
from nu_biz_nu_logistics_directive_data_pool a
|
||||
left join nu_biz_elder_info b on a.customer_id = b.id
|
||||
where a.iz_orders = 'N'
|
||||
order by a.start_time,orderEmp,a.nu_id
|
||||
</select>
|
||||
|
||||
<select id="getEmpPermissionAndOnline" resultType="com.nu.modules.biz.logistics.order.entity.LogisticsOrders">
|
||||
select
|
||||
distinct
|
||||
a.id as employeeId,
|
||||
a.name as employeeName,
|
||||
a.order_cap as orderCap,
|
||||
ifnull(e.orderNum,0) as orderNum,
|
||||
ifnull(e.totalDuration,0) as totalDuration,
|
||||
ifnull(e.totalComPrice,0) as totalComPrice,
|
||||
e.maxTime,
|
||||
ifnull(e.ownCn,0) as ownCn,
|
||||
(case when ifnull(f.orderNum,0) = 0 then 1 else 0 end) as izFree,
|
||||
0 as level
|
||||
from nu_biz_employees_info a
|
||||
inner join nu_biz_employees_servcie_tags b on a.id = b.employees_id
|
||||
inner join nu_service_tag c on c.id = b.tags_id
|
||||
inner join nu_servtag_directive d on d.tag_id = c.id
|
||||
left join (
|
||||
select employee_id,count(*) as orderNum,
|
||||
sum(service_duration) as totalDuration,
|
||||
round(sum(ifnull(com_price,0)),4) as totalComPrice,
|
||||
max(start_time) as maxTime,
|
||||
sum(case when iz_finish='N' then 1 else 0 end) as ownCn
|
||||
from nu_biz_nu_logistics_directive_order
|
||||
where start_time >=DATE_FORMAT(NOW(), '%Y-%m-%d 00:00:00')
|
||||
and start_time <=DATE_FORMAT(NOW(), '%Y-%m-%d 23:59:59')
|
||||
group by employee_id
|
||||
) e on a.id = e.employee_id
|
||||
left join (
|
||||
select employee_id,sum(case when iz_finish='N' then 1 else 0 end) as orderNum
|
||||
from nu_biz_nu_logistics_directive_order
|
||||
where start_time = #{startTime}
|
||||
or (start_time < #{startTime} and end_time > #{startTime})
|
||||
group by employee_id
|
||||
) f on a.id = f.employee_id
|
||||
where a.del_flag = '0'
|
||||
and a.iz_freeze = 'N'
|
||||
and a.iz_online = 'Y'
|
||||
and c.del_flag = '0'
|
||||
and c.iz_enabled = 'Y'
|
||||
<if test="directiveId != null and directiveId != ''">
|
||||
AND d.directive_id = #{directiveId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getEmpOrderly" resultType="com.nu.modules.biz.logistics.order.entity.LogisticsOrders">
|
||||
select orderly as employeeIds
|
||||
from nu_biz_elder_info
|
||||
where id = #{customerId}
|
||||
</select>
|
||||
|
||||
<select id="getPermissionEmps" resultType="com.nu.modules.biz.logistics.order.entity.LogisticsOrders">
|
||||
select a.id as employeeId,count(*) as ownCn
|
||||
from nu_biz_employees_info a
|
||||
inner join nu_biz_employees_servcie_tags b on a.id = b.employees_id
|
||||
inner join nu_service_tag c on c.id = b.tags_id
|
||||
inner join nu_servtag_directive d on d.tags_id = c.id
|
||||
where d.directive_id in
|
||||
<foreach collection="directiveIds" item="directiveId" open="(" separator="," close=")">
|
||||
#{directiveId}
|
||||
</foreach>
|
||||
group by a.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nu.modules.biz.logistics.order.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.biz.logistics.order.entity.LogisticsOrders;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
||||
/**
|
||||
* @Description: 后勤类服务指令工单主表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-12-1
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ILogisticsOrdersService extends IService<LogisticsOrders> {
|
||||
Result<?> generateOrdersBatch();
|
||||
}
|
||||
|
|
@ -0,0 +1,319 @@
|
|||
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.logistics.order.entity.LogisticsOrders;
|
||||
import com.nu.modules.biz.logistics.order.mapper.LogisticsOrdersMapper;
|
||||
import com.nu.modules.biz.logistics.order.service.ILogisticsOrdersService;
|
||||
import com.nu.modules.config.sendorderpriority.entity.SendOrderRule;
|
||||
import com.nu.modules.config.sendorderpriority.service.ISendOrderRuleService;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 后勤类服务指令工单主表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-12-1
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class LogisticsOrdersServiceImpl extends ServiceImpl<LogisticsOrdersMapper, LogisticsOrders> implements ILogisticsOrdersService {
|
||||
|
||||
@Autowired
|
||||
ISendOrderRuleService sendOrderRuleService;
|
||||
|
||||
/**
|
||||
* 获取在线,有指令权限的员工,并获取员工的接单上限、收益、服务时长、单次
|
||||
* @param directiveId
|
||||
* @return
|
||||
*/
|
||||
private List<LogisticsOrders> getEmpPermissionAndOnline(String directiveId, Date startTime){
|
||||
return baseMapper.getEmpPermissionAndOnline(directiveId,startTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取长者指定所有护理员
|
||||
* @param customerId
|
||||
* @return
|
||||
*/
|
||||
private Map<String,String> getEmpOrderly(String customerId){
|
||||
Map<String, String> map = null;
|
||||
LogisticsOrders orders = baseMapper.getEmpOrderly(customerId);
|
||||
if(orders!=null){
|
||||
String empIds = orders.getEmployeeIds();
|
||||
if(empIds!=null&&!empIds.equals("")){
|
||||
String[] pairs = empIds.split(",");
|
||||
if(pairs.length>0){
|
||||
map = new HashMap<>();
|
||||
for (String pair : pairs) {
|
||||
map.put(pair, pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指令池批量生成工单-定时调用
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<?> generateOrdersBatch(){
|
||||
List<LogisticsOrders> ordersList = baseMapper.queryDataPoolList(null);
|
||||
for(int i=0;i<ordersList.size();i++){
|
||||
LogisticsOrders orders = ordersList.get(i);
|
||||
generateOrders(orders);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工单子表数据,并进行处理
|
||||
* @param orders
|
||||
*/
|
||||
private void generateOrders(LogisticsOrders orders){
|
||||
System.out.println("护理单元:"+orders.getNuId()+",服务时间"+orders.getStartTime());
|
||||
//获取满足条件的员工
|
||||
LogisticsOrders employee = employeeScreening(orders.getDirectiveId(),orders.getCustomerId(),orders.getStartTime());
|
||||
if(employee!=null){
|
||||
orders.setEmployeeId(employee.getEmployeeId());
|
||||
orders.setEmployeeName(employee.getEmployeeName());
|
||||
orders.setIzStart("N");
|
||||
orders.setIzFinish("N");
|
||||
this.save(orders);//生成工单主表
|
||||
System.out.println("护理单元:"+orders.getNuId()+",服务时间:"+orders.getStartTime()+",服务员工:"+employee.getEmployeeName()+",获得积分:"+employee.getLevel());
|
||||
System.out.println("");
|
||||
System.out.println("");
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取满足条件的员工
|
||||
* @return
|
||||
*/
|
||||
private LogisticsOrders employeeScreening(String directiveId, String customerId, Date startTime){
|
||||
|
||||
//获取派单规则
|
||||
QueryWrapper<SendOrderRule> qw = new QueryWrapper<>();
|
||||
qw.eq("izEnabled", "Y");
|
||||
SendOrderRule one = sendOrderRuleService.getOne(qw);
|
||||
if(one.getPriorityCode().equals("1")){
|
||||
return getByPriority();
|
||||
}
|
||||
if(one.getPriorityCode().equals("2")){
|
||||
return getByHeadCount();
|
||||
}
|
||||
if(one.getPriorityCode().equals("3")){
|
||||
return getBySpecial();
|
||||
}
|
||||
|
||||
List<LogisticsOrders> empList = getEmpPermissionAndOnline(directiveId,startTime);
|
||||
Map<String,String> orderlyMap = getEmpOrderly(customerId);
|
||||
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());
|
||||
String employeeId = emp.getEmployeeId();
|
||||
if(emp.getIzFree().equals(1)){
|
||||
Integer empLevel = emp.getLevel();
|
||||
empLevel = empLevel + empList.size()*5; //提高5N等级
|
||||
emp.setLevel(empLevel);
|
||||
}
|
||||
System.out.println("员工获取空闲积分信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName()+"["+emp.getLevel()+"]");
|
||||
if(orderlyMap!=null){
|
||||
String orderlyId = orderlyMap.get(employeeId);
|
||||
if(orderlyId!=null&&!orderlyId.equals("")){
|
||||
Integer empLevel = emp.getLevel();
|
||||
empLevel = empLevel + empList.size()*3; //提高4N等级
|
||||
emp.setLevel(empLevel);
|
||||
}
|
||||
}
|
||||
System.out.println("员工获取指定护理积分信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName()+"["+emp.getLevel()+"]");
|
||||
}
|
||||
//通过工单次数排序数据来设置优先级
|
||||
sortByNumAndSetLevel(empList);
|
||||
for(int i=0;i<empList.size();i++){
|
||||
LogisticsOrders emp = empList.get(i);
|
||||
System.out.println("员工获取工单数积分信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName()+"["+emp.getLevel()+"]");
|
||||
}
|
||||
//通过总收益排序数据来设置优先级
|
||||
sortByPriceAndSetLevel(empList);
|
||||
for(int i=0;i<empList.size();i++){
|
||||
LogisticsOrders emp = empList.get(i);
|
||||
System.out.println("员工获取工单收益积分信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName()+"["+emp.getLevel()+"]");
|
||||
}
|
||||
//通过服务时长排序数据来设置优先级
|
||||
sortByDurationAndSetLevel(empList);
|
||||
for(int i=0;i<empList.size();i++){
|
||||
LogisticsOrders emp = empList.get(i);
|
||||
System.out.println("员工获取服务时长积分信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName()+"["+emp.getLevel()+"]");
|
||||
}
|
||||
//通过最后一次接收派单时间排序数据来设置优先级
|
||||
sortByMaxTimeAndSetLevel(empList);
|
||||
for(int i=0;i<empList.size();i++){
|
||||
LogisticsOrders emp = empList.get(i);
|
||||
System.out.println("员工获取派单时间积分信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName()+"["+emp.getLevel()+"]");
|
||||
}
|
||||
//按优先级排序数据
|
||||
sortByLevel(empList);
|
||||
for(int i=0;i<empList.size();i++){
|
||||
LogisticsOrders emp = empList.get(i);
|
||||
System.out.println("员工获取总积分信息:"+emp.getEmployeeId()+"-"+emp.getEmployeeName()+"["+emp.getLevel()+"]");
|
||||
}
|
||||
//获取员工信息
|
||||
return empList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先级派单
|
||||
* @return
|
||||
*/
|
||||
private LogisticsOrders getByPriority(){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按人头派单
|
||||
* @return
|
||||
*/
|
||||
private LogisticsOrders getByHeadCount(){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1V1派单
|
||||
* @return
|
||||
*/
|
||||
private LogisticsOrders getBySpecial(){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过工单次数排序数据来设置优先级
|
||||
* @param empList
|
||||
*/
|
||||
public void sortByNumAndSetLevel(List<LogisticsOrders> empList) {
|
||||
// 根据orderNum倒序排序,并为level顺序赋值
|
||||
List<LogisticsOrders> sortedEmployees = empList.stream()
|
||||
.sorted(Comparator.comparing(LogisticsOrders::getOrderNum).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 为level字段顺序赋值1,2,3...
|
||||
for (int i = 0; i < sortedEmployees.size(); i++) {
|
||||
Integer levle = sortedEmployees.get(i).getLevel()+i+1;
|
||||
sortedEmployees.get(i).setLevel(levle);
|
||||
}
|
||||
|
||||
// 如果需要返回新列表,可以返回sortedEmployees
|
||||
// 如果要在原列表上修改,可以清空原列表并添加所有元素
|
||||
empList.clear();
|
||||
empList.addAll(sortedEmployees);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过总收益排序数据来设置优先级
|
||||
* @param empList
|
||||
*/
|
||||
public void sortByPriceAndSetLevel(List<LogisticsOrders> empList) {
|
||||
// 根据totalComPrice倒序排序,并为level顺序赋值
|
||||
List<LogisticsOrders> sortedEmployees = empList.stream()
|
||||
.sorted(Comparator.comparing(LogisticsOrders::getTotalComPrice).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 为level字段顺序赋值1,2,3...
|
||||
for (int i = 0; i < sortedEmployees.size(); i++) {
|
||||
Integer levle = sortedEmployees.get(i).getLevel()+i+1;
|
||||
sortedEmployees.get(i).setLevel(levle);
|
||||
}
|
||||
|
||||
// 如果需要返回新列表,可以返回sortedEmployees
|
||||
// 如果要在原列表上修改,可以清空原列表并添加所有元素
|
||||
empList.clear();
|
||||
empList.addAll(sortedEmployees);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过服务时长排序数据来设置优先级
|
||||
* @param empList
|
||||
*/
|
||||
public void sortByDurationAndSetLevel(List<LogisticsOrders> empList) {
|
||||
// 根据totalDuration倒序排序,并为level顺序赋值
|
||||
List<LogisticsOrders> sortedEmployees = empList.stream()
|
||||
.sorted(Comparator.comparing(LogisticsOrders::getTotalDuration).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 为level字段顺序赋值1,2,3...
|
||||
for (int i = 0; i < sortedEmployees.size(); i++) {
|
||||
Integer levle = sortedEmployees.get(i).getLevel()+i+1;
|
||||
sortedEmployees.get(i).setLevel(levle);
|
||||
}
|
||||
|
||||
// 如果需要返回新列表,可以返回sortedEmployees
|
||||
// 如果要在原列表上修改,可以清空原列表并添加所有元素
|
||||
empList.clear();
|
||||
empList.addAll(sortedEmployees);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过最后一次接收派单时间排序数据来设置优先级
|
||||
* @param empList
|
||||
*/
|
||||
public void sortByMaxTimeAndSetLevel(List<LogisticsOrders> empList) {
|
||||
// 根据maxTime倒序排序,并为level顺序赋值
|
||||
List<LogisticsOrders> sortedEmployees = empList.stream()
|
||||
.sorted(Comparator.comparing(
|
||||
LogisticsOrders::getMaxTime,
|
||||
Comparator.nullsLast(Comparator.reverseOrder())
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 为level字段顺序赋值1,2,3...
|
||||
for (int i = 0; i < sortedEmployees.size(); i++) {
|
||||
Integer levle = sortedEmployees.get(i).getLevel()+i+1;
|
||||
sortedEmployees.get(i).setLevel(levle);
|
||||
}
|
||||
|
||||
// 如果需要返回新列表,可以返回sortedEmployees
|
||||
// 如果要在原列表上修改,可以清空原列表并添加所有元素
|
||||
empList.clear();
|
||||
empList.addAll(sortedEmployees);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按优先级排序数据
|
||||
* @param empList
|
||||
*/
|
||||
public void sortByLevel(List<LogisticsOrders> empList) {
|
||||
for (int i = 0; i < empList.size(); i++) {
|
||||
//工单超出接单上限,降4N级
|
||||
if(empList.get(i).getOwnCn()>=empList.get(i).getOrderCap()){
|
||||
Integer levle = empList.get(i).getLevel()-empList.size()*4;
|
||||
empList.get(i).setLevel(levle);
|
||||
}
|
||||
}
|
||||
//为level顺序
|
||||
List<LogisticsOrders> sortedEmployees = empList.stream()
|
||||
.sorted(Comparator.comparing(LogisticsOrders::getLevel).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 如果需要返回新列表,可以返回sortedEmployees
|
||||
// 如果要在原列表上修改,可以清空原列表并添加所有元素
|
||||
empList.clear();
|
||||
empList.addAll(sortedEmployees);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.entity.LogisticsDirectiveEntity;
|
||||
import com.nu.modules.biz.logistics.datapool.service.ILogisticsDataPoolService;
|
||||
import com.nu.modules.biz.logistics.plan.entity.PlanBizNuCustomerLogisticsServer;
|
||||
import com.nu.modules.biz.logistics.plan.mapper.PlanBizNuCustomerLogisticsServerMapper;
|
||||
import com.nu.modules.biz.logistics.plan.service.IPlanBizNuCustomerLogisticsServerService;
|
||||
|
|
@ -27,8 +28,8 @@ public class PlanBizNuCustomerLogisticsServerServiceImpl extends ServiceImpl<Pla
|
|||
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
// @Autowired
|
||||
// private CareDataPoolServiceImpl dataPoolServiceImpl;
|
||||
@Autowired
|
||||
private ILogisticsDataPoolService dataPoolServiceImpl;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPlanList(LogisticsDirectiveEntity logisticsDirectiveEntity) {
|
||||
|
|
@ -50,7 +51,7 @@ public class PlanBizNuCustomerLogisticsServerServiceImpl extends ServiceImpl<Pla
|
|||
//TODO 增加日志
|
||||
|
||||
//单一指令生成到数据池
|
||||
// dataPoolServiceImpl.generateDataPool(planBizNuCustomerServer);
|
||||
dataPoolServiceImpl.generateDataPool(planBizNuCustomerServer);
|
||||
BeanUtils.copyProperties(planBizNuCustomerServer, logisticsDirectiveEntity);
|
||||
return logisticsDirectiveEntity;
|
||||
}
|
||||
|
|
@ -63,7 +64,7 @@ public class PlanBizNuCustomerLogisticsServerServiceImpl extends ServiceImpl<Pla
|
|||
baseMapper.updateById(planBizNuCustomerServer);
|
||||
//TODO 增加日志
|
||||
//调用方法先删除数据池中的数据,再生成数据池中的数据
|
||||
// dataPoolServiceImpl.editDataPool(entity);
|
||||
dataPoolServiceImpl.editDataPool(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -72,7 +73,7 @@ public class PlanBizNuCustomerLogisticsServerServiceImpl extends ServiceImpl<Pla
|
|||
BeanUtils.copyProperties(logisticsDirectiveEntity,planBizNuCustomerServer);
|
||||
String id = planBizNuCustomerServer.getId();
|
||||
//调用方法删除数据池中的数据
|
||||
// dataPoolServiceImpl.deleteDataPool(planBizNuCustomerServer);
|
||||
dataPoolServiceImpl.deleteDataPool(planBizNuCustomerServer);
|
||||
baseMapper.deleteByIdPhysic(id);
|
||||
//TODO 增加日志
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue