JinHanShengHang
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,24 +140,26 @@ 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)
{
if (FeeTemplateDetail.ISCTN&&isctnnum==1)
{
var addfeelist = new List<MsChFee>();
decimal ttlamount = 0;
foreach (var FeeTemplate in FeeTemplateDetailList)
foreach (var FeeTemplate in FindFeeTemplateDetailList)
{
if (FeeTemplate.FEENAME == FEENAME) {
var unit = unitlist.Find(x => x.UNIT == FeeTemplate.UNIT);
if (unit != null)
@ -164,35 +173,44 @@ namespace JobCreateFee
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 = newfee.UnitPrice* newfee.Quantity;
}
newfee.Amount = Convert.ToDecimal(returndata.totalAmount);
newfee.FeeEName = returndata.feeName.Replace("'", "").Replace(",", "").Replace(".", "");
addfeelist.Add(newfee);
// addfeelist.Add(newfee);
ttlamount = ttlamount + newfee.Amount;
}
feelist.Add(newfee);
isadd = true;
}
}
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}");
}
//if (ttlamount == Convert.ToDecimal(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 {
else
{
var newfee = new MsChFee();
newfee.FA_ID = returndata.itemUuid;
@ -207,8 +225,11 @@ namespace JobCreateFee
newfee.Amount = Convert.ToDecimal(returndata.totalAmount);
newfee.FeeEName = returndata.feeName.Replace("'", "").Replace(",", "").Replace(".", "");
feelist.Add(newfee);
isadd = true;
}
}
}
else
@ -226,35 +247,36 @@ 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} 未匹配添加");
}
}
}
}
//}
}
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,10 +288,14 @@ namespace JobCreateFee
log.Debug($"记录插入错误:{e.Message}" + sql);
}
try
{
if (feelist != null && feelist.Count != 0) {
if (feelist != null && feelist.Count != 0)
{
dbcon.Open();
foreach (var fee in feelist) {
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)";
@ -286,6 +312,11 @@ namespace JobCreateFee
}
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