20240718 和川接收大简云订舱同步,费用封帐时只更新部分指定字段

dev
ddlucky 4 months ago
parent 107c71d46d
commit 9368a43310

@ -1923,242 +1923,290 @@ SELECT @ps_BillNo as N'billno'";
var newhead = head.GetOpseae();
//过滤权限 20230421 正式使用后不做人员限制
//var cando = 人员是否具备权限(newhead.录入人, "776");
//if (!cando)
//{
// logger.Debug($"录入人无权限:{newhead.录入人}");
// continue;
//}
//20230726 会计期间改为:如果有实际开船日期 ATD/预抵日期 则按实际开船日期计算,如果没有,则按当前日期计算
//如果费用封账
if (updrec. == "费用封帐")
{
//newhead.会计期间 = updrec.会计期间;
////newhead.ETD= updrec.ETD;
//newhead.预抵日期 = updrec.预抵日期;
////20230927 增加四个在费用封账状态下不更新的字段
//newhead.揽货人 = updrec.揽货人;
//newhead.委托单位 = updrec.委托单位;
//newhead.货代公司 = updrec.货代公司;//订舱代理
//newhead.船公司 = updrec.船公司;
//ETD ATD 使用原有数据而不用大简云发布的信息覆盖(已取消)
//newhead.ETD = updrec.ETD;
//newhead.开船日期= updrec.开船日期;
//20240718 费用封账后
//大简云在东胜封账后 这些是可以改的收发通件重尺唛头EDI和 辅助字段 ,操作备注 单证备注 客服备注。除此之外的其他字段都不准更改东胜了
newhead. = updrec.;
newhead. = updrec.;
updrec. = newhead.;
updrec. = newhead.;
updrec. = newhead.;
updrec. = newhead.;
updrec. = newhead.;
updrec. = newhead.;
updrec. = newhead.;
//20230523 改为接收业务状态
//newhead.业务状态 = updrec.业务状态;
newhead. = updrec.;
updrec.EDI = newhead.EDI;
updrec. = newhead.;//单证备注
updrec. = newhead.;//操作备注
//20230726 会计期间改为:如果有实际开船日期 ATD/预抵日期 则按实际开船日期计算,如果没有,则按当前日期计算
//如果费用封账
if (updrec. == "费用封帐") {
newhead. = updrec.;
//newhead.ETD= updrec.ETD;
newhead. = updrec.;
//20230927 增加四个在费用封账状态下不更新的字段
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;//订舱代理
newhead. = updrec.;
//newhead.三
}
newhead. = string.IsNullOrWhiteSpace(head.mblno) ? updrec. : head.mblno;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
//20230803 根据马静怡的要求
//在同步时 如果目的港ETA为空 则不用空值更新东胜的ETA当前值
if (newhead.ETA == null) {
newhead.ETA = updrec.ETA;
}
updrec. = newhead.;
updrec. = newhead.;
updrec. = newhead.;
updrec. = newhead.;
logger.Debug($"开始处理(更新){newhead.主提单号};{newhead.DJYID}");
//执行中对象2.执行列表数();
DS6Data.t_op_seae.AddOrUpdate(updrec);
Set(ref newhead, head);
DS6Data.t_op_seae.AddOrUpdate(newhead);
DS6Data.SaveChanges();
//logger.Debug($"更新业务1{head.Id}");
#region 箱信息
DS6Data = new DS6DataContext();
var Currctnlist = DS6Data.t_op_ctn.Where(x => x. == headid).ToList();
var ctn_addlist = new List<t_op_ctn_md>();
//var ctn_updlist = new List<t_op_ctn_md>();
var ctn_dellist = new List<t_op_ctn_md>();
#region AMS信息
//DS6Data = new DS6DataContext();
var amslist = DS6Data.t_op_ams.Where(x => x. == headid).ToList();
DS6Data.t_op_ams.RemoveRange(amslist);
var newamslist = head.GetAmsList(newhead);
DS6Data.t_op_ams.AddRange(newamslist);
var newctnList = head.GetCtnList(newhead.);
mark = 1.12m;
DS6Data.SaveChanges();
//logger.Debug($"更新提单信息:{head.Id}");
#endregion
foreach (var ctn in newctnList)
{
//if (Currctnlist.Exists(x => x.DJYCTNID == ctn.DJYCTNID))
//{
// var currctn = Currctnlist.First(x => x.DJYCTNID == ctn.DJYCTNID);
// DingCangHead.GetCtn(ref currctn, ctn);
// ctn_updlist.Add(currctn);
//}
//else
{
ctn_addlist.Add(ctn);
}
DS6Data.SaveChanges();
}
foreach (var oldctn in Currctnlist)
{
//if (newctnList.Exists(x => x.DJYCTNID == oldctn.DJYCTNID))
//{
else {
//}
//else
//过滤权限 20230421 正式使用后不做人员限制
//var cando = 人员是否具备权限(newhead.录入人, "776");
//if (!cando)
//{
// ctn_dellist.Add(oldctn);
// logger.Debug($"录入人无权限:{newhead.录入人}");
// continue;
//}
ctn_dellist.Add(oldctn);
}
if (ctn_dellist.Count > 0)
{
mark = 1.11m;
DS6Data.t_op_ctn.RemoveRange(ctn_dellist);
DS6Data.SaveChanges();
logger.Debug($"删除原箱信息:{JsonConvert.SerializeObject(ctn_dellist)}");
}
if (ctn_addlist.Count > 0)
{
mark = 1.112m;
DS6Data.t_op_ctn.AddRange(ctn_addlist);
DS6Data.SaveChanges();
logger.Debug($"插入箱信息:{JsonConvert.SerializeObject(ctn_addlist)}");
}
//if (ctn_updlist.Count > 0)
//{
// foreach (var updctn in ctn_updlist)
// {
// DS6Data.t_op_ctn.AddOrUpdate(updctn);
// }
//}
//ETD ATD 使用原有数据而不用大简云发布的信息覆盖(已取消)
//newhead.ETD = updrec.ETD;
//newhead.开船日期= updrec.开船日期;
//20240718 非 费用封账 采用原有逻辑
#endregion
newhead. = updrec.;
newhead. = updrec.;
#region 提单信息
DS6Data = new DS6DataContext();
var amslist = DS6Data.t_op_ams.Where(x => x. == headid).ToList();
DS6Data.t_op_ams.RemoveRange(amslist);
var newamslist = head.GetAmsList(newhead);
DS6Data.t_op_ams.AddRange(newamslist);
//20230523 改为接收业务状态
//newhead.业务状态 = updrec.业务状态;
newhead. = updrec.;
mark = 1.12m;
DS6Data.SaveChanges();
//logger.Debug($"更新提单信息:{head.Id}");
#endregion
newhead. = string.IsNullOrWhiteSpace(head.mblno) ? updrec. : head.mblno;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
newhead. = updrec.;
#region 分单
//分单列表
DS6Data = new DS6DataContext();
var newassistantList = head.GetAssistantList(newhead);
//20230803 根据马静怡的要求
//在同步时 如果目的港ETA为空 则不用空值更新东胜的ETA当前值
if (newhead.ETA == null)
{
newhead.ETA = updrec.ETA;
}
var old_assistantList = DS6Data.t_op_seae_assistant.Where(x => x. == headid).ToList();
//var assistantUpdList = new List<t_op_seae_assistant_md>();
var assistantAddList = new List<t_op_seae_assistant_md>();
var assistantDelList = new List<t_op_seae_assistant_md>();
logger.Debug($"开始处理(更新){newhead.主提单号};{newhead.DJYID}");
//执行中对象2.执行列表数();
//DS6Data.t_op_seae_assistant.RemoveRange(amslist);
Set(ref newhead, head);
DS6Data.t_op_seae.AddOrUpdate(newhead);
DS6Data.SaveChanges();
//logger.Debug($"更新业务1{head.Id}");
#region 箱信息
DS6Data = new DS6DataContext();
var Currctnlist = DS6Data.t_op_ctn.Where(x => x. == headid).ToList();
var ctn_addlist = new List<t_op_ctn_md>();
//var ctn_updlist = new List<t_op_ctn_md>();
var ctn_dellist = new List<t_op_ctn_md>();
foreach (var assistant in newassistantList)
{
//if (old_assistantList.Exists(x => x.DJYCHILDRENID == assistant.DJYCHILDRENID))
var newctnList = head.GetCtnList(newhead.);
foreach (var ctn in newctnList)
{
//if (Currctnlist.Exists(x => x.DJYCTNID == ctn.DJYCTNID))
//{
// var currctn = Currctnlist.First(x => x.DJYCTNID == ctn.DJYCTNID);
// DingCangHead.GetCtn(ref currctn, ctn);
// ctn_updlist.Add(currctn);
//}
//else
{
ctn_addlist.Add(ctn);
}
}
foreach (var oldctn in Currctnlist)
{
//if (newctnList.Exists(x => x.DJYCTNID == oldctn.DJYCTNID))
//{
//}
//else
//{
// ctn_dellist.Add(oldctn);
//}
ctn_dellist.Add(oldctn);
}
if (ctn_dellist.Count > 0)
{
mark = 1.11m;
DS6Data.t_op_ctn.RemoveRange(ctn_dellist);
DS6Data.SaveChanges();
logger.Debug($"删除原箱信息:{JsonConvert.SerializeObject(ctn_dellist)}");
}
if (ctn_addlist.Count > 0)
{
mark = 1.112m;
DS6Data.t_op_ctn.AddRange(ctn_addlist);
DS6Data.SaveChanges();
logger.Debug($"插入箱信息:{JsonConvert.SerializeObject(ctn_addlist)}");
}
//if (ctn_updlist.Count > 0)
//{
// var curr = old_assistantList.First(x => x.DJYCHILDRENID == assistant.DJYCHILDRENID);
// DingCangHead.GetAssistant(ref curr, assistant);
// assistantUpdList.Add(curr);
// foreach (var updctn in ctn_updlist)
// {
// DS6Data.t_op_ctn.AddOrUpdate(updctn);
// }
//}
//else
//{
#endregion
#region AMS信息
DS6Data = new DS6DataContext();
var amslist = DS6Data.t_op_ams.Where(x => x. == headid).ToList();
DS6Data.t_op_ams.RemoveRange(amslist);
var newamslist = head.GetAmsList(newhead);
DS6Data.t_op_ams.AddRange(newamslist);
mark = 1.12m;
DS6Data.SaveChanges();
//logger.Debug($"更新提单信息:{head.Id}");
#endregion
#region 分单
//分单列表
DS6Data = new DS6DataContext();
var newassistantList = head.GetAssistantList(newhead);
var old_assistantList = DS6Data.t_op_seae_assistant.Where(x => x. == headid).ToList();
//var assistantUpdList = new List<t_op_seae_assistant_md>();
var assistantAddList = new List<t_op_seae_assistant_md>();
var assistantDelList = new List<t_op_seae_assistant_md>();
//DS6Data.t_op_seae_assistant.RemoveRange(amslist);
foreach (var assistant in newassistantList)
{
//if (old_assistantList.Exists(x => x.DJYCHILDRENID == assistant.DJYCHILDRENID))
//{
// var curr = old_assistantList.First(x => x.DJYCHILDRENID == assistant.DJYCHILDRENID);
// DingCangHead.GetAssistant(ref curr, assistant);
// assistantUpdList.Add(curr);
//}
//else
//{
assistantAddList.Add(assistant);
//}
}
//}
}
foreach (var old in old_assistantList)
{
//if (newassistantList.Exists(x => x.DJYCHILDRENID == old.DJYCHILDRENID))
//{
foreach (var old in old_assistantList)
{
//if (newassistantList.Exists(x => x.DJYCHILDRENID == old.DJYCHILDRENID))
//{
//}
//else
//{
//}
//else
//{
assistantDelList.Add(old);
//}
}
if (assistantDelList.Count > 0)
{
mark = 1.13m;
DS6Data.t_op_seae_assistant.RemoveRange(assistantDelList);
DS6Data.SaveChanges();
//logger.Debug($"更新分单信息1{head.Id}");
}
if (assistantAddList.Count > 0)
{
mark = 1.132m;
DS6Data.t_op_seae_assistant.AddRange(assistantAddList);
DS6Data.SaveChanges();
//logger.Debug($"更新分单信息2{head.Id}");
}
//if (assistantUpdList.Count > 0)
//{
// foreach (var upd in assistantUpdList)
// {
// DS6Data.t_op_seae_assistant.AddOrUpdate(upd);
// }
//}
}
if (assistantDelList.Count > 0)
{
mark = 1.13m;
DS6Data.t_op_seae_assistant.RemoveRange(assistantDelList);
DS6Data.SaveChanges();
//logger.Debug($"更新分单信息1{head.Id}");
}
if (assistantAddList.Count > 0)
{
mark = 1.132m;
DS6Data.t_op_seae_assistant.AddRange(assistantAddList);
DS6Data.SaveChanges();
//logger.Debug($"更新分单信息2{head.Id}");
}
//if (assistantUpdList.Count > 0)
//{
// foreach (var upd in assistantUpdList)
// {
// DS6Data.t_op_seae_assistant.AddOrUpdate(upd);
// }
//}
//DS6Data.SaveChanges();
//DS6Data.SaveChanges();
#endregion
#endregion
#region 业务状态
DS6Data = new DS6DataContext();
var Currstatuslist = DS6Data.t_op_state.Where(x => x. == headid).ToList();
if (Currstatuslist != null && Currstatuslist.Count > 0)
{
DS6Data.t_op_state.RemoveRange(Currstatuslist);
DS6Data.SaveChanges();
#region 业务状态
DS6Data = new DS6DataContext();
var Currstatuslist = DS6Data.t_op_state.Where(x => x. == headid).ToList();
if (Currstatuslist != null && Currstatuslist.Count > 0)
{
DS6Data.t_op_state.RemoveRange(Currstatuslist);
DS6Data.SaveChanges();
}
var statusList = head.GetOpStatus(newhead);
if (statusList != null && statusList.Count > 0)
{
DS6Data.t_op_state.AddRange(statusList);
DS6Data.SaveChanges();
}
var statusList = head.GetOpStatus(newhead);
if (statusList != null && statusList.Count > 0)
{
DS6Data.t_op_state.AddRange(statusList);
DS6Data.SaveChanges();
}
}
#endregion
#endregion
mark = 1.2m;
DS6Data = new DS6DataContext();
var ob = new
{
head = newhead,
ctnlist = ctn_addlist,
amslist = newamslist,
ass1 = assistantAddList,
//ass2 = assistantUpdList,
ass3 = assistantDelList,
};
errorobjstr = JsonConvert.SerializeObject(ob);
//logger.Debug($"更新完成:{newhead.主提单号};{newhead.DJYID}");
AfterSave(newhead.);
//DS6Data.SaveChanges();
logger.Debug($"完成处理(更新){newhead.主提单号};{newhead.DJYID}");
}
mark = 1.2m;
DS6Data = new DS6DataContext();
var ob = new
{
head = newhead,
ctnlist = ctn_addlist,
amslist = newamslist,
ass1 = assistantAddList,
//ass2 = assistantUpdList,
ass3 = assistantDelList,
};
errorobjstr = JsonConvert.SerializeObject(ob);
//logger.Debug($"更新完成:{newhead.主提单号};{newhead.DJYID}");
AfterSave(newhead.);
//DS6Data.SaveChanges();
logger.Debug($"完成处理(更新){newhead.主提单号};{newhead.DJYID}");
}
else
{

Loading…
Cancel
Save