hanxuntao 6 months ago
parent 0f5c23a970
commit 13f57b5e89

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<NameOfLastUsedPublishProfile>FolderProfile</NameOfLastUsedPublishProfile>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort />

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort />

@ -13,6 +13,7 @@ using DSWeb.Common;
using JobAutoCreateFee.Model;
using System.Security.Policy;
using System.Xml.Linq;
using System.Diagnostics.Eventing.Reader;
namespace JobCreateFee
{
@ -71,6 +72,7 @@ namespace JobCreateFee
{
var MBLNO = row["MBLNO"].ToString();
var BSNO = row["BSNO"].ToString();
var ETD = row["ETD"].ToString();
if (!string.IsNullOrEmpty(MBLNO) && MBLNO.Length > 4) {
MBLNO = MBLNO.Substring(4);
}
@ -98,18 +100,23 @@ namespace JobCreateFee
{
var feelist = new List<MsChFee>();
var unitlist = GetFeeUnit(BSNO, dbcon);
var isctnnum = 1;
var findunitlist = unitlist.FindAll(x=>x.ISCTN);
if (findunitlist != null && unitlist.Count >= 2) {
isctnnum = 2;
}
string sql = "";
try
{
dbcon.Open();
foreach (var returndata in returnlist)
{
var BS = GETBSNO(BSNO, dbcon, BsSql);
if (BS.BSNO != "" && !BS.FEESTATUS)
{
if (!GETINVNOISUSE(BS.BSNO, returndata.itemUuid, dbcon))
if (!GETINVNOISUSE(BSNO, returndata.itemUuid, dbcon))
{
@ -125,7 +132,7 @@ namespace JobCreateFee
var COUNT = "1";
if (curr != "RMB")
{
exrate = GetUsdExrate(dbcon, curr, BS.ETD);
exrate = GetUsdExrate(dbcon, curr, ETD);
}
price = price.Replace(",", "");
if (string.IsNullOrEmpty(FEENAME))
@ -133,81 +140,95 @@ namespace JobCreateFee
var feeback = new feeback();
feeback.ReceiveId = returndata.bno;
feeback.Success = false;
feeback.Reason = $"提单号:{MBLNO},编号:{BS.BSNO},费用名称:{returndata.feeName} 未匹配";
feeback.Reason = $"提单号:{MBLNO},编号:{BSNO},费用名称:{returndata.feeName} 未匹配";
feebacklist.Add(feeback);
log.Debug($"提单号:{MBLNO},编号:{BS.BSNO},费用名称:{returndata.feeName} 未匹配");
log.Debug($"提单号:{MBLNO},编号:{BSNO},费用名称:{returndata.feeName} 未匹配");
}
else
{
var FeeTemplateDetail = FeeTemplateDetailList.Find(x=>x.FEENAME==FEENAME);
if (FeeTemplateDetail != null)
bool isadd = false;
var FindFeeTemplateDetailList = FeeTemplateDetailList.FindAll(x=>x.FEENAME==FEENAME);
if (FindFeeTemplateDetailList != null&& FindFeeTemplateDetailList.Count!=0)
{
if (FeeTemplateDetail.ISCTN)
foreach (var FeeTemplateDetail in FindFeeTemplateDetailList)
{
var addfeelist = new List<MsChFee>();
decimal ttlamount = 0;
foreach (var FeeTemplate in FeeTemplateDetailList)
if (FeeTemplateDetail.ISCTN&&isctnnum==1)
{
var addfeelist = new List<MsChFee>();
decimal ttlamount = 0;
foreach (var FeeTemplate in FindFeeTemplateDetailList)
{
var unit = unitlist.Find(x => x.UNIT == FeeTemplate.UNIT);
if (unit != null)
{
var newfee = new MsChFee();
newfee.FA_ID = returndata.itemUuid;
newfee.Currency = curr;
newfee.CustomerName = FEECUSTNAME;
newfee.BSNO = BSNO;
newfee.ExChangerate = exrate;
newfee.FeeName = FEENAME;
newfee.Quantity = unit.QUANTITY;
newfee.Unit = FeeTemplate.UNIT;
if (FeeTemplate.UNITPRICE == 0)
{
newfee.UnitPrice =Convert.ToDecimal(returndata.totalAmount)/ newfee.Quantity;
}
else
{
newfee.UnitPrice = FeeTemplate.UNITPRICE;
}
newfee.Amount = Convert.ToDecimal(returndata.totalAmount);
newfee.FeeEName = returndata.feeName.Replace("'", "").Replace(",", "").Replace(".", "");
// addfeelist.Add(newfee);
ttlamount = ttlamount + newfee.Amount;
feelist.Add(newfee);
isadd = true;
if (FeeTemplate.FEENAME == FEENAME) {
var unit = unitlist.Find(x=>x.UNIT==FeeTemplate.UNIT);
if (unit != null)
{
var newfee = new MsChFee();
newfee.FA_ID = returndata.itemUuid;
newfee.Currency = curr;
newfee.CustomerName = FEECUSTNAME;
newfee.BSNO = BSNO;
newfee.ExChangerate = exrate;
newfee.FeeName = FEENAME;
newfee.Quantity = unit.QUANTITY;
newfee.Unit = FeeTemplate.UNIT;
newfee.UnitPrice = FeeTemplate.UNITPRICE;
newfee.Amount = newfee.UnitPrice* newfee.Quantity;
newfee.FeeEName = returndata.feeName.Replace("'", "").Replace(",", "").Replace(".", "");
addfeelist.Add(newfee);
ttlamount = ttlamount + newfee.Amount;
}
}
}
//if (ttlamount == Convert.ToDecimal(returndata.totalAmount))
//{
if (ttlamount == Convert.ToDecimal(returndata.totalAmount))
{
foreach (var tmpfee in addfeelist) {
feelist.Add(tmpfee);
}
}
else {
var feeback = new feeback();
feeback.ReceiveId = returndata.bno;
feeback.Success = false;
feeback.Reason = $"提单号:{MBLNO},编号:{BS.BSNO},费用金额:{ttlamount} 未匹配{returndata.totalAmount}";
feebacklist.Add(feeback);
log.Debug($"提单号:{MBLNO},编号:{BS.BSNO},费用金额:{ttlamount} 未匹配{returndata.totalAmount}");
//}
//else
//{
// var feeback = new feeback();
// feeback.ReceiveId = returndata.bno;
// feeback.Success = false;
// feeback.Reason = $"提单号:{MBLNO},编号:{BS.BSNO},费用金额:{ttlamount} 未匹配{returndata.totalAmount}";
// feebacklist.Add(feeback);
// log.Debug($"提单号:{MBLNO},编号:{BS.BSNO},费用金额:{ttlamount} 未匹配{returndata.totalAmount}");
//}
}
else
{
var newfee = new MsChFee();
newfee.FA_ID = returndata.itemUuid;
newfee.Currency = curr;
newfee.CustomerName = FEECUSTNAME;
newfee.BSNO = BSNO;
newfee.ExChangerate = exrate;
newfee.FeeName = FEENAME;
newfee.Quantity = 1;
newfee.Unit = FeeTemplateDetail.UNIT;
newfee.UnitPrice = Convert.ToDecimal(returndata.totalAmount);
newfee.Amount = Convert.ToDecimal(returndata.totalAmount);
newfee.FeeEName = returndata.feeName.Replace("'", "").Replace(",", "").Replace(".", "");
feelist.Add(newfee);
isadd = true;
}
else {
var newfee = new MsChFee();
newfee.FA_ID = returndata.itemUuid;
newfee.Currency = curr;
newfee.CustomerName = FEECUSTNAME;
newfee.BSNO = BSNO;
newfee.ExChangerate = exrate;
newfee.FeeName = FEENAME;
newfee.Quantity = 1;
newfee.Unit = FeeTemplateDetail.UNIT;
newfee.UnitPrice = Convert.ToDecimal(returndata.totalAmount);
newfee.Amount = Convert.ToDecimal(returndata.totalAmount);
newfee.FeeEName = returndata.feeName.Replace("'", "").Replace(",", "").Replace(".", "");
feelist.Add(newfee);
}
}
}
@ -226,7 +247,20 @@ namespace JobCreateFee
newfee.Amount= Convert.ToDecimal(returndata.totalAmount);
newfee.FeeEName = returndata.feeName.Replace("'", "").Replace(",", "").Replace(".", "");
feelist.Add(newfee);
isadd = true;
}
if (!isadd) {
var feeback = new feeback();
feeback.ReceiveId = returndata.bno;
feeback.Success = false;
feeback.Reason = $"提单号:{MBLNO},编号:{BSNO},费用名称:{returndata.feeName} 金额:{returndata.totalAmount}未匹配添加";
feebacklist.Add(feeback);
log.Debug($"提单号:{MBLNO},编号:{BSNO},费用名称:{returndata.feeName} 金额:{returndata.totalAmount} 未匹配添加");
}
}
@ -237,24 +271,12 @@ namespace JobCreateFee
}
//}
}
else
{
var feeback = new feeback();
feeback.ReceiveId = returndata.bno;
feeback.Success = false;
feeback.Reason = "费用状态已锁定 不允许插入费用!";
feebacklist.Add(feeback);
log.Debug($"提单号:{MBLNO},编号:{BS.BSNO},费用状态:{BS.FEESTATUS} 未插入");
}
}
dbcon.Close();
@ -266,25 +288,34 @@ namespace JobCreateFee
log.Debug($"记录插入错误:{e.Message}" + sql);
}
try
{
if (feelist != null && feelist.Count != 0) {
dbcon.Open();
foreach (var fee in feelist) {
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,SETTLEMENT,INVOICE,ORDERAMOUNT,ORDERINVOICE,ORDERSETTLEMENT,ORDERINVSETTLEMENT)";
sql = sql + "VALUES ";
sql = sql + "('" + Guid.NewGuid().ToString() + "','" + fee.BSNO + "',2,'" + fee.FeeName+ "','船公司','" + fee.CustomerName + "','"+fee.Unit+"'";
sql = sql + "," + fee.UnitPrice + "," + fee.Quantity + "," + fee.Amount + ",'" + fee.Currency+ "'," + fee.ExChangerate+ ",'','',0";
sql = sql + ",'" + ENTEROPERATOR + "',GETDATE(),0,0,10," + FEESTATUS + ",'',''";
sql = sql + ",0," + fee.Amount + ",0,0," + fee.UnitPrice + ",'" + ENTEROPERATOR + "',GETDATE(),'',0,0,'COSCO账单回写','RMB','',0,'" + fee.FeeEName + "'";
sql = sql + ",'" + fee.FA_ID+ "',0,0,0,0,0,0)";
// log.Debug($"更新语句:{sql}");
SqlCommand cmd2 = new SqlCommand(sql, dbcon);
cmd2.ExecuteNonQuery();
if (feelist != null && feelist.Count != 0)
{
dbcon.Open();
foreach (var fee in feelist)
{
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,SETTLEMENT,INVOICE,ORDERAMOUNT,ORDERINVOICE,ORDERSETTLEMENT,ORDERINVSETTLEMENT)";
sql = sql + "VALUES ";
sql = sql + "('" + Guid.NewGuid().ToString() + "','" + fee.BSNO + "',2,'" + fee.FeeName + "','船公司','" + fee.CustomerName + "','" + fee.Unit + "'";
sql = sql + "," + fee.UnitPrice + "," + fee.Quantity + "," + fee.Amount + ",'" + fee.Currency + "'," + fee.ExChangerate + ",'','',0";
sql = sql + ",'" + ENTEROPERATOR + "',GETDATE(),0,0,10," + FEESTATUS + ",'',''";
sql = sql + ",0," + fee.Amount + ",0,0," + fee.UnitPrice + ",'" + ENTEROPERATOR + "',GETDATE(),'',0,0,'COSCO账单回写','RMB','',0,'" + fee.FeeEName + "'";
sql = sql + ",'" + fee.FA_ID + "',0,0,0,0,0,0)";
// log.Debug($"更新语句:{sql}");
SqlCommand cmd2 = new SqlCommand(sql, dbcon);
cmd2.ExecuteNonQuery();
}
dbcon.Close();
}
dbcon.Close();
}
catch (Exception ex)
{
log.Debug($"插入费用出错:{ex.Message+sql}");
}
}
@ -499,6 +530,7 @@ namespace JobCreateFee
data.SUNIT = "P-单票";
data.UNIT = "单票";
data.QUANTITY = 1;
data.ISCTN = false;
bodyList.Add(data);
if (row["PKGS"] != DBNull.Value)
PKGS = Convert.ToDecimal(row["PKGS"]);
@ -512,28 +544,33 @@ namespace JobCreateFee
kgsdata.SUNIT = "Z-重量";
kgsdata.UNIT = "重量";
kgsdata.QUANTITY = KGS;
kgsdata.ISCTN = false;
bodyList.Add(kgsdata);
var cbmdata = new MsFeeUnitD7();
cbmdata.SUNIT = "C-尺码";
cbmdata.UNIT = "尺码";
cbmdata.QUANTITY = CBM;
cbmdata.ISCTN = false;
bodyList.Add(cbmdata);
var pkgsdata = new MsFeeUnitD7();
pkgsdata.SUNIT = "J-件数";
pkgsdata.UNIT = "件数";
pkgsdata.QUANTITY = PKGS;
pkgsdata.ISCTN = false;
bodyList.Add(pkgsdata);
var netkgsdata = new MsFeeUnitD7();
netkgsdata.SUNIT = "N-净重";
netkgsdata.UNIT = "净重";
netkgsdata.QUANTITY = NETWEIGHT;
netkgsdata.ISCTN = false;
bodyList.Add(netkgsdata);
var Bdata = new MsFeeUnitD7();
Bdata.SUNIT = "B-BILL";
Bdata.UNIT = "BILL";
Bdata.QUANTITY = 1;
Bdata.ISCTN = false;
bodyList.Add(Bdata);
var ton = KGS / 1000;
@ -545,6 +582,7 @@ namespace JobCreateFee
feetondata.SUNIT = "JF-计费吨";
feetondata.UNIT = "计费吨";
feetondata.QUANTITY = jfd;
feetondata.ISCTN = false;
bodyList.Add(feetondata);
}
else
@ -555,6 +593,7 @@ namespace JobCreateFee
feetondata.SUNIT = "JF-计费吨";
feetondata.UNIT = "计费吨";
feetondata.QUANTITY = jfd;
feetondata.ISCTN = false;
bodyList.Add(feetondata);
}
var jzton = Math.Round(NETWEIGHT / 1000, 3, MidpointRounding.AwayFromZero);
@ -562,6 +601,7 @@ namespace JobCreateFee
feejztondata.SUNIT = "JZD-净重吨";
feejztondata.UNIT = "净重吨";
feejztondata.QUANTITY = jzton;
feejztondata.ISCTN = false;
bodyList.Add(feejztondata);
}
@ -575,6 +615,7 @@ namespace JobCreateFee
CTNNUM = CTNNUM + ctndata.QUANTITY;
if (row["TEU"] != DBNull.Value)
TEUNUM = TEUNUM + Convert.ToDecimal(row["TEU"]);
ctndata.ISCTN = true;
bodyList.Add(ctndata);
}
isfirst = isfirst + 1;
@ -584,36 +625,43 @@ namespace JobCreateFee
teudata.SUNIT = "TEU";
teudata.UNIT = "TEU";
teudata.QUANTITY = TEUNUM;
teudata.ISCTN = false;
bodyList.Add(teudata);
var ctnalldata = new MsFeeUnitD7();
ctnalldata.SUNIT = "自然箱";
ctnalldata.UNIT = "自然箱";
ctnalldata.QUANTITY = CTNNUM;
ctnalldata.ISCTN = false;
bodyList.Add(ctnalldata);
var data9 = new MsFeeUnitD7();
data9.SUNIT = "T-天";
data9.UNIT = "天";
data9.QUANTITY = 0;
data9.ISCTN = false;
bodyList.Add(data9);
var data10 = new MsFeeUnitD7();
data10.SUNIT = "G-个";
data10.UNIT = "个";
data10.QUANTITY = 0;
data10.ISCTN = false;
bodyList.Add(data10);
var data11 = new MsFeeUnitD7();
data11.SUNIT = "S-小时";
data11.UNIT = "小时";
data11.QUANTITY = 0;
data11.ISCTN = false;
bodyList.Add(data11);
var data12 = new MsFeeUnitD7();
data12.SUNIT = "S-票";
data12.UNIT = "票";
data12.QUANTITY = 0;
data12.ISCTN = false;
bodyList.Add(data12);
var data13 = new MsFeeUnitD7();
data13.SUNIT = "D-吨";
data13.UNIT = "吨";
data13.QUANTITY = 0;
data13.ISCTN = false;
bodyList.Add(data13);

@ -90,7 +90,7 @@ namespace JobAutoCreateFee.Model
set { _quantity = value; }
}
public bool ISCTN { get; set; }
}

Loading…
Cancel
Save