59 lines
2.8 KiB
C#
59 lines
2.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BLL
|
|
{
|
|
public class TwArrivalStatisticsService
|
|
{
|
|
public static IEnumerable GetStatistics(string projectid,string materialCode)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var NeedOutMateriaList = from x in db.HJGL_PipeLineMat
|
|
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
|
join z in db.HJGL_Pipeline on x.PipelineId equals z.PipelineId
|
|
where z.ProjectId == projectid && (string.IsNullOrEmpty(materialCode) || x.MaterialCode .Contains( materialCode))
|
|
group x by x.MaterialCode
|
|
into g
|
|
select new
|
|
{
|
|
g.Key,
|
|
NeedNum = g.Sum(x => x.Number) ?? 0,
|
|
};
|
|
|
|
var RealInMateriaList = from x in db.Tw_InputDetail
|
|
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
|
group x by x.MaterialCode
|
|
into g
|
|
where (string.IsNullOrEmpty(materialCode) || g.Key.Contains( materialCode))
|
|
select new
|
|
{
|
|
g.Key,
|
|
RealNum = g.Sum(x => x.ActNum) ?? 0,
|
|
};
|
|
|
|
var StatisticsList =from x in NeedOutMateriaList
|
|
join y in RealInMateriaList on x.Key equals y.Key into gg
|
|
from y in gg.DefaultIfEmpty()
|
|
join z in db.HJGL_MaterialCodeLib on x.Key equals z.MaterialCode into zz
|
|
from z in zz.DefaultIfEmpty()
|
|
select new
|
|
{
|
|
MaterialCode = x.Key,
|
|
NeedNum = x.NeedNum,
|
|
RealNum = y==null?0:y.RealNum,
|
|
MaterialName = z.MaterialName,
|
|
MaterialSpec=z.MaterialSpec,
|
|
MaterialUnit=z.MaterialUnit,
|
|
};
|
|
return StatisticsList.ToList();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|