焊接材料管理修改
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Numerics;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -29,7 +32,7 @@ namespace BLL
|
||||
///获取焊接任务单编号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetTaskCodeByDate(string projectId, string date)
|
||||
public static string GetTaskCodeByDate(string projectId, string date,string unitworkid,string unitid)
|
||||
{
|
||||
string code = string.Empty;
|
||||
var list = (from x in Funs.DB.HJGL_WeldTask where x.ProjectId == projectId && x.TaskDate == Convert.ToDateTime(date) orderby x.TaskCode descending select x.TaskCode).Distinct().ToList();
|
||||
@@ -62,6 +65,7 @@ namespace BLL
|
||||
{
|
||||
code = date + "-001";
|
||||
}
|
||||
code = code.Replace("-", "") + "-" + UnitService.GetUnitCodeByUnitId(unitid) + "-" + UnitWorkService.getUnitWorkByUnitWorkId(unitworkid)?.UnitWorkCode;
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -305,6 +309,113 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void GenOutPlanmasterByWeldTaskId(string unitworkid,string unitid,DateTime date,string Personid)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.View_HJGL_WeldingTask weldTask = db.View_HJGL_WeldingTask.FirstOrDefault(e => e.UnitWorkId==unitworkid && e.UnitId==unitid&& e.TaskDate.Value.Date==date.Date);
|
||||
if (weldTask==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string WeldTaskId= unitworkid+"|"+unitid+ "|" + string.Format("{0:yyyyMMMMdd}", date);
|
||||
//判断是否已经生成过出库计划单
|
||||
var queryIsExitInMaster = new Tw_InOutMasterOutput();
|
||||
queryIsExitInMaster.WeldTaskId = WeldTaskId;
|
||||
queryIsExitInMaster.InOutType=(int)TwConst.InOutType.出库;
|
||||
queryIsExitInMaster.TypeInt = (int)TwConst.TypeInt.领料出库;
|
||||
var IsExitInMaster = TwInOutplanmasterService.GetModle(queryIsExitInMaster).FirstOrDefault();
|
||||
if (IsExitInMaster != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var pipelineList = db.View_HJGL_WeldingTask.Where(e => e.UnitWorkId == unitworkid && e.UnitId == unitid && e.TaskDate.Value.Date == date.Date).Select(x=>x.PipelineId).Distinct().ToList();
|
||||
|
||||
//var outMateriaList = db.HJGL_PipeLineMat.Where(x => pipelineList.Contains(x.PipelineId))
|
||||
// .GroupBy(x => x.MaterialCode).Select(x => new
|
||||
// {
|
||||
// x.Key,
|
||||
// planNum = x.Sum(y => y.Number)??0,
|
||||
// }).ToList();
|
||||
var outMateriaList = from x in db.HJGL_PipeLineMat
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
where pipelineList.Contains(x.PipelineId)
|
||||
group x by new { x.MaterialCode, y.MaterialUnit }
|
||||
into g
|
||||
select new
|
||||
{
|
||||
g.Key.MaterialCode,
|
||||
planNum = g.Sum(x => x.Number) ?? 0,
|
||||
MaterialName = g.Key.MaterialUnit,
|
||||
};
|
||||
|
||||
var outPlanDetailListPiece = outMateriaList.Where(x => x.MaterialName.Contains("个"));//管件
|
||||
var outPlanDetailListOthere = outMateriaList.Where(x => x.MaterialName.Contains("米"));//管段
|
||||
var weldTaskCode = GetWeldTaskById(weldTask.WeldTaskId)?.TaskCode;
|
||||
if (outPlanDetailListPiece.Any())
|
||||
{
|
||||
Model.Tw_InOutPlanMaster table = new Model.Tw_InOutPlanMaster
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ProjectId = weldTask.ProjectId,
|
||||
// CusBillCode = string.Format("{0:yyyyMMdd}", DateTime.Now) + UnitService.GetUnitCodeByUnitId(weldTask.UnitId) + "-" + UnitWorkService.getUnitWorkByUnitWorkId(weldTask.UnitWorkId)?.UnitWorkCode + "AP-PF01",
|
||||
CusBillCode=TwInOutplanmasterService.GetCusBillCodeByTaskCode(weldTaskCode,TwConst.TypeInt.领料出库,TwConst.Category.管件),
|
||||
WarehouseCode = PipelineService.GetPipeArea().Where(x => x.Value == PipelineService.GetPipelineByPipelineId(weldTask.PipelineId).PipeArea).Select(x => x.Text).FirstOrDefault(),
|
||||
Source = 1,
|
||||
InOutType = (int)TwConst.InOutType.出库,
|
||||
TypeInt = (int)TwConst.TypeInt.领料出库,
|
||||
State = (int)TwConst.State.待审核,
|
||||
Category = (int)TwConst.Category.管件,
|
||||
CreateMan = Personid,
|
||||
CreateDate = DateTime.Now,
|
||||
WeldTaskId = WeldTaskId,
|
||||
ReqUnitId = weldTask.UnitId,
|
||||
};
|
||||
TwInOutplanmasterService.Add(table);
|
||||
foreach (var item in outPlanDetailListPiece)
|
||||
{
|
||||
Model.Tw_InOutPlanDetail detail = new Model.Tw_InOutPlanDetail
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
InOutPlanMasterId = table.Id,
|
||||
MaterialCode = item.MaterialCode,
|
||||
PlanNum = item.planNum,
|
||||
};
|
||||
TwInOutplandetailService.Add(detail);
|
||||
}
|
||||
}
|
||||
if (outPlanDetailListOthere.Any())
|
||||
{
|
||||
Model.Tw_InOutPlanMaster table = new Model.Tw_InOutPlanMaster
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ProjectId = weldTask.ProjectId,
|
||||
CusBillCode =TwInOutplanmasterService.GetCusBillCodeByTaskCode(weldTaskCode, TwConst.TypeInt.领料出库, TwConst.Category.管段),
|
||||
WarehouseCode = PipelineService.GetPipeArea().Where(x => x.Value == PipelineService.GetPipelineByPipelineId(weldTask.PipelineId).PipeArea).Select(x => x.Text).FirstOrDefault(),
|
||||
Source = 1,
|
||||
InOutType = (int)TwConst.InOutType.出库,
|
||||
TypeInt = (int)TwConst.TypeInt.领料出库,
|
||||
State = (int)TwConst.State.待审核,
|
||||
Category = (int)TwConst.Category.管段,
|
||||
CreateMan = Personid,
|
||||
CreateDate = DateTime.Now,
|
||||
WeldTaskId = WeldTaskId,
|
||||
ReqUnitId = weldTask.UnitId,
|
||||
};
|
||||
TwInOutplanmasterService.Add(table);
|
||||
foreach (var item in outPlanDetailListOthere)
|
||||
{
|
||||
Model.Tw_InOutPlanDetail detail = new Model.Tw_InOutPlanDetail
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
InOutPlanMasterId = table.Id,
|
||||
MaterialCode = item.MaterialCode,
|
||||
PlanNum = item.planNum,
|
||||
};
|
||||
TwInOutplandetailService.Add(detail);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user