1
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
using System;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
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;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class TwArrivalStatisticsService
|
||||
{
|
||||
public static IEnumerable GetStatistics(string projectid,string materialCode)
|
||||
public static List<Tw_ArrivalStatisticsOutPut> GetStatistics(string projectid,string materialCode)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
@@ -36,12 +39,12 @@ namespace BLL
|
||||
RealNum = g.Sum(x => x.ActNum) ?? 0,
|
||||
};
|
||||
|
||||
var StatisticsList =from x in NeedOutMateriaList
|
||||
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
|
||||
select new Tw_ArrivalStatisticsOutPut
|
||||
{
|
||||
MaterialCode = x.Key,
|
||||
NeedNum = x.NeedNum,
|
||||
@@ -49,10 +52,139 @@ namespace BLL
|
||||
MaterialName = z.MaterialName,
|
||||
MaterialSpec=z.MaterialSpec,
|
||||
MaterialUnit=z.MaterialUnit,
|
||||
};
|
||||
return StatisticsList.ToList();
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Tw_PipeMatMatchOutput> GetPipeMatMatch(string projectid, List<string> pipelineIds,string WarehouseCode)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var results = new List<Tw_PipeMatMatchOutput>();
|
||||
|
||||
// 获取所需材料列表
|
||||
var requiredMaterials = (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 && pipelineIds.Contains(z.PipelineId)
|
||||
select new Tw_PipeMatMatchOutput
|
||||
{
|
||||
Id= Guid.NewGuid().ToString(),
|
||||
PipelineId =x.PipelineId,
|
||||
PipelineCode=z.PipelineCode,
|
||||
PrefabricatedComponents=x.PrefabricatedComponents,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialName= y.MaterialName,
|
||||
MaterialSpec= y.MaterialSpec,
|
||||
MaterialUnit= y.MaterialUnit,
|
||||
MaterialDef= y.MaterialDef,
|
||||
NeedNum=x.Number,
|
||||
}
|
||||
).ToList();
|
||||
Tw_MaterialStockOutput tw_MaterialStockOutput=new Tw_MaterialStockOutput();
|
||||
tw_MaterialStockOutput .WarehouseCode=WarehouseCode;
|
||||
var stockList= TwMaterialstockService.GetTw_MaterialStockByModle(tw_MaterialStockOutput).ToList();//获取库存列表
|
||||
|
||||
// 模拟库存管理
|
||||
foreach (var material in requiredMaterials)
|
||||
{
|
||||
var thisMaterialStockNum = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode)?.StockNum??0;
|
||||
if (thisMaterialStockNum >= material.NeedNum)
|
||||
{
|
||||
material.MatchNum=material.NeedNum;
|
||||
material.MatchRate=1;
|
||||
material.MatchRateString="100%";
|
||||
}
|
||||
else
|
||||
{
|
||||
material.MatchNum = thisMaterialStockNum<0?0:thisMaterialStockNum;
|
||||
material.MatchRate = (material.NeedNum == 0 ? 0 : material.MatchNum??0 / material.NeedNum);
|
||||
material.MatchRateString = Math.Round((decimal)material.MatchRate * 100, 2).ToString() + "%";
|
||||
|
||||
}
|
||||
//修改stockList对应的库存数量
|
||||
var stock = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode);
|
||||
if (stock != null)
|
||||
{
|
||||
stock.StockNum -= material.MatchNum;
|
||||
}
|
||||
}
|
||||
results = requiredMaterials;
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<Tw_PipeMatMatchOutput> GetMatMatchByOutPlanMasterId(string outPlanMasterId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var results = new List<Tw_PipeMatMatchOutput>();
|
||||
|
||||
// 获取所需材料列表
|
||||
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
|
||||
select new Tw_PipeMatMatchOutput
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
PipelineId = x.PipelineId,
|
||||
PipelineCode = z.PipelineCode,
|
||||
PrefabricatedComponents = x.PrefabricatedComponents,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialName = y.MaterialName,
|
||||
MaterialSpec = y.MaterialSpec,
|
||||
MaterialUnit = y.MaterialUnit,
|
||||
MaterialDef = y.MaterialDef,
|
||||
NeedNum = x.Number,
|
||||
}
|
||||
).ToList();
|
||||
var masterModle = db.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == outPlanMasterId);
|
||||
Tw_MaterialStockOutput tw_MaterialStockOutput = new Tw_MaterialStockOutput();
|
||||
tw_MaterialStockOutput.WarehouseCode = masterModle.WarehouseCode;
|
||||
var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(tw_MaterialStockOutput).ToList();//获取库存列表
|
||||
|
||||
// 模拟库存管理
|
||||
foreach (var material in requiredMaterials)
|
||||
{
|
||||
var thisMaterialStockNum = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode)?.StockNum ?? 0;
|
||||
if (thisMaterialStockNum >= material.NeedNum)
|
||||
{
|
||||
material.MatchNum = material.NeedNum;
|
||||
material.MatchRate = 1;
|
||||
material.MatchRateString = "100%";
|
||||
}
|
||||
else
|
||||
{
|
||||
material.MatchNum = thisMaterialStockNum < 0 ? 0 : thisMaterialStockNum;
|
||||
material.MatchRate = (material.NeedNum == 0 ? 0 : material.MatchNum ?? 0 / material.NeedNum);
|
||||
material.MatchRateString = Math.Round((decimal)material.MatchRate * 100, 2).ToString() + "%";
|
||||
|
||||
}
|
||||
//修改stockList对应的库存数量
|
||||
var stock = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode);
|
||||
if (stock != null)
|
||||
{
|
||||
stock.StockNum -= material.MatchNum;
|
||||
}
|
||||
}
|
||||
results = requiredMaterials;
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,26 @@ namespace BLL
|
||||
{ "补料出库" ,(int)TypeInt.补料出库},
|
||||
{ "其他出库" ,(int)TypeInt.其他出库},
|
||||
{ "散件出库" ,(int)TypeInt.散件出库}
|
||||
};
|
||||
public static Dictionary<string, int> PlanPrintMap = new Dictionary<string, int>
|
||||
{
|
||||
{ "采购通知单" ,(int)TypeInt.采购入库},
|
||||
{ "退料通知单" ,(int)TypeInt.退料入库},
|
||||
{ "其他入库通知单" ,(int)TypeInt.其他入库},
|
||||
{ "材料领用申请单" ,(int)TypeInt.领料出库},
|
||||
{ "补料申请单" ,(int)TypeInt.补料出库},
|
||||
{ "其他出库申请单" ,(int)TypeInt.其他出库},
|
||||
{ "散件出库申请单" ,(int)TypeInt.散件出库}
|
||||
};
|
||||
public static Dictionary<string, int> PrintMap = new Dictionary<string, int>
|
||||
{
|
||||
{ "采购入库单" ,(int)TypeInt.采购入库},
|
||||
{ "退料入库单" ,(int)TypeInt.退料入库},
|
||||
{ "其他入库单" ,(int)TypeInt.其他入库},
|
||||
{ "材料出库单" ,(int)TypeInt.领料出库},
|
||||
{ "补料出库单" ,(int)TypeInt.补料出库},
|
||||
{ "其他出库单" ,(int)TypeInt.其他出库},
|
||||
{ "散件出库单" ,(int)TypeInt.散件出库}
|
||||
};
|
||||
public static Dictionary<string, int> StateMap = new Dictionary<string, int>
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace BLL
|
||||
x.PrefabricatedComponents,
|
||||
x.Number,
|
||||
mat.MaterialName,
|
||||
|
||||
mat.MaterialDef
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -27,7 +27,11 @@ namespace BLL
|
||||
join y in Funs.DB.HJGL_Pipeline_Component on x.PipelineComponentId equals y.PipelineComponentId into yy
|
||||
from y in yy.DefaultIfEmpty()
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
join master in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals master.Id into masters
|
||||
from master in masters.DefaultIfEmpty()
|
||||
join stock in Funs.DB.Tw_MaterialStock on new { x.MaterialCode, master.WarehouseCode } equals new { MaterialCode = stock.PipeLineMatCode, stock.WarehouseCode } into st
|
||||
from stock in st.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.InOutPlanMasterId) || x.InOutPlanMasterId.Contains(table.InOutPlanMasterId)) &&
|
||||
@@ -43,6 +47,8 @@ namespace BLL
|
||||
ActNum = x.ActNum,
|
||||
PipelineComponentCode = y.PipelineComponentCode,
|
||||
MaterialName = mat.MaterialName,
|
||||
MaterialDef= mat.MaterialDef,
|
||||
StockNum = stock.StockNum ?? 0,
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using EmitMapper;
|
||||
using FineUIPro;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using MiniExcelLibs;
|
||||
using Model;
|
||||
using NPOI.Util;
|
||||
@@ -213,10 +214,6 @@ namespace BLL
|
||||
responeData.message = "导入数据为空!";
|
||||
return responeData;
|
||||
}
|
||||
var queryAll = new Tw_InOutMasterOutput()
|
||||
{
|
||||
ProjectId = projectid
|
||||
};
|
||||
var warehouseCodeList = temeplateDtoIns.Select(x => x.WarehouseCode).Distinct().ToList(); //获取导入文件的仓库编号
|
||||
string errorWarehouseCode = "";
|
||||
foreach (var item in warehouseCodeList)
|
||||
@@ -251,7 +248,15 @@ namespace BLL
|
||||
return responeData;
|
||||
}
|
||||
}
|
||||
|
||||
string cusbilcode = GetDataInCusBillCode(projectid,UnitService.GetUnitCodeByUnitId(Person_PersonsService.GetPerson_PersonsById(creatUserId).UnitId));
|
||||
foreach (var item in temeplateDtoIns)
|
||||
{
|
||||
item.CusBillCode = cusbilcode;
|
||||
}
|
||||
/*var queryAll = new Tw_InOutMasterOutput()
|
||||
{
|
||||
ProjectId = projectid
|
||||
};
|
||||
var queryAllresult = GetModle(queryAll).Select(x => x.CusBillCode).Distinct().ToList();//查询所有的编号
|
||||
var CusBillCodeList = temeplateDtoIns.Select(x => x.CusBillCode).Distinct().ToList(); //获取导入文件的编号
|
||||
var IsContain = CusBillCodeList.Intersect(queryAllresult).ToList(); //判断导入文件中是有已存在的编号
|
||||
@@ -260,7 +265,8 @@ namespace BLL
|
||||
responeData.code = 0;
|
||||
responeData.message = string.Join(",", IsContain)+ "编号已存在!";
|
||||
return responeData;
|
||||
}
|
||||
}*/
|
||||
var CusBillCodeList = temeplateDtoIns.Select(x => x.CusBillCode).Distinct().ToList(); //获取导入文件的编号
|
||||
#endregion
|
||||
//根据申请单编号分组插入数据
|
||||
foreach (var CusBillCode in CusBillCodeList)
|
||||
@@ -510,6 +516,23 @@ namespace BLL
|
||||
return cusBillCode;
|
||||
}
|
||||
|
||||
|
||||
public static string GetDataInCusBillCode(string projectid, string unitcode)
|
||||
{
|
||||
|
||||
//生成规则是20240919-unitcode-AP-GR01
|
||||
string cusBillCode = string.Format("{0:yyyyMMdd}", DateTime.Now) + unitcode + "-AP-GR";
|
||||
var queryAll = new Tw_InOutMasterOutput()
|
||||
{
|
||||
ProjectId = projectid,
|
||||
CusBillCode=cusBillCode,
|
||||
};
|
||||
var queryAllresult = GetModle(queryAll).Count();
|
||||
cusBillCode = cusBillCode + (queryAllresult + 1).ToString().PadLeft(2, '0');
|
||||
return cusBillCode;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据任务单生成出库计划单
|
||||
/// </summary>
|
||||
@@ -655,5 +678,7 @@ namespace BLL
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ namespace BLL
|
||||
ActNum = x.ActNum,
|
||||
PipelineComponentCode = y.PipelineComponentCode,
|
||||
MaterialName = mat.MaterialName,
|
||||
MaterialDef = mat.MaterialDef
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace BLL
|
||||
/// <summary>
|
||||
/// 根据计划单生成入库单
|
||||
/// </summary>
|
||||
public static void GenInMasterByPlanId(string planId, List<Model.Tw_InputDetail> detailLists)
|
||||
public static void GenInMasterByPlanId(string planId, List<Model.Tw_InputDetail> detailLists,string remark)
|
||||
{
|
||||
//获取计划单
|
||||
var planQueryModel = new Tw_InOutMasterOutput();
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace BLL
|
||||
ProjectId = x.ProjectId,
|
||||
MaterialName = mat.MaterialName,
|
||||
MaterialSpec = mat.MaterialSpec,
|
||||
MaterialUnit = mat.MaterialUnit,
|
||||
MaterialUnit = mat.MaterialUnit,
|
||||
MaterialDef = mat.MaterialDef
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -27,9 +27,11 @@ namespace BLL
|
||||
var q = from x in Funs.DB.Tw_OutputDetail
|
||||
join y in Funs.DB.HJGL_Pipeline_Component on x.PipelineComponentId equals y.PipelineComponentId into yy
|
||||
from y in yy.DefaultIfEmpty()
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
join stock in Funs.DB.Tw_MaterialStock on x.MaterialCode equals stock.PipeLineMatCode into st
|
||||
join master in Funs.DB.Tw_OutputMaster on x.OutputMasterId equals master.Id into masters
|
||||
from master in masters.DefaultIfEmpty()
|
||||
join stock in Funs.DB.Tw_MaterialStock on new { x.MaterialCode,master.WarehouseCode} equals new { MaterialCode=stock.PipeLineMatCode,stock.WarehouseCode } into st
|
||||
from stock in st.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
@@ -48,7 +50,8 @@ namespace BLL
|
||||
MaterialName = mat.MaterialName,
|
||||
StockNum = stock.StockNum ?? 0,
|
||||
DiffNum = (x.ActNum??0) - (x.PlanNum??0),
|
||||
}
|
||||
MaterialDef = mat.MaterialDef
|
||||
}
|
||||
;
|
||||
|
||||
return q;
|
||||
|
||||
Reference in New Issue
Block a user