|
|
|
|
using log4net;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Quartz;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace JobCreateFee
|
|
|
|
|
{
|
|
|
|
|
public class JobYtD6Fee : IJob
|
|
|
|
|
{
|
|
|
|
|
private ILog log = LogManager.GetLogger(typeof(JobYtD6Fee));
|
|
|
|
|
//private const string CfgFileName = "starttime.cfg";
|
|
|
|
|
//private static string CfgFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CfgFileName);
|
|
|
|
|
|
|
|
|
|
public void Execute(IJobExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
log.Debug($"Execute开始");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
|
|
|
|
|
string reqUrl = context.JobDetail.JobDataMap.GetString("YTReqUrl");
|
|
|
|
|
string YTUserName = context.JobDetail.JobDataMap.GetString("YTUserName");
|
|
|
|
|
string YTPassWord = context.JobDetail.JobDataMap.GetString("YTPassWord");
|
|
|
|
|
string CustName = context.JobDetail.JobDataMap.GetString("CustName");
|
|
|
|
|
string CustPsw = context.JobDetail.JobDataMap.GetString("CustPsw");
|
|
|
|
|
int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
|
|
|
|
|
|
|
|
|
|
var yesterday = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
|
|
|
|
|
JsonYtSend reqObj = new JsonYtSend();
|
|
|
|
|
reqObj.custname = CustName;
|
|
|
|
|
reqObj.custpsw= CustPsw;
|
|
|
|
|
reqObj.username = YTUserName;
|
|
|
|
|
reqObj.password = YTPassWord;
|
|
|
|
|
reqObj.start_time = yesterday;
|
|
|
|
|
reqObj.end_time= yesterday;
|
|
|
|
|
|
|
|
|
|
var sendstr = JsonConvert.SerializeObject(reqObj);
|
|
|
|
|
log.Debug($"发送包:{sendstr}");
|
|
|
|
|
|
|
|
|
|
//发送请求数据
|
|
|
|
|
string rtn = WebRequestHelper.DoPost(reqUrl, sendstr, reqTimeout * 1000);
|
|
|
|
|
log.Debug($"数据返回:{rtn}");
|
|
|
|
|
var objRtn = JsonConvert.DeserializeAnonymousType(rtn, new { status = "", message = "" });
|
|
|
|
|
|
|
|
|
|
if (objRtn.status == "1")
|
|
|
|
|
{
|
|
|
|
|
var parseJsonObj = JsonConvert.DeserializeObject<List<JsonYtFee>>(objRtn.message);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (SqlConnection dbcon = new SqlConnection(connStr))
|
|
|
|
|
{
|
|
|
|
|
dbcon.Open();
|
|
|
|
|
foreach (var returndata in parseJsonObj)
|
|
|
|
|
{
|
|
|
|
|
if (returndata.fee == "" || returndata.fee == null) returndata.fee = "0";
|
|
|
|
|
if (returndata.ydFee == "" || returndata.ydFee == null) returndata.ydFee = "0";
|
|
|
|
|
if (returndata.secondPrintFee == "" || returndata.secondPrintFee == null) returndata.secondPrintFee = "0";
|
|
|
|
|
var D6BS = GETD6BS(returndata.bookingno, dbcon);
|
|
|
|
|
|
|
|
|
|
string sql = " INSERT INTO t_op_ytfee_log([bsno],[vessel],[voyage],[bookingno],[ctn_type],[ctn_no],[yard],[operatetime],[operatetype]";
|
|
|
|
|
sql = sql + ",[printType],[fee],[ydFee],[secondPrintFee],[applicant_code]) values ('" + D6BS.BSNO + "','" + returndata.vessel + "'";
|
|
|
|
|
sql = sql + ",'" + returndata.voyage + "','" + returndata.bookingno + "','" + returndata.ctn_type + "','" + returndata.ctn_no + "','" + returndata.yard + "'";
|
|
|
|
|
sql = sql + "," + returndata.operatetime + ",'" + returndata.operatetype + "'," + returndata.printType + ",'" + returndata.fee
|
|
|
|
|
+ "','" + returndata.ydFee + "','" + returndata.secondPrintFee + "','" + returndata.applicant_code + "')";
|
|
|
|
|
SqlCommand cmd = new SqlCommand(sql, dbcon);
|
|
|
|
|
cmd.ExecuteNonQuery();
|
|
|
|
|
if (!string.IsNullOrEmpty(D6BS.BSNO)) {
|
|
|
|
|
if (Convert.ToDecimal(returndata.fee) != 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string Feesql = "INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
|
|
|
|
|
Feesql = Feesql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
|
|
|
|
|
Feesql = Feesql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
|
|
|
|
|
Feesql = Feesql + ",[机密],[是否垫付],[申请金额],[不开发票],[费用英文名称]";
|
|
|
|
|
Feesql = Feesql + ",[申请开票],[提交],[不含税价],[税率],[税额],PROJECTFEEID) VALUES ";
|
|
|
|
|
Feesql = Feesql + "('收','审核通过','" + D6BS.BSNO + "','提箱小票费','委托单位','" + D6BS.CUSTOMERNAME + "','单票'";
|
|
|
|
|
Feesql = Feesql + ",5,1,5,'RMB',1,'',0,0";
|
|
|
|
|
Feesql = Feesql + ",'DEMO-SA',GETDATE(),0,100,0";
|
|
|
|
|
Feesql = Feesql + ",0,0,0,0,''";
|
|
|
|
|
Feesql = Feesql + ",0,0,5,0,0,'易通小票费')";
|
|
|
|
|
Feesql = Feesql + " INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
|
|
|
|
|
Feesql = Feesql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
|
|
|
|
|
Feesql = Feesql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
|
|
|
|
|
Feesql = Feesql + ",[机密],[是否垫付],[申请金额],[不开发票],[费用英文名称]";
|
|
|
|
|
Feesql = Feesql + ",[申请开票],[提交],[不含税价],[税率],[税额],PROJECTFEEID) VALUES ";
|
|
|
|
|
Feesql = Feesql + "('付','审核通过','" + D6BS.BSNO + "','提箱小票费','代理','亿通(付费)','单票'";
|
|
|
|
|
Feesql = Feesql + ","+ returndata.fee + ",1,"+ returndata.fee + ",'RMB',1,'',0,0";
|
|
|
|
|
Feesql = Feesql + ",'DEMO-SA',GETDATE(),0,100,0";
|
|
|
|
|
Feesql = Feesql + ",0,0,0,0,''";
|
|
|
|
|
Feesql = Feesql + ",0,0,"+ returndata.fee + ",0,0,'易通小票费')";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Debug($"费用语句-{Feesql}");
|
|
|
|
|
dbcon.Open();
|
|
|
|
|
SqlCommand Feecmd = new SqlCommand(Feesql, dbcon);
|
|
|
|
|
Feecmd.ExecuteNonQuery();
|
|
|
|
|
dbcon.Close();
|
|
|
|
|
}
|
|
|
|
|
if (Convert.ToDecimal(returndata.ydFee) != 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string Feesql = "INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
|
|
|
|
|
Feesql = Feesql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
|
|
|
|
|
Feesql = Feesql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
|
|
|
|
|
Feesql = Feesql + ",[机密],[是否垫付],[申请金额],[不开发票],[费用英文名称]";
|
|
|
|
|
Feesql = Feesql + ",[申请开票],[提交],[不含税价],[税率],[税额],PROJECTFEEID) VALUES ";
|
|
|
|
|
Feesql = Feesql + "('收','审核通过','" + D6BS.BSNO + "','提箱小票费','委托单位','" + D6BS.CUSTOMERNAME + "','单票'";
|
|
|
|
|
Feesql = Feesql + "," + returndata.ydFee + ",1," + returndata.ydFee + ",'RMB',1,'',0,0";
|
|
|
|
|
Feesql = Feesql + ",'DEMO-SA',GETDATE(),0,100,0";
|
|
|
|
|
Feesql = Feesql + ",0,0,0,0,''";
|
|
|
|
|
Feesql = Feesql + ",0,0," + returndata.ydFee + ",0,0,'易通小票费')";
|
|
|
|
|
Feesql = Feesql + " INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
|
|
|
|
|
Feesql = Feesql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
|
|
|
|
|
Feesql = Feesql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
|
|
|
|
|
Feesql = Feesql + ",[机密],[是否垫付],[申请金额],[不开发票],[费用英文名称]";
|
|
|
|
|
Feesql = Feesql + ",[申请开票],[提交],[不含税价],[税率],[税额],PROJECTFEEID) VALUES ";
|
|
|
|
|
Feesql = Feesql + "('付','审核通过','" + D6BS.BSNO + "','提箱小票费','代理','C亿通(付费)','单票'";
|
|
|
|
|
Feesql = Feesql + "," + returndata.ydFee + ",1," + returndata.ydFee + ",'RMB',1,'',0,0";
|
|
|
|
|
Feesql = Feesql + ",'DEMO-SA',GETDATE(),0,100,0";
|
|
|
|
|
Feesql = Feesql + ",0,0,0,0,''";
|
|
|
|
|
Feesql = Feesql + ",0,0," + returndata.ydFee + ",0,0,'易通小票费')";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Debug($"费用语句-{Feesql}");
|
|
|
|
|
dbcon.Open();
|
|
|
|
|
SqlCommand Feecmd = new SqlCommand(Feesql, dbcon);
|
|
|
|
|
Feecmd.ExecuteNonQuery();
|
|
|
|
|
dbcon.Close();
|
|
|
|
|
}
|
|
|
|
|
if (Convert.ToDecimal(returndata.secondPrintFee) != 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string Feesql = "INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
|
|
|
|
|
Feesql = Feesql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
|
|
|
|
|
Feesql = Feesql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
|
|
|
|
|
Feesql = Feesql + ",[机密],[是否垫付],[申请金额],[不开发票],[费用英文名称]";
|
|
|
|
|
Feesql = Feesql + ",[申请开票],[提交],[不含税价],[税率],[税额],PROJECTFEEID) VALUES ";
|
|
|
|
|
Feesql = Feesql + "('收','审核通过','" + D6BS.BSNO + "','调箱费','委托单位','" + D6BS.CUSTOMERNAME + "','单票'";
|
|
|
|
|
Feesql = Feesql + "," + returndata.secondPrintFee + ",1," + returndata.secondPrintFee + ",'RMB',1,'',0,0";
|
|
|
|
|
Feesql = Feesql + ",'DEMO-SA',GETDATE(),0,100,0";
|
|
|
|
|
Feesql = Feesql + ",0,0,0,0,''";
|
|
|
|
|
Feesql = Feesql + ",0,0," + returndata.secondPrintFee + ",0,0,'易通小票费')";
|
|
|
|
|
Feesql = Feesql + " INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
|
|
|
|
|
Feesql = Feesql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
|
|
|
|
|
Feesql = Feesql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
|
|
|
|
|
Feesql = Feesql + ",[机密],[是否垫付],[申请金额],[不开发票],[费用英文名称]";
|
|
|
|
|
Feesql = Feesql + ",[申请开票],[提交],[不含税价],[税率],[税额],PROJECTFEEID) VALUES ";
|
|
|
|
|
Feesql = Feesql + "('付','审核通过','" + D6BS.BSNO + "','调箱费','代理','C亿通(付费)','单票'";
|
|
|
|
|
Feesql = Feesql + "," + returndata.secondPrintFee + ",1," + returndata.secondPrintFee + ",'RMB',1,'',0,0";
|
|
|
|
|
Feesql = Feesql + ",'DEMO-SA',GETDATE(),0,100,0";
|
|
|
|
|
Feesql = Feesql + ",0,0,0,0,''";
|
|
|
|
|
Feesql = Feesql + ",0,0," + returndata.secondPrintFee + ",0,0,'易通小票费')";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Debug($"费用语句-{Feesql}");
|
|
|
|
|
dbcon.Open();
|
|
|
|
|
SqlCommand Feecmd = new SqlCommand(Feesql, dbcon);
|
|
|
|
|
Feecmd.ExecuteNonQuery();
|
|
|
|
|
dbcon.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var headstr = "";
|
|
|
|
|
if (returndata.bookingno.Length > 3)
|
|
|
|
|
{
|
|
|
|
|
headstr = returndata.bookingno.Substring(0, 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(D6BS.BSNO) && (headstr == "QGD" || headstr == "AMQ" || headstr == "AMG" || headstr == "AYQ"))
|
|
|
|
|
{
|
|
|
|
|
SaveMail(dbcon, "CMABKG@SDSMARTLOGISTICS.COM", returndata.bookingno + "此单号已退仓,但是系统检测到打印过小票" + returndata.printType + ",请知悉,谢谢", returndata.bookingno + "此单号已退仓,但是系统检测到打印过小票" + returndata.printType + ",请知悉,谢谢", "1");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
dbcon.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
log.Debug($"记录插入错误:{e.Message}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
log.Debug($"数据返回错误:{objRtn.message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error(ex.Message);
|
|
|
|
|
log.Error(ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int SaveMail(SqlConnection dbcon, string sendto, string title, string body, string smtpid)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var sqlstr = $" INSERT INTO [Mail_Send] ([GID],[SendTo],[Title],[Body],[SendStatus],[TryCount],[CreateTime],[SmtpConfig],[Sender],[ShowName]) select newid(),'{sendto}','{title}','{body.Replace("'", "''")}','Create',0,GETDATE(),'{smtpid}','','' ";
|
|
|
|
|
SqlCommand cmd = new SqlCommand(sqlstr, dbcon);
|
|
|
|
|
return cmd.ExecuteNonQuery();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
static public D6BS GETD6BS(string MBLNO, SqlConnection dbcon)
|
|
|
|
|
{
|
|
|
|
|
var newbs = new D6BS();
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT TOP 1 编号 BSNO,委托单位 CUSTOMERNAME from t_op_seae where 主提单号='" + MBLNO + "'");
|
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
|
|
|
|
|
DataTable table = new DataTable();
|
|
|
|
|
adapter.Fill(table);
|
|
|
|
|
var BSNO = "";
|
|
|
|
|
if (table.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow row in table.Rows)
|
|
|
|
|
{
|
|
|
|
|
newbs.BSNO = row["BSNO"].ToString();
|
|
|
|
|
newbs.CUSTOMERNAME = row["CUSTOMERNAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return newbs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class JsonYtSend
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public string custname { get; set; }
|
|
|
|
|
public string custpsw { get; set; }
|
|
|
|
|
public string username { get; set; }
|
|
|
|
|
public string password { get; set; }
|
|
|
|
|
public string start_time { get; set; }
|
|
|
|
|
public string end_time { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class JsonYtFee
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public string vessel { get; set; }
|
|
|
|
|
public string voyage { get; set; }
|
|
|
|
|
public string bookingno { get; set; }
|
|
|
|
|
public string ctn_type { get; set; }
|
|
|
|
|
public string ctn_no { get; set; }
|
|
|
|
|
public string yard { get; set; }
|
|
|
|
|
public string trans_port_code { get; set; }
|
|
|
|
|
public string operatetime { get; set; }
|
|
|
|
|
|
|
|
|
|
public string operatetype { get; set; }
|
|
|
|
|
public string printType { get; set; }
|
|
|
|
|
public string fee { get; set; }
|
|
|
|
|
public string ydFee { get; set; }
|
|
|
|
|
public string secondPrintFee { get; set; }
|
|
|
|
|
public string applicant_code { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class D6BS
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public string BSNO { get; set; }
|
|
|
|
|
public string CUSTOMERNAME { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|