ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/WebService1.asmx.cs

846 lines
46 KiB
C#
Raw Normal View History

2024-05-08 17:17:11 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.IO.Compression;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Web;
using System.Collections;
using System.Runtime.Serialization.Json;
using System.Runtime.Serialization;
using System.Web.Services.Protocols;
using System.Web.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using BLL;
namespace FineUIPro.Web
{
/// <summary>
/// WebService1 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod(Description="求和方法")]
public int sum(int a ,int b)
{
return a + b;
}
[WebMethod(Description = "项目焊工")]
public string welderListToJson(string projectId)
{
//var project = BLL.Project_WelderService.GetProjectWelder(projectId);
//string[] welders = new string[project.Count()];
List<Model.Project_Welder> welderList = new List<Model.Project_Welder>();
welderList = BLL.Project_WelderService.GetProjectWelder(projectId);
//foreach (var p in project)
//{
// welderList = BLL.Project_WelderService.GetProjectWelder(p.WED_ID);
// //welderList.Add(welder.WED_Code + welder.WED_Name);
//}
//return BLL.JsonHelper.SerializeObject(welderList);
DataContractJsonSerializer json = new DataContractJsonSerializer(welderList.GetType());
string welderJson = "";
return BLL.JsonHelper.ListToJson(welderList);
//welders = welderList.ToArray();
//return welderJson;
}
[WebMethod(Description = "获取项目焊工")]
public string[] welderList(string projectId)
{
var project = BLL.Project_WelderService.GetProjectWelder(projectId);
string[] welders = new string[project.Count()];
List<string> welderList = new List<string>();
foreach (var p in project)
{
var welder = BLL.HJGL_PersonManageService.GetWelderByWenId(p.WED_ID);
welderList.Add(welder.WED_Code + welder.WED_Name);
}
welders = welderList.ToArray();
return welders;
}
[WebMethod(Description = "hello")]
public string pHelloWorld(string projectId)
{
return projectId + " Hello World";
}
[WebMethod(Description = "日报预提交")]
public string InsertPreWeldReportMain(string jotId)
{
try
{
var jot = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(jotId);
Model.HJGL_BO_PreWeldReportMain report = new Model.HJGL_BO_PreWeldReportMain();
report.PreWeldReportId = BLL.SQLHelper.GetNewID(typeof(Model.HJGL_BO_PreWeldReportMain));
report.ProjectId = jot.ProjectId;
report.JOT_ID = jotId;
report.JOT_WeldDate = DateTime.Now;
BLL.Funs.DB.HJGL_BO_PreWeldReportMain.InsertOnSubmit(report);
BLL.Funs.DB.SubmitChanges();
return "日报预提交成功!";
}
catch(Exception e)
{
return "日报预提交失败!";
}
}
/// <summary>
/// 焊接日报提交
/// </summary>
/// <param name="strJson">Json字符串</param>
/// <returns>提示字符串</returns>
[WebMethod(Description = "焊接日报提交")]
public string WeldReportSubmit(string strJson)
{
string message = string.Empty;
JObject obj = JObject.Parse(strJson);
string jotId = obj["jotId"].ToString();
string jot_FloorWelderID = obj["jot_FloorWelderID"].ToString();
string jot_CellWelderID = obj["jot_CellWelderID"].ToString();
string jot_WeldDate = obj["jot_WeldDate"].ToString();
string wlo_CodeID = obj["wlo_CodeID"].ToString();
string jot_DoneDin = obj["jot_DoneDin"].ToString();
string jot_JointAttribute = obj["jot_JointAttribute"].ToString();
string jot_Location = obj["jot_Location"].ToString();
string jot_Sch = obj["jot_Sch"].ToString();
string wme_ID = obj["wme_ID"].ToString();
string jot_WeldMat = obj["jot_WeldMat"].ToString();
string jot_WeldSilk = obj["jot_WeldSilk"].ToString();
string currUser = obj["currUser"].ToString();
string dReportId = BLL.HJGL_WeldReportService.GetDailyReportByWelder(jot_CellWelderID, Convert.ToDateTime(jot_WeldDate));
var newJointInfo = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(jotId);
var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(newJointInfo.ISO_ID);
var project = BLL.Base_ProjectService.GetProjectByProjectId(isoInfo.ProjectId);
if (!string.IsNullOrEmpty(jot_CellWelderID) && !string.IsNullOrEmpty(jot_FloorWelderID))
{
var welder = BLL.HJGL_PersonManageService.GetWelderByWenId(jot_CellWelderID);
newJointInfo.JOT_JointStatus = "100";
newJointInfo.JOT_CellWelder = jot_CellWelderID;
newJointInfo.JOT_FloorWelder = jot_FloorWelderID;
newJointInfo.WLO_Code = wlo_CodeID;
if (!string.IsNullOrEmpty(jot_DoneDin))
{
newJointInfo.JOT_DoneDin = Convert.ToDecimal(jot_DoneDin);
}
newJointInfo.JOT_JointAttribute = jot_JointAttribute;
newJointInfo.JOT_Location = jot_Location;
newJointInfo.JOT_Sch = jot_Sch;
newJointInfo.WME_ID = wme_ID;
if (!string.IsNullOrEmpty(jot_WeldMat))
{
newJointInfo.JOT_WeldMat = jot_WeldMat;
}
if (!string.IsNullOrEmpty(jot_WeldSilk))
{
newJointInfo.JOT_WeldSilk = jot_WeldSilk;
}
if (newJointInfo.JOT_Dia.HasValue)
{
var inch = BLL.HJGL_ControlService.GetSizeByDia(newJointInfo.JOT_Dia.Value);//焊口寸经根据外径改变
if (inch != null)
{
newJointInfo.JOT_Size = inch;
newJointInfo.JOT_DoneDin = inch;
}
}
//焊口规格:Φ外径*壁厚
if (newJointInfo.JOT_Dia.HasValue && !string.IsNullOrEmpty(newJointInfo.JOT_Sch))
{
newJointInfo.JOT_JointDesc = "Φ" + newJointInfo.JOT_Dia.Value.ToString() + "×" + jot_Sch;
}
if (!string.IsNullOrEmpty(dReportId))
{
newJointInfo.DReportID = dReportId;
}
else
{
// 先保存日报
Model.HJGL_BO_WeldReportMain newWeldReportMain = new Model.HJGL_BO_WeldReportMain();
newWeldReportMain.ProjectId = newJointInfo.ProjectId;
string perfix = project.ProjectCode + "-" + welder.WED_Code + "-";
string dailyReportNo = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId", "dbo.HJGL_BO_WeldReportMain", "JOT_DailyReportNo", newJointInfo.ProjectId, perfix);
newWeldReportMain.JOT_DailyReportNo = dailyReportNo;
if (!string.IsNullOrEmpty(isoInfo.BSU_ID))
{
newWeldReportMain.BSU_ID = isoInfo.BSU_ID;
}
newWeldReportMain.JOT_WeldDate = Convert.ToDateTime(jot_WeldDate);
newWeldReportMain.CHT_Tabler = currUser;
newWeldReportMain.CHT_TableDate = DateTime.Now.Date;
string newReportID=BLL.SQLHelper.GetNewID(typeof(Model.HJGL_BO_WeldReportMain));
newWeldReportMain.DReportID = newReportID;
BLL.HJGL_WeldReportService.AddWeldReport(newWeldReportMain);
newJointInfo.DReportID = newReportID;
}
// 再更新焊口
BLL.HJGL_PW_JointInfoService.UpdateJointInfoByDReport(newJointInfo);
//更新焊口号 修改固定焊口号后 +G
BLL.HJGL_PW_JointInfoService.UpdateJointNoAddG(newJointInfo.JOT_ID, newJointInfo.JOT_JointAttribute, "增加");
// 最后再插入批里
// 组批条件
if (newJointInfo != null && !string.IsNullOrEmpty(newJointInfo.InstallationId)
&& !string.IsNullOrEmpty(jot_CellWelderID) && !string.IsNullOrEmpty(jot_FloorWelderID)
&& !string.IsNullOrEmpty(isoInfo.ISC_ID) && !string.IsNullOrEmpty(newJointInfo.NDTR_ID)
&& !string.IsNullOrEmpty(isoInfo.ISO_Executive) && !string.IsNullOrEmpty(newJointInfo.JOTY_ID)
&& !string.IsNullOrEmpty(isoInfo.STE_ID))
{
var batchInfo = from x in Funs.DB.HJGL_BO_Batch
where x.ProjectId == isoInfo.ProjectId
&& x.InstallationId == newJointInfo.InstallationId && x.ISC_ID == isoInfo.ISC_ID
&& x.STE_ID == isoInfo.STE_ID
&& x.ExecStandardId == isoInfo.ISO_Executive && x.JOTY_ID == newJointInfo.JOTY_ID
&& x.NDTR_ID == newJointInfo.NDTR_ID && x.IsSpecial == newJointInfo.IsSpecial
&& (x.BatchIsClosed == null || x.BatchIsClosed == false)
select x;
string batchId = string.Empty;
if (batchInfo.Count() == 0)
{
Model.HJGL_BO_Batch batch = new Model.HJGL_BO_Batch();
batch.BatchId = SQLHelper.GetNewID(typeof(Model.HJGL_BO_Batch));
batchId = batch.BatchId;
//string perfix = ins.InstallationCode + "-" + isoC.ISC_IsoCode + "-" + ser.SER_Abbreviate + "-" + execS.ExecStandardName + "-";
batch.BatchCode = BLL.SQLHelper.RunProcFlowCode("SpGetFlowCode", "dbo.HJGL_BO_Batch", "BatchCode", isoInfo.ProjectId);
batch.ProjectId = isoInfo.ProjectId;
batch.InstallationId = newJointInfo.InstallationId;
batch.ISC_ID = isoInfo.ISC_ID;
batch.STE_ID = isoInfo.STE_ID;
//batch.SER_ID = isoInfo.SER_ID;
batch.ExecStandardId = isoInfo.ISO_Executive;
batch.JOTY_ID = newJointInfo.JOTY_ID;
batch.NDTR_ID = newJointInfo.NDTR_ID;
batch.IsSpecial = newJointInfo.IsSpecial;
batch.BatchStartDate = DateTime.Now.Date;
BLL.HJGL_BO_BatchService.AddBatch(batch);
}
else
{
batchId = batchInfo.First().BatchId;
}
var b = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByJotId(jotId);
if (b == null)
{
Model.HJGL_BO_BatchDetail batchDetail = new Model.HJGL_BO_BatchDetail();
batchDetail.BatchDetailId = SQLHelper.GetNewID(typeof(Model.HJGL_BO_BatchDetail));
batchDetail.BatchId = batchId;
batchDetail.ISO_ID = newJointInfo.ISO_ID;
batchDetail.JOT_ID = jotId;
BLL.Funs.DB.HJGL_BO_BatchDetail.InsertOnSubmit(batchDetail);
BLL.Funs.DB.SubmitChanges();
}
message = "焊口【" + newJointInfo.JOT_JointNo + "】焊接日报提交成功!";
}
else
{
message = "焊口【" + newJointInfo.JOT_JointNo + "】组批条件不能为空!";
}
}
else
{
message = "请选择焊工!";
}
return message;
}
[WebMethod(Description = "返修记录提交")]
public string RepairRecordSubmit(string strJson)
{
string message = string.Empty;
JObject obj = JObject.Parse(strJson);
JArray arr = JArray.Parse(obj["strJson"].ToString());
try
{
foreach (var item in arr)
{
string repairItemRecordId = item["repairItemRecordId"].ToString();
string strIsHotProess = item["isHotHandle"].ToString();
string welderID = item["optWelder"].ToString();
string weldDate = item["weldDate"].ToString();
string currUser = item["currUser"].ToString();
var man = BLL.Sys_UserService.GetUsersByUserId(currUser);
if (!string.IsNullOrEmpty(repairItemRecordId) && !string.IsNullOrEmpty(welderID) && !string.IsNullOrEmpty(weldDate))
{
var hotProessTrustItems = from x in Funs.DB.HJGL_CH_HotProessTrustItem select x;
Model.HJGL_CH_RepairItemRecord record = BLL.HJGL_CH_RepairItemRecordService.GetRepairItemRecordById(repairItemRecordId);
var jot = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(record.JOT_ID);
record.IsWeld = true;
bool isHotProess = Convert.ToBoolean(strIsHotProess);
if (isHotProess) //勾选了热处理委托
{
var oldHotProessTrustItem = (from x in hotProessTrustItems
join y in Funs.DB.HJGL_CH_RepairItemRecord
on x.TrustItemID equals y.RepairItemRecordId
where x.JOT_ID == record.JOT_ID && y.RepairMark == record.RepairMark
orderby x.TrustDate descending
select x).FirstOrDefault();
if (oldHotProessTrustItem == null) //该口本次返修尚未进行热处理委托
{
Model.HJGL_PW_JointInfo joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(record.JOT_ID);
Model.HJGL_PW_IsoInfo iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(record.ISO_ID);
Model.Base_Project project = BLL.Base_ProjectService.GetProjectByProjectId(record.ProjectId);
if (!string.IsNullOrEmpty(joint.ProessTypes))
{
string[] strs = joint.ProessTypes.Split('|');
Model.HJGL_CH_HotProessTrust trust = new Model.HJGL_CH_HotProessTrust();
trust.HotProessTrustId = SQLHelper.GetNewID(typeof(Model.Base_Project));
trust.ProjectId = record.ProjectId;
trust.HotProessTrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCode2ByProjectId", "dbo.HJGL_CH_HotProessTrust", "HotProessTrustCode", record.ProjectId, BLL.Base_ProjectService.GetProjectCode(record.ProjectId) + "-" + string.Format("{0:MMdd}", DateTime.Now) + "-R-");
trust.ProjectName = project.ProjectName;
trust.ConstructionNo = project.ProjectCode;
trust.TrustUnitId = iso.BSU_ID;
trust.TrstManId = currUser;
trust.TrustType = "2"; //返修口
BLL.HJGL_CH_HotProessTrustService.AddCH_HotProessTrust(trust);
foreach (var str in strs)
{
Model.HJGL_CH_HotProessTrustItem newTrustItem = new Model.HJGL_CH_HotProessTrustItem();
newTrustItem.HotProessTrustId = trust.HotProessTrustId;
newTrustItem.JOT_ID = record.JOT_ID;
newTrustItem.ProessTypes = str;
newTrustItem.TrustDate = DateTime.Now;
newTrustItem.TrustItemID = record.RepairItemRecordId;
BLL.HJGL_CH_HotProessTrustService.AddCH_HotProessTrustItem(newTrustItem);
if (newTrustItem.ProessTypes.Contains("4") || newTrustItem.ProessTypes.Contains("5")) //需要进入热处理报告的记录
{
Model.HJGL_HotProessItem oldHotProessItem = (from x in Funs.DB.HJGL_HotProessItem where x.JOT_ID == newTrustItem.JOT_ID && x.ProessTypes == newTrustItem.ProessTypes && x.HotProessTrustId == trust.HotProessTrustId select x).FirstOrDefault();
if (oldHotProessItem == null)
{
Model.HJGL_HotProessItem hotProessItem = new Model.HJGL_HotProessItem();
hotProessItem.HotProessItemId = SQLHelper.GetNewID(typeof(Model.HJGL_HotProessItem));
hotProessItem.JOT_ID = newTrustItem.JOT_ID;
hotProessItem.HotProessTrustId = trust.HotProessTrustId;
hotProessItem.ProessTypes = newTrustItem.ProessTypes;
hotProessItem.SortIndex = BLL.HJGL_HotProessManageEditService.GetSortIndex(trust.HotProessTrustId, newTrustItem.JOT_ID, newTrustItem.ProessTypes);
BLL.HJGL_HotProessManageEditService.AddHotProessItem(hotProessItem, "", null);
}
}
//进入热处理结果反馈
Model.HJGL_CH_HotProessResult oldHotProessResult = (from x in Funs.DB.HJGL_CH_HotProessResult where x.JOT_ID == newTrustItem.JOT_ID && x.ProessTypes == newTrustItem.ProessTypes && x.HotProessTrustId == trust.HotProessTrustId select x).FirstOrDefault();
if (oldHotProessResult == null)
{
Model.HJGL_CH_HotProessResult hotProessResult = new Model.HJGL_CH_HotProessResult();
hotProessResult.JOT_ID = newTrustItem.JOT_ID;
hotProessResult.HotProessTrustId = trust.HotProessTrustId;
hotProessResult.ProessTypes = newTrustItem.ProessTypes;
BLL.HJGL_CH_HotProessResultService.AddHotProessResult(hotProessResult);
}
}
}
}
}
record.JOT_CellWelder = welderID;
record.JOT_FloorWelder = welderID;
record.WeldDate = Convert.ToDateTime(weldDate);
if (man != null)
{
record.ConstructionPerson = man.UserName;
}
record.ConfirmDate = DateTime.Now;
BLL.HJGL_CH_RepairItemRecordService.UpdateCH_RepairItemRecord(record);
}
else
{
message = "焊工或焊接日期不能为空!";
}
}
message = "返修记录提交成功!";
}
catch (Exception e)
{
message = e.Message;
}
return message;
}
[WebMethod(Description = "检测批委托提交")]
public string GeneratingOrderSubmit(string strJson)
{
string message = string.Empty;
try
{
JObject obj = JObject.Parse(strJson);
JArray arr = JArray.Parse(obj["strJson"].ToString());
string firstBatchDetailId = arr[0]["batchDetailId"].ToString();
var firstBatchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(firstBatchDetailId);
string batchId = firstBatchDetail.BatchId;
var batch = BLL.HJGL_BO_BatchService.GetBatchById(batchId);
var trust = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == batchId select x;
if (trust.Count() == 0)
{
int flag = 1;
foreach (var item in arr)
{
string batchDetailId = item["batchDetailId"].ToString();
string ndtItem = item["ndtItem"].ToString();
string currUser = item["currUser"].ToString();
var man = BLL.Sys_UserService.GetUsersByUserId(currUser);
var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId);
if (batchDetail != null)
{
if (!string.IsNullOrEmpty(ndtItem))
{
batchDetail.NDT = ndtItem;
batchDetail.PointDate = DateTime.Now;
batchDetail.PointType = "1";
batchDetail.Checker = man.UserName;
}
else
{
batchDetail.NDT = null;
batchDetail.PointDate = null;
batchDetail.PointType = null;
batchDetail.Checker = null;
}
batchDetail.BatchDetailId = batchDetailId;
BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail);
}
string[] ndt = ndtItem.Split(','); // 可能有多种探伤类型
foreach (string n in ndt)
{
var trustNdt = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == batchId && x.CH_NDTMethod == n && x.Flag == flag select x;
if (trustNdt.Count() == 0)
{
var joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(batchDetail.JOT_ID);
var iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(joint.ISO_ID);
var ndtInfo = BLL.HJGL_TestingService.GetTestingByTestingId(n);
//选择管道等级、执行标准时,自动添加对接焊缝检测比例、合格等级、支管连接接头检测比例、合格等级、角焊缝检测比例、合格等级
var weldControl = BLL.HJGL_WeldControlService.GEtWeldControlByISCIDAndExecStandardId(iso.ISC_ID, iso.ISO_Executive);
Model.HJGL_CH_Trust t = new Model.HJGL_CH_Trust();
t.BatchId = batchId;
t.CH_TrustID = SQLHelper.GetNewID(typeof(Model.HJGL_CH_Trust));
t.CH_TrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetTrustCodeByProjectId", "dbo.HJGL_CH_Trust", "CH_TrustCode", batch.ProjectId, ndtInfo.NDT_Code + "-");
t.CH_NDTMethod = n;
t.Flag = flag;
t.CH_TrustType = "1";
t.CH_TrustDate = DateTime.Now;
t.ProjectId = batch.ProjectId;
t.InstallationId = batch.InstallationId;
t.CH_WeldMethod = joint.WME_ID;
t.CH_SlopeType = joint.JST_ID;
t.CH_NDTRate = batch.NDTR_ID;
t.CH_NDTCriteria = "NB/T47013-2015";
t.CH_TrustMan = currUser;
if (weldControl != null)
{
if (ndtInfo.NDT_Code == "RT")
{
t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_Level).Value;
}
else
{
t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_C_Level).Value;
}
}
BLL.HJGL_TrustManageEditService.AddCH_Trust(t);
// 增加明细
Model.HJGL_CH_TrustItem trustItem = new Model.HJGL_CH_TrustItem();
trustItem.CH_TrustID = t.CH_TrustID;
trustItem.JOT_ID = batchDetail.JOT_ID;
trustItem.BatchDetailId = batchDetail.BatchDetailId;
trustItem.States = "1"; // 生成委托单时状态为等检测
BLL.HJGL_TrustManageEditService.AddCH_TrustItem(trustItem);
}
else
{
Model.HJGL_CH_TrustItem trustItem = new Model.HJGL_CH_TrustItem();
trustItem.CH_TrustID = trustNdt.First().CH_TrustID;
trustItem.JOT_ID = batchDetail.JOT_ID;
trustItem.BatchDetailId = batchDetail.BatchDetailId;
trustItem.States = "1"; // 生成委托单时状态为等检测
BLL.HJGL_TrustManageEditService.AddCH_TrustItem(trustItem);
}
}
}
message = "成功生成委托单!";
}
else
{
message = "已生成委托单!";
}
}
catch (Exception e)
{
message = e.Message;
}
return message;
}
[WebMethod(Description = "检测批再委托")]
public string AgainGeneratingSubmit(string strJson)
{
string message = string.Empty;
try
{
JObject obj = JObject.Parse(strJson);
JArray arr = JArray.Parse(obj["strJson"].ToString());
string firstBatchDetailId = arr[0]["batchDetailId"].ToString();
var firstBatchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(firstBatchDetailId);
string batchId = firstBatchDetail.BatchId;
var batch = BLL.HJGL_BO_BatchService.GetBatchById(batchId);
var trust = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == batchId select x;
if (trust.Count() > 0)
{
int? maxFlag = trust.Select(x => x.Flag).Max();
int flag = (maxFlag != null ? maxFlag.Value : 1) + 1;
foreach (var item in arr)
{
string batchDetailId = item["batchDetailId"].ToString();
string ndtItem = item["ndtItem"].ToString();
string currUser = item["currUser"].ToString();
var man = BLL.Sys_UserService.GetUsersByUserId(currUser);
var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId);
string[] ndt = ndtItem.Split(','); // 可能有多种探伤类型
foreach (string n in ndt)
{
var trustNdt = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == batchId && x.CH_NDTMethod == n && x.Flag == flag select x;
if (trustNdt.Count() == 0)
{
var joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(batchDetail.JOT_ID);
var iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(joint.ISO_ID);
var ndtInfo = BLL.HJGL_TestingService.GetTestingByTestingId(n);
//选择管道等级、执行标准时,自动添加对接焊缝检测比例、合格等级、支管连接接头检测比例、合格等级、角焊缝检测比例、合格等级
var weldControl = BLL.HJGL_WeldControlService.GEtWeldControlByISCIDAndExecStandardId(iso.ISC_ID, iso.ISO_Executive);
Model.HJGL_CH_Trust t = new Model.HJGL_CH_Trust();
t.BatchId = batchId;
t.CH_TrustID = SQLHelper.GetNewID(typeof(Model.HJGL_CH_Trust));
t.CH_TrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetTrustCodeByProjectId", "dbo.HJGL_CH_Trust", "CH_TrustCode", batch.ProjectId, ndtInfo.NDT_Code + "-");
t.CH_NDTMethod = n;
t.Flag = flag;
t.CH_TrustType = "1";
t.CH_TrustDate = DateTime.Now;
t.ProjectId = batch.ProjectId;
t.InstallationId = batch.InstallationId;
t.CH_WeldMethod = joint.WME_ID;
t.CH_SlopeType = joint.JST_ID;
t.CH_NDTRate = batch.NDTR_ID;
t.CH_NDTCriteria = "NB/T47013-2015";
t.CH_TrustMan = currUser;
if (weldControl != null)
{
if (ndtInfo.NDT_Code == "RT")
{
t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_Level).Value;
}
else
{
t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_C_Level).Value;
}
}
BLL.HJGL_TrustManageEditService.AddCH_Trust(t);
// 增加明细
Model.HJGL_CH_TrustItem trustItem = new Model.HJGL_CH_TrustItem();
trustItem.CH_TrustID = t.CH_TrustID;
trustItem.JOT_ID = batchDetail.JOT_ID;
trustItem.BatchDetailId = batchDetail.BatchDetailId;
trustItem.States = "1"; // 生成委托单时状态为等检测
BLL.HJGL_TrustManageEditService.AddCH_TrustItem(trustItem);
}
else
{
Model.HJGL_CH_TrustItem trustItem = new Model.HJGL_CH_TrustItem();
trustItem.CH_TrustID = trustNdt.First().CH_TrustID;
trustItem.JOT_ID = batchDetail.JOT_ID;
trustItem.BatchDetailId = batchDetail.BatchDetailId;
trustItem.States = "1"; // 生成委托单时状态为等检测
BLL.HJGL_TrustManageEditService.AddCH_TrustItem(trustItem);
}
}
if (!string.IsNullOrEmpty(ndtItem))
{
batchDetail.NDT = ndtItem;
batchDetail.PointDate = DateTime.Now;
batchDetail.PointType = "1";
batchDetail.Checker = currUser;
BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail);
}
}
message = "成功再委托!";
}
else
{
message = "还未生成委托单,请点击检验批委托菜单!";
}
}
catch (Exception e)
{
message = e.Message;
}
return message;
}
[WebMethod(Description = "取消检测批委托")]
public string CancelGeneratingSubmit(string strJson)
{
string message = string.Empty;
try
{
JObject obj = JObject.Parse(strJson);
JArray arr = JArray.Parse(obj["strJson"].ToString());
string jots = string.Empty;
foreach (var item in arr)
{
string batchDetailId = item["batchDetailId"].ToString();
string ndtItem = item["ndtItem"].ToString(); // 取消的委托类型(可能有两个及以上)
string[] ndts = ndtItem.Split(',');
string ndtId = string.Empty;
var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId);
var jot = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(batchDetail.JOT_ID);
if (ndts.Count() > 0)
{
jots = jots + jot.JOT_JointNo + ",";
List<string> ndtList = batchDetail.NDT.Split(',').ToList();
foreach (string ndt in ndts)
{
var t = from x in Funs.DB.HJGL_CH_TrustItem
join y in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals y.CH_TrustID
where x.JOT_ID == batchDetail.JOT_ID && y.CH_NDTMethod == ndt
select x;
if (t.Count() > 0 && t.FirstOrDefault().States == "1") // 待检测状态
{
BLL.HJGL_CH_TrustItemService.DeleteTrustItemById(t.FirstOrDefault().CH_TrustItemID);
ndtList.Remove(ndt);
}
}
Model.HJGL_BO_BatchDetail newBatchDetail = Funs.DB.HJGL_BO_BatchDetail.FirstOrDefault(x => x.BatchDetailId == batchDetailId);
if (newBatchDetail != null)
{
if (ndtList.Count() > 0)
{
foreach (var q in ndtList)
{
ndtId = ndtId + q + ",";
}
newBatchDetail.NDT = ndtId.Substring(0, ndtId.Length - 1);
}
else
{
newBatchDetail.NDT = null;
newBatchDetail.PointDate = null;
newBatchDetail.PointType = null;
batchDetail.Checker = null;
}
Funs.DB.SubmitChanges();
}
}
}
if (jots.Length > 0)
{
jots = jots.Substring(0, jots.Length - 1);
}
message = "已取消焊口:" + jots + "的委托!";
}
catch (Exception e)
{
message = e.Message;
}
return message;
}
[WebMethod(Description = "返修记录委托提交")]
public string RepairRecordTrustSubmit(string strJson)
{
string message = string.Empty;
try
{
JObject obj = JObject.Parse(strJson);
JArray arr = JArray.Parse(obj["strJson"].ToString());
var totalRepairItemRecords = from x in Funs.DB.HJGL_View_CH_RepairItemRecord select x;
var totalRepairItems = from x in Funs.DB.HJGL_CH_RepairItem select x;
foreach (var item in arr)
{
string repairItemRecordId = item["repairItemRecordId"].ToString();
string strIsRepairTrust = item["isRepairTrust"].ToString();
string currUser = item["currUser"].ToString();
bool isRepairTrust = Convert.ToBoolean(strIsRepairTrust);
Model.HJGL_View_CH_RepairItemRecord record = totalRepairItemRecords.FirstOrDefault(x => x.RepairItemRecordId == repairItemRecordId);
if (isRepairTrust) //勾选委托
{
var oldRepairItem = totalRepairItems.FirstOrDefault(x => x.RepairItemRecordId == repairItemRecordId);
if (oldRepairItem == null) //尚未生成返修明细记录
{
var repair = from x in Funs.DB.HJGL_CH_Repair where x.BatchId == record.BatchId && x.ISO_ID == record.ISO_ID && x.NDT_ID == record.NDT_ID && x.TrustItemID == record.TrustItemID select x;
if (repair.Count() == 0)
{
Model.HJGL_PW_IsoInfo iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(record.ISO_ID);
Model.HJGL_PW_JointInfo joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(record.JOT_ID);
//选择管道等级、执行标准时,自动添加对接焊缝检测比例、合格等级、支管连接接头检测比例、合格等级、角焊缝检测比例、合格等级
var weldControl = BLL.HJGL_WeldControlService.GEtWeldControlByISCIDAndExecStandardId(iso.ISC_ID, iso.ISO_Executive);
var ndtInfo = BLL.HJGL_TestingService.GetTestingByTestingId(record.NDT_ID);
Model.HJGL_CH_Repair newRepair = new Model.HJGL_CH_Repair();
newRepair.CH_RepairID = SQLHelper.GetNewID(typeof(Model.HJGL_CH_Repair));
newRepair.ProjectId = record.ProjectId;
newRepair.TrustItemID = record.TrustItemID;
newRepair.ISO_ID = record.ISO_ID;
newRepair.JOT_ID = record.JOT_ID;
newRepair.NDT_ID = record.NDT_ID;
newRepair.CH_TrustUnit = iso.BSU_ID;
newRepair.InstallationId = joint.InstallationId;
if (string.IsNullOrEmpty(record.ExtendedNum))
{
newRepair.CH_TrustType = "1"; //委托
}
else
{
newRepair.CH_TrustType = "2"; //扩透
}
newRepair.CH_ItemName = iso.ISO_IsoNo;
newRepair.CH_Tabler = currUser;
newRepair.RepairTrustDate = DateTime.Now;
newRepair.BatchId = record.BatchId;
newRepair.CH_RepairNo = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId", "dbo.HJGL_CH_Repair", "CH_RepairNo", record.ProjectId, ndtInfo.NDT_Code + "-R-");
newRepair.CH_WeldMethod = joint.WME_ID;
newRepair.CH_SlopeType = joint.JST_ID;
newRepair.CH_NDTCriteria = "NB/T47013-2015";
if (weldControl != null)
{
if (ndtInfo.NDT_Code == "RT")
{
newRepair.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_Level).Value;
}
else
{
newRepair.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_C_Level).Value;
}
}
BLL.HJGL_RepairService.AddCH_Repair(newRepair);
// 增加明细
Model.HJGL_CH_RepairItem newRepairItem = new Model.HJGL_CH_RepairItem();
newRepairItem.CH_RepairItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_RepairItem));
newRepairItem.CH_RepairID = newRepair.CH_RepairID;
newRepairItem.JOT_ID = record.JOT_ID;
newRepairItem.DefectNature = record.DefectNature;
newRepairItem.FilmNum = record.FilmNum;
newRepairItem.States = "1"; // 生成返修委托单时状态为待检测
Model.HJGL_BO_BatchDetail batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByJotId(record.JOT_ID);
if (batchDetail != null)
{
if (batchDetail.PointType != null && batchDetail.PointType.Contains("2")) //扩拍
{
newRepairItem.ExtendedNum = "K";
}
}
newRepairItem.CheckPerson = currUser;
newRepairItem.RepairItemRecordId = record.RepairItemRecordId;
BLL.HJGL_RepairItemService.AddCH_RepairItem(newRepairItem);
}
else
{
Model.HJGL_CH_RepairItem newRepairItem = new Model.HJGL_CH_RepairItem();
newRepairItem.CH_RepairItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_RepairItem));
newRepairItem.CH_RepairID = repair.First().CH_RepairID;
newRepairItem.JOT_ID = record.JOT_ID;
newRepairItem.DefectNature = record.DefectNature;
newRepairItem.FilmNum = record.FilmNum;
newRepairItem.States = "3"; // 生成返修委托单时状态为待拍片
Model.HJGL_BO_BatchDetail batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByJotId(record.JOT_ID);
if (batchDetail != null)
{
if (batchDetail.PointType != null && batchDetail.PointType.Contains("2")) //扩拍
{
newRepairItem.ExtendedNum = "K";
}
}
newRepairItem.CheckPerson = currUser;
//newRepairItem.Remark = values.Value<string>("Remark");
newRepairItem.RepairItemRecordId = record.RepairItemRecordId;
BLL.HJGL_RepairItemService.AddCH_RepairItem(newRepairItem);
}
}
}
}
message = "成功生成返修委托单!";
}
catch (Exception e)
{
message = e.Message;
}
return message;
}
}
}