@@ -1,25 +1,36 @@
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.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
public class WmsPurchaseQcrecordService : BaseWareHouseService
{
private const string BizTypeId = WmsWareHouseConst . BIZTYPE_WmsPurchaseQcrecord_ID ;
private readonly ISqlSugarClient _db ;
@@ -52,5 +63,98 @@ namespace Tnb.WarehouseMgr
}
[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 > ( "batchno" ) ;
material_specification = JObject . Parse ( input . queryJson ) . Value < string > ( nameof ( WmsCarryCode . material_specification ) ) ;
container_no = JObject . Parse ( input . queryJson ) . Value < string > ( nameof ( WmsCarryCode . container_no ) ) ;
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 . FromUnixTimeSeconds ( ( long ) _start_time ) ;
DateTime start_time = _start_timeofs . DateTime ;
DateTimeOffset _end_timeofs = DateTimeOffset . FromUnixTimeSeconds ( ( 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 )
. 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 ) = > new WmsPurchaseQcrecord
{
material_id = a . material_id ,
material_code = a . material_code ,
material_name = a . material_name ,
material_specification = 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
} ) . 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 ; }
}
}