wet 2 years ago
parent 4e828380ad
commit 08908007ec

@ -43,7 +43,7 @@ namespace djy.IService.Ams
List<CommonCodeValue> GetVessel(string strlink); List<CommonCodeValue> GetVessel(string strlink);
Task<Response> SendDE(string Gid, User user, string docType); Task<Response> SendDE(string Gid, User user, string docType,string hid);
Response SaveReceipt(string retdto); Response SaveReceipt(string retdto);
@ -59,6 +59,9 @@ namespace djy.IService.Ams
string SaveTemplate(AMS_AddrTemplate dto, User user); string SaveTemplate(AMS_AddrTemplate dto, User user);
List<AMS_AddrTemplate> GetTemplate(User user, string type,string TemPlateName); List<AMS_AddrTemplate> GetTemplate(User user, string type,string TemPlateName);
void DeleteTemplate(string ids);
byte[] PDF(string ids); byte[] PDF(string ids);
} }

@ -54,7 +54,7 @@ namespace djy.IService.Isf
/// <param name="userid"></param> /// <param name="userid"></param>
string SaveTemplate(ISF_CompanyTemplate dto, User user); string SaveTemplate(ISF_CompanyTemplate dto, User user);
void DeleteTemplate(string ids);
/// <summary> /// <summary>
/// 发送接口 /// 发送接口
/// </summary> /// </summary>

@ -138,6 +138,21 @@ namespace djy.Model.Ams
public string NOTIFYPARTYCity { get; set; } public string NOTIFYPARTYCity { get; set; }
public string State { get; set; } public string State { get; set; }
/// <summary>
/// 申报状态
/// </summary>
public string ReportState { get; set; }
/// <summary>
/// 匹配状态
/// </summary>
public string MateState { get; set; }
/// <summary>
/// 最新通知
/// </summary>
public string NewNotice { get; set; }
} }
} }

@ -139,19 +139,6 @@ namespace djy.Model.Ams
/// <summary>
/// 申报状态
/// </summary>
public string ReportState { get; set; }
/// <summary>
/// 匹配状态
/// </summary>
public string MateState { get; set; }
/// <summary>
/// 最新通知
/// </summary>
public string NewNotice { get; set; }
} }
} }

@ -133,20 +133,7 @@ namespace djy.Model.AmsDto
/// 最后一个非美港/中转港Code /// 最后一个非美港/中转港Code
/// </summary> /// </summary>
public string LastNoUsPortCode { get; set; } public string LastNoUsPortCode { get; set; }
/// <summary>
/// 申报状态
/// </summary>
public string ReportState { get; set; }
/// <summary>
/// 匹配状态
/// </summary>
public string MateState { get; set; }
/// <summary>
/// 最新通知
/// </summary>
public string NewNotice { get; set; }
public List<AMS_MasterHistory> HistoryDto { get; set; } public List<AMS_MasterHistory> HistoryDto { get; set; }
@ -282,6 +269,20 @@ namespace djy.Model.AmsDto
/// 通知人城市 /// 通知人城市
/// </summary> /// </summary>
public string NOTIFYPARTYCity { get; set; } public string NOTIFYPARTYCity { get; set; }
/// <summary>
/// 申报状态
/// </summary>
public string ReportState { get; set; }
/// <summary>
/// 匹配状态
/// </summary>
public string MateState { get; set; }
/// <summary>
/// 最新通知
/// </summary>
public string NewNotice { get; set; }
public List<AMS_Cntrno> CntrnoDto { get; set; } public List<AMS_Cntrno> CntrnoDto { get; set; }
} }

@ -56,9 +56,6 @@ namespace djy.Service.Ams
var dto = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>() var dto = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>()
.Where(x => x.IsDel != true && x.CompID == user.CompId) .Where(x => x.IsDel != true && x.CompID == user.CompId)
.WhereIf(req.MBLNO != null, x => x.MBLNO.Contains(req.MBLNO.Trim())) .WhereIf(req.MBLNO != null, x => x.MBLNO.Contains(req.MBLNO.Trim()))
.WhereIf(req.ReportState == "0", x => x.ReportState == "未申报" || x.ReportState == "接收失败")
.WhereIf(req.ReportState == "1", x => !(x.ReportState == "未申报" || x.ReportState == "接收失败"))
.WhereIf(req.ReportState != null && req.ReportState != "0" && req.ReportState != "1", x => ReportStates.Contains(x.ReportState))
.WhereIf(req.PORTDISCHARGECode != null, x => x.PORTDISCHARGECode == req.PORTDISCHARGECode) .WhereIf(req.PORTDISCHARGECode != null, x => x.PORTDISCHARGECode == req.PORTDISCHARGECode)
.WhereIf(req.LoadingPortCode != null, x => x.LoadingPortCode == req.LoadingPortCode) .WhereIf(req.LoadingPortCode != null, x => x.LoadingPortCode == req.LoadingPortCode)
.WhereIf(req.UserName != null, x => x.UserName.Contains(req.UserName.Trim())) .WhereIf(req.UserName != null, x => x.UserName.Contains(req.UserName.Trim()))
@ -76,6 +73,9 @@ namespace djy.Service.Ams
item.HistoryDto = historyDto; item.HistoryDto = historyDto;
var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == item.GID) var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == item.GID)
.WhereIf(req.HBLNo != null, x => x.HBLNo.Contains(req.HBLNo.Trim())) .WhereIf(req.HBLNo != null, x => x.HBLNo.Contains(req.HBLNo.Trim()))
.WhereIf(req.ReportState == "0", x => x.ReportState == "未申报" || x.ReportState == "接收失败")
.WhereIf(req.ReportState == "1", x => !(x.ReportState == "未申报" || x.ReportState == "接收失败"))
.WhereIf(req.ReportState != null && req.ReportState != "0" && req.ReportState != "1", x => ReportStates.Contains(x.ReportState))
.ToList<AMS_HouseDto>(); .ToList<AMS_HouseDto>();
item.HouseDto = hodto; item.HouseDto = hodto;
if (hodto != null) if (hodto != null)
@ -136,7 +136,6 @@ namespace djy.Service.Ams
{ {
return "-1"; return "-1";
} }
if (dto.GID.IsNull()) if (dto.GID.IsNull())
{ {
DbBus.Get(DbList.AMSCenter).Transaction(() => DbBus.Get(DbList.AMSCenter).Transaction(() =>
@ -149,7 +148,6 @@ namespace djy.Service.Ams
master.CompID = user.CompId; master.CompID = user.CompId;
master.CompName = user.COMNAME; master.CompName = user.COMNAME;
master.IsDel = false; master.IsDel = false;
master.ReportState = "未申报";
master.PORTDISCHARGE = DbBus.Get(DbList.Common).Select<CodePort>().Where(x => x.Code == master.PORTDISCHARGECode).ToList().Select(x => x.EnName).FirstOrDefault(); master.PORTDISCHARGE = DbBus.Get(DbList.Common).Select<CodePort>().Where(x => x.Code == master.PORTDISCHARGECode).ToList().Select(x => x.EnName).FirstOrDefault();
master.CARRIER = DbBus.Get(DbList.Common).Select<CodeCarrier>().Where(x => x.Code == master.CARRIERID).ToList().Select(x => x.EnName).FirstOrDefault(); master.CARRIER = DbBus.Get(DbList.Common).Select<CodeCarrier>().Where(x => x.Code == master.CARRIERID).ToList().Select(x => x.EnName).FirstOrDefault();
master.LoadingPort = DbBus.Get(DbList.Common).Select<CodePortLoad>().Where(x => x.EdiCode == master.LoadingPortCode).ToList().Select(x => x.EnName).FirstOrDefault(); master.LoadingPort = DbBus.Get(DbList.Common).Select<CodePortLoad>().Where(x => x.EdiCode == master.LoadingPortCode).ToList().Select(x => x.EnName).FirstOrDefault();
@ -180,7 +178,7 @@ namespace djy.Service.Ams
house.PID = master.GID; house.PID = master.GID;
house.IsDel = false; house.IsDel = false;
house.State = "0"; house.State = "0";
house.ReportState = "未申报";
DbBus.Get(DbList.AMSCenter).Insert(house).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(house).ExecuteAffrows();
if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0) if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0)
{ {
@ -205,7 +203,143 @@ namespace djy.Service.Ams
} }
else else
{ {
DbBus.Get(DbList.AMSCenter).Transaction(() => if (dto.HouseDto[0].ReportState == "未申报")
{
DbBus.Get(DbList.AMSCenter).Transaction(() =>
{
var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(w => w.GID == dto.GID).ToOne();
master.CARRIERID = dto.CARRIERID;
master.MBLNO = dto.MBLNO;
master.VESSEL = dto.VESSEL;
master.VOYNO = dto.VOYNO;
master.ShippingType = dto.ShippingType;
master.SHIPPERADDR = dto.SHIPPERADDR;
master.ETA = dto.ETA;
master.ETD = dto.ETD;
master.LastUpdate = DateTime.Now;
master.ShippingNo = dto.ShippingNo;
master.ConsignmentType = dto.ConsignmentType;
master.LoadingPortCode = dto.LoadingPortCode;
master.PORTDISCHARGECode = dto.PORTDISCHARGECode;
master.LastNoUsPortCode = dto.LastNoUsPortCode;
master.PORTDISCHARGE = DbBus.Get(DbList.Common).Select<CodePort>().Where(x => x.Code == master.PORTDISCHARGECode).ToList().Select(x => x.EnName).FirstOrDefault();
master.CARRIER = DbBus.Get(DbList.Common).Select<CodeCarrier>().Where(x => x.Code == master.CARRIERID).ToList().Select(x => x.EnName).FirstOrDefault();
master.LoadingPort = DbBus.Get(DbList.Common).Select<CodePortLoad>().Where(x => x.EdiCode == master.LoadingPortCode).ToList().Select(x => x.EnName).FirstOrDefault();
master.LastNoUsPort = DbBus.Get(DbList.Common).Select<CodePort>().Where(x => x.Code == master.LastNoUsPortCode).ToList().Select(x => x.EnName).FirstOrDefault();
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().SetSource(master).ExecuteAffrows();
List<string> houseid = dto.HouseDto.Select(x => x.GID).ToList();
DbBus.Get(DbList.AMSCenter).Delete<AMS_House>().Where(w => w.PID == master.GID && !houseid.Contains(w.GID)).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Delete<AMS_Cntrno>().Where(w => w.PID == master.GID && !houseid.Contains(w.HID)).ExecuteAffrows();
foreach (var item in dto.HouseDto)
{
var house = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(w => w.GID == item.GID).ToOne();
if (house != null)
{
house.HBLNo = item.HBLNo;
house.SHIPPERNAME = item.SHIPPERNAME;
house.SHIPPERADDR = item.SHIPPERADDR;
house.SHIPPERTEL = item.SHIPPERTEL;
house.CONSIGNEEName = item.CONSIGNEEName;
house.CONSIGNEEDADDR = item.CONSIGNEEDADDR;
house.CONSIGNEETEL = item.CONSIGNEETEL;
house.NOTIFYPARTYNAME = item.NOTIFYPARTYNAME;
house.NOTIFYPARTYADDR = item.NOTIFYPARTYADDR;
house.NOTIFYPARTYTEL = item.NOTIFYPARTYTEL;
house.SHIPPERCountry = item.SHIPPERCountry;
house.SHIPPERCountryCode = item.SHIPPERCountryCode;
house.SHIPPERCity = item.SHIPPERCity;
house.CONSIGNEECountry = item.CONSIGNEECountry;
house.CONSIGNEECountryCode = item.CONSIGNEECountryCode;
house.CONSIGNEECity = item.CONSIGNEECity;
house.NOTIFYPARTYCountry = item.NOTIFYPARTYCountry;
house.NOTIFYPARTYCountryCode = item.NOTIFYPARTYCountryCode;
house.NOTIFYPARTYCity = item.NOTIFYPARTYCity;
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().SetSource(house).ExecuteAffrows();
if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0)
{
foreach (var it in item.CntrnoDto)
{
var cntrno = DbBus.Get(DbList.AMSCenter).Select<AMS_Cntrno>().Where(w => w.GID == it.GID).ToOne();
if (cntrno != null)
{
cntrno.CNTRNO = it.CNTRNO;
cntrno.SEALNO = it.SEALNO;
cntrno.CTNALL = it.CTNALL;
cntrno.HSCode = it.HSCode;
cntrno.ProductName = it.ProductName;
cntrno.MARKS = it.MARKS;
cntrno.PKGS = it.PKGS;
cntrno.KINDPKGS = it.KINDPKGS;
cntrno.KGS = it.KGS;
cntrno.CBM = it.CBM;
cntrno.DUNNO = it.DUNNO;
cntrno.LINKMAN = it.LINKMAN;
cntrno.KINDPKGSCode = it.KINDPKGSCode;
cntrno.OriginCountry = it.OriginCountry;
cntrno.OriginCountryCode = it.OriginCountryCode;
cntrno.LINKMANTel = it.LINKMANTel;
cntrno.DangerGrade = it.DangerGrade;
DbBus.Get(DbList.AMSCenter).Update<AMS_Cntrno>().SetSource(cntrno).ExecuteAffrows();
}
else
{
cntrno = it.MapTo<AMS_Cntrno>();
cntrno.GID = Guid.NewGuid().ToString("N");
cntrno.PID = master.GID;
cntrno.HID = house.GID;
cntrno.IsDel = false;
DbBus.Get(DbList.AMSCenter).Insert(cntrno).ExecuteAffrows();
}
}
}
}
else
{
house = item.MapTo<AMS_House>();
house.GID = Guid.NewGuid().ToString("N");
house.PID = master.GID;
house.IsDel = false;
house.State = "0";
house.ReportState = "未申报";
DbBus.Get(DbList.AMSCenter).Insert(house).ExecuteAffrows();
if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0)
{
foreach (var it in item.CntrnoDto)
{
AMS_Cntrno cntrno = it.MapTo<AMS_Cntrno>();
cntrno.GID = Guid.NewGuid().ToString("N");
cntrno.PID = master.GID;
cntrno.HID = house.GID;
cntrno.IsDel = false;
DbBus.Get(DbList.AMSCenter).Insert(cntrno).ExecuteAffrows();
}
}
}
}
AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID;
history.SendTime = DateTime.Now;
history.State = "已修改";
history.Type = "修改";
history.Operator = user.SHOWNAME;
history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "修改了单据";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
guid = master.GID;
});
}
else
{
DbBus.Get(DbList.AMSCenter).Transaction(() =>
{ {
var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(w => w.GID == dto.GID).ToOne(); var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(w => w.GID == dto.GID).ToOne();
master.CARRIERID = dto.CARRIERID; master.CARRIERID = dto.CARRIERID;
@ -227,12 +361,9 @@ namespace djy.Service.Ams
master.LoadingPort = DbBus.Get(DbList.Common).Select<CodePortLoad>().Where(x => x.EdiCode == master.LoadingPortCode).ToList().Select(x => x.EnName).FirstOrDefault(); master.LoadingPort = DbBus.Get(DbList.Common).Select<CodePortLoad>().Where(x => x.EdiCode == master.LoadingPortCode).ToList().Select(x => x.EnName).FirstOrDefault();
master.LastNoUsPort = DbBus.Get(DbList.Common).Select<CodePort>().Where(x => x.Code == master.LastNoUsPortCode).ToList().Select(x => x.EnName).FirstOrDefault(); master.LastNoUsPort = DbBus.Get(DbList.Common).Select<CodePort>().Where(x => x.Code == master.LastNoUsPortCode).ToList().Select(x => x.EnName).FirstOrDefault();
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().SetSource(master).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().SetSource(master).ExecuteAffrows();
#region 注释掉原有编辑逻辑
//DbBus.Get(DbList.AMSCenter).Delete<AMS_House>().Where(w => w.PID == master.GID).ExecuteAffrows(); List<string> houseid = dto.HouseDto.Select(x => x.GID).ToList();
//DbBus.Get(DbList.AMSCenter).Delete<AMS_Cntrno>().Where(w => w.PID == master.GID).ExecuteAffrows();
#endregion
foreach (var item in dto.HouseDto) foreach (var item in dto.HouseDto)
{ {
var house = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(w => w.GID == item.GID).ToOne(); var house = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(w => w.GID == item.GID).ToOne();
@ -294,35 +425,8 @@ namespace djy.Service.Ams
} }
} }
} }
else {
house = item.MapTo<AMS_House>();
house.GID = Guid.NewGuid().ToString("N");
house.PID = master.GID;
house.IsDel = false;
house.State = "0";
DbBus.Get(DbList.AMSCenter).Insert(house).ExecuteAffrows();
if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0)
{
foreach (var it in item.CntrnoDto)
{
AMS_Cntrno cntrno = it.MapTo<AMS_Cntrno>();
cntrno.GID = Guid.NewGuid().ToString("N");
cntrno.PID = master.GID;
cntrno.HID = house.GID;
cntrno.IsDel = false;
DbBus.Get(DbList.AMSCenter).Insert(cntrno).ExecuteAffrows();
}
}
}
} }
AMS_MasterHistory history = new AMS_MasterHistory(); AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID; history.AM_ID = master.GID;
@ -332,41 +436,16 @@ namespace djy.Service.Ams
history.Operator = user.SHOWNAME; history.Operator = user.SHOWNAME;
history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "修改了单据"; history.Remark = user.SHOWNAME + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "修改了单据";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
#region 注释掉原有编辑逻辑
//if (dto.HouseDto != null && dto.HouseDto.Count() > 0)
//{
// foreach (var item in dto.HouseDto)
// {
// AMS_House house = item.MapTo<AMS_House>();
// house.GID = Guid.NewGuid().ToString("N");
// house.PID = master.GID;
// house.IsDel = false;
// house.State = "0";
// DbBus.Get(DbList.AMSCenter).Insert(house).ExecuteAffrows();
// if (item.CntrnoDto != null && item.CntrnoDto.Count() > 0)
// {
// foreach (var it in item.CntrnoDto)
// {
// AMS_Cntrno cntrno = it.MapTo<AMS_Cntrno>();
// cntrno.GID = Guid.NewGuid().ToString("N");
// cntrno.PID = master.GID;
// cntrno.HID = house.GID;
// cntrno.IsDel = false;
// DbBus.Get(DbList.AMSCenter).Insert(cntrno).ExecuteAffrows();
// }
// }
// }
//}
#endregion
guid = master.GID; guid = master.GID;
}); });
}
return guid; return guid;
} }
} }
#endregion #endregion
#region 第三方接口 #region 第三方接口
/// <summary> /// <summary>
/// 发送接口 /// 发送接口
@ -374,29 +453,165 @@ namespace djy.Service.Ams
/// <param name="Gid"></param> /// <param name="Gid"></param>
/// <param name="userid"></param> /// <param name="userid"></param>
/// <param name="docType"></param> /// <param name="docType"></param>
public async Task<Response> SendDE(string Gid, User user , string docType) public async Task<Response> SendDE(string Gid, User user , string docType, string hid = null)
{ {
Response req = new Response(); Response req = new Response();
try try
{ {
string[] id = Gid.Split(','); string[] id = Gid.Split(',');
string[] House = null;
if (hid != null) {
House = hid.Split(',');
}
foreach (string oid in id) foreach (string oid in id)
{ {
if (oid != "") if (oid != "")
{ {
var docContent = ""; var docContent = "";
var fin = new FinanceService(); var fin = new FinanceService();
var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(x =>x.IsDel != true && x.CompID == user.CompId && x.GID == oid).ToOne(); var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(x =>x.IsDel != true && x.CompID == user.CompId && x.GID == oid).ToOne();
var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == oid && x.State == "0").ToList<AMS_HouseDto>(); var hodto = new List<AMS_HouseDto>();
if (docType != "AMSD")
if (docType == "AMSDOC")
{ {
#region docContent 新增 重发 修改 hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == oid && x.State == "0").
ToList<AMS_HouseDto>();
#region docContent 新增
if (docType == "AMSAR" && !(master.ReportState == "删单成功" || master.MateState == "接收失败")) var cARRIERIDList = DbBus.Get(DbList.Common).Select<MappingCarrier>().Where(map => map.Module == "AMS").ToList();
var portList = DbBus.Get(DbList.Common).Select<CodePort>().ToList();
var containerTypeList = DbBus.Get(DbList.Common).Select<MappingCtn>().Where(map => map.Module == "AMS").ToList();
var packageList = DbBus.Get(DbList.Common).Select<MappingPackage>().Where(map => map.Module == "AMS").ToList();
MasterBillInfoDto dto = new MasterBillInfoDto();
masterBillInfo masterBillInfo = new masterBillInfo();
masterBillInfo.masterBillNo = cARRIERIDList.Where(x => x.Code == master.CARRIERID).Select(x => x.MapCode).FirstOrDefault() + master.MBLNO;
masterBillInfo.shippingNo = null;
masterBillInfo.shipCompany = cARRIERIDList.Where(x => x.Code == master.CARRIERID).Select(x => x.MapCode).FirstOrDefault();
masterBillInfo.vessel = master.VESSEL;
masterBillInfo.voyage = master.VOYNO;
masterBillInfo.requesterDea = sysOptionConfig.Webconfig.requesterDea;
masterBillInfo.consignmentType = master.ConsignmentType;
masterBillInfo.loadHarbour = master.LoadingPort;
masterBillInfo.loadHarbourCode = master.LoadingPortCode;
masterBillInfo.dischargeHarbour = master.PORTDISCHARGE;
masterBillInfo.dischargeHarbourCode = portList.Where(x => x.Code == master.PORTDISCHARGECode).Select(x => x.EdiCode).FirstOrDefault();
masterBillInfo.lastForeignHarbour = master.LastNoUsPort;
masterBillInfo.lastForeignHarbourCode = portList.Where(x => x.Code == master.LastNoUsPortCode).Select(x => x.EdiCode).FirstOrDefault();
masterBillInfo.loadDate = Convert.ToDateTime(master.ETA).ToString("yyyy-MM-dd hh:mm:ss");
masterBillInfo.estimatedArrivalTime = Convert.ToDateTime(master.ETD).ToString("yyyy-MM-dd hh:mm:ss");
masterBillInfo.filingType = master.ShippingType;
dto.masterBillInfo = masterBillInfo;
List<HouseBillInfoListItem> houseBillInfoListItems = new List<HouseBillInfoListItem>();
foreach (var item in hodto)
{ {
var getfinrs = fin.Expend(new CustFee
{
ETD = master.ETD,
VOYNO = master.VOYNO,
VESSEL = master.VESSEL,
HBLNO = item.HBLNo,
SENDUSERID = user.GID,
LURURENID = user.GID,
CtnrCount = 1,
CtnrInfo = string.Empty,
BSTYPE = 15,
SENDTYPE = 0,
BSNO = oid.ToString(),
MBLNO = master.MBLNO.ToString(),
}
, 0);
if (!getfinrs.Status)
{
req.Code = 201;
req.Message = getfinrs.Message;
return req;
}
HouseBillInfoListItem houseinfo = new HouseBillInfoListItem();
houseinfo.businessId = item.GID;
houseinfo.shippingNo = null;
houseinfo.houseBillNo = item.HBLNo;
houseinfo.sendAddress = item.SHIPPERADDR;
houseinfo.sendName = item.SHIPPERNAME;
houseinfo.sendCity = item.SHIPPERCity;
houseinfo.sendCountry = item.SHIPPERCountry;
houseinfo.sendCountryCode = item.SHIPPERCountryCode;
houseinfo.receiveAddress = item.CONSIGNEEDADDR;
houseinfo.receiveName = item.CONSIGNEEName;
houseinfo.receiveCity = item.CONSIGNEECity;
houseinfo.receiveCountry = item.CONSIGNEECountry;
houseinfo.receiveCountryCode = item.CONSIGNEECountryCode;
houseinfo.notifyAddress = item.NOTIFYPARTYADDR;
houseinfo.notifyName = item.NOTIFYPARTYNAME;
houseinfo.notifyCity = item.NOTIFYPARTYCity;
houseinfo.notifyCountry = item.NOTIFYPARTYCountry;
houseinfo.notifyCountryCode = item.NOTIFYPARTYCountryCode;
var cnt = DbBus.Get(DbList.AMSCenter).Select<AMS_Cntrno>().Where(x => (x.IsDel == false || x.IsDel == null) && x.HID == item.GID).ToList();
CtnInfo CtnInfo = new CtnInfo();
List<InsertListItem> list = new List<InsertListItem>();
foreach (var it in cnt)
{
InsertListItem insertList = new InsertListItem();
insertList.containerMark = null;
insertList.containerType = containerTypeList.Where(x => x.Code == it.CTNALL).Select(x => x.MapCode).FirstOrDefault();
insertList.enProductName = it.ProductName;
insertList.containerNo = it.CNTRNO;
insertList.sealNo = it.SEALNO;
insertList.digit = it.PKGS.ToString();
insertList.grossWeight = it.KGS.ToString();
insertList.volume = it.CBM.ToString();
insertList.packing = packageList.Where(x => x.Code == it.KINDPKGSCode).Select(x => x.MapName).FirstOrDefault();
insertList.packingCode = packageList.Where(x => x.Code == it.KINDPKGSCode).Select(x => x.MapCode).FirstOrDefault();
insertList.shippingMark = it.MARKS;
insertList.secondSealNo = null;
insertList.originCountry = "CHINA";
insertList.originCountryCode = "CN";
insertList.unCode = it.DUNNO;
insertList.dangerGrade = it.DangerGrade;
insertList.dangerContact = "";
insertList.dangerContactTel = "";
insertList.dangerMemo = "";
insertList.ignite = "";
list.Add(insertList);
CtnInfo.insertList = list;
}
houseinfo.ctnInfo = CtnInfo;
houseBillInfoListItems.Add(houseinfo);
}
dto.houseBillInfoList = houseBillInfoListItems;
var data = JsonConvert.SerializeObject(dto);
AMSDocContent aMSDoc = new AMSDocContent();
aMSDoc.fromdea = "n";
aMSDoc.todea = "n";
aMSDoc.editype = "AMSDOC";
aMSDoc.port = "Ningbo";
aMSDoc.masterBillInfo = dto;
docContent = JsonConvert.SerializeObject(aMSDoc);
docContent = JsonConvert.SerializeObject(aMSDoc).ToBase64();
#endregion
}
else if (docType == "AMSAR" || docType == "AMSM") {
hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == oid && x.State == "1").
WhereIf(hid != null, x => House.Contains(x.GID)).
ToList<AMS_HouseDto>();
#region docContent 修改 重发
if (string.IsNullOrEmpty(hid))
{
req.Code = 201; req.Code = 201;
req.Message = "当前状态不能重发!如有疑问,请联系相关客服!"; req.Message = "没有相关货代提单号id";
return req; return req;
} }
var cARRIERIDList = DbBus.Get(DbList.Common).Select<MappingCarrier>().Where(map => map.Module == "AMS").ToList(); var cARRIERIDList = DbBus.Get(DbList.Common).Select<MappingCarrier>().Where(map => map.Module == "AMS").ToList();
@ -426,14 +641,21 @@ namespace djy.Service.Ams
List<HouseBillInfoListItem> houseBillInfoListItems = new List<HouseBillInfoListItem>(); List<HouseBillInfoListItem> houseBillInfoListItems = new List<HouseBillInfoListItem>();
foreach (var item in hodto) foreach (var item in hodto)
{ {
if (docType == "AMSAR" || docType == "AMSDOC") if (docType == "AMSAR" && !(item.ReportState == "删单成功" || item.MateState == "接收失败"))
{
req.Code = 201;
req.Message = "当前状态不能重发!如有疑问,请联系相关客服!";
return req;
}
if (docType == "AMSAR")
{ {
var getfinrs = fin.Expend(new CustFee var getfinrs = fin.Expend(new CustFee
{ {
ETD=master.ETD, ETD = master.ETD,
VOYNO =master.VOYNO, VOYNO = master.VOYNO,
VESSEL =master.VESSEL, VESSEL = master.VESSEL,
HBLNO=item.HBLNo, HBLNO = item.HBLNo,
SENDUSERID = user.GID, SENDUSERID = user.GID,
LURURENID = user.GID, LURURENID = user.GID,
CtnrCount = 1, CtnrCount = 1,
@ -470,7 +692,7 @@ namespace djy.Service.Ams
houseinfo.notifyCity = item.NOTIFYPARTYCity; houseinfo.notifyCity = item.NOTIFYPARTYCity;
houseinfo.notifyCountry = item.NOTIFYPARTYCountry; houseinfo.notifyCountry = item.NOTIFYPARTYCountry;
houseinfo.notifyCountryCode = item.NOTIFYPARTYCountryCode; houseinfo.notifyCountryCode = item.NOTIFYPARTYCountryCode;
var cnt = DbBus.Get(DbList.AMSCenter).Select<AMS_Cntrno>().Where(x => (x.IsDel == false || x.IsDel == null) && x.HID == item.GID).ToList(); var cnt = DbBus.Get(DbList.AMSCenter).Select<AMS_Cntrno>().Where(x => x.IsDel!=true && x.HID == item.GID).ToList();
CtnInfo CtnInfo = new CtnInfo(); CtnInfo CtnInfo = new CtnInfo();
List<InsertListItem> list = new List<InsertListItem>(); List<InsertListItem> list = new List<InsertListItem>();
foreach (var it in cnt) foreach (var it in cnt)
@ -517,18 +739,32 @@ namespace djy.Service.Ams
docContent = JsonConvert.SerializeObject(aMSDoc).ToBase64(); docContent = JsonConvert.SerializeObject(aMSDoc).ToBase64();
#endregion #endregion
} }
else else
{ {
if (master.ReportState == "删单成功") hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == oid && x.State == "1").
WhereIf(hid != null, x => House.Contains(x.GID)).
ToList<AMS_HouseDto>();
foreach (var item in hodto)
{ {
if (item.ReportState == "删单成功")
{
req.Code = 201;
req.Message = "已删除单据不可以再次删除";
return req;
}
}
if (string.IsNullOrEmpty(hid))
{
req.Code = 201; req.Code = 201;
req.Message = "已删除单据不可以再次删除"; req.Message = "没有相关货代提单号id";
return req; return req;
} }
AMSDDto aMSDDto = new AMSDDto(); AMSDDto aMSDDto = new AMSDDto();
aMSDDto.fromdea = "n"; aMSDDto.fromdea = "n";
aMSDDto.ids = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel!=true && x.PID == oid).ToList().Select(x => x.GID).ToList(); aMSDDto.ids = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == oid && House.Contains(x.GID)).ToList().Select(x => x.GID).ToList();
docContent = JsonConvert.SerializeObject(aMSDDto).ToBase64(); docContent = JsonConvert.SerializeObject(aMSDDto).ToBase64();
} }
@ -641,7 +877,7 @@ namespace djy.Service.Ams
if (docType == "AMSDOC") if (docType == "AMSDOC")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { ReportState = "已提交", NewNotice = "新增发送成功" }).Where(w => w.GID == oid).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { ReportState = "已提交", NewNotice = "新增发送成功" }).Where(w => w.PID == oid).ExecuteAffrows();
foreach (var item in hodto) foreach (var item in hodto)
{ {
var getfinrs = fin.Expend(new CustFee var getfinrs = fin.Expend(new CustFee
@ -665,7 +901,7 @@ namespace djy.Service.Ams
else if (docType == "AMSAR") else if (docType == "AMSAR")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { ReportState = "已提交", NewNotice = "重发发送成功" }).Where(w => w.GID == oid).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { ReportState = "已提交", NewNotice = "重发发送成功" }).Where(w => House.Contains(w.GID)).ExecuteAffrows();
foreach (var item in hodto) foreach (var item in hodto)
{ {
var getfinrs = fin.Expend(new CustFee var getfinrs = fin.Expend(new CustFee
@ -688,12 +924,12 @@ namespace djy.Service.Ams
} }
else if (docType == "AMSM") else if (docType == "AMSM")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { ReportState = "已提交", NewNotice = "修改发送成功" }).Where(w => w.GID == oid).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { ReportState = "已提交", NewNotice = "修改发送成功" }).Where(w => House.Contains(w.GID)).ExecuteAffrows();
} }
else else
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { ReportState = "已提交", NewNotice = "删除发送成功" }).Where(w => w.GID == oid).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { ReportState = "已提交", NewNotice = "删除发送成功" }).Where(w => House.Contains(w.GID)).ExecuteAffrows();
} }
} }
@ -725,134 +961,133 @@ namespace djy.Service.Ams
_LogsAdd("SaveReceipt", "post", $"AMS接口推送{msg}"); _LogsAdd("SaveReceipt", "post", $"AMS接口推送{msg}");
if (retdto != null) if (retdto != null)
{ {
var masterid = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.GID == retdto.businessId).ToList().Select(x => x.PID).FirstOrDefault(); var masterid = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.GID == retdto.businessId).ToList().Select(x => x.PID).FirstOrDefault();
var master = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(x => x.GID == masterid).ToOne(); var house = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.GID == retdto.businessId).ToOne();
if (retdto.status == "W2") if (retdto.status == "W2")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "0" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "1" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
var houses = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == master.GID && x.State != "1").ToList();
if (houses != null && houses.Count == 0) if (house != null)
{ {
AMS_MasterHistory history = new AMS_MasterHistory(); AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID; history.AM_ID = masterid;
history.SendTime = DateTime.Now; history.SendTime = DateTime.Now;
history.State = "匹配成功"; history.State = "匹配成功";
history.Type = "匹配成功"; history.Type = "匹配成功";
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关接收成功"; history.Remark = "您的单据" + house.HBLNo + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关接收成功";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
if (master.NewNotice == "删除发送成功") if (house.NewNotice == "删除发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关接收成功", ReportState = "删单成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "海关接收成功", ReportState = "删单成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "修改发送成功") if (house.NewNotice == "修改发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关接收成功", ReportState = "修改成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "海关接收成功", ReportState = "修改成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功") if (house.NewNotice == "重发发送成功" || house.NewNotice == "新增发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关接收成功", ReportState = "接收成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "海关接收成功", ReportState = "接收成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
} }
var faillist = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == master.GID && x.State == "0").ToList();
} }
else if (retdto.status == "1Y") else if (retdto.status == "1Y")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "0" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "1" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
var houses = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == master.GID && x.State != "1").ToList(); if (house != null )
if (houses != null && houses.Count == 0)
{ {
AMS_MasterHistory history = new AMS_MasterHistory(); AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID; history.AM_ID = masterid;
history.SendTime = DateTime.Now; history.SendTime = DateTime.Now;
history.State = "匹配成功"; history.State = "匹配成功";
history.Type = "匹配成功"; history.Type = "匹配成功";
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "船司匹配成功"; history.Remark = "您的单据"+house.HBLNo+"于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "船司匹配成功";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
if (master.NewNotice == "删除发送成功") if (house.NewNotice == "删除发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "船司匹配成功", ReportState = "删单成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "船司匹配成功", ReportState = "删单成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "修改发送成功") if (house.NewNotice == "修改发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "船司匹配成功", ReportState = "修改成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "船司匹配成功", ReportState = "修改成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功") if (house.NewNotice == "重发发送成功" || house.NewNotice == "新增发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "船司匹配成功", ReportState = "接收成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "船司匹配成功", ReportState = "接收成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
} }
var faillist = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == master.GID && x.State == "0").ToList();
} }
else if (retdto.status == "3Z") else if (retdto.status == "3Z")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "0" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "1" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
var houses = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == master.GID && x.State != "1").ToList();
if (houses != null && houses.Count == 0) if (house != null )
{ {
AMS_MasterHistory history = new AMS_MasterHistory(); AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID; history.AM_ID = masterid;
history.SendTime = DateTime.Now; history.SendTime = DateTime.Now;
history.State = "匹配成功"; history.State = "匹配成功";
history.Type = "匹配成功"; history.Type = "匹配成功";
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "ISF匹配成功"; history.Remark = "您的单据"+house.HBLNo+"于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "ISF匹配成功";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
if (master.NewNotice == "删除发送成功") if (house.NewNotice == "删除发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "ISF匹配成功", ReportState = "删单成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "ISF匹配成功", ReportState = "删单成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "修改发送成功") if (house.NewNotice == "修改发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "ISF匹配成功", ReportState = "修改成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "ISF匹配成功", ReportState = "修改成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功") if (house.NewNotice == "重发发送成功" || house.NewNotice == "新增发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "ISF匹配成功", ReportState = "接收成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "ISF匹配成功", ReportState = "接收成功" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
} }
var faillist = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => (x.IsDel == false || x.IsDel == null) && x.PID == master.GID && x.State == "0").ToList(); var faillist = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == masterid && x.State == "0").ToList();
} }
else if (retdto.status == "W1") else if (retdto.status == "W1")
{ {
AMS_MasterHistory history = new AMS_MasterHistory(); AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID; history.AM_ID = masterid;
history.SendTime = DateTime.Now; history.SendTime = DateTime.Now;
history.State = "匹配失败"; history.State = "匹配失败";
history.Type = "匹配失败"; history.Type = "匹配失败";
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的明细单据" + retdto.businessId + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关拒绝"; history.Remark = "您的单据"+house.HBLNo+"于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关拒绝";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "1" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
if (master.NewNotice == "删除发送成功") if (house.NewNotice == "删除发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "删单失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "修改发送成功") if (house.NewNotice == "修改发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "修改失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "修改失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功") if (house.NewNotice == "重发发送成功" || house.NewNotice == "新增发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "接收失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "接收失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
} }
@ -860,57 +1095,57 @@ namespace djy.Service.Ams
{ {
AMS_MasterHistory history = new AMS_MasterHistory(); AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID; history.AM_ID = masterid;
history.SendTime = DateTime.Now; history.SendTime = DateTime.Now;
history.State = "匹配失败"; history.State = "匹配失败";
history.Type = "匹配失败"; history.Type = "匹配失败";
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的明细单据" + retdto.businessId + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "箱货信息不匹配"; history.Remark = "您的单据" + house.HBLNo+ "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "箱货信息不匹配";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "1" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
if (master.NewNotice == "删除发送成功") if (house.NewNotice == "删除发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "箱货信息不匹配", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "箱货信息不匹配", ReportState = "删单失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "修改发送成功") if (house.NewNotice == "修改发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "箱货信息不匹配", ReportState = "修改失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "箱货信息不匹配", ReportState = "修改失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功") if (house.NewNotice == "重发发送成功" || house.NewNotice == "新增发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "箱货信息不匹配", ReportState = "接收失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "箱货信息不匹配", ReportState = "接收失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
} }
else else
{ {
AMS_MasterHistory history = new AMS_MasterHistory(); AMS_MasterHistory history = new AMS_MasterHistory();
history.GID = Guid.NewGuid().ToString("N"); history.GID = Guid.NewGuid().ToString("N");
history.AM_ID = master.GID; history.AM_ID = masterid;
history.SendTime = DateTime.Now; history.SendTime = DateTime.Now;
history.State = "匹配失败"; history.State = "匹配失败";
history.Type = "匹配失败"; history.Type = "匹配失败";
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的明细单据" + retdto.businessId + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "失败"; history.Remark = "您的单据" + house.HBLNo+ "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "匹配失败";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { State = "1" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
if (master.NewNotice == "删除发送成功") if (house.NewNotice == "删除发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "删单失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "修改发送成功") if (house.NewNotice == "修改发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "修改失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "修改失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功") if (house.NewNotice == "重发发送成功" || house.NewNotice == "新增发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<AMS_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "接收失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<AMS_House>().Set(w => new AMS_House { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "接收失败" }).Where(w => w.GID == retdto.businessId).ExecuteAffrows();
} }
} }
@ -1310,5 +1545,28 @@ namespace djy.Service.Ams
} }
#endregion #endregion
#region 删除模板
public void DeleteTemplate(string ids)
{
string[] id = ids.Split(',');
DbBus.Get(DbList.AMSCenter).Transaction(() =>
{
foreach (string oid in id)
{
if (oid != "")
{
DbBus.Get(DbList.AMSCenter).Transaction(() =>
{
DbBus.Get(DbList.AMSCenter).Delete<AMS_AddrTemplate>().Where(w => w.GID == oid).ExecuteAffrows();
});
}
}
});
}
#endregion
} }
} }

@ -253,6 +253,28 @@ namespace djy.Service.Isf
#endregion #endregion
#region 删除模板
public void DeleteTemplate(string ids)
{
string[] id = ids.Split(',');
DbBus.Get(DbList.AMSCenter).Transaction(() =>
{
foreach (string oid in id)
{
if (oid != "")
{
DbBus.Get(DbList.AMSCenter).Transaction(() =>
{
DbBus.Get(DbList.AMSCenter).Delete<ISF_CompanyTemplate>().Where(w => w.GID == oid).ExecuteAffrows();
});
}
}
});
}
#endregion
#region 第三方接口 #region 第三方接口
public async Task<Response> SendDE(string Gid, User user, string msgType) public async Task<Response> SendDE(string Gid, User user, string msgType)
@ -606,7 +628,7 @@ namespace djy.Service.Isf
if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功") if (master.NewNotice == "重发发送成功" || master.NewNotice == "新增发送成功")
{ {
DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "接收成功" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new ISF_Master { MateState = retdto.status, NewNotice = "匹配失败", ReportState = "接收成功" }).Where(w => w.GID == master.GID).ExecuteAffrows();
} }
} }
else if (retdto.status == "02") else if (retdto.status == "02")
@ -620,7 +642,7 @@ namespace djy.Service.Isf
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关删除成功"; history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关删除成功";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "ISF和AMS匹配成功", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new ISF_Master { MateState = retdto.status, NewNotice = "ISF和AMS匹配成功", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows();
} }
else if (retdto.status == "01") else if (retdto.status == "01")
{ {
@ -633,7 +655,7 @@ namespace djy.Service.Isf
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关拒绝"; history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关拒绝";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new ISF_Master { MateState = retdto.status, NewNotice = "海关拒绝", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows();
} }
else if (retdto.status == "SB" || retdto.status == "S2" || retdto.status == "S3" || retdto.status == "S4" || retdto.status == "S5" || retdto.status == "S6") else if (retdto.status == "SB" || retdto.status == "S2" || retdto.status == "S3" || retdto.status == "S4" || retdto.status == "S5" || retdto.status == "S6")
{ {
@ -646,7 +668,7 @@ namespace djy.Service.Isf
history.Operator = "系统管理员"; history.Operator = "系统管理员";
history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关拒绝"; history.Remark = "您的单据于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "海关拒绝";
DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Insert(history).ExecuteAffrows();
DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new AMS_Master { MateState = retdto.status, NewNotice = "未匹配AMS", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Update<ISF_Master>().Set(w => new ISF_Master { MateState = retdto.status, NewNotice = "未匹配AMS", ReportState = "删单失败" }).Where(w => w.GID == master.GID).ExecuteAffrows();
} }
} }
else else

@ -103,7 +103,7 @@ namespace djy_AmsApi.Controllers.AMS
#region 第三方接口 #region 第三方接口
[HttpGet("Send")] [HttpGet("Send")]
public async Task<Response> Send(string ids, string docType) public async Task<Response> Send(string ids, string docType,string hid)
{ {
Response req = new Response(); Response req = new Response();
var user = GetUserInfo(); var user = GetUserInfo();
@ -114,7 +114,7 @@ namespace djy_AmsApi.Controllers.AMS
req.Message = "登录过期,请重新登录!"; req.Message = "登录过期,请重新登录!";
return req; return req;
} }
var result = ser.SendDE(ids, user, docType); var result = ser.SendDE(ids, user, docType,hid);
req.Code = result.Result.Code; req.Code = result.Result.Code;
req.Message = result.Result.Message; req.Message = result.Result.Message;
return req; return req;
@ -190,6 +190,39 @@ namespace djy_AmsApi.Controllers.AMS
return result; return result;
} }
#endregion #endregion
#region 删除模板
/// <summary>
/// 删除接口
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpGet("DeleteTemplate")]
public Response DeleteTemplate(string ids)
{
var result = new Response();
try
{
var user = GetUserInfo();
if (user == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
ser.DeleteTemplate(ids);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
#endregion
} }
} }

File diff suppressed because one or more lines are too long

@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<_PublishTargetUrl>C:\Project\DJYAMS\djyweb_ams\web\djy.WebApi\bin\Release\net5.0\publish\</_PublishTargetUrl> <_PublishTargetUrl>C:\Project\DJYAMS\djyweb_ams\web\djy.WebApi\bin\Release\net5.0\publish\</_PublishTargetUrl>
<History>True|2022-07-08T09:01:30.6693134Z;True|2022-07-08T12:06:36.3838761+08:00;True|2022-07-07T16:23:24.9970320+08:00;True|2022-07-07T16:13:59.0482365+08:00;True|2022-07-07T11:23:54.2426892+08:00;True|2022-07-05T16:20:17.0177653+08:00;True|2022-07-05T16:19:13.8760086+08:00;True|2022-07-05T11:23:47.7031600+08:00;</History> <History>True|2022-07-12T08:27:25.6510813Z;True|2022-07-12T16:05:05.4184759+08:00;True|2022-07-12T10:39:59.0985811+08:00;True|2022-07-12T10:33:46.3867816+08:00;True|2022-07-08T17:01:30.6693134+08:00;True|2022-07-08T12:06:36.3838761+08:00;True|2022-07-07T16:23:24.9970320+08:00;True|2022-07-07T16:13:59.0482365+08:00;True|2022-07-07T11:23:54.2426892+08:00;True|2022-07-05T16:20:17.0177653+08:00;True|2022-07-05T16:19:13.8760086+08:00;True|2022-07-05T11:23:47.7031600+08:00;</History>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -153,7 +153,37 @@ namespace djy_Isfpi.Controllers.ISF
} }
#endregion #endregion
#region 删除模板
/// <summary>
/// 删除接口
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpGet("DeleteTemplate")]
public Response DeleteTemplate(string ids)
{
var result = new Response();
try
{
var user = GetUserInfo();
if (user == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
ser.DeleteTemplate(ids);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
#endregion
#region 第三方接口 #region 第三方接口
[HttpGet("Send")] [HttpGet("Send")]

@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<_PublishTargetUrl>C:\Project\DJYAMS\djyweb_ams\web\djy_IsfApi\bin\Release\net5.0\publish\</_PublishTargetUrl> <_PublishTargetUrl>C:\Project\DJYAMS\djyweb_ams\web\djy_IsfApi\bin\Release\net5.0\publish\</_PublishTargetUrl>
<History>True|2022-07-05T03:48:21.5945057Z;True|2022-07-05T11:21:19.6041212+08:00;True|2022-07-05T11:19:11.9998954+08:00;</History> <History>True|2022-07-12T08:28:26.6852287Z;True|2022-07-12T16:07:24.1013785+08:00;True|2022-07-05T11:48:21.5945057+08:00;True|2022-07-05T11:21:19.6041212+08:00;True|2022-07-05T11:19:11.9998954+08:00;</History>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
Loading…
Cancel
Save