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/JobAutoCreateFee/JobHCCreateFee.cs

666 lines
34 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 log4net;
using Newtonsoft.Json;
using Quartz;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using JobAutoCreateFee.Model;
namespace JobCreateFee
{
public class JobHCCreateFee : IJob
{
private ILog log = LogManager.GetLogger(typeof(JobHCCreateFee));
public void Execute(IJobExecutionContext context)
{
string connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
string querySql = context.JobDetail.JobDataMap.GetString("QuerySql");
string UseEdt = context.JobDetail.JobDataMap.GetString("UseEdt");
using (SqlConnection dbcon = new SqlConnection(connStr))
{
var clientlist = CreateClientList(dbcon);
var strSql = new StringBuilder();
strSql.Append("select * from t_ch_project_new WITH (NOLOCK) where 方案状态='审核通过' AND 结束日期>=GETDATE() order by 方案名称 ");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = strSql.ToString();
cmd.CommandTimeout = 120000; //要加这一句
cmd.Connection = dbcon;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
var feeprojectlist = CreateFeeProjectList(table);
if (feeprojectlist != null)
{
foreach (var enumFeeproject in feeprojectlist)
{
log.Debug($"开始费用方案:{enumFeeproject.FADESCRIP}--{DateTime.Now.ToString()}");
var bsstr = CreateSql(enumFeeproject.FA_ID, dbcon);
var strSqlBs = new StringBuilder();
strSqlBs.Clear();
if (UseEdt == "1")
{
strSqlBs.Append("select B.编号,B.方案名称,B.主提单号,B.委托单位,B.船公司,B.货代公司,B.报关行,B.船代,B.场站,B.代理,B.发货人,B.收货人,B.通知人,B.第三方付费,B.其他相关公司,B.承运车队,B.开船日期 预抵日期 ");
strSqlBs.Append(",B.操作员,B.销售部门 from t_op_seae B WITH (NOLOCK) where ISNULL(B.是否占舱,'')<>'Y' And B.开船日期>='" + enumFeeproject.ETDFR + "' and B.开船日期<'" + enumFeeproject.ETDTO + "' ");
}
else {
strSqlBs.Append("select B.编号,B.方案名称,B.主提单号,B.委托单位,B.船公司,B.货代公司,B.报关行,B.船代,B.场站,B.代理,B.发货人,B.收货人,B.通知人,B.第三方付费,B.其他相关公司,B.承运车队,B.预抵日期 ");
strSqlBs.Append(",B.操作员,B.销售部门 from t_op_seae B WITH (NOLOCK) where ISNULL(B.是否占舱,'')<>'Y' And B.预抵日期>='" + enumFeeproject.ETDFR + "' and B.预抵日期<'" + enumFeeproject.ETDTO + "' ");
}
if (querySql != "")
strSqlBs.Append(querySql);
strSqlBs.Append(bsstr);
log.Debug($"费用方案语句:{strSqlBs.ToString()}");
SqlCommand cmdBS = new SqlCommand();
cmdBS.CommandText = strSqlBs.ToString();
cmdBS.CommandTimeout = 120000; //要加这一句
cmdBS.Connection = dbcon;
SqlDataAdapter bsadapter = new SqlDataAdapter(cmdBS);
DataTable bstable = new DataTable();
bsadapter.Fill(bstable);
dbcon.Close();
if (bstable.Rows.Count > 0)
{
var OpSeaeList = CreateOpSeaList(bstable);
var FeeTemplateDetailList = GetFeeTemplate(enumFeeproject.FA_ID, dbcon);
try
{
insertFee(OpSeaeList, FeeTemplateDetailList,enumFeeproject, clientlist,dbcon);
}
catch (Exception e)
{
log.Debug($"{enumFeeproject.FADESCRIP + " " + enumFeeproject.PROJECTTYPE}生成费用错误:{e.Message}");
}
}
}
}
}
}
}
static public List<MsOpSeae> CreateOpSeaList(DataTable table)
{
var headList = new List<MsOpSeae>();
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
MsOpSeae data = new MsOpSeae();
data.BSNO = row["编号"].ToString();
data.MBLNO= row["主提单号"].ToString();
data.CUSTOMERNAME = row["委托单位"].ToString();
data.CARRIER = row["船公司"].ToString();
data.FORWARDER = row["货代公司"].ToString();
data.CUSTOMSER = row["报关行"].ToString();
data.CUSTSERVICE = row["船代"].ToString();
data.YARD = row["场站"].ToString();
data.TRUCKER = row["承运车队"].ToString();
data.AGENTID = row["代理"].ToString();
data.SHIPPERID = row["发货人"].ToString();
data.CONSIGNEEID = row["收货人"].ToString();
data.NOTIFYPARTYID = row["通知人"].ToString();
data.THIRDPARTY = row["第三方付费"].ToString();
data.OTHERPARTY = row["其他相关公司"].ToString();
data.OP = row["操作员"].ToString();
data.SALEDEPT= row["销售部门"].ToString();
data.DLFA = row["方案名称"].ToString();
if (row["预抵日期"] != DBNull.Value)
data.ETD = Convert.ToDateTime(row["预抵日期"].ToString()).ToString("yyyy-MM-dd");
headList.Add(data);
}
}
return headList;
}
static public List<MsFeeProject> CreateFeeProjectList(DataTable table)
{
var headList = new List<MsFeeProject>();
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
MsFeeProject data = new MsFeeProject();
data.FA_ID = row["方案代码"].ToString();
data.FADESCRIP = row["方案名称"].ToString();
// data.PROJECTTYPE = row["费用类型"].ToString();
if (row["开船日期起"] != DBNull.Value)
data.ETDFR = Convert.ToDateTime(row["开船日期起"].ToString()).ToString("yyyy-MM-dd");
if (row["开船日期止"] != DBNull.Value)
data.ETDTO = Convert.ToDateTime(row["开船日期止"].ToString()).ToString("yyyy-MM-dd");
data.FEETYPE = row["费用类型"].ToString();
data.INPUTBY = row["录入人"].ToString();
data.AUDITER = row["审核人"].ToString();
headList.Add(data);
}
}
return headList;
}
static public List<MsClient> CreateClientList(SqlConnection dbcon)
{
var headList = new List<MsClient>();
var strSql = new StringBuilder();
strSql.Append("SELECT 客户简称,客户全称,客商编码 from t_crm_client WITH (NOLOCK) ");
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
MsClient data = new MsClient();
data.CUSTCODE = row["客商编码"].ToString();
data.CUSTNAME = row["客户简称"].ToString();
data.FULLNAME = row["客户全称"].ToString();
headList.Add(data);
}
}
return headList;
}
private string insertFee(List<MsOpSeae> MsOpSeaeList, List<MsChFee> MsChFeeList, MsFeeProject feeProject, List<MsClient> clientList,SqlConnection dbcon)
{
var FEETYPE = "收";
if (feeProject.FEETYPE != "收费") FEETYPE = "付";
if (MsOpSeaeList != null)
{
foreach (var enumValue in MsOpSeaeList)
{
// var usdexrate = GetUsdExrate(dbcon,enumValue.ETD);
try
{
var FANAME = GetOpSeaeFAStr(dbcon,enumValue.BSNO);
if (FANAME.IndexOf(feeProject.FADESCRIP) < 0)
{
log.Debug($"{enumValue.MBLNO}开始生成费用,方案:{feeProject.FADESCRIP}--{DateTime.Now.ToString()}");
var FeeUnitList = GetFeeUnit(enumValue.BSNO, dbcon);
log.Debug($"箱型费用000{FeeUnitList.ToString()}");
var oldfeelist = GetFeeList(enumValue.BSNO, dbcon);
if (MsChFeeList != null)
{
var iscreatefee = false;
foreach (var enumFeeValue in MsChFeeList)
{
decimal exrate = 1;
// if (enumFeeValue.Currency == "USD") exrate = usdexrate;
decimal feequantity = 0;
decimal amount = 0;
decimal tax = 0;
if (enumFeeValue.Unit == "箱型")
{
var FeeTemplateDetailList = GetFeeTemplateDetail(enumFeeValue.DE_ID, dbcon);
// var FeeTemplateDetailList = MsChFeeDetailList.FindAll(x=>x.DE_ID== enumFeeValue.DE_ID);
foreach (var FeeTemplateDetail in FeeTemplateDetailList) {
feequantity = 0;
FeeUnitList.ForEach(i =>
{
if (i.FEEUNIT == FeeTemplateDetail.Unit)
{
feequantity = i.FEEQUANTITY;
amount = feequantity * FeeTemplateDetail.UnitPrice;
}
});
log.Debug($"箱型费用:{FeeTemplateDetail.FA_ID}{feequantity}{amount}" );
tax = 0;
var customername = GetClient(enumFeeValue.CustomerType, enumValue, enumFeeValue.CustomerName);
var client = clientList.Find(x => x.CUSTNAME == customername);
var custcode = "";
var custfullname = "";
if (client != null) {
custcode = client.CUSTCODE;
custfullname = client.FULLNAME;
}
log.Debug($"箱型费用c{customername}");
if (oldfeelist.Find(x => x.CustomerName == customername && x.FeeName == enumFeeValue.FeeName && x.Unit == FeeTemplateDetail.Unit && x.Amount == amount && x.Currency == enumFeeValue.Currency && x.FeeType == enumFeeValue.FeeType) == null)
if (FeeTemplateDetail.UnitPrice != 0 && amount != 0 && customername != "")
{
log.Debug($"箱型费用2{FeeTemplateDetail.FA_ID}{feequantity}{amount}");
string sql = "INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
sql = sql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
sql = sql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
sql = sql + ",[机密],[申请金额],[不开发票],不含税金额,系统费用,所属部门";
sql = sql + ",[申请开票],[税率],[税额],方案名称,客户全称,客商编码,提交日期,审核日期,审核人) VALUES ";
sql = sql + "('" + FEETYPE + "','审核通过','" + enumValue.BSNO + "','" + enumFeeValue.FeeName + "','" + enumFeeValue.CustomerType + "','" + customername + "','" + FeeTemplateDetail.Unit.Replace("'", "''") + "'";
sql = sql + "," + FeeTemplateDetail.UnitPrice + "," + feequantity.ToString() + "," + amount.ToString() + ",'" + enumFeeValue.Currency + "'," + exrate.ToString() + ",'" + enumFeeValue.Remark + "',0,0";
sql = sql + ",'"+ enumValue.OP+ "',GETDATE(),0," + enumFeeValue.Sort + ",0";
sql = sql + ",0,0,0,0,0,'" + enumValue.SALEDEPT + "'";
sql = sql + ",0," + enumFeeValue.TAXRATE + "," + tax.ToString() + ",'" + feeProject.FADESCRIP + "','" + custfullname + "','" + custcode + "',GETDATE(),GETDATE(),'"+ feeProject.AUDITER + "')";
//log.Debug($"{enumValue.MBLNO},方案:{feeProject.FADESCRIP}-费用语句-{sql}");
if (dbcon.State == 0) dbcon.Open();
SqlCommand cmd = new SqlCommand(sql, dbcon);
cmd.ExecuteNonQuery();
dbcon.Close();
log.Debug($"箱型费用生成成功!:{FeeTemplateDetail.FA_ID}{feequantity}{amount}");
iscreatefee = true;
}
}
}
else
{
FeeUnitList.ForEach(i =>
{
if (i.FEEUNIT == enumFeeValue.Unit)
{
feequantity = i.FEEQUANTITY;
amount = feequantity * enumFeeValue.UnitPrice;
}
});
tax = 0;
var customername = GetClient(enumFeeValue.CustomerType, enumValue, enumFeeValue.CustomerName);
var client = clientList.Find(x => x.CUSTNAME == customername);
var custcode = "";
var custfullname = "";
if (client != null)
{
custcode = client.CUSTCODE;
custfullname = client.FULLNAME;
}
if (oldfeelist.Find(x => x.CustomerName == customername && x.FeeName == enumFeeValue.FeeName && x.Unit == enumFeeValue.Unit && x.Amount == amount && x.Currency == enumFeeValue.Currency && x.FeeType == enumFeeValue.FeeType) == null)
if (enumFeeValue.UnitPrice != 0 && amount != 0 && customername != "")
{
string sql = "INSERT INTO [t_ch_fee] ([类型],[费用状态],[编号],[费用名称],[结算单位],[客户名称],[标准]";
sql = sql + ",[单价],[数量],[金额],[币别],[汇率],[备注],[结算金额],[开票金额]";
sql = sql + ",[录入人],[录入日期],[是否对帐],[顺序],[冲抵金额]";
sql = sql + ",[机密],[申请金额],[不开发票],不含税金额,系统费用,所属部门";
sql = sql + ",[申请开票],[税率],[税额],方案名称,客户全称,客商编码,提交日期,审核日期,审核人) VALUES ";
sql = sql + "('" + FEETYPE + "','审核通过','" + enumValue.BSNO + "','" + enumFeeValue.FeeName + "','" + enumFeeValue.CustomerType + "','" + customername + "','" + enumFeeValue.Unit.Replace("'", "''") + "'";
sql = sql + "," + enumFeeValue.UnitPrice + "," + feequantity.ToString() + "," + amount.ToString() + ",'" + enumFeeValue.Currency + "'," + exrate.ToString() + ",'" + enumFeeValue.Remark + "',0,0";
sql = sql + ",'" + enumValue.OP + "',GETDATE(),0," + enumFeeValue.Sort + ",0";
sql = sql + ",0,0,0,0,0,'" + enumValue.SALEDEPT + "'";
sql = sql + ",0," + enumFeeValue.TAXRATE + "," + tax.ToString() + ",'" + feeProject.FADESCRIP + "','" + custfullname + "','" + custcode + "',GETDATE(),GETDATE(),'" + feeProject.AUDITER + "')";
//log.Debug($"{enumValue.MBLNO},方案:{feeProject.FADESCRIP}-费用语句-{sql}");
if (dbcon.State==0) dbcon.Open();
SqlCommand cmd = new SqlCommand(sql, dbcon);
cmd.ExecuteNonQuery();
dbcon.Close();
iscreatefee = true;
}
}
if (enumFeeValue.UnitPrice == 0) iscreatefee = true;
}
if (iscreatefee)
{
string sqlupdate = "UPDATE [t_op_seae] set 编号=编号 ";
sqlupdate = sqlupdate + " ,方案名称=ISNULL(方案名称,'')+'," + feeProject.FADESCRIP + "'";
enumValue.DLFA = enumValue.DLFA + "(" + feeProject.FADESCRIP + ")";
if (dbcon.State == 0) dbcon.Open();
sqlupdate = sqlupdate + " WHERE 编号='" + enumValue.BSNO + "'";
SqlCommand cmdupdate = new SqlCommand(sqlupdate, dbcon);
cmdupdate.ExecuteNonQuery();
dbcon.Close();
}
}
}
}
catch (Exception e) {
log.Debug($"{enumValue.MBLNO},方案:{feeProject.FADESCRIP}-生成费用出错!"+e.Message);
}
}
}
return "";
}
static public string CreateSql(string FA_ID, SqlConnection dbcon)
{
var str = " and 1=1 ";
var headList = new List<MsChFee>();
var strSql = new StringBuilder();
strSql.Append("SELECT *");
strSql.Append(" from t_ch_project_Condition WITH (NOLOCK) where 方案代码=" + FA_ID);
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
str = str + " AND " + row["条件名称"].ToString();
str = str + "='" + row["条件值"].ToString() + "'";
}
}
return str;
}
static public List<MsChFee> GetFeeTemplate(string FA_ID, SqlConnection dbcon)
{
var headList = new List<MsChFee>();
var strSql = new StringBuilder();
strSql.Append("SELECT * ");
strSql.Append(" from t_ch_project_fee_new WITH (NOLOCK) where 方案代码=" + FA_ID);
strSql.Append(" order by 顺序,DE_ID");
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
var Feedata = new MsChFee();
Feedata.DE_ID = row["DE_ID"].ToString();
Feedata.FA_ID =row["方案代码"].ToString();
Feedata.FeeName = row["费用名称"].ToString();
Feedata.CustomerType = row["结算单位"].ToString();
Feedata.CustomerName = row["客户名称"].ToString();
Feedata.Currency = row["币别"].ToString();
if (row["汇率"] != DBNull.Value)
Feedata.ExChangerate= Convert.ToDecimal(row["汇率"].ToString());
if (row["单价"] != DBNull.Value)
Feedata.UnitPrice = Convert.ToDecimal(row["单价"].ToString());
if (row["税率"] != DBNull.Value)
Feedata.TAXRATE = Convert.ToDecimal(row["税率"].ToString());
if (row["顺序"] != DBNull.Value)
Feedata.Sort = Convert.ToString(row["顺序"].ToString());
if (string.IsNullOrEmpty(Feedata.Sort)) Feedata.Sort = "1";
Feedata.Unit =row["标准"].ToString();
// Feedata. = row["税率"].ToString();
Feedata.Remark = row["费用备注"].ToString();
headList.Add(Feedata);
}
}
return headList;
}
static public List<MsChFee> GetFeeTemplateDetail(string DE_ID, SqlConnection dbcon)
{
var headList = new List<MsChFee>();
var strSql = new StringBuilder();
strSql.Append("SELECT * ");
strSql.Append(" from t_ch_project_standard_new WITH (NOLOCK) where DE_ID=" + DE_ID);
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
var Feedata = new MsChFee();
Feedata.DE_ID = row["DE_ID"].ToString();
Feedata.FA_ID = row["箱型代码"].ToString();
if (row["单价"] != DBNull.Value)
Feedata.UnitPrice = Convert.ToDecimal(row["单价"].ToString());
Feedata.Unit = row["标准"].ToString();
if (row["备注"] != DBNull.Value)
Feedata.Remark= row["备注"].ToString();
headList.Add(Feedata);
}
}
return headList;
}
static public List<MsChFee> GetFeeList(string BSNO, SqlConnection dbcon)
{
var headList = new List<MsChFee>();
var strSql = new StringBuilder();
strSql.Append("SELECT * ");
strSql.Append(" from t_ch_fee WITH (NOLOCK) where 编号='" + BSNO + "'");
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
var Feedata = new MsChFee();
Feedata.FeeName = row["费用名称"].ToString();
Feedata.CustomerName = row["客户名称"].ToString();
Feedata.Currency = row["币别"].ToString();
if (row["金额"] != DBNull.Value)
Feedata.Amount = Convert.ToDecimal(row["金额"].ToString());
Feedata.Unit = row["标准"].ToString();
Feedata.FeeType= row["类型"].ToString();
headList.Add(Feedata);
}
}
return headList;
}
static public List<MsFeeUnit> GetFeeUnit(string BSNO, SqlConnection dbcon)
{
decimal TEUNUM;
TEUNUM = 0;
decimal PKGS;
PKGS = 0;
decimal KGS;
KGS = 0;
decimal CBM;
CBM = 0;
decimal NETWEIGHT = 0;
decimal CTNNUM;
CTNNUM = 0;
decimal FEEKGS=0;
var headList = new List<MsFeeUnit>();
var strSql = new StringBuilder();
strSql.Append("SELECT NO,PKGS,KGS,CBM,NETWEIGHT,FEEKGS,CTNALL,CTNNUM,TEU FROM (");
strSql.Append("SELECT '1' as NO,件数 PKGS,重量 KGS,尺码 CBM,重量 AS NETWEIGHT,0 AS FEEKGS,");
strSql.Append("'' as CTNALL,0 AS CTNNUM,0 AS TEU ");
strSql.Append(",isnull((select sum(数量) from t_op_ctn WITH (NOLOCK) where 编号=t_op_seae.编号),0) 总箱数 ");
// strSql.Append(",isnull((select sum(ctnrCount) from t_op_txxp_log where 编号=t_op_seae.编号),0)-isnull((select sum(数量) from t_op_ctn where 编号=t_op_seae.编号),0) 超额小票数 ");
strSql.Append(" from t_op_seae WITH (NOLOCK) ");
strSql.Append(" where 编号='"+BSNO+"'");
strSql.Append(") AS T ");
strSql.Append(" union ");
strSql.Append("SELECT '2' AS NO,0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,0 AS FEEKGS,");
strSql.Append("P.表现形式 CTNALL,SUM(P.数量) AS CTNNUM,SUM(P.TEU) AS TEU");
strSql.Append(" from t_op_ctn P WITH (NOLOCK) ");
strSql.Append(" where p.编号='"+BSNO+"'");
strSql.Append(" GROUP BY P.表现形式 order by PKGS desc");
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
var isfirst = 0;
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
if (row["NO"].ToString() == "1")
{
var data = new MsFeeUnit();
data.FEEUNIT = "单票";
data.FEEQUANTITY = 1;
headList.Add(data);
if (!string.IsNullOrEmpty(row["PKGS"].ToString()))
PKGS = Convert.ToDecimal(row["PKGS"].ToString());
if (!string.IsNullOrEmpty(row["KGS"].ToString()))
KGS = Convert.ToDecimal(row["KGS"].ToString());
if (!string.IsNullOrEmpty(row["CBM"].ToString()))
CBM = Convert.ToDecimal(row["CBM"].ToString());
if (!string.IsNullOrEmpty(row["NETWEIGHT"].ToString()))
NETWEIGHT = Convert.ToDecimal(row["NETWEIGHT"].ToString());
if (!string.IsNullOrEmpty(row["FEEKGS"].ToString()))
FEEKGS = Convert.ToDecimal(row["FEEKGS"].ToString());
var data2 = new MsFeeUnit();
data2.FEEUNIT = "重量";
data2.FEEQUANTITY = KGS;
headList.Add(data2);
var data3 = new MsFeeUnit();
data3.FEEUNIT = "尺码";
data3.FEEQUANTITY = CBM;
headList.Add(data3);
var data4 = new MsFeeUnit();
data4.FEEUNIT = "件数";
data4.FEEQUANTITY = PKGS;
headList.Add(data4);
var data5 = new MsFeeUnit();
data5.FEEUNIT = "计价重量";
data5.FEEQUANTITY = FEEKGS;
headList.Add(data5);
var data6 = new MsFeeUnit();
data6.FEEUNIT = "计费吨";
data6.FEEQUANTITY = 0;
headList.Add(data6);
}
else
{
if (!string.IsNullOrEmpty(row["CTNALL"].ToString()))
{
var ctndata = new MsFeeUnit();
ctndata.FEEUNIT = row["CTNALL"].ToString();
if (!string.IsNullOrEmpty(row["CTNNUM"].ToString()))
ctndata.FEEQUANTITY = Convert.ToDecimal(row["CTNNUM"].ToString());
CTNNUM = CTNNUM + ctndata.FEEQUANTITY;
if (!string.IsNullOrEmpty(row["TEU"].ToString()))
TEUNUM = TEUNUM + Convert.ToDecimal(row["TEU"].ToString());
headList.Add(ctndata);
}
}
isfirst = 1;
}
var teudata = new MsFeeUnit();
teudata.FEEUNIT = "TEU";
teudata.FEEQUANTITY = TEUNUM;
headList.Add(teudata);
var ctnalldata = new MsFeeUnit();
ctnalldata.FEEUNIT = "箱数";
ctnalldata.FEEQUANTITY = CTNNUM;
headList.Add(ctnalldata);
}
return headList;
}
static public string GetClient(string custtype, MsOpSeae opSeae,string cust)
{
if (cust != "") return cust;
var custname = "";
if (custtype == "委托单位") custname = opSeae.CUSTOMERNAME;
if (custtype == "船公司") custname = opSeae.CARRIER;
if (custtype == "货代") custname = opSeae.FORWARDER;
if (custtype == "车队") custname = opSeae.TRUCKER;
if (custtype == "报关行") custname = opSeae.CUSTOMSER;
if (custtype == "船代") custname = opSeae.CUSTSERVICE;
if (custtype == "场站") custname = opSeae.YARD;
if (custtype == "代理") custname = opSeae.AGENTID;
if (custtype == "第三方") custname = opSeae.THIRDPARTY;
if (custtype == "发货人") custname = opSeae.SHIPPERID;
if (custtype == "收货人") custname = opSeae.CONSIGNEEID;
if (custtype == "通知人") custname = opSeae.NOTIFYPARTYID;
if (custtype == "其他相关公司") custname = opSeae.OTHERPARTY;
return custname;
}
static public decimal GetUsdExrate(SqlConnection dbcon,string etd)
{
decimal usdexrate = 0;
var strSql = new StringBuilder();
strSql.Append("select 汇率 from t_code_usdexrate WITH (NOLOCK) where 开始日期<='" + etd + "' and 结束日期>='"+ etd + "'");
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
usdexrate= Convert.ToDecimal(row["汇率"].ToString());
}
}
if (usdexrate == 0) {
SqlDataAdapter adapter2 = new SqlDataAdapter("select 汇率 from t_code_currency where 币别='USD'", dbcon);
DataTable table2 = new DataTable();
adapter2.Fill(table2);
if (table2.Rows.Count > 0)
{
foreach (DataRow row in table2.Rows)
{
usdexrate = Convert.ToDecimal(row["汇率"].ToString());
}
}
}
return usdexrate;
}
static public string GetOpSeaeFAStr(SqlConnection dbcon, string bsno)
{
string FANAME="";
var strSql = new StringBuilder();
strSql.Append("select 方案名称 from t_op_seae WITH (NOLOCK) where 编号='" + bsno + "'");
SqlDataAdapter adapter = new SqlDataAdapter(strSql.ToString(), dbcon);
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
FANAME = Convert.ToString(row["方案名称"].ToString());
}
}
return FANAME;
}
}
}