380 lines
12 KiB
C#
380 lines
12 KiB
C#
using Model;
|
|
using Model.APIItem;
|
|
using NPOI.SS.Formula.Eval;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
|
|
namespace BLL.API
|
|
{
|
|
public class APIWeldServices
|
|
{
|
|
|
|
public static Model.ResponeData usingPlanList(string weldName, string needConfirm, string userId, string useState,int page, int pageSize)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
List<string> projectids = new List<string>();
|
|
var upids = db.Project_User.Where(x => x.UserId == userId).Select(x => x.ProjectId).ToList();
|
|
projectids.AddRange(upids);
|
|
var wpids = db.Project_Welder.Where(x => x.WED_ID == userId).Select(x => x.ProjectId).ToList();
|
|
projectids.AddRange(wpids);
|
|
|
|
var q = from x in db.Weld_UsingPlan where projectids.Contains(x.ProjectId) select x;
|
|
List<string> usingplanids = new List<string>();
|
|
if (!string.IsNullOrEmpty(useState))
|
|
{
|
|
switch (useState)
|
|
{
|
|
case "0"://未领用
|
|
q = q.Where(x => x.IsCancel.Value == false);
|
|
var ids1 = db.Weld_UsingMat.Where(x => projectids.Contains(x.ProjectId)).Select(x => x.UsingPlanId).ToList();
|
|
usingplanids.AddRange(ids1);
|
|
break;
|
|
case "1"://已领用
|
|
var ids2 = db.Weld_UsingMat.Where(x => projectids.Contains(x.ProjectId)).Select(x => x.UsingPlanId).ToList();
|
|
usingplanids.AddRange(ids2);
|
|
break;
|
|
case "2"://已作废
|
|
q = q.Where(x => x.IsCancel.Value == true);
|
|
break;
|
|
}
|
|
|
|
}
|
|
//if (!string.IsNullOrEmpty(userId))
|
|
//{
|
|
// q = q.Where(x => x.WeldId == userId);
|
|
//}
|
|
List<string> weldIds = new List<string>();
|
|
if (!string.IsNullOrEmpty(weldName))
|
|
{
|
|
weldIds = db.Weld_WeldInfo.Where(x => x.WeldName.Contains(weldName)).Select(x => x.WeldId).ToList();
|
|
q = q.Where(x => weldIds.Contains(x.WeldId));
|
|
}
|
|
if (!string.IsNullOrEmpty(needConfirm))
|
|
{
|
|
q = q.Where(x => x.IsNeedConfirm.Value == true);
|
|
}
|
|
List<UsingPlanItem> usingPlanItem = new List<UsingPlanItem>();
|
|
var list = q.OrderBy(x=>x.OrderDate).ToList();
|
|
if (list.Count > 0)
|
|
{
|
|
foreach (var x in list)
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(weldName))
|
|
{
|
|
bool hasFind = false;
|
|
foreach (string wid in weldIds)
|
|
if (wid == x.WeldId)
|
|
{
|
|
hasFind = true;
|
|
}
|
|
if (!hasFind)
|
|
continue;
|
|
}
|
|
|
|
if (useState == "1")
|
|
{
|
|
bool hasFind = false;
|
|
foreach (string wid in usingplanids)
|
|
if (wid == x.UsingPlanId)
|
|
{
|
|
hasFind = true;
|
|
}
|
|
if (!hasFind)
|
|
continue;
|
|
}
|
|
if (useState == "0" && usingplanids.Count() > 0)
|
|
{
|
|
bool hasFind = false;
|
|
foreach (var wid in usingplanids)
|
|
if (wid == x.UsingPlanId)
|
|
{
|
|
hasFind = true;
|
|
}
|
|
if (hasFind)
|
|
continue;
|
|
}
|
|
|
|
|
|
UsingPlanItem planItem= new UsingPlanItem();
|
|
planItem.UsingPlanId = x.UsingPlanId;
|
|
planItem.WeldId = x.WeldId;
|
|
planItem.ProjectId = x.ProjectId;
|
|
planItem.UsePosition = x.UsePosition;
|
|
planItem.Amount = x.Amount;
|
|
planItem.UsingManOne = x.UsingManOne;
|
|
planItem.UsingManTwo = x.UsingManTwo;
|
|
planItem.InPutDate = x.InPutDate;
|
|
planItem.CancelDate = x.CancelDate;
|
|
planItem.IsCancel = x.IsCancel;
|
|
planItem.FinishMan = x.FinishMan;
|
|
planItem.OrderTime = x.OrderTime;
|
|
planItem.OrderDate = x.OrderDate;
|
|
planItem.CancelResult = x.CancelResult;
|
|
planItem.IsSubmit = x.IsSubmit;
|
|
planItem.UsingUnit = x.UsingUnit;
|
|
planItem.IsNeedConfirm = x.IsNeedConfirm;
|
|
planItem.InPutMan = x.InPutMan;
|
|
planItem.IsSteelStru = x.IsSteelStru;
|
|
planItem.TeamGroupId = x.TeamGroupId;
|
|
planItem.STE_ID = x.STE_ID;
|
|
planItem.IsFinish = x.IsFinish;
|
|
planItem.STE_Name = x.STE_Name;
|
|
|
|
usingPlanItem.Add(planItem);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
usingPlanItem = usingPlanItem.Skip(page*pageSize).Take(pageSize).ToList();
|
|
foreach (var item in usingPlanItem)
|
|
{
|
|
if (!string.IsNullOrEmpty(item.ProjectId))
|
|
{
|
|
var project = db.Base_Project.Where(x => x.ProjectId == item.ProjectId).FirstOrDefault();
|
|
if (project != null)
|
|
{
|
|
item.ProjectName = project.ProjectName;
|
|
item.ProjectCode = project.ProjectCode;
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(item.WeldId))
|
|
{
|
|
var weldInfo = db.Weld_WeldInfo.Where(x => x.WeldId == item.WeldId).FirstOrDefault();
|
|
if (weldInfo != null)
|
|
{
|
|
item.WeldName = weldInfo.WeldName;
|
|
item.WeldSpec = weldInfo.WeldSpec;
|
|
}
|
|
if (weldInfo != null && !string.IsNullOrEmpty(weldInfo.WeldTypeId))
|
|
{
|
|
var weldType = db.Weld_WeldType.Where(x => x.WeldTypeId == weldInfo.WeldTypeId).FirstOrDefault();
|
|
|
|
if (weldType != null)
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(item.UsingManOne))
|
|
{
|
|
item.UsingManOneName = db.HJGL_BS_Welder.Where(x => x.WED_ID == item.UsingManOne).Select(x => x.WED_Name).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(item.UsingManTwo))
|
|
{
|
|
item.UsingManTwoName = db.HJGL_BS_Welder.Where(x => x.WED_ID == item.UsingManTwo).Select(x => x.WED_Name).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(item.UsingUnit))
|
|
{
|
|
item.UsingUnitName = db.Base_Unit.Where(x => x.UnitId == item.UsingUnit).Select(x => x.UnitName).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(item.InPutMan))
|
|
{
|
|
item.InPutManName = db.Sys_User.Where(x => x.UserId == item.InPutMan).Select(x => x.UserName).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(item.TeamGroupId))
|
|
{
|
|
item.TeamGroupName = db.Base_TeamGroup.Where(x => x.TeamGroupId == item.TeamGroupId).Select(x => x.TeamGroupName).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(item.TeamGroupId))
|
|
{
|
|
item.TeamGroupName = db.Base_TeamGroup.Where(x => x.TeamGroupId == item.TeamGroupId).Select(x => x.TeamGroupName).FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
|
|
respone.data = usingPlanItem;
|
|
}
|
|
return respone;
|
|
}
|
|
public static Model.ResponeData getUsingPlanById(string usingPlanId)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
|
|
|
|
Weld_UsingPlan usingPlan = (from x in db.Weld_UsingPlan where x.UsingPlanId == usingPlanId select x).FirstOrDefault();
|
|
|
|
UsingPlanItem planItem = new UsingPlanItem();
|
|
planItem.UsingPlanId = usingPlan.UsingPlanId;
|
|
planItem.WeldId = usingPlan.WeldId;
|
|
planItem.ProjectId = usingPlan.ProjectId;
|
|
planItem.UsePosition = usingPlan.UsePosition;
|
|
planItem.Amount = usingPlan.Amount;
|
|
planItem.UsingManOne = usingPlan.UsingManOne;
|
|
planItem.UsingManTwo = usingPlan.UsingManTwo;
|
|
planItem.InPutDate = usingPlan.InPutDate;
|
|
planItem.CancelDate = usingPlan.CancelDate;
|
|
planItem.IsCancel = usingPlan.IsCancel;
|
|
planItem.FinishMan = usingPlan.FinishMan;
|
|
planItem.OrderTime = usingPlan.OrderTime;
|
|
planItem.OrderDate = usingPlan.OrderDate;
|
|
planItem.CancelResult = usingPlan.CancelResult;
|
|
planItem.IsSubmit = usingPlan.IsSubmit;
|
|
planItem.UsingUnit = usingPlan.UsingUnit;
|
|
planItem.IsNeedConfirm = usingPlan.IsNeedConfirm;
|
|
planItem.InPutMan = usingPlan.InPutMan;
|
|
planItem.IsSteelStru = usingPlan.IsSteelStru;
|
|
planItem.TeamGroupId = usingPlan.TeamGroupId;
|
|
planItem.STE_ID = usingPlan.STE_ID;
|
|
planItem.IsFinish = usingPlan.IsFinish;
|
|
planItem.STE_Name = usingPlan.STE_Name;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(planItem.ProjectId))
|
|
{
|
|
var project = db.Base_Project.Where(x => x.ProjectId == planItem.ProjectId).FirstOrDefault();
|
|
if (project != null)
|
|
{
|
|
planItem.ProjectName = project.ProjectName;
|
|
planItem.ProjectCode = project.ProjectCode;
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(planItem.WeldId))
|
|
{
|
|
var weldInfo = db.Weld_WeldInfo.Where(x => x.WeldId == planItem.WeldId).FirstOrDefault();
|
|
if (weldInfo != null)
|
|
{
|
|
planItem.WeldName = weldInfo.WeldName;
|
|
planItem.WeldSpec = weldInfo.WeldSpec;
|
|
}
|
|
if (weldInfo != null && !string.IsNullOrEmpty(weldInfo.WeldTypeId))
|
|
{
|
|
var weldType = db.Weld_WeldType.Where(x => x.WeldTypeId == weldInfo.WeldTypeId).FirstOrDefault();
|
|
|
|
if (weldType != null)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(planItem.UsingManOne))
|
|
{
|
|
planItem.UsingManOneName = db.HJGL_BS_Welder.Where(x => x.WED_ID == planItem.UsingManOne).Select(x => x.WED_Name).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(planItem.UsingManTwo))
|
|
{
|
|
planItem.UsingManTwoName = db.HJGL_BS_Welder.Where(x => x.WED_ID == planItem.UsingManTwo).Select(x => x.WED_Name).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(planItem.UsingUnit))
|
|
{
|
|
planItem.UsingUnitName = db.Base_Unit.Where(x => x.UnitId == planItem.UsingUnit).Select(x => x.UnitName).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(planItem.InPutMan))
|
|
{
|
|
planItem.InPutManName = db.Sys_User.Where(x => x.UserId == planItem.InPutMan).Select(x => x.UserName).FirstOrDefault();
|
|
}
|
|
if (!string.IsNullOrEmpty(planItem.TeamGroupId))
|
|
{
|
|
planItem.TeamGroupName = db.Base_TeamGroup.Where(x => x.TeamGroupId == planItem.TeamGroupId).Select(x => x.TeamGroupName).FirstOrDefault();
|
|
}
|
|
|
|
|
|
respone.data = planItem;
|
|
}
|
|
return respone;
|
|
}
|
|
|
|
public static Model.ResponeData welderQueIsPass(string welderId, string steelType, bool isSteelStru)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
respone.data = true;
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
List<HJGL_BS_WelderQualifiedProject> list = new List<HJGL_BS_WelderQualifiedProject>();
|
|
if (isSteelStru == true)
|
|
{
|
|
list = db.HJGL_BS_WelderQualifiedProject.Where(x => x.WED_ID == welderId && x.LimitDate < DateTime.Now).ToList();
|
|
}
|
|
else
|
|
{
|
|
list = db.HJGL_BS_WelderQualifiedProject.Where(x => x.WED_ID == welderId && x.LimitDate < DateTime.Now && (!x.IsSteelStru.HasValue || !x.IsSteelStru.HasValue)).ToList();
|
|
|
|
}
|
|
|
|
foreach(string type in steelType.Split(','))
|
|
{
|
|
foreach(HJGL_BS_WelderQualifiedProject item in list)
|
|
{
|
|
if (!item.MaterialType.Contains(type))
|
|
{
|
|
respone.data = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return respone;
|
|
}
|
|
|
|
public static Model.ResponeData addUsingPlan(UsingPlanItem usingPlan)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
|
|
|
|
Weld_UsingPlan newUsingPlan = new Weld_UsingPlan();
|
|
if (string.IsNullOrEmpty(usingPlan.UsingPlanId))
|
|
{
|
|
newUsingPlan.UsingPlanId = Guid.NewGuid().ToString();
|
|
newUsingPlan.OrderDate = DateTime.Now;
|
|
db.Weld_UsingPlan.InsertOnSubmit(newUsingPlan);
|
|
}
|
|
else
|
|
{
|
|
newUsingPlan = db.Weld_UsingPlan.FirstOrDefault(x => x.UsingPlanId == usingPlan.UsingPlanId);
|
|
}
|
|
newUsingPlan.WeldId = usingPlan.WeldId;
|
|
newUsingPlan.ProjectId = usingPlan.ProjectId;
|
|
newUsingPlan.UsePosition = usingPlan.UsePosition;
|
|
newUsingPlan.Amount = usingPlan.Amount;
|
|
newUsingPlan.UsingManOne = usingPlan.UsingManOne;
|
|
newUsingPlan.UsingManTwo = usingPlan.UsingManTwo;
|
|
newUsingPlan.InPutDate = usingPlan.InPutDate;
|
|
newUsingPlan.CancelDate = usingPlan.CancelDate;
|
|
newUsingPlan.IsCancel = usingPlan.IsCancel;
|
|
newUsingPlan.FinishMan = usingPlan.FinishMan;
|
|
newUsingPlan.OrderTime = usingPlan.OrderTime;
|
|
newUsingPlan.OrderDate = usingPlan.OrderDate;
|
|
newUsingPlan.CancelResult = usingPlan.CancelResult;
|
|
newUsingPlan.IsSubmit = usingPlan.IsSubmit;
|
|
newUsingPlan.UsingUnit = usingPlan.UsingUnit;
|
|
newUsingPlan.IsNeedConfirm = usingPlan.IsNeedConfirm;
|
|
newUsingPlan.InPutMan = usingPlan.InPutMan;
|
|
newUsingPlan.IsSteelStru = usingPlan.IsSteelStru;
|
|
newUsingPlan.TeamGroupId = usingPlan.TeamGroupId;
|
|
newUsingPlan.STE_ID = usingPlan.STE_ID;
|
|
newUsingPlan.IsFinish = usingPlan.IsFinish;
|
|
newUsingPlan.STE_Name = usingPlan.STE_Name;
|
|
db.SubmitChanges();
|
|
|
|
var old = db.Weld_UsingPlan.Where(x => x.UsingManOne == usingPlan.UsingManOne && x.OrderTime == usingPlan.OrderTime && x.OrderDate == usingPlan.OrderDate).ToList();
|
|
if (old.Count > 2)
|
|
{
|
|
foreach(var item in old)
|
|
{
|
|
item.IsNeedConfirm = true;
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
return respone;
|
|
}
|
|
|
|
|
|
}
|
|
}
|