材料管理修改(打印修改,出库单已审核已完成不计算匹配率)材料匹配修改,焊接任务单修改

This commit is contained in:
2024-12-06 22:17:50 +08:00
parent 77fbdb946d
commit f4f7f93835
24 changed files with 850 additions and 323 deletions
@@ -1336,82 +1336,171 @@ namespace FineUIPro.Web.HJGL.WeldingManage
protected void btnPrintTask_Click(object sender, EventArgs e)
{
DateTime? taskTime = Funs.GetNewDateTime(tvControlItem.SelectedNodeID.Split('|')[2]);
if (taskTime != null)
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
var weldTaskList = BLL.WeldTaskService.GetWeldingTaskList(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID.Split('|')[0], tvControlItem.SelectedNodeID.Split('|')[1], Convert.ToDateTime(taskTime), this.rbIsAudit.SelectedValue);
var pipelines = weldTaskList.Select(x => x.PipelineId).Distinct().ToList();
if (pipelines.Any())
if (tvControlItem.SelectedNodeID.Contains("|"))
{
BLL.FastReportService.ResetData();
//var result = HJGL_PipelineComponentService.GetPrintModelByPipelineComponentIds(null, pipelines.ToArray(), true);
//var PipelineComponentIds = result.Select(x => x.PipelineComponentId).ToArray();
//var tb = LINQToDataTable(result);
//if (tb != null && tb.Rows.Count > 0)
//{
// tb.TableName = "Table1";
//}
//else
//{
// ShowNotify("该管线已打印完成", MessageBoxIcon.Question);
// return;
//}
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("Code", UnitWorkService.getUnitWorkByUnitWorkId(tvControlItem.SelectedNodeID.Split('|')[0]).UnitWorkCode+ string.Format("{0:yyyyMMdd}", taskTime.Value));
keyValuePairs.Add("TaskDate", string.Format("{0:yyyy-MM-dd}", taskTime.Value));
keyValuePairs.Add("UnitName", UnitService.GetUnitNameByUnitId(tvControlItem.SelectedNodeID.Split('|')[1]));
keyValuePairs.Add("UnitWorkName]", UnitWorkService.getUnitWorkByUnitWorkId(tvControlItem.SelectedNodeID.Split('|')[0]).UnitWorkName);
// 创建一个新的DataTable
DataTable dataTable = new DataTable();
dataTable.TableName = "Data";
// 添加列
dataTable.Columns.Add("PipelineCode", typeof(string));
dataTable.Columns.Add("FlowingSection", typeof(string));
dataTable.Columns.Add("MaterialCode", typeof(string));
dataTable.Columns.Add("MaterialSpec", typeof(string));
dataTable.Columns.Add("MatchRate", typeof(string));
foreach (string pipeline in pipelines)
DateTime? taskTime = Funs.GetNewDateTime(tvControlItem.SelectedNodeID.Split('|')[2]);
if (taskTime != null)
{
DataRow dr = dataTable.NewRow();
var pipelineModel = PipelineService.GetPipelineByPipelineId(pipeline);
List<string > list=new List<string> { pipeline };
var weldTaskList = BLL.WeldTaskService.GetWeldingTaskList(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID.Split('|')[0], tvControlItem.SelectedNodeID.Split('|')[1], Convert.ToDateTime(taskTime), this.rbIsAudit.SelectedValue);
var pipelines = weldTaskList.Select(x => x.PipelineId).Distinct().ToList();
dr["PipelineCode"] = pipelineModel.PipelineCode;
dr["FlowingSection"] = pipelineModel.FlowingSection;
dr["MaterialCode"] = Base_MaterialService.GetMaterialByMaterialId(pipelineModel.MaterialId).MaterialCode ;
dr["MaterialSpec"] = string.Join(",", weldTaskList.Select(x => x.Specification).Distinct().ToList()) ;
dr["MatchRate"] = Math.Round((decimal)TwArrivalStatisticsService.GetPipeMatch(pipeline) * 100, 2).ToString() + "%" ;
dataTable.Rows.Add(dr);
}
BLL.FastReportService.AddFastreportTable(dataTable);
BLL.FastReportService.AddFastreportParameter(keyValuePairs);
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\管道焊接任务单.frx";
if (pipelines.Any())
{
BLL.FastReportService.ResetData();
List<Model.Tw_PrintMaster> tw_PrintMasters = new List<Model.Tw_PrintMaster>();
var time = Convert.ToDateTime(taskTime);
var weldTask_CreateName = (from x in Funs.DB.HJGL_WeldTask
where x.ProjectId == this.CurrUser.LoginProjectId &&
x.UnitWorkId == tvControlItem.SelectedNodeID.Split('|')[0] &&
x.UnitId == tvControlItem.SelectedNodeID.Split('|')[1]
&& x.TaskDate.Value.Date == time.Date && x.Tabler != null
select x).FirstOrDefault();
var weldTask = (from x in Funs.DB.HJGL_WeldTask
where x.ProjectId == this.CurrUser.LoginProjectId &&
x.UnitWorkId == tvControlItem.SelectedNodeID.Split('|')[0] &&
x.UnitId == tvControlItem.SelectedNodeID.Split('|')[1]
&& x.TaskDate.Value.Date == time.Date && x.AuditMan != null && x.AuditMan2 != null &&
x.Tabler != null
select x).FirstOrDefault();
Model.Tw_PrintMaster printMaster = new Model.Tw_PrintMaster
{
CreateManName = !string.IsNullOrEmpty(weldTask_CreateName?.Tabler) ? BLL.Person_PersonsService.getSignatureUrl(weldTask_CreateName.Tabler) : "",
AuditManName = !string.IsNullOrEmpty(weldTask?.AuditMan) ? BLL.Person_PersonsService.getSignatureUrl(weldTask.AuditMan) : "",
AuditManName2 = !string.IsNullOrEmpty(weldTask?.AuditMan2) ? BLL.Person_PersonsService.getSignatureUrl(weldTask.AuditMan2) : "",
};
tw_PrintMasters.Add(printMaster);
DataTable Table1 = LINQToDataTable(tw_PrintMasters);
if (Table1 != null)
{
Table1.TableName = "Table1";
}
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("Code", UnitWorkService.getUnitWorkByUnitWorkId(tvControlItem.SelectedNodeID.Split('|')[0]).UnitWorkCode + string.Format("{0:yyyyMMdd}", taskTime.Value));
keyValuePairs.Add("TaskDate", string.Format("{0:yyyy-MM-dd}", taskTime.Value));
keyValuePairs.Add("UnitName", UnitService.GetUnitNameByUnitId(tvControlItem.SelectedNodeID.Split('|')[1]));
keyValuePairs.Add("UnitWorkName]", UnitWorkService.getUnitWorkByUnitWorkId(tvControlItem.SelectedNodeID.Split('|')[0]).UnitWorkName);
// 创建一个新的DataTable
DataTable dataTable = new DataTable();
dataTable.TableName = "Data";
// 添加列
dataTable.Columns.Add("PipelineCode", typeof(string));
dataTable.Columns.Add("FlowingSection", typeof(string));
dataTable.Columns.Add("MaterialCode", typeof(string));
dataTable.Columns.Add("MaterialSpec", typeof(string));
dataTable.Columns.Add("MatchRate", typeof(string));
dataTable.Columns.Add("Dia", typeof(string));
foreach (string pipeline in pipelines)
{
DataRow dr = dataTable.NewRow();
var pipelineModel = PipelineService.GetPipelineByPipelineId(pipeline);
List<string> list = new List<string> { pipeline };
dr["PipelineCode"] = pipelineModel.PipelineCode;
dr["FlowingSection"] = pipelineModel.FlowingSection;
dr["MaterialCode"] = Base_MaterialService.GetMaterialByMaterialId(pipelineModel.MaterialId).MaterialCode;
dr["MaterialSpec"] = string.Join(",", weldTaskList.Select(x => x.Specification).Distinct().ToList());
dr["MatchRate"] = Math.Round((decimal)TwArrivalStatisticsService.GetPipeMatch(pipeline) * 100, 2).ToString() + "%";
dr["Dia"] = weldTaskList.Where(x => x.PipelineId == pipeline).Sum(x => x.Size ?? 0)
.ToString();
dataTable.Rows.Add(dr);
}
BLL.FastReportService.AddFastreportTable(Table1);
BLL.FastReportService.AddFastreportTable(dataTable);
BLL.FastReportService.AddFastreportParameter(keyValuePairs);
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\管道焊接任务单.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("~/Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
}
else
{
ShowNotify("无关联管线", MessageBoxIcon.Question);
}
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("~/Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
}
else
{
ShowNotify("无关联管线", MessageBoxIcon.Question);
ShowNotify("请选择任务单", MessageBoxIcon.Question);
}
}
}
}
else
protected void btnPassMaster_OnClick(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
ShowNotify("请选择任务单", MessageBoxIcon.Question);
}
if (tvControlItem.SelectedNodeID.Contains("|"))
{
DateTime? taskTime = Funs.GetNewDateTime(tvControlItem.SelectedNodeID.Split('|')[2]);
if (taskTime != null)
{
var time = Convert.ToDateTime(taskTime);
var weldTaskList = (from x in Funs.DB.HJGL_WeldTask
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == tvControlItem.SelectedNodeID.Split('|')[0] && x.UnitId == tvControlItem.SelectedNodeID.Split('|')[1]
&& x.TaskDate.Value.Date == time.Date
select x).ToList();
foreach (var weldTask in weldTaskList)
{
weldTask.AuditMan = this.CurrUser.PersonId;
weldTask.AuditDate = DateTime.Now;
Funs.DB.SubmitChanges();
}
ShowNotify("审核通过!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("请选择任务单", MessageBoxIcon.Question);
}
}
}
protected void btnPassMaster2_OnClick(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
if (tvControlItem.SelectedNodeID.Contains("|"))
{
DateTime? taskTime = Funs.GetNewDateTime(tvControlItem.SelectedNodeID.Split('|')[2]);
if (taskTime != null)
{
var time = Convert.ToDateTime(taskTime);
var weldTaskList = (from x in Funs.DB.HJGL_WeldTask
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == tvControlItem.SelectedNodeID.Split('|')[0] && x.UnitId == tvControlItem.SelectedNodeID.Split('|')[1]
&& x.TaskDate.Value.Date == time.Date
select x).ToList();
foreach (var weldTask in weldTaskList)
{
weldTask.AuditMan2 = this.CurrUser.PersonId;
weldTask.AuditDate2 = DateTime.Now;
Funs.DB.SubmitChanges();
}
ShowNotify("审核通过!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("请选择任务单", MessageBoxIcon.Question);
}
}
}
}
}