1022-gaofei

This commit is contained in:
gaofei
2021-10-22 10:10:15 +08:00
parent 36c572af6d
commit 282cb7bd08
8 changed files with 557 additions and 79 deletions
@@ -110,7 +110,7 @@ namespace FineUIPro.Web.ProjectData
foreach (var installation in installations)
{
TreeNode newNode = new TreeNode();
newNode.Text = installation.InstallationName;
newNode.Text = "[" + installation.InstallationCode + "]" + installation.InstallationName;
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.EnableExpandEvent = true;
@@ -135,7 +135,7 @@ namespace FineUIPro.Web.ProjectData
foreach (var installation in installations)
{
TreeNode newNode = new TreeNode();
newNode.Text = installation.InstallationName;
newNode.Text = "[" + installation.InstallationCode + "]" + installation.InstallationName;
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.EnableExpandEvent = true;
@@ -244,6 +244,152 @@ namespace FineUIPro.Web.ProjectData
string url = Funs.RealNameApiUrl + "/Projects/GetConstructionWbsList";
string contenttype = "application/json;charset=utf-8";
var returndata = BLL.APIGetHttpService.ControlHttp(Funs.ControlApiUrl + "/Projects/GetConstructionWbsList?ProjId=" + 2370, "GET", contenttype, null, null);
if (!string.IsNullOrEmpty(returndata))
{
JObject obj = JObject.Parse(returndata);
JArray arr = JArray.Parse(obj["result"].ToString());
Model.SGGLDB db = Funs.DB;
//专业
var cnProfessionInits = from x in db.WBS_CnProfessionInit where x.CnProfessionId < 19 select x;
//单位工程及子单位工程
var unitProjectInits = from x in db.Wbs_UnitProjectInit where x.CnProfessionId < 19 orderby x.SuperUnitProject select x;
//分部/子分部/分项/子分项
var wbsSetInits = (from x in db.WBS_WbsSetInit where x.CnProfessionId < 19 orderby x.SuperWbsSetCode select x).ToList();
//费用清单对应关系
var wbsSetMatchCostControlInits = from x in db.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
//费用清单项
var totalCostControlInits = from x in db.WBS_CostControlInit orderby x.CostControlInitCode select x;
foreach (var item in arr)
{
string id = item["id"].ToString(); //记录Id,主键
string parentId = item["parentId"].ToString(); //上一级记录Id
string code = item["code"].ToString(); //WBS编码
string name = item["name"].ToString(); //WBS名称
string level = item["level"].ToString(); //级别,0-7依次表示:项目、阶段(施工)、装置、工序、主项、专业、分部工程、分项工程
string isLeaf = item["isLeaf"].ToString(); //是否末级
string ppsId = item["ppsId"].ToString(); //阶段ID3代表施工
string projId = item["projId"].ToString(); //项目ID
string planStart = item["planStart"].ToString(); //计划开始日期
string planFinish = item["planFinish"].ToString(); //计划完成日期
string remark = item["remark"].ToString(); //备注
if (level == "0" || level == "1" || level == "2" || level == "3" || level == "4")
{
Model.Project_Installation installation = new Model.Project_Installation();
installation.InstallationId = id;
installation.ProjectId = this.CurrUser.LoginProjectId;
installation.InstallationCode = code;
installation.InstallationName = name;
installation.SuperInstallationId = parentId == "-1" ? "0" : parentId;
installation.StartDate = Funs.GetNewDateTime(planStart);
installation.EndDate = Funs.GetNewDateTime(planFinish);
installation.IsEnd = Convert.ToBoolean(isLeaf);
installation.Def = remark;
db.Project_Installation.InsertOnSubmit(installation);
db.SubmitChanges();
}
else if (level == "5")
{
var cn = cnProfessionInits.FirstOrDefault(x => x.CnProfessionName.Contains(name.Substring(0, 2)));
//拷贝专业
if (cn != null)
{
Model.WBS_CnProfession cnProfession = new Model.WBS_CnProfession();
cnProfession.CnProfessionId = id;
cnProfession.CnProfessionName = cn.CnProfessionName;
cnProfession.CnProfessionCode = cn.CnProfessionCode;
cnProfession.InstallationId = parentId;
cnProfession.ProjectId = this.CurrUser.LoginProjectId;
cnProfession.StartDate = Funs.GetNewDateTime(planStart);
cnProfession.EndDate = Funs.GetNewDateTime(planFinish);
cnProfession.OldId = cn.CnProfessionId;
db.WBS_CnProfession.InsertOnSubmit(cnProfession);
db.SubmitChanges();
//单位工程
var unitProjects = unitProjectInits.Where(x => x.CnProfessionId == cn.CnProfessionId);
foreach (var unitProjectInit in unitProjects)
{
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
unitProject.InstallationId = parentId;
unitProject.SortIndex = unitProjectInit.SortIndex;
unitProject.SuperUnitProjectId = null;
unitProject.ProjectId = this.CurrUser.LoginProjectId;
unitProject.CnProfessionId = id;
unitProject.StartDate = Funs.GetNewDateTime(planStart);
unitProject.EndDate = Funs.GetNewDateTime(planFinish);
unitProject.Remark = unitProjectInit.Remark;
unitProject.IsIn = true;
db.Wbs_UnitProject.InsertOnSubmit(unitProject);
db.SubmitChanges();
}
//分部分项
var wbsSets = wbsSetInits.Where(x => x.CnProfessionId == cn.CnProfessionId);
foreach (var wbsSetInit in wbsSets)
{
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
wbsSet.InstallationId = parentId;
wbsSet.CnProfessionId = id;
wbsSet.UnitProjectId = (from x in db.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.CnProfessionId == id select x.UnitProjectId).FirstOrDefault();
if (wbsSetInit.SuperWbsSetCode == null)
{
wbsSet.SuperWbsSetId = null;
}
else
{
wbsSet.SuperWbsSetId = (from x in db.Wbs_WbsSet
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == parentId && x.CnProfessionId == id
select x.WbsSetId).FirstOrDefault();
}
wbsSet.ProjectId = this.CurrUser.LoginProjectId;
wbsSet.StartDate = Funs.GetNewDateTime(planStart);
wbsSet.EndDate = Funs.GetNewDateTime(planFinish);
wbsSet.Flag = wbsSetInit.Flag;
wbsSet.Way = wbsSetInit.Way;
wbsSet.Weights = wbsSetInit.Weights;
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
wbsSet.Remark = wbsSetInit.Remark;
wbsSet.IsIn = true;
db.Wbs_WbsSet.InsertOnSubmit(wbsSet);
db.SubmitChanges();
var wbsSetMatchCostControls = wbsSetMatchCostControlInits.Where(x => x.WbsSetCode == wbsSetInit.WbsSetCode);
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControls)
{
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
wbsSetMatchCostControl.WbsSetId = wbsSet.WbsSetId;
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
if (wbsSetMatchCostControl.WbsSetId != null)
{
db.WBS_WbsSetMatchCostControl.InsertOnSubmit(wbsSetMatchCostControl);
db.SubmitChanges();
//拷贝费用清单项
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
foreach (var costControlInit in costControlInits)
{
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
costControl.CostControlId = SQLHelper.GetNewID();
costControl.ProjectId = this.CurrUser.LoginProjectId;
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
costControl.CostControlCode = costControlInit.CostControlInitCode;
costControl.CostControlName = costControlInit.CostControlInitName;
costControl.Unit = costControlInit.Unit;
db.WBS_CostControl.InsertOnSubmit(costControl);
db.SubmitChanges();
}
}
}
}
}
}
}
ShowNotify("抽取成功!", MessageBoxIcon.Success);
}
}
else
{