|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.Templates;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using NPOI.OpenXmlFormats.Wordprocessing;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using NPOI.XWPF.UserModel;
|
|
|
|
|
using Org.BouncyCastle.Crypto;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订舱业务参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "Para", Order = 10)]
|
|
|
|
|
public class ParaService : IParaService, IDynamicApiController
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<ParaGoodsInfo> _paraGoodsInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<ParaGoodsCategoryInfo> _paraGoodsCategoryInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<ParaContractNoInfo> _paraContractNoInfoRepository;
|
|
|
|
|
private readonly ILogger<ParaService> _logger;
|
|
|
|
|
|
|
|
|
|
public ParaService(SqlSugarRepository<ParaGoodsInfo> paraGoodsInfoRepository,
|
|
|
|
|
SqlSugarRepository<ParaGoodsCategoryInfo> paraGoodsCategoryInfoRepository,
|
|
|
|
|
SqlSugarRepository<ParaContractNoInfo> paraContractNoInfoRepository,
|
|
|
|
|
ILogger<ParaService> logger
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
_paraGoodsInfoRepository = paraGoodsInfoRepository;
|
|
|
|
|
_paraGoodsCategoryInfoRepository = paraGoodsCategoryInfoRepository;
|
|
|
|
|
_paraContractNoInfoRepository = paraContractNoInfoRepository;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存品名参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">品名参数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/Para/SaveParaGoodsInfo")]
|
|
|
|
|
public async Task<long> SaveParaGoodsInfo(ParaGoodsDto model)
|
|
|
|
|
{
|
|
|
|
|
ParaGoodsInfo info = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//判断代码不能重复
|
|
|
|
|
var sameList = _paraGoodsInfoRepository.AsQueryable()
|
|
|
|
|
.Where(t => t.GOODS_CODE.Equals(model.GoodsCode, StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
|
|
|
|
|
if(sameList.Count > 0 && !string.IsNullOrWhiteSpace(model.Id) && sameList.Any(t=>t.Id != long.Parse(model.Id)))
|
|
|
|
|
throw Oops.Oh($"商品编码【{model.GoodsCode}】已存在不能重复保存");
|
|
|
|
|
|
|
|
|
|
//如果填写了品名分配需要确认根据库中数据一致
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.GoodsCategory))
|
|
|
|
|
{
|
|
|
|
|
var categoryInfo = _paraGoodsCategoryInfoRepository.AsQueryable().First(t => t.GOODS_CATEGORY.Equals(model.GoodsCategory.Trim()));
|
|
|
|
|
|
|
|
|
|
if (categoryInfo == null)
|
|
|
|
|
throw Oops.Oh($"品名分类代码【{model.GoodsCategory}】不存在,请确认品名分类");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.GoodsCategoryName) && !categoryInfo.GOODS_CATEGORY_NAME.Equals(model.GoodsCategoryName.Trim()))
|
|
|
|
|
throw Oops.Oh($"品名分类名称【{model.GoodsCategoryName}】错误,code={model.GoodsCategory}请确认品名分类");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.Id))
|
|
|
|
|
{
|
|
|
|
|
info = await _paraGoodsInfoRepository.AsQueryable().FirstAsync(t => t.Id == long.Parse(model.Id));
|
|
|
|
|
|
|
|
|
|
if(info == null)
|
|
|
|
|
throw Oops.Oh($"品名信息获取失败,请确认{model.Id}对应记录是否存在");
|
|
|
|
|
|
|
|
|
|
info.GOODS_CODE = model.GoodsCode;
|
|
|
|
|
info.GOODS_NAME_CN = model.GoodsNameCN;
|
|
|
|
|
info.GOODS_NAME_EN = model.GoodsNameEN;
|
|
|
|
|
info.GOODS_DESP = model.GoodsDesp;
|
|
|
|
|
info.GOODS_CATEGORY = model.GoodsCategory;
|
|
|
|
|
info.GOODS_CATEGORY_NAME = model.GoodsCategoryName;
|
|
|
|
|
|
|
|
|
|
await _paraGoodsInfoRepository.AsUpdateable(info).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
info = model.Adapt<ParaGoodsInfo>();
|
|
|
|
|
|
|
|
|
|
await _paraGoodsInfoRepository.InsertAsync(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"保存品名参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return info.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 作废品名参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Ids">品名参数主键数组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/Para/DeleteParaGoodsInfo")]
|
|
|
|
|
public async Task<string> DeleteParaGoodsInfo([FromBody] long[] Ids)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//如果没有给主键直接抛异常
|
|
|
|
|
if (Ids.Length == 0)
|
|
|
|
|
throw Oops.Oh("没有提供需要作废的主键信息");
|
|
|
|
|
|
|
|
|
|
var list = _paraGoodsInfoRepository.AsQueryable().Where(t => Ids.Contains(t.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
if (list.Count != Ids.Length)
|
|
|
|
|
{
|
|
|
|
|
var noRecord = string.Join(",", Ids.GroupJoin(list, l => l, r => r.Id, (l, r) => {
|
|
|
|
|
var currList = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (r.Count() > 0)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
return l.ToString();
|
|
|
|
|
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray());
|
|
|
|
|
|
|
|
|
|
throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list.ForEach(async entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.IsDeleted = true;
|
|
|
|
|
entity.UpdatedTime = DateTime.Now;
|
|
|
|
|
entity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
entity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _paraGoodsInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"作废品名参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "作废成功";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 主键获取品名参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id">品名主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/Para/GetParaGoodsInfo")]
|
|
|
|
|
public async Task<ParaGoodsShowDto> GetParaGoodsInfo([FromQuery]long Id)
|
|
|
|
|
{
|
|
|
|
|
ParaGoodsShowDto model = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ParaGoodsInfo info = _paraGoodsInfoRepository.AsQueryable().First(t => t.Id == Id);
|
|
|
|
|
|
|
|
|
|
if(info == null)
|
|
|
|
|
throw Oops.Oh($"获取品名参数失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model = info.Adapt<ParaGoodsShowDto>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"获取品名参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检索品名参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="queryItem">检索值</param>
|
|
|
|
|
/// <param name="top">默认最大行数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/Para/QueryParaGoodsInfo")]
|
|
|
|
|
public async Task<List<ParaGoodsShowDto>> QueryParaGoodsInfo([FromQuery] string queryItem, [FromQuery] int top = 10)
|
|
|
|
|
{
|
|
|
|
|
List<ParaGoodsShowDto> list = new List<ParaGoodsShowDto>();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var query = _paraGoodsInfoRepository.AsQueryable();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryItem))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(t => t.GOODS_CODE.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.GOODS_NAME_CN.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.GOODS_NAME_EN.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.GOODS_DESP.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.GOODS_CATEGORY.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.GOODS_CATEGORY_NAME.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
query = query.OrderBy("GOODS_CODE asc");
|
|
|
|
|
|
|
|
|
|
var goodsList = await query.Take(top).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (goodsList.Count > 0)
|
|
|
|
|
list = goodsList.Select(t => t.Adapt<ParaGoodsShowDto>()).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"保存品名参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 品名参数台账查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="QuerySearch">品名参数台账查询请求</param>
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
[HttpPost("/Para/GetParaGoodsPage")]
|
|
|
|
|
public async Task<dynamic> GetParaGoodsPageAsync(QueryParaGoodsDto QuerySearch)
|
|
|
|
|
{
|
|
|
|
|
DateTime createBegin = DateTime.MinValue;
|
|
|
|
|
DateTime createEnd = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
DateTime updateBegin = DateTime.MinValue;
|
|
|
|
|
DateTime updateEnd = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeBegin))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.CreateTimeBegin, out createBegin))
|
|
|
|
|
throw Oops.Oh($"创建开始日期格式错误,{QuerySearch.CreateTimeBegin}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeEnd))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.CreateTimeEnd, out createEnd))
|
|
|
|
|
throw Oops.Oh($"创建结束日期格式错误,{QuerySearch.CreateTimeEnd}");
|
|
|
|
|
|
|
|
|
|
createEnd = createEnd.AddDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeBegin))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.UpdateTimeBegin, out updateBegin))
|
|
|
|
|
throw Oops.Oh($"更新起始日期格式错误,{QuerySearch.UpdateTimeBegin}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeEnd))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.UpdateTimeEnd, out updateEnd))
|
|
|
|
|
throw Oops.Oh($"更新结束日期格式错误,{QuerySearch.UpdateTimeEnd}");
|
|
|
|
|
|
|
|
|
|
updateEnd = updateEnd.AddDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string entityOrderCol = "CreatedTime";
|
|
|
|
|
|
|
|
|
|
//这里因为返回给前端的台账数据是DTO,所以这里排序时候需要转换成Entity对应的字段
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.SortField))
|
|
|
|
|
entityOrderCol = MapsterExtHelper.GetAdaptProperty<ParaGoodsShowDto, ParaGoodsInfo>(QuerySearch.SortField);
|
|
|
|
|
|
|
|
|
|
var entities = await _paraGoodsInfoRepository.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsCode), t => t.GOODS_CODE.Contains(QuerySearch.GoodsCode.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsNameCN), t => t.GOODS_NAME_CN.Contains(QuerySearch.GoodsNameCN.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value >= createBegin)
|
|
|
|
|
.WhereIF(createEnd != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value < createEnd)
|
|
|
|
|
.WhereIF(updateBegin != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value >= updateBegin)
|
|
|
|
|
.WhereIF(updateEnd != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value < updateEnd)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsDesp), t => t.GOODS_DESP.Contains(QuerySearch.GoodsDesp.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsNameEN), t => t.GOODS_NAME_EN.Contains(QuerySearch.GoodsNameEN.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsCategory), t => t.GOODS_CATEGORY.Equals(QuerySearch.GoodsCategory.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUserName), t => t.CreatedUserName.Contains(QuerySearch.CreateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUserName), t => t.UpdatedUserName.Contains(QuerySearch.UpdateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc "))
|
|
|
|
|
.ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize);
|
|
|
|
|
|
|
|
|
|
return entities.Adapt<SqlSugarPagedList<ParaGoodsShowDto>>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存品名分类参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">品名分类参数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/Para/SaveParaGoodsCategoryInfo")]
|
|
|
|
|
public async Task<long> SaveParaGoodsCategoryInfo(ParaGoodsCategoryDto model)
|
|
|
|
|
{
|
|
|
|
|
ParaGoodsCategoryInfo info = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//判断代码不能重复
|
|
|
|
|
var sameList = _paraGoodsCategoryInfoRepository.AsQueryable()
|
|
|
|
|
.Where(t => t.GOODS_CATEGORY.Equals(model.GoodsCategory, StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
|
|
|
|
|
if (sameList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.Id) || (!string.IsNullOrWhiteSpace(model.Id) && sameList.Any(t => t.Id != long.Parse(model.Id))))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"商品分类代码【{model.GoodsCategory}】已存在不能重复保存");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.Id))
|
|
|
|
|
{
|
|
|
|
|
info = await _paraGoodsCategoryInfoRepository.AsQueryable().FirstAsync(t => t.Id == long.Parse(model.Id));
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
throw Oops.Oh($"品名分类获取失败,请确认{model.Id}对应记录是否存在");
|
|
|
|
|
|
|
|
|
|
//如果填写了品名分配需要确认根据库中数据一致
|
|
|
|
|
if (!info.GOODS_CATEGORY.Equals(model.GoodsCategory, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
var existsList = _paraGoodsCategoryInfoRepository.AsQueryable()
|
|
|
|
|
.LeftJoin(_paraGoodsInfoRepository.AsQueryable(), (cate, goods) => cate.GOODS_CATEGORY == goods.GOODS_CATEGORY)
|
|
|
|
|
.Where(cate => cate.Id == info.Id)
|
|
|
|
|
.Select((cate, goods) => new { Cate = cate, Goods = goods }).ToList();
|
|
|
|
|
|
|
|
|
|
if (existsList.Any(t => t.Goods != null))
|
|
|
|
|
throw Oops.Oh($"原分类代码{info.GOODS_CATEGORY}已有对应品名参数,不能修改");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info.GOODS_CATEGORY = model.GoodsCategory;
|
|
|
|
|
info.GOODS_CATEGORY_NAME = model.GoodsCategoryName;
|
|
|
|
|
|
|
|
|
|
await _paraGoodsCategoryInfoRepository.AsUpdateable(info).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
info = model.Adapt<ParaGoodsCategoryInfo>();
|
|
|
|
|
|
|
|
|
|
await _paraGoodsCategoryInfoRepository.InsertAsync(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"保存品名分类参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return info.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 主键获取品名分类参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id">品名分类主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/Para/GetParaGoodsCategoryInfo")]
|
|
|
|
|
public async Task<ParaGoodsCategoryShowDto> GetParaGoodsCategoryInfo(long Id)
|
|
|
|
|
{
|
|
|
|
|
ParaGoodsCategoryShowDto model = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ParaGoodsCategoryInfo info = _paraGoodsCategoryInfoRepository.AsQueryable().First(t => t.Id == Id);
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
throw Oops.Oh($"获取品名分类参数失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model = info.Adapt<ParaGoodsCategoryShowDto>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"获取品名分类参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检索品名分类参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="queryItem">检索值</param>
|
|
|
|
|
/// <param name="top">默认最大行数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/Para/QueryParaGoodsCategoryInfo")]
|
|
|
|
|
public async Task<List<ParaGoodsCategoryShowDto>> QueryParaGoodsCategoryInfo([FromQuery] string queryItem, [FromQuery] int top = 10)
|
|
|
|
|
{
|
|
|
|
|
List<ParaGoodsCategoryShowDto> list = new List<ParaGoodsCategoryShowDto>();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var query = _paraGoodsCategoryInfoRepository.AsQueryable();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryItem))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(t =>
|
|
|
|
|
t.GOODS_CATEGORY.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.GOODS_CATEGORY_NAME.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
query = query.OrderBy("GOODS_CATEGORY asc");
|
|
|
|
|
|
|
|
|
|
var currList = await query.Take(top).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (currList.Count > 0)
|
|
|
|
|
list = currList.Select(t => t.Adapt<ParaGoodsCategoryShowDto>()).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"保存品名参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 作废品名分类参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Ids">品名分类参数主键数组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/Para/DeleteParaGoodsCategoryInfo")]
|
|
|
|
|
public async Task<string> DeleteParaGoodsCategoryInfo(long[] Ids)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//如果没有给主键直接抛异常
|
|
|
|
|
if (Ids.Length == 0)
|
|
|
|
|
throw Oops.Oh("没有提供需要作废的主键信息");
|
|
|
|
|
|
|
|
|
|
var list = _paraGoodsCategoryInfoRepository.AsQueryable().Where(t => Ids.Contains(t.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
if (list.Count != Ids.Length)
|
|
|
|
|
{
|
|
|
|
|
var noRecord = string.Join(",", Ids.GroupJoin(list, l => l, r => r.Id, (l, r) => {
|
|
|
|
|
var currList = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (r.Count() > 0)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
return l.ToString();
|
|
|
|
|
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray());
|
|
|
|
|
|
|
|
|
|
throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//这里需要判断当前的品名分类是否已经对应到品名上,如果已有对应则不能直接作废
|
|
|
|
|
var existsList = _paraGoodsCategoryInfoRepository.EntityContext.Queryable<ParaGoodsCategoryInfo>()
|
|
|
|
|
.InnerJoin<ParaGoodsInfo>((cate, goods) => cate.GOODS_CATEGORY == goods.GOODS_CATEGORY)
|
|
|
|
|
.Where(cate => Ids.Contains(cate.Id))
|
|
|
|
|
.Select((cate, goods) => new { Cate = cate, Goods = goods }).ToList();
|
|
|
|
|
|
|
|
|
|
if(existsList.Count > 0)
|
|
|
|
|
throw Oops.Oh($"以下分类代码已指定品名参数不能直接删除,{string.Join(",",existsList.Select(t=>t.Cate.GOODS_CATEGORY).Distinct().ToArray())}");
|
|
|
|
|
|
|
|
|
|
list.ForEach(async entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.IsDeleted = true;
|
|
|
|
|
entity.UpdatedTime = DateTime.Now;
|
|
|
|
|
entity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
entity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _paraGoodsCategoryInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"作废品名参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "作废成功";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 品名分类参数台账查询
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 品名分类参数台账查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="QuerySearch">品名分类参数台账查询请求</param>
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
[HttpPost("/Para/GetParaGoodsCategoryPage")]
|
|
|
|
|
public async Task<dynamic> GetParaGoodsCategoryPageAsync(QueryParaGoodsCategoryDto QuerySearch)
|
|
|
|
|
{
|
|
|
|
|
DateTime createBegin = DateTime.MinValue;
|
|
|
|
|
DateTime createEnd = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
DateTime updateBegin = DateTime.MinValue;
|
|
|
|
|
DateTime updateEnd = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeBegin))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.CreateTimeBegin, out createBegin))
|
|
|
|
|
throw Oops.Oh($"创建开始日期格式错误,{QuerySearch.CreateTimeBegin}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeEnd))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.CreateTimeEnd, out createEnd))
|
|
|
|
|
throw Oops.Oh($"创建结束日期格式错误,{QuerySearch.CreateTimeEnd}");
|
|
|
|
|
|
|
|
|
|
createEnd = createEnd.AddDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeBegin))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.UpdateTimeBegin, out updateBegin))
|
|
|
|
|
throw Oops.Oh($"更新起始日期格式错误,{QuerySearch.UpdateTimeBegin}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeEnd))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.UpdateTimeEnd, out updateEnd))
|
|
|
|
|
throw Oops.Oh($"更新结束日期格式错误,{QuerySearch.UpdateTimeEnd}");
|
|
|
|
|
|
|
|
|
|
updateEnd = updateEnd.AddDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string entityOrderCol = "CreatedTime";
|
|
|
|
|
|
|
|
|
|
//这里因为返回给前端的台账数据是DTO,所以这里排序时候需要转换成Entity对应的字段
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.SortField))
|
|
|
|
|
entityOrderCol = MapsterExtHelper.GetAdaptProperty<ParaGoodsCategoryShowDto, ParaGoodsCategoryInfo>(QuerySearch.SortField);
|
|
|
|
|
|
|
|
|
|
var entities = await _paraGoodsCategoryInfoRepository.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsCategory), t => t.GOODS_CATEGORY.Contains(QuerySearch.GoodsCategory.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsCategoryName), t => t.GOODS_CATEGORY_NAME.Contains(QuerySearch.GoodsCategoryName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value >= createBegin)
|
|
|
|
|
.WhereIF(createEnd != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value < createEnd)
|
|
|
|
|
.WhereIF(updateBegin != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value >= updateBegin)
|
|
|
|
|
.WhereIF(updateEnd != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value < updateEnd)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUserName), t => t.CreatedUserName.Contains(QuerySearch.CreateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUserName), t => t.UpdatedUserName.Contains(QuerySearch.UpdateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc "))
|
|
|
|
|
.ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize);
|
|
|
|
|
|
|
|
|
|
return entities.Adapt<SqlSugarPagedList<ParaGoodsCategoryShowDto>>();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存约号参数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存约号参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">约号参数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/Para/SaveParaContractNoInfo")]
|
|
|
|
|
public async Task<long> SaveParaContractNoInfo(ParaContractNoDto model)
|
|
|
|
|
{
|
|
|
|
|
ParaContractNoInfo info = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
////判断代码不能重复
|
|
|
|
|
//var sameList = _paraContractNoInfoRepository.AsQueryable()
|
|
|
|
|
// .Where(t => t.CONTRACT_NO.Equals(model.ContractNo, StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
|
|
|
|
|
//if (sameList.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// if (string.IsNullOrWhiteSpace(model.Id) || (!string.IsNullOrWhiteSpace(model.Id) && sameList.Any(t => t.Id != long.Parse(model.Id))))
|
|
|
|
|
// {
|
|
|
|
|
// throw Oops.Oh($"合约号编号【{model.ContractNo}】已存在不能重复保存");
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.Id))
|
|
|
|
|
{
|
|
|
|
|
info = await _paraContractNoInfoRepository.AsQueryable().FirstAsync(t => t.Id == long.Parse(model.Id));
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
throw Oops.Oh($"约号获取失败,请确认{model.Id}对应记录是否存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info.CONTRACT_NO = model.ContractNo?.Trim();
|
|
|
|
|
info.CONTRACT_NAME = model.ContractName?.Trim();
|
|
|
|
|
info.CONTRACT_NOTE = model.ContractNote?.Trim();
|
|
|
|
|
|
|
|
|
|
await _paraContractNoInfoRepository.AsUpdateable(info).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
info = model.Adapt<ParaContractNoInfo>();
|
|
|
|
|
|
|
|
|
|
await _paraContractNoInfoRepository.InsertAsync(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"保存约号参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return info.Id;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 主键获取约号参数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 主键获取约号参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id">约号主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/Para/GetParaContractNoInfo")]
|
|
|
|
|
public async Task<ParaContractNoShowDto> GetParaContractNoInfo(long Id)
|
|
|
|
|
{
|
|
|
|
|
ParaContractNoShowDto model = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ParaContractNoInfo info = _paraContractNoInfoRepository.AsQueryable().First(t => t.Id == Id);
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
throw Oops.Oh($"获取约号参数失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model = info.Adapt<ParaContractNoShowDto>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"获取约号参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 检索约号参数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检索约号参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="queryItem">检索值</param>
|
|
|
|
|
/// <param name="top">默认最大行数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/Para/QuerytParaContractNoInfo")]
|
|
|
|
|
public async Task<List<ParaContractNoShowDto>> QuerytParaContractNoInfo([FromQuery] string queryItem, [FromQuery] int top = 10)
|
|
|
|
|
{
|
|
|
|
|
List<ParaContractNoShowDto> list = new List<ParaContractNoShowDto>();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var query = _paraContractNoInfoRepository.AsQueryable();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryItem))
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(t =>
|
|
|
|
|
t.CONTRACT_NO.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.CONTRACT_NAME.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
t.CONTRACT_NOTE.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
query = query.OrderBy("CONTRACT_NO asc");
|
|
|
|
|
|
|
|
|
|
var currList = await query.Take(top).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (currList.Count > 0)
|
|
|
|
|
list = currList.Select(t => t.Adapt<ParaContractNoShowDto>()).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"检索约号参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 作废约号参数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 作废约号参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Ids">约号参数主键数组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/Para/DeleteParaContractNoInfo")]
|
|
|
|
|
public async Task<string> DeleteParaContractNoInfo(long[] Ids)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//如果没有给主键直接抛异常
|
|
|
|
|
if (Ids.Length == 0)
|
|
|
|
|
throw Oops.Oh("没有提供需要作废的主键信息");
|
|
|
|
|
|
|
|
|
|
var list = _paraContractNoInfoRepository.AsQueryable().Where(t => Ids.Contains(t.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
if (list.Count != Ids.Length)
|
|
|
|
|
{
|
|
|
|
|
var noRecord = string.Join(",", Ids.GroupJoin(list, l => l, r => r.Id, (l, r) => {
|
|
|
|
|
var currList = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (r.Count() > 0)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
return l.ToString();
|
|
|
|
|
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray());
|
|
|
|
|
|
|
|
|
|
throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list.ForEach(async entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.IsDeleted = true;
|
|
|
|
|
entity.UpdatedTime = DateTime.Now;
|
|
|
|
|
entity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
entity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _paraContractNoInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"作废约号参数异常,{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "作废成功";
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 约号参数台账查询
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 约号参数台账查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="QuerySearch">约号参数台账查询请求</param>
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
[HttpPost("/Para/GetParaContractNoPage")]
|
|
|
|
|
public async Task<dynamic> GetParaContractNoPageAsync(QueryParaContractNoDto QuerySearch)
|
|
|
|
|
{
|
|
|
|
|
DateTime createBegin = DateTime.MinValue;
|
|
|
|
|
DateTime createEnd = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
DateTime updateBegin = DateTime.MinValue;
|
|
|
|
|
DateTime updateEnd = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeBegin))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.CreateTimeBegin, out createBegin))
|
|
|
|
|
throw Oops.Oh($"创建开始日期格式错误,{QuerySearch.CreateTimeBegin}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeEnd))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.CreateTimeEnd, out createEnd))
|
|
|
|
|
throw Oops.Oh($"创建结束日期格式错误,{QuerySearch.CreateTimeEnd}");
|
|
|
|
|
|
|
|
|
|
createEnd = createEnd.AddDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeBegin))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.UpdateTimeBegin, out updateBegin))
|
|
|
|
|
throw Oops.Oh($"更新起始日期格式错误,{QuerySearch.UpdateTimeBegin}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeEnd))
|
|
|
|
|
{
|
|
|
|
|
if (!DateTime.TryParse(QuerySearch.UpdateTimeEnd, out updateEnd))
|
|
|
|
|
throw Oops.Oh($"更新结束日期格式错误,{QuerySearch.UpdateTimeEnd}");
|
|
|
|
|
|
|
|
|
|
updateEnd = updateEnd.AddDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string entityOrderCol = "CreatedTime";
|
|
|
|
|
|
|
|
|
|
//这里因为返回给前端的台账数据是DTO,所以这里排序时候需要转换成Entity对应的字段
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(QuerySearch.SortField))
|
|
|
|
|
entityOrderCol = MapsterExtHelper.GetAdaptProperty<ParaContractNoShowDto, ParaContractNoInfo>(QuerySearch.SortField);
|
|
|
|
|
|
|
|
|
|
var entities = await _paraContractNoInfoRepository.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.ContractNo), t => t.CONTRACT_NO.Contains(QuerySearch.ContractNo.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.ContractName), t => t.CONTRACT_NAME.Contains(QuerySearch.ContractName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.ContractNote), t => t.CONTRACT_NOTE.Contains(QuerySearch.ContractNote.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value >= createBegin)
|
|
|
|
|
.WhereIF(createEnd != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value < createEnd)
|
|
|
|
|
.WhereIF(updateBegin != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value >= updateBegin)
|
|
|
|
|
.WhereIF(updateEnd != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value < updateEnd)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUserName), t => t.CreatedUserName.Contains(QuerySearch.CreateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUserName), t => t.UpdatedUserName.Contains(QuerySearch.UpdateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc "))
|
|
|
|
|
.ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize);
|
|
|
|
|
|
|
|
|
|
return entities.Adapt<SqlSugarPagedList<ParaContractNoShowDto>>();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|