From fba48d2d676cd9b6d493163aef9d87f6e5090aee Mon Sep 17 00:00:00 2001
From: 如洲 陈 <1278080563@qq.com>
Date: 星期五, 12 九月 2025 19:02:00 +0800
Subject: [PATCH] 出库检和退货检验
---
MES.Service/service/QC/MesOqcItemsDetect02Manager.cs | 632 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 632 insertions(+), 0 deletions(-)
diff --git a/MES.Service/service/QC/MesOqcItemsDetect02Manager.cs b/MES.Service/service/QC/MesOqcItemsDetect02Manager.cs
new file mode 100644
index 0000000..33a7b2f
--- /dev/null
+++ b/MES.Service/service/QC/MesOqcItemsDetect02Manager.cs
@@ -0,0 +1,632 @@
+锘縰sing System.Data;
+using Masuit.Tools;
+using MES.Service.DB;
+using MES.Service.Dto.service;
+using MES.Service.Modes;
+using MES.Service.util;
+using SqlSugar;
+using DbType = System.Data.DbType;
+
+namespace MES.Service.service.QC;
+
+public class MesOqcItemsDetect02Manager : Repository<MesOqcItemsDetect02>
+{
+ public (List<MesOqcItemsDetect02> item, int TotalCount) GetPage(
+ XJPageResult queryObj)
+ {
+ if (queryObj == null)
+ throw new ArgumentNullException(nameof(queryObj));
+
+ //if (string.IsNullOrEmpty(queryObj.CreateBy))
+ // return (new List<MesOqcItemsDetect02>(), 0);
+
+ //if (queryObj.CreateBy.IsNullOrEmpty()) return ([], 0);
+
+ var db = Db;
+
+ //瀹夊叏鐨勭被鍨嬭浆鎹�
+ if (!decimal.TryParse(queryObj.Id.ToString(), out decimal id))
+ {
+ id = 0;
+ // 澶勭悊杞崲澶辫触鐨勬儏鍐�
+ }
+
+
+ var totalCount = 0;
+
+ var pageList = Db.Queryable<MesOqcItemsDetect02, MesItems
+ , SysUser, SysUser, MesDepots>((a, b, c, d, e) =>
+ new JoinQueryInfos(JoinType.Left, a.ItemNo == b.ItemNo,
+ JoinType.Left, a.CreateBy == c.Fcode,
+ JoinType.Left, a.FcheckBy == d.Fcode,
+ JoinType.Left, a.DepotId == e.DepotId
+ ))
+ .WhereIF(
+ StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
+ "鏈畬鎴�".Equals(queryObj.Result),
+ (a, b, c, d, e) => a.FcheckResu == null || a.Fsubmit == 0)
+ .WhereIF(
+ StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
+ !"鏈畬鎴�".Equals(queryObj.Result),
+ (a, b, c, d, e) => a.FcheckResu != null && a.Fsubmit == 1)
+ .WhereIF(id > 0, (a, b, c, d, e) => a.Id == id)
+ .OrderByDescending((a, b, c, d, e) => a.Id)
+ .Select((a, b, c, d, e) => new MesOqcItemsDetect02()
+ {
+ ItemNo = b.ItemNo,
+ ItemName = b.ItemName,
+ ItemModel = b.ItemModel,
+ CreateUser = c.Fname,
+ FcheckUser = d.Fname,
+ DepotName = e.DepotName
+ }, true)
+ .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
+ return (pageList, totalCount);
+ }
+
+ public List<MesOqcItemsDetectDetail5> GetDetail5(OQCDto dto)
+ {
+ return Db.Queryable<MesOqcItemsDetectDetail5>()
+ .Where(s => s.ReleaseNo == dto.ReleaseNo)
+ .ToList();
+ }
+
+ public List<MesOqcItemsDetectDetail12> GetDetail12(OQCDto dto)
+ {
+ return Db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.ReleaseNo == dto.ReleaseNo
+ && s.MainId == dto.MainId)
+ .ToList();
+ }
+
+ public MesInvItemStocks GetItemBarCode(XJPageResult queryObj)
+ {
+ if (queryObj.ItemCode.IsNullOrEmpty())
+ {
+ throw new NotImplementedException("璇锋壂鎻忔潯鐮�");
+ }
+
+ var mesInvItemStocks = Db.Queryable<MesInvItemStocks>()
+ .Where(a => a.ItemBarcode == queryObj.ItemCode)
+ .First();
+
+ if (mesInvItemStocks == null)
+ {
+ throw new NotImplementedException("鏉$爜涓嶅瓨鍦ㄤ簬搴撳瓨涓�");
+ }
+
+ // 妫�鏌ユ潯鐮佹槸鍚﹀凡缁忓瓨鍦ㄤ簬MesOqcBarcode琛ㄤ腑锛堝凡妫�楠岃繃锛�
+ var existingBarcode = Db.Queryable<MesOqcBarcode>()
+ .Where(a => a.ItemBarcode == queryObj.ItemCode)
+ .First();
+
+ if (existingBarcode != null)
+ {
+ throw new NotImplementedException("璇ユ潯鐮佸凡缁忔楠岃繃锛屼笉鑳介噸澶嶆楠�");
+ }
+
+ /*var mesDepots = Db.Queryable<MesDepots>()
+ .Where(s => s.DepotId == 121163).First();
+
+ if (!mesDepots.Equals(mesInvItemStocks.DepotsCode))
+ {
+ throw new NotImplementedException("鍙兘鎵弿" + mesDepots.DepotCode +
+ "浠撳簱鐨勭爜");
+ }*/
+
+ if (mesInvItemStocks.ItemNo is null)
+ {
+ throw new NotImplementedException("鐗╂枡鏄潪娉曠殑");
+ }
+
+ var mesItems = Db.Queryable<MesItems>()
+ .Where(b => b.ItemNo == mesInvItemStocks.ItemNo)
+ .Select<MesItems>(b => new MesItems
+ {
+ ItemName = b.ItemName,
+ ItemModel = b.ItemModel,
+ })
+ .First();
+
+ mesInvItemStocks.ItemName = mesItems.ItemName;
+ mesInvItemStocks.ItemModel = mesItems.ItemModel;
+
+ return mesInvItemStocks;
+ }
+
+ //OQCDto
+ public int ItemBarCodeSubmit(OQCDto dto)
+ {
+ //getbillcode1
+ var billNo = Db.Ado.GetString(
+ "SELECT getbillcode1('1000', '1000', 'OQC') FROM DUAL");
+
+ var dtoItemBarCodeData = dto.ItemBarCodeData;
+
+ var sum = dtoItemBarCodeData.Sum(s => s.Quantity);
+
+ MesOqcItemsDetect02 from = new MesOqcItemsDetect02
+ {
+ CreateBy = dto.CreateUser,
+ CreateDate = DateTime.Now,
+ ReleaseNo = billNo,
+ Fsubmit = 0,
+ Ismodify1 = 0,
+ FcheckBy = dto.CreateUser,
+ FcheckDate = DateTime.Now,
+ ItemNo = dtoItemBarCodeData[0].ItemNo,
+ //ItemId = dtoItemBarCodeData[0].ItemId,
+ PlanQty = sum,
+ SaleOrderNo = dtoItemBarCodeData[0].TaskNo,
+ DepotId = 121163
+ };
+
+ var id = Db.Insertable(from)
+ .IgnoreColumns(ignoreNullColumn: true)
+ .ExecuteReturnIdentity();
+
+ //璁板綍鏉$爜
+ List<MesOqcBarcode> oqcBarcodes = new List<MesOqcBarcode>();
+
+ foreach (var mesInvItemStockse in dtoItemBarCodeData)
+ {
+ MesOqcBarcode entity = new MesOqcBarcode()
+ {
+ CreateBy = dto.CreateUser,
+ CreateDate = DateTime.Now,
+ ItemBarcode = mesInvItemStockse.ItemBarcode,
+ //ItemId = mesInvItemStockse.ItemId,
+ ItemNo = mesInvItemStockse.ItemNo,
+ Qty = mesInvItemStockse.Quantity,
+ Pid = id,
+ SaleOrderNo = mesInvItemStockse.TaskNo,
+ };
+ oqcBarcodes.Add(entity);
+ }
+
+ var executeCommand = Db.Insertable(oqcBarcodes).PageSize(1)
+ .IgnoreColumnsNull()
+ .ExecuteCommand();
+
+ //PRC_OQC_ITEM_INSERT_BTN
+ if (executeCommand > 0 && id > 0)
+ {
+ // 瀹氫箟杈撳嚭鍙傛暟
+ var outputResult = new SugarParameter("PO_RESULT", null,
+ DbType.Int32, ParameterDirection.Output, 4000);
+ var outputMessage = new SugarParameter("PO_TEXT", null,
+ DbType.String,
+ ParameterDirection.Output, 4000);
+
+ // 瀹氫箟杈撳叆鍙傛暟
+ var parameters = new List<SugarParameter>
+ {
+ new("P_RELEASE_NO", from.ReleaseNo, DbType.String,
+ ParameterDirection.Input),
+ new("P_ITEM_NO", from.ItemNo, DbType.String ,
+ ParameterDirection.Input),
+ new("P_BILL_NO ", "", DbType.String,
+ ParameterDirection.Input),
+ outputResult,
+ outputMessage
+ };
+
+ var db = SqlSugarHelper.GetInstance();
+
+ // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼
+ db.Ado.ExecuteCommand(
+ "BEGIN PRC_OQC_ITEM_INSERT_BTN(:P_RELEASE_NO,:P_ITEM_ID,:P_BILL_NO,:PO_RESULT, :PO_TEXT); END;",
+ parameters.ToArray());
+
+ // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+ var resultValue = outputResult.Value?.ToString();
+ var messageValue = outputMessage.Value?.ToString();
+
+ if ("1".Equals(resultValue))
+ // 澶勭悊澶辫触鎯呭喌锛岃繑鍥為敊璇俊鎭�
+ throw new Exception($"鎿嶄綔澶辫触: {messageValue}");
+
+ // 褰� resultValue 涓� "0" 鏃惰繑鍥炴垚鍔熺姸鎬�
+ return id;
+ }
+
+ return 0;
+ }
+
+ public OQCDto getXjDetail02ById(decimal? id)
+ {
+ var rkjDto = new OQCDto();
+
+ var qsItemOqcItem =
+ Db.Queryable<MesOqcItemsDetectDetail5>().Single(s => s.Id == id);
+
+ /* if (qsItemOqcItem.IsPass == 0)
+ qsItemOqcItem.Result = "涓嶅悎鏍�";
+ else if (qsItemOqcItem.IsPass == 1)
+ qsItemOqcItem.Result = "鍚堟牸";
+ else
+ qsItemOqcItem.Result = "鏈畬鎴�";
+
+ if (qsItemOqcItem.Picture is { Length: > 0 })
+ qsItemOqcItem.imageData =
+ Convert.ToBase64String(qsItemOqcItem.Picture);
+ */
+ //鑾峰彇涓嶅悎鏍兼暟
+ var count = Db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.Fstand == "脳" && s.MainId == id).Count();
+
+ qsItemOqcItem.Unqualified = count;
+
+ rkjDto.ItemXj01 = qsItemOqcItem;
+
+
+ rkjDto.ItemXj02s = Db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.MainId == id)
+ .ToList();
+
+ return rkjDto;
+ }
+
+ public int UpdateQSItemDetail(MesOqcItemsDetectDetail12 detail)
+ {
+ var withOracle = SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<MesOqcItemsDetectDetail12>()
+ .SetColumns(s => s.LastupdateBy == detail.LastupdateBy)
+ // .SetColumns(s => s.LastupdateDate == DateTime.Now)
+ .SetColumnsIF(StringUtil.IsNotNullOrEmpty(detail.Fstand),
+ s => s.Fstand == detail.Fstand)
+ .SetColumnsIF(StringUtil.IsNotNullOrEmpty(detail.FcheckResu),
+ s => s.FcheckResu == detail.FcheckResu)
+ .Where(s => s.MainId == detail.MainId && s.Id == detail.Id)
+ .ExecuteCommand();
+ });
+
+ detail.CreateBy = detail.LastupdateBy;
+
+ withOracle += autoResult(detail);
+
+ return withOracle;
+ }
+
+ private int autoResult(MesOqcItemsDetectDetail12 detail)
+ {
+ var db = SqlSugarHelper.GetInstance();
+
+ // Single 娌℃湁鏌ヨ鍒扮粨鏋滄椂杩斿洖Null锛屽鏋滅粨鏋滃ぇ浜�1鏉′細鎶涘嚭閿欒
+ var QsItemOqcItem = db.Queryable<MesOqcItemsDetectDetail5>()
+ .Single(s => s.Id == detail.MainId);
+
+ if (QsItemOqcItem == null) return 0;
+
+ //鏌ヨ杩欎釜妫�楠岄」鐩笅鐨勬楠岀粨鏋�
+ var count = db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.MainId == detail.MainId).Count();
+
+ updateDetail5(detail);
+ var result = "";
+
+ //妫�楠屽疄闄呯粨鏋滀笉绛変簬搴旇妫�楠岀殑涓暟鏃剁洿鎺ユ帹鍑�
+ if (QsItemOqcItem.CheckQyt != count) return 0;
+
+ //鍚堟牸鐨勬湁澶氬皯涓�
+ var passCount = db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.MainId == detail.MainId && s.Fstand == "鈭�").Count();
+ //涓嶅悎鏍肩殑鏈夊灏戜釜
+ var noCount = db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.MainId == detail.MainId && s.Fstand == "脳").Count();
+
+ if (count == passCount)
+ result = "鍚堟牸";
+ //else if (count - passCount < QsItemOqcItem.FreQty)
+ // result = "涓嶅悎鏍�";
+ else if (noCount >= QsItemOqcItem.FreQty)
+ result = "涓嶅悎鏍�";
+ var useTransactionWithOracle =
+ SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ var commit = 0;
+ commit += db.Updateable<MesOqcItemsDetectDetail5>()
+ .SetColumns(s => s.FcheckResu == result)
+ .SetColumns(s => s.FenterQty == count)
+ .Where(s => s.Id == detail.MainId)
+ .ExecuteCommand();
+
+ return commit;
+ });
+
+ var isNull = db.Queryable<MesOqcItemsDetectDetail5>()
+ .Where(s => s.ReleaseNo == detail.ReleaseNo && s.FcheckResu == null)
+ .Count();
+
+ if (isNull > 0) return 1;
+ //鑾峰彇妫�楠屽崟鐨勬楠岄」鐩殑涓暟
+ var sum = db.Queryable<MesOqcItemsDetectDetail5>()
+ .Where(s => s.ReleaseNo == detail.ReleaseNo).Count();
+
+ if (sum == 0) return 1;
+
+ //鑾峰彇妫�楠屽崟涓嬬殑鍚堟牸鐨勬楠岄」鐩釜鏁�
+ var icount = db.Queryable<MesOqcItemsDetectDetail5>()
+ .Where(s => s.ReleaseNo == detail.ReleaseNo && s.FcheckResu == "鍚堟牸")
+ .Count();
+
+ var FcheckResu = "涓嶅悎鏍�";
+
+ //瀹為檯涓暟绛変簬鐞嗚涓暟鏃跺妫�楠屽崟杩涜鍒ゅ畾
+ if (sum == icount)
+ //鍚堟牸鐨勬楠岀粨鏋滅瓑浜庢�绘楠屾暟瑙嗕负鍚堟牸
+ FcheckResu = "鍚堟牸";
+ //var sysUser = db.Queryable<SysUser>()
+ // .Where(s => s.Fcode == detail.CreateBy).First();
+
+ SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<MesOqcItemsDetect02>()
+ .SetColumns(s => s.FcheckResu == FcheckResu)
+ .SetColumns(s => s.FcheckDate == DateTime.Now)
+ //.SetColumns(s => s.FcheckBy == sysUser.Fname)
+ .SetColumns(s => s.LastupdateBy == detail.CreateBy)
+ .SetColumns(s => s.LastupdateDate == DateTime.Now)
+ .Where(s => s.ReleaseNo == detail.ReleaseNo)
+ .ExecuteCommand();
+ });
+ // if (FcheckResu.Equals("涓嶅悎鏍�"))
+ //鑷姩鐢熸垚鍏ュ簱妫�寮傚父瀵圭瓥
+ /// saveDetect02(detail.Id, detail.CreateBy);
+
+ return useTransactionWithOracle;
+ }
+
+ private int updateDetail5(MesOqcItemsDetectDetail12 detail)
+ {
+ var db = SqlSugarHelper.GetInstance();
+
+ //鏌ヨ杩欎釜妫�楠岄」鐩笅鐨勬楠屾暟閲�
+ var count = db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.MainId == detail.MainId).Count();
+
+ //鑾峰彇涓嶅悎鏍兼暟
+ var countNo = db.Queryable<MesOqcItemsDetectDetail12>()
+ .Where(s => s.MainId == detail.MainId && s.Fstand == "脳").Count();
+ //鏇存柊妫�楠屾槑缁嗗凡妫�鏁伴噺
+ var withOracle = SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<MesOqcItemsDetectDetail5>()
+ .SetColumns(s => s.FenterQty == count)
+ .SetColumns(s => s.FngQty == countNo)
+ .Where(s => s.Id == detail.MainId)
+ .ExecuteCommand();
+ });
+
+ return withOracle;
+ }
+
+ public int saveRemarksPid(LLJDto dto)
+ {
+ return SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<MesOqcItemsDetectDetail5>()
+ .SetColumns(it =>
+ it.Remarks == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊�
+ .Where(it => it.Id == dto.pid)
+ .ExecuteCommand();
+ });
+ }
+
+ public bool IqcQaSubmit(LLJDto dto)
+ {
+ try
+ {
+ // 瀹氫箟杈撳嚭鍙傛暟
+ var outputResult = new SugarParameter("o_Result", null,
+ DbType.Int32, ParameterDirection.Output,
+ 4000);
+
+ var outputMessage = new SugarParameter("o_Msg", null,
+ DbType.String,
+ ParameterDirection.Output, 4000);
+
+ // 瀹氫箟杈撳叆鍙傛暟
+ var parameters = new List<SugarParameter>
+ {
+ new("p_Release_No", dto.releaseNo, DbType.String,
+ ParameterDirection.Input),
+ new("p_User", dto.userNo, DbType.String,
+ ParameterDirection.Input),
+ outputResult,
+ outputMessage
+ };
+
+ var db = SqlSugarHelper.GetInstance();
+
+ // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼
+ db.Ado.ExecuteCommand(
+ "BEGIN PRC_MES_OQC_QA_SUBMIT82(:p_Release_No, :p_User, :o_Result, :o_Msg); END;",
+ parameters.ToArray());
+
+ // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+ var resultValue = outputResult.Value?.ToString();
+ var messageValue = outputMessage.Value?.ToString();
+
+ if ("1".Equals(resultValue)) throw new Exception(messageValue);
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+ public int saveRemarksGid(LLJDto dto)
+ {
+ return SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<MesOqcItemsDetect02>()
+ .SetColumns(it =>
+ it.Remeke == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊�
+ .Where(it => it.ReleaseNo == dto.releaseNo)
+ .ExecuteCommand();
+ });
+ }
+
+ public int SetQSItemDetail(MesOqcItemsDetectDetail12 detail)
+ {
+ var oracle = SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ List<MesOqcItemsDetectDetail12> result = new();
+ for (var i = 0; i < detail.count; i++)
+ {
+ var item = new MesOqcItemsDetectDetail12();
+ item.MainId = detail.MainId;
+ item.ReleaseNo = detail.ReleaseNo;
+ item.Fstand = detail.Fstand;
+ item.FcheckResu = detail.FcheckResu;
+ item.CreateBy = detail.LastupdateBy;
+ item.CreateDate = DateTime.Now;
+ item.Factory = "1000";
+ item.Company = "1000";
+ result.Add(item);
+ }
+
+ return db.Insertable(result).ExecuteCommand();
+ });
+
+ detail.CreateBy = detail.LastupdateBy;
+
+ autoResult(detail);
+
+ return oracle;
+ }
+
+ public List<QsItemIpiItem> SetQSItems(string itemNo)
+ {
+ var db = SqlSugarHelper.GetInstance();
+
+ // 棣栧厛妫�鏌ES_QA琛ㄤ腑璇ョ墿鏂欑殑妫�楠岄」鐩槸鍚﹀凡瀹℃牳
+ var qaCount = db.Queryable<MesQa>()
+ .Where(q => q.ItemNo == itemNo && q.QsType == "6" && q.Fsubmit == 1).Count();
+
+ if (qaCount <= 0) return [];
+
+ // 鐩存帴鏌ヨMesQualityStandard琛ㄤ腑qsType涓�"6"鐨勬楠岄」鐩�
+ var count = db.Queryable<MesQualityStandard>()
+ .Where(b => b.QsType == "6" && b.ItemNo == itemNo).Count();
+
+ if (count <= 0) return [];
+
+ return db
+ .Queryable<MesQualityStandard>()
+ .Where(b => b.QsType == "6" && b.ItemNo == itemNo).Select(
+ b => new QsItemIpiItem
+ {
+ ProjName = b.ProjName,
+ ItemMod = b.ItemMod,
+ InspectionMethod = b.InspectionMethod,
+ UsingInstruments = b.UsingInstruments,
+ LevelNum = SqlFunc.IsNull(
+ SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1),
+ b.InspectionLevel),
+ MaxValue = b.MaxValue,
+ StandardValue = b.StandardValue,
+ MinValue = b.MinValue,
+ Notes = b.Notes,
+ FcheckLevel = b.FcheckLevel,
+ FacLevel = b.FacLevel,
+ QsCode = b.QsCode,
+ QsName = b.QsName,
+ Picture = b.Picture,
+ Picturename = b.Picturename,
+ result = "鏈娴�",
+ isCheck = 0
+ }).ToList();
+ }
+
+ public List<MesOqcItemsDetectDetail5> SaveItem(string releaseNo, List<QsItemIpiItem> items)
+ {
+ var db = SqlSugarHelper.GetInstance();
+
+ SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ // 鏂板鍓嶅厛杩涜鍒犻櫎鏃ч」鐩紙瑕嗙洊鎿嶄綔锛�
+ db.Deleteable<MesOqcItemsDetectDetail5>().Where(it => it.ReleaseNo == releaseNo).ExecuteCommand();
+ db.Deleteable<MesOqcItemsDetectDetail12>().Where(it => it.ReleaseNo == releaseNo).ExecuteCommand();
+
+ // 杞崲QsItemIpiItem涓篗esOqcItemsDetectDetail5骞舵彃鍏�
+ var oqcItems = items.Select(item => new MesOqcItemsDetectDetail5
+ {
+ ReleaseNo = releaseNo,
+ FcheckItem = item.ProjName,
+ FcheckItemDesc = item.ItemMod,
+ CheckQyt = item.LevelNum,
+ FcheckResu = "鏈楠�",
+ FenterQty = 0,
+ Company = "1000",
+ Factory = "1000",
+ FcheckLevel = item.FcheckLevel,
+ FacLevel = item.FacLevel,
+ FcheckTool = item.UsingInstruments,
+ FspecRequ = item.InspectionMethod,
+ Fstand = item.StandardValue,
+ FupAllow = item.MaxValue?.ToString(),
+ FdownAllow = item.MinValue?.ToString(),
+ Remarks = item.Notes,
+ LastupdateBy = "system",
+ LastupdateDate = DateTime.Now,
+ // AC鏁板拰RE鏁板皢閫氳繃瀛樺偍杩囩▼璁剧疆
+ FacQty = 0,
+ FreQty = 0
+ }).ToList();
+
+ // 鎻掑叆妫�楠岄」鐩�
+ var insertResult = db.Insertable(oqcItems).ExecuteCommand();
+
+ // 璋冪敤瀛樺偍杩囩▼璁剧疆AC鏁板拰RE鏁�
+ if (insertResult > 0)
+ {
+ try
+ {
+ // 瀹氫箟杈撳嚭鍙傛暟
+ var outputResult = new SugarParameter("PO_RESULT", null,
+ DbType.Int32, ParameterDirection.Output, 4000);
+ var outputMessage = new SugarParameter("PO_TEXT", null,
+ DbType.String, ParameterDirection.Output, 4000);
+
+ // 瀹氫箟杈撳叆鍙傛暟
+ var parameters = new List<SugarParameter>
+ {
+ new("P_RELEASE_NO", releaseNo, DbType.String, ParameterDirection.Input),
+ outputResult,
+ outputMessage
+ };
+
+ // 鎵ц瀛樺偍杩囩▼
+ db.Ado.ExecuteCommand(
+ "BEGIN prc_mes_oqc_check_items(:P_RELEASE_NO, :PO_RESULT, :PO_TEXT); END;",
+ parameters.ToArray());
+
+ // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+ var resultValue = outputResult.Value?.ToString();
+ var messageValue = outputMessage.Value?.ToString();
+
+ if ("1".Equals(resultValue))
+ {
+ // 澶勭悊澶辫触鎯呭喌锛岃繑鍥為敊璇俊鎭�
+ throw new Exception($"璁剧疆AC鏁癛E鏁板け璐�: {messageValue}");
+ }
+ }
+ catch (Exception ex)
+ {
+ // 濡傛灉瀛樺偍杩囩▼璋冪敤澶辫触锛岃褰曢敊璇絾涓嶅奖鍝嶄富娴佺▼
+ Console.WriteLine($"璋冪敤prc_mes_oqc_check_items瀛樺偍杩囩▼澶辫触: {ex.Message}");
+ }
+ }
+
+ return insertResult;
+ });
+
+ // 杩斿洖鏇存柊鍚庣殑妫�楠岄」鐩垪琛�
+ return GetDetail5(new OQCDto { ReleaseNo = releaseNo });
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.3