代码无效引用清理,试压包资料界面看板修改
This commit is contained in:
@@ -1,78 +1,73 @@
|
||||
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace BLL
|
||||
namespace BLL
|
||||
{
|
||||
public class TwArrivalStatisticsService
|
||||
{
|
||||
public static List<Tw_ArrivalStatisticsOutPut> GetStatistics(string projectid,string materialCode,string WarehouseCode)
|
||||
public static List<Tw_ArrivalStatisticsOutPut> GetStatistics(string projectid, string materialCode, string WarehouseCode)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string PipeArea= WarehouseCode == "工厂预制"?"1":"2";
|
||||
string PipeArea = WarehouseCode == "工厂预制" ? "1" : "2";
|
||||
///所需材料数量列表
|
||||
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)) && z.PipeArea== PipeArea
|
||||
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)) && z.PipeArea == PipeArea
|
||||
group x by x.MaterialCode
|
||||
into g
|
||||
select new
|
||||
{
|
||||
g.Key,
|
||||
NeedNum = g.Sum(x => x.Number) ?? 0,
|
||||
};
|
||||
select new
|
||||
{
|
||||
g.Key,
|
||||
NeedNum = g.Sum(x => x.Number) ?? 0,
|
||||
};
|
||||
///实际材料入库数量列表
|
||||
var RealInMateriaList = from x in db.Tw_InputDetail
|
||||
join master in db.Tw_InputMaster on x.InputMasterId equals master.Id
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
where master.ProjectId== projectid && master.WarehouseCode== WarehouseCode
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
where master.ProjectId == projectid && master.WarehouseCode == WarehouseCode
|
||||
group x by x.MaterialCode
|
||||
into g
|
||||
where (string.IsNullOrEmpty(materialCode) || g.Key.Contains( materialCode))
|
||||
where (string.IsNullOrEmpty(materialCode) || g.Key.Contains(materialCode))
|
||||
select new
|
||||
{
|
||||
g.Key,
|
||||
RealNum = g.Sum(x => x.ActNum) ?? 0,
|
||||
};
|
||||
//库存数量
|
||||
var tw_MaterialStock=from x in db.Tw_MaterialStock
|
||||
where x.WarehouseCode==WarehouseCode && x.ProjectId== projectid
|
||||
select x;
|
||||
var tw_MaterialStock = from x in db.Tw_MaterialStock
|
||||
where x.WarehouseCode == WarehouseCode && x.ProjectId == projectid
|
||||
select x;
|
||||
|
||||
|
||||
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()
|
||||
join m in tw_MaterialStock on x.Key equals m.PipeLineMatCode into mm
|
||||
from m in mm.DefaultIfEmpty()
|
||||
select new Tw_ArrivalStatisticsOutPut
|
||||
{
|
||||
MaterialCode = x.Key,
|
||||
StockNum = m==null?0: (decimal)m.StockNum,
|
||||
NeedNum = x.NeedNum,
|
||||
RealNum = y==null?0:y.RealNum,
|
||||
MaterialName = z.MaterialName,
|
||||
MaterialSpec=z.MaterialSpec,
|
||||
MaterialUnit=z.MaterialUnit,
|
||||
MaterialDef = z.MaterialDef,
|
||||
MatchRate = (x.NeedNum == 0 ?0:Math.Round((y == null ? 0 : y.RealNum) / x.NeedNum, 4,MidpointRounding.ToEven)),
|
||||
}).ToList();
|
||||
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()
|
||||
join m in tw_MaterialStock on x.Key equals m.PipeLineMatCode into mm
|
||||
from m in mm.DefaultIfEmpty()
|
||||
select new Tw_ArrivalStatisticsOutPut
|
||||
{
|
||||
MaterialCode = x.Key,
|
||||
StockNum = m == null ? 0 : (decimal)m.StockNum,
|
||||
NeedNum = x.NeedNum,
|
||||
RealNum = y == null ? 0 : y.RealNum,
|
||||
MaterialName = z.MaterialName,
|
||||
MaterialSpec = z.MaterialSpec,
|
||||
MaterialUnit = z.MaterialUnit,
|
||||
MaterialDef = z.MaterialDef,
|
||||
MatchRate = (x.NeedNum == 0 ? 0 : Math.Round((y == null ? 0 : y.RealNum) / x.NeedNum, 4, MidpointRounding.ToEven)),
|
||||
}).ToList();
|
||||
foreach (var item in StatisticsList)
|
||||
{
|
||||
item.MatchRateString = Math.Round(item.MatchRate*100, 2).ToString()+"%" ;
|
||||
}
|
||||
return StatisticsList ;
|
||||
item.MatchRateString = Math.Round(item.MatchRate * 100, 2).ToString() + "%";
|
||||
}
|
||||
return StatisticsList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +78,8 @@ namespace BLL
|
||||
/// <param name="warehouseCode"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Tw_PipeMatMatchOutput> GetMatMatchOutput(List<Tw_PipeMatMatchOutput> requiredMaterials ,string warehouseCode ,string projectId)
|
||||
{
|
||||
public static List<Tw_PipeMatMatchOutput> GetMatMatchOutput(List<Tw_PipeMatMatchOutput> requiredMaterials, string warehouseCode, string projectId)
|
||||
{
|
||||
Tw_MaterialStockOutput twMaterialStockOutput = new Tw_MaterialStockOutput
|
||||
{
|
||||
WarehouseCode = warehouseCode,
|
||||
@@ -113,11 +108,11 @@ namespace BLL
|
||||
if (stock != null)
|
||||
{
|
||||
stock.StockNum -= material.MatchNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var results = requiredMaterials;
|
||||
return results;
|
||||
return results;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取管线匹配率
|
||||
@@ -127,7 +122,7 @@ namespace BLL
|
||||
public static decimal? GetPipeMatch(string pipelineId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
{
|
||||
var twPipeMatMatchOutputs = new List<Tw_PipeMatMatchOutput>();
|
||||
var pipelineModel = PipelineService.GetPipelineByPipelineId(pipelineId);
|
||||
string warehouseCode = PipelineService
|
||||
@@ -138,7 +133,7 @@ namespace BLL
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
join z in db.HJGL_Pipeline on x.PipelineId equals z.PipelineId
|
||||
join m in db.WBS_UnitWork on z.UnitWorkId equals m.UnitWorkId
|
||||
where z.PipelineId== pipelineId && x.PrefabricatedComponents != "" //x.PrefabricatedComponents!="" 用于筛选非散件材料
|
||||
where z.PipelineId == pipelineId && x.PrefabricatedComponents != "" //x.PrefabricatedComponents!="" 用于筛选非散件材料
|
||||
select new Tw_PipeMatMatchOutput
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
@@ -154,10 +149,10 @@ namespace BLL
|
||||
MaterialDef = y.MaterialDef,
|
||||
NeedNum = x.Number,
|
||||
}
|
||||
).ToList();
|
||||
|
||||
twPipeMatMatchOutputs = GetMatMatchOutput(requiredMaterials, warehouseCode, pipelineModel.ProjectId);
|
||||
var result = twPipeMatMatchOutputs.Count==0?0: twPipeMatMatchOutputs.Sum(x=>x.MatchRate)/ twPipeMatMatchOutputs.Count;
|
||||
).ToList();
|
||||
|
||||
twPipeMatMatchOutputs = GetMatMatchOutput(requiredMaterials, warehouseCode, pipelineModel.ProjectId);
|
||||
var result = twPipeMatMatchOutputs.Count == 0 ? 0 : twPipeMatMatchOutputs.Sum(x => x.MatchRate) / twPipeMatMatchOutputs.Count;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -170,29 +165,29 @@ namespace BLL
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var results = new List<Tw_PipeMatMatchOutput>();
|
||||
string [] taskPipeLineList= null;
|
||||
var results = new List<Tw_PipeMatMatchOutput>();
|
||||
string[] taskPipeLineList = null;
|
||||
|
||||
var inoutPlanMasterl = db.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == outPlanMasterId);
|
||||
if (inoutPlanMasterl!=null)
|
||||
if (inoutPlanMasterl != null)
|
||||
{
|
||||
if (inoutPlanMasterl.WeldTaskId.Split('|').Length==4)
|
||||
{
|
||||
taskPipeLineList = Funs.DB.View_HJGL_WeldingTask.Where(e =>
|
||||
e.UnitWorkId == inoutPlanMasterl.WeldTaskId.Split('|')[0].ToString()
|
||||
&& e.UnitId == inoutPlanMasterl.WeldTaskId.Split('|')[1].ToString()
|
||||
&& e.TaskDate.Value.Date == DateTime
|
||||
.ParseExact(inoutPlanMasterl.WeldTaskId.Split('|')[2].ToString(), "yyyyMMdd", null).Date
|
||||
&& e.SerialNumber == inoutPlanMasterl.WeldTaskId.Split('|')[3].ToString()
|
||||
).Distinct().OrderBy(x => x.PipeLineSortIndex).Select(x => x.PipelineId).ToArray();
|
||||
if (inoutPlanMasterl.WeldTaskId.Split('|').Length == 4)
|
||||
{
|
||||
taskPipeLineList = Funs.DB.View_HJGL_WeldingTask.Where(e =>
|
||||
e.UnitWorkId == inoutPlanMasterl.WeldTaskId.Split('|')[0].ToString()
|
||||
&& e.UnitId == inoutPlanMasterl.WeldTaskId.Split('|')[1].ToString()
|
||||
&& e.TaskDate.Value.Date == DateTime
|
||||
.ParseExact(inoutPlanMasterl.WeldTaskId.Split('|')[2].ToString(), "yyyyMMdd", null).Date
|
||||
&& e.SerialNumber == inoutPlanMasterl.WeldTaskId.Split('|')[3].ToString()
|
||||
).Distinct().OrderBy(x => x.PipeLineSortIndex).Select(x => x.PipelineId).ToArray();
|
||||
}
|
||||
}
|
||||
// 获取所需材料列表
|
||||
var requiredMaterials = (from x in db.Tw_InOutPlanDetail_Relation
|
||||
join master in db.Tw_InOutPlanMaster on x.InOutPlanMasterId equals master.Id
|
||||
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 x.InOutPlanMasterId == outPlanMasterId
|
||||
join z in db.HJGL_Pipeline on x.PipelineId equals z.PipelineId
|
||||
where x.InOutPlanMasterId == outPlanMasterId
|
||||
select new Tw_PipeMatMatchOutput
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
@@ -213,7 +208,7 @@ namespace BLL
|
||||
|
||||
}
|
||||
|
||||
var masterModle = db.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == outPlanMasterId);
|
||||
var masterModle = db.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == outPlanMasterId);
|
||||
results = GetMatMatchOutput(requiredMaterials, masterModle.WarehouseCode, masterModle.ProjectId);
|
||||
return results;
|
||||
}
|
||||
@@ -259,7 +254,7 @@ namespace BLL
|
||||
foreach (string id in pipelineIds)
|
||||
{
|
||||
newRequiredMaterials.AddRange(requiredMaterials.Where(x => x.PipelineId == id));
|
||||
}
|
||||
}
|
||||
results = GetMatMatchOutput(newRequiredMaterials, warehouseCode, projectId);
|
||||
return results;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user