168 lines
7.8 KiB
C#
168 lines
7.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reactive;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Filter;
|
|
using JNPF.Systems.Entitys.Permission;
|
|
using JNPF.Systems.Entitys.System;
|
|
using JNPF.Systems.Interfaces.System;
|
|
using JNPF.VisualDev;
|
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
|
using JNPF.VisualDev.Interfaces;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json.Linq;
|
|
using Senparc.CO2NET.Extensions;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.BasicData.Interfaces;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
using Tnb.WarehouseMgr.Entities.Entity;
|
|
using Tnb.WarehouseMgr.Entities.Enums;
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
{
|
|
[OverideVisualDev(ModuleConsts.MODULE_WmsPurchaseQcrecord_ID)]
|
|
[ServiceModule(BizTypeId)]
|
|
public class WmsPurchaseQcrecordService : BaseWareHouseService
|
|
{
|
|
private const string BizTypeId = WmsWareHouseConst.BIZTYPE_WmsPurchaseQcrecord_ID;
|
|
private readonly ISqlSugarClient _db;
|
|
private readonly IUserManager _userManager;
|
|
private readonly IBillRullService _billRullService;
|
|
private readonly IRunService _runService;
|
|
private readonly IVisualDevService _visualDevService;
|
|
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
|
|
private readonly IWareHouseService _wareHouseService;
|
|
private readonly IThirdApiRecordService _thirdApiRecordService;
|
|
|
|
public WmsPurchaseQcrecordService(
|
|
ISqlSugarRepository<WmsPurchaseQcrecord> repository,
|
|
IUserManager userManager,
|
|
IBillRullService billRullService,
|
|
IRunService runService,
|
|
IVisualDevService visualDevService,
|
|
IWmsPDAScanInStockService wmsPDAScanInStock,
|
|
IThirdApiRecordService thirdApiRecordService,
|
|
IWareHouseService wareHouseService)
|
|
{
|
|
_db = repository.AsSugarClient();
|
|
_userManager = userManager;
|
|
_billRullService = billRullService;
|
|
_runService = runService;
|
|
_visualDevService = visualDevService;
|
|
_wmsPDAScanInStock = wmsPDAScanInStock;
|
|
_wareHouseService = wareHouseService;
|
|
_thirdApiRecordService = thirdApiRecordService;
|
|
}
|
|
|
|
|
|
[HttpPost, AllowAnonymous]
|
|
public async Task<dynamic> ReportData(VisualDevModelListQueryInput input)
|
|
{
|
|
var type = "";
|
|
var material_code = "";
|
|
var material_specification = "";
|
|
var batchno = "";
|
|
var container_no = "";
|
|
var time = new JArray();
|
|
if (!input.queryJson.IsNullOrWhiteSpace())
|
|
{
|
|
type = JObject.Parse(input.queryJson).Value<string>("type");
|
|
material_code = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.material_code));
|
|
batchno = JObject.Parse(input.queryJson).Value<string>("code_batch");
|
|
material_specification = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.material_specification));
|
|
container_no = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.container_no));
|
|
if (JObject.Parse(input.queryJson).ContainsKey("time"))
|
|
time = JObject.Parse(input.queryJson).Value<JArray>("time");
|
|
}
|
|
|
|
decimal total_qty = 0;
|
|
decimal ok_qty = 0;
|
|
decimal await_qty = 0;
|
|
decimal vergeOk_qty = 0;
|
|
decimal no_qty = 0;
|
|
var _start_time = time.Count > 0 ? (long)time[0] : 0;
|
|
var _end_time = time.Count > 1 ? (long)time[1] : 0;
|
|
|
|
DateTimeOffset _start_timeofs = DateTimeOffset.FromUnixTimeMilliseconds((long)_start_time);
|
|
DateTime start_time = _start_timeofs.DateTime;
|
|
DateTimeOffset _end_timeofs = DateTimeOffset.FromUnixTimeMilliseconds((long)_end_time);
|
|
DateTime end_time = _end_timeofs.DateTime;
|
|
|
|
var data = await _db.Queryable<WmsPurchaseQcrecord>()
|
|
.InnerJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
|
.LeftJoin<DictionaryDataEntity>((a, b, c) => c.EnCode == b.unit_id && c.DictionaryTypeId == WmsWareHouseConst.UNITTYPEID)
|
|
.LeftJoin<WmsPurchaseD>((a, b, c, d) => d.id == a.ori_detail_id)
|
|
.LeftJoin<UserEntity>((a, b, c, d, e) => e.Id == a.checker)
|
|
.WhereIF(!string.IsNullOrEmpty(material_specification), (a, b, c, d) => b.material_specification.Contains(material_specification))
|
|
.WhereIF(!string.IsNullOrEmpty(batchno), (a, b, c, d) => a.batchno.Contains(batchno))
|
|
.WhereIF(!string.IsNullOrEmpty(container_no), (a, b, c, d) => b.material_standard.Contains(container_no))
|
|
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d) => a.material_code.Contains(material_code))
|
|
.WhereIF(!string.IsNullOrEmpty(type), (a, b, c, d) => a.type == type)
|
|
.WhereIF(_start_time != 0, (a, b, c, d) => a.create_time >= start_time)
|
|
.WhereIF(_end_time != 0, (a, b, c, d) => a.create_time <= end_time)
|
|
.Select((a, b, c, d, e) => new WmsPurchaseQcrecord
|
|
{
|
|
material_id = a.material_id,
|
|
material_code = a.material_code,
|
|
material_name = a.material_name,
|
|
container_no = b.material_standard,
|
|
material_spec = b.material_specification,
|
|
unit_id = c.FullName,
|
|
purchase_qty = a.purchase_qty,
|
|
purchase_prqty = a.purchase_prqty,
|
|
purchase_arriveqty = a.purchase_prqty,
|
|
batchno = a.batchno,
|
|
result = SqlFunc.IF(a.result.Equals("await") || string.IsNullOrEmpty(a.result)).Return("待检")
|
|
.ElseIF(a.result.Equals("vergeOk")).Return("让步接收").ElseIF(a.result.Equals("ok")).Return("合格")
|
|
.ElseIF(a.result.Equals("no")).Return("不合格").End(""),
|
|
create_time = d.create_time,
|
|
checker = e.RealName,
|
|
check_time = a.check_time,
|
|
check_timestr = a.check_time.Value.ToString("yyyy-MM-dd HH:mm:ss")
|
|
}).ToListAsync();
|
|
|
|
total_qty = data.Count;
|
|
ok_qty = data.Where(r => r.result == "合格").Count();
|
|
await_qty = data.Where(r => r.result == "待检").Count();
|
|
vergeOk_qty = data.Where(r => r.result == "让步接收").Count();
|
|
no_qty = data.Where(r => r.result == "不合格").Count();
|
|
|
|
List<WmsPurchaseQcrecord> pages = data.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList();
|
|
WmsPurchaseQcrecordSqlSugarPagedList<WmsPurchaseQcrecord> pagedList = new()
|
|
{
|
|
total_qty = total_qty,
|
|
ok_qty = ok_qty,
|
|
await_qty = await_qty,
|
|
vergeOk_qty = vergeOk_qty,
|
|
no_qty = no_qty,
|
|
list = pages,
|
|
pagination = new()
|
|
{
|
|
CurrentPage = input.currentPage,
|
|
PageSize = input.pageSize,
|
|
Total = data.Count()
|
|
}
|
|
};
|
|
return pagedList;
|
|
}
|
|
}
|
|
|
|
public class WmsPurchaseQcrecordSqlSugarPagedList<TEntity> : SqlSugarPagedList<TEntity>
|
|
{
|
|
public decimal total_qty { get; set; }
|
|
public decimal ok_qty { get; set; }
|
|
public decimal await_qty { get; set; }
|
|
public decimal vergeOk_qty { get; set; }
|
|
public decimal no_qty { get; set; }
|
|
}
|
|
}
|