diff --git a/DSWeb.DJYMQ/DS7Service.cs b/DSWeb.DJYMQ/DS7Service.cs index d42507ce..c9906a83 100644 --- a/DSWeb.DJYMQ/DS7Service.cs +++ b/DSWeb.DJYMQ/DS7Service.cs @@ -1922,243 +1922,291 @@ SELECT @ps_BillNo as N'billno'"; var headid = updrec.编号; 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.预抵日期; - //ETD ATD 使用原有数据而不用大简云发布的信息覆盖(已取消) - //newhead.ETD = updrec.ETD; - //newhead.开船日期= updrec.开船日期; + ////20230927 增加四个在费用封账状态下不更新的字段 + //newhead.揽货人 = updrec.揽货人; + //newhead.委托单位 = updrec.委托单位; + //newhead.货代公司 = updrec.货代公司;//订舱代理 + //newhead.船公司 = updrec.船公司; - newhead.编号 = updrec.编号; - newhead.主编号 = updrec.主编号; + //20240718 费用封账后 + //大简云在东胜封账后 这些是可以改的收发通,件重尺,唛头,EDI和 辅助字段 ,操作备注 单证备注 客服备注。除此之外的其他字段都不准更改东胜了 - //20230523 改为接收业务状态 - //newhead.业务状态 = updrec.业务状态; - newhead.费用状态 = updrec.费用状态; + updrec.收货人代码 = newhead.收货人代码; + updrec.发货人代码 = newhead.发货人代码; + updrec.通知人代码 = newhead.通知人代码; + updrec.件数 = newhead.件数; + updrec.件数包装 = newhead.件数包装; + 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.三 - } + updrec.EDI备注 = newhead.EDI备注; + 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; - } - logger.Debug($"开始处理(更新):{newhead.主提单号};{newhead.DJYID}"); - //执行中对象2.执行列表数(); + updrec.辅助字段一 = newhead.辅助字段一; + updrec.辅助字段二 = newhead.辅助字段二; + updrec.辅助字段三 = newhead.辅助字段三; + updrec.辅助字段四 = newhead.辅助字段四; - 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(); - //var ctn_updlist = new List(); - var ctn_dellist = new List(); + DS6Data.t_op_seae.AddOrUpdate(updrec); - var newctnList = head.GetCtnList(newhead.编号); + #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); - foreach (var ctn in newctnList) - { - //if (Currctnlist.Exists(x => x.DJYCTNID == ctn.DJYCTNID)) + mark = 1.12m; + DS6Data.SaveChanges(); + //logger.Debug($"更新提单信息:{head.Id}"); + #endregion + + + DS6Data.SaveChanges(); + } + + else { + + //过滤权限 20230421 正式使用后不做人员限制 + //var cando = 人员是否具备权限(newhead.录入人, "776"); + //if (!cando) //{ - // var currctn = Currctnlist.First(x => x.DJYCTNID == ctn.DJYCTNID); - // DingCangHead.GetCtn(ref currctn, ctn); + // logger.Debug($"录入人无权限:{newhead.录入人}"); + // continue; - // ctn_updlist.Add(currctn); //} - //else + + + //ETD ATD 使用原有数据而不用大简云发布的信息覆盖(已取消) + //newhead.ETD = updrec.ETD; + //newhead.开船日期= updrec.开船日期; + + //20240718 非 费用封账 采用原有逻辑 + + newhead.编号 = updrec.编号; + newhead.主编号 = updrec.主编号; + + //20230523 改为接收业务状态 + //newhead.业务状态 = updrec.业务状态; + newhead.费用状态 = updrec.费用状态; + + 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) { - ctn_addlist.Add(ctn); + newhead.ETA = updrec.ETA; } - } - foreach (var oldctn in Currctnlist) - { - //if (newctnList.Exists(x => x.DJYCTNID == oldctn.DJYCTNID)) - //{ + logger.Debug($"开始处理(更新):{newhead.主提单号};{newhead.DJYID}"); + //执行中对象2.执行列表数(); - //} - //else + 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(); + //var ctn_updlist = new List(); + var ctn_dellist = new List(); + + 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) //{ - // ctn_dellist.Add(oldctn); + // foreach (var updctn in ctn_updlist) + // { + // DS6Data.t_op_ctn.AddOrUpdate(updctn); + // } //} - 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); - // } - //} - - - #endregion - #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); - mark = 1.12m; - DS6Data.SaveChanges(); - //logger.Debug($"更新提单信息:{head.Id}"); - #endregion + #endregion - #region 分单 - //分单列表 - DS6Data = new DS6DataContext(); - var newassistantList = head.GetAssistantList(newhead); + #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 old_assistantList = DS6Data.t_op_seae_assistant.Where(x => x.编号 == headid).ToList(); - //var assistantUpdList = new List(); - var assistantAddList = new List(); - var assistantDelList = new List(); + mark = 1.12m; + DS6Data.SaveChanges(); + //logger.Debug($"更新提单信息:{head.Id}"); + #endregion - //DS6Data.t_op_seae_assistant.RemoveRange(amslist); + #region 分单 + //分单列表 + DS6Data = new DS6DataContext(); + var newassistantList = head.GetAssistantList(newhead); - 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 - //{ + var old_assistantList = DS6Data.t_op_seae_assistant.Where(x => x.编号 == headid).ToList(); + //var assistantUpdList = new List(); + var assistantAddList = new List(); + var assistantDelList = new List(); + + //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(); - #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(); + //DS6Data.SaveChanges(); - } - var statusList = head.GetOpStatus(newhead); - if (statusList != null && statusList.Count > 0) - { - DS6Data.t_op_state.AddRange(statusList); - 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(); - mark = 1.2m; - DS6Data = new DS6DataContext(); - var ob = new - { - head = newhead, - ctnlist = ctn_addlist, - amslist = newamslist, - ass1 = assistantAddList, - //ass2 = assistantUpdList, - ass3 = assistantDelList, + } + var statusList = head.GetOpStatus(newhead); + if (statusList != null && statusList.Count > 0) + { + DS6Data.t_op_state.AddRange(statusList); + DS6Data.SaveChanges(); - }; - errorobjstr = JsonConvert.SerializeObject(ob); + } - //logger.Debug($"更新完成:{newhead.主提单号};{newhead.DJYID}"); + #endregion - 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 {