From c2a9a460e38c7c196fe98a94e29e6330eac3626f Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 03 三月 2023 14:30:06 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/Sc_ProcessMangementController.cs |  127 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 108 insertions(+), 19 deletions(-)

diff --git a/WebAPI/Controllers/Sc_ProcessMangementController.cs b/WebAPI/Controllers/Sc_ProcessMangementController.cs
index 8e02797..b5da1e3 100644
--- a/WebAPI/Controllers/Sc_ProcessMangementController.cs
+++ b/WebAPI/Controllers/Sc_ProcessMangementController.cs
@@ -6,10 +6,12 @@
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
+using System.IO;
 using System.Web.Http;
 using WebAPI.DLL;
 using WebAPI.Models;
 using WebAPI.Service;
+using Kingdee.BOS.WebApi.Client;
 
 namespace WebAPI.Controllers
 {
@@ -18,7 +20,7 @@
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
 
         private json objJsonResult = new json();
-
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
@@ -274,7 +276,6 @@
         //        model.Add("FBillType", new JObject() { ["Fnumber"] = "SCHBD01_SYS" }); //鍗曟嵁绫诲瀷鐢熶骇姹囨姤鈥淪CHBD02_SYS鈥� 鍏ュ簱姹囨姤SCHBD01_SYS
         //        model.Add("FPrdOrgId", new JObject() { ["Fnumber"] = dr1["FPrdOrgNUMBER"].ToString() }); //鐢熶骇缁勭粐1
         //        model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡1
-        //        model.Add("FHZYMESFLAG", "鏄�");//  鏄惁涓篗ES鍚屾
         //        model.Add("FBillNo", BillNo);
 
         //        JArray Fentity = new JArray();
@@ -302,19 +303,15 @@
         //            FentityModel.Add("FFailQty", item["涓嶈壇鏁伴噺"].ToString());//涓嶅悎鏍兼暟閲�
         //            FentityModel.Add("FStockInOrgId ", new JObject() { ["Fnumber"] = OrganizationNUM });// 鍏ュ簱缁勭粐 
         //            FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = dr1["FStockNUM"].ToString() }); // 浠撳簱 
-        //            FentityModel.Add("FMOID", dr1["FMOID"].ToString());//  
         //            FentityModel.Add("FMOBILLNO", dr1["FMOBILLNO"].ToString());//  
         //            FentityModel.Add("FMOENTRYID", dr1["FMOENTRYID"].ToString());//  
-        //            FentityModel.Add("FMOENTRYSEQ", dr1["FMOENTRYSEQ"].ToString());//  
         //            FentityModel.Add("FOwnerTypeId", dr1["FOWNERTYPEID"].ToString()); //璐т富绫诲瀷锛欶OwnerTypeId(蹇呭~椤�)
         //            FentityModel.Add("FOwnerId", new JObject() { ["Fnumber"] = dr1["FOwnerNumber"].ToString() }); //璐т富锛欶OwnerId(蹇呭~椤�)
-        //            FentityModel.Add("FBomId", new JObject() { ["Fnumber"] = dr1["FBOMNUM"].ToString() }); //BOM鐗堟湰锛欶BomId(蹇呭~椤�)
+        //            FentityModel.Add("FBomId", new JObject() { ["F    number"] = dr1["FBOMNUM"].ToString() }); //BOM鐗堟湰锛欶BomId(蹇呭~椤�)
         //            FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 鎴愭湰鏉冮噸
         //            FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 鍊掑啿棰嗘枡
         //            FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());//
-        //            FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() }); //鍖呰鏍囪瘑
         //            FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //鎵瑰彿
-        //            FentityModel.Add("F_bsv_Text", dr1["宸ュ簭娴佽浆鍗″彿"].ToString()); //娴佽浆鍗″彿
         //            JArray Fentity2 = new JArray();
         //            JObject FentityModel2 = new JObject();
         //            FentityModel2.Add("FEntity_Link_FFlowId", "f6e6eec3-5267-4f02-8593-b633da508a72");
@@ -327,9 +324,6 @@
         //            FentityModel2.Add("FEntity_Link_FBaseQuaQtyOld", item["鍚堟牸鏁伴噺"].ToString());
         //            FentityModel2.Add("FEntity_Link_FBaseQuaQty", item["鍚堟牸鏁伴噺"].ToString());
         //            Fentity2.Add(FentityModel2);
-        //            FentityModel.Add("FEntity_Link", Fentity2);
-        //            FentityModel.Add("FBFLowId", new JObject() { ["FID"] = "f6e6eec3-5267-4f02-8593-b633da508a72" }); //
-        //            Fentity.Add(FentityModel);
         //        }
         //        model.Add("FEntity", Fentity); //鏄庣粏淇℃伅                       
         //        JObject jsonRoot = new JObject()
@@ -517,7 +511,7 @@
                     FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 鎴愭湰鏉冮噸
                     FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 鍊掑啿棰嗘枡
                     FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());//
-                    FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() }); //鍖呰鏍囪瘑
+                    //FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() }); //鍖呰鏍囪瘑
                     FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //鎵瑰彿
                     FentityModel.Add("F_bsv_Text", dr1["宸ュ簭娴佽浆鍗″彿"].ToString()); //娴佽浆鍗″彿
                     JArray Fentity2 = new JArray();
@@ -622,6 +616,19 @@
                 ////鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁
                 //DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc");
                 //DataRow dr = ds.Tables[0].Rows[0];
+
+                //鍒ゆ柇鍏ュ簱鐨勫悎鏍兼暟閲忔槸鍚︿负0
+                var DTable = oCN.RunProcReturn("select * from  Sc_StationOutBillMain where HBillNo='"+ BillNo + "' ", "Sc_StationOutBillMain").Tables[0];
+
+                if (double.Parse(DTable.Rows[0]["HQty"].ToString()) == 0)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 2;
+                    objJsonResult.Message = "鍚堟牸鏁伴噺涓�0,涓嶉渶瑕佸叆搴擄紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 //淇濆瓨
                 oCN.BeginTran();
                 //鐢熶骇姹囨姤鍗曚富琛�
@@ -710,7 +717,21 @@
                     FentityModel.Add("FBaseRealQty", item["鏁伴噺"].ToString());//
                     FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//
                     FentityModel.Add("FOwnerId", new JObject() { ["FNumber"] = item["HPrdOrgNumber"].ToString() });//
-                    FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumber"].ToString() }); // 浠撳簱 
+                    string sErr = "";
+                    if (oSystemParameter.ShowBill(ref sErr))
+                    {
+                        if (oSystemParameter.omodel.WMS_CampanyName == "鐟炰笌绁�")
+                        {
+                            if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ヨ壓璺嚎")
+                            {
+                                FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumbers"].ToString() }); // 浠撳簱 
+                            }
+                            else if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ュ簭")
+                            {
+                                FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumber"].ToString() }); // 浠撳簱 
+                            }
+                        }
+                    }
                     FentityModel.Add("FLot", new JObject() { ["FNumber"] = item["HBatchNo"].ToString() }); //鎵瑰彿
                     FentityModel.Add("FISBACKFLUSH", "true");//  
                     FentityModel.Add("FWorkShopId1", new JObject() { ["FNumber"] = item["HWorkShopNumber"].ToString() }); //  鐢熶骇杞﹂棿
@@ -869,6 +890,20 @@
                 ////鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁
                 //DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc");
                 //DataRow dr = ds.Tables[0].Rows[0];
+
+                //鍒ゆ柇鏈鎶ュ簾鎬绘暟閲忔槸鍚︿负0
+                var DTable = oCN.RunProcReturn("select sum(HWasterQty) HWasterQty from  Sc_StationOutBillMain where  HProcExchBillNo='"+ BillNo + "' and HBFFlag=0 ", "Sc_StationOutBillMain").Tables[0];
+
+                if (double.Parse(DTable.Rows[0]["HWasterQty"].ToString()) == 0)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 2;
+                    objJsonResult.Message = "鎶ュ簾鏁伴噺涓�0,涓嶉渶瑕佸叆搴擄紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
                 //淇濆瓨
                 oCN.BeginTran();
                 //鐢熶骇姹囨姤鍗曚富琛�
@@ -949,7 +984,21 @@
                     FentityModel.Add("FBaseRealQty", item["鏁伴噺"].ToString());//
                     FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//
                     FentityModel.Add("FOwnerId", new JObject() { ["FNumber"] = item["HPrdOrgNumber"].ToString() });//
-                    FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumber"].ToString() }); // 浠撳簱 
+                    string sErr = "";
+                    if (oSystemParameter.ShowBill(ref sErr))
+                    {
+                        if (oSystemParameter.omodel.WMS_CampanyName == "鐟炰笌绁�")
+                        {
+                            if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ヨ壓璺嚎")
+                            {
+                                FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumbers"].ToString() }); // 浠撳簱 
+                            }
+                            else if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ュ簭")
+                            {
+                                FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumber"].ToString() }); // 浠撳簱 
+                            }
+                        }
+                    }
                     FentityModel.Add("FLot", new JObject() { ["FNumber"] = item["HBatchNo"].ToString() }); //鎵瑰彿
                     FentityModel.Add("FISBACKFLUSH", "true");//  
                     FentityModel.Add("FWorkShopId1", new JObject() { ["FNumber"] = item["HWorkShopNumber"].ToString() }); //  鐢熶骇杞﹂棿
@@ -1104,14 +1153,30 @@
             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)
+            Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID)
         {
             try
             {
                 //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿
-                Int64 HInterID = DBUtility.ClsPub.CreateBillID("7503", ref DBUtility.ClsPub.sExeReturnInfo);
-                string HBillNo = DBUtility.ClsPub.CreateBillCode("7503", ref DBUtility.ClsPub.sExeReturnInfo, true);
-              
+                //Int64 HInterID = DBUtility.ClsPub.CreateBillID("7503", ref DBUtility.ClsPub.sExeReturnInfo);
+                //string HBillNo = DBUtility.ClsPub.CreateBillCode("7503", ref DBUtility.ClsPub.sExeReturnInfo, true);
+
+                DataSet ds1 = oCN.RunProcReturn("select   * from MES_AccessoriesList  where  HSourceBillNo = '" + HBillNo + "'", "MES_AccessoriesList");
+                string HFileName = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFileName"]);
+                string HFilePath = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["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);
+
+
                 //淇濆瓨
                 oCN.BeginTran();
                 //鐢熶骇姹囨姤鍗曚富琛�
@@ -1159,6 +1224,7 @@
                 model.Add("FSourceOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //鏉ユ簮缁勭粐
                 model.Add("FInspectOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //璐ㄦ缁勭粐
                 model.Add("FISSYNCED", "false");//  鏄惁宸插悓姝�
+                model.Add("F_PGKJ_Date", DateTime.Now.ToString("yyyy-MM-dd"));//  鎶ユ鏃ユ湡
                 model.Add("FBillNo", HBillNo);
 
                 JArray Fentity = new JArray();
@@ -1257,7 +1323,7 @@
                     oCN.RollBack();
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍚屾閲戣澏浜戝け璐ワ紒鍗曞彿:{HBillNo.ToString()}" + result;
+                    objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍚屾閲戣澏浜戝け璐ワ紒鍗曞彿:{HBillNo.ToString()}" + jsonRoot;
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
@@ -1270,10 +1336,28 @@
                 {
                     Ids = fID,
                 };
+
+                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")
                 {
+                    string jsonStr = "{" +
+                        " \"FileName\":\"" + HFileName + "\"," +
+                            " \"FormId\":\"QM_InspectBill\"," +
+                            " \"IsLast\":\"true\"," +
+                            " \"InterId\":\"" + HInterID + "\"," +
+                            " \"BillNO\":\"" + HBillNo + "\"," +
+                            " \"AliasFileName\":\"test\"," +
+                            " \"SendByte\":\"" + a + "\"," +
+                        "}";
+
+                    var ret = client.AttachmentUpload(jsonStr);
+
+
                     oCN.RollBack();
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -1328,7 +1412,7 @@
                 string HBillNo = DBUtility.ClsPub.CreateBillCode("7501", ref DBUtility.ClsPub.sExeReturnInfo, true);
 
                 //淇濆瓨
-                oCN.BeginTran();
+                //oCN.BeginTran();
                 //鐢熸垚浜у搧妫�楠屽崟
                 //oCN.RunProc("Insert Into QC_POStockInCheckBillMain   " +
                 //"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" +
@@ -1464,6 +1548,10 @@
                 //FentityModel.Add("FReferDetail", Fentity3);
                 Fentity.Add(FentityModel);
                 model.Add("FEntity", Fentity); //鏄庣粏淇℃伅
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                DataSet ds = oCN.RunProcReturn("select HCheckdate from Sc_ProcessReportMain where hbillno = '" + HSourceBillNo + "'", "Sc_ProcessReportMain");
+                DateTime HCheckDate = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["HCheckdate"]);
                 JObject jsonRoot = new JObject()
                 {
                     ["Creator"] = "",
@@ -1472,6 +1560,7 @@
                     ["IsDeleteEntry"] = "false",
                     ["SubSystemId"] = "",
                     ["IsVerifyBaseDataField"] = "false",
+                    ["F_PGKJ_Date"] = HCheckDate.ToString(),
                     //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳�
                     ["Model"] = model
                 };

--
Gitblit v1.9.1