1
This commit is contained in:
@@ -35,6 +35,10 @@ namespace BLL
|
||||
from y in yy.DefaultIfEmpty()
|
||||
join person in Funs.DB.Person_Persons on x.CreateMan equals person.PersonId into persons
|
||||
from person in persons.DefaultIfEmpty()
|
||||
join auditperson in Funs.DB.Person_Persons on x.AuditMan equals auditperson.PersonId into auditpersons
|
||||
from auditperson in auditpersons.DefaultIfEmpty()
|
||||
join auditperson2 in Funs.DB.Person_Persons on x.AuditMan2 equals auditperson2.PersonId into auditpersons2
|
||||
from auditperson2 in auditpersons2.DefaultIfEmpty()
|
||||
join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units
|
||||
from unit in units.DefaultIfEmpty()
|
||||
where
|
||||
@@ -69,7 +73,13 @@ namespace BLL
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = unit.UnitName,
|
||||
UnitWorkId = y.UnitWorkId,
|
||||
WeldTaskCode = y.TaskCode
|
||||
WeldTaskCode = y.TaskCode,
|
||||
AuditMan = x.AuditMan,
|
||||
AuditManName = auditperson.PersonName,
|
||||
AuditDate = x.AuditDate,
|
||||
Remark = x.Remark,
|
||||
AuditManName2 = auditperson2.PersonName,
|
||||
AuditDate2 = x.AuditDate2,
|
||||
}
|
||||
;
|
||||
|
||||
@@ -82,43 +92,6 @@ namespace BLL
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable GetListData(Model.Tw_InOutMasterOutput table, Grid grid1)
|
||||
{
|
||||
|
||||
var q = GetModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize).ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in result
|
||||
select new Model.Tw_InOutMasterOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
ProjectId = x.ProjectId,
|
||||
CusBillCode = x.CusBillCode,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
Source = x.Source,
|
||||
InOutType = x.InOutType,
|
||||
TypeInt = x.TypeInt,
|
||||
Category = x.Category,
|
||||
State = x.State,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = x.CreateManName,
|
||||
CreateDate = x.CreateDate,
|
||||
OutputMasterId = x.OutputMasterId,
|
||||
WeldTaskId = x.WeldTaskId,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = x.ReqUnitName,
|
||||
UnitWorkId = x.UnitWorkId,
|
||||
WeldTaskCode= x.WeldTaskId!=null? x.WeldTaskId.Contains('|')? Funs.DB.HJGL_WeldTask.FirstOrDefault(e => e.UnitWorkId == x.WeldTaskId.Split('|')[0].ToString() && e.UnitId == x.WeldTaskId.Split('|')[1].ToString() && e.TaskDate.Value.Date == Convert.ToDateTime(x.WeldTaskId.Split('|')[2].ToString()).Date)?.TaskCode :"":"",
|
||||
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
||||
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Tw_InOutMasterOutput> GetListData(Model.Tw_InOutMasterOutput table)
|
||||
{
|
||||
@@ -154,10 +127,61 @@ namespace BLL
|
||||
WeldTaskCode = x.WeldTaskId != null ? x.WeldTaskId.Contains('|') ? Funs.DB.HJGL_WeldTask.FirstOrDefault(e => e.UnitWorkId == x.WeldTaskId.Split('|')[0].ToString() && e.UnitId == x.WeldTaskId.Split('|')[1].ToString() && e.TaskDate.Value.Date == Convert.ToDateTime(x.WeldTaskId.Split('|')[2].ToString()).Date)?.TaskCode : "" : "",
|
||||
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
||||
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key,
|
||||
AuditMan = x.AuditMan,
|
||||
AuditManName = x.AuditManName,
|
||||
AuditDate = x.AuditDate,
|
||||
Remark = x.Remark,
|
||||
AuditManName2 = x.AuditManName2,
|
||||
AuditDate2 = x.AuditDate2,
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable GetListData(Model.Tw_InOutMasterOutput table, Grid grid1)
|
||||
{
|
||||
|
||||
var q = GetModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize).ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in result
|
||||
select new Model.Tw_InOutMasterOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
ProjectId = x.ProjectId,
|
||||
CusBillCode = x.CusBillCode,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
Source = x.Source,
|
||||
InOutType = x.InOutType,
|
||||
TypeInt = x.TypeInt,
|
||||
Category = x.Category,
|
||||
State = x.State,
|
||||
CreateMan = x.CreateMan,
|
||||
CreateManName = x.CreateManName,
|
||||
CreateDate = x.CreateDate,
|
||||
OutputMasterId = x.OutputMasterId,
|
||||
WeldTaskId = x.WeldTaskId,
|
||||
ReqUnitId = x.ReqUnitId,
|
||||
ReqUnitName = x.ReqUnitName,
|
||||
UnitWorkId = x.UnitWorkId,
|
||||
WeldTaskCode = x.WeldTaskId != null ? x.WeldTaskId.Contains('|') ? Funs.DB.HJGL_WeldTask.FirstOrDefault(e => e.UnitWorkId == x.WeldTaskId.Split('|')[0].ToString() && e.UnitId == x.WeldTaskId.Split('|')[1].ToString() && e.TaskDate.Value.Date == Convert.ToDateTime(x.WeldTaskId.Split('|')[2].ToString()).Date)?.TaskCode : "" : "",
|
||||
CategoryString = TwConst.CategoryMap.FirstOrDefault(y => y.Value == x.Category).Key,
|
||||
TypeString = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
||||
StateString = TwConst.StateMap.FirstOrDefault(y => y.Value == x.State).Key,
|
||||
AuditMan = x.AuditMan,
|
||||
AuditManName = x.AuditManName,
|
||||
AuditDate = x.AuditDate,
|
||||
Remark = x.Remark,
|
||||
AuditManName2 = x.AuditManName2,
|
||||
AuditDate2 = x.AuditDate2,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -167,7 +191,7 @@ namespace BLL
|
||||
/// <param name="projectid"></param>
|
||||
/// <param name="creatUserId"></param>
|
||||
/// <returns></returns>
|
||||
public static ResponeData ImportData(string path, string projectid, string creatUserId)
|
||||
public static ResponeData ImportData(string OriFileName,string path, string projectid, string creatUserId)
|
||||
{
|
||||
var responeData = new ResponeData();
|
||||
List<Tw_InputDataIn> temeplateDtoIns;
|
||||
@@ -259,6 +283,7 @@ namespace BLL
|
||||
twInOutPlanMaster.ProjectId = projectid;
|
||||
twInOutPlanMaster.CreateMan = creatUserId;
|
||||
twInOutPlanMaster.CreateDate = DateTime.Now;
|
||||
twInOutPlanMaster.Remark = OriFileName;
|
||||
Add(twInOutPlanMaster);
|
||||
TwInOutplandetailService.AddList(twInOutPlanDetails, twInOutPlanMaster.Id); //插入入库明细
|
||||
|
||||
@@ -290,6 +315,11 @@ namespace BLL
|
||||
OutputMasterId = newtable.OutputMasterId,
|
||||
WeldTaskId = newtable.WeldTaskId,
|
||||
ReqUnitId = newtable.ReqUnitId,
|
||||
AuditMan = newtable.AuditMan,
|
||||
AuditDate = newtable.AuditDate,
|
||||
Remark = newtable.Remark,
|
||||
AuditMan2=newtable.AuditMan2,
|
||||
AuditDate2=newtable.AuditDate2,
|
||||
};
|
||||
Funs.DB.Tw_InOutPlanMaster.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
@@ -314,6 +344,11 @@ namespace BLL
|
||||
table.OutputMasterId = newtable.OutputMasterId;
|
||||
table.WeldTaskId = newtable.WeldTaskId;
|
||||
table.ReqUnitId = newtable.ReqUnitId;
|
||||
table.AuditMan = newtable.AuditMan;
|
||||
table.AuditDate = newtable.AuditDate;
|
||||
table.Remark = newtable.Remark;
|
||||
table.AuditMan2 = newtable.AuditMan2;
|
||||
table.AuditDate2 = newtable.AuditDate2;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
@@ -325,6 +360,7 @@ namespace BLL
|
||||
if (table != null)
|
||||
{
|
||||
TwInOutplandetailService.DeleteByInOutPlanMasterId(table.Id);
|
||||
TwInoutplandetailRelationService.DeleteByInOutPlanMasterId(table.Id);
|
||||
|
||||
Funs.DB.Tw_InOutPlanMaster.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
@@ -405,7 +441,7 @@ namespace BLL
|
||||
Source = 2,
|
||||
Category = outMaster.Category,
|
||||
TypeInt = outMaster.TypeInt,
|
||||
State = (int)TwConst.State.待审核,
|
||||
State = (int)TwConst.State.已审核,
|
||||
CreateMan = outMaster.CreateMan,
|
||||
CreateDate = DateTime.Now,
|
||||
ReqUnitId = outMaster.ReqUnitId,
|
||||
@@ -473,5 +509,151 @@ namespace BLL
|
||||
}
|
||||
return cusBillCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据任务单生成出库计划单
|
||||
/// </summary>
|
||||
/// <param name="unitworkid"></param>
|
||||
/// <param name="unitid"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <param name="Personid"></param>
|
||||
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 MaterDatial= from x in db.HJGL_PipeLineMat
|
||||
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
|
||||
where pipelineList.Contains(x.PipelineId)
|
||||
select new
|
||||
{
|
||||
x.PipelineId,
|
||||
x.PrefabricatedComponents,
|
||||
x.MaterialCode,
|
||||
x.Number,
|
||||
y.MaterialUnit,
|
||||
};
|
||||
//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 outMateriaList = from x in MaterDatial
|
||||
group x by new { x.MaterialCode, x.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 = WeldTaskService.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);
|
||||
}
|
||||
var twinoutplandetailRelationList = MaterDatial.ToList().Select(x => new Tw_InOutPlanDetail_Relation
|
||||
{
|
||||
PipelineId = x.PipelineId,
|
||||
MaterialCode = x.MaterialCode,
|
||||
Number = x.Number,
|
||||
PrefabricatedComponents = x.PrefabricatedComponents,
|
||||
}).ToList();
|
||||
TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, table.Id);
|
||||
}
|
||||
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);
|
||||
}
|
||||
var twinoutplandetailRelationList = MaterDatial.ToList().Select(x => new Tw_InOutPlanDetail_Relation
|
||||
{
|
||||
PipelineId = x.PipelineId,
|
||||
MaterialCode = x.MaterialCode,
|
||||
Number = x.Number,
|
||||
PrefabricatedComponents = x.PrefabricatedComponents,
|
||||
}).ToList();
|
||||
TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, table.Id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user