feat 根据工号获取海宁消费记录
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Order.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
@@ -148,6 +149,18 @@ public class BalancesController : ControllerBase
|
||||
[HttpPost("haining/import")]
|
||||
public async Task Import(BalanceHainingImportRequest request)
|
||||
{
|
||||
await _balanceService.Import(request);
|
||||
await _balanceService.HainingImportAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据工号海宁餐补数据获取
|
||||
/// </summary>
|
||||
/// <param name="userCode">工号</param>
|
||||
/// <returns></returns>
|
||||
[IgnoreTenant]
|
||||
[HttpGet("haining/list")]
|
||||
public async Task<List<BalanceHainingDownloadResponse>> HainingDownloadAsync([Required(ErrorMessage = "工号不能为空")] string userCode)
|
||||
{
|
||||
return await _balanceService.HainingDownloadAsync(userCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Converters;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
{
|
||||
public class BalanceHainingDownloadResponse
|
||||
{
|
||||
//工号、消费厂区、人员档案厂区、人事范围(若有)、部门(若有)、成本日期,消费时间,备注,金额,type,source,营业点,设备号,流水号,
|
||||
|
||||
public string No { get; set; }
|
||||
|
||||
public string Factory { get; set; }
|
||||
public string OriginFactory { get; set; }
|
||||
public string Werks { get; set; }
|
||||
public string DepartmentNo { get; set; }
|
||||
public string DepartmentName { get; set; }
|
||||
|
||||
[JsonConverter(typeof(ToDateJsonConverter))]
|
||||
public DateTime CostDate { get; set; }
|
||||
|
||||
[JsonConverter(typeof(ToDateJsonConverter), "yyyy-MM-dd HH:mm:ss.fff")]
|
||||
public DateTime CostDateTime { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
public BalanceRecordTypeEnumType Type { get; set; }
|
||||
|
||||
public BalanceRecordSourceEnumType Source { get; set; }
|
||||
|
||||
public string BusinessPlaceCode { get; set; }
|
||||
|
||||
public string DeviceUniqueNo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -31,5 +31,7 @@ public interface IBalanceService : IScopeDependency
|
||||
Task<Pagination<DevicePageResponse>> GetConsumeDeviceAsync(GetConsumeDeviceRequest request);
|
||||
|
||||
|
||||
Task Import(BalanceHainingImportRequest request);
|
||||
}
|
||||
Task HainingImportAsync(BalanceHainingImportRequest request);
|
||||
|
||||
Task<List<BalanceHainingDownloadResponse>> HainingDownloadAsync(string userCode);
|
||||
}
|
||||
@@ -494,7 +494,7 @@ public class BalanceService : IBalanceService
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task Import(BalanceHainingImportRequest request)
|
||||
public async Task HainingImportAsync(BalanceHainingImportRequest request)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == request.UserCode).SingleAsync();
|
||||
gainfo.ThrowIfNull($"工号{request.UserCode}不存在");
|
||||
@@ -510,7 +510,7 @@ public class BalanceService : IBalanceService
|
||||
ShiftCode = c.Code
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
|
||||
if (request.Type == BalanceRecordTypeEnumType.Out)
|
||||
{
|
||||
businessPlace.ThrowIfNull($"营业点{request.BusinessPlaceCode}不存在");
|
||||
@@ -529,12 +529,12 @@ public class BalanceService : IBalanceService
|
||||
UserNo = gainfo.No,
|
||||
No = request.No,
|
||||
UserCode = gainfo.Code,
|
||||
TenantId = request.Factory,
|
||||
Status = BalanceRecordStatusEnumType.Valid,
|
||||
Source = request.Source,
|
||||
Remark = request.Remark,
|
||||
CostId = gainfo.CostId,
|
||||
SubsidiesFromMonth = request.CostDate.ToString("yyyyMM"),
|
||||
TenantId = request.Factory,
|
||||
OriginTenantId = gainfo.Factory,
|
||||
Werks = gainfo.Werks,
|
||||
Name = gainfo.Name,
|
||||
@@ -561,6 +561,36 @@ public class BalanceService : IBalanceService
|
||||
.ExecuteCommandThrowVersionAsync("写入失败,正在消费中");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<BalanceHainingDownloadResponse>> HainingDownloadAsync(string userCode)
|
||||
{
|
||||
return await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.LeftJoin<GainfoEntity>((record, ga) => record.UserNo == ga.No)
|
||||
.LeftJoin<DepartmentEntity>((record, ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<BusinessPlaceEntity>((record, ga, department, bPlace) => record.BusinessPlaceCode == bPlace.Code)
|
||||
.Where(record => record.Status == BalanceRecordStatusEnumType.Valid)
|
||||
.Where((record, ga) => ga.Code == userCode)
|
||||
.OrderBy(record => record.CreateTime, OrderByType.Desc)
|
||||
.Select((record, ga, department, bPlace) => new BalanceHainingDownloadResponse
|
||||
{
|
||||
No = record.No,
|
||||
Factory = record.TenantId,
|
||||
OriginFactory = record.OriginTenantId,
|
||||
Werks = record.Werks,
|
||||
DepartmentNo = record.DepartmentNo,
|
||||
DepartmentName = department.Name,
|
||||
CostDate = record.CostDate,
|
||||
CostDateTime = record.CostDateTime,
|
||||
Remark = record.Remark,
|
||||
Amount = SqlFunc.Abs(record.Amount),
|
||||
Type = record.Type,
|
||||
Source = record.Source,
|
||||
BusinessPlaceCode = bPlace.CustomCode,
|
||||
DeviceUniqueNo = record.DeviceUniqueNo
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取离线设备
|
||||
|
||||
Reference in New Issue
Block a user