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.
1166 lines
56 KiB
C#
1166 lines
56 KiB
C#
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 JobD7CreateFee : IJob
|
|
{
|
|
private ILog log = LogManager.GetLogger(typeof(JobD7CreateFee));
|
|
|
|
public void Execute(IJobExecutionContext context)
|
|
{
|
|
|
|
string connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
|
|
string reqUrl = context.JobDetail.JobDataMap.GetString("ReqUrl");
|
|
string companyCode = context.JobDetail.JobDataMap.GetString("CompanyCode");
|
|
string companySecret = context.JobDetail.JobDataMap.GetString("CompanySecret");
|
|
string querySql = context.JobDetail.JobDataMap.GetString("QuerySql");
|
|
string projectquerySql = context.JobDetail.JobDataMap.GetString("projectquerySql");
|
|
string ENTEROPERATOR = context.JobDetail.JobDataMap.GetString("ENTEROPERATOR");
|
|
|
|
|
|
using (SqlConnection dbcon = new SqlConnection(connStr))
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("select * from code_fee_template_auto where BGNDATE<=GETDATE() AND (ENDDATE>=GETDATE() or isnull(ENDDATE,'')='') " + projectquerySql + " order by ISDEF,CLASS desc ");
|
|
|
|
|
|
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 feecodelist = GetFeeTypeRefList(dbcon);
|
|
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();
|
|
strSqlBs.Append("select B.BSNO,B.MBLNO,B.CUSTOMERNAME,B.CARRIER,B.FORWARDER,B.CUSTOMSER,B.SHIPAGENCY,B.YARD,B.AGENTID,B.OP ");
|
|
strSqlBs.Append(" from v_op_bs B where ISNULL(FEESTATUS,0)=0 ");
|
|
if (!string.IsNullOrEmpty(enumFeeproject.PROJECTTYPE))
|
|
{
|
|
strSqlBs.Append(" AND not EXISTS (SELECT 1 FROM op_auto_fee_detail D WHERE D.BSNO=B.BSNO AND D.FEEGROUP='" + enumFeeproject.PROJECTTYPE + "' AND D.FEETYPE=" + enumFeeproject.FEETYPE + ") ");
|
|
}
|
|
else {
|
|
strSqlBs.Append(" AND not EXISTS (SELECT 1 FROM op_auto_fee_detail D WHERE D.BSNO=B.BSNO and TEMPLATEID='"+ enumFeeproject.FA_ID + "') ");
|
|
}
|
|
|
|
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, feecodelist, dbcon, ENTEROPERATOR);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
log.Debug($"{enumFeeproject.FADESCRIP + " " + enumFeeproject.PROJECTTYPE}生成费用错误:{e.Message}");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
dbcon.Close();
|
|
}
|
|
}
|
|
|
|
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["BSNO"].ToString();
|
|
data.MBLNO= row["MBLNO"].ToString();
|
|
data.CUSTOMERNAME = row["CUSTOMERNAME"].ToString();
|
|
data.CARRIER = row["CARRIER"].ToString();
|
|
data.FORWARDER = row["FORWARDER"].ToString();
|
|
data.CUSTOMSER = row["CUSTOMSER"].ToString();
|
|
data.SHIPAGENCY = row["SHIPAGENCY"].ToString();
|
|
data.YARD = row["YARD"].ToString();
|
|
data.AGENTID = row["AGENTID"].ToString();
|
|
data.OP = row["OP"].ToString();
|
|
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["GID"].ToString();
|
|
data.FADESCRIP = row["DESCRIPTION"].ToString();
|
|
data.PROJECTTYPE = row["FEEGROUP"].ToString();
|
|
if (row["ISDEF"] != DBNull.Value&& row["ISDEF"].ToString()=="1")
|
|
data.ISDEFAUT =true;
|
|
data.FEETYPE = row["FEETYPE"].ToString();
|
|
data.INPUTBY = row["CREATEUSER"].ToString();
|
|
data.OPTYPE = Convert.ToString(row["OPTYPE"]);
|
|
headList.Add(data);
|
|
}
|
|
}
|
|
return headList;
|
|
|
|
}
|
|
|
|
private string insertFee(List<MsOpSeae> MsOpSeaeList, List<CodeFeeTemplateDetailAuto> MsChFeeList, MsFeeProject feeProject, List<FeeTypeRefModel> FeeCodeList, SqlConnection dbcon,string ENTEROPERATOR)
|
|
{
|
|
|
|
if (MsOpSeaeList != null)
|
|
{
|
|
|
|
foreach (var enumValue in MsOpSeaeList)
|
|
{
|
|
var unitlist = GetFeeUnit(enumValue.BSNO, feeProject.OPTYPE,dbcon);
|
|
var CurrDatelist =GetFeeDateCurrList(feeProject.OPTYPE, enumValue.BSNO, dbcon);
|
|
|
|
|
|
try
|
|
{
|
|
foreach (var FeeTempDetail in MsChFeeList)
|
|
{
|
|
var unit = unitlist.Find(e => e.UNIT == FeeTempDetail.UNIT);
|
|
if ((FeeTempDetail.ISCTN && unit != null) || (!FeeTempDetail.ISCTN))
|
|
{
|
|
|
|
decimal quantity = 1;
|
|
if (unit != null)
|
|
{
|
|
quantity = unit.QUANTITY;
|
|
}
|
|
var taxrate = FeeTempDetail.TAXRATE;
|
|
decimal acctaxrate = 0;
|
|
var taxrateb = Math.Round(1 + (taxrate / 100), 4, MidpointRounding.AwayFromZero);
|
|
decimal TaxUnitPrice = 0;
|
|
if (FeeTempDetail.TAXUNITPRICE == 0) TaxUnitPrice = Math.Round(FeeTempDetail.UNITPRICE * taxrateb, 4, MidpointRounding.AwayFromZero);
|
|
else TaxUnitPrice = FeeTempDetail.TAXUNITPRICE;
|
|
if (!string.IsNullOrEmpty(FeeTempDetail.UNITPRICEDESCRPTION))
|
|
{
|
|
var formulastr = FeeTempDetail.UNITPRICEDESCRPTION;
|
|
unitlist.ForEach(i =>
|
|
{
|
|
formulastr = formulastr.Replace("[" + i.UNIT + "]", i.QUANTITY.ToString());
|
|
});
|
|
|
|
;
|
|
try
|
|
{
|
|
DataTable dt = new DataTable();
|
|
if (dt.Compute(formulastr, "false") != DBNull.Value)
|
|
{
|
|
FeeTempDetail.UNITPRICE = Convert.ToDecimal(dt.Compute(formulastr, "false").ToString());
|
|
quantity = 1;
|
|
unitlist.ForEach(i =>
|
|
{
|
|
if (i.UNIT == FeeTempDetail.UNIT)
|
|
{
|
|
quantity = i.QUANTITY;
|
|
TaxUnitPrice = Math.Round(FeeTempDetail.UNITPRICE * taxrateb, 4, MidpointRounding.AwayFromZero);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
log.Debug($"{enumValue.MBLNO}公式错误:{e.Message}");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
var amout = Math.Round(TaxUnitPrice * quantity, 2, MidpointRounding.AwayFromZero);
|
|
decimal notaxamount = 0;
|
|
if (amout > 0)
|
|
{
|
|
notaxamount = Math.Round(amout / taxrateb, 2, MidpointRounding.AwayFromZero);
|
|
}
|
|
else
|
|
{
|
|
notaxamount = -Math.Round(Math.Abs(amout) / taxrateb, 2, MidpointRounding.AwayFromZero);
|
|
}
|
|
var tax = amout - notaxamount;
|
|
acctaxrate = FeeTempDetail.ACCTAXRATE;
|
|
decimal exrate = FeeTempDetail.EXCHANGERATE;
|
|
if (FeeTempDetail.CURRENCY == "RMB") exrate = 1;
|
|
if (exrate == 0)
|
|
{
|
|
var CurrDate = CurrDatelist.Find(x => x.CURR == FeeTempDetail.CURRENCY);
|
|
if (CurrDate != null)
|
|
{
|
|
if (feeProject.FEETYPE == "2") exrate = CurrDate.CRDEFRATE; else exrate = CurrDate.DEFRATE;
|
|
}
|
|
else
|
|
{
|
|
var Curr = CurrDatelist.Find(x => x.CURR == FeeTempDetail.CURRENCY);
|
|
if (feeProject.FEETYPE == "2") exrate = Curr.CRDEFRATE; else exrate = Curr.DEFRATE;
|
|
}
|
|
|
|
}
|
|
var customername = FeeTempDetail.CUSTOMERNAME;
|
|
var custtype = FeeTempDetail.CLIENTREF;
|
|
if (string.IsNullOrEmpty(FeeTempDetail.CUSTOMERNAME))
|
|
{
|
|
|
|
customername = GetClient(FeeTempDetail.CLIENT, enumValue, FeeTempDetail.CUSTOMERNAME);
|
|
if (FeeTempDetail.CLIENT == "CARRIER")
|
|
{
|
|
custtype = "船公司";
|
|
}
|
|
else if (FeeTempDetail.CLIENT == "FORWARDER")
|
|
{
|
|
custtype = "订舱代理";
|
|
|
|
}
|
|
else if (FeeTempDetail.CLIENT == "YARD")
|
|
{
|
|
custtype = "场站";
|
|
}
|
|
else if (FeeTempDetail.CLIENT == "TRUCKER")
|
|
{
|
|
custtype = "车队";
|
|
}
|
|
else if (FeeTempDetail.CLIENT == "CUSTOMERNAME")
|
|
{
|
|
custtype = "委托单位";
|
|
}
|
|
else if (FeeTempDetail.CLIENT == "CUSTOMSER")
|
|
{
|
|
custtype = "报关行";
|
|
}
|
|
else if (FeeTempDetail.CLIENT == "SHIPAGENCY")
|
|
{
|
|
custtype = "船代";
|
|
|
|
|
|
|
|
}
|
|
else if (FeeTempDetail.CLIENT == "OP")
|
|
{
|
|
custtype = "操作";
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
customername = FeeTempDetail.CUSTOMERNAME;
|
|
custtype = FeeTempDetail.CLIENTREF;
|
|
|
|
}
|
|
|
|
}
|
|
var FeeDescription = "";
|
|
var FeeCode = FeeCodeList.Find(x => x.Name == FeeTempDetail.FEENAME);
|
|
if (FeeCode != null) FeeDescription = FeeCode.Description;
|
|
var sql = "INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME,CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,";
|
|
sql = sql + "EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT,CARGO_GID,";
|
|
sql = sql + "TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC,FEEDESCRIPTION,DELIVERYNO)";
|
|
sql = sql + "VALUES ";
|
|
sql = sql + "('" + Guid.NewGuid().ToString() + "','" + enumValue.BSNO + "'," + feeProject.FEETYPE + ",'" + FeeTempDetail.FEENAME.Replace(",", "") + "','" + custtype + "','" + customername + "','" + FeeTempDetail.UNIT + "'";
|
|
sql = sql + "," + FeeTempDetail.UNITPRICE + "," + quantity + "," + amout + ",'" + FeeTempDetail.CURRENCY + "'," + exrate.ToString() + ",'','',0";
|
|
sql = sql + ",'" + ENTEROPERATOR + "',GETDATE(),0,0," + FeeTempDetail.SORT.ToString() + ",1,'',''";
|
|
sql = sql + "," + taxrate.ToString() + "," + notaxamount.ToString() + "," + acctaxrate.ToString() + ",0," + TaxUnitPrice.ToString() + ",'" + ENTEROPERATOR + "',GETDATE(),'',0,0,'自动方案','RMB','',0,'" + FeeDescription + "'";
|
|
sql = sql + ",'" + feeProject.FA_ID + "')";
|
|
log.Debug($"{enumValue.MBLNO},方案:{feeProject.FADESCRIP}-费用语句-{sql}");
|
|
dbcon.Open();
|
|
SqlCommand cmd = new SqlCommand(sql, dbcon);
|
|
cmd.ExecuteNonQuery();
|
|
dbcon.Close();
|
|
|
|
}
|
|
}
|
|
|
|
string sqlexe = "INSERT INTO [op_auto_fee_detail] ([GID],[TEMPLATEID],[BSNO],[FEEGROUP],[CREATETIME],[FEETYPE])";
|
|
sqlexe = sqlexe + "VALUES";
|
|
sqlexe = sqlexe + "(NEWID(),'"+ feeProject.FA_ID+ "','" + enumValue.BSNO + "','"+ feeProject.PROJECTTYPE + "',GETDATE(),'"+feeProject.FEETYPE+"')";
|
|
log.Debug($"{enumValue.MBLNO},方案:{feeProject.FADESCRIP}-执行语句-{sqlexe}");
|
|
dbcon.Open();
|
|
SqlCommand cmdexe = new SqlCommand(sqlexe, dbcon);
|
|
cmdexe.ExecuteNonQuery();
|
|
dbcon.Close();
|
|
enumValue.ISBSNO = enumValue.BSNO;
|
|
log.Debug($"{enumValue.MBLNO + ",方案 " + feeProject.FADESCRIP}已生成费用");
|
|
|
|
|
|
}
|
|
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 C.*");
|
|
strSql.Append(",q.FIELDCNAME,q.FIELDTYPE");
|
|
strSql.Append(" from code_fee_template_condition c ");
|
|
strSql.Append(" left join sys_queryfield_setting q on (q.FORMNAME='MsCodeFeeTemplateAutoEdit' and q.FIELDNAME=c.FIELDNAME) ");
|
|
strSql.Append(" where C.TEMPLATEID='" + 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)
|
|
{
|
|
if (row["FIELDTYPE"].ToString() == "BOOLEAN")
|
|
{
|
|
str = str + " AND ISNULL(" + row["FIELDNAME"].ToString()+",0)";
|
|
|
|
if (row["FIELDCONDIT"].ToString() == "等于") str = str + "=" + row["FIELDVALUE"].ToString() + "";
|
|
if (row["FIELDCONDIT"].ToString() == "不等于") str = str + "<>" + row["FIELDVALUE"].ToString()+ "";
|
|
} else if (row["FIELDTYPE"].ToString() == "STR")
|
|
{
|
|
str = str + " AND " + row["FIELDNAME"].ToString();
|
|
|
|
if (row["FIELDCONDIT"].ToString() == "等于") str = str + "='" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "不等于") str = str + "<>'" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "模糊") str = str + "like '%" + row["FIELDVALUE"].ToString() + "%'";
|
|
}
|
|
else if (row["FIELDTYPE"].ToString() == "NUM")
|
|
{
|
|
str = str + " AND " + row["FIELDNAME"].ToString();
|
|
|
|
if (row["FIELDCONDIT"].ToString() == "等于") str = str + "=" + row["FIELDVALUE"].ToString() + "";
|
|
if (row["FIELDCONDIT"].ToString() == "不等于") str = str + "<>" + row["FIELDVALUE"].ToString() + "";
|
|
if (row["FIELDCONDIT"].ToString() == "大于") str = str + ">=" + row["FIELDVALUE"].ToString() + "";
|
|
if (row["FIELDCONDIT"].ToString() == "小于") str = str + "<=" + row["FIELDVALUE"].ToString() + "";
|
|
}
|
|
else if (row["FIELDTYPE"].ToString() == "DATE"|| row["FIELDTYPE"].ToString() == "ACCDATE"||row["FIELDTYPE"].ToString() == "DATETIME")
|
|
{
|
|
str = str + " AND " + row["FIELDNAME"].ToString();
|
|
|
|
if (row["FIELDCONDIT"].ToString() == "等于") str = str + "='" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "不等于") str = str + "<>'" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "大于") str = str + ">='" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "小于") str = str + "<='" + row["FIELDVALUE"].ToString() + "'";
|
|
}
|
|
else
|
|
{
|
|
str = str + " AND " + row["FIELDNAME"].ToString();
|
|
if (row["FIELDCONDIT"].ToString() == "等于") str = str + "='" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "不等于") str = str + "<>'" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "模糊") str = str + " like '%" + row["FIELDVALUE"].ToString() + "%'";
|
|
if (row["FIELDCONDIT"].ToString() == "不包含") str = str + " not like '%" + row["FIELDVALUE"].ToString() + "%'";
|
|
if (row["FIELDCONDIT"].ToString() == "大于") str = str + ">='" + row["FIELDVALUE"].ToString() + "'";
|
|
if (row["FIELDCONDIT"].ToString() == "小于") str = str + "<='" + row["FIELDVALUE"].ToString() + "'";
|
|
}
|
|
}
|
|
}
|
|
|
|
return str;
|
|
}
|
|
static public List<CodeFeeTemplateDetailAuto> GetFeeTemplate(string FA_ID, SqlConnection dbcon)
|
|
{
|
|
|
|
var headList = new List<CodeFeeTemplateDetailAuto>();
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,TEMPLATEID,FEENAME,CUSTOMERNAME,CLIENT,UNIT");
|
|
strSql.Append(",CURRENCY,UNITPRICE,REMARK,SORT,CREATEUSER,CREATETIME,EXCHANGERATE,ISCTN,TAXRATE,TAXUNITPRICE,TAX,ACCTAXRATE");
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=96201 and EnumValueID=code_fee_templatedetail_auto.CLIENT) as CLIENTREF");
|
|
strSql.Append(",(case ISCTN when 1 then '是' else '否' end) as ISCTNREF,ISINVOICE,ISADVANCEDPAY,FEEFRT,SALECORP,FEEDESCRIPTION,UNITPRICEDESCRPTION ");
|
|
strSql.Append(" from code_fee_templatedetail_auto WHERE TEMPLATEID='"+ FA_ID + "'");
|
|
strSql.Append(" order by SORT ");
|
|
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 data = new CodeFeeTemplateDetailAuto();
|
|
data.GID = Convert.ToString(row["GID"]);
|
|
data.TEMPLATEID = Convert.ToString(row["TEMPLATEID"]);
|
|
if (row["UNITPRICE"] != DBNull.Value)
|
|
data.UNITPRICE = Convert.ToDecimal(row["UNITPRICE"]);
|
|
if (row["EXCHANGERATE"] != DBNull.Value)
|
|
data.EXCHANGERATE = Convert.ToDecimal(row["EXCHANGERATE"]);
|
|
if (row["TAXRATE"] != DBNull.Value)
|
|
data.TAXRATE = Convert.ToDecimal(row["TAXRATE"]);
|
|
if (row["TAX"] != DBNull.Value)
|
|
data.TAX = Convert.ToDecimal(row["TAX"]);
|
|
data.FEENAME = Convert.ToString(row["FEENAME"]);
|
|
data.FEEDESCRIPTION = Convert.ToString(row["FEEDESCRIPTION"]);
|
|
data.CUSTOMERNAME = Convert.ToString(row["CUSTOMERNAME"]);
|
|
if (row["CLIENT"] != DBNull.Value)
|
|
data.CLIENT = Convert.ToString(row["CLIENT"]);
|
|
data.CLIENTREF = Convert.ToString(row["CLIENTREF"]);
|
|
data.UNIT = Convert.ToString(row["UNIT"]);
|
|
data.CURRENCY = Convert.ToString(row["CURRENCY"]);
|
|
data.REMARK = Convert.ToString(row["REMARK"]);
|
|
if (row["SORT"] != DBNull.Value)
|
|
data.SORT = Convert.ToInt16(row["SORT"]);
|
|
data.FEEFRT = Convert.ToString(row["FEEFRT"]);
|
|
data.CREATEUSER = Convert.ToString(row["CREATEUSER"]);
|
|
data.CREATETIME = Convert.ToString(row["CREATETIME"]);
|
|
if (row["ISCTN"] != DBNull.Value)
|
|
data.ISCTN = Convert.ToBoolean(row["ISCTN"]);
|
|
data.ISCTNREF = Convert.ToString(row["ISCTNREF"]);
|
|
if (row["ISINVOICE"] != DBNull.Value)
|
|
data.ISINVOICE = Convert.ToBoolean(row["ISINVOICE"]);
|
|
if (row["ISADVANCEDPAY"] != DBNull.Value)
|
|
data.ISADVANCEDPAY = Convert.ToBoolean(row["ISADVANCEDPAY"]);
|
|
data.SALECORP = Convert.ToString(row["SALECORP"]);
|
|
if (row["TAXUNITPRICE"] != DBNull.Value)
|
|
data.TAXUNITPRICE = Convert.ToDecimal(row["TAXUNITPRICE"]);
|
|
if (row["ACCTAXRATE"] != DBNull.Value)
|
|
data.ACCTAXRATE = Convert.ToDecimal(row["ACCTAXRATE"]);
|
|
data.UNITPRICEDESCRPTION = Convert.ToString(row["UNITPRICEDESCRPTION"]);
|
|
headList.Add(data);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
return headList;
|
|
}
|
|
|
|
static public List<MsFeeUnitD7> GetFeeUnit(string bsno,string bstype,SqlConnection dbcon)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
if (bstype == "op_seae")
|
|
{
|
|
if (!string.IsNullOrEmpty(bsno))
|
|
{
|
|
strSql.Append("SELECT PKGS,KGS,CBM,KGS AS NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,0 AS CTNNUM,0 AS TEU,'' AS CTNALL");
|
|
strSql.Append(" from op_seae ");
|
|
strSql.Append(" where bsno='" + bsno + "'");
|
|
strSql.Append(" union ");
|
|
strSql.Append("SELECT 0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,");
|
|
strSql.Append("P.SIZE,P.CTN,SUM(P.CTNNUM) AS CTNNUM,SUM(P.TEU) AS TEU,P.CTNALL");
|
|
strSql.Append(" from OP_CTN P ");
|
|
strSql.Append(" where p.bsno='" + bsno + "'");
|
|
strSql.Append(" GROUP BY P.SIZE,P.CTN,P.CTNALL order by PKGS desc");
|
|
}
|
|
else
|
|
{
|
|
strSql.Append("SELECT top 1 1 PKGS,0 KGS,0 CBM,0 AS NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,0 AS CTNNUM,0 AS TEU,'' AS CTNALL");
|
|
strSql.Append(" from op_seae ");
|
|
strSql.Append(" union ");
|
|
strSql.Append("SELECT distinct 0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,");
|
|
strSql.Append("P.SIZE,P.CTN,0 AS CTNNUM,0 AS TEU,P.CTNALL");
|
|
strSql.Append(" from OP_CTN P ");
|
|
|
|
|
|
}
|
|
return SetSeaeCtnUnitData(strSql, bstype, dbcon);
|
|
}
|
|
else if (bstype == "op_seai")
|
|
{
|
|
strSql.Append("SELECT PKGS,KGS,CBM,NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,0 AS CTNNUM,0 AS TEU,'' AS CTNALL");
|
|
strSql.Append(" from op_seai ");
|
|
strSql.Append(" where bsno='" + bsno + "'");
|
|
strSql.Append(" union ");
|
|
strSql.Append("SELECT 0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,");
|
|
strSql.Append("P.SIZE,P.CTN,SUM(P.CTNNUM) AS CTNNUM,SUM(P.TEU) AS TEU,P.CTNALL");
|
|
strSql.Append(" from OP_CTN P ");
|
|
strSql.Append(" where p.bsno='" + bsno + "'");
|
|
strSql.Append(" GROUP BY P.SIZE,P.CTN,P.CTNALL order by PKGS desc");
|
|
return SetSeaeCtnUnitData(strSql, bstype, dbcon);
|
|
}
|
|
else if (bstype == "op_apply")
|
|
{
|
|
strSql.Append("SELECT PKGS,KGS,CBM,NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,0 AS CTNNUM,0 AS TEU,'' AS CTNALL");
|
|
strSql.Append(" from op_apply ");
|
|
strSql.Append(" where bsno='" + bsno + "'");
|
|
return SetSeaeCtnUnitData(strSql, bstype, dbcon);
|
|
}
|
|
else if (bstype == "op_seaeorder")
|
|
{
|
|
strSql.Append("SELECT PKGS,KGS,CBM,0 AS NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,0 AS CTNNUM,0 AS TEU,'' AS CTNALL");
|
|
strSql.Append(" from crm_seaeorder ");
|
|
strSql.Append(" where ORDNO='" + bsno + "'");
|
|
strSql.Append(" union ");
|
|
strSql.Append("SELECT 0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' as CTN,SUM(P.CTNNUM) AS CTNNUM,0 AS TEU,P.CTNALL");
|
|
strSql.Append(" from crm_seaeorderctn P ");
|
|
strSql.Append(" where p.ordno='" + bsno + "'");
|
|
strSql.Append(" GROUP BY P.CTNALL order by PKGS desc ");
|
|
return SetSeaeCtnUnitData(strSql, bstype, dbcon);
|
|
}
|
|
else if (bstype == "op_other")
|
|
{
|
|
strSql.Append("SELECT PKGS,KGS,CBM,NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,CTNALL AS CTN,CTNNUM,0 AS TEU,CTNALL");
|
|
strSql.Append(" from op_other ");
|
|
strSql.Append(" where bsno='" + bsno + "'");
|
|
return SetSeaeCtnUnitData(strSql, bstype, dbcon);
|
|
}
|
|
else if (bstype == "op_railway")
|
|
{
|
|
strSql.Append("SELECT PKGS,KGS,CBM,KGS as NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,CTNNUM,0 AS TEU,CTNALL");
|
|
strSql.Append(" from op_railway ");
|
|
strSql.Append(" where bsno='" + bsno + "'");
|
|
strSql.Append(" union ");
|
|
strSql.Append("SELECT 0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,");
|
|
strSql.Append("P.SIZE,P.CTN,SUM(P.CTNNUM) AS CTNNUM,SUM(P.TEU) AS TEU,P.CTNALL");
|
|
strSql.Append(" from OP_CTN P ");
|
|
strSql.Append(" where p.bsno='" + bsno + "'");
|
|
strSql.Append(" GROUP BY P.SIZE,P.CTN,P.CTNALL order by PKGS desc");
|
|
return SetRailwayCtnUnitData(strSql, dbcon);
|
|
}
|
|
else if (bstype == "op_aire")
|
|
{
|
|
strSql.Append("SELECT PKGS,FEEKGS KGS,CBM,FEEKGS NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,0 CTNNUM,0 AS TEU,'' CTNALL");
|
|
strSql.Append(" from op_aire ");
|
|
strSql.Append(" where bsno='" + bsno + "'");
|
|
return SetSeaeCtnUnitData(strSql, bstype, dbcon);
|
|
}
|
|
else if (bstype == "op_airi")
|
|
{
|
|
strSql.Append("SELECT PKGS,FEEKGS KGS,CBM,FEEKGS NETWEIGHT,");
|
|
strSql.Append("'' as SIZE,'' AS CTN,0 CTNNUM,0 AS TEU,'' CTNALL");
|
|
strSql.Append(" from op_airi");
|
|
strSql.Append(" where bsno='" + bsno + "'");
|
|
return SetSeaeCtnUnitData(strSql, bstype, dbcon);
|
|
}else return SetCtnUnitData(strSql, dbcon);
|
|
|
|
}
|
|
|
|
|
|
private static List<MsFeeUnitD7> SetCtnUnitData(StringBuilder strSql, SqlConnection dbcon)
|
|
{
|
|
var bodyList = new List<MsFeeUnitD7>();
|
|
var strSqla = new StringBuilder();
|
|
strSqla.Append("SELECT CTN from code_ctn");
|
|
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)
|
|
{
|
|
MsFeeUnitD7 Data = new MsFeeUnitD7();
|
|
Data.SUNIT = Convert.ToString(row["CTN"]);
|
|
Data.UNIT = Convert.ToString(row["CTN"]);
|
|
Data.QUANTITY = 1;
|
|
bodyList.Add(Data);
|
|
}
|
|
}
|
|
|
|
|
|
var data = new MsFeeUnitD7();
|
|
data.SUNIT = "P-单票";
|
|
data.UNIT = "单票";
|
|
data.QUANTITY = 1;
|
|
bodyList.Add(data);
|
|
var data2 = new MsFeeUnitD7();
|
|
data2.SUNIT = "J-件";
|
|
data2.UNIT = "件数";
|
|
data2.QUANTITY = 0;
|
|
bodyList.Add(data2);
|
|
var data4 = new MsFeeUnitD7();
|
|
data4.SUNIT = "Z-重量";
|
|
data4.UNIT = "重量";
|
|
data4.QUANTITY = 0;
|
|
bodyList.Add(data4);
|
|
var data3 = new MsFeeUnitD7();
|
|
data3.SUNIT = "T-TEU";
|
|
data3.UNIT = "TEU";
|
|
data3.QUANTITY = 0;
|
|
bodyList.Add(data3);
|
|
|
|
var data5 = new MsFeeUnitD7();
|
|
data5.SUNIT = "C-CBM";
|
|
data5.UNIT = "CBM";
|
|
data5.QUANTITY = 0;
|
|
bodyList.Add(data5);
|
|
|
|
var data6 = new MsFeeUnitD7();
|
|
data6.SUNIT = "X-箱型";
|
|
data6.UNIT = "箱型";
|
|
data6.QUANTITY = 0;
|
|
bodyList.Add(data6);
|
|
|
|
var data7 = new MsFeeUnitD7();
|
|
data7.SUNIT = "B-BILL";
|
|
data7.UNIT = "BILL";
|
|
data7.QUANTITY = 0;
|
|
bodyList.Add(data7);
|
|
|
|
var data8 = new MsFeeUnitD7();
|
|
data8.SUNIT = "V-车";
|
|
data8.UNIT = "车";
|
|
data8.QUANTITY = 0;
|
|
bodyList.Add(data8);
|
|
|
|
var data9 = new MsFeeUnitD7();
|
|
data9.SUNIT = "T-天";
|
|
data9.UNIT = "天";
|
|
data9.QUANTITY = 0;
|
|
bodyList.Add(data9);
|
|
var data10 = new MsFeeUnitD7();
|
|
data10.SUNIT = "G-个";
|
|
data10.UNIT = "个";
|
|
data10.QUANTITY = 0;
|
|
bodyList.Add(data10);
|
|
var data11 = new MsFeeUnitD7();
|
|
data11.SUNIT = "S-小时";
|
|
data11.UNIT = "小时";
|
|
data11.QUANTITY = 0;
|
|
bodyList.Add(data10);
|
|
return bodyList;
|
|
}
|
|
|
|
private static List<MsFeeUnitD7> SetSeaeCtnUnitData(StringBuilder strSql, string bstype, SqlConnection dbcon)
|
|
{
|
|
var bodyList = new List<MsFeeUnitD7>();
|
|
decimal TEUNUM;
|
|
TEUNUM = 0;
|
|
decimal PKGS;
|
|
PKGS = 0;
|
|
decimal KGS;
|
|
KGS = 0;
|
|
decimal CBM;
|
|
CBM = 0;
|
|
decimal NETWEIGHT = 0;
|
|
decimal CTNNUM;
|
|
CTNNUM = 0;
|
|
|
|
int isfirst = 0;
|
|
|
|
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)
|
|
{
|
|
#region Set DB data to Object
|
|
if (isfirst == 0)
|
|
{
|
|
var data = new MsFeeUnitD7();
|
|
data.SUNIT = "P-单票";
|
|
data.UNIT = "单票";
|
|
data.QUANTITY = 1;
|
|
bodyList.Add(data);
|
|
if (row["PKGS"] != DBNull.Value)
|
|
PKGS = Convert.ToDecimal(row["PKGS"]);
|
|
if (row["KGS"] != DBNull.Value)
|
|
KGS = Convert.ToDecimal(row["KGS"]);
|
|
if (row["CBM"] != DBNull.Value)
|
|
CBM = Convert.ToDecimal(row["CBM"]);
|
|
if (row["NETWEIGHT"] != DBNull.Value)
|
|
NETWEIGHT = Convert.ToDecimal(row["NETWEIGHT"]);
|
|
var kgsdata = new MsFeeUnitD7();
|
|
kgsdata.SUNIT = "Z-重量";
|
|
kgsdata.UNIT = "重量";
|
|
kgsdata.QUANTITY = KGS;
|
|
bodyList.Add(kgsdata);
|
|
var cbmdata = new MsFeeUnitD7();
|
|
cbmdata.SUNIT = "C-尺码";
|
|
cbmdata.UNIT = "尺码";
|
|
cbmdata.QUANTITY = CBM;
|
|
bodyList.Add(cbmdata);
|
|
var pkgsdata = new MsFeeUnitD7();
|
|
pkgsdata.SUNIT = "J-件数";
|
|
pkgsdata.UNIT = "件数";
|
|
pkgsdata.QUANTITY = PKGS;
|
|
bodyList.Add(pkgsdata);
|
|
if (bstype == "op_aire" || bstype == "op_airi")
|
|
{
|
|
var netkgsdata = new MsFeeUnitD7();
|
|
netkgsdata.SUNIT = "JFZL-计费重量";
|
|
netkgsdata.UNIT = "计费重量";
|
|
netkgsdata.QUANTITY = NETWEIGHT;
|
|
bodyList.Add(netkgsdata);
|
|
|
|
}
|
|
else
|
|
{
|
|
var netkgsdata = new MsFeeUnitD7();
|
|
netkgsdata.SUNIT = "N-净重";
|
|
netkgsdata.UNIT = "净重";
|
|
netkgsdata.QUANTITY = NETWEIGHT;
|
|
bodyList.Add(netkgsdata);
|
|
}
|
|
var Bdata = new MsFeeUnitD7();
|
|
Bdata.SUNIT = "B-BILL";
|
|
Bdata.UNIT = "BILL";
|
|
Bdata.QUANTITY = 1;
|
|
bodyList.Add(Bdata);
|
|
|
|
var ton = KGS / 1000;
|
|
if (ton > CBM)
|
|
{
|
|
var jfd = Math.Round(KGS / 1000, 3, MidpointRounding.AwayFromZero);
|
|
if (jfd < 1) jfd = 1;
|
|
var feetondata = new MsFeeUnitD7();
|
|
feetondata.SUNIT = "JF-计费吨";
|
|
feetondata.UNIT = "计费吨";
|
|
feetondata.QUANTITY = jfd;
|
|
bodyList.Add(feetondata);
|
|
}
|
|
else
|
|
{
|
|
var jfd = CBM;
|
|
if (jfd < 1) jfd = 1;
|
|
var feetondata = new MsFeeUnitD7();
|
|
feetondata.SUNIT = "JF-计费吨";
|
|
feetondata.UNIT = "计费吨";
|
|
feetondata.QUANTITY = jfd;
|
|
bodyList.Add(feetondata);
|
|
}
|
|
var jzton = Math.Round(NETWEIGHT / 1000, 3, MidpointRounding.AwayFromZero);
|
|
var feejztondata = new MsFeeUnitD7();
|
|
feejztondata.SUNIT = "JZD-净重吨";
|
|
feejztondata.UNIT = "净重吨";
|
|
feejztondata.QUANTITY = jzton;
|
|
bodyList.Add(feejztondata);
|
|
|
|
}
|
|
if (Convert.ToString(row["CTNALL"]) != "")
|
|
{
|
|
var ctndata = new MsFeeUnitD7();
|
|
ctndata.SUNIT = Convert.ToString(row["CTNALL"]);
|
|
ctndata.UNIT = Convert.ToString(row["CTNALL"]);
|
|
if (row["CTNNUM"] != DBNull.Value)
|
|
ctndata.QUANTITY = Convert.ToDecimal(row["CTNNUM"]);
|
|
CTNNUM = CTNNUM + ctndata.QUANTITY;
|
|
if (row["TEU"] != DBNull.Value)
|
|
TEUNUM = TEUNUM + Convert.ToDecimal(row["TEU"]);
|
|
bodyList.Add(ctndata);
|
|
}
|
|
isfirst = isfirst + 1;
|
|
#endregion
|
|
}
|
|
var teudata = new MsFeeUnitD7();
|
|
teudata.SUNIT = "TEU";
|
|
teudata.UNIT = "TEU";
|
|
teudata.QUANTITY = TEUNUM;
|
|
bodyList.Add(teudata);
|
|
var ctnalldata = new MsFeeUnitD7();
|
|
ctnalldata.SUNIT = "自然箱";
|
|
ctnalldata.UNIT = "自然箱";
|
|
ctnalldata.QUANTITY = CTNNUM;
|
|
bodyList.Add(ctnalldata);
|
|
var data9 = new MsFeeUnitD7();
|
|
data9.SUNIT = "T-天";
|
|
data9.UNIT = "天";
|
|
data9.QUANTITY = 0;
|
|
bodyList.Add(data9);
|
|
var data10 = new MsFeeUnitD7();
|
|
data10.SUNIT = "G-个";
|
|
data10.UNIT = "个";
|
|
data10.QUANTITY = 0;
|
|
bodyList.Add(data10);
|
|
var data11 = new MsFeeUnitD7();
|
|
data11.SUNIT = "S-小时";
|
|
data11.UNIT = "小时";
|
|
data11.QUANTITY = 0;
|
|
bodyList.Add(data11);
|
|
var data12 = new MsFeeUnitD7();
|
|
data12.SUNIT = "S-票";
|
|
data12.UNIT = "票";
|
|
data12.QUANTITY = 0;
|
|
bodyList.Add(data12);
|
|
var data13 = new MsFeeUnitD7();
|
|
data13.SUNIT = "D-吨";
|
|
data13.UNIT = "吨";
|
|
data13.QUANTITY = 0;
|
|
bodyList.Add(data13);
|
|
|
|
|
|
}
|
|
return bodyList;
|
|
}
|
|
private static List<MsFeeUnitD7> SetRailwayCtnUnitData(StringBuilder strSql, SqlConnection dbcon)
|
|
{
|
|
var bodyList = new List<MsFeeUnitD7>();
|
|
decimal TEUNUM;
|
|
TEUNUM = 0;
|
|
decimal PKGS;
|
|
PKGS = 0;
|
|
decimal KGS;
|
|
KGS = 0;
|
|
decimal CBM;
|
|
CBM = 0;
|
|
decimal NETWEIGHT = 0;
|
|
|
|
int isfirst = 0;
|
|
|
|
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)
|
|
{
|
|
#region Set DB data to Object
|
|
if (isfirst == 0)
|
|
{
|
|
var data = new MsFeeUnitD7();
|
|
data.SUNIT = "P-单票";
|
|
data.UNIT = "单票";
|
|
data.QUANTITY = 1;
|
|
bodyList.Add(data);
|
|
PKGS = Convert.ToDecimal(row["PKGS"]);
|
|
KGS = Convert.ToDecimal(row["KGS"]);
|
|
CBM = Convert.ToDecimal(row["CBM"]);
|
|
NETWEIGHT = Convert.ToDecimal(row["NETWEIGHT"]);
|
|
var kgsdata = new MsFeeUnitD7();
|
|
kgsdata.SUNIT = "Z-重量";
|
|
kgsdata.UNIT = "重量";
|
|
kgsdata.QUANTITY = KGS;
|
|
bodyList.Add(kgsdata);
|
|
var cbmdata = new MsFeeUnitD7();
|
|
cbmdata.SUNIT = "C-尺码";
|
|
cbmdata.UNIT = "尺码";
|
|
cbmdata.QUANTITY = CBM;
|
|
bodyList.Add(cbmdata);
|
|
var pkgsdata = new MsFeeUnitD7();
|
|
pkgsdata.SUNIT = "J-件数";
|
|
pkgsdata.UNIT = "件数";
|
|
pkgsdata.QUANTITY = PKGS;
|
|
bodyList.Add(pkgsdata);
|
|
var netkgsdata = new MsFeeUnitD7();
|
|
netkgsdata.SUNIT = "N-净重";
|
|
netkgsdata.UNIT = "净重";
|
|
netkgsdata.QUANTITY = NETWEIGHT;
|
|
bodyList.Add(netkgsdata);
|
|
var PCsdata = new MsFeeUnitD7();
|
|
PCsdata.SUNIT = "P-棚车";
|
|
PCsdata.UNIT = "棚车";
|
|
PCsdata.QUANTITY = 1;
|
|
bodyList.Add(PCsdata);
|
|
var CCsdata = new MsFeeUnitD7();
|
|
CCsdata.SUNIT = "P-敞车";
|
|
CCsdata.UNIT = "敞车";
|
|
CCsdata.QUANTITY = 1;
|
|
bodyList.Add(CCsdata);
|
|
var GCsdata = new MsFeeUnitD7();
|
|
GCsdata.SUNIT = "G-罐车";
|
|
GCsdata.UNIT = "罐车";
|
|
GCsdata.QUANTITY = 1;
|
|
bodyList.Add(GCsdata);
|
|
var PCCsdata = new MsFeeUnitD7();
|
|
PCCsdata.SUNIT = "P-平车";
|
|
PCCsdata.UNIT = "平车";
|
|
PCsdata.QUANTITY = 1;
|
|
bodyList.Add(PCCsdata);
|
|
var LCRsdata = new MsFeeUnitD7();
|
|
LCRsdata.SUNIT = "LCR";
|
|
LCRsdata.UNIT = "LCR";
|
|
LCRsdata.QUANTITY = 1;
|
|
bodyList.Add(LCRsdata);
|
|
var SHsdata = new MsFeeUnitD7();
|
|
SHsdata.SUNIT = "SH-散货车";
|
|
SHsdata.UNIT = "散货车";
|
|
SHsdata.QUANTITY = 1;
|
|
bodyList.Add(SHsdata);
|
|
|
|
var ton = KGS / 1000;
|
|
if (ton > CBM)
|
|
{
|
|
var feetondata = new MsFeeUnitD7();
|
|
feetondata.SUNIT = "JF-计费吨";
|
|
feetondata.UNIT = "计费吨";
|
|
feetondata.QUANTITY = Math.Round(KGS / 1000, 2, MidpointRounding.AwayFromZero);
|
|
bodyList.Add(feetondata);
|
|
}
|
|
else
|
|
{
|
|
var feetondata = new MsFeeUnitD7();
|
|
feetondata.SUNIT = "JF-计费吨";
|
|
feetondata.UNIT = "计费吨";
|
|
feetondata.QUANTITY = CBM;
|
|
bodyList.Add(feetondata);
|
|
}
|
|
|
|
}
|
|
if (Convert.ToString(row["CTNALL"]) != "")
|
|
{
|
|
var ctndata = new MsFeeUnitD7();
|
|
ctndata.SUNIT = Convert.ToString(row["CTNALL"]);
|
|
ctndata.UNIT = Convert.ToString(row["CTNALL"]);
|
|
if (row["CTNNUM"] != DBNull.Value)
|
|
ctndata.QUANTITY = Convert.ToDecimal(row["CTNNUM"]);
|
|
if (row["TEU"] != DBNull.Value)
|
|
TEUNUM = TEUNUM + Convert.ToDecimal(row["TEU"]);
|
|
bodyList.Add(ctndata);
|
|
}
|
|
isfirst = isfirst + 1;
|
|
#endregion
|
|
}
|
|
var teudata = new MsFeeUnitD7();
|
|
teudata.SUNIT = "TEU";
|
|
teudata.UNIT = "TEU";
|
|
teudata.QUANTITY = TEUNUM;
|
|
bodyList.Add(teudata);
|
|
|
|
|
|
}
|
|
return bodyList;
|
|
}
|
|
|
|
|
|
|
|
static public string GetClient(string custtype, MsOpSeae opSeae,string cust)
|
|
{
|
|
if (cust != "") return cust;
|
|
|
|
var custname = "";
|
|
if (custtype == "CARRIER") custname = opSeae.CARRIER;
|
|
if (custtype == "FORWARDER") custname = opSeae.FORWARDER;
|
|
if (custtype == "YARD") custname = opSeae.YARD;
|
|
if (custtype == "TRUCKER") custname = opSeae.TRUCKER;
|
|
if (custtype == "CUSTOMERNAME") custname = opSeae.CUSTOMERNAME;
|
|
if (custtype == "CUSTOMSER") custname = opSeae.CUSTOMSER;
|
|
if (custtype == "SHIPAGENCY") custname = opSeae.SHIPAGENCY;
|
|
if (custtype == "OP") custname = opSeae.OP;
|
|
|
|
return custname;
|
|
}
|
|
|
|
|
|
|
|
public static List<MsFeeCurr> GetFeeDateCurrList(string type, string bsno, SqlConnection dbcon)
|
|
{
|
|
var FEEEXRATEDEF = GetSysParamValue("FEEEXRATEDEF", dbcon);
|
|
DateTime currdate = DateTime.Now;
|
|
if (FEEEXRATEDEF == "BSDATE" || FEEEXRATEDEF == "ACCDATE" || FEEEXRATEDEF == "CREATETIME")
|
|
{
|
|
var currset = "shipping";
|
|
if (FEEEXRATEDEF == "BSDATE") currset = "shipping";
|
|
if (FEEEXRATEDEF == "ACCDATE") currset = "account";
|
|
if (FEEEXRATEDEF == "CREATETIME") currset = "common";
|
|
currdate = GetopDate(currset, bsno, dbcon);
|
|
}
|
|
|
|
var evList = new List<MsFeeCurr>();
|
|
if (currdate != DateTime.MinValue)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select CURRENCYID,VALUE,CRVALUE,");
|
|
strSql.Append("(select CodeName from code_currency where GID=currency_exchange.CURRENCYID) as CODENAME");
|
|
strSql.Append(" from currency_exchange ");
|
|
strSql.Append(" where STARTTIME<='" + currdate.ToShortDateString().ToString() + "' and ENDTIME>='" + currdate.ToShortDateString().ToString() + "'");
|
|
|
|
|
|
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 evData = new MsFeeCurr();
|
|
evData.CURR = Convert.ToString(row["CODENAME"]);
|
|
evData.DEFRATE = Convert.ToDecimal(row["VALUE"]);
|
|
if (row["CRVALUE"] != DBNull.Value)
|
|
evData.CRDEFRATE = Convert.ToDecimal(row["CRVALUE"]);
|
|
if (evData.CRDEFRATE == 0) evData.CRDEFRATE = evData.DEFRATE;
|
|
evList.Add(evData);
|
|
}
|
|
}
|
|
}
|
|
if (evList.Count == 0) return GetFeeCurrList(dbcon);
|
|
else return evList;
|
|
|
|
}
|
|
|
|
public static DateTime GetopDate(string datetype, string bsno, SqlConnection dbcon)
|
|
{
|
|
DateTime CurrDate = DateTime.MinValue;
|
|
//CurrDate = DateTime.Now;
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select accdate,opdate,createtime ");
|
|
strSql.Append(" from opdate ");
|
|
strSql.Append(" where bsno='" + 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)
|
|
{
|
|
if (datetype == "shipping")
|
|
{
|
|
if (row["opdate"] != DBNull.Value)
|
|
CurrDate = Convert.ToDateTime(row["opdate"]);
|
|
}
|
|
else if (datetype == "account")
|
|
{
|
|
if (row["accdate"] != DBNull.Value)
|
|
CurrDate = Convert.ToDateTime(Convert.ToString(row["accdate"]) + "-01");
|
|
|
|
}
|
|
else if (datetype == "common")
|
|
{
|
|
if (row["createtime"] != DBNull.Value)
|
|
CurrDate = Convert.ToDateTime(row["createtime"]);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
return CurrDate;
|
|
}
|
|
|
|
public static List<MsFeeCurr> GetFeeCurrList(SqlConnection dbcon)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select GID,CODENAME,DEFAULTRATE ");
|
|
strSql.Append(" from code_currency ");
|
|
strSql.Append(" order by CODENAME");
|
|
|
|
var evList = new List<MsFeeCurr>();
|
|
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 evData = new MsFeeCurr();
|
|
evData.GID = Convert.ToString(row["GID"]);
|
|
evData.CURR = Convert.ToString(row["CODENAME"]);
|
|
evData.DEFRATE = Convert.ToDecimal(row["DEFAULTRATE"]);
|
|
evData.CRDEFRATE = Convert.ToDecimal(row["DEFAULTRATE"]);
|
|
evList.Add(evData);
|
|
}
|
|
}
|
|
|
|
return evList;
|
|
}
|
|
|
|
public static List<FeeTypeRefModel> GetFeeTypeRefList(SqlConnection dbcon)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select FeeCode,Name,FEECODE + '-' + NAME AS CodeAndName,DEFAULTCURR,DEFAULTDEBIT,DEFAULTCREDIT,feetype,Description,DefaultUnit,FeeFRT,ISADVANCEDPAY,TAXRATE ");
|
|
strSql.Append(",isnull(CASE DEFAULTDEBIT when 1 then '船公司' when 2 then '订舱代理' when 3 then '场站' when 4 then '车队' when 5 then '委托单位' when 6 then '报关行' when 7 then '代理' when 8 then '航空公司' when 9 then '发货人' when 10 then '收货人' when 11 then '通知人' when 12 then '船代' when 0 then '其他' end ,'') DEFAULTDEBITREF ");
|
|
strSql.Append(",isnull(CASE DEFAULTCREDIT when 1 then '船公司' when 2 then '订舱代理' when 3 then '场站' when 4 then '车队' when 5 then '委托单位' when 6 then '报关行' when 7 then '代理' when 8 then '航空公司' when 9 then '发货人' when 10 then '收货人' when 11 then '通知人' when 12 then '船代' when 0 then '其他' end ,'') DEFAULTCREDITREF ");
|
|
strSql.Append(" from code_fee ");
|
|
strSql.Append(" order by FeeCode");
|
|
|
|
var evList = new List<FeeTypeRefModel>();
|
|
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 evData = new FeeTypeRefModel();
|
|
evData.FeeCode = Convert.ToString(row["FeeCode"]);
|
|
evData.Name = Convert.ToString(row["Name"]);
|
|
evData.DefaultCurr = Convert.ToString(row["DEFAULTCURR"]);
|
|
evData.Description = Convert.ToString(row["Description"]);
|
|
evData.CodeAndName = Convert.ToString(row["CodeAndName"]);
|
|
evData.DefaultDebit = Convert.ToString(row["DEFAULTDEBIT"]);
|
|
evData.DefaultCredit = Convert.ToString(row["DEFAULTCREDIT"]);
|
|
evData.DefaultDebitRef = Convert.ToString(row["DEFAULTDEBITREF"]);
|
|
evData.DefaultCreditRef = Convert.ToString(row["DEFAULTCREDITREF"]);
|
|
evData.DefaultUnit = Convert.ToString(row["DefaultUnit"]);
|
|
evData.FEETYPE = Convert.ToString(row["FEETYPE"]);
|
|
evData.FEEFRT = Convert.ToString(row["FEEFRT"]);
|
|
if (row["ISADVANCEDPAY"] != DBNull.Value)
|
|
{
|
|
if (Convert.ToBoolean(row["ISADVANCEDPAY"])) evData.ISADVANCEDPAY = "1";
|
|
}
|
|
if (row["TAXRATE"] != DBNull.Value)
|
|
evData.TAXRATE = Convert.ToDecimal(row["TAXRATE"]);
|
|
evList.Add(evData);
|
|
}
|
|
}
|
|
|
|
return evList;
|
|
}
|
|
|
|
public static string GetSysParamValue(string PARAMNAME,SqlConnection dbcon)
|
|
{
|
|
var parmavalue = "";
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("GID,PARAMNAME,PARAMTYPE,PARAMDESCRIPTION,PARAMVALUE,MODIFIEDUSER,MODIFIEDTIME,FIELDTYPE");
|
|
strSql.Append(",(CASE WHEN PARAMNAME='CWSTARTUSING' THEN (SELECT TOP 1 STARTNAME FROM cw_design_startusing WHERE GID=sys_param_set.PARAMVALUE) ELSE ");
|
|
strSql.Append("(select top 1 DISPVALUE from sys_parameter_value where PARAMNAME=sys_param_set.PARAMNAME and PARAMVALUE=sys_param_set.PARAMVALUE) END) DISPVALUE");
|
|
strSql.Append(" from sys_param_set ");
|
|
strSql.Append(" where PARAMNAME = '" + PARAMNAME + "'");
|
|
strSql.Append(" order by PARAMTYPE,PARAMNAME");
|
|
|
|
|
|
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)
|
|
{
|
|
parmavalue = Convert.ToString(row["PARAMVALUE"]);
|
|
}
|
|
|
|
}
|
|
return parmavalue;
|
|
}
|
|
|
|
|
|
}
|
|
}
|