195 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			195 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     /// <summary>
 | |
|     /// 无损委托明细
 | |
|     /// </summary>
 | |
|     public static class Batch_BatchTrustItemService
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 根据主键获取无损委托明细
 | |
|         /// </summary>
 | |
|         /// <param name="batchTrustItemId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.Batch_BatchTrustItem GetBatchTrustItemById(string trustBatchItemId)
 | |
|         {
 | |
|             Model.HJGLDB db = Funs.DB;
 | |
|             return db.Batch_BatchTrustItem.FirstOrDefault(e => e.TrustBatchItemId == trustBatchItemId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据无损委托Id获取相关明细信息
 | |
|         /// </summary>
 | |
|         /// <param name="hardTrustId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.Batch_BatchTrustItem> GetBatchTrustItemByTrustBatchId(string trustBatchId)
 | |
|         {
 | |
|             Model.HJGLDB db = Funs.DB;
 | |
|             return (from x in db.Batch_BatchTrustItem where x.TrustBatchId == trustBatchId select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 添加无损委托明细
 | |
|         /// </summary>
 | |
|         /// <param name="batchTrustItem"></param>
 | |
|         public static void AddBatchTrustItem(Model.Batch_BatchTrustItem batchTrustItem)
 | |
|         {
 | |
|             Model.HJGLDB db = Funs.DB;
 | |
|             Model.Batch_BatchTrustItem newTrustBatchItem = new Model.Batch_BatchTrustItem
 | |
|             {
 | |
|                 TrustBatchItemId = batchTrustItem.TrustBatchItemId,
 | |
|                 TrustBatchId = batchTrustItem.TrustBatchId,
 | |
|                 PointBatchItemId = batchTrustItem.PointBatchItemId,
 | |
|                 RepairRecordId = batchTrustItem.RepairRecordId,
 | |
|                 WeldJointId = batchTrustItem.WeldJointId,
 | |
|                 CreateDate = batchTrustItem.CreateDate,
 | |
|                 RepairNum = batchTrustItem.RepairNum,
 | |
|                 FilmNum = batchTrustItem.FilmNum,
 | |
|             };
 | |
|             db.Batch_BatchTrustItem.InsertOnSubmit(newTrustBatchItem);
 | |
|             db.SubmitChanges();
 | |
|             BLL.Batch_PointBatchItemService.UpdateTrustNum(batchTrustItem.TrustBatchItemId, 1);
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据无损委托Id获取相关明细视图信息
 | |
|         /// </summary>
 | |
|         /// <param name="projectId"></param>
 | |
|         /// <param name="hardTrustId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.View_Batch_BatchTrustItem> GetViewBatchTrustItem(string trustBatchId)
 | |
|         {
 | |
|             Model.HJGLDB db = Funs.DB;
 | |
|             return (from x in db.View_Batch_BatchTrustItem where x.TrustBatchId == trustBatchId && x.IsCancelTrust==string.Empty select x).ToList();
 | |
|         }
 | |
| 
 | |
|  
 | |
| 	/// <summary>
 | |
|         /// 根据Id删除明细信息
 | |
|         /// </summary>
 | |
|         /// <param name="checkItemId"></param>
 | |
|         public static void DeleteTrustItemByTrustBatchItemId(string trustBatchItemId)
 | |
|         {
 | |
|             Model.HJGLDB db = Funs.DB;
 | |
|             Model.Batch_BatchTrustItem trustItem = db.Batch_BatchTrustItem.FirstOrDefault(e => e.TrustBatchItemId == trustBatchItemId);
 | |
|             if (trustItem != null)
 | |
|             {
 | |
|                 BLL.Batch_PointBatchItemService.UpdateTrustNum(trustBatchItemId, -1);
 | |
|                 db.Batch_BatchTrustItem.DeleteOnSubmit(trustItem);
 | |
|                 db.SubmitChanges();
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         #region 更新是否取消委托
 | |
|         /// <summary>
 | |
|         /// 更新是否取消委托
 | |
|         /// </summary>
 | |
|         /// <param name="trustBatchItemId"></param>
 | |
|         /// <param name="isCancelTrust"></param>
 | |
|         public static void UpdatIsCancelTrust(string trustBatchItemId, bool? isCancelTrust)
 | |
|         {
 | |
|             Model.HJGLDB db = Funs.DB;
 | |
|             Model.Batch_BatchTrustItem update = db.Batch_BatchTrustItem.FirstOrDefault(e => e.TrustBatchItemId == trustBatchItemId);
 | |
|             if (update != null)
 | |
|             {
 | |
|                 var updatePoint = db.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == update.PointBatchItemId);
 | |
|                 if (updatePoint != null)
 | |
|                 {
 | |
|                     updatePoint.PointDate = null;
 | |
|                     updatePoint.PointState = null;
 | |
|                     updatePoint.CutDate = null;////更新批明细 切除日期
 | |
|                     updatePoint.IsBuildTrust = null;
 | |
|                     updatePoint.JLAudit = null;
 | |
|                     updatePoint.GLGSAudit = null;
 | |
|                     updatePoint.QTAudit = null;
 | |
|                 }
 | |
|                 var item = from x in db.Batch_BatchTrustItem where x.TrustBatchId == update.TrustBatchId select x;
 | |
|                 // 表示这个批里只有它一条明细,删除主表
 | |
|                 if (item.Count() == 1)
 | |
|                 {
 | |
|                     Model.Batch_BatchTrust delTrust = db.Batch_BatchTrust.FirstOrDefault(x => x.TrustBatchId == update.TrustBatchId);
 | |
|                     db.Batch_BatchTrustItem.DeleteOnSubmit(update);
 | |
|                     if (delTrust != null)
 | |
|                     {
 | |
|                         db.Batch_BatchTrust.DeleteOnSubmit(delTrust);
 | |
|                     }
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     db.Batch_BatchTrustItem.DeleteOnSubmit(update);
 | |
|                 }
 | |
|                 //update.IsCancelTrust = isCancelTrust;
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据探伤比例和管径获取大于等于500的焊口拍片数
 | |
|         /// </summary>
 | |
|         /// <param name="detectionRateValue"></param>
 | |
|         /// <param name="dia"></param>
 | |
|         /// <returns></returns>
 | |
|         public static int? GetFilmNumByRateAndDia(int? detectionRateValue, decimal? dia)
 | |
|         {
 | |
|             int? filmNum = null;
 | |
|             if (detectionRateValue == 5)
 | |
|             {
 | |
|                 if (dia >= 500 && dia < 1600)
 | |
|                 {
 | |
|                     filmNum = 1;
 | |
|                 }
 | |
|                 if (dia >= 1600 && dia < 1800)
 | |
|                 {
 | |
|                     filmNum = 2;
 | |
|                 }
 | |
|             }
 | |
|             else if (detectionRateValue == 10)
 | |
|             {
 | |
|                 if (dia >= 500 && dia < 800)
 | |
|                 {
 | |
|                     filmNum = 1;
 | |
|                 }
 | |
|                 if (dia >= 800 && dia < 1600)
 | |
|                 {
 | |
|                     filmNum = 2;
 | |
|                 }
 | |
|                 if (dia >= 1600 && dia < 1800)
 | |
|                 {
 | |
|                     filmNum = 3;
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             else if (detectionRateValue == 20)
 | |
|             {
 | |
|                 if (dia >= 500 && dia < 800)
 | |
|                 {
 | |
|                     filmNum = 2;
 | |
|                 }
 | |
|                 if (dia >= 800 && dia < 1200)
 | |
|                 {
 | |
|                     filmNum = 3;
 | |
|                 }
 | |
|                 if (dia >= 1200 && dia < 1600)
 | |
|                 {
 | |
|                     filmNum = 4;
 | |
|                 }
 | |
|                 if (dia >= 1600 && dia < 1800)
 | |
|                 {
 | |
|                     filmNum = 5;
 | |
|                 }
 | |
|             }
 | |
|             return filmNum;
 | |
|         }
 | |
| 
 | |
|     }
 | |
| }
 |