|
|
@ -24,43 +24,153 @@ using WY.NewJit.PrintTable.Dtos; |
|
|
|
|
|
|
|
namespace WY.NewJit.PrintTable |
|
|
|
{ |
|
|
|
[Route("api/newjit/already-print")] |
|
|
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.报文打印)] |
|
|
|
public class AlreadyPrintAppService : ApplicationService, IAlreadyPrintAppService |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// 取待打印列表
|
|
|
|
/// 错误信息前缀
|
|
|
|
/// </summary>
|
|
|
|
private string _errorMessagePrefix |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
return System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."; |
|
|
|
} |
|
|
|
} |
|
|
|
private ILogger<WaitPrint> _logger; |
|
|
|
private readonly NewJitDapperRepository _newJitDapperRepository; |
|
|
|
public AlreadyPrintAppService(ILogger<WaitPrint> logger, NewJitDapperRepository newJitDapperRepository) |
|
|
|
{ |
|
|
|
_logger = logger; |
|
|
|
_newJitDapperRepository = newJitDapperRepository; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 已打印列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input">输入查询条件</param>
|
|
|
|
/// <returns>返回符合条件的排序分页列表</returns>
|
|
|
|
//[HttpGet]
|
|
|
|
//[UnitOfWork(false)]
|
|
|
|
//[Route("wait-print-list")]
|
|
|
|
//public virtual async Task<PagedResultDto<WaitPrintDto>> GetWaitPrintListAsync(QueryAlreadyPrintDto input)
|
|
|
|
//{
|
|
|
|
// _logger.LogDebug(_errorMessagePrefix + "GetListAsync 进入");
|
|
|
|
// try
|
|
|
|
// {
|
|
|
|
// PagedResultDto<WaitPrintDto> ret = new PagedResultDto<WaitPrintDto>();
|
|
|
|
// if (input.BusinessType == BusinessTypeEnum.MenBan)
|
|
|
|
// {
|
|
|
|
// ret = await QueryByConditionAsync(input, (PagedAndSortedBase)input);
|
|
|
|
// }
|
|
|
|
// else if (input.BusinessType == BusinessTypeEnum.OtherZhuHuBan || input.BusinessType == BusinessTypeEnum.ZhuHuBan)
|
|
|
|
// {
|
|
|
|
// ret = await QueryZHBByConditionAsync(input, (PagedAndSortedBase)input);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// throw new BusinessException("1001", "请传入正确的BusinessType参数!");
|
|
|
|
// }
|
|
|
|
// return ret;
|
|
|
|
// }
|
|
|
|
// catch (Exception ex)
|
|
|
|
// {
|
|
|
|
// string errMsg = _errorMessagePrefix + "GetListAsync 执行出错:" + ex.Message;
|
|
|
|
// _logger.LogError(errMsg);
|
|
|
|
// return new PagedResultDto<WaitPrintDto>(0, new List<WaitPrintDto>());
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
[HttpGet] |
|
|
|
[UnitOfWork(false)] |
|
|
|
[Route("already-print-list")] |
|
|
|
public virtual async Task<PagedResultDto<AlreadyPrintDto>> GetAlreadyPrintListAsync(QueryAlreadyPrintDto input) |
|
|
|
{ |
|
|
|
_logger.LogDebug(_errorMessagePrefix + "GetAlreadyPrintListAsync 进入"); |
|
|
|
try |
|
|
|
{ |
|
|
|
PagedResultDto<AlreadyPrintDto> ret = new PagedResultDto<AlreadyPrintDto>(); |
|
|
|
string where = GetWhere(input); |
|
|
|
ret.TotalCount = await GetEntityCountAsync("FisAlreadyPrint", where); |
|
|
|
//计算分页
|
|
|
|
int skipNum = input.SkipCount; |
|
|
|
int takeNum = input.MaxResultCount; |
|
|
|
var lst = await GetEntityListFromToAsync<AlreadyPrintDto>("FisAlreadyPrint", where, "HostSN2", skipNum, takeNum); |
|
|
|
ret.Items = lst; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
string errMsg = _errorMessagePrefix + "GetAlreadyPrintListAsync 执行出错:" + ex.Message; |
|
|
|
_logger.LogError(errMsg); |
|
|
|
return new PagedResultDto<AlreadyPrintDto>(0, new List<AlreadyPrintDto>()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static string GetWhere(QueryAlreadyPrintDto input) |
|
|
|
{ |
|
|
|
//select * from FisWaitPrint
|
|
|
|
//where 1=1 and BusinessType = 1 and ProductLine = '01' and PrintType = 1 and HostSN >= 10377 and HostSN <= 10388
|
|
|
|
//order by HostSN2
|
|
|
|
string where = ""; |
|
|
|
if (input.BusinessType != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and BusinessType = {0}", ((int)input.BusinessType).ToString()); |
|
|
|
} |
|
|
|
if (input.ProductLine != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and ProductLine = '{0}'", input.ProductLine); |
|
|
|
} |
|
|
|
if (input.PrintType != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and PrintType = {0}", ((int)input.PrintType).ToString()); |
|
|
|
} |
|
|
|
if (input.HostSNBegin.HasValue()) |
|
|
|
{ |
|
|
|
where += string.Format(" and HostSN >= {0}", input.HostSNBegin); |
|
|
|
} |
|
|
|
if (input.HostSNEnd.HasValue()) |
|
|
|
{ |
|
|
|
where += string.Format(" and HostSN <= {0}", input.HostSNEnd); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.KNRBegin)) |
|
|
|
{ |
|
|
|
where += string.Format(" and KNR >= '{0}'", input.KNRBegin); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.KNREnd)) |
|
|
|
{ |
|
|
|
where += string.Format(" and KNR <= '{0}'", input.KNREnd); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.VINBegin)) |
|
|
|
{ |
|
|
|
where += string.Format(" and VIN >= '{0}'", input.VINBegin); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.VINEnd)) |
|
|
|
{ |
|
|
|
where += string.Format(" and VIN <= '{0}'", input.VINEnd); |
|
|
|
} |
|
|
|
if (input.AssemblyID != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and AssemblyID = '{0}'", input.AssemblyID.ToString()); |
|
|
|
} |
|
|
|
if (input.OnlineTimeBegin != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and OnlineTime >= '{0}'", ((DateTime)input.OnlineTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); |
|
|
|
} |
|
|
|
if (input.OnlineTimeEnd != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and OnlineTime <= '{0}'", ((DateTime)input.OnlineTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); |
|
|
|
} |
|
|
|
if (input.VehicleModelCode != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and VehicleModelCode like '%{0}%'", input.VehicleModelCode); |
|
|
|
} |
|
|
|
if (input.ReceiveTimeBegin != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and ReceiveTime >= '{0}'", ((DateTime)input.ReceiveTimeBegin).ToString("yyyy-MM-dd HH:mm:ss")); |
|
|
|
} |
|
|
|
if (input.ReceiveTimeEnd != null) |
|
|
|
{ |
|
|
|
where += string.Format(" and ReceiveTime <= '{0}'", ((DateTime)input.ReceiveTimeEnd).ToString("yyyy-MM-dd HH:mm:ss")); |
|
|
|
} |
|
|
|
if (input.BillStatus != null && input.BillStatus != BillStatusEnum.None) |
|
|
|
{ |
|
|
|
where += string.Format(" and BillStatus = {0}", ((int)input.BillStatus).ToString()); |
|
|
|
} |
|
|
|
return where; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 取单表记录总数
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="tableName"></param>
|
|
|
|
/// <param name="where"></param>
|
|
|
|
/// <param name="orderFieldName"></param>
|
|
|
|
/// <param name="pageSize"></param>
|
|
|
|
/// <param name="pageIndex"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<int> GetEntityCountAsync(string tableName, string where) |
|
|
|
{ |
|
|
|
string sql = $"select count(*) from {tableName} where 1=1 {where}"; |
|
|
|
var ret = await _newJitDapperRepository.GetSingleBySqlAsync<int>(sql); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
private async Task<List<T>> GetEntityListFromToAsync<T>(string tableName, string where, string orderFieldName, int skipNum, int takeNum) |
|
|
|
{ |
|
|
|
string sql = $"select * from {tableName} where 1=1 {where} order by {orderFieldName} offset {skipNum} rows fetch next {takeNum} rows only"; |
|
|
|
var ret = await _newJitDapperRepository.GetListBySqlAsync<T>(sql); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|