From 033d6d49fbb0a924653c7fd3ef3700a24f37ee59 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期一, 22 十二月 2025 16:16:41 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/Sc_ProcessMangementController.cs |  301 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 299 insertions(+), 2 deletions(-)

diff --git a/WebAPI/Controllers/Sc_ProcessMangementController.cs b/WebAPI/Controllers/Sc_ProcessMangementController.cs
index cf752f6..bd41db0 100644
--- a/WebAPI/Controllers/Sc_ProcessMangementController.cs
+++ b/WebAPI/Controllers/Sc_ProcessMangementController.cs
@@ -1402,7 +1402,7 @@
             }
         }
 
-
+        #region
         /// <summary>
         /// 鐢熸垚閲戣澏浜戞潵鏂欐楠屽崟
         /// </summary>
@@ -1451,7 +1451,7 @@
                 " values('7503','7503'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" +
                 ",DATENAME(YEAR,GETDATE()),0,''," + HSupID.ToString() + "," + HMaterID.ToString() +
                 ",'" + HCheckQty.ToString() + "','" + HCheckQty.ToString() + "','" + HRightQty.ToString() + "','" + HBadQty.ToString() + "','" + HKeeperID.ToString() + "'" +
-                ",'" + HCheckResult.ToString() + "','', '','','','" +
+                ",'" + HCheckResult.ToString() + "','', '','',''" +
                 ") ");
                 //鐢熶骇姹囨姤鍗曞瓙琛�
                 oCN.RunProc("Insert into QC_POStockInCheckBillSub " +
@@ -1648,9 +1648,306 @@
                 return objJsonResult;
             }
         }
+        #endregion
+
+
+        #region 鐢熸垚閲戣澏浜戞潵鏂欐楠屽崟 2025/11/26
+        [Route("QCStockInCheckBill/set_SaveQCStockInCheckBill_Json2")]
+        [HttpGet]
+        public object set_SaveQCStockInCheckBill_Json2(string HZJOrgNumber, string HMaterNumber, string HUnitNumber,
+            double HCheckQty, double HRightQty, double HBadQty,
+            string HCheckResult, string HSupNumber,
+            string HUseResult, Int64 HSeQ, Int64 HSourceInterID,
+            Int64 HSourceEntryID, string HSourceBillNo, string user,
+            Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID,
+            Int64 HMaterID, string HSourceBillType, Int64 HSLInterID,
+            Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID, string HBatchNo)
+        {
+            try
+            {
+                //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿
+                //Int64 HInterID = DBUtility.ClsPub.CreateBillID("7503", ref DBUtility.ClsPub.sExeReturnInfo);
+                //string HBillNo = DBUtility.ClsPub.CreateBillCode("7503", ref DBUtility.ClsPub.sExeReturnInfo, true);               
+                HBatchNo = HBatchNo ?? "";
+                //淇濆瓨
+                oCN.BeginTran();
+                //鐢熶骇姹囨姤鍗曚富琛�
+                oCN.RunProc("Insert Into QC_POStockInCheckBillMain   " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" +
+                ",HYear,HPeriod,HRemark,HSupID,HMaterID" +
+                ",HInstockQty,HCheckQty,HRightQty,HBadQty,HFirstCheckEmp" +
+                ",HCheckerResult,HSteelStoveNo,HSteelCompReport,HAspect,HSize" +
+                ") " +
+                " values('7503','7503'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" +
+                ",DATENAME(YEAR,GETDATE()),0,''," + HSupID.ToString() + "," + HMaterID.ToString() +
+                ",'" + HCheckQty.ToString() + "','" + HCheckQty.ToString() + "','" + HRightQty.ToString() + "','" + HBadQty.ToString() + "','" + HKeeperID.ToString() + "'" +
+                ",'" + HCheckResult.ToString() + "','', '','',''" +
+                ") ");
+                //鐢熶骇姹囨姤鍗曞瓙琛�
+                oCN.RunProc("Insert into QC_POStockInCheckBillSub " +
+                      " (HInterID,HEntryID,HCloseMan,HCloseType" +
+                      ",HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
+                      ",HRelationQty,HRelationMoney,HQCCheckClassID,HQCCheckItemID,HQCStd," +
+                      "HResult,HQCRelValue,HProcCheckEmp,HProcCheckTime" +
+                      ") values("
+                      + HInterID.ToString() + ",1,'',''" +
+                      ",''," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','" + HSourceBillType.ToString() + "'" +
+                      ",0,0,0,0,''" +
+                      ",'" + HCheckResult.ToString() + "','" + HCheckResult.ToString() + "','" + HKeeperID.ToString() + "',getdate()" +
+                      ") ");
+                //鍚屾閲戣澏
+                //璁块棶閲戣澏
+                var loginRet = InvokeHelper.Login();
+                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+                if (isSuccess == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                // string sql = @"select a.FID,a.FNUMBER Employee,d.FNUMBER Dept from Gy_Employee e
+                //             join AIS20210811135644..T_HR_EMPINFO a on e.HNumber = a.FNUMBER
+                //             join AIS20210811135644..T_BD_STAFFTEMP c on c.FID = a.FID
+                //             join AIS20210811135644..T_BD_DEPARTMENT d on c.FDEPTID = d.FDEPTID
+                //             where e.HItemID ='" + HKeeperID + "' ";
+                // //鏌ヨ璐ㄦ鍛樺搴旇川妫�閮ㄩ棬
+                // ds = oCN.RunProcReturn(sql, "T_HR_EMPINFO");
+                // LogService.Write("sql" + sql);
+                // if (ds.Tables[0].Rows.Count == 0)
+                // {
+                //     objJsonResult.code = "0";
+                //     objJsonResult.count = 0;
+                //     objJsonResult.Message = "鎿嶄綔澶辫触,璐ㄦ鍛樺搴旇川妫�閮ㄩ棬鏃犳暟鎹��" + sql;
+                //     objJsonResult.data = null;
+                //     return objJsonResult;
+                // }
+
+
+                JObject model = new JObject();
+                model.Add("FBillTypeID", new JObject() { ["Fnumber"] = "JYD001_SYS" }); //鍗曟嵁绫诲瀷 鏉ユ枡妫�楠屽崟JYD001_SYS
+                model.Add("FBusinessType", "1"); //涓氬姟绫诲瀷
+                model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡
+                model.Add("FInspectOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //璐ㄦ缁勭粐
+                model.Add("FSourceOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //鏉ユ簮缁勭粐
+                //model.Add("FInspectDepId", new JObject() { ["Fnumber"] = ds.Tables[0].Rows[0]["Dept"].ToString() }); //璐ㄦ閮ㄩ棬
+                //model.Add("FInspectorId", new JObject() { ["Fnumber"] = ds.Tables[0].Rows[0]["Employee"].ToString() }); //璐ㄦ鍛�
+                model.Add("FISSYNCED", "false");//  鏄惁宸插悓姝�
+                model.Add("F_PGKJ_Date", DateTime.Now.ToString("yyyy-MM-dd"));//  鎶ユ鏃ユ湡
+                model.Add("FBillNo", HBillNo);
+
+               // LogService.Write("璐ㄦ閮ㄩ棬" + ds.Tables[0].Rows[0]["Dept"].ToString());
+               // LogService.Write("璐ㄦ鍛�" + ds.Tables[0].Rows[0]["Employee"].ToString());
+
+                JArray Fentity = new JArray();
+                JObject FentityModel = new JObject();
+                FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });//  鐗╂枡鍐呯爜 
+                FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//璁¢噺鍗曚綅鍐呯爜
+                FentityModel.Add("FInspectQty", HCheckQty.ToString());//  妫�楠屾暟閲� 
+                FentityModel.Add("FQualifiedQty", HRightQty.ToString());//  鍚堟牸鏁伴噺 
+                FentityModel.Add("FUnqualifiedQty", HBadQty.ToString());//  涓嶅悎鏍兼暟閲�
+                FentityModel.Add("FInspectResult", HCheckResult.ToString());//  妫�楠岀粨鏋�
+                FentityModel.Add("FQCStatus", "1");//  璐ㄦ鐘舵�� 
+                FentityModel.Add("FIsRelated", false);//  涓嶈壇鍝佸叧鑱旀爣蹇�
+                FentityModel.Add("FSrcBillType0", "PUR_ReceiveBill");//  婧愬崟绫诲瀷
+                FentityModel.Add("FBaseUnitId", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//鍩烘湰鍗曚綅
+                FentityModel.Add("FBaseInspectQty", HCheckQty.ToString());//鍩烘湰鍗曚綅妫�楠屾暟閲�
+                FentityModel.Add("FSupplierId", new JObject() { ["Fnumber"] = HSupNumber.ToString() }); //  渚涘簲鍟�
+                                                                                                        //FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = HWHNumber.ToString() }); // 浠撳簱
+                FentityModel.Add("FInspectTimes", "1"); // 妫�楠屾鏁� 
+                FentityModel.Add("FTimeUnit", "24");//鏃堕棿鍗曚綅
+                FentityModel.Add("FSAMPLEDAMAGEBEARER", "2");//鏍锋湰鐮村潖鎵挎媴鏂�
+                FentityModel.Add("FISFIRSTINSPECT", false);//棣栨
+                FentityModel.Add("FBaseQualifiedQty", HRightQty.ToString());//鍩烘湰鍗曚綅鍚堟牸鏁�
+                FentityModel.Add("FBaseAcceptQty", HRightQty.ToString());//鍩烘湰鍗曚綅鎺ユ敹鏁�
+                FentityModel.Add("FCurrency", new JObject() { ["Fnumber"] = "PRE001" });//甯佸埆
+                FentityModel.Add("FIsSplitRow ", false);// 鏄惁鎷嗗垎琛�
+                FentityModel.Add("FLot", new JObject() { ["Fnumber"] = HBatchNo.ToString() });//鎵瑰彿
+
+                JArray Fentity2 = new JArray();
+                JObject FentityModel2 = new JObject();
+                FentityModel2.Add("FPolicyMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });//  鐗╂枡鍐呯爜 
+                FentityModel2.Add("FPolicyStatus", "1");  //鐘舵��
+                FentityModel2.Add("FPolicyQty", HRightQty.ToString() == "0" ? HBadQty.ToString() : HRightQty.ToString());    //鏁伴噺
+                FentityModel2.Add("FBasePolicyQty", HRightQty.ToString() == "0" ? HBadQty.ToString() : HRightQty.ToString()); //鍩烘湰鍗曚綅鏁伴噺
+                FentityModel2.Add("FUsePolicy", HUseResult.ToString());   //浣跨敤鍐崇瓥
+                FentityModel2.Add("FIsCheck", false);   //鏄惁鎶芥
+                FentityModel2.Add("FIsDefectProcess", false);  //涓嶈壇澶勭悊
+                FentityModel2.Add("FCanSale", false);   //鍙攢鍞�
+                FentityModel2.Add("FIsMRBReview", false);   //MRP璇勫
+                FentityModel2.Add("FIsReturn", true);   //鍒ら��
+                FentityModel2.Add("FIsRelatedDefect", false);   //涓嶈壇鍝佸叧鑱旀爣蹇�
+                Fentity2.Add(FentityModel2);
+                FentityModel.Add("FPolicyDetail", Fentity2);
 
 
 
+                JArray Fentity3 = new JArray();
+                JObject FentityModel3 = new JObject();
+                FentityModel3.Add("FDetailID", "0");//  
+                FentityModel3.Add("FSrcBillType", "PUR_ReceiveBill");   //婧愬崟绫诲瀷
+                FentityModel3.Add("FSrcBillNo", HSLBillNo.ToString());    //鏀舵枡閫氱煡鍗曞崟鍙�
+                FentityModel3.Add("FSrcInterId", HSLInterID.ToString());      //鏀舵枡閫氱煡鍗曚富ID
+                FentityModel3.Add("FSrcEntryId", HSLEntryID.ToString());    //鏀舵枡閫氱煡鍗曞瓙ID
+                FentityModel3.Add("FSrcEntrySeq", HSLSeQ.ToString());    //婧愬崟琛屽彿
+                FentityModel3.Add("FOrderType", new JObject() { ["FID"] = "PUR_PurchaseOrder" });  //  璁㈠崟绫诲瀷
+                FentityModel3.Add("FOrderBillNo", HSourceBillNo.ToString());   //璁㈠崟鍗曞彿
+                FentityModel3.Add("FOrderId", HSourceInterID.ToString());      //璁㈠崟涓籌D
+                FentityModel3.Add("FOrderEntryId", HSourceEntryID.ToString());  //璁㈠崟瀛怚D
+                FentityModel3.Add("FOrderEntrySeq", HSeQ.ToString());  //璁㈠崟琛屽彿
+                Fentity3.Add(FentityModel3);
+                FentityModel.Add("FReferDetail", Fentity3);
+
+
+                JArray Fentity4 = new JArray();
+                JObject FentityModel4 = new JObject();
+                FentityModel4.Add("FEntity_Link_FRuleId", "QM_PURReceive2Inspect");   //鍗曟嵁杞崲瑙勫垯
+                FentityModel4.Add("FEntity_Link_FSTableName", "T_PUR_RECEIVEENTRY");    //鏀舵枡閫氱煡鍗曞瓙琛�
+                FentityModel4.Add("FEntity_Link_FSBillId", HSLInterID.ToString());      //鏀舵枡閫氱煡鍗曚富鍐呯爜
+                FentityModel4.Add("FEntity_Link_FSId", HSLEntryID.ToString());    //鏀舵枡閫氱煡鍗曞瓙鍐呯爜
+                FentityModel4.Add("FEntity_Link_FBaseAcceptQty", HRightQty.ToString());    //
+                FentityModel4.Add("FEntity_Link_FBaseAcceptQtyOld", HRightQty.ToString());    //
+                FentityModel4.Add("FEntity_Link_FBaseInspectQtyOld", HRightQty.ToString());    //
+                FentityModel4.Add("FEntity_Link_FInspectQtyOld", HRightQty.ToString());    //
+                Fentity4.Add(FentityModel4);
+                FentityModel.Add("FEntity_Link", Fentity4);
+
+
+
+                Fentity.Add(FentityModel);
+                model.Add("FEntity", Fentity); //鏄庣粏淇℃伅
+                JObject jsonRoot = new JObject()
+                {
+                    ["Creator"] = "",
+                    ["NeedUpDateFields"] = new JArray(),
+                    ["NeedReturnFields"] = new JArray(),
+                    ["IsDeleteEntry"] = "false",
+                    ["SubSystemId"] = "",
+                    ["IsVerifyBaseDataField"] = "false",
+                    //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳�
+                    ["Model"] = model
+                };
+                LogService.Write("妫�楠屽崟json锛�" + jsonRoot);
+                string result = InvokeHelper.Save("QM_InspectBill", JsonConvert.SerializeObject(jsonRoot));//淇濆瓨
+                //鍒ゆ柇淇濆瓨鏄惁鎴愬姛
+                if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    LogService.Write("鏉ユ枡妫�楠屽崟淇濆瓨閿欒jsonRoot:" + jsonRoot);
+                    LogService.Write("鎶ラ敊:" + result);
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍚屾閲戣澏浜戝け璐ワ紒鍗曞彿:{HBillNo.ToString()}" + jsonRoot;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鎻愪氦瀹℃牳
+                string result1 = string.Empty;
+                string result2 = string.Empty;
+                var fID = JObject.Parse(result)["Result"]["Id"].ToString();
+                var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString();
+                var json = new
+                {
+                    Ids = fID,
+                };
+
+                K3CloudApiClient client = new K3CloudApiClient("http://47.96.97.237/k3cloud");
+                //        K3CloudApiClient client = new K3CloudApiClient("http://192.168.80.90/k3cloud/");
+
+
+
+                result1 = InvokeHelper.Submit("QM_InspectBill", JsonConvert.SerializeObject(json));//鎻愪氦
+                //result2 = InvokeHelper.Audit("QM_InspectBill", JsonConvert.SerializeObject(json));//瀹℃牳
+                if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍙凤細{fBillNo}锛屾彁浜ゅけ璐�" + result;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+
+                    DataSet ds1 = oCN.RunProcReturn("select * from MES_AccessoriesList  where  HSourceBillNo = '" + HBillNo + "'", "MES_AccessoriesList");
+
+                    for (var i = 0; i < ds1.Tables[0].Rows.Count; i++)
+                    {
+                        string HFileName = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[i]["HFileName"]);
+                        string HFilePath = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[i]["HFilePath"]);
+
+                        string path = HFilePath;
+                        FileInfo fi = new FileInfo(path);
+                        long len = fi.Length;
+                        byte[] buffer = new byte[len];
+                        FileStream fs = new FileStream(path, FileMode.Open);
+                        fs.Read(buffer, 0, (int)len);
+                        //鏂囦欢IO娴�
+                        string a = Convert.ToBase64String(buffer);
+
+                        ds = oCN.RunProcReturn("select * from  AIS20210811135644..T_QM_INSPECTBILL where FBILLNO='" + HBillNo + "'", "T_QM_INSPECTBILL");
+
+                        HInterID = long.Parse(ds.Tables[0].Rows[0]["FID"].ToString());
+
+                        string jsonStr = "{" +
+                           " \"FileName\":\"" + HFileName + "\"," +
+                               " \"FormId\":\"QM_InspectBill\"," +
+                               " \"IsLast\":\"true\"," +
+                               " \"InterId\":\"" + HInterID + "\"," +
+                               " \"BillNo\":\"" + HBillNo + "\"," +
+                               " \"AliasFileName\":\"test\"," +
+                               " \"SendByte\":\"" + a + "\"" +
+                           "}";
+                        string _vlog = InvokeHelper.UpLoad("QM_InspectBill", jsonStr);
+                        LogService.Write("json:" + jsonStr);
+                        LogService.Write("_vlog:" + _vlog);
+                        
+                        if (JObject.Parse(_vlog)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                        {
+                            oCN.RollBack();
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍙凤細{fBillNo}锛岀収鐗囧悓姝ュけ璐�" + _vlog;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+
+
+                    //string jsonStr = "{" +
+                    //   " \"FileName\":\"" + HFileName + "\"," +
+                    //       " \"FormId\":\"QM_InspectBill\"," +
+                    //       " \"IsLast\":\"true\"," +
+                    //       " \"InterId\":\"" + HInterID + "\"," +
+                    //       " \"BillNO\":\"" + HBillNo + "\"," +
+                    //       " \"AliasFileName\":\"test\"," +
+                    //       " \"SendByte\":\"" + a + "\"," +
+                    //   "}";
+
+                    //var ret = client.AttachmentUpload(jsonStr);
+                }
+
+                oCN.Commit();
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
 
 
 

--
Gitblit v1.9.1