237 lines
9.3 KiB
C#
237 lines
9.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace BLL
|
|
{
|
|
public class CQMS_MainPlanService
|
|
{
|
|
/// <summary>
|
|
/// 获取总包施工计划信息
|
|
/// </summary>
|
|
/// <param name="UnitWorkId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Plan_MainPlan GetMainPlanByMainPlanId(string MainPlanId)
|
|
{
|
|
return Funs.DB.Plan_MainPlan.FirstOrDefault(e => e.MainPlanId == MainPlanId);
|
|
}
|
|
/// <summary>
|
|
/// 添加总包施工计划信息
|
|
/// </summary>
|
|
/// <param name="WPQ"></param>
|
|
public static void AddMainPlan(Model.Plan_MainPlan MainPlan)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Plan_MainPlan newMainPlan = new Model.Plan_MainPlan();
|
|
newMainPlan.MainPlanId = MainPlan.MainPlanId;
|
|
newMainPlan.ProjectId = MainPlan.ProjectId;
|
|
newMainPlan.PlanCode = MainPlan.PlanCode;
|
|
newMainPlan.FileName = MainPlan.FileName;
|
|
newMainPlan.State = MainPlan.State;
|
|
newMainPlan.CompileMan = MainPlan.CompileMan;
|
|
newMainPlan.CompileDate = MainPlan.CompileDate;
|
|
newMainPlan.FilePath = MainPlan.FilePath;
|
|
db.Plan_MainPlan.InsertOnSubmit(newMainPlan);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改总包施工计划信息
|
|
/// </summary>
|
|
/// <param name="WPQ"></param>
|
|
public static void UpdateMainPlan(Model.Plan_MainPlan MainPlan)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Plan_MainPlan newMainPlan = db.Plan_MainPlan.FirstOrDefault(e => e.MainPlanId == MainPlan.MainPlanId);
|
|
if (newMainPlan != null)
|
|
{
|
|
newMainPlan.PlanCode = MainPlan.PlanCode;
|
|
newMainPlan.FileName = MainPlan.FileName;
|
|
newMainPlan.State = MainPlan.State;
|
|
newMainPlan.FilePath = MainPlan.FilePath;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据主键删除总包施工计划信息
|
|
/// </summary>
|
|
/// <param name="checkerId"></param>
|
|
public static void DeleteMainPlanById(string MainPlanId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Plan_MainPlan MainPlan = db.Plan_MainPlan.FirstOrDefault(e => e.MainPlanId == MainPlanId);
|
|
if (MainPlan != null)
|
|
{
|
|
db.Plan_MainPlan.DeleteOnSubmit(MainPlan);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据状态选择下一步办理类型
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetDHandleTypeByState(string state, string mainPlanId)
|
|
{
|
|
var auditApproves = Funs.DB.Plan_MainPlanApprove.FirstOrDefault(x => x.MainPlanId == mainPlanId && x.ApproveType == Const.MainPlan_Audit3);
|
|
if (state == Const.MainPlan_Compile)
|
|
{
|
|
ListItem[] lis = new ListItem[1];
|
|
lis[0] = new ListItem("施工经理审核", Const.MainPlan_Audit1);
|
|
return lis;
|
|
}
|
|
else if (state == Const.MainPlan_ReCompile)
|
|
{
|
|
if (auditApproves == null) //未进入小组评审
|
|
{
|
|
ListItem[] lis = new ListItem[1];
|
|
lis[0] = new ListItem("施工经理审核", Const.MainPlan_Audit1);
|
|
return lis;
|
|
}
|
|
else
|
|
{
|
|
ListItem[] lis = new ListItem[1];
|
|
lis[0] = new ListItem("评审小组组长确认", Const.MainPlan_Audit5);
|
|
return lis;
|
|
}
|
|
}
|
|
else if (state == Const.MainPlan_Audit1)
|
|
{
|
|
if (auditApproves == null) //未进入小组评审
|
|
{
|
|
ListItem[] lis = new ListItem[2];
|
|
lis[0] = new ListItem("部门评审小组审核", Const.MainPlan_Audit2);
|
|
lis[1] = new ListItem("重新编制", Const.MainPlan_ReCompile);
|
|
return lis;
|
|
}
|
|
else
|
|
{
|
|
ListItem[] lis = new ListItem[2];
|
|
lis[0] = new ListItem("项目经理批准", Const.MainPlan_Audit4);
|
|
lis[1] = new ListItem("重新编制", Const.MainPlan_ReCompile);
|
|
return lis;
|
|
}
|
|
}
|
|
else if (state == Const.MainPlan_Audit4)
|
|
{
|
|
ListItem[] lis = new ListItem[2];
|
|
lis[0] = new ListItem("审批完成", Const.MainPlan_Complete);
|
|
lis[1] = new ListItem("重新编制", Const.MainPlan_ReCompile);
|
|
return lis;
|
|
}
|
|
else
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 把状态转换代号为文字形式
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static string ConvertState(object state)
|
|
{
|
|
if (state != null)
|
|
{
|
|
if (state.ToString() == BLL.Const.MainPlan_ReCompile)
|
|
{
|
|
return "重新编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Compile)
|
|
{
|
|
return "编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit1)
|
|
{
|
|
return "施工经理审核";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit2)
|
|
{
|
|
return "部门评审小组审核";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit3)
|
|
{
|
|
return "审核";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit4)
|
|
{
|
|
return "项目经理批准";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit5)
|
|
{
|
|
return "评审小组组长确认";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Complete)
|
|
{
|
|
return "审批完成";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public static List<Model.Plan_MainPlan> getListDataForApi(string projectId, int startRowIndex, int maximumRows)
|
|
{
|
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
IQueryable<Model.Plan_MainPlan> q = db.Plan_MainPlan;
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
q = q.Where(e => e.ProjectId == projectId);
|
|
}
|
|
var qres = from x in q
|
|
orderby x.CompileDate descending
|
|
select new
|
|
{
|
|
x.MainPlanId,
|
|
x.PlanCode,
|
|
x.ProjectId,
|
|
x.FileName,
|
|
x.CompileDate,
|
|
x.CompileMan,
|
|
x.State,
|
|
StateStr = ConvertState(x.State),
|
|
CompileManName = (from y in db.Person_Persons where y.PersonId == x.CompileMan select y.PersonName).First(),
|
|
HandleManName = BLL.CQMS_MainPlanApproveService.GetHandleManName(x.MainPlanId),
|
|
FilePath = x.FilePath,
|
|
};
|
|
List<Model.Plan_MainPlan> res = new List<Model.Plan_MainPlan>();
|
|
var list = qres.Skip(startRowIndex).Take(maximumRows).ToList();
|
|
foreach (var item in list)
|
|
{
|
|
Model.Plan_MainPlan cd = new Model.Plan_MainPlan();
|
|
cd.MainPlanId = item.MainPlanId;
|
|
cd.ProjectId = item.ProjectId;
|
|
cd.PlanCode = item.PlanCode;
|
|
cd.FileName = item.FileName;
|
|
cd.CompileDate = item.CompileDate;
|
|
cd.CompileMan = item.CompileMan + "$" + item.CompileManName;
|
|
cd.State = item.State + "$" + item.StateStr + "$" + item.HandleManName;
|
|
cd.FilePath = item.FilePath;
|
|
res.Add(cd);
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取总包施工计划信息
|
|
/// </summary>
|
|
/// <param name="UnitWorkId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Plan_MainPlan GetMainPlanByMainPlanIdForApi(string MainPlanId)
|
|
{
|
|
var q = Funs.DB.Plan_MainPlan.FirstOrDefault(e => e.MainPlanId == MainPlanId);
|
|
if (q != null)
|
|
{
|
|
q.State = q.State + "$" + ConvertState(q.State) + "$" + BLL.CQMS_MainPlanApproveService.GetHandleManName(q.MainPlanId);
|
|
q.CompileMan = q.CompileMan + "$" + BLL.Person_PersonsService.GetPersonsNameById(q.CompileMan);
|
|
}
|
|
return q;
|
|
}
|
|
}
|
|
}
|