2022-11-16-001 焊接施工计划状态字段获取

This commit is contained in:
2022-11-16 19:48:03 +08:00
parent 0352866cea
commit 4d94c81026
8 changed files with 278 additions and 17 deletions
+123 -3
View File
@@ -1,4 +1,6 @@
using MiniExcelLibs;
using Microsoft.Office.Interop.Word;
using Microsoft.SqlServer.Dts.Runtime;
using MiniExcelLibs;
using Model;
using System;
using System.Collections.Generic;
@@ -6,7 +8,9 @@ using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
using static BLL.PipelineService;
namespace BLL
{
@@ -20,6 +24,29 @@ namespace BLL
/// 现场安装
/// </summary>
public const string PipeArea_FIELD = "2";
/// <summary>
/// 实际日期类型
/// </summary>
public enum ActDateType
{
/// <summary>
/// 实际开始日期(预制)
/// </summary>
ActDateStart_Shop,
/// <summary>
/// 实际完成日期(预制)
/// </summary>
ActDateEnd_Shop ,
/// <summary>
/// 实际开始日期(安装)
/// </summary>
ActDateStart_FIELD ,
/// <summary>
/// 实际完成日期(安装)
/// </summary>
ActDateEnd_FIELD ,
}
public static ListItem[] GetPipeArea()
{
ListItem[] list = new ListItem[2];
@@ -37,6 +64,99 @@ namespace BLL
{
return Funs.DB.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
}
public static void GetStateByPipelineId(string pipelineId)
{//< f:ListItem Value = "0" Text = "未开始" />
// < f:ListItem Value = "1" Text = "未开始且延误" />
// < f:ListItem Value = "2" Text = "开始" />
// < f:ListItem Value = "3" Text = "已开始且延误" />
// < f:ListItem Value = "4" Text = "完成" />
var mdoel = GetPipelineByPipelineId(pipelineId);
var PlanStartDate = mdoel.PlanStartDate;
var PlanEndDate = mdoel.PlanEndDate;
var ActStartDate = new DateTime?();
var ActEndDate = new DateTime?();
if (!string .IsNullOrEmpty(GetDateByPipelineId(pipelineId, ActDateType.ActDateStart_FIELD)))
{
ActStartDate = Convert.ToDateTime(GetDateByPipelineId(pipelineId, ActDateType.ActDateStart_FIELD));
}
if (!string.IsNullOrEmpty(GetDateByPipelineId(pipelineId, ActDateType.ActDateEnd_FIELD)))
{
ActEndDate = Convert.ToDateTime(GetDateByPipelineId(pipelineId, ActDateType.ActDateEnd_FIELD));
}
if (ActStartDate==null&&DateTime.Compare(DateTime.Now,PlanStartDate.Value)<0)
{
mdoel.State = 0;
}
else if(ActStartDate == null && DateTime.Compare(DateTime.Now, PlanStartDate.Value) > 0)
{
mdoel.State = 1;
}
else if (ActStartDate!=null && DateTime.Compare(ActStartDate.Value, PlanStartDate.Value)<0 && ActEndDate==null)
{
mdoel.State = 2;
}
else if (ActStartDate != null && DateTime.Compare(ActStartDate.Value, PlanStartDate.Value) > 0 && ActEndDate == null)
{
mdoel.State = 3;
}
else if (ActEndDate != null)
{
mdoel.State = 4;
}
UpdatePipeline(mdoel);
}
public static string GetDateByPipelineId(object pipelineId, ActDateType actDateType)
{
string result ="";
string _pipelineId = pipelineId.ToString();
string ActDateStart_Shop = "";
string ActDateEnd_Shop = "";
string ActDateStart_FIELD = "";
string ActDateEnd_FIELD = "";
var pipemodel = GetPipelineByPipelineId(_pipelineId);
var joints = BLL.WeldJointService.GetWeldJointsByPipelineId(_pipelineId);
int joint_Shop_count = joints.Where(x => x.JointAttribute == "预制口").Count();
int joint_Field_count = joints.Where(x => x.JointAttribute == "安装口").Count();
var TaskJoints = (from x in Funs.DB.View_HJGL_WeldingTask where x.ProjectId == pipemodel.ProjectId && x.PipelineCode == pipemodel.PipelineCode
select x).ToList();
var TaskJoints_Shop = TaskJoints.Where(x => x.JointAttribute == "预制口").ToList();
var TaskJoints_Field= TaskJoints.Where(x => x.JointAttribute == "安装口").ToList();
if (TaskJoints_Shop.Count>0)
{
ActDateStart_Shop = TaskJoints_Shop.OrderBy(x => x.TaskDate).First().TaskDate.Value.ToShortDateString();
}
if (joint_Shop_count== TaskJoints_Shop.Count&& joint_Shop_count>0)
{
ActDateEnd_Shop = TaskJoints_Shop.OrderByDescending(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
}
if (TaskJoints_Field.Count > 0)
{
ActDateStart_FIELD = TaskJoints_Field.OrderBy(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
}
if (joint_Field_count == TaskJoints_Field.Count && joint_Field_count > 0)
{
ActDateEnd_FIELD = TaskJoints_Field.OrderByDescending(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
}
switch (actDateType)
{
case ActDateType.ActDateStart_Shop:
result = ActDateStart_Shop;
break;
case ActDateType.ActDateEnd_Shop:
result = ActDateEnd_Shop;
break;
case ActDateType.ActDateStart_FIELD:
result = ActDateStart_FIELD;
break;
case ActDateType.ActDateEnd_FIELD:
result = ActDateEnd_FIELD;
break;
}
return result;
}
public static Model.HJGL_Pipeline GetPipelineByPipelineCode(string pipelineCode)
{
return Funs.DB.HJGL_Pipeline.FirstOrDefault(e => e.PipelineCode == pipelineCode);
@@ -158,7 +278,7 @@ namespace BLL
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
tb.TableName = "Data";
var value = new Dictionary<string, object>()
{
@@ -225,7 +345,7 @@ namespace BLL
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
tb.TableName = "Data";
var value = new Dictionary<string, object>()
{