From 7b31d00b64218b6f11e2fa92386e3d15ee332d3e Mon Sep 17 00:00:00 2001
From: yxj <1qaz@123>
Date: 星期一, 16 五月 2022 15:51:49 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/生产管理/生产任务单/Sc_ICMOBillController.cs |  139 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 100 insertions(+), 39 deletions(-)

diff --git "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
index ccdeb43..55afaf2 100644
--- "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
+++ "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
@@ -16,14 +16,14 @@
     public class Sc_ICMOBillController : ApiController
     {
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
-        private json objJsonResult = new json(); 
+        private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
 
         #region 鐢熶骇浠诲姟鍗曞垹闄ゅ姛鑳�
         [Route("Sc_ICMOBill/DeltetSc_ICMOReportBill")]
         [HttpGet]
-        public object DeltetSc_ICMOReportBill(string HInterID,string user)
+        public object DeltetSc_ICMOReportBill(string HInterID, string user)
         {
             try
             {
@@ -75,6 +75,33 @@
         }
         #endregion
 
+        #region 鐢熶骇浠诲姟鍗曡幏鍙栬溅闂�
+        [Route("Sc_ICMOBill/GetHDeptList")]
+        [HttpGet]
+        public object GetHDeptList()
+        {
+            try
+            {
+                DataSet oDs = new DataSet();
+                //==========
+                oDs = oCN.RunProcReturn("select HItemID,HName from Gy_Department", "Gy_Department");
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇鎴愬姛锛�";
+                objJsonResult.data = oDs.Tables[0];
+                return objJsonResult; ;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 澧欏挃瑁呯鍗曞洖杞︿簨浠�
         [Route("Sc_ICMOBill/QK_PackingBillByXSBill")]
         [HttpGet]
@@ -82,16 +109,34 @@
         {
             try
             {
-                string sql = string.Format(@"select a.HInterID,a.HBillNo,a.HMaterID,m.HName HMaterName, a.HUnitID,u.HName HUnitName,b.HQty HPlanQty,a.HCusID, c.HName HCusName,a.HEmpID,e.HName HEmpName,a.HDeptID,d.HName HDeptName,a.HPlanEndDate,0 HMinQty,0 HTotalQty,0 HSpsQty
-                                            from Sc_ICMOBillMain a 
-                                            left join Sc_ICMOBillSub b on a.HInterID=b.HInterID
-                                            left join Gy_Material m on b.HMaterID=m.HItemID
-                                            left join Gy_Unit u on b.HUnitID=u.HItemID
-                                            left join Gy_Customer c on a.HCusID=c.HItemID
-                                            left join Gy_Employee e on a.HEmpID=e.HItemID
-                                            left join Gy_Department d on a.HDeptID=d.HItemID
-                                            where b.HDEPTID='113546' and  b.HSeOrderInterID=(select HSeOrderInterID from Sc_PPBomBillMain where HBillNo='" + HBillNo + "')");
-               
+                //string sql = string.Format(@"select a.HInterID,a.HBillNo,a.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName, a.HUnitID,u.HName HUnitName,b.HQty HPlanQty,a.HCusID, c.HName HCusName,a.HEmpID,e.HName HEmpName,a.HDeptID,d.HName HDeptName,a.HPlanEndDate,0 HMinQty,0 HTotalQty,0 HSpsQty,a.HSeOrderBillNo
+                //                            from Sc_ICMOBillMain a 
+                //                            left join Sc_ICMOBillSub b on a.HInterID=b.HInterID
+                //                            left join Gy_Material m on b.HMaterID=m.HItemID
+                //                            left join Gy_Unit u on b.HUnitID=u.HItemID
+                //                            left join Gy_Customer c on a.HCusID=c.HItemID
+                //                            left join Gy_Employee e on a.HEmpID=e.HItemID
+                //                            left join Gy_Department d on a.HDeptID=d.HItemID
+                //                            where b.HInterID=(select HICMOInterID from Sc_PPBomBillMain where HBillNo='" + HBillNo + "')");
+                string sql = string.Format(@" select a.HInterID,a.HBillNo,a.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName, a.HUnitID,u.HName HUnitName,b.HQty HPlanQty,a.HCusID,
+                    c.HName HCusName,a.HEmpID,e.HName HEmpName,a.HDeptID,d.HName HDeptName,a.HPlanEndDate,0 HMinQty,0 HTotalQty,0 HSpsQty,a.HSeOrderBillNo
+                     ,fo.FBILLNO FBillNo,fo.F_ZZZZ_TEXT7 FLXName,fo.FRECEIVEADDRESS FInAddress,fm1.FOLDNUMBER FMaterName,fo.F_ZZZZ_TEXT FBZFS,fu.FDATAVALUE FHX,
+                    fu1.FDATAVALUE FQK,fo.F_ZZZZ_WBBZ FWBBZ
+                    from Sc_ICMOBillMain a 
+                    left join Sc_ICMOBillSub b on a.HInterID=b.HInterID
+                    left join Gy_Material m on b.HMaterID=m.HItemID
+                    left join Gy_Unit u on b.HUnitID=u.HItemID
+                    left join Gy_Customer c on a.HCusID=c.HItemID
+                    left join Gy_Employee e on a.HEmpID=e.HItemID
+                    left join Gy_Department d on a.HDeptID=d.HItemID
+                     left join AIS20200908101915zs..T_PRD_MOENTRY f1 on b.HERPEntryID=f1.FENTRYID
+                    left join AIS20200908101915zs..T_SAL_ORDER fo on f1.FSaleOrderId =fo.FID
+                    left join AIS20200908101915zs..T_SAL_ORDERENTRY fo1 on fo.FID=fo1.FID
+                    left join AIS20200908101915zs..T_BD_MATERIAL fm1 on fo1.FSUBMATERIALNUMBER=fm1.FMATERIALID
+                    LEFT JOIN AIS20200908101915zs..T_BAS_ASSISTANTDATAENTRY_L fu1 on fo1.F_ZZZZ_ASSISTANT1=fu1.FENTRYID
+                    LEFT JOIN AIS20200908101915zs..T_BAS_ASSISTANTDATAENTRY_L fu on fo1.F_ZZZZ_ASSISTANT2=fu.FENTRYID
+                     where b.HInterID=(select HICMOInterID from Sc_PPBomBillMain where HBillNo='" + HBillNo + "')");
+
                 ds = oCN.RunProcReturn(sql, "Sc_ICMOBillMain");
                 if (ds.Tables[0].Rows.Count != 0 || ds != null)
                 {
@@ -153,9 +198,13 @@
                 string day = DateTime.Now.Day.ToString();
                 string nowDate = year + month + day;
                 string materid = "";
+                int LSH;
+                string LSH2;
+                string TM = "";
                 long sum = 0;
-                if (msg4=="ZZ")
+                if (msg4 == "ZZ")
                 {
+                    string FID = "";
                     oCN.BeginTran();
                     foreach (Models.ClsQK_PackingBill oItemSub in ls)
                     {
@@ -164,11 +213,19 @@
                         {
                             //鐢熸垚鍞竴鏉$爜   鏉$爜鍓嶇紑 = 缁勭粐浠g爜 + 鐗╂枡浠g爜 + 骞� + 鏈� + 鏃�
                             string sTMNumber = OrgNum + oItemSub.HMaterNumber + nowDate;
+
                             Ds1 = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
-                            int LSH = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//鍞竴鐮�
-                                                                             //鑾峰彇鍐呯爜
+                            LSH = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//鍞竴鐮�
+                            LSH = LSH + 1;
+                            LSH2 = LSH.ToString();
+                            while (LSH2.Length<6)
+                            {
+                                LSH2 = "0" + LSH2;
+                            }
+                            TM = sTMNumber + LSH2;
+                            //鑾峰彇鍐呯爜
                             long HInterID = DBUtility.ClsPub.CreateBillID_Prod("85", ref DBUtility.ClsPub.sExeReturnInfo);
-                            oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                            string str = string.Format(@"insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                                         ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
                                         ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
                                         ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
@@ -177,21 +234,23 @@
                                         ",HGiveAwayFlag " +
                                         ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                                         ") values ("
-                                        + "'" + LSH + "','鍞竴鏉$爜'," + oItemSub.HMaterID.ToString() + "," + oItemSub.HUnitID.ToString() + "," + oItemSub.HMinQty.ToString()
+                                        + "'" + TM + "','鍞竴鏉$爜'," + oItemSub.HMaterID.ToString() + "," + oItemSub.HUnitID.ToString() + "," + oItemSub.HMinQty.ToString()
                                         + ",'',0,0,'" + msg3 + "',getdate(),0," + oItemSub.HMinQty.ToString()
                                         + ", " + oItemSub.HInterID.ToString() + "," + oItemSub.HInterID.ToString() + ",'" + oItemSub.HBillNo + "','3710',''"
                                         + ",1,1," + oItemSub.HDeptID.ToString() + ",0,0,''"
                                         + ", " + oItemSub.HCusID.ToString() + ",'',getdate(),'',getdate()"
-                                        + ", " + msg5.ToString() + "," + OrgNum.ToString() + ",''," + HInterID.ToString()
+                                        + ", " + msg5.ToString() + "," + OrgNum.ToString() + ",'" + oItemSub.HSeOrderBillNo.ToString() + "'," + HInterID.ToString()
                                         + ",0"
                                         + ",'" + oItemSub.HMaterName + "','','',0,'','')");
-
+                            oCN.RunProc(str);
+                            oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                             string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=" + oItemSub.HSpsQty + " where HInterID=" + oItemSub.HInterID);
                             oCN.RunProc(sql1);
+                            FID = FID + HInterID + ",";
                         }
                     }
                     oCN.Commit();
-                    objJsonResult.code = "1";
+                    objJsonResult.code = FID;
                     objJsonResult.count = 1;
                     objJsonResult.Message = "鏁磋鐢熸垚鎴愬姛锛�";
                     objJsonResult.data = 1;
@@ -211,7 +270,7 @@
                         //鐢熸垚鍞竴鏉$爜   鏉$爜鍓嶇紑 = 缁勭粐浠g爜 + 鐗╂枡浠g爜 + 骞� + 鏈� + 鏃�
                         string sTMNumber = OrgNum + oItemSub.HMaterNumber + nowDate;
                         Ds1 = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
-                        int LSH = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//鍞竴鐮�
+                        LSH = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//鍞竴鐮�
                         //鎻掑叆鏉$爜妗f
                         oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                                     ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
@@ -230,14 +289,14 @@
                                     + ", " + msg5.ToString() + "," + OrgNum.ToString() + ",''," + HInterID2.ToString()
                                     + ",0"
                                     + ",'" + oItemSub.HMaterName + "','','',0,'','')");
-                       //鎻掑叆缁勬墭鍗曞瓙琛�
+                        //鎻掑叆缁勬墭鍗曞瓙琛�
                         string sql = string.Format(@"insert into Sc_PackUnionBillSub(HInterID,HEntryID,HCloseMan,HCloseType,HRemark,
                                                     HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,
                                                     HRelationQty,HRelationMoney,HMaterID,HUnitID,HQty,HSourceID,HEquipID,HGroupID,HWorkerID,
 	                                                HScanDate,HBarCode,HBarCode_Pack)
-                                                    values("+HInterID+",'','',0,'鑷姩缁戝畾',"+oItemSub.HInterID+",'','"+oItemSub.HBillNo+"','3710',"+
-	                                                "0,0,"+ oItemSub.HMaterID+","+ oItemSub.HUnitID+","+ oItemSub.HPlanQty+", 0,0,0,0,"+
-	                                                "getdate(),'"+ LSH + "','" +HBillNo+"')");
+                                                    values(" + HInterID + ",'','',0,'鑷姩缁戝畾'," + oItemSub.HInterID + ",'','" + oItemSub.HBillNo + "','3710'," +
+                                                    "0,0," + oItemSub.HMaterID + "," + oItemSub.HUnitID + "," + oItemSub.HPlanQty + ", 0,0,0,0," +
+                                                    "getdate(),'" + LSH + "','" + HBillNo + "')");
                         //鏇存敼鐢熶骇璁㈠崟鐨勬暟閲�
                         string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=" + oItemSub.HSpsQty + " where HInterID=" + oItemSub.HInterID);
 
@@ -251,14 +310,14 @@
                                                     HProdOrgID,HDeptID,HEmpID,HSNum,HPackNum,HBarCode_Cus,HBatchNo,HBillSubType)
                                                     values('2022',1,'3783'," + HInterID + ",getdate(),'" + HBillNo + "',1,0,0," +
                                                         "'鑷姩缁戝畾','','', '" + msg3 + "',getdate(),'','',0,'',0,0,'" +
-                                                         HBillNo + "',0,0,0,0,0," + 
+                                                         HBillNo + "',0,0,0,0,0," +
                                                         "0,0,0,0,0,'','','')");
                     oCN.RunProc(sql2);
                     //鍐嶆鐢熸垚鍞竴鐮�
                     //鑾峰彇鍐呯爜
                     long HInterID3 = DBUtility.ClsPub.CreateBillID_Prod("85", ref DBUtility.ClsPub.sExeReturnInfo);
                     //鐢熸垚鍞竴鏉$爜   鏉$爜鍓嶇紑 = 缁勭粐浠g爜 + 鐗╂枡浠g爜 + 骞� + 鏈� + 鏃�
-                    string sTMNumber1 = OrgNum  + materid+nowDate;
+                    string sTMNumber1 = OrgNum + materid + nowDate;
                     Ds1 = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber1 + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
                     int LSH1 = ClsPub.isInt(Ds1.Tables[0].Rows[0][0]);//鍞竴鐮�
                     string sql3 = string.Format(@"insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
@@ -287,7 +346,7 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                
+
             }
             catch (Exception e)
             {
@@ -322,10 +381,10 @@
                                     left join Gy_Employee e on a.HEmpID=e.HItemID 
                                     left join Gy_Department d on a.HDeptID=d.HItemID
                                     left join Sc_PackUnionBillMain p on a.HSourceInterID=p.HInterID
-                                    where a.HBarCode=(select HBarCode from  Sc_PackUnionBillSub where HInterID=
-                                    (select HBarcodeNo from Gy_BarCodeBill where HBarCode='" + HInterID + "'))");
+                                    where a.HBarCode in(select HBarCode from  Sc_PackUnionBillSub where HInterID=
+                                    (select HBarcodeNo from Gy_BarCodeBill where HItemID='" + HInterID + "'))");
                 ds = oCN.RunProcReturn(sql, "Sc_PackUnionBillSub");
-                
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
@@ -353,7 +412,7 @@
         {
             try
             {
-               
+
                 ds = QK_GetPackingBillList_s(sWhere);
 
                 //if (ds.Tables[0].Rows.Count != 0 || ds != null)
@@ -412,18 +471,18 @@
         /// <returns></returns>
         [Route("Sc_ICMOBillController/DeleteQK_GetPackingBillList")]
         [HttpGet]
-        public object DeleteQK_GetPackingBillList(string HInterID,string Flag)
+        public object DeleteQK_GetPackingBillList(string HInterID, string Flag)
         {
             try
             {
                 oCN.BeginTran();
-                if (Flag=="0")
+                if (Flag == "0")
                 {
                     DataSet ds = new DataSet();
                     ds = oCN.RunProcReturn("select * from Gy_BarCodeBill where HItemID=" + HInterID, "Gy_BarCodeBill");
                     DataRow dr = ds.Tables[0].Rows[0];
                     string sql = string.Format(@"delete from Gy_BarCodeBill where HItemID=" + HInterID);
-                    string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=HPlanQty+" + dr["HQty"] +" where HInterID=(select HSourceInterID from Gy_BarCodeBill where HItemID="+ HInterID + ")");
+                    string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=HPlanQty+" + dr["HQty"] + " where HInterID=(select HSourceInterID from Gy_BarCodeBill where HItemID=" + HInterID + ")");
                     oCN.RunProc(sql);
                     oCN.RunProc(sql1);
                 }
@@ -440,18 +499,18 @@
                         foreach (DataRow dr in dt.Rows)
                         {
                             DataSet ds = new DataSet();
-                            ds = oCN.RunProcReturn("select * from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString()+"'", "Gy_BarCodeBill");
+                            ds = oCN.RunProcReturn("select * from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString() + "'", "Gy_BarCodeBill");
                             DataRow dr1 = ds.Tables[0].Rows[0];
 
-                            string sql = string.Format(@"delete from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString()+"'");
+                            string sql = string.Format(@"delete from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString() + "'");
                             string sql1 = string.Format(@"update Sc_ICMOBillSub set HQty=HPlanQty+" + dr1["HQty"] + " where HInterID=(select HSourceInterID from Gy_BarCodeBill where HBarCode='" + dr["HBarCode"].ToString() + "')");
                             oCN.RunProc(sql);
                             oCN.RunProc(sql1);
                         }
                     }
-                   
+
                     //閬嶅巻瀹屽悗鍒犻櫎閫氳繃鏉$爜id鎵惧埌鎵樻潯鐮侊紝閫氳繃鎵樻潯鐮佹壘鍒扮粍鎵樺崟瀛愯〃鐨勬暟鎹紝浠ュ強涓昏〃鏁版嵁
-                    string sql3 = string.Format(@"delect from Sc_PackUnionBillSub where HInterID=(select HBarcodeNo from Gy_BarCodeBill where HItemID="+ HInterID);
+                    string sql3 = string.Format(@"delect from Sc_PackUnionBillSub where HInterID=(select HBarcodeNo from Gy_BarCodeBill where HItemID=" + HInterID);
                     string sql4 = string.Format(@"delect from Sc_PackUnionBillMain where HInterID=(select HBarcodeNo from Gy_BarCodeBill where HItemID=" + HInterID);
                     //鍒犻櫎鏈�澶х殑鍚堟垚鐨勫敮涓�鐮�
                     string sql5 = string.Format(@"delete from Gy_BarCodeBill where HItemID=" + HInterID);
@@ -478,5 +537,7 @@
             }
         }
         #endregion
+
+        
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1