jianghaiqing 4 months ago
commit 93b68f598a

@ -16,6 +16,7 @@ using Mapster;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using DS.Module.Core.Constants; using DS.Module.Core.Constants;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
namespace DS.WMS.Core.Op.Method namespace DS.WMS.Core.Op.Method
{ {
@ -52,405 +53,420 @@ namespace DS.WMS.Core.Op.Method
{ {
try try
{ {
if (req.Count == 0) // 当BusinessId不为空时将BusinessId的值转为订舱主键否则仍然使用BookingId作为订舱记录主键
if (!string.IsNullOrEmpty(req[0].BusinessId))
{ {
if (long.TryParse(req[0].BusinessId, out long itemBusinessId))
return; {
req[0].BookingId = itemBusinessId;
}
else
{
_logger.Error($"在将item.BusinessId转为BookingId时发生异常货运动态插入失败item.BusinessId的值为{req[0].BusinessId}");
return;
}
} }
else _logger.Info($"货运动态回调:"+ JsonConvert.SerializeObject(req));
//订舱状态
var dicList = db.Queryable<SysDictData>().Where(x => x.TypeId == 1788810332945387520).ToList();
foreach (var item in req)
{ {
//订舱状态
var dicList = db.Queryable<SysDictData>().Where(x => x.TypeId == 1788810332945387520).ToList();
foreach (var item in req)
{
// 当BusinessId不为空时将BusinessId的值转为订舱主键否则仍然使用BookingId作为订舱记录主键 // 当BusinessId不为空时将BusinessId的值转为订舱主键否则仍然使用BookingId作为订舱记录主键
if (!string.IsNullOrEmpty(item.BusinessId)) if (!string.IsNullOrEmpty(item.BusinessId))
{
if (long.TryParse(item.BusinessId, out long itemBusinessId))
{ {
if (long.TryParse(item.BusinessId, out long itemBusinessId)) item.BookingId = itemBusinessId;
{
item.BookingId = itemBusinessId;
}
else
{
_logger.Error($"在将item.BusinessId转为BookingId时发生异常货运动态插入失败item.BusinessId的值为{item.BusinessId}");
continue;
}
} }
var tenantId= accessor.HttpContext.Request.Headers["PushBackKey"].FirstOrDefault(); else
var tenantDb = saasService.GetBizDbScopeById(tenantId); {
var businessId = item.BookingId; _logger.Error($"在将item.BusinessId转为BookingId时发生异常货运动态插入失败item.BusinessId的值为{item.BusinessId}");
//TODO continue;
var list = await tenantDb.Queryable<BookingStatus>().Filter(null, true) }
.InnerJoin<SysDictData>((d, t) => d.StatusCode == t.Value && d.StatusGroup == "booking_status_group_billtrace" && d.BusinessId == businessId).Select((d, t) => new }
{ var tenantId = accessor.HttpContext.Request.Headers["PushBackKey"].FirstOrDefault();
BusinessId = d.BusinessId, var tenantDb = saasService.GetBizDbScopeById(tenantId);
StatusCode = d.StatusCode, var businessId = item.BookingId;
StatusName = d.StatusName, //TODO
StatusTime = d.StatusTime, var list = await tenantDb.Queryable<BookingStatus>().Filter(null, true)
Name = t.Name, .InnerJoin<SysDictData>((d, t) => d.StatusCode == t.Value && t.TypeId == 1788810332945387520 && d.StatusGroup == "booking_status_group_billtrace"
Value = t.Value && d.BusinessId == businessId, "shippingweb8_dev.sys_dict_data")
}).ToListAsync(); .Select((d, t) => new
// var list = await tenantDb.Queryable<BookingStatus>().Filter(null, true).Where(x=>x.StatusGroup == "booking_status_group_billtrace" && x.BusinessId == businessId).Select(d=> new {
//{ BusinessId = d.BusinessId,
// BusinessId = d.BusinessId, StatusCode = d.StatusCode,
// StatusCode = d.StatusCode, StatusName = d.StatusName,
// StatusName = d.StatusName, StatusTime = d.StatusTime,
// StatusTime = d.StatusTime Name = t.Name,
//}).ToListAsync(); Value = t.Value
}).ToListAsync();
var oldLog = await tenantDb.Queryable<BookingStatusLog>().Where(x => x.BusinessId == businessId && x.Group == "yunzong").FirstAsync(); // var list = await tenantDb.Queryable<BookingStatus>().Filter(null, true).Where(x=>x.StatusGroup == "booking_status_group_billtrace" && x.BusinessId == businessId).Select(d=> new
//{
// BusinessId = d.BusinessId,
// StatusCode = d.StatusCode,
// StatusName = d.StatusName,
// StatusTime = d.StatusTime
//}).ToListAsync();
var oldLog = await tenantDb.Queryable<BookingStatusLog>().Where(x => x.BusinessId == businessId && x.Group == "yunzong").FirstAsync();
if (oldLog.IsNotNull()) {
//删除日志详情和日志 //删除日志详情和日志
var oldLogDetails = await tenantDb.Queryable<BookingStatusLogDetail>().Where(x => x.PId == oldLog.Id).ToListAsync(); var oldLogDetails = await tenantDb.Queryable<BookingStatusLogDetail>().Where(x => x.PId == oldLog.Id).ToListAsync();
await tenantDb.Deleteable(oldLogDetails).ExecuteCommandAsync(); if (oldLogDetails.Count > 0)
{
await tenantDb.Deleteable(oldLogDetails).ExecuteCommandAsync();
}
await tenantDb.Deleteable(oldLog).ExecuteCommandAsync(); await tenantDb.Deleteable(oldLog).ExecuteCommandAsync();
}
#region 日志
//新增数据 #region 日志
var statusLog = new BookingStatusLog() //新增数据
{ var statusLog = new BookingStatusLog()
BusinessId = businessId, {
Group = "yunzong", BusinessId = businessId,
Status = item.Status, Group = "yunzong",
OpTime = item.OpTime, Status = item.Status,
MBLNO = item.MBLNO OpTime = item.OpTime,
}; MBLNO = item.MBLNO
await tenantDb.Insertable(statusLog).ExecuteCommandAsync(); };
if (item.detail != null && item.detail.Count > 0) await tenantDb.Insertable(statusLog).ExecuteCommandAsync();
if (item.detail != null && item.detail.Count > 0)
{
foreach (var dt in item.detail)
{ {
foreach (var dt in item.detail) var logDetail = new BookingStatusLogDetail()
{ {
var logDetail = new BookingStatusLogDetail() PId = statusLog.Id,
{ Status = dt.Status,
PId = statusLog.Id, CNTRNO = dt.CNTRNO,
Status = dt.Status, OpTime = dt.OPTime
CNTRNO = dt.CNTRNO, };
OpTime = dt.OPTime await tenantDb.Insertable(logDetail).ExecuteCommandAsync();
};
await tenantDb.Insertable(logDetail).ExecuteCommandAsync();
}
} }
if (item.Status == "提箱") }
{ if (item.Status == "提箱")
//自动引入场站箱型箱量数据 {
//await _bookingorderservice.AutoYardData(item.BookingId); //自动引入场站箱型箱量数据
//await _bookingorderservice.AutoYardData(item.BookingId);
//#region 推送已提箱状态 //#region 推送已提箱状态
////2023-12-28 JHQ 增加提箱推送状态 ////2023-12-28 JHQ 增加提箱推送状态
//DateTime opTime = DateTime.MinValue; //DateTime opTime = DateTime.MinValue;
//if (item.detail != null && item.detail.Count > 0 && item.detail.Any(x => x.OPTime.HasValue)) //if (item.detail != null && item.detail.Count > 0 && item.detail.Any(x => x.OPTime.HasValue))
// opTime = item.detail.Where(x => x.OPTime.HasValue).Max(x => x.OPTime.Value); // opTime = item.detail.Where(x => x.OPTime.HasValue).Max(x => x.OPTime.Value);
//var pushModel = new ModifyServiceProjectStatusDto //var pushModel = new ModifyServiceProjectStatusDto
//{ //{
// BookingId = businessId, // BookingId = businessId,
// SourceType = TrackingSourceTypeEnum.AUTO, // SourceType = TrackingSourceTypeEnum.AUTO,
// StatusCodes = new List<ModifyServiceProjectStatusDetailDto> { // StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
// new ModifyServiceProjectStatusDetailDto { StatusCode = "YTX" } } // new ModifyServiceProjectStatusDetailDto { StatusCode = "YTX" } }
//}; //};
//if (opTime != DateTime.MinValue) //if (opTime != DateTime.MinValue)
//{ //{
// pushModel.StatusCodes[0].SetActDate = opTime; // pushModel.StatusCodes[0].SetActDate = opTime;
//} //}
//var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(pushModel); //var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(pushModel);
//_logger.Info("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt)); //_logger.Info("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt));
//#endregion //#endregion
} }
#endregion #endregion
#region 订舱状态 #region 订舱状态
if (item.Status == "舱单") if (item.Status == "舱单")
{
if (list.Where(x => x.Value == "status_cangdan").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_cangdan").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_cangdan",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_cangdan").Select(x => x.Name).First(),
StatusCode = "status_cangdan", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_cangdan").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}; //2023-12-28 JHQ 增加舱单放行推送状态
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync(); await seaComService.SetGoodsStatus("CDFX", item.BookingId);
//2023-12-28 JHQ 增加舱单放行推送状态
await seaComService.SetGoodsStatus("CDFX", item.BookingId);
}
} }
if (item.Status == "海关放行") }
if (item.Status == "海关放行")
{
if (list.Where(x => x.Value == "status_haifang").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_haifang").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_haifang",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_haifang").Select(x => x.Name).First(),
StatusCode = "status_haifang", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_haifang").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}; await seaComService.SetGoodsStatus("BG", item.BookingId);
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("BG", item.BookingId);
}
} }
if (item.Status == "装载") }
if (item.Status == "装载")
{
if (list.Where(x => x.Value == "status_zhuangzai").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_zhuangzai").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_zhuangzai",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_zhuangzai").Select(x => x.Name).First(),
StatusCode = "status_zhuangzai", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_zhuangzai").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}; await seaComService.SetGoodsStatus("ZZFX", item.BookingId);
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("ZZFX", item.BookingId);
}
} }
if (item.Status == "码放") }
if (item.Status == "码放")
{
if (list.Where(x => x.Value == "status_mafang").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_mafang").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_mafang",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_mafang").Select(x => x.Name).First(),
StatusCode = "status_mafang", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_mafang").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}; await seaComService.SetGoodsStatus("MTFX", item.BookingId);
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("MTFX", item.BookingId);
}
} }
if (item.Status == "装船") }
if (item.Status == "装船")
{
if (list.Where(x => x.Value == "status_zhuangchuan").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_zhuangchuan").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_zhuangchuan",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_zhuangchuan").Select(x => x.Name).First(),
StatusCode = "status_zhuangchuan", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_zhuangchuan").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}
} }
if (item.Status == "ATD") }
if (item.Status == "ATD")
{
if (list.Where(x => x.Value == "status_atd").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_atd").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_atd",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_atd").Select(x => x.Name).First(),
StatusCode = "status_atd", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_atd").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}
} }
if (item.Status == "MDGETA") }
if (item.Status == "MDGETA")
{
if (list.Where(x => x.Value == "status_mdgeta").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_mdgeta").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_mdgeta",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_mdgeta").Select(x => x.Name).First(),
StatusCode = "status_mdgeta", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_mdgeta").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
} }
var order = tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => x.Id == businessId && x.Deleted == false).First(); var order = tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => x.Id == businessId && x.Deleted == false).First();
if (order.ETA != item.OpTime && item.OpTime != null) if (order.ETA != item.OpTime && item.OpTime != null)
{ {
order.ETA = item.OpTime; order.ETA = item.OpTime;
await tenantDb.Updateable(order).EnableDiffLogEvent().ExecuteCommandAsync(); await tenantDb.Updateable(order).EnableDiffLogEvent().ExecuteCommandAsync();
}
} }
if (item.Status == "MDGATA") }
if (item.Status == "MDGATA")
{
if (list.Where(x => x.Value == "status_mdgata").FirstOrDefault() == null)
{ {
if (list.Where(x => x.Value == "status_mdgata").FirstOrDefault() == null) var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_mdgata",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_mdgata").Select(x => x.Name).First(),
StatusCode = "status_mdgata", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_mdgata").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}; }
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}
var order = tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => x.Id == businessId && x.Deleted == false).First(); var order = tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => x.Id == businessId && x.Deleted == false).First();
if (order.ATA != item.OpTime && item.OpTime != null) if (order.ATA != item.OpTime && item.OpTime != null)
{
order.ATA = item.OpTime;
await tenantDb.Updateable(order).EnableDiffLogEvent().ExecuteCommandAsync();
}
}
#region 入港时间
if (item.Status == "入港")
{ {
order.ATA = item.OpTime;
await tenantDb.Updateable(order).EnableDiffLogEvent().ExecuteCommandAsync();
}
}
#region 入港时间
if (item.Status == "入港")
{
if (list.Where(x => x.Value == "status_rugang").FirstOrDefault() == null) if (list.Where(x => x.Value == "status_rugang").FirstOrDefault() == null)
{
var bookingStatus = new BookingStatus()
{ {
var bookingStatus = new BookingStatus() BusinessId = businessId,
{ StatusCode = "status_rugang",
BusinessId = businessId, StatusName = dicList.Where(x => x.Value == "status_rugang").Select(x => x.Name).First(),
StatusCode = "status_rugang", StatusTime = item.OpTime,
StatusName = dicList.Where(x => x.Value == "status_rugang").Select(x => x.Name).First(), StatusGroup = "booking_status_group_billtrace"
StatusTime = item.OpTime, };
StatusGroup = "booking_status_group_billtrace" await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}; await seaComService.SetGoodsStatus("YRG", item.BookingId);
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("YRG", item.BookingId);
}
} }
#endregion }
#endregion #endregion
#endregion
#region 船舶动态ATD ETD ATA ETA MDGETA MDGATA #region 船舶动态ATD ETD ATA ETA MDGETA MDGATA
if (item.Status == "ATD" || item.Status == "ETD" || item.Status == "ATA" || item.Status == "ETA" || item.Status == "MDGETA" || item.Status == "MDGATA") if (item.Status == "ATD" || item.Status == "ETD" || item.Status == "ATA" || item.Status == "ETA" || item.Status == "MDGETA" || item.Status == "MDGATA")
{ {
var config = await db.Queryable<SysConfig>().FirstAsync(x => x.Code == TenantParamCode.ENABLE_STATUS_TO_SAILING_DATE); var config = await db.Queryable<SysConfig>().FirstAsync(x => x.Code == TenantParamCode.ENABLE_STATUS_TO_SAILING_DATE);
if (config.IsNotNull() && config.Value == "YES") if (config.IsNotNull() && config.Value == "YES")
{
var order = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == businessId && x.MBLNO == item.MBLNO).FirstAsync();
if (item.Status == "ATD")
{ {
var order = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == businessId && x.MBLNO == item.MBLNO).FirstAsync(); //2023-8-31排查单号为177GZHZHQ5711V的数据原来录入的船已开船运踪港前不再查询而因订阅港后数据会继续回推数据所以导致ATD被改
if (item.Status == "ATD") //因此暂时取消运踪回推时写入ATD还是以船期表查询为准
{
//2023-8-31排查单号为177GZHZHQ5711V的数据原来录入的船已开船运踪港前不再查询而因订阅港后数据会继续回推数据所以导致ATD被改
//因此暂时取消运踪回推时写入ATD还是以船期表查询为准
// 2024-4-8 因为港捷需要,重新开启,并通过租户参数判断 // 2024-4-8 因为港捷需要,重新开启,并通过租户参数判断
//变更ATD //变更ATD
if (order != null && item.OpTime != null && order.ATD != item.OpTime) if (order != null && item.OpTime != null && order.ATD != item.OpTime)
{
order.ATD = item.OpTime;
await tenantDb.Updateable(order).UpdateColumns(x => new
{ {
order.ATD = item.OpTime; x.ATD
await tenantDb.Updateable(order).UpdateColumns(x => new }).EnableDiffLogEvent().ExecuteCommandAsync();
{ //sendDsList.Add(item.BookingId);
x.ATD //await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}).EnableDiffLogEvent().ExecuteCommandAsync();
//sendDsList.Add(item.BookingId);
//await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
/*
* 2023824ATD
*
*
*/
////批量变更相同船期
//if (!string.IsNullOrEmpty(o.VESSEL) && !string.IsNullOrEmpty(o.VOYNO) && !string.IsNullOrEmpty(o.CARRIERID))
//{
// var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == o.VOYNO && x.VESSEL == o.VESSEL && x.CARRIERID == o.CARRIERID && x.TenantId == o.TenantId && x.IsDeleted == false && x.Id != item.BookingId).ToListAsync();
// foreach (var it in order)
// {
// var _oldorder = it;
// var _oldatd = it.ATD;
// if (_oldatd != item.OpTime)
// {
// it.ATD = item.OpTime;
// await _rep.UpdateAsync(it);
// await _bookingorderservice.SaveLog(it, _oldorder);
// await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
// }
// }
//}
} }
else if (item.Status == "ETD")
/*
* 2023824ATD
*
*
*/
////批量变更相同船期
//if (!string.IsNullOrEmpty(o.VESSEL) && !string.IsNullOrEmpty(o.VOYNO) && !string.IsNullOrEmpty(o.CARRIERID))
//{
// var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == o.VOYNO && x.VESSEL == o.VESSEL && x.CARRIERID == o.CARRIERID && x.TenantId == o.TenantId && x.IsDeleted == false && x.Id != item.BookingId).ToListAsync();
// foreach (var it in order)
// {
// var _oldorder = it;
// var _oldatd = it.ATD;
// if (_oldatd != item.OpTime)
// {
// it.ATD = item.OpTime;
// await _rep.UpdateAsync(it);
// await _bookingorderservice.SaveLog(it, _oldorder);
// await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
// }
// }
//}
}
else if (item.Status == "ETD")
{
if (order != null && item.OpTime != null && order.YgtETD != item.OpTime)
{ {
if (order != null && item.OpTime != null && order.YgtETD != item.OpTime) order.YgtETD = item.OpTime;
await tenantDb.Updateable(order).UpdateColumns(x => new
{ {
order.YgtETD = item.OpTime; x.YgtETD
await tenantDb.Updateable(order).UpdateColumns(x => new }).EnableDiffLogEvent().ExecuteCommandAsync();
{ //await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
x.YgtETD
}).EnableDiffLogEvent().ExecuteCommandAsync();
//await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
} }
else if (item.Status == "ATA") }
else if (item.Status == "ATA")
{
if (order != null && item.OpTime != null && order.StartATA != item.OpTime)
{ {
if (order != null && item.OpTime != null && order.StartATA != item.OpTime) order.StartATA = item.OpTime;
await tenantDb.Updateable(order).UpdateColumns(x => new
{ {
order.StartATA = item.OpTime; x.StartATA
await tenantDb.Updateable(order).UpdateColumns(x => new }).EnableDiffLogEvent().ExecuteCommandAsync();
{ //await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
x.StartATA
}).EnableDiffLogEvent().ExecuteCommandAsync();
//await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
} }
else if (item.Status == "ETA") }
else if (item.Status == "ETA")
{
if (order != null && item.OpTime != null && order.StartETA != item.OpTime)
{ {
if (order != null && item.OpTime != null && order.StartETA != item.OpTime) order.StartETA = item.OpTime;
await tenantDb.Updateable(order).UpdateColumns(x => new
{ {
order.StartETA = item.OpTime; x.StartETA
await tenantDb.Updateable(order).UpdateColumns(x => new }).EnableDiffLogEvent().ExecuteCommandAsync();
{ //await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
x.StartETA
}).EnableDiffLogEvent().ExecuteCommandAsync();
//await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
} }
else if (item.Status == "MDGETA") }
else if (item.Status == "MDGETA")
{
if (order != null && item.OpTime != null && order.ETA != item.OpTime)
{ {
if (order != null && item.OpTime != null && order.ETA != item.OpTime) order.ETA = item.OpTime;
await tenantDb.Updateable(order).UpdateColumns(x => new
{ {
order.ETA = item.OpTime; x.ETA
await tenantDb.Updateable(order).UpdateColumns(x => new }).EnableDiffLogEvent().ExecuteCommandAsync();
{ //await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
x.ETA
}).EnableDiffLogEvent().ExecuteCommandAsync();
//await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
} }
else if (item.Status == "MDGATA")
}
else if (item.Status == "MDGATA")
{
if (order != null && item.OpTime != null && order.ATA != item.OpTime)
{ {
if (order != null && item.OpTime != null && order.ATA != item.OpTime) order.ATA = item.OpTime;
await tenantDb.Updateable(order).UpdateColumns(x => new
{ {
order.ATA = item.OpTime; x.ATA
await tenantDb.Updateable(order).UpdateColumns(x => new }).EnableDiffLogEvent().ExecuteCommandAsync();
{ //await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
x.ATA
}).EnableDiffLogEvent().ExecuteCommandAsync();
//await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
} }
} }
} }
#endregion
} }
#endregion
} }
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -114,6 +114,7 @@ namespace DS.WMS.Core.Op.Method
billdto.PWD = userPwd; billdto.PWD = userPwd;
billdto.url = resUrl; billdto.url = resUrl;
billdto.Gid = userId; billdto.Gid = userId;
billdto.PushBackKey = user.TenantId;//根据回传的租户Id回调
var json = billdto.ToJsonString(); var json = billdto.ToJsonString();
var postData =new { msg = json }; var postData =new { msg = json };
@ -163,7 +164,7 @@ namespace DS.WMS.Core.Op.Method
Key = userKey, Key = userKey,
PWD = userPwd, PWD = userPwd,
Gid = userId, Gid = userId,
PushBackKey= user.TenantId.ToString(), PushBackKey= user.TenantId,
}; };
foreach (var item in req) foreach (var item in req)
{ {

@ -24,7 +24,7 @@ public class UserReq
/// <summary> /// <summary>
/// 密码 /// 密码
/// </summary> /// </summary>
[RegularExpression(pattern:@"^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$",ErrorMessage ="8")] //[RegularExpression(pattern:@"^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$",ErrorMessage ="密码至少要包含8个字符同时包含至少一个大写字母、一个小写字母、一个数字和一个特殊字符")]
public string Password { get; set; } public string Password { get; set; }
/// <summary> /// <summary>

@ -1,4 +1,5 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Sys.Dtos; using DS.WMS.Core.Sys.Dtos;
namespace DS.WMS.Core.Sys.Interface; namespace DS.WMS.Core.Sys.Interface;
@ -32,4 +33,12 @@ public interface IUserService
/// <param name="code"></param> /// <param name="code"></param>
/// <returns></returns> /// <returns></returns>
public Task<DataResult> CheckUserCode(string code); public Task<DataResult> CheckUserCode(string code);
/// <summary>
/// 删除用户
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult> BatchDelUser(IdModel req);
} }

@ -1,7 +1,10 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers; using DS.Module.Core.Helpers;
using DS.Module.SqlSugar;
using DS.Module.UserModule; using DS.Module.UserModule;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Sys.Dtos; using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface; using DS.WMS.Core.Sys.Interface;
@ -114,7 +117,6 @@ public class UserService : IUserService
} }
} }
#endregion #endregion
var data = model.MapTo<UserReq, SysUser>(); var data = model.MapTo<UserReq, SysUser>();
@ -150,7 +152,7 @@ public class UserService : IUserService
} }
if (model.LaneIds.Count() > 0) if (model.LaneIds.Count() > 0)
{ {
foreach (var item in model.OrgIds) foreach (var item in model.LaneIds)
{ {
var laneUser = new SysUserLane var laneUser = new SysUserLane
{ {
@ -263,4 +265,39 @@ public class UserService : IUserService
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess); return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
} }
} }
/// <summary>
/// 删除用户
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult> BatchDelUser(IdModel req)
{
if (req.Ids.Contains(long.Parse(user.UserId)))
{
return await Task.FromResult(DataResult.Failed("不能删除本人账号!"));
}
var list = await db.Queryable<SysUser>().Where(x => req.Ids.Contains(x.Id)).ToListAsync();
if (list.Count > 0)
{
foreach (var item in list)
{
var roleUsers = await db.Queryable<SysRoleUser>().Where(x => x.UserId == item.Id).ToListAsync();
if (roleUsers.Count > 0)
await db.Deleteable(roleUsers).ExecuteCommandAsync();
var orgUsers = await db.Queryable<SysOrgUser>().Where(x => x.UserId == item.Id).ToListAsync();
if (orgUsers.Count > 0)
await db.Deleteable(orgUsers).ExecuteCommandAsync();
var userLanes = await db.Queryable<SysUserLane>().Where(x => x.UserId == item.Id).ToListAsync();
if (userLanes.Count > 0)
await db.Deleteable(userLanes).ExecuteCommandAsync();
}
await db.Deleteable(list).ExecuteCommandAsync();
}
return await Task.FromResult(DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess));
}
} }

@ -1,4 +1,5 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Sys.Dtos; using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Interface; using DS.WMS.Core.Sys.Interface;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -72,4 +73,17 @@ public class UserController : ApiController
var res = await _invokeService.CheckUserCode(code); var res = await _invokeService.CheckUserCode(code);
return res; return res;
} }
/// <summary>
/// 批量删除用户
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("BatchDelUser")]
public async Task<DataResult> BatchDelUser([FromBody] IdModel req)
{
var res =await _invokeService.BatchDelUser(req);
return res;
}
} }
Loading…
Cancel
Save