wet 2 years ago
parent 0539af23b6
commit 3bc7be7e1d

@ -74,8 +74,8 @@ namespace djy.Service.Ams
var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == item.GID) var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == item.GID)
.WhereIf(!string.IsNullOrEmpty(req.Hid), x => x.GID == req.Hid) .WhereIf(!string.IsNullOrEmpty(req.Hid), x => x.GID == req.Hid)
.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 == "0", x => x.ReportState == "未申报")
.WhereIf(req.ReportState == "1", x => !(x.ReportState == "未申报" || x.ReportState == "接收失败")) .WhereIf(req.ReportState == "1", x => x.ReportState != "未申报")
.WhereIf(req.ReportState != null && req.ReportState != "0" && req.ReportState != "1", x => ReportStates.Contains(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;
@ -216,7 +216,8 @@ namespace djy.Service.Ams
} }
else else
{ {
if (dto.HouseDto[0].ReportState == "未申报")
if (DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel != true && x.PID == dto.GID).ToList().Where(x=>x.ReportState.Contains("未申报")).Count()>0)
{ {
DbBus.Get(DbList.AMSCenter).Transaction(() => DbBus.Get(DbList.AMSCenter).Transaction(() =>
{ {
@ -240,64 +241,11 @@ 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();
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_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).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Delete<AMS_Cntrno>().Where(w => w.PID == master.GID).ExecuteAffrows();
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();
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 = new 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 = item.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();
}
else
{
house = item.MapTo<AMS_House>(); house = item.MapTo<AMS_House>();
house.GID = Guid.NewGuid().ToString("N"); house.GID = Guid.NewGuid().ToString("N");
house.PID = master.GID; house.PID = master.GID;
@ -328,11 +276,7 @@ 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();
}
} }
guid = master.GID; guid = master.GID;
}); });
} }
@ -361,7 +305,6 @@ namespace djy.Service.Ams
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();
DbBus.Get(DbList.AMSCenter).Delete<AMS_Cntrno>().Where(w => w.PID == master.GID).ExecuteAffrows(); DbBus.Get(DbList.AMSCenter).Delete<AMS_Cntrno>().Where(w => w.PID == master.GID).ExecuteAffrows();
List<string> houseid = dto.HouseDto.Select(x => x.GID).ToList(); List<string> houseid = dto.HouseDto.Select(x => x.GID).ToList();
foreach (var item in dto.HouseDto) foreach (var item in dto.HouseDto)

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save