Просмотр исходного кода

模具变更-未完成(变更型号部分)

qinqi 2 лет назад
Родитель
Сommit
8d336d5df0

+ 173 - 11
DK.Service/PCModuleService/PCModuleLogic.cs

@@ -21,6 +21,9 @@ using Dongke.IBOSS.PRD.Service.CMNModuleService;
 using Dongke.IBOSS.PRD.Service.DataModels;
 using Dongke.IBOSS.PRD.WCF.DataModels;
 using Dongke.WinForm.Utilities;
+using SAP.Middleware.Connector;
+using System.Configuration;
+using Dongke.IBOSS.PRD.Basics.Library;
 
 namespace Dongke.IBOSS.PRD.Service.PCModuleService
 {
@@ -29,6 +32,21 @@ namespace Dongke.IBOSS.PRD.Service.PCModuleService
     /// </summary>
     public static class PCModuleLogic
     {
+        //SAP服务器配置参数
+        //public static string appServerHost = ConfigurationManager.AppSettings["SapAppServerHost"].ToString();
+        //public static string systemNumber = ConfigurationManager.AppSettings["SapSystemNumber"].ToString();
+        //public static string user = ConfigurationManager.AppSettings["SapUser"].ToString();
+        //public static string password = ConfigurationManager.AppSettings["SapPassword"].ToString();
+        //public static string client = ConfigurationManager.AppSettings["SapClient"].ToString();
+        //SAP服务器配置参数
+        public static Basics.Library.INIUtility ini = Basics.Library.INIUtility.Instance(Basics.Library.INIUtility.IniFile.SAP_HEGII);
+        public static string appServerHost = ini.ReadIniData("SAP_RFC_INFO", "SapAppServerHost");
+        public static string systemNumber = ini.ReadIniData("SAP_RFC_INFO", "SapSystemNumber");
+        public static string user = ini.ReadIniData("SAP_RFC_INFO", "SapUser");
+        public static string password = ini.ReadIniData("SAP_RFC_INFO", "SapPassword");
+        public static string client = ini.ReadIniData("SAP_RFC_INFO", "SapClient");
+
+
         #region 成型线管理
 
         #region 成型线一览
@@ -3171,10 +3189,59 @@ namespace Dongke.IBOSS.PRD.Service.PCModuleService
 
                         }
                     }
+
+                    #region 转模具料号SAP
+                    //待产
+                    //sql = "SELECT m.MouldID\n" +
+                    // "      ,m.MouldCode\n" +
+                    // "      ,m.MouldBarcode\n" +
+                    // "      ,m.GoodsID\n" +
+                    // "      ,m.GoodsCode\n" +
+                    // "      ,m.GroutingNum\n" +
+                    // "      ,m.MouldStatus\n" +
+                    // "      ,m.GroutingLineDetailID\n" +
+                    // "      ,g.mouldmaterialcode\n" +
+                    // "      ,m.STANDARDGROUTINGSUM - m.GroutingNum notusedGroutingNum\n" +
+                    // "  FROM tp_pc_mould m\n" +
+                    // "  left join tp_mst_goods g  on m.goodsid = g.goodsid\n" +
+                    // " WHERE m.accountid = :accountid\n" +
+                    // "   AND m.valueflag = '1'\n" +
+                    // "   AND m.MouldID in (" + cre.Properties["MouldIDs"] + ")\n" +
+                    // "   AND m.MOULDSTATUS = 3\n";
+                    //paras = new OracleParameter[]
+                    //{
+                    //    new OracleParameter(":accountid", OracleDbType.Int32,  sUserInfo.AccountID, ParameterDirection.Input),
+                    //};
+
+                    //mouldTable = con.GetSqlResultToDt(sql, paras);
+                     
+                    //string ZTYPE;
+                    //string ZMSG;
+                    //DataTable dt = new DataTable();
+
+                    //// 查询更新后的产品编码-物料编码
+
+                    //string sqlString = "SELECT g.mouldmaterialcode FROM tp_mst_goods g WHERE g.goodscode = :goodsCode";
+                    //paras = new OracleParameter[]
+                    //{
+                    //    new OracleParameter(":goodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"].ToString(), ParameterDirection.Input),
+                    //};
+
+                    //DataTable newGoodsCodeTable = con.GetSqlResultToDt(sqlString, paras);
+
+                    ////更新前的模具信息
+                    //sqlString = "";
+
+
+
+                    //DataTable dtResult = ZPPFM050(DateTime.Now.Date.ToString("yyyyMMdd"), dt, out ZTYPE, out ZMSG);
+
+                    #endregion
+
                     #endregion
                 }
-                // 模具领用
-                else if (mouldOperationType == (int)Constant.MouldOperationType.InvToOut)
+				// 模具领用
+				else if (mouldOperationType == (int)Constant.MouldOperationType.InvToOut)
                 {
                     #region
                     foreach (DataRow item in mouldTable.Rows)
@@ -3945,16 +4012,111 @@ namespace Dongke.IBOSS.PRD.Service.PCModuleService
                 }
             }
         }
-        #endregion
-
-        #region 模具盘点
 
-        /// <summary>
-        /// 获取盘点单列表(searchbox用)
-        /// </summary>
-        /// <param name="sUserInfo"></param>
-        /// <returns></returns>
-        public static ServiceResultEntity GetMouldCheckedList(SUserInfo sUserInfo, ClientRequestEntity cre)
+		/// <summary>
+		/// sap接口-模具型号变更-转模具料号接口 ZPPFM050
+		/// </summary>
+		/// <param name="sUserInfo"></param>
+		/// <param name="cre"></param>
+		/// <returns></returns>
+		public static DataTable ZPPFM050(string BUDAT, DataTable dtTable, out string ZTYPE, out string ZMSG)
+		{  
+            RfcConfigParameters rfcPara = new RfcConfigParameters();
+			rfcPara.Add(RfcConfigParameters.AppServerHost, appServerHost);
+			rfcPara.Add(RfcConfigParameters.SystemNumber, systemNumber);
+			rfcPara.Add(RfcConfigParameters.User, user);
+			rfcPara.Add(RfcConfigParameters.Password, password);
+			rfcPara.Add(RfcConfigParameters.Client, client);
+
+			rfcPara.Add(RfcConfigParameters.Name, "CON");
+			rfcPara.Add(RfcConfigParameters.Language, "ZH");
+			rfcPara.Add(RfcConfigParameters.PoolSize, "5");
+			rfcPara.Add(RfcConfigParameters.ConnectionIdleTimeout, "60");
+
+			RfcDestination rfcDest = RfcDestinationManager.GetDestination(rfcPara);
+			RfcRepository rfcRep = rfcDest.Repository;
+
+			//接口API
+			IRfcFunction rfcApi = rfcRep.CreateFunction("ZPPFM050");
+
+			//WERKS   CHAR    4   0   工厂             Y   5000
+			//MATNR_B CHAR    40  0   物料编号_转换前  Y   211860087N2000
+			//MATNR_A CHAR    40  0   物料编号_转换后  Y   211860088N2000
+			//MENGE   QUAN    13  3   数量             Y   50
+			//MEINS   UNIT    3   0   基本计量单位     Y   CI
+			//BUDAT   DATS    8   0   凭证中的过帐日期 Y   格式: yyyymmdd
+			//LGORT   CHAR    4   0   库存地点         Y   2110、2210、2310
+
+			//输入参数
+			IRfcTable imTable = rfcApi.GetTable("IT_ITEM");
+
+			foreach (DataRow dr in dtTable.Rows)
+			{
+				imTable.Append();
+				imTable.SetValue("WERKS", "5000");
+				imTable.SetValue("MATNR_B", "");
+				imTable.SetValue("MATNR_A", "");
+				imTable.SetValue("MENGE", "");
+				imTable.SetValue("MEINS", "CI");
+				imTable.SetValue("BUDAT", BUDAT);
+				imTable.SetValue("LGORT", "");
+			}
+
+			//调用接口
+			rfcApi.Invoke(rfcDest);
+
+			//获取输出
+			ZTYPE = rfcApi.GetValue("ZTYPE").ToString();
+			ZMSG = rfcApi.GetValue("ZMSG").ToString();
+			IRfcTable table = rfcApi.GetTable("ET_RETURN");
+
+			DataTable dt = GetDataTableFromRFCTable(table);
+
+
+			rfcDest = null;
+			rfcRep = null;
+
+			return dt;
+		}
+
+		/// <summary>
+		/// IRfcTable转DataTable
+		/// </summary>
+		/// <param name="myrfcTable"></param>
+		/// <returns></returns>
+		private static DataTable GetDataTableFromRFCTable(IRfcTable myrfcTable)
+		{
+
+			DataTable loTable = new DataTable();
+			int liElement = 0;
+			for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
+			{
+				RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
+				loTable.Columns.Add(metadata.Name);
+			}
+
+			foreach (IRfcStructure Row in myrfcTable)
+			{
+				DataRow ldr = loTable.NewRow();
+				for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
+				{
+					RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
+					ldr[metadata.Name] = Row.GetString(metadata.Name);
+				}
+				loTable.Rows.Add(ldr);
+			}
+			return loTable;
+		}
+		#endregion
+
+		#region 模具盘点
+
+		/// <summary>
+		/// 获取盘点单列表(searchbox用)
+		/// </summary>
+		/// <param name="sUserInfo"></param>
+		/// <returns></returns>
+		public static ServiceResultEntity GetMouldCheckedList(SUserInfo sUserInfo, ClientRequestEntity cre)
         {
             ServiceResultEntity sre = new ServiceResultEntity();
             IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);

+ 9 - 0
DK.Service/PCModuleService/PCModuleService.csproj

@@ -82,7 +82,16 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\DLL\Oracle.ManagedDataAccess.dll</HintPath>
     </Reference>
+    <Reference Include="sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\DLL\sapnco.dll</HintPath>
+    </Reference>
+    <Reference Include="sapnco_utils, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\DLL\sapnco_utils.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Data" />