first commit

This commit is contained in:
陈现府
2025-11-20 10:45:16 +08:00
commit 8355431361
2643 changed files with 291314 additions and 0 deletions
@@ -0,0 +1,124 @@
package com.mhd.job.task;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.mhd.common.core.constant.Constants;
import com.mhd.common.core.constant.NoticeConstants;
import com.mhd.common.core.domain.dto.NoticeMessageLoggingDto;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.enums.MessageTypeEnum;
import com.mhd.common.core.service.jPush.AsyncJPushApplicationService;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.redis.service.RedisService;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.WlhyServiceFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Component("appLocationTask")
public class AppLocationTask {
@Resource
private WlhyServiceFeign wlhyServiceFeign;
@Resource
private UserServiceFeign userServiceFeign;
@Resource
private RedisService redisService;
@Autowired
private AsyncJPushApplicationService asyncJPushApplicationService;
@Resource
private SystemServiceFeign systemServiceFeign;
public void getUserException(){
// log.info("app离线司机任务开始调用,时间{}", DateUtil.date());
//所有在运输的司机
List<Long> all = new ArrayList<>();
//当前在线的司机
List<Long> online = new ArrayList<>();
R<List<Long>> allTransportNote = wlhyServiceFeign.getAllTransportNote();
if (R.SUCCESS == allTransportNote.getCode()) {
all = allTransportNote.getData();
if (all != null && all.size() > 0 ){
all = all.stream().distinct().collect(Collectors.toList());
}
}
R<List<Long>> onlineDriver = userServiceFeign.getOnlineDriver();
if (R.SUCCESS == onlineDriver.getCode()) {
online = onlineDriver.getData();
}
//所有异常离线的司机
List<Long> offline = getLongSubList(all, online);
/**
* 通过redis转换,保存已经离线的司机和
* 1.获取redis中离线的司机
* 2.去除当前和redis中的差,为当前离线的司机
*/
String key = Constants.APP_OFFLINE+ "offline";
List<Long> redisOffline = redisService.getCacheObject(key);
//目前离线司机
List<Long> nowoffline = getLongSubList(offline, redisOffline);
//重新保存所有离线司机
redisService.setCacheObject(key, offline);
//开始消息推送
if (nowoffline != null && nowoffline.size() > 0){
NoticeMessageLoggingDto param = new NoticeMessageLoggingDto();
NoticeMessageLoggingDto common = new NoticeMessageLoggingDto();
common.setNoticeMessageType(MessageTypeEnum.system_notifications.getCode());
common.setNoticeMessageName(MessageTypeEnum.system_notifications.getInfo());
common.setNoticeMessageTitle(NoticeConstants.exception_offline);
String text = StringUtils.format(NoticeConstants.app_location_exception, DateUtil.formatDateTime(new Date()));
common.setNoticeMessageContent(text);
List<String> list = new ArrayList<>();
List<NoticeMessageLoggingDto> res = new ArrayList<>();
for (Long aLong : nowoffline) {
list.add(aLong.toString());
NoticeMessageLoggingDto fhr = new NoticeMessageLoggingDto();
BeanUtils.copyProperties(common,fhr);
fhr.setUserId(aLong);
res.add(fhr);
}
param.setNoticeList(res);
systemServiceFeign.addMessageLoggingList(param);
asyncJPushApplicationService.pushAndroidIndividualByAlias(NoticeConstants.exception_offline,NoticeConstants.app_location_exception, list, 0);
//根据szwlUserId推送前端
wlhyServiceFeign.pushNowOffLine(nowoffline);
}
}
/**
* 获取两个集合的差集
*/
public static List<Long> getLongSubList(List<Long> list1, List<Long> list2) {
if (CollectionUtil.isEmpty(list1) || list1.get(list1.size() -1) == null) {
return null;
}
if (CollectionUtil.isEmpty(list2) || list2.get(list2.size() -1) == null) {
return list1;
}
return list1.stream().filter(e -> {
return !list2.contains(e);
}).collect(Collectors.toList());
}
}
@@ -0,0 +1,37 @@
package com.mhd.job.task;
import cn.hutool.core.date.DateUtil;
import com.mhd.job.feign.WlhyServiceFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 网货竞价定时任务
*/
@Slf4j
@Component("biddingTask")
public class BiddingTask {
@Autowired
private WlhyServiceFeign wlhyServiceFeign;
/**
* 首次竞价
*/
public void pollingBiding() {
log.info("首次竞价定时任务开始调用,时间{}", DateUtil.date());
wlhyServiceFeign.pollingBiding();
log.info("首次竞价定时任务结束调用,时间{}", DateUtil.date());
}
/**
* 二次竞价
*/
public void pollingSecondBidding() {
log.info("首次竞价定时任务开始调用,时间{}", DateUtil.date());
wlhyServiceFeign.pollingSecondBidding();
log.info("首次竞价定时任务结束调用,时间{}", DateUtil.date());
}
}
@@ -0,0 +1,35 @@
package com.mhd.job.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.mhd.job.feign.TicketServiceFeign;
import com.mhd.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("refuseInvoiceTask")
public class RefuseInvoiceTask {
@Autowired
private TicketServiceFeign ticketServiceFeign;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
}
public void ryParams(String params)
{
System.out.println("执行有参方法:" + params);
}
public void refuseAll()
{
ticketServiceFeign.refuseAll();
System.out.println("执行票务系统定时任务:" + DateUtil.format(new DateTime(), "yyyy年MM月dd日 HH时mm分ss秒"));
}
}
@@ -0,0 +1,40 @@
package com.mhd.job.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import com.mhd.job.feign.LogisticsServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.mhd.common.core.utils.StringUtils;
/**
* 定时任务调度测试
*
* @author mhd
*/
@Component("ryTask")
public class RyTask
{
@Autowired
private LogisticsServiceFeign logisticsServiceFeign;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
}
public void ryParams(String params)
{
System.out.println("执行有参方法:" + params);
}
public void ryNoParams()
{
JSONObject jsonObject = new JSONObject();
jsonObject.set("waybillId","202309141102");
logisticsServiceFeign.testJob(jsonObject);
System.out.println("执行无参方法" + DateUtil.format(new DateTime(), "yyyy年MM月dd日 HH时mm分ss秒"));
}
}
@@ -0,0 +1,19 @@
package com.mhd.job.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.mhd.job.feign.ProductServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("tenantsOutOfDataTask")
public class TenantsOutOfDataTask {
@Autowired
private ProductServiceFeign productServiceFeign;
public void getAllOut0fDate()
{
productServiceFeign.getAllOut0fDate();
System.out.println("执行租户查询停用的方法:" + DateUtil.format(new DateTime(), "yyyy年MM月dd日 HH时mm分ss秒"));
}
}
@@ -0,0 +1,23 @@
package com.mhd.job.task;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
import java.time.LocalDate;
@Slf4j
public class TestJob extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
log.info("============================定时任务开始执行======================");
System.out.println("执行定时任务" + LocalDate.now());
log.info("============================定时任务执行完毕======================");
}
}
@@ -0,0 +1,32 @@
package com.mhd.job.task;
import cn.hutool.core.date.DateUtil;
import com.mhd.job.feign.WlhyServiceFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author ZhouGY
* @title WlhyTask
* @description: 网络货运定时器
* @date 2024/3/25 10:28
**/
@Slf4j
@Component("wlhyTask")
public class WlhyTask {
@Autowired
private WlhyServiceFeign wlhyServiceFeign;
/**
* @description 每天1点关闭超时批量货
* @author ZhouGY
* @date 2024/3/25 10:24
*/
public void closeOverrunOrder() {
log.info("关闭超时批量货定时任务开始调用,时间{}", DateUtil.date());
wlhyServiceFeign.closeOverrunOrder();
log.info("关闭超时批量货定时任务结束调用,时间{}", DateUtil.date());
}
}