You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.5 KiB
93 lines
3.5 KiB
2 years ago
|
using Elight.Utility.logs;
|
||
|
using Elight.Utility;
|
||
|
using Newtonsoft.Json;
|
||
|
using Quartz;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
using Elight.Entity;
|
||
|
using Microsoft.Extensions.Logging;
|
||
|
using SqlSugar;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using java.sql;
|
||
|
using org.omg.PortableServer;
|
||
|
using System.Runtime.Intrinsics.X86;
|
||
|
using Microsoft.OpenApi.Validations;
|
||
|
using static com.sun.tools.@internal.xjc.reader.xmlschema.bindinfo.BIConversion;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
|
||
|
namespace Elight.Logic.Job
|
||
|
{
|
||
|
[DisallowConcurrentExecution]
|
||
|
public class WsJob : IJob
|
||
|
{
|
||
|
private readonly SqlSugarClient _db;//数据库
|
||
|
public WsJob(IConfiguration configuration)
|
||
|
{
|
||
|
var connectionString = configuration.GetSection("ConnectionStrings:MySQLConnString").Value;
|
||
|
_db = new SqlSugarClient(new ConnectionConfig
|
||
|
{
|
||
|
ConnectionString = connectionString,
|
||
|
DbType = SqlSugar.DbType.MySql,
|
||
|
IsAutoCloseConnection = true,
|
||
|
InitKeyType = InitKeyType.Attribute
|
||
|
});
|
||
|
}
|
||
|
public async Task Execute(IJobExecutionContext context)
|
||
|
{
|
||
|
Console.WriteLine("定时任务执行中...");
|
||
|
Console.WriteLine("定时任务执行中...");
|
||
|
JobDataMap datas = context.JobDetail.JobDataMap;
|
||
|
// 定时任务执行的代码
|
||
|
Console.WriteLine("定时任务执行中...");
|
||
|
var daa = new { data = "{\"token\":\"www.archives.net.cn\",\"dwbm\":\"640000\",\"zt\":\"03\"}" };
|
||
|
var msg = "";
|
||
|
var data = HttpHelper.Post("http://jhg.ahjiguang.cn:80/agyw/api/user/command/wssdapi/getwssdlist", daa, out msg);
|
||
|
var Results = JsonConvert.DeserializeObject<RequestResults>(data);
|
||
|
var Documentlist = JsonConvert.DeserializeObject<List<App_DocumentModel>>(Results.data);
|
||
|
if (Documentlist.Count() > 0)
|
||
|
{
|
||
|
//await AddDocument(Documentlist);
|
||
|
_db.Dispose();
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(msg))
|
||
|
Console.WriteLine($"文书签收错误...{msg}");
|
||
|
//LogService.WriteLog(msg, "文书签收");
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 添加文书签收
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns></returns>
|
||
|
public async Task AddDocument(List<App_DocumentModel> Documentdata)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
//获取app平台所有用户身份证
|
||
|
var usercardIds = _db.Queryable<App_Sys_UserModel>().Where(q => q.IsDeleted == 0 && q.usertype == 1).Select(q => q.cardId).ToList();
|
||
|
//获取app平台所有用户身份证
|
||
|
//var usercardIds = _db.Queryable<App_DocumentModel>().OrderByDescending(q=>q.i).ToList();
|
||
|
Documentdata = Documentdata.Where(q => usercardIds.Contains(q.zjhm)).ToList();
|
||
|
_db.BeginTran();
|
||
|
Documentdata.ForEach(q =>
|
||
|
{
|
||
|
q.Id = Guid.NewGuid().ToString();
|
||
|
});
|
||
|
//Documentdata.Id = Guid.NewGuid().ToString();
|
||
|
var num = await _db.Insertable(Documentdata).ExecuteCommandAsync();
|
||
|
_db.CommitTran();
|
||
|
}
|
||
|
catch (System.Exception ex)
|
||
|
{
|
||
|
_db.RollbackTran();
|
||
|
LogService.WriteLog(ex, "添加文书签收");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|