jianghaiqing 2 years ago
commit 2588dbc655

@ -121,6 +121,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<ParaContractNoInfo> _paraContractNoInfoRepository;
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _djyWebsiteAccountConfigRepository;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISysOrgService _orgService;
private readonly IBookingGoodsStatusConfigService _GoodsConfig;
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
@ -138,7 +139,8 @@ namespace Myshipping.Application
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact, SqlSugarRepository<BookingSampleBill> repSampleBill, SqlSugarRepository<DjyCustomer> djycustomer,
SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<DjyUserMailAccount> repUserMail, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig,
SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingServiceItem> serviceItem,
SqlSugarRepository<ParaContractNoInfo> paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository<DjyWebsiteAccountConfig> djyWebsiteAccountConfigRepository)
SqlSugarRepository<ParaContractNoInfo> paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository<DjyWebsiteAccountConfig> djyWebsiteAccountConfigRepository,
ISysOrgService orgService)
{
this._logger = logger;
this._rep = rep;
@ -173,6 +175,7 @@ namespace Myshipping.Application
this._djycustomer = djycustomer;
this._paraGoodsInfoRepository = paraGoodsInfoRepository;
this._paraContractNoInfoRepository = paraContractNoInfoRepository;
this._orgService = orgService;
_httpContextAccessor = httpContextAccessor;
_GoodsConfig = GoodsConfig;
@ -198,6 +201,21 @@ namespace Myshipping.Application
var etoday = DateTime.Now.AddDays(15);
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
//按部门查询
List<string> saleUserList = null;
List<string> opUserList = null;
if (input.OrgSale.HasValue)
{
var tmpList = await _orgService.GetUserIdListInOrg(input.OrgSale.Value);
saleUserList = tmpList.Select(x => x.ToString()).ToList();
}
if (input.OrgOp.HasValue)
{
var tmpList = await _orgService.GetUserIdListInOrg(input.OrgOp.Value);
opUserList = tmpList.Select(x => x.ToString()).ToList();
}
#region
var entities = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID)
.WhereIF(!input.ISDel, x => x.IsDeleted == false)
@ -353,6 +371,8 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrWhiteSpace(input.DZRemark), u => u.DZRemark.Contains(input.DZRemark))
.WhereIF(!string.IsNullOrWhiteSpace(input.CZRemark), u => u.CZRemark.Contains(input.CZRemark))
.WhereIF(!string.IsNullOrWhiteSpace(input.ZhanCangFlag), u => u.ZhanCangFlag == input.ZhanCangFlag)
.WhereIF(saleUserList != null && saleUserList.Count > 0, o => saleUserList.Contains(o.SALEID))
.WhereIF(opUserList != null && opUserList.Count > 0, o => opUserList.Contains(o.OPID))
.WhereIF(userlist != null && userlist.Count() > 0, u => userlist.Contains((long)u.CreatedUserId) || UserManager.UserId.ToString() == u.ROUTEID || UserManager.Name.ToString() == u.ROUTE || UserManager.UserId.ToString() == u.SALEID || UserManager.Name.ToString() == u.SALE || UserManager.UserId.ToString() == u.OPID || UserManager.Name.ToString() == u.OP || UserManager.UserId.ToString() == u.DOCID || UserManager.Name.ToString() == u.DOC || UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE)
.OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.DescSort))
.ToPagedListAsync(input.PageNo, input.PageSize);
@ -794,113 +814,113 @@ namespace Myshipping.Application
}
[HttpPost("/BookingOrder/AddOrUpdate")]
public async Task<long> AddOrUpdate(BookingOrderDto Dto)
{
if (Dto == null)
{
throw Oops.Bah("请传入正常数据!");
}
if (Dto.Id == 0)
{
return await Add(Dto);
}
else
{
await Update(Dto);
return Dto.Id;
}
}
/// <summary>
/// 增加订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/Add")]
public async Task<long> Add(BookingOrderDto input)
{
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
var ms = JsonUtil.TrimFields(input);
if (!string.IsNullOrEmpty(ms))
{
throw Oops.Bah(ms);
}
if (input.ctnInputs != null)
{
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
input.CNTRTOTAL = string.Join(" / ", groupList);
}
if (!string.IsNullOrWhiteSpace(input.MBLNO))
{
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId).FirstAsync();
if (et != null)
{
throw Oops.Bah("当前提单号已存在,请勿重复录入!");
}
}
var entity = input.Adapt<BookingOrder>();
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
//entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
await _rep.InsertAsync(entity);
if (input.ctnInputs != null)
{
foreach (var item in input.ctnInputs)
{
var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息
if (item.ctnDetailInputs != null)
{
foreach (var it in item.ctnDetailInputs)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
}
}
if (input.BookingEDIExt != null)
{
//写入EDI扩展
var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
////添加booking日志
await _bookinglog.InsertAsync(new BookingLog
{
Type = "Add",
BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
//////分单不调用
//if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
//{
// await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
//}
return entity.Id;
}
#region 废弃代码
//[HttpPost("/BookingOrder/AddOrUpdate")]
//public async Task<long> AddOrUpdate(BookingOrderDto Dto)
//{
// if (Dto == null)
// {
// throw Oops.Bah("请传入正常数据!");
// }
// if (Dto.Id == 0)
// {
// return await Add(Dto);
// }
// else
// {
// await Update(Dto);
// return Dto.Id;
// }
//}
///// <summary>
///// 增加订舱
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//[SqlSugarUnitOfWork]
//[HttpPost("/BookingOrder/Add")]
//public async Task<long> Add(BookingOrderDto input)
//{
// JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
// var ms = JsonUtil.TrimFields(input);
// if (!string.IsNullOrEmpty(ms))
// {
// throw Oops.Bah(ms);
// }
// if (input.ctnInputs != null)
// {
// var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
// input.CNTRTOTAL = string.Join(" / ", groupList);
// }
// if (!string.IsNullOrWhiteSpace(input.MBLNO))
// {
// var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId).FirstAsync();
// if (et != null)
// {
// throw Oops.Bah("当前提单号已存在,请勿重复录入!");
// }
// }
// var entity = input.Adapt<BookingOrder>();
// entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
// //entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
// await _rep.InsertAsync(entity);
// if (input.ctnInputs != null)
// {
// foreach (var item in input.ctnInputs)
// {
// var ctnentity = item.Adapt<BookingCtn>();
// ctnentity.BILLID = entity.Id;
// await _repCtn.InsertAsync(ctnentity);
// //这里保存有可能没有添加多品名,所有箱下没有货物信息
// if (item.ctnDetailInputs != null)
// {
// foreach (var it in item.ctnDetailInputs)
// {
// var ctndetail = it.Adapt<BookingCtnDetail>();
// ctndetail.CTNID = ctnentity.Id;
// await _ctndetailrep.InsertAsync(ctndetail);
// }
// }
// }
// }
// if (input.BookingEDIExt != null)
// {
// //写入EDI扩展
// var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
// ediExtEntity.BookingId = entity.Id;
// await _bookingEDIExt.InsertAsync(ediExtEntity);
// }
// ////添加booking日志
// await _bookinglog.InsertAsync(new BookingLog
// {
// Type = "Add",
// BookingId = entity.Id,
// TenantId = Convert.ToInt64(UserManager.TENANT_ID),
// CreatedTime = DateTime.Now,
// CreatedUserId = UserManager.UserId,
// CreatedUserName = UserManager.Name
// });
// //////分单不调用
// //if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
// //{
// // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// //}
// return entity.Id;
//}
#endregion
/// <summary>
/// 删除订舱
/// </summary>
@ -1051,161 +1071,161 @@ namespace Myshipping.Application
}
/// <summary>
/// 更新订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/Update")]
public async Task Update(BookingOrderDto input)
{
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
JsonUtil.TrimFields(input);
if (input.ctnInputs != null)
{
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
input.CNTRTOTAL = string.Join(" / ", groupList);
}
var main = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
if (!string.IsNullOrWhiteSpace(input.MBLNO))
{
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
if (et != null)
{
throw Oops.Bah("当前提单号已存在,请勿重复录入!");
}
}
var entity = input.Adapt<BookingOrder>();
//entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
await _rep.AsUpdateable(entity).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
await _repCtn.DeleteAsync(x => x.BILLID == input.Id);
await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
if (input.ctnInputs != null)
{
foreach (var item in input.ctnInputs)
{
var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity);
if (item.ctnDetailInputs != null)
{
foreach (var it in item.ctnDetailInputs)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
}
}
if (input.BookingEDIExt != null)
{
//检索EDI扩展
var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == input.Id);
if (ediExtEntity == null)
{
//写入EDI扩展
ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
else
{
//更新EDI扩展
var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
currEdiExtEntity.Id = ediExtEntity.Id;
currEdiExtEntity.BookingId = ediExtEntity.BookingId;
await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new
{
it.BookingId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
}
}
bool flag = true;
long bid = 0;
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
{
string name = descriptor.Name;
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
{
continue;
}
object value = descriptor.GetValue(entity);
var oldvalue = main.GetType().GetProperty(name).GetValue(main, null);
if (name == "KGS" || name == "CBM")
{
if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
{
continue;
}
}
string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
string _value = value != null ? value.ToString() : "";
if (_oldvalue != _value && !string.IsNullOrWhiteSpace(descriptor.Description))
{
if (flag)
{
////添加booking日志
bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
{
Type = "Edit",
BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
flag = false;
}
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{
PId = bid,
Field = descriptor.Description,
OldValue = _oldvalue,
NewValue = _value,
});
//if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO")
//{
// if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
// {
// await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// }
//}
}
}
}
#region 废弃代码
///// <summary>
///// 更新订舱
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//[SqlSugarUnitOfWork]
//[HttpPost("/BookingOrder/Update")]
//public async Task Update(BookingOrderDto input)
//{
// JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
// JsonUtil.TrimFields(input);
// if (input.ctnInputs != null)
// {
// var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
// input.CNTRTOTAL = string.Join(" / ", groupList);
// }
// var main = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
// if (!string.IsNullOrWhiteSpace(input.MBLNO))
// {
// var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
// if (et != null)
// {
// throw Oops.Bah("当前提单号已存在,请勿重复录入!");
// }
// }
// var entity = input.Adapt<BookingOrder>();
// //entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
// await _rep.AsUpdateable(entity).IgnoreColumns(it => new
// {
// it.ParentId,
// it.TenantId,
// it.CreatedTime,
// it.CreatedUserId,
// it.CreatedUserName,
// it.TenantName,
// it.IsDeleted,
// it.BOOKINGNO
// }).ExecuteCommandAsync();
// var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
// await _repCtn.DeleteAsync(x => x.BILLID == input.Id);
// await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
// if (input.ctnInputs != null)
// {
// foreach (var item in input.ctnInputs)
// {
// var ctnentity = item.Adapt<BookingCtn>();
// ctnentity.BILLID = entity.Id;
// await _repCtn.InsertAsync(ctnentity);
// if (item.ctnDetailInputs != null)
// {
// foreach (var it in item.ctnDetailInputs)
// {
// var ctndetail = it.Adapt<BookingCtnDetail>();
// ctndetail.CTNID = ctnentity.Id;
// await _ctndetailrep.InsertAsync(ctndetail);
// }
// }
// }
// }
// if (input.BookingEDIExt != null)
// {
// //检索EDI扩展
// var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == input.Id);
// if (ediExtEntity == null)
// {
// //写入EDI扩展
// ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
// ediExtEntity.BookingId = entity.Id;
// await _bookingEDIExt.InsertAsync(ediExtEntity);
// }
// else
// {
// //更新EDI扩展
// var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
// currEdiExtEntity.Id = ediExtEntity.Id;
// currEdiExtEntity.BookingId = ediExtEntity.BookingId;
// await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new
// {
// it.BookingId,
// it.TenantId,
// it.CreatedTime,
// it.CreatedUserId,
// it.CreatedUserName
// }).ExecuteCommandAsync();
// }
// }
// bool flag = true;
// long bid = 0;
// foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
// {
// string name = descriptor.Name;
// if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
// {
// continue;
// }
// object value = descriptor.GetValue(entity);
// var oldvalue = main.GetType().GetProperty(name).GetValue(main, null);
// if (name == "KGS" || name == "CBM")
// {
// if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
// {
// continue;
// }
// }
// string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
// string _value = value != null ? value.ToString() : "";
// if (_oldvalue != _value && !string.IsNullOrWhiteSpace(descriptor.Description))
// {
// if (flag)
// {
// ////添加booking日志
// bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
// {
// Type = "Edit",
// BookingId = entity.Id,
// TenantId = Convert.ToInt64(UserManager.TENANT_ID),
// CreatedTime = DateTime.Now,
// CreatedUserId = UserManager.UserId,
// CreatedUserName = UserManager.Name
// });
// flag = false;
// }
// await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
// {
// PId = bid,
// Field = descriptor.Description,
// OldValue = _oldvalue,
// NewValue = _value,
// });
// //if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO")
// //{
// // if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
// // {
// // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// // }
// //}
// }
// }
//}
#endregion
/// <summary>
/// 获取订舱明细
/// </summary>
@ -1571,7 +1591,7 @@ namespace Myshipping.Application
var userid = order.CreatedUserId;
if (userid != null)
{
//获取当前用户已经录入的货物状态
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == input.BookingId).
OrderBy((goods, config) => config.Sort).
@ -1589,7 +1609,7 @@ namespace Myshipping.Application
Sort = config.Sort
}).ToListAsync();
//配置中所有的货物状态
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{
@ -1604,11 +1624,12 @@ namespace Myshipping.Application
Remark = null,
Sort = config.Sort
}).ToList();
//去掉两个list中重复的货物状态
foreach (var item in list)
{
config.RemoveAll(x => x.ConfigId == item.ConfigId);
}
var t = list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).DistinctBy(x => x.StatusName).ToList();
if (t != null)
{
@ -1632,12 +1653,7 @@ namespace Myshipping.Application
it.BOOKINGNO
}).ExecuteCommandAsync();
}
List<long> tslist = new List<long>();
tslist.Add((long)input.BookingId);
var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault();
@ -6107,7 +6123,7 @@ namespace Myshipping.Application
" } " +
" ] " +
" } " +
"} " ;
"} ";
}
#endregion

@ -827,12 +827,12 @@ namespace Myshipping.Application
/// <summary>
/// 销售部门
/// </summary>
public string SaleDept { get; set; }
public long? OrgSale { get; set; }
/// <summary>
/// 操作部门
/// </summary>
public string OpDept { get; set; }
public long? OrgOp { get; set; }
}
public class AddBookingOrderInput : BookingOrderDto

@ -14245,6 +14245,19 @@
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.SysOrgService.GetOrgTreeList">
<summary>
获取租户公司的部门树(用于下拉列表,普通用户也可获取)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.SysOrgService.GetUserIdListInOrg(System.Int64)">
<summary>
根据部门ID获取指定部门及其子部门下的所有人员id
</summary>
<param name="depId"></param>
<returns></returns>
</member>
<member name="T:Myshipping.Core.Service.PosInput">
<summary>
职位参数

@ -16,4 +16,5 @@ public interface ISysOrgService
Task<dynamic> QueryOrgPageList([FromQuery] PageOrgInput input);
Task UpdateOrg(UpdateOrgInput input);
Task<List<long>> GetAllDataScopeIdList();
Task<List<long>> GetUserIdListInOrg(long orgId);
}

@ -19,23 +19,27 @@ namespace Myshipping.Core.Service;
public class SysOrgService : ISysOrgService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<SysOrg> _sysOrgRep; // 组织机构表仓储
private readonly SqlSugarRepository<SysUserDataScope> _sysUserDataScopeRep;
private readonly SqlSugarRepository<SysUserDataScope> _sysUserDataScopeRep;
private readonly SqlSugarRepository<SysEmp> _sysEmpRep;
private readonly ISysCacheService _sysCacheService;
private readonly ISysEmpService _sysEmpService;
private readonly ISysEmpExtOrgPosService _sysEmpExtOrgPosService;
public SysOrgService(SqlSugarRepository<SysOrg> sysOrgRep,
SqlSugarRepository<SysUserDataScope> sysUserDataScopeRep,
ISysCacheService sysCacheService,
ISysEmpService sysEmpService,
ISysEmpExtOrgPosService sysEmpExtOrgPosService)
public SysOrgService(SqlSugarRepository<SysOrg> sysOrgRep,
SqlSugarRepository<SysUserDataScope> sysUserDataScopeRep,
ISysCacheService sysCacheService,
ISysEmpService sysEmpService,
ISysEmpExtOrgPosService sysEmpExtOrgPosService,
SqlSugarRepository<SysEmp> sysEmpRep)
{
_sysOrgRep = sysOrgRep;
_sysUserDataScopeRep = sysUserDataScopeRep;
_sysCacheService = sysCacheService;
_sysEmpService = sysEmpService;
_sysEmpExtOrgPosService = sysEmpExtOrgPosService;
}
_sysEmpRep = sysEmpRep;
}
/// <summary>
/// 分页查询组织机构
@ -197,7 +201,7 @@ public class SysOrgService : ISysOrgService, IDynamicApiController, ITransient
try
{
_sysOrgRep.CurrentBeginTran();
// 级联删除该机构及子机构对应的角色-数据范围关联信息
await _sysOrgRep.Change<SysRoleDataScope>().DeleteAsync(u => childIdList.Contains(u.SysOrgId));
@ -207,7 +211,7 @@ public class SysOrgService : ISysOrgService, IDynamicApiController, ITransient
await _sysOrgRep.DeleteAsync(u => childIdList.Contains(u.Id));
_sysOrgRep.CurrentCommitTran();
}
catch (System.Exception)
{
@ -255,21 +259,21 @@ public class SysOrgService : ISysOrgService, IDynamicApiController, ITransient
// 如果名称有变化,则修改对应员工的机构相关信息
if (!sysOrg.Name.Equals(input.Name))
await _sysEmpService.UpdateEmpOrgInfo(sysOrg.Id, input.Name);
var isChangePid = sysOrg.Pid.ToString() != input.Pid;
var oldPids=sysOrg.Pids;
var oldPids = sysOrg.Pids;
sysOrg = input.Adapt<SysOrg>();
await FillPids(sysOrg);
//如果父级菜单有变化则修改该机构所有子级的pids
if (isChangePid)
await _sysOrgRep.UpdateAsync(m=>m.Pids.Contains(sysOrg.Id.ToString()),m=> new SysOrg { Pids = m.Pids.Replace(oldPids, sysOrg.Pids) });
if (isChangePid)
await _sysOrgRep.UpdateAsync(m => m.Pids.Contains(sysOrg.Id.ToString()), m => new SysOrg { Pids = m.Pids.Replace(oldPids, sysOrg.Pids) });
await _sysOrgRep.AsUpdateable(sysOrg).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
_sysOrgRep.CurrentCommitTran();
}
catch (System.Exception)
{
@ -376,4 +380,49 @@ public class SysOrgService : ISysOrgService, IDynamicApiController, ITransient
{
return await _sysOrgRep.AsQueryable().Select(u => u.Id).ToListAsync();
}
}
/// <summary>
/// 获取租户公司的部门树(用于下拉列表,普通用户也可获取)
/// </summary>
/// <returns></returns>
[HttpGet("/sysOrg/treeList")]
public async Task<dynamic> GetOrgTreeList()
{
var orgs = await _sysOrgRep
.Where(u => u.Status == (int)CommonStatus.ENABLE && u.TenantId == UserManager.TENANT_ID)
.OrderBy(u => u.Sort)
.Select(u => new OrgTreeNode
{
Id = u.Id,
ParentId = u.Pid,
Title = u.Name,
Value = u.Id.ToString(),
Weight = u.Sort
}).ToListAsync();
return new TreeBuildUtil<OrgTreeNode>().DoTreeBuild(orgs);
}
/// <summary>
/// 根据部门ID获取指定部门及其子部门下的所有人员id
/// </summary>
/// <param name="depId"></param>
/// <returns></returns>
public async Task<List<long>> GetUserIdListInOrg(long orgId)
{
//获取所有子部门
var orgIdList = _sysOrgRep.AsQueryable()
.Where(x => x.Pids.Contains($"[{orgId}]"))
.Select(x => x.Id)
.ToList();
//获取部门下的人
var uidList = _sysEmpRep.AsQueryable()
.Where(x => x.OrgId == orgId || orgIdList.Contains(x.OrgId))
.Select(x => x.Id)
.ToList();
return uidList;
}
}

Loading…
Cancel
Save