tangjiang 10 months ago
parent
commit
d56a46f50d

+ 61 - 11
src/DataSharing.Host/StartupHelper.cs

@@ -1,4 +1,5 @@
-using DataSharing.Repository;
+using DataSharing.Province.SendTask;
+using DataSharing.Repository;
 using DataSharing.SendTask;
 using Mapster;
 using MapsterMapper;
@@ -192,16 +193,65 @@ namespace DataSharing.Host
                 d.InterruptJobsOnShutdownWithWait = true;
                 d.MaxBatchSize = 3;
 
-                ////load send task
-                //var taskLoadJobKey = new JobKey("task-load-job", "load task");
-                //d.AddJob<TaskLoadJob>(taskLoadJobKey);
+                //服务工单受理  
+                var taskSubmitCaseInfoJobKey = new JobKey("task-submit-case-info-job", "load task");
+                d.AddJob<TaskSubmitCaseInfoJob>(taskSubmitCaseInfoJobKey);
+                d.AddTrigger(t => t
+                    .WithIdentity("task-submit-case-info-trigger")
+                    .ForJob(taskSubmitCaseInfoJobKey)
+                    .StartNow()
+                     .WithCronSchedule("0/30 * * * * ? ")
+                );
 
-                //d.AddTrigger(t => t
-                //    .WithIdentity("task-load-trigger")
-                //    .ForJob(taskLoadJobKey)
-                //    .StartNow()
-                //    .WithCronSchedule("0 0/1 * * * ? ")
-                //);
+                //服务工单处理过程
+                var taskSubmitCaseProcessKey = new JobKey("task-submit-case-process-job", "load task");
+                d.AddJob<TaskSubmitCaseProcessJob>(taskSubmitCaseProcessKey);
+                d.AddTrigger(t => t
+                    .WithIdentity("task-submit-case-process-trigger")
+                    .ForJob(taskSubmitCaseProcessKey)
+                    .StartNow()
+                     .WithCronSchedule("0/30 * * * * ? ")
+                );
+
+                //服务工单处理结果
+                var taskSubmitCaseResultKey = new JobKey("task-submit-case-result-job", "load task");
+                d.AddJob<TaskSubmitCaseResultJob>(taskSubmitCaseResultKey);
+                d.AddTrigger(t => t
+                    .WithIdentity("task-submit-case-result-trigger")
+                    .ForJob(taskSubmitCaseResultKey)
+                    .StartNow()
+                     .WithCronSchedule("0/30 * * * * ? ")
+                );
+
+                //电话记录
+                var taskSubmitCaseRecordKey = new JobKey("task-submit-case-record-job", "load task");
+                d.AddJob<TaskSubmitCaseRecordJob>(taskSubmitCaseRecordKey);
+                d.AddTrigger(t => t
+                    .WithIdentity("task-submit-case-record-trigger")
+                    .ForJob(taskSubmitCaseRecordKey)
+                    .StartNow()
+                     .WithCronSchedule("0/30 * * * * ? ")
+                );
+
+                //省推送其他服务
+                var taskProvinceOtherKey = new JobKey("task-province-other-job", "load task");
+                d.AddJob<TaskProvinceOtherJob>(taskProvinceOtherKey);
+                d.AddTrigger(t => t
+                    .WithIdentity("task-province-other-trigger")
+                    .ForJob(taskProvinceOtherKey)
+                    .StartNow()
+                     .WithCronSchedule("0/30 * * * * ? ")
+                );
+
+                //其它平台服务
+                var taskOtherPlatformsKey = new JobKey("task-other-platforms-job", "load task");
+                d.AddJob<TaskOtherPlatformsJob>(taskOtherPlatformsKey);
+                d.AddTrigger(t => t
+                    .WithIdentity("task-other-platforms-trigger")
+                    .ForJob(taskOtherPlatformsKey)
+                    .StartNow()
+                     .WithCronSchedule("0/30 * * * * ? ")
+                );
 
                 ////execute send task
                 //var taskExecuteJobKey = new JobKey("task-execute-job", "send task");
@@ -235,7 +285,7 @@ namespace DataSharing.Host
                 //);
 
             });
-            
+
 
             services.AddQuartzServer(d =>
             {

+ 6 - 6
src/DataSharing.Share/Dtos/Province/ProvinceResponse.cs

@@ -35,22 +35,22 @@
     public class ProvinceBathErrorObjsResponse
     {
         [System.Text.Json.Serialization.JsonPropertyName("resturl")]
-        public string Resturl {  get; set; }
+        public string RestUrl {  get; set; }
 
         [System.Text.Json.Serialization.JsonPropertyName("datasource")]
-        public string Datasource { get; set; }
+        public string DataSource { get; set; }
 
         [System.Text.Json.Serialization.JsonPropertyName("caseserial")]
-        public string Caseserial { get; set; }
+        public string CaseSerial { get; set; }
 
         [System.Text.Json.Serialization.JsonPropertyName("caseid")]
-        public string Caseid { get; set; }
+        public string CaseId { get; set; }
 
         [System.Text.Json.Serialization.JsonPropertyName("dataobj")]
-        public string Dataobj { get; set; }
+        public string DataObj { get; set; }
 
         [System.Text.Json.Serialization.JsonPropertyName("errormsg")]
-        public string Errormsg { get; set; }
+        public string ErrorMsg { get; set; }
     }
 
     /// <summary>

+ 6 - 0
src/DataSharing/Province/SendTask/SubmitCaseProcess/DsSendTaskSubmitCaseProcess.cs

@@ -10,6 +10,12 @@ namespace DataSharing.Province.SendTask.SubmitCaseProcess
     [Description("业务汇聚-服务工单处理过程推送任务数据")]
     public class DsSendTaskSubmitCaseProcess : BaseSendTask
     {
+        /// <summary>
+        /// 过程唯一ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "过程唯一ID")]
+        public string? CaseId {  get; set; }
+
         /// <summary>
         /// 组装参数
         /// </summary>

+ 6 - 0
src/DataSharing/Province/SendTask/SubmitCaseProcess/DsWaitSendTaskSubmitCaseProcess.cs

@@ -10,6 +10,12 @@ namespace DataSharing.Province.SendTask.SubmitCaseProcess
     [Description("业务汇聚-服务工单处理过程待推送任务数据")]
     public class DsWaitSendTaskSubmitCaseProcess : BaseWaitSendTask
     {
+        /// <summary>
+        /// 过程唯一ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "过程唯一ID")]
+        public string? CaseId { get; set; }
+
         /// <summary>
         /// 组装参数
         /// </summary>

+ 36 - 36
src/DataSharing/Province/SendTask/TaskProvinceOtherJob.cs

@@ -1,27 +1,19 @@
 using DataSharing.Province.SendTask.ProvinceOther;
+using DataSharing.RawData;
 using DataSharing.SendTask;
-using DataSharing.Share.Dtos.HotlineWeb;
 using DataSharing.Share.Dtos.Province;
 using DataSharing.Share.Enums;
 using Microsoft.Extensions.Logging;
 using Newtonsoft.Json;
 using Quartz;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
 using System.Net;
-using System.Text;
-using System.Text.Json;
-using System.Threading;
-using System.Threading.Tasks;
 using XF.Domain.Repository;
-using static System.Runtime.InteropServices.JavaScript.JSType;
-using System.Xml.Linq;
-using DataSharing.RawData;
 
 namespace DataSharing.Province.SendTask
 {
+    /// <summary>
+    /// 
+    /// </summary>
     public class TaskProvinceOtherJob : IJob, IDisposable
     {
         private readonly ILogger<TaskProvinceOtherJob> _logger;
@@ -34,6 +26,18 @@ namespace DataSharing.Province.SendTask
         private readonly IHttpClientFactory _httpClientFactory;
         private readonly IRepository<DsOrderVisitSend> _dsOrderVisitSendRepository;
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="logger"></param>
+        /// <param name="sendTaskProvinceOtherRepository"></param>
+        /// <param name="waitSendTaskProvinceOtherRepository"></param>
+        /// <param name="channelConfigurationManager"></param>
+        /// <param name="huiJuClient"></param>
+        /// <param name="xieTongClient"></param>
+        /// <param name="sendTaskDetailInfoRepository"></param>
+        /// <param name="httpClientFactory"></param>
+        /// <param name="dsOrderVisitSendRepository"></param>
         public TaskProvinceOtherJob(ILogger<TaskProvinceOtherJob> logger,
             IRepository<DsSendTaskProvinceOther> sendTaskProvinceOtherRepository,
             IRepository<DsWaitSendTaskProvinceOther> waitSendTaskProvinceOtherRepository,
@@ -72,7 +76,6 @@ namespace DataSharing.Province.SendTask
 
             if (tasks.Count != 0)
             {
-
                 //处理推送数据
                 foreach (var sendTask in tasks)
                 {
@@ -117,6 +120,9 @@ namespace DataSharing.Province.SendTask
                             }
                         }
                         _logger.LogWarning("省接口返回:" + name + "--------------" + System.Text.Json.JsonSerializer.Serialize(result));
+
+                        //写入明细表
+                        DsSendTaskDetailInfo dsSendTaskInfo = new() { TaskId = sendTask.Id, Result = System.Text.Json.JsonSerializer.Serialize(result), ResultErrorData = error };
                         if (result is not null)
                         {
                             #region 处理待同步表数据
@@ -139,14 +145,10 @@ namespace DataSharing.Province.SendTask
                             }
                             #endregion
 
+                            #region 处理推送任务表
                             var sendTaskData = await _sendTaskProvinceOtherRepository.GetAsync(p => p.Id == sendTask.Id, context.CancellationToken);
                             if (sendTaskData != null)
                             {
-                                #region 处理推送任务表,推送明细表
-
-                                //写入明细表
-                                DsSendTaskDetailInfo dsSendTaskInfo = new() { TaskId = sendTask.Id, Result = System.Text.Json.JsonSerializer.Serialize(result) };
-
                                 //处理推送时间
                                 sendTaskData.LastTime = DateTime.Now;
                                 sendTaskData.SendTimes = sendTaskData.SendTimes + 1;
@@ -160,34 +162,32 @@ namespace DataSharing.Province.SendTask
                                     dsSendTaskInfo.IsSuccess = true;
                                 }
                                 else
-                                {
-                                    dsSendTaskInfo.ResultErrorData = error;
                                     sendTaskData.IsSuccess = ESendTaskState.PushFail;
-                                }
-
-                                await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskInfo, context.CancellationToken);
+                                
                                 await _sendTaskProvinceOtherRepository.UpdateAsync(sendTaskData, context.CancellationToken);
-                                #endregion
+                                
+                            }
+                            #endregion
 
-                                #region 处理回访数据推送时间
-                                if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
+                            #region 处理回访数据推送时间
+                            if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
+                            {
+                                if (sendTask.TaskType == "SubmitVisitInfo" || sendTask.TaskType == "GetVisitInfoReceive")
                                 {
-                                    if (sendTask.TaskType == "SubmitVisitInfo" || sendTask.TaskType == "GetVisitInfoReceive")
+                                    var visitData = await _dsOrderVisitSendRepository.GetAsync(p => p.ProvinceNo == sendTaskData.ProvinceNo, context.CancellationToken);
+                                    if (visitData != null)
                                     {
-                                        var visitData = await _dsOrderVisitSendRepository.GetAsync(p => p.ProvinceNo == sendTaskData.ProvinceNo, context.CancellationToken);
-                                        if (visitData != null)
-                                        {
-                                            if (visitData.FirstSendProvinceTime is null)
-                                                visitData.FirstSendProvinceTime = DateTime.Now;
+                                        if (visitData.FirstSendProvinceTime is null)
+                                            visitData.FirstSendProvinceTime = DateTime.Now;
 
-                                            visitData.LastSendProvinceTime = DateTime.Now;
-                                            await _dsOrderVisitSendRepository.UpdateAsync(visitData, context.CancellationToken);
-                                        }
+                                        visitData.LastSendProvinceTime = DateTime.Now;
+                                        await _dsOrderVisitSendRepository.UpdateAsync(visitData, context.CancellationToken);
                                     }
                                 }
-                                #endregion
                             }
+                            #endregion
                         }
+                        await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskInfo, context.CancellationToken);
                     }
                 }
             }

+ 45 - 76
src/DataSharing/Province/SendTask/TaskSubmitCaseInfoJob.cs

@@ -114,96 +114,65 @@ namespace DataSharing.Province.SendTask
 
                     if (result != null)
                     {
-                        //这里表示有错误信息
-                        if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
+                        //处理数据
+                        foreach (var item in taskData)
                         {
-                            //遍历错误消息
-                            foreach (var item in result.Custom.ErrorObjs)
+                            //查询是否有错误
+                            //有错误处理
+                            //没有错误删除待推送表,更新主表
+                            bool isError = false;
+                            if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
                             {
-                                var tempData = taskData.Find(p => p.ProvinceNo == item.Caseserial);
-                                if (tempData != null)
-                                {
-                                    //根据返回值处理数据
-                                    tempData.LastTime = DateTime.Now;
-                                    tempData.SendTimes = tempData.SendTimes + 1;
-
-                                    if (tempData.FirstTime is null)
-                                        tempData.FirstTime = DateTime.Now;
-
-                                    if (tempData.SendTimes >= 7)
-                                        tempData.State = EWaitSendTaskState.PushFail;
-
-                                    tempData.IsSuccess = ESendTaskState.PushFail;
-
-                                    DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
-                                    {
-                                        TaskId = tempData.Id,
-                                        IsSuccess = false,
-                                        ResultErrorData = item.Errormsg,
-                                        Result = JsonSerializer.Serialize(result)
-                                    };
-                                    //新增明细
-                                    await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                                    //修改待推送表
-                                    await _waitSendTaskSubmitCaseInfoRepository.UpdateAsync(tempData, context.CancellationToken);
-                                    //修改主表
-                                    await _sendTaskSubmitCaseInfoRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseInfo>(tempData), context.CancellationToken);
-                                    //移除这一条数据
-                                    taskData.Remove(tempData);
-                                }
+                                var temp = result.Custom.ErrorObjs.Find(p => p.CaseSerial == item.ProvinceNo);
+                                if (temp != null)
+                                    isError = true;
                             }
-                        }
 
-                        //处理没有错误的消息
-                        foreach (var item in taskData)
-                        {
-                            //根据返回值处理数据
-                            item.LastTime = DateTime.Now;
-                            item.SendTimes = item.SendTimes + 1;
+                            //处理待推送数据
+                            if (isError)
+                            {
+                                //修改
+                                item.LastTime = DateTime.Now;
+                                item.SendTimes = item.SendTimes + 1;
 
-                            if (item.FirstTime is null)
-                                item.FirstTime = DateTime.Now;
+                                if (item.FirstTime is null)
+                                    item.FirstTime = DateTime.Now;
 
-                            if (item.SendTimes >= 7)
-                                item.State = EWaitSendTaskState.PushFail;
+                                if (item.SendTimes >= 7)
+                                    item.State = EWaitSendTaskState.PushFail;
 
-                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
+                                //修改待推送表
+                                await _waitSendTaskSubmitCaseInfoRepository.UpdateAsync(item, context.CancellationToken);
+                            }
+                            else
                             {
-                                TaskId = item.Id,
-                                IsSuccess = false,
-                                Result = JsonSerializer.Serialize(result.ReturnInfo),
-                                ResultErrorData = JsonSerializer.Serialize(result),
-                            };
+                                //删除
+                                await _waitSendTaskSubmitCaseInfoRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
+                            }
 
-                            if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
+                            //查询主表
+                            var sendData = await _sendTaskSubmitCaseInfoRepository.GetAsync(p => p.Id == item.Id, context.CancellationToken);
+                            if (sendData != null)
                             {
-                                item.IsSuccess = ESendTaskState.PushSuccess;
-                                dsSendTaskDetailInfo.IsSuccess = true;
+                                sendData.LastTime = DateTime.Now;
+                                sendData.SendTimes = sendData.SendTimes + 1;
+
+                                if (sendData.FirstTime is null)
+                                    sendData.FirstTime = DateTime.Now;
+
+                                sendData.IsSuccess = isError == false ? ESendTaskState.PushSuccess : ESendTaskState.PushFail;
+                                await _sendTaskSubmitCaseInfoRepository.UpdateAsync(sendData, cancellationToken: context.CancellationToken);
                             }
-                            else
-                                dsSendTaskDetailInfo.ResultErrorData = error;
 
                             //新增明细
-                            await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                            //修改推送主表
-                            await _sendTaskSubmitCaseInfoRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseInfo>(item), context.CancellationToken);
-                            //删除待推送表
-                            await _waitSendTaskSubmitCaseInfoRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
-
-                            #region 推送成功,处理工单推送表数据,用于统计
-                            if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
+                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
                             {
-                                var orderSend = await _orderSendRepository.GetAsync(p => p.ProvinceNo == item.ProvinceNo, context.CancellationToken);
-                                if (orderSend != null)
-                                {
-                                    if (orderSend.FirstSendProvinceTime is null)
-                                        orderSend.FirstSendProvinceTime = DateTime.Now;
-
-                                    orderSend.LastSendProvinceTime = DateTime.Now;
-                                    await _orderSendRepository.UpdateAsync(orderSend, context.CancellationToken);
-                                }
-                            }
-                            #endregion
+                                TaskId = item.Id,
+                                IsSuccess = false,
+                                Result = JsonSerializer.Serialize(result),
+                                ResultErrorData = error,
+                            };
+                            await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
                         }
                     }
                 }

+ 47 - 61
src/DataSharing/Province/SendTask/TaskSubmitCaseProcessJob.cs

@@ -4,6 +4,7 @@ using DataSharing.Share.Dtos.Province;
 using DataSharing.Share.Enums;
 using MapsterMapper;
 using Microsoft.Extensions.Logging;
+using Org.BouncyCastle.Ocsp;
 using Quartz;
 using System.Text.Json;
 using XF.Domain.Repository;
@@ -107,81 +108,66 @@ namespace DataSharing.Province.SendTask
                     }
                     if (result != null)
                     {
-                        //这里表示有错误信息
-                        if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
+                        //处理数据
+                        foreach (var item in taskData)
                         {
-                            //遍历错误消息
-                            foreach (var item in result.Custom.ErrorObjs)
+                            //查询是否有错误
+                            //有错误处理
+                            //没有错误删除待推送表,更新主表
+                            bool isError = false;
+                            if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
                             {
-                                var tempData = taskData.Find(p => p.ProvinceNo == item.Caseserial);
-                                if (tempData != null)
-                                {
-                                    //根据返回值处理数据
-                                    tempData.LastTime = DateTime.Now;
-                                    tempData.SendTimes = tempData.SendTimes + 1;
-
-                                    if (tempData.FirstTime is null)
-                                        tempData.FirstTime = DateTime.Now;
-
-                                    if (tempData.SendTimes >= 7)
-                                        tempData.State = EWaitSendTaskState.PushFail;
-
-                                    tempData.IsSuccess = ESendTaskState.PushFail;
-
-                                    DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
-                                    {
-                                        TaskId = tempData.Id,
-                                        IsSuccess = false,
-                                        ResultErrorData = item.Errormsg,
-                                        Result = JsonSerializer.Serialize(result)
-                                    };
-                                    //新增明细
-                                    await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                                    //修改待推送表
-                                    await _waitSendTaskSubmitCaseProcessRepository.UpdateAsync(tempData, context.CancellationToken);
-                                    //修改主表
-                                    await _sendTaskSubmitCaseProcessRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseProcess>(tempData), context.CancellationToken);
-                                    //移除这一条数据
-                                    taskData.Remove(tempData);
-                                }
+                                var temp = result.Custom.ErrorObjs.Find(p => p.CaseId == item.CaseId);
+                                if (temp != null)
+                                    isError = true;
                             }
-                        }
 
-                        //处理没有错误的消息
-                        foreach (var item in taskData)
-                        {
-                            //根据返回值处理数据
-                            item.LastTime = DateTime.Now;
-                            item.SendTimes = item.SendTimes + 1;
+                            //处理待推送数据
+                            if (isError)
+                            {
+                                //修改
+                                item.LastTime = DateTime.Now;
+                                item.SendTimes = item.SendTimes + 1;
 
-                            if (item.FirstTime is null)
-                                item.FirstTime = DateTime.Now;
+                                if (item.FirstTime is null)
+                                    item.FirstTime = DateTime.Now;
 
-                            if (item.SendTimes >= 7)
-                                item.State = EWaitSendTaskState.PushFail;
+                                if (item.SendTimes >= 7)
+                                    item.State = EWaitSendTaskState.PushFail;
 
-                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
+                                //修改待推送表
+                                await _waitSendTaskSubmitCaseProcessRepository.UpdateAsync(item, context.CancellationToken);
+                            }
+                            else
                             {
-                                TaskId = item.Id,
-                                IsSuccess = false,
-                                Result = JsonSerializer.Serialize(result.ReturnInfo),
-                                ResultErrorData = JsonSerializer.Serialize(result),
-                            };
+                                //删除
+                                await _waitSendTaskSubmitCaseProcessRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
+                            }
 
-                            if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
+                            //查询主表
+                            var sendData = await _sendTaskSubmitCaseProcessRepository.GetAsync(p => p.Id == item.Id, context.CancellationToken);
+                            if (sendData != null)
                             {
-                                item.IsSuccess = ESendTaskState.PushSuccess;
-                                dsSendTaskDetailInfo.IsSuccess = true;
+                                sendData.LastTime = DateTime.Now;
+                                sendData.SendTimes = sendData.SendTimes + 1;
+
+                                if (sendData.FirstTime is null)
+                                    sendData.FirstTime = DateTime.Now;
+
+                                sendData.IsSuccess = isError == false ? ESendTaskState.PushSuccess : ESendTaskState.PushFail;
+                                await _sendTaskSubmitCaseProcessRepository.UpdateAsync(sendData, cancellationToken: context.CancellationToken);
                             }
-                            else
-                                dsSendTaskDetailInfo.ResultErrorData = error;
 
                             //新增明细
+                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
+                            {
+                                TaskId = item.Id,
+                                IsSuccess = false,
+                                Result = JsonSerializer.Serialize(result),
+                                ResultErrorData = error,
+                            };
                             await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                            //修改推送主表
-                            await _sendTaskSubmitCaseProcessRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseProcess>(item), context.CancellationToken);
-                            //删除待推送表
-                            await _waitSendTaskSubmitCaseProcessRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
+
                         }
                     }
                 }

+ 45 - 78
src/DataSharing/Province/SendTask/TaskSubmitCaseRecordJob.cs

@@ -113,98 +113,65 @@ namespace DataSharing.Province.SendTask
                     }
                     if (result != null)
                     {
-                        //这里表示有错误信息
-                        if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
+                        //处理数据
+                        foreach (var item in taskData)
                         {
-                            //遍历错误消息
-                            foreach (var item in result.Custom.ErrorObjs)
+                            //查询是否有错误
+                            //有错误处理
+                            //没有错误删除待推送表,更新主表
+                            bool isError = false;
+                            if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
                             {
-                                var tempData = taskData.Find(p => p.ProvinceNo == item.Caseserial);
-                                if (tempData != null)
-                                {
-                                    //根据返回值处理数据
-                                    tempData.LastTime = DateTime.Now;
-                                    tempData.SendTimes = tempData.SendTimes + 1;
-
-                                    if (tempData.FirstTime is null)
-                                        tempData.FirstTime = DateTime.Now;
-
-                                    if (tempData.SendTimes >= 7)
-                                        tempData.State = EWaitSendTaskState.PushFail;
-
-                                    tempData.IsSuccess = ESendTaskState.PushFail;
-
-                                    DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
-                                    {
-                                        TaskId = tempData.Id,
-                                        IsSuccess = false,
-                                        ResultErrorData = item.Errormsg,
-                                        Result = JsonSerializer.Serialize(result)
-                                    };
-                                    //新增明细
-                                    await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                                    //修改待推送表
-                                    await _waitSendTaskSubmitCaseRecordRepository.UpdateAsync(tempData, context.CancellationToken);
-                                    //修改主表
-                                    await _sendTaskSubmitCaseRecordRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseRecord>(tempData), context.CancellationToken);
-                                    //移除这一条数据
-                                    taskData.Remove(tempData);
-                                }
+                                var temp = result.Custom.ErrorObjs.Find(p => p.CaseSerial == item.ProvinceNo);
+                                if (temp != null)
+                                    isError = true;
                             }
-                        }
 
-                        //处理没有错误的消息
-                        foreach (var item in taskData)
-                        {
-                            //根据返回值处理数据
-                            item.LastTime = DateTime.Now;
-                            item.SendTimes = item.SendTimes + 1;
+                            //处理待推送数据
+                            if (isError)
+                            {
+                                //修改
+                                item.LastTime = DateTime.Now;
+                                item.SendTimes = item.SendTimes + 1;
 
-                            if (item.FirstTime is null)
-                                item.FirstTime = DateTime.Now;
+                                if (item.FirstTime is null)
+                                    item.FirstTime = DateTime.Now;
 
-                            if (item.SendTimes >= 7)
-                                item.State = EWaitSendTaskState.PushFail;
+                                if (item.SendTimes >= 7)
+                                    item.State = EWaitSendTaskState.PushFail;
 
-                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
-                            {
-                                TaskId = item.Id,
-                                IsSuccess = false,
-                                Result = JsonSerializer.Serialize(result.ReturnInfo),
-                                ResultErrorData = JsonSerializer.Serialize(result),
-                            };
-
-                            if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
-                            {
-                                item.IsSuccess = ESendTaskState.PushSuccess;
-                                dsSendTaskDetailInfo.IsSuccess = true;
+                                //修改待推送表
+                                await _waitSendTaskSubmitCaseRecordRepository.UpdateAsync(item, context.CancellationToken);
                             }
                             else
-                                dsSendTaskDetailInfo.ResultErrorData = error;
-
-                            //新增明细
-                            await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                            //修改推送主表
-                            await _sendTaskSubmitCaseRecordRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseRecord>(item), context.CancellationToken);
-                            //删除待推送表
-                            await _waitSendTaskSubmitCaseRecordRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
-
-                            #region 处理通话记录推送时间
-                            if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
                             {
+                                //删除
+                                await _waitSendTaskSubmitCaseRecordRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
+                            }
 
-                                var telCall = await _dsTelCallRepository.GetAsync(p => p.TaskId == item.Id, context.CancellationToken);
-                                if (telCall != null)
-                                {
-                                    if (telCall.FirstSendProvinceTime is null)
-                                        telCall.FirstSendProvinceTime = DateTime.Now;
+                            //查询主表
+                            var sendData = await _sendTaskSubmitCaseRecordRepository.GetAsync(p => p.Id == item.Id, context.CancellationToken);
+                            if (sendData != null)
+                            {
+                                sendData.LastTime = DateTime.Now;
+                                sendData.SendTimes = sendData.SendTimes + 1;
 
-                                    telCall.LastSendProvinceTime = DateTime.Now;
-                                    await _dsTelCallRepository.UpdateAsync(telCall, context.CancellationToken);
-                                }
+                                if (sendData.FirstTime is null)
+                                    sendData.FirstTime = DateTime.Now;
 
+                                sendData.IsSuccess = isError == false ? ESendTaskState.PushSuccess : ESendTaskState.PushFail;
+                                await _sendTaskSubmitCaseRecordRepository.UpdateAsync(sendData, cancellationToken: context.CancellationToken);
                             }
-                            #endregion
+
+                            //新增明细
+                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
+                            {
+                                TaskId = item.Id,
+                                IsSuccess = false,
+                                Result = JsonSerializer.Serialize(result),
+                                ResultErrorData = error,
+                            };
+                            await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
                         }
                     }
                 }

+ 45 - 62
src/DataSharing/Province/SendTask/TaskSubmitCaseResultJob.cs

@@ -109,84 +109,67 @@ namespace DataSharing.Province.SendTask
 
                     if (result != null)
                     {
-                        //这里表示有错误信息
-                        if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
+                        //处理数据
+                        foreach (var item in taskData)
                         {
-                            //遍历错误消息
-                            foreach (var item in result.Custom.ErrorObjs)
+                            //查询是否有错误
+                            //有错误处理
+                            //没有错误删除待推送表,更新主表
+                            bool isError = false;
+                            if (result.Custom.ErrorObjs != null && result.Custom.ErrorObjs.Count > 0)
                             {
-                                var tempData = taskData.Find(p => p.ProvinceNo == item.Caseserial);
-                                if (tempData != null)
-                                {
-                                    //根据返回值处理数据
-                                    tempData.LastTime = DateTime.Now;
-                                    tempData.SendTimes = tempData.SendTimes + 1;
-
-                                    if (tempData.FirstTime is null)
-                                        tempData.FirstTime = DateTime.Now;
-
-                                    if (tempData.SendTimes >= 7)
-                                        tempData.State = EWaitSendTaskState.PushFail;
-
-                                    tempData.IsSuccess = ESendTaskState.PushFail;
-
-                                    DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
-                                    {
-                                        TaskId = tempData.Id,
-                                        IsSuccess = false,
-                                        ResultErrorData = item.Errormsg,
-                                        Result = JsonSerializer.Serialize(result)
-                                    };
-                                    //新增明细
-                                    await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                                    //修改待推送表
-                                    await _waitSendTaskSubmitCaseResultRepository.UpdateAsync(tempData, context.CancellationToken);
-                                    //修改主表
-                                    await _sendTaskSubmitCaseResultRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseResult>(tempData), context.CancellationToken);
-                                    //移除这一条数据
-                                    taskData.Remove(tempData);
-                                }
+                                var temp = result.Custom.ErrorObjs.Find(p => p.CaseSerial == item.ProvinceNo);
+                                if (temp != null)
+                                    isError = true;
                             }
-                        }
 
-                        //处理没有错误的消息
-                        foreach (var item in taskData)
-                        {
-                            //根据返回值处理数据
-                            item.LastTime = DateTime.Now;
-                            item.SendTimes = item.SendTimes + 1;
+                            //处理待推送数据
+                            if (isError)
+                            {
+                                //修改
+                                item.LastTime = DateTime.Now;
+                                item.SendTimes = item.SendTimes + 1;
 
-                            if (item.FirstTime is null)
-                                item.FirstTime = DateTime.Now;
+                                if (item.FirstTime is null)
+                                    item.FirstTime = DateTime.Now;
 
-                            if (item.SendTimes >= 7)
-                                item.State = EWaitSendTaskState.PushFail;
+                                if (item.SendTimes >= 7)
+                                    item.State = EWaitSendTaskState.PushFail;
 
-                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
+                                //修改待推送表
+                                await _waitSendTaskSubmitCaseResultRepository.UpdateAsync(item, context.CancellationToken);
+                            }
+                            else
                             {
-                                TaskId = item.Id,
-                                IsSuccess = false,
-                                Result = JsonSerializer.Serialize(result.ReturnInfo),
-                                ResultErrorData = JsonSerializer.Serialize(result),
-                            };
+                                //删除
+                                await _waitSendTaskSubmitCaseResultRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
+                            }
 
-                            if (result.ReturnInfo is not null && result.ReturnInfo.Code == "1")
+                            //查询主表
+                            var sendData = await _sendTaskSubmitCaseResultRepository.GetAsync(p => p.Id == item.Id, context.CancellationToken);
+                            if (sendData != null)
                             {
-                                item.IsSuccess = ESendTaskState.PushSuccess;
-                                dsSendTaskDetailInfo.IsSuccess = true;
+                                sendData.LastTime = DateTime.Now;
+                                sendData.SendTimes = sendData.SendTimes + 1;
+
+                                if (sendData.FirstTime is null)
+                                    sendData.FirstTime = DateTime.Now;
+
+                                sendData.IsSuccess = isError == false ? ESendTaskState.PushSuccess : ESendTaskState.PushFail;
+                                await _sendTaskSubmitCaseResultRepository.UpdateAsync(sendData, cancellationToken: context.CancellationToken);
                             }
-                            else
-                                dsSendTaskDetailInfo.ResultErrorData = error;
 
                             //新增明细
+                            DsSendTaskDetailInfo dsSendTaskDetailInfo = new()
+                            {
+                                TaskId = item.Id,
+                                IsSuccess = false,
+                                Result = JsonSerializer.Serialize(result),
+                                ResultErrorData = error,
+                            };
                             await _sendTaskDetailInfoRepository.AddAsync(dsSendTaskDetailInfo, context.CancellationToken);
-                            //修改推送主表
-                            await _sendTaskSubmitCaseResultRepository.UpdateAsync(_mapper.Map<DsSendTaskSubmitCaseResult>(item), context.CancellationToken);
-                            //删除待推送表
-                            await _waitSendTaskSubmitCaseResultRepository.RemoveAsync(item, cancellationToken: context.CancellationToken);
                         }
                     }
-
                 }
             }
         }

+ 2 - 1
src/DataSharing/SendTask/InitPushDataService.cs

@@ -135,7 +135,8 @@ namespace DataSharing.SendTask
                 Request = request,
                 RequestData = requestData,
                 GenerationTime = generationTime,
-                PathType = EPathType.HuiJu
+                PathType = EPathType.HuiJu,
+                CaseId= requestData.CaseId
             };
             waitTask.Id = await _waitSendTaskSubmitCaseProcessRepository.AddAsync(waitTask, cancellationToken);