You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb.Service.Output/JobFanWeiToDS7.cs

142 lines
5.1 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DSWeb.Common;
using DSWeb.Common.DB;
using DSWeb.Common.Helper;
using log4net;
using log4net.Repository.Hierarchy;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Quartz;
using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Runtime.Caching;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;
namespace DSWeb.Service.Output
{
//配置了舱单数据输出到ds7的公司自动将舱单数据发送到消息队列
public class JobFanWeiToDS7 : IJob
{
//private const string ExchangeName = "output";
//private const string QueuePrefix = "djy.output.cangdan.ds7.";
private ILog log = LogManager.GetLogger(typeof(JobFanWeiToDS7));
//private string rabbitUri = ConfigurationManager.AppSettings["OutputDS7MQUri"];
string OAconnStr = ConfigurationManager.AppSettings["OAconnStr"];
string DS7connStr = ConfigurationManager.AppSettings["DS7connStr"];
string DS7URL = ConfigurationManager.AppSettings["DS7URL"];
public void Execute(IJobExecutionContext context)
{
//int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
try
{
log.Debug("Execute start");
//int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
var dc1 = new OtherDB(OAconnStr);
var cdc = new CommonDataContext(DS7connStr);
//从cdc中寻找待读取审核结果的业务
var List = cdc.ch_fee_payapplication.Where(x => x.BILLSTATUS == 2 && x.PAYAPPID != null && x.PAYAPPID != "").ToList();
if (List == null || List.Count <= 0) return;
var idList = List.Select(s => s.PAYAPPID).ToList();
log.Info(idList.ToList());
//从dc1中寻找这些id的业务的审核结果
var List = dc1.view_pjrequestbas.Where(x => x.workflowid == 79 && x.currentnodetype == "3" && idList.Contains(x.requestid.ToString())).ToList();
//var AuditGidlistStr = "";
foreach (var item in List)
{
SetAudit(dc1, cdc, DS7URL, item);
}
//将审核完成的更新至cdc中的业务中
//update ch_fee_payapplication set BILLSTATUS=0,AUDITUSER='" + USERID + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where BILLNO=@BILLNO");
log.Debug("Execute end");
}
catch (Exception ex)
{
log.Debug($"catch{ex.Message}");
log.Error(ex.Message);
log.Error(ex.StackTrace);
}
}
public void DoWork()
{
var dc1 = new OtherDB(OAconnStr);
var cdc = new CommonDataContext(DS7connStr);
//从cdc中寻找待读取审核结果的业务
var List = cdc.ch_fee_payapplication.Where(x => x.BILLSTATUS == 2 && x.PAYAPPID != null && x.PAYAPPID != "").ToList();
if (List == null || List.Count <= 0) return;
var idList = List.Select(s => s.PAYAPPID).ToList();
log.Debug(idList.ToList());
//从dc1中寻找这些id的业务的审核结果
var List = dc1.view_pjrequestbas.Where(x => x.workflowid == 79 && x.currentnodetype == "3" && idList.Contains(x.requestid.ToString())).ToList();
//var AuditGidlistStr = "";
foreach (var item in List)
{
SetAudit(dc1, cdc, DS7URL, item);
}
}
private void SetAudit(OtherDB dc1, CommonDataContext cdc, string DS7URL, view_pjrequestbas_md Audititem)
{
try
{
//根据oa系统的userid查找ds7系统的userid
log.Debug("audit start");
var OAUser = dc1.view_hrmresource.FirstOrDefault(x => x.id == Audititem.lastoperator);
var ds7user = cdc.VW_user.Where(x => x.SHOWNAME.Replace(" ","") == OAUser.lastname).ToList();
//var ds7user = cdc.VW_user.Where(x => x.SHOWNAME == "系统管理员").ToList();
if (ds7user != null && ds7user.Count > 0)
{
var userid = ds7user[0].USERID;
var dic = new Dictionary<string, string> {
{ "requestid",Audititem.requestid.ToString()},
{ "userid",userid}
};
string rtn = WebRequestHelper.DoPost(DS7URL, dic, 12000);
log.Debug("rtn=" + rtn);
}
log.Debug("audit end");
}
catch (Exception e) {
log.Error(e.Message);
}
}
}
}