|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data.Entity.Migrations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Common.Helper
|
|
|
|
|
{
|
|
|
|
|
public static class EnumHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取枚举值的description文本
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
/// <param name="strVal"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetDescription(Type type, string strVal)
|
|
|
|
|
{
|
|
|
|
|
System.Reflection.FieldInfo field = type.GetField(strVal);
|
|
|
|
|
if (field != null)
|
|
|
|
|
{
|
|
|
|
|
var attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
|
|
|
|
|
if (attribute != null)
|
|
|
|
|
{
|
|
|
|
|
return attribute.Description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取枚举所有项的名称(name)和显示文本(description)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static Dictionary<string, string> GetEnumList(Type type)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
|
|
foreach (int val in Enum.GetValues(type))
|
|
|
|
|
{
|
|
|
|
|
string strName = Enum.GetName(type, val);//获取名称
|
|
|
|
|
string desp = GetDescription(type, strName);
|
|
|
|
|
dic.Add(strName, desp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dic;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class ModelHelper
|
|
|
|
|
{
|
|
|
|
|
public static ch_fee_md getchfeeHelper() {
|
|
|
|
|
var feeShou = new ch_fee_md();
|
|
|
|
|
//2021-12-31,要求下列字段不能为空,填写0或false
|
|
|
|
|
feeShou.COMMISSIONRATE = 0;
|
|
|
|
|
feeShou.AUDITSTATUS = 0;
|
|
|
|
|
feeShou.LINENUM = 0;
|
|
|
|
|
feeShou.ISDEBIT = false;
|
|
|
|
|
feeShou.ISOPEN = false;
|
|
|
|
|
feeShou.ACCTAXRATE = 0;
|
|
|
|
|
feeShou.ISVOU = false;
|
|
|
|
|
feeShou.TAX = 0;
|
|
|
|
|
feeShou.PREAMOUNT = 0;
|
|
|
|
|
feeShou.ISACC = false;
|
|
|
|
|
feeShou.CUSTDUI = false;
|
|
|
|
|
|
|
|
|
|
feeShou.SETTLEMENT = 0;
|
|
|
|
|
feeShou.ORDERAMOUNT = 0;
|
|
|
|
|
feeShou.ORDERINVOICE = 0;
|
|
|
|
|
feeShou.ORDERINVSETTLEMENT = 0;
|
|
|
|
|
feeShou.ORDERSETTLEMENT = 0;
|
|
|
|
|
feeShou.INVOICE = 0;
|
|
|
|
|
feeShou.TAXRATE = 0;
|
|
|
|
|
feeShou.ISADVANCEDPAY = false;
|
|
|
|
|
feeShou.ISINVOICE = false;
|
|
|
|
|
feeShou.ISCRMORDERFEE = false;
|
|
|
|
|
feeShou.TAXUNITPRICE = 0;//2021-12-29,于菲:同样赋值单价和金额
|
|
|
|
|
feeShou.NOTAXAMOUNT = 0;//2021-12-29,于菲:同样赋值单价和金额
|
|
|
|
|
|
|
|
|
|
return feeShou;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LogHelper
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static void SaveLog(string NAME, string LOGTYPE, string LOGCONTENT, string createuser = "")
|
|
|
|
|
{
|
|
|
|
|
var sys_log = new sys_log_md(NAME, LOGTYPE, LOGCONTENT, createuser);
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
cdc.sys_log.AddOrUpdate(sys_log);
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class DJY_SYNC_BC_Helper
|
|
|
|
|
{
|
|
|
|
|
private static List<string> WorkingBSNOList = new List<string>();
|
|
|
|
|
|
|
|
|
|
private static bool addworking(string BSNO)
|
|
|
|
|
{
|
|
|
|
|
if (WorkingBSNOList.Exists(x => x == BSNO))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void delworking(string BSNO)
|
|
|
|
|
{
|
|
|
|
|
if (WorkingBSNOList.Exists(x => x == BSNO))
|
|
|
|
|
{
|
|
|
|
|
WorkingBSNOList.RemoveAll(x => x == BSNO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Add(DJY_SYNC_BC_md addrec)
|
|
|
|
|
{
|
|
|
|
|
var cando = addworking(addrec.BSNO);
|
|
|
|
|
if (!cando)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
Add(addrec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var currlist = cdc.DJY_SYNC_BC.Where(x => x.BSNO == addrec.BSNO).ToList();
|
|
|
|
|
|
|
|
|
|
if (currlist == null || currlist.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
cdc.DJY_SYNC_BC.Add(addrec);
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (currlist.Exists(x => x.USED == false))
|
|
|
|
|
{
|
|
|
|
|
var updrec = currlist.First(x => x.USED == false);
|
|
|
|
|
updrec.MBLNO = addrec.MBLNO;
|
|
|
|
|
updrec.EDI_TIME = addrec.EDI_TIME;
|
|
|
|
|
updrec.VGM_TIME = addrec.VGM_TIME;
|
|
|
|
|
updrec.VESSEL = addrec.VESSEL;
|
|
|
|
|
updrec.VOYNO = addrec.VOYNO;
|
|
|
|
|
updrec.ATD = addrec.ATD;
|
|
|
|
|
updrec.CARRIER = addrec.CARRIER;
|
|
|
|
|
updrec.TRANSNO = addrec.TRANSNO;
|
|
|
|
|
//updrec.MBLNO = addrec.MBLNO;
|
|
|
|
|
updrec.CREATETIME = addrec.CREATETIME;
|
|
|
|
|
|
|
|
|
|
cdc.DJY_SYNC_BC.AddOrUpdate(updrec);
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cdc.DJY_SYNC_BC.Add(addrec);
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.SaveLog("接收大简云订舱同步信息", "错误", ex.Message, "DS7");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
delworking(addrec.BSNO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UseRecord(DJY_SYNC_BC_md usedRec)
|
|
|
|
|
{
|
|
|
|
|
var cando = addworking(usedRec.BSNO);
|
|
|
|
|
if (!cando)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
UseRecord(usedRec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var currlist = cdc.DJY_SYNC_BC.Where(x => x.GID == usedRec.GID).ToList();
|
|
|
|
|
|
|
|
|
|
if (currlist == null || currlist.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.SaveLog("BC同步操作", "错误", $"未找到GID{usedRec.GID}");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var updrec = currlist.First(x => x.USED == false);
|
|
|
|
|
updrec.USED = true;
|
|
|
|
|
cdc.DJY_SYNC_BC.AddOrUpdate(updrec);
|
|
|
|
|
cdc.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.SaveLog("BC同步操作", "错误", ex.Message, "DS7");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
delworking(usedRec.BSNO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|