From 557c2711a3e103ebc3d0492344eca9730d5e92b2 Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期一, 17 二月 2025 10:47:47 +0800
Subject: [PATCH] 增加司机配送单超时处理任务,防止一直不停手机定位信息,
---
CoreCms.Net.Task/AutoCloseCYPeiSongJobs.cs | 60 ++++++++++++++++++++++++++++++
CoreCms.Net.Task/HangfireDispose.cs | 2 +
CoreCms.Net.Configuration/AppSettingsConstVars.cs | 5 ++
CoreCms.Net.Model/CyinOAModel/CoreDeliverOrder.cs | 13 ++++++
CoreCms.Net.Services/CYOAServices/CyinOAService.cs | 5 +-
5 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/CoreCms.Net.Configuration/AppSettingsConstVars.cs b/CoreCms.Net.Configuration/AppSettingsConstVars.cs
index 510ba43..6959622 100644
--- a/CoreCms.Net.Configuration/AppSettingsConstVars.cs
+++ b/CoreCms.Net.Configuration/AppSettingsConstVars.cs
@@ -57,6 +57,11 @@
/// </summary>
public static readonly string CyDbDbType = AppSettingsHelper.GetContent("CyConnectionStrings", "DbType");
+ /// <summary>
+ /// 宸濆嵃娲鹃�佽鍗曡秴鏃舵椂闂磋缃�
+ /// </summary>
+ public static readonly string CyDeliverOverTime = AppSettingsHelper.GetContent("CyinOs", "CyDeliverOverTime");
+
#endregion
#region redis================================================================================
diff --git a/CoreCms.Net.Model/CyinOAModel/CoreDeliverOrder.cs b/CoreCms.Net.Model/CyinOAModel/CoreDeliverOrder.cs
index fac9cdf..c883e0e 100644
--- a/CoreCms.Net.Model/CyinOAModel/CoreDeliverOrder.cs
+++ b/CoreCms.Net.Model/CyinOAModel/CoreDeliverOrder.cs
@@ -1,5 +1,7 @@
锘縰sing System;
using System.Collections.Generic;
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using SqlSugar;
@@ -131,19 +133,28 @@
/// <summary>
/// 鏈紑濮嬶紝宸茬粡棰勭害 寤虹珛灏辫〃绀洪绾�
/// </summary>
+ [Description("鏈紑濮嬶紝宸茬粡棰勭害 寤虹珛灏辫〃绀洪绾�")]
UnStart,
/// <summary>
/// 寮�濮�
/// </summary>
+ [Description("寮�濮�")]
Start,
/// <summary>
/// 瀹屾垚
/// </summary>
+ [Description("瀹屾垚")]
Completed,
/// <summary>
/// 澶辫触鍙栨秷
/// </summary>
- Faile
+ [Description("澶辫触鍙栨秷")]
+ Faile,
+ /// <summary>
+ /// 瓒呮椂
+ /// </summary>
+ [Description("瓒呮椂瀹屾垚")]
+ OverTime
}
}
diff --git a/CoreCms.Net.Services/CYOAServices/CyinOAService.cs b/CoreCms.Net.Services/CYOAServices/CyinOAService.cs
index ee027df..9bae019 100644
--- a/CoreCms.Net.Services/CYOAServices/CyinOAService.cs
+++ b/CoreCms.Net.Services/CYOAServices/CyinOAService.cs
@@ -59,8 +59,7 @@
const string IsSchoolID = "IsShoodsID:";
const string IsSchoolMangerID = "IsSchoolManger:";
const string IsDeliverManageKey = "IsDeliverManageKey:";
- private readonly ISqlSugarClient _CyDbClient;
- private readonly IUnitOfWork _UnitOfWork;
+ private readonly ISqlSugarClient _CyDbClient;
private readonly IHttpContextUser _User;
private readonly ICoreCmsUserServices _coreCmsUserServices;
private readonly IRedisOperationRepository _redisOperationRepository;
@@ -76,7 +75,7 @@
IRedisOperationRepository redisOperationRepository, ICoreCmsUserServices coreCmsUser)
{
- _UnitOfWork = unitOfWork;
+
_CyDbClient = unitOfWork.GetDbClient().GetConnection(AppSettingsConstVars.CYDbDbID);
_User = contextUser;
_coreCmsUserServices = coreCmsUserServices;
diff --git a/CoreCms.Net.Task/AutoCloseCYPeiSongJobs.cs b/CoreCms.Net.Task/AutoCloseCYPeiSongJobs.cs
new file mode 100644
index 0000000..69381cd
--- /dev/null
+++ b/CoreCms.Net.Task/AutoCloseCYPeiSongJobs.cs
@@ -0,0 +1,60 @@
+锘縰sing CoreCms.Net.Configuration;
+using CoreCms.Net.IRepository.UnitOfWork;
+using CoreCms.Net.IServices;
+using CoreCms.Net.Repository.UnitOfWork;
+using CoreCms.Net.Utility.Extensions;
+using EC_SeckillInfo;
+using Essensoft.Paylink.Alipay.Domain;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CoreCms.Net.Task
+{
+ /// <summary>
+ /// 鑷姩鍏抽棴CY閰嶉�佸崟锛岄槻姝㈠畾浣嶄俊鎭棤鏁堝闀�
+ /// </summary>
+ public class AutoCloseCYPeiSongJobs
+ {
+
+ private readonly ISqlSugarClient _CyDbClient;
+
+
+ public AutoCloseCYPeiSongJobs(IUnitOfWork unitOfWork)
+ {
+ _CyDbClient = unitOfWork.GetDbClient().GetConnection(AppSettingsConstVars.CYDbDbID);
+ }
+ public async System.Threading.Tasks.Task Execute()
+ {
+ var ListData= await _CyDbClient.Queryable<CoreDeliverOrder>().Where(x => x.OrderState == CoreDeliverOrderType.Start).ToListAsync();
+
+ await _CyDbClient.AsTenant().BeginTranAsync();
+ try
+ {
+ foreach (var item in ListData)
+ {
+ if( item.StartTime.Value.AddDays(AppSettingsConstVars.CyDeliverOverTime.ToInt32OrDefault(5))<DateTime.Now)
+ {
+ item.OverTime= DateTime.Now;
+ item.OrderState = CoreDeliverOrderType.OverTime;
+ item.UpDataBy = "瀹氭椂浠诲姟";
+ item.UpdataTime = DateTime.Now;
+ item.Remarke = "绯荤粺瓒呮椂瀹岀粨澶勭悊";
+ await _CyDbClient.Updateable(item).ExecuteCommandAsync();
+ }
+ }
+ await _CyDbClient.AsTenant().CommitTranAsync();
+ }
+ catch (Exception)
+ {
+ await _CyDbClient.AsTenant().RollbackTranAsync();
+ throw;
+ }
+
+
+ }
+ }
+}
diff --git a/CoreCms.Net.Task/HangfireDispose.cs b/CoreCms.Net.Task/HangfireDispose.cs
index 07fa16d..00f8125 100644
--- a/CoreCms.Net.Task/HangfireDispose.cs
+++ b/CoreCms.Net.Task/HangfireDispose.cs
@@ -72,6 +72,8 @@
//瀹氭椂璁$畻缁忛攢鍟嗘帹骞胯垂鐢�
RecurringJob.AddOrUpdate<AutoSettleAchievementTotal>("AutoSettleAchievementTotal", s => s.Execute(), "0 0 0/1 * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 姣忓皬鏃惰绠楃粡閿�鍟嗘帹骞胯垂鐢�
+ //瀹氭椂澶勭悊鍙告満閰嶉�佸崟瓒呮椂澶勭悊
+ RecurringJob.AddOrUpdate<AutoCloseCYPeiSongJobs>("AutoCloseCYPeiSongJobs", s => s.Execute(), "0 */6 * * *", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 姣�6灏忔椂鎵ц涓�娆¢厤閫佸崟瓒呮椂妫�娴� 0 */6 * * *
}
#endregion
--
Gitblit v1.9.1