using BLL; using System; using System.Web.Http; namespace WebAPI.Controllers { /// /// 点口,委托,无损检测 /// public class NDETrustController : ApiController { #region 点口 /// /// 根据单位工程、项目Id获取未点口的批 /// /// 单位工程Id /// 项目Id /// public Model.ResponeData getNotEndPointBatch(string unitWorkId, string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getNotEndPointBatch(unitWorkId, projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 选择单位工程、探伤类型、探伤比例、点口批号获取需要进行点口的批,自动点口调用 /// /// /// /// /// /// public Model.ResponeData getAutoPointBatchCode(string unitWorkId, string detectionTypeId, string detectionRateId, string pointBatchCode) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getAutoPointBatchCode(unitWorkId, detectionTypeId, pointBatchCode, pointBatchCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据单位工程、点口批号、批开始时间获取需要调整的批(已点口但还未进行委托的批列表) /// /// /// /// /// /// public Model.ResponeData getPointBatchCode(string unitWorkId, string startDate, string detectionTypeId, string detectionRateId, string pointBatchCode) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getPointBatchCode(unitWorkId, startDate, detectionTypeId, pointBatchCode, pointBatchCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据点口批ID获取批明细(自动点口调用呈现) /// /// /// public Model.ResponeData getPointBatchDetail(string pointBatchId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getPointBatchDetail(pointBatchId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据点口批ID获取已点口还未审批的焊口 /// /// /// public Model.ResponeData getPointWeldJoint(string pointBatchId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getPointWeldJoint(pointBatchId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据点口批ID和焊口ID获取待调整焊口 /// /// /// /// public Model.ResponeData getPointWeldJoint(string pointBatchId, string weldJointId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getPointWeldJoint(pointBatchId, weldJointId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据单位工程获取所有已点的焊口列表 /// /// /// public Model.ResponeData GetPointWeldJointList(string unitWorkId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetPointWeldJointList(unitWorkId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 对所选批次进行自动点口 /// /// /// public Model.ResponeData getAutoPointSave(string pointBatchId) { var responeData = new Model.ResponeData(); try { APINDETrustService.AutoPointSave(pointBatchId); responeData.code = 1; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据焊口手动点口 /// /// /// public Model.ResponeData getManualPointSave(string weldJointId) { var responeData = new Model.ResponeData(); try { string res = APINDETrustService.ManualPointSave(weldJointId); if (!string.IsNullOrEmpty(res)) { responeData.code = 0; responeData.message = res; } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 对所选批次进行强制关闭批 /// /// /// public Model.ResponeData getCloseBatchSave(string pointBatchId) { var responeData = new Model.ResponeData(); try { var batch = BLL.PointBatchService.GetPointBatchById(pointBatchId); if (batch != null) { if (!batch.EndDate.HasValue) { PointBatchService.UpdateBatchIsClosed2(pointBatchId, DateTime.Now); //生成委托单 Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust(); var project = BLL.ProjectService.GetProjectByProjectId(batch.ProjectId); var unit = BLL.UnitService.GetUnitByUnitId(batch.UnitId); var area = BLL.UnitWorkService.getUnitWorkByUnitWorkId(batch.UnitWorkId); var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(batch.DetectionTypeId); var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(batch.DetectionRateId); string perfix = string.Empty; newBatchTrust.TrustBatchCode = batch.PointBatchCode.Replace("-DK-", "-WT-"); string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust)); newBatchTrust.TrustBatchId = trustBatchId; newBatchTrust.TrustDate = DateTime.Now; newBatchTrust.ProjectId = batch.ProjectId; newBatchTrust.PointBatchId = batch.PointBatchId; newBatchTrust.UnitId = batch.UnitId; newBatchTrust.UnitWorkId = batch.UnitWorkId; newBatchTrust.DetectionTypeId = batch.DetectionTypeId; newBatchTrust.DetectionRateId = batch.DetectionRateId; newBatchTrust.PointBatchId = pointBatchId; BLL.Batch_BatchTrustService.AddBatchTrust(newBatchTrust); // 新增委托单 responeData.code = 1; } } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 点口调整 /// /// /// [HttpPost] public Model.ResponeData getRePointSave([FromBody] Model.PointBatch oldJointId) { var responeData = new Model.ResponeData(); try { //APINDETrustService.RePointSave(oldJointId, newJointId); foreach (Model.PointBatchItem item in oldJointId.oldJointId) { if (item.selected == true) { BLL.PointBatchDetailService.UpdatePointBatchDetail(Convert.ToString(item.PointBatchItemId), "1", DateTime.Now); } else { BLL.PointBatchDetailService.UpdatePointBatchDetail(Convert.ToString(item.PointBatchItemId), null, null); } } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据单位工程获取所有已点的焊口生成委托单 /// /// /// public Model.ResponeData getGenerateTrust(string unitWorkId) { var responeData = new Model.ResponeData(); try { APINDETrustService.GenerateTrust(unitWorkId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 无损委托 /// /// 选择单位工程、探伤类型、探伤比例、委托单号等获取委托单 /// /// /// /// /// /// /// public Model.ResponeData getBatchTrustCode(string unitWorkId, string detectionTypeId, string detectionRateId, string startDate, string trustBatchCode) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getBatchTrustCode(unitWorkId, detectionTypeId, detectionRateId, startDate, trustBatchCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 选择委托单ID获取委托单明细信息 /// /// /// public Model.ResponeData getBatchTrustDetail(string trustBatchId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetBatchTrustDetail(trustBatchId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #region 生成委托单 /// /// 生成委托单 /// /// 委托单 /// [HttpPost] public Model.ResponeData SaveTrust([FromBody] Model.BatchItem newItem) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.SaveTrust(newItem.PointBatchId, newItem.NDEUnit); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion /// /// 对所选委托单进行审核 /// /// /// public Model.ResponeData getBatchTrustAudit(string trustBatchId) { var responeData = new Model.ResponeData(); try { APINDETrustService.BatchTrustAudit(trustBatchId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 无损检测单 /// /// 选择单位工程、探伤类型、检测单号获取检测单 /// /// /// /// /// public Model.ResponeData getBatchNdeCode(string unitWorkId, string startDate, string detectionTypeId, string ndeCode) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.getBatchNdeCode(unitWorkId, startDate, detectionTypeId, ndeCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据检测单ID获取检测单明细 /// /// /// public Model.ResponeData getBatchNDEDetail(string ndeId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetBatchNDEDetail(ndeId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 返修/扩透 /// /// 获取返修单列表 /// /// /// /// /// public Model.ResponeData GetRepairRecord(string unitWorkId, bool isAudit, string repairRecordCode) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetRepairRecord(unitWorkId, isAudit, repairRecordCode); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取返修单信息 /// /// /// public Model.ResponeData GetRepairInfoByRepairRecordId(string repairRecordId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetRepairInfoByRepairRecordId(repairRecordId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 根据条件获取可选取扩透口的批明细 /// /// /// 同焊工 /// 同管线 /// 同一天 /// 返修前所焊 /// 同材质 /// 同规格 /// public Model.ResponeData GetRepairExpDetail(string repairRecordId, bool welder, bool batch, bool pipeLine, bool daily, bool repairBefore, bool mat, bool spec) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetRepairExpDetail(repairRecordId, welder, batch, pipeLine, daily, repairBefore, mat, spec); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 获取扩透口的随机数 /// /// /// public Model.ResponeData GetRandomExport(int num) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.RandomExport(num); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 保存返修/扩透口信息 /// /// 返修ID /// 扩透口ID(多个用“,”号隔开) /// 返修焊工 /// 返修日期 /// 是否切除 public Model.ResponeData GetRepairExpSaveInfo(string repairRecordId, string expandId, string repairWelder, string repairDate, bool isCut) { var responeData = new Model.ResponeData(); try { APINDETrustService.GetRepairExpSaveInfo(repairRecordId, expandId, repairWelder, repairDate, isCut); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 返修单审核 /// /// /// public Model.ResponeData GetRepairAudit(string repairRecordId) { var responeData = new Model.ResponeData(); try { APINDETrustService.RepairAudit(repairRecordId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 生成返修委托单 /// /// /// public Model.ResponeData GetGenerateRepairTrust(string repairRecordId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GenerateRepairTrust(repairRecordId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region NDE预警 /// /// 无损检测不合格焊口信息 /// /// /// public Model.ResponeData GetNdeCheckNoPassWarn(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetNdeCheckNoPassWarn(projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 未委托焊口预警 /// /// /// public Model.ResponeData GetNoTrustJointWarn(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetNoTrustJointWarn(projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } /// /// 未检测焊口预警 /// /// /// public Model.ResponeData GetNoCheckJointWarn(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = APINDETrustService.GetNoTrustJointWarn(projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion } }