fubin vor 3 Jahren
Ursprung
Commit
b9dae64e62

BIN
DK.Basics/Library/Dll/sapnco.dll


BIN
DK.Basics/Library/Dll/sapnco.dll.refresh


BIN
DK.Basics/Library/Dll/sapnco_utils.dll


+ 14 - 1
DK.Basics/Library/Library.csproj

@@ -110,6 +110,14 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\DLL\Newtonsoft.Json.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="SharpZipLib">
       <HintPath>..\..\IBOSS.PRD.Client\SharpZipLib.dll</HintPath>
     </Reference>
@@ -145,6 +153,7 @@
     <Compile Include="OperateXmlUtility.cs" />
     <Compile Include="OutputLog.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="SapApi.cs" />
     <Compile Include="SystemAPI.cs" />
     <Compile Include="Utility.cs" />
     <Compile Include="Win32.cs" />
@@ -167,10 +176,14 @@
       <Name>BaseResources</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <None Include="Dll\sapnco.dll.refresh" />
+  </ItemGroup>
   <ItemGroup>
     <Content Include="Dll\DataSetSurrogate.dll" />
     <Content Include="Dll\Interop.Excel.dll" />
+    <Content Include="Dll\sapnco.dll" />
+    <Content Include="Dll\sapnco_utils.dll" />
     <Content Include="Dll\SharpZipLib.dll" />
     <Content Include="Dll\zxing.dll" />
   </ItemGroup>

+ 558 - 0
DK.Basics/Library/SapApi.cs

@@ -0,0 +1,558 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+
+using Dongke.IBOSS.PRD.Basics.Library;
+using SAP.Middleware.Connector;
+
+/// <summary>
+/// SapApi
+/// </summary>
+public class SapApi
+{
+    //SAP服务器配置参数
+    public static INIUtility ini = INIUtility.Instance(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");
+
+    /// <summary>
+    /// 读取库存单价接口(获取库存数量)
+    /// </summary>
+    /// <param name="WERKS">工厂代号</param>
+    /// <param name="MATNR">物料编号</param>
+    /// <param name="LGORT">库存地点</param>
+    /// <param name="ZTYPE">消息类型: S 成功,E 错误,W 警告,I 信息,A 中断</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static DataTable ZMMFM037(string WERKS, List<string> matnrs, string LGORT, 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("ZMMFM037");
+
+        //输入参数
+        IRfcTable imTable = rfcApi.GetTable("TAB_IN");
+
+        foreach (string MATNR in matnrs)
+        {
+            imTable.Append();
+            imTable.SetValue("WERKS", WERKS);
+            imTable.SetValue("MATNR", MATNR);
+            imTable.SetValue("LGORT", LGORT);
+        }
+
+        //调用接口
+        rfcApi.Invoke(rfcDest);
+
+        //获取输出
+        ZTYPE = rfcApi.GetValue("ZTYPE").ToString();
+        ZMSG = rfcApi.GetValue("ZMSG").ToString();
+        IRfcTable table = rfcApi.GetTable("TAB_OUT");
+
+        DataTable dt = GetDataTableFromRFCTable(table);
+
+        //string[] columns = new string[] { "WERKS", "MATNR", "MEINS", "VBELN", "POSNR", "CHARG", "LGORT", "MENGE", "VERPR", "WAERS" };
+        //DataTable dt = new DataTable();
+        //foreach (string clmn in columns)
+        //{
+        //    dt.Columns.Add(clmn);
+        //}
+        //for (int i = 0; i < table.RowCount; i++)
+        //{
+        //    DataRow dr = dt.NewRow();
+        //    foreach (string clmn in columns)
+        //    {
+        //        dr[clmn] = table.GetString(clmn);
+        //    }
+        //    dt.Rows.Add(dr);
+        //}
+
+        rfcDest = null;
+        rfcRep = null;
+
+        return dt;
+    }
+
+    /// <summary>
+    /// 读取库存单价接口(获取库存数量)
+    /// </summary>
+    /// <param name="WERKS">工厂代号</param>
+    /// <param name="MATNR">物料编号</param>
+    /// <param name="LGORT">库存地点</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static DataTable ZMM_WMS016(string WERKS, List<string> matnrs, string LGORT, 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("ZMM_WMS016");
+
+        //输入参数
+        IRfcTable imTable = rfcApi.GetTable("IT_INPUT");
+
+        foreach (string MATNR in matnrs)
+        {
+            imTable.Append();
+            imTable.SetValue("WERKS", WERKS);
+            imTable.SetValue("MATNR", MATNR);
+            imTable.SetValue("LGORT", LGORT);
+        }
+
+        //调用接口
+        rfcApi.Invoke(rfcDest);
+
+        //获取输出
+        ZMSG = rfcApi.GetValue("E_MSG").ToString();
+        IRfcTable table = rfcApi.GetTable("IT_OUTPUT");
+
+        DataTable dt = GetDataTableFromRFCTable(table);
+
+        rfcDest = null;
+        rfcRep = null;
+
+        return dt;
+    }
+
+    /// <summary>
+    /// 读取库存单价接口(获取库存数量)
+    /// </summary>
+    /// <param name="WERKS">工厂代号</param>
+    /// <param name="LGORT">库存地点</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static DataTable ZMM_WMS016(string WERKS, DataTable dtInventory, 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("ZMM_WMS016");
+
+        //输入参数
+        IRfcTable imTable = rfcApi.GetTable("IT_INPUT");
+
+        foreach (DataRow row in dtInventory.Rows)
+        {
+            imTable.Append();
+            imTable.SetValue("WERKS", WERKS);
+            imTable.SetValue("MATNR", row["IDNRK"]);
+            imTable.SetValue("LGORT", row["POSITION"]);
+        }
+
+        //调用接口
+        rfcApi.Invoke(rfcDest);
+
+        //获取输出
+        ZMSG = rfcApi.GetValue("E_MSG").ToString();
+        IRfcTable table = rfcApi.GetTable("IT_OUTPUT");
+
+        DataTable dt = GetDataTableFromRFCTable(table);
+
+        rfcDest = null;
+        rfcRep = null;
+
+        return dt;
+    }
+
+    /// <summary>
+    /// 查询PO的相关信息(获取订单达成数量)
+    /// </summary>
+    /// <param name="IN_EBELN">采购凭证号</param>
+    /// <param name="ZTYPE">消息类型: S 成功,E 错误,W 警告,I 信息,A 中断</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static DataTable ZMMFM_MES_POCX(string IN_EBELN, 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("ZMMFM_MES_POCX");
+
+        //输入参数
+        rfcApi.SetValue("IN_EKORG", 1000);
+        rfcApi.SetValue("IN_EBELN", IN_EBELN);
+        rfcApi.SetValue("IN_AEDAT_FROM", "20220101");
+        rfcApi.SetValue("IN_AEDAT_TO", "20301231");
+
+        //调用接口
+        rfcApi.Invoke(rfcDest);
+
+        //获取输出
+        ZTYPE = rfcApi.GetValue("ZTYPE").ToString();
+        ZMSG = rfcApi.GetValue("ZMSG").ToString();
+        IRfcTable table = rfcApi.GetTable("GT_OUT");
+
+        //EBELN  采购凭证编号
+        //EBELP  采购凭证的项目编号
+        //MENGE  采购订单数量
+        //MEINS  订单计量单位
+        //ZYSSL  已收/ 退数量数量
+        //ZWSSL  未收/ 退数量
+        //ELIKZ  交货已完成标识
+        //LIFNR  供应商编码
+        //EKGRP  采购组
+        //MATNR  物料编码
+
+        //string[] columns = new string[] { "EBELN", "EBELP", "MENGE", "MEINS", "ZYSSL", "ZWSSL", "ELIKZ", "LIFNR", "EKGRP", "MATNR" };
+        DataTable dt = GetDataTableFromRFCTable(table);
+        //foreach (string clmn in columns)
+        //{
+        //    dt.Columns.Add(clmn);
+        //}
+        //for (int i = 0; i < table.RowCount; i++)
+        //{
+        //    DataRow dr = dt.NewRow();
+        //    foreach (string clmn in columns)
+        //    {
+        //        dr[clmn] = table.ro.GetString(clmn);
+        //    }
+        //    dt.Rows.Add(dr);
+        //}
+
+        rfcDest = null;
+        rfcRep = null;
+
+        return dt;
+    }
+
+    /// <summary>
+    /// 物料主数据接口(同步最小包装数用)
+    /// </summary>
+    /// <param name="MBLNR">物料凭证编号</param>
+    /// <param name="createTime">创建时间</param>
+    /// <param name="ZTYPE">消息类型: S 成功,E 错误,W 警告,I 信息,A 中断</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static DataTable ZMMFM054(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("ZMMFM054");
+
+        //输入参数
+        rfcApi.SetValue("IN_ALL", 'Y');
+        rfcApi.SetValue("IN_WERKS", 5020);
+
+        //调用接口
+        rfcApi.Invoke(rfcDest);
+
+        //获取输出
+        ZTYPE = rfcApi.GetValue("ZTYPE").ToString();
+        ZMSG = rfcApi.GetValue("ZMSG").ToString();
+        IRfcTable table = rfcApi.GetTable("OUT_TABLE");
+
+        DataTable dt = GetDataTableFromRFCTable(table);
+
+        rfcDest = null;
+        rfcRep = null;
+        return dt;
+    }
+
+    /// <summary>
+    /// 东科与SAP系统之线边仓库存领用接口(库存过账)
+    /// </summary>
+    /// <param name="BLDAT">过帐日期</param>
+    /// <param name="ZDKNO">东科单据号</param>
+    /// <param name="ZTYPE">消息类型: S 成功,E 错误,W 警告,I 信息,A 中断</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static DataTable ZMMFM045(string BLDAT, string ZDKNO, 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("ZMMFM045");
+
+        //BLDAT     DATS    8   0   必填 凭证日期    格式: yyyymmdd
+        //BUDAT     DATS    8   0   必填 过帐日期    格式: yyyymmdd
+        //WERKS     CHAR    4   0   必填 工厂  5020
+        //LGORT_FM  CHAR    4   0   必填 发出库位
+        //LGORT_TO  CHAR    4   0   必填 接收库位
+        //MATNR     CHAR    40  0   必填 物料编号
+        //BWART     CHAR    3   0   必填 移动类型(库存管理)  目前只允许填:311
+        //MEINS     UNIT    3   0   必填 基本计量单位
+        //MENGE     QUAN    13  3   必填 数量
+        //ZDKNO     CHAR    40  0   必填 东科单据号
+
+        //输入参数
+        IRfcTable imTable = rfcApi.GetTable("IT_ITEM");
+
+        foreach (DataRow dr in dtTable.Rows)
+        {
+            imTable.Append();
+            imTable.SetValue("BLDAT", BLDAT);
+            imTable.SetValue("BUDAT", BLDAT);
+            imTable.SetValue("WERKS", "5000");
+            imTable.SetValue("LGORT_FM", dr["LGORT_FM"]);
+            imTable.SetValue("LGORT_TO", dr["TOLOGT"]);
+            imTable.SetValue("MATNR", dr["MATNR"]);
+            imTable.SetValue("CHARG", dr["CHARG"] + "");
+            imTable.SetValue("BWART", "311");
+            imTable.SetValue("MEINS", dr["MEINS"]);
+            imTable.SetValue("MENGE", dr["MENGE"]);
+            imTable.SetValue("ZDKNO", ZDKNO);
+        }
+
+        //调用接口
+        rfcApi.Invoke(rfcDest);
+
+        //获取输出
+        ZTYPE = rfcApi.GetValue("ZTYPE").ToString();
+        ZMSG = rfcApi.GetValue("ZMSG").ToString();
+        IRfcTable table = rfcApi.GetTable("ET_RETURN");
+
+        DataTable dt = GetDataTableFromRFCTable(table);
+
+        //string[] columns = new string[] { "BLDAT", "WERKS", "MBLNR", "MJAHR", "MSGTY", "MSGTX" };
+        //DataTable dt = new DataTable();
+        //foreach (string clmn in columns)
+        //{
+        //    dt.Columns.Add(clmn);
+        //}
+        //for (int i = 0; i < table.RowCount; i++)
+        //{
+        //    DataRow dr = dt.NewRow();
+        //    foreach (string clmn in columns)
+        //    {
+        //        dr[clmn] = table.GetString(clmn);
+        //    }
+        //    dt.Rows.Add(dr);
+        //}
+
+        rfcDest = null;
+        rfcRep = null;
+
+        return dt;
+    }
+
+    /// <summary>
+    /// 冲销凭证接口(撤销过账)
+    /// </summary>
+    /// <param name="MBLNR">物料凭证编号</param>
+    /// <param name="createTime">创建时间</param>
+    /// <param name="ZTYPE">消息类型: S 成功,E 错误,W 警告,I 信息,A 中断</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static void ZMMFM038(string MBLNR, DateTime createTime, 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("ZMMFM038");
+
+        //输入参数
+        rfcApi.SetValue("MBLNR", MBLNR);
+        rfcApi.SetValue("MJAHR", createTime.ToString("yyyy"));
+        rfcApi.SetValue("BUDAT", createTime.ToString("yyyyMMdd"));
+
+        //调用接口
+        rfcApi.Invoke(rfcDest);
+
+        //获取输出
+        ZTYPE = rfcApi.GetValue("ZTYPE").ToString();
+        ZMSG = rfcApi.GetValue("ZMSG").ToString();
+
+        rfcDest = null;
+        rfcRep = null;
+    }
+
+    /// <summary>
+    /// 测试用,用于把线边仓的货,全挪走
+    /// </summary>
+    /// <param name="BLDAT">过帐日期</param>
+    /// <param name="ZDKNO">东科单据号</param>
+    /// <param name="ZTYPE">消息类型: S 成功,E 错误,W 警告,I 信息,A 中断</param>
+    /// <param name="ZMSG">消息文本</param>
+    /// <returns></returns>
+    public static DataTable ZMMFM045_TEST(string BLDAT, string ZDKNO, 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("ZMMFM045");
+
+        //BLDAT     DATS    8   0   必填 凭证日期    格式: yyyymmdd
+        //BUDAT     DATS    8   0   必填 过帐日期    格式: yyyymmdd
+        //WERKS     CHAR    4   0   必填 工厂  5020
+        //LGORT_FM  CHAR    4   0   必填 发出库位
+        //LGORT_TO  CHAR    4   0   必填 接收库位
+        //MATNR     CHAR    40  0   必填 物料编号
+        //BWART     CHAR    3   0   必填 移动类型(库存管理)  目前只允许填:311
+        //MEINS     UNIT    3   0   必填 基本计量单位
+        //MENGE     QUAN    13  3   必填 数量
+        //ZDKNO     CHAR    40  0   必填 东科单据号
+
+        //输入参数
+        IRfcTable imTable = rfcApi.GetTable("IT_ITEM");
+
+        foreach (DataRow dr in dtTable.Rows)
+        {
+            imTable.Append();
+            imTable.SetValue("BLDAT", BLDAT);
+            imTable.SetValue("BUDAT", BLDAT);
+            imTable.SetValue("WERKS", "5020");
+            imTable.SetValue("LGORT_FM", "2205");
+            imTable.SetValue("LGORT_TO", "1103");
+            imTable.SetValue("MATNR", dr["MATNR"]);
+            imTable.SetValue("CHARG", dr["CHARG"] + "");
+            imTable.SetValue("BWART", "311");
+            imTable.SetValue("MEINS", dr["MEINS"]);
+            imTable.SetValue("MENGE", dr["MENGE"]);
+            imTable.SetValue("ZDKNO", ZDKNO);
+        }
+
+        //调用接口
+        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;
+    }
+}

+ 46 - 0
DK.Basics/Library/Utility.cs

@@ -17,6 +17,8 @@
  *******************************************************************************/
 
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using System.Data;
 using System.Drawing;
 using System.Drawing.Imaging;
@@ -28,6 +30,7 @@ using System.Text.RegularExpressions;
 using System.Windows.Forms;
 
 using Dongke.IBOSS.PRD.Basics.BaseResources;
+using Newtonsoft.Json.Linq;
 
 namespace Dongke.IBOSS.PRD.Basics.Library
 {
@@ -1909,5 +1912,48 @@ namespace Dongke.IBOSS.PRD.Basics.Library
             }
             return Convert.ToInt32(obj);
         }
+
+        #region JArray转DataTable
+        /// <summary>
+        /// JArray转DataTable
+        /// </summary>
+        /// <param name="dataArr"></param>
+        /// <returns></returns>
+        public static DataTable ConvertToDataTable(JArray dataArr)
+        {
+            if (dataArr == null || dataArr.Count <= 0)
+                return null;
+            DataTable result = new DataTable();
+            var colnames = ((JObject)(dataArr.First)).Properties();
+            List<string> columnNames = new List<string>();
+            if (colnames == null || colnames.Count() <= 0)
+                return null;
+            foreach (var item in colnames)
+            {
+                if (!columnNames.Contains(item.Name))
+                    columnNames.Add(item.Name);
+                result.Columns.Add(item.Name, typeof(string));
+            }
+            foreach (JObject data in dataArr)
+            {
+                JObject jo = JObject.Parse(data.ToString());
+                DataRow row = result.NewRow();
+                foreach (var columnName in columnNames)
+                {
+                    if (jo.Property(columnName) == null)
+                    {
+                        data.Add(columnName, "");
+                        row[columnName] = data[columnName].ToString();
+                    }
+                    else
+                    {
+                        row[columnName] = data[columnName].ToString();
+                    }
+                }
+                result.Rows.Add(row);
+            }
+            return result;
+        }
+        #endregion
     }
 }

+ 394 - 13
DK.Service/PMModuleLogic/PMModuleLogicDAL.cs

@@ -10580,7 +10580,7 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                     #region 变更商标
                     if (!string.IsNullOrEmpty(productionData.NewLogoID))
                     {
-                        object oldLogoID = oracleTrConn.GetSqlResultToObj(@"
+                        string oldLogoID = oracleTrConn.GetSqlResultToStr(@"
                         SELECT GDD.LOGOID
                           FROM TP_PM_GROUTINGDAILYDETAIL GDD
                          WHERE GDD.BARCODE = :BARCODE ",
@@ -10605,7 +10605,7 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                             string delSql = @"
                             DELETE FROM TP_PM_BARCODEIDNRKREL
                              WHERE BARCODE = :BARCODE
-                               AND INSTR(:CANSAVEIDNRKS, ''|| IDNRK ||'') = 0 ";
+                               AND INSTR(:CANSAVEIDNRKS, ','|| IDNRK ||',') = 0 ";
 
                             returnRows += oracleTrConn.ExecuteNonQuery(delSql, new OracleParameter[]
                             {
@@ -18104,9 +18104,10 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
         /// 设置条码商标 
         /// </summary>
         /// <returns></returns>
-        public static int SaveBarCodeLogo(string barcode, int logoid, SUserInfo sUserInfo)
+        public static int SaveBarCodeLogo(string barcode, int logoid, SUserInfo sUserInfo, out string returnMessage)
         {
             int returnRows = 0;
+            returnMessage = "";
             IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
             try
             {
@@ -18126,6 +18127,7 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                 //end
                 object pid = null;
                 string sql = "";
+                string oldMatnr = "";// 老物料编码
 
                 //sql = @"select logoid from tp_pm_groutingdailydetail where barcode=:barcode";
                 //oldLogoID = oracleTrConn.GetSqlResultToObj(sql, new OracleParameter[]{
@@ -18137,7 +18139,7 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                 //sql = @"select g.logoid, f.fhuserid from tp_pm_groutingdailydetail g
                 //        left join tp_pm_finishedproduct f on g.barcode = f.barcode
                 //        where g.barcode=:barcode";
-                sql = @"select g.logoid,g.GROUTINGDAILYDETAILID,f.fhuserid from tp_pm_groutingdailydetail g
+                sql = @"select g.logoid,g.GROUTINGDAILYDETAILID,g.materialcode,f.fhuserid from tp_pm_groutingdailydetail g
                         left join tp_pm_finishedproduct f on g.barcode = f.barcode
                         where g.barcode=:barcode";
                 //end
@@ -18152,6 +18154,7 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                     //lsq 20210723 已注浆非产成品没有商标可以变更商标
                     //begin
                     pdid = dt.Rows[0]["GROUTINGDAILYDETAILID"];
+                    oldMatnr = dt.Rows[0]["materialcode"] + "";
                     //if (oldLogoID == null || oldLogoID == DBNull.Value)
                     if (pdid == null || pdid == DBNull.Value)
                     //end
@@ -18330,6 +18333,12 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                     };
                 returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
 
+                // 切换物料,切换已装组件
+                returnRows = SetMatnrIdnrk(oracleTrConn, oldMatnr, barcode, sUserInfo, out returnMessage);
+                if (returnRows < 0)
+                {
+                    return returnRows;
+                }
 
                 //if (returnRows == 0)
                 //{
@@ -18359,9 +18368,10 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
         /// </summary>
         /// <returns></returns>
         public static int SaveBarCodeLogoAndGlazetype(string barcode, int logoid, int glazetypeid,
-            SUserInfo sUserInfo)
+            SUserInfo sUserInfo, out string returnMessage)
         {
             int returnRows = 0;
+            returnMessage = "";
             IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
             try
             {
@@ -18374,7 +18384,7 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                 //barcode = oracleTrConn.GetSqlResultToStr(sqlString, paras1);
 
                 OracleParameter[] Paras = null;
-                string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
+                string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, g.materialcode, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
                     " left join tp_pm_inproduction t on t.barcode = g.barcode\n" +
                     "where g.barcode = :barcode";
                 Paras = new OracleParameter[] {
@@ -18384,9 +18394,12 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
                 DataTable dt = oracleTrConn.GetSqlResultToDt(sql, Paras);
                 if (dt == null || dt.Rows.Count == 0)
                 {
+                    returnMessage = "条码不存在";
                     return -2;
                 }
 
+                string oldMatnr = dt.Rows[0]["materialcode"] + "";// 老物料编码
+
                 // 釉料变更履历
                 sql = "insert into TP_PM_GlazetypeRecord\n" +
                 //"values\n" + xuwei update 2020-01-02
@@ -18489,6 +18502,13 @@ updateuserid=:updateuserid where barcode=:barcode";
                     };
                 returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
 
+                // 切换物料,切换已装组件
+                returnRows = SetMatnrIdnrk(oracleTrConn, oldMatnr, barcode, sUserInfo, out returnMessage);
+                if (returnRows < 0)
+                {
+                    return returnRows;
+                }
+
                 oracleTrConn.Commit();
             }
             catch (Exception ex)
@@ -18508,17 +18528,18 @@ updateuserid=:updateuserid where barcode=:barcode";
         /// </summary>
         /// <returns></returns>
         public static int SaveBarCodesLogoAndGlazetype(string barcodesstr, int logoid, int glazetypeid,
-            int procedureID, SUserInfo sUserInfo)
+            int procedureID, SUserInfo sUserInfo, out string returnMessage)
         {
             int returnRows = 0;
+            returnMessage = "";
             IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
             try
             {
                 OracleParameter[] Paras = null;
-                string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
+                string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, g.materialcode, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
                     " left join tp_pm_inproduction t on t.barcode = g.barcode\n" +
                     "where g.barcode = :barcode";
-                string sql0 = "select g.groutingdailydetailid, g.logoid, g.glazetypeid from tp_pm_groutingdailydetail g \n" +
+                string sql0 = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, g.materialcode from tp_pm_groutingdailydetail g \n" +
                     "where g.barcode = :barcode";
                 // 釉料变更履历
                 string sql1 = "insert into TP_PM_GlazetypeRecord\n" +
@@ -18584,12 +18605,15 @@ updateuserid=:updateuserid where barcode=:barcode";
                     {
                         dt = oracleTrConn.GetSqlResultToDt(sql, Paras);
                     }
+
                     if (dt == null || dt.Rows.Count == 0)
                     {
-                        //continue;
+                        returnMessage = "条码不存在";
                         return -2;
                     }
 
+                    string oldMatnr = dt.Rows[0]["materialcode"] + "";// 老物料编码
+
                     Paras = new OracleParameter[] {
                         new OracleParameter(":GROUTINGDAILYDETAILID",OracleDbType.Int32,
                             dt.Rows[0]["GROUTINGDAILYDETAILID"],ParameterDirection.Input),
@@ -18651,6 +18675,13 @@ updateuserid=:updateuserid where barcode=:barcode";
                             barcode,ParameterDirection.Input)
                     };
                     returnRows = oracleTrConn.ExecuteNonQuery(sqlin, Paras);
+
+                    // 切换物料,切换已装组件
+                    returnRows = SetMatnrIdnrk(oracleTrConn, oldMatnr, barcode, sUserInfo, out returnMessage);
+                    if (returnRows < 0)
+                    {
+                        return returnRows;
+                    }
                 }
 
                 oracleTrConn.Commit();
@@ -18674,9 +18705,10 @@ updateuserid=:updateuserid where barcode=:barcode";
         /// <param name="logoid"></param>
         /// <param name="sUserInfo"></param>
         /// <returns></returns>
-        public static int SetFinishedLogo(string[] barcodes, int logoid, SUserInfo sUserInfo)
+        public static int SetFinishedLogo(string[] barcodes, int logoid, SUserInfo sUserInfo, out string returnMessage)
         {
             int returnRows = 0;
+            returnMessage = "";
             IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
             try
             {
@@ -18689,16 +18721,19 @@ updateuserid=:updateuserid where barcode=:barcode";
 
                 foreach (string barcode in barcodes)
                 {
-                    sql = @"select groutingdailydetailid, logoid from tp_pm_groutingdailydetail where barcode=:barcode";
+                    sql = @"select groutingdailydetailid, logoid, g.materialcode from tp_pm_groutingdailydetail where barcode=:barcode";
                     dataTable = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]{
                         new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
                     });
                     if (dataTable == null || dataTable.Rows.Count == 0)
                     {
-                        continue;
+                        //continue;
+                        returnMessage = "条码不存在";
+                        return -2;
                     }
                     gdid = dataTable.Rows[0]["groutingdailydetailid"];
                     oldLogoID = dataTable.Rows[0]["logoid"];
+                    string oldMatnr = dataTable.Rows[0]["materialcode"] + "";// 老物料编码
 
                     // 1.更新注浆明细
                     sql = @"update tp_pm_groutingdailydetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
@@ -18751,6 +18786,13 @@ updateuserid=:updateuserid where barcode=:barcode";
                             barcode,ParameterDirection.Input)
                     };
                     returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
+
+                    // 切换物料,切换已装组件
+                    returnRows = SetMatnrIdnrk(oracleTrConn, oldMatnr, barcode, sUserInfo, out returnMessage);
+                    if (returnRows < 0)
+                    {
+                        return returnRows;
+                    }
                 }
 
                 //if (returnRows == 0)
@@ -26726,5 +26768,344 @@ updateuserid=:updateuserid where barcode=:barcode";
             return returnRows;
         }
 
+        /// <summary>
+        /// 设置物料编码组件
+        /// </summary>
+        /// <returns></returns>
+        private static int SetMatnrIdnrk(IDBTransaction oracleTrConn, string oldMatnr, string barcode, SUserInfo sUserInfo, out string message)
+        {
+            int returnRows = 0;
+            message = "";
+            try
+            {
+                string sql = "";
+                sql = @"
+                SELECT GDD.MATERIALCODE AS MATNR,
+                       DECODE(GDD.TESTMOULDFLAG, 0, 'C', 1, 'Y', '-') AS ZSCMS,
+                       CASE
+                           WHEN (INSTR(GDD.GROUTINGLINECODE, 'A') = 1 OR INSTR(GDD.GROUTINGLINECODE, 'D') = 1)
+                                AND INSTR(GT.GOODSTYPECODE, '001002') = 1 THEN
+                            1
+                           WHEN (INSTR(GDD.GROUTINGLINECODE, 'B') = 1 OR INSTR(GDD.GROUTINGLINECODE, 'D') = 1)
+                                AND INSTR(GT.GOODSTYPECODE, '001001') = 1 THEN
+                            2
+                           WHEN INSTR(GDD.GROUTINGLINECODE, 'C') = 1 THEN
+                            3
+                           ELSE
+                            9
+                       END AS WORKSHOP
+                  FROM TP_PM_GROUTINGDAILYDETAIL GDD
+                 INNER JOIN TP_MST_GOODS G
+                    ON G.GOODSID = GDD.GOODSID
+                 INNER JOIN TP_MST_GOODSTYPE GT
+                    ON GT.GOODSTYPEID = G.GOODSTYPEID
+                 WHERE GDD.BARCODE = :BARCODE ";
+
+                DataTable dtMatnr = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]
+                {
+                    new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input)
+                });
+
+                // 如果物料编码不一致
+                if (!oldMatnr.Equals(dtMatnr.Rows[0]["MATNR"]))
+                {
+                    sql = @"
+                    SELECT IDNRK,
+                           MEINS,
+                           MENGE,
+                           IDNRKNAME,
+                           IDNRKONLYCODE,
+                           CHARG,
+                           LGORT
+                      FROM TP_PM_BARCODEIDNRKREL
+                     WHERE VALUEFLAG = '1'
+                       AND BARCODE = :BARCODE ";
+                    DataTable dtIdnrks = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]
+                    {
+                        new OracleParameter(":BARCODE", OracleDbType.Varchar2, barcode, ParameterDirection.Input)
+                    });
+
+                    // 如果装了配件了
+                    if (dtIdnrks.Rows.Count > 0)
+                    {
+                        string datuv = System.DateTime.Now.Date.ToString("yyyyMMdd");
+
+                        Hashtable pars = new Hashtable();
+                        pars.Add("MATNR", dtMatnr.Rows[0]["MATNR"]);  // 物料
+                        pars.Add("WERKS", "5000");                    // 工厂
+                        pars.Add("ZSCS", "T");                        // 生产工艺
+                        pars.Add("ZSCCJ", dtMatnr.Rows[0]["WORKSHOP"]); // 生产车间
+                        pars.Add("ZSCMS", dtMatnr.Rows[0]["ZSCMS"]);  // 生产模式
+                        pars.Add("ZJDNU", "60");                      // 节点
+                        pars.Add("DATUV", datuv);                     // 查询日期
+                        pars.Add("EMENG", 1);                         // 需求数量
+
+                        Hashtable item = new Hashtable();
+                        item.Add("item", pars);
+
+                        Hashtable body = new Hashtable();
+                        body.Add("T_INPUT", item);
+
+                        string postString = JsonConvert.SerializeObject(body);
+
+                        INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
+                        string url039 = ini.ReadIniData("SAP_NEW_INFO", "Url039");
+                        //string url039 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM039";
+
+                        string result = string.Empty;
+                        try
+                        {
+                            result = SAPDataLogic.PostData(url039, postString, "POST");
+                        }
+                        catch (Exception ex)
+                        {
+                            message = "获取SAP库存接口异常:\n" + ex.Message;
+                            return -4;
+                        }
+
+
+                        JObject returnObj = JsonConvert.DeserializeObject<JObject>(result);
+                        JObject output = returnObj["T_OUTPUT"] as JObject;
+                        JArray array = output["item"] as JArray;
+                        DataTable dtIdnrk = Utility.ConvertToDataTable(array);
+
+                        if ("E".Equals(dtIdnrk.Rows[0]["ZTYPE"] + ""))
+                        {
+                            message = "获取SAP库存失败";
+                            return -5;
+                        }
+
+                        dtIdnrk.DefaultView.RowFilter = "MAKTX NOT LIKE '%半成品%'";
+                        dtIdnrk = dtIdnrk.DefaultView.ToTable();
+
+                        // 获取已走过的装配工序
+                        string procedureidlist = oracleTrConn.GetSqlResultToStr(@"
+                        SELECT LISTAGG(PROCEDUREID, ',') WITHIN GROUP(ORDER BY PROCEDUREID) AS PROCEDUREIDLIST
+                          FROM TP_PM_PRODUCTIONDATA
+                         WHERE VALUEFLAG = '1'
+                           AND MODELTYPE = '-5'
+                           AND BARCODE = :BARCODE ",
+                           new OracleParameter[] { new OracleParameter("BARCODE", barcode) }
+                        );
+                        procedureidlist = "," + procedureidlist + ",";
+
+
+                        // 过滤当前工序需要的组件
+                        DataTable dtIdnrkType = oracleTrConn.GetSqlResultToDt(@"
+                        SELECT IDNRKTYPE
+                          FROM TP_PC_PROCEDUREIDNRKTYPE
+                         WHERE INSTR(:PROCEDUREIDLIST , ',' || PROCEDUREID || ',') > 0",
+                            new OracleParameter[] { new OracleParameter("PROCEDUREIDLIST", procedureidlist) }
+                        );
+
+                        dtIdnrk.DefaultView.RowFilter = "MAKTX NOT LIKE '%半成品%'";
+                        dtIdnrk = dtIdnrk.DefaultView.ToTable();
+
+                        // 如果包含其它,就不判断了
+                        if (dtIdnrkType.Select("IDNRKTYPE = '其它'").Length == 0)
+                        {
+                            string fifter = "";
+                            foreach (DataRow row in dtIdnrkType.Rows)
+                            {
+                                fifter += " MAKTX LIKE '%" + row["IDNRKTYPE"] + "%' OR";
+                            }
+
+                            // 如果没有条件,也不判断了
+                            if (fifter.Length > 0)
+                            {
+                                fifter = fifter.Substring(0, fifter.Length - 2);
+                                dtIdnrk.DefaultView.RowFilter = fifter;
+                                dtIdnrk = dtIdnrk.DefaultView.ToTable();
+                            }
+                        }
+
+                        // 过滤掉已安装的组件
+                        object idnrklist = oracleTrConn.GetSqlResultToStr(@"
+                        SELECT LISTAGG(IDNRK, ''',''') WITHIN GROUP(ORDER BY IDNRK) AS IDNRKLIST
+                          FROM TP_PM_BARCODEIDNRKREL
+                         WHERE VALUEFLAG = '1'
+                           AND BARCODE = :BARCODE ",
+                            new OracleParameter[] { new OracleParameter("BARCODE", barcode) }
+                        );
+
+                        // 可以保留的组件
+                        DataTable dtCanSaveIdnrk = dtIdnrk.Copy();
+                        dtCanSaveIdnrk.DefaultView.RowFilter = "IDNRK IN ('" + idnrklist + "')";
+                        dtCanSaveIdnrk = dtCanSaveIdnrk.DefaultView.ToTable();
+
+                        if (idnrklist != null)
+                        {
+                            dtIdnrk.DefaultView.RowFilter = "IDNRK NOT IN ('" + idnrklist + "')";
+                            dtIdnrk = dtIdnrk.DefaultView.ToTable();
+                        }
+
+                        if (dtIdnrk.Rows.Count == 0)
+                        {
+                        }
+
+                        // 加上需要的列
+                        dtIdnrk.Columns.Add("LGORT", typeof(string));
+                        dtIdnrk.Columns.Add("CHARG", typeof(string));
+                        dtIdnrk.Columns.Add("IDNRKONLYCODE", typeof(string));
+
+                        // 提取包材物料编码
+                        List<string> matnrs = new List<string>();
+                        foreach (DataRow row in dtIdnrk.Rows)
+                        {
+                            if (!matnrs.Contains(row["IDNRK"] + ""))
+                            {
+                                matnrs.Add(row["IDNRK"] + "");
+                            }
+                        }
+
+                        string ZMSG = string.Empty;
+
+                        // 查线边仓库存
+                        DataTable dtSapInventory = SapApi.ZMM_WMS016("5000", matnrs, "", out ZMSG);
+                        dtSapInventory.DefaultView.RowFilter = "LGORT IN('2420','2430','2440','2450','2460','2470','2480','2490')";
+                        dtSapInventory = dtSapInventory.DefaultView.ToTable();
+
+                        DataRow[] rows = null;
+                        if (dtSapInventory != null && dtSapInventory.Rows.Count > 0)
+                        {
+                            // 改名
+                            dtSapInventory.Columns["MATNR"].ColumnName = "IDNRK";
+
+                            // 判断是否缺库存
+                            List<string> notEnoughIdnrks = new List<string>();
+                            foreach (string idnrk in matnrs)
+                            {
+                                rows = dtSapInventory.Select("IDNRK = '" + idnrk + "'"); ;
+                                if (rows.Length == 0)
+                                {
+                                    notEnoughIdnrks.Add(idnrk);
+                                }
+                            }
+
+                            if (notEnoughIdnrks.Count > 0)
+                            {
+                                message = "以下组件在SAP系统中库存不足:\n" + string.Join(",", notEnoughIdnrks.ToArray());
+                                return -6;
+                            }
+
+                            // 库存数量要改为数字类型
+                            dtSapInventory.Columns.Add("BALANCE", typeof(decimal));
+                            decimal balance = 0;
+
+                            foreach (DataRow row in dtSapInventory.Rows)
+                            {
+                                decimal.TryParse(row["KYKC"] + "", out balance);
+                                row["BALANCE"] = balance;
+                            }
+                        }
+                        else
+                        {
+                            message = "以下组件在SAP系统中库存不足:\n" + string.Join(",", matnrs.ToArray());
+                            return -6;
+                        }
+
+                        dtSapInventory.DefaultView.RowFilter = "BALANCE <> 0";
+                        dtSapInventory = dtSapInventory.DefaultView.ToTable();
+
+                        dtSapInventory.DefaultView.Sort = "LGORT, CHARG";
+                        dtSapInventory = dtSapInventory.DefaultView.ToTable();
+
+                        DateTime now = DateTime.Now;
+                        foreach (DataRow row in dtIdnrk.Rows)
+                        {
+                            rows = dtSapInventory.Select("IDNRK = '" + row["IDNRK"] + "' AND BALANCE >= " + row["MENGE"]);
+                            if (rows.Length > 0)
+                            {
+                                row["LGORT"] = rows[0]["LGORT"];
+                                row["CHARG"] = rows[0]["CHARG"];
+                                row["IDNRKONLYCODE"] = "";
+                            }
+                        }
+
+                        dtIdnrk.TableName = "Idnrk";
+                        dtCanSaveIdnrk.TableName = "CanSaveIdnrk";
+
+                        string canSaveIdnrks = ",";
+                        if (dtCanSaveIdnrk != null && dtCanSaveIdnrk.Rows.Count > 0)
+                        {
+                            foreach (DataRow row in dtCanSaveIdnrk.Rows)
+                            {
+                                canSaveIdnrks += row["IDNRK"] + ",";
+                            }
+                        }
+
+                        string delSql = @"
+                        DELETE FROM TP_PM_BARCODEIDNRKREL
+                         WHERE BARCODE = :BARCODE
+                           AND INSTR(:CANSAVEIDNRKS, ','|| IDNRK ||',') = 0 ";
+
+                        returnRows += oracleTrConn.ExecuteNonQuery(delSql, new OracleParameter[]
+                        {
+                            new OracleParameter(":BARCODE", barcode),
+                            new OracleParameter(":CANSAVEIDNRKS", canSaveIdnrks)
+                        });
+
+                        if (dtIdnrk != null && dtIdnrk.Rows.Count > 0)
+                        {
+                            string barcodeidnrkrel = @"
+                            INSERT INTO TP_PM_BARCODEIDNRKREL
+                                    (PROCEDUREID,
+                                     BARCODE,
+                                     MATNR,
+                                     IDNRK,
+                                     MEINS,
+                                     MENGE,
+                                     IDNRKNAME,
+                                     IDNRKONLYCODE,
+                                     CHARG,
+                                     LGORT,
+                                     ACCOUNTID,
+                                     CREATEUSERID,
+                                     UPDATEUSERID)
+                                VALUES
+                                    (:PROCEDUREID,
+                                     :BARCODE,
+                                     :MATNR,
+                                     :IDNRK,
+                                     :MEINS,
+                                     :MENGE,
+                                     :IDNRKNAME,
+                                     :IDNRKONLYCODE,
+                                     :CHARG,
+                                     :LGORT,
+                                     :ACCOUNTID,
+                                     :USERID,
+                                     :USERID) ";
+
+                            foreach (DataRow row in dtIdnrk.Rows)
+                            {
+                                returnRows += oracleTrConn.ExecuteNonQuery(barcodeidnrkrel,
+                                new OracleParameter[]
+                                {
+                                    new OracleParameter(":PROCEDUREID", -1),
+                                    new OracleParameter(":BARCODE", barcode),
+                                    new OracleParameter(":MATNR", row["MATNR"]),
+                                    new OracleParameter(":IDNRK", row["IDNRK"]),
+                                    new OracleParameter(":MEINS", row["MEINS"]),
+                                    new OracleParameter(":MENGE", Convert.ToDecimal( row["MENGE"])),
+                                    new OracleParameter(":IDNRKNAME", row["MAKTX"]),
+                                    new OracleParameter(":IDNRKONLYCODE", row["IDNRKONLYCODE"]),
+                                    new OracleParameter(":CHARG", row["CHARG"]),
+                                    new OracleParameter(":LGORT", row["LGORT"]),
+                                    new OracleParameter(":ACCOUNTID", sUserInfo.AccountID),
+                                    new OracleParameter(":USERID", sUserInfo.UserID)
+                                });
+                            }
+                        }
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                message = "接口异常:\n" + ex.Message;
+                return -4;
+            }
+            return returnRows;
+        }
     }
 }

BIN
DLL/sapnco.dll


BIN
DLL/sapnco.dll.refresh


BIN
DLL/sapnco_utils.dll


+ 17 - 0
WCF.Service/WCF.Hosting/SAP_HEGII.ini

@@ -43,6 +43,7 @@ PackingURL=http://172.18.32.32:9300/api/mes/packing/?matnr=
 Url030=http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM030
 Url033=http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM033
 Url034=http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM034
+Url039=http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM039
 UserName=hgsapdk:Sapdk#240
 Factory=5000
 
@@ -50,5 +51,21 @@ Factory=5000
 #Url030=http://hgs4powd1.hegii.com:8000/RESTAdapter/DKMES/ZPPFM030
 #Url033=http://hgs4powd1.hegii.com:8000/RESTAdapter/DKMES/ZPPFM033
 #Url034=http://hgs4powd1.hegii.com:8000/RESTAdapter/DKMES/ZPPFM034
+#Url039=http://hgs4podev.hegii.com:8000/RESTAdapter/DKMES/ZPPFM039
 #UserName=PODKMES:Sapdk#800
 #Factory=5000
+
+
+[SAP_RFC_INFO]
+SapAppServerHost=S4DEVAPP.hegii.com
+SapSystemNumber=00
+SapUser=hgsapdk
+SapPassword=Sapdk#240
+SapClient=230
+
+
+#SapAppServerHost=S4PRDAPP1.HEGII.COM
+#SapSystemNumber=01
+#SapUser=hgsapdk
+#SapPassword=Prddk209
+#SapClient=800

+ 216 - 210
WCF.Service/WCF.Services/PDAModuleService.cs

@@ -6353,8 +6353,9 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                     return actionResult;
                 }
 
+                string returnMessage = "";
                 int returnValue = ServiceInvoker.Invoke<int>(this,
-                   () => PMModuleLogicDAL.SaveBarCodeLogo(barcode, logoid, sUserInfo));
+                   () => PMModuleLogicDAL.SaveBarCodeLogo(barcode, logoid, sUserInfo, out returnMessage));
                 actionResult.Result = JsonHelper.ToJson(returnValue);
                 if (returnValue > 0)
                 {
@@ -6376,6 +6377,7 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                 }
                 else
                 {
+                    actionResult.Message = returnMessage;
                     actionResult.Status = (int)Constant.PDAResult.Fail;
                 }
             }
@@ -6409,8 +6411,9 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                     return actionResult;
                 }
 
+                string returnMessage = "";
                 int returnValue = ServiceInvoker.Invoke<int>(this,
-                   () => PMModuleLogicDAL.SaveBarCodeLogoAndGlazetype(barcode, logoid, glazetypeid, sUserInfo));
+                   () => PMModuleLogicDAL.SaveBarCodeLogoAndGlazetype(barcode, logoid, glazetypeid, sUserInfo,out returnMessage));
                 actionResult.Result = JsonHelper.ToJson(returnValue);
                 if (returnValue > 0)
                 {
@@ -6419,7 +6422,7 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                 else
                 {
                     actionResult.Status = (int)Constant.PDAResult.Fail;
-                    actionResult.Message = "条码不存在";
+                    actionResult.Message = returnMessage;
                 }
             }
             catch (Exception ex)
@@ -6450,9 +6453,9 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                 {
                     return actionResult;
                 }
-
+                string returnMessage = "";
                 int returnValue = ServiceInvoker.Invoke<int>(this,
-                   () => PMModuleLogicDAL.SaveBarCodesLogoAndGlazetype(barcodes, logoid, glazetypeid, procedureID, sUserInfo));
+                   () => PMModuleLogicDAL.SaveBarCodesLogoAndGlazetype(barcodes, logoid, glazetypeid, procedureID, sUserInfo, out returnMessage));
                 actionResult.Result = JsonHelper.ToJson(returnValue);
                 if (returnValue > 0)
                 {
@@ -6461,7 +6464,7 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                 else
                 {
                     actionResult.Status = (int)Constant.PDAResult.Fail;
-                    actionResult.Message = "条码不存在";
+                    actionResult.Message = returnMessage;
                 }
             }
             catch (Exception ex)
@@ -10080,13 +10083,14 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                 #endregion
 
                 #region 包装装板限制
-                  if (module == "FinishedLoadingCar")
+                if (module == "FinishedLoadingCar")
                 {
                     if (action == "GetSetting")
                     {
                         ClientRequestEntity cre = new ClientRequestEntity();
                         cre.Properties["GoodsID"] = data["GoodsID"];
-                        if (data.ContainsKey("logoID")) {
+                        if (data.ContainsKey("logoID"))
+                        {
                             cre.Properties["logoID"] = data["logoID"] + "";
                         }
                         else
@@ -10652,12 +10656,14 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                         int logoid = Convert.ToInt32(data["logoid"]);
                         string[] barcodes = data["barcodes"].ToString().Split(',');
 
-                        int result = PMModuleLogicDAL.SetFinishedLogo(barcodes, logoid, sUserInfo);
+                        string returnMessage = "";
+                        int result = PMModuleLogicDAL.SetFinishedLogo(barcodes, logoid, sUserInfo,out returnMessage);
 
                         //actionResult.Result = JsonHelper.ToJson(Convert.ToInt32(resultEntity.Result));
                         if (result < 0)
                         {
                             actionResult.Status = (int)Constant.PDAResult.Fail;
+                            actionResult.Message = returnMessage;
                         }
                         else
                         {
@@ -11613,7 +11619,7 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                         int procedureID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["finishedcheckprocedureid"]);
 
 
-                        sre = Service.PCModuleService.FinishedCheckLogic.CheckBarcode(procedureID,barcode,sUserInfo);
+                        sre = Service.PCModuleService.FinishedCheckLogic.CheckBarcode(procedureID, barcode, sUserInfo);
 
 
                         //actionResult.Result = JsonHelper.ToJson(Convert.ToInt32(resultEntity.Result));
@@ -11631,13 +11637,13 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                         }
                         return actionResult;
                     }
-                    
+
                     //撤销查询
                     if (action == "GetFinishedCancleData")
                     {
                         string barcode = data["barcode"] + "";
 
-                        ServiceResultEntity sre = Service.PCModuleService.FinishedCheckLogic.GetFinishedCancleData( barcode, sUserInfo);
+                        ServiceResultEntity sre = Service.PCModuleService.FinishedCheckLogic.GetFinishedCancleData(barcode, sUserInfo);
 
                         //actionResult.Result = JsonHelper.ToJson(Convert.ToInt32(resultEntity.Result));
                         if (Convert.ToInt32(sre.Result) < 0)
@@ -11654,7 +11660,7 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                         }
                         return actionResult;
                     }
-                    
+
                     //保存成品检验
                     if (action == "AddCheckBarcode")
                     {
@@ -11670,206 +11676,206 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                         //DataTable DSTableImage = JsonHelper.FromJson<DataTable>(data["dSTableImage"] + "");
 
                         //ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[TableProductionData.Rows.Count];
-						#region 转换实体
-						//for (int i = 0; i < TableProductionData.Rows.Count; i++)
-						//{
-						//	if (TableProductionData.Rows[i]["ReadOnly"].ToString() == "1") //只读数据不进行保存
-						//	{
-						//		continue;
-						//	}
-
-						//	ProductionDataEntity productionDataEntity = new ProductionDataEntity();
-						//	if (TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
-						//	{
-						//		productionDataEntity.ProductionDataID = Convert.ToInt32(TableProductionData.Rows[i]["ProductionDataID"]);
-						//	}
-						//	productionDataEntity.Barcode = TableProductionData.Rows[i]["BarCode"].ToString();
-						//	productionDataEntity.UserID = sUserInfo.UserID;
-						//	productionDataEntity.UserCode = sUserInfo.UserCode;
-						//	productionDataEntity.UserName = sUserInfo.UserName; ;
-						//	productionDataEntity.DefectFlag = Convert.ToInt32(TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 4 ? 1 : 2;
-						//	productionDataEntity.GoodsLevelID = Convert.ToInt32(TableProductionData.Rows[i]["DefectFlagID"]);
-						//	productionDataEntity.GoodsLevelTypeID = Convert.ToInt32(TableProductionData.Rows[i]["GoodsLevelTypeID"]);
-						//	productionDataEntity.Remarks = TableProductionData.Rows[i]["Remarks"].ToString();
-						//	if (TableProductionData.Rows[i]["LogoID"].ToString() != "")
-						//	{
-						//		productionDataEntity.LogoID = Convert.ToInt32(TableProductionData.Rows[i]["LogoID"]);
-						//	}
-
-						//	if (TableProductionData.Rows[i]["OPTimeStamp"].ToString() != "")
-						//	{
-						//		productionDataEntity.OPTimeStamp = Convert.ToDateTime(TableProductionData.Rows[i]["OPTimeStamp"]);
-						//	}
-
-						//	if (TableProductionData.Rows[i]["CheckTime"].ToString() != "")
-						//	{
-						//		productionDataEntity.CheckTime = Convert.ToDateTime(TableProductionData.Rows[i]["CheckTime"]);
-						//	}
-						//	if (TableProductionData.Rows[i]["OrgGoodsLevelTypeID"].ToString() != "-1")
-						//	{
-						//		productionDataEntity.OrgGoodsLevelTypeID = Convert.ToInt32(TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]);
-						//	}
-						//	if (!string.IsNullOrEmpty(TableProductionData.Rows[i]["ReworkProcedureID"].ToString()))
-						//	{
-						//		productionDataEntity.ReworkProcedureID = int.Parse(TableProductionData.Rows[i]["ReworkProcedureID"].ToString());
-						//		productionDataEntity.IsReworked = 1;
-						//	}
-						//	productionDataEntitys[i] = productionDataEntity;
-
-						//	List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
-						//	ProductionDefectEntity productionDefectEntity = null;
-						//	for (int j = 0; j < productionDefectTable.Rows.Count; j++) //缺陷列表
-						//	{
-						//		productionDefectEntity = new ProductionDefectEntity();
-						//		productionDefectEntity.SpecialDefect = productionDefectTable.Rows[j]["IsOtherDefect"].ToString();
-						//		//if (productionDefectTable.Rows[j]["DefectDeductionID"].ToString() != "-1"
-						//		//    && productionDefectTable.Rows[j]["DefectDeductionID"].ToString() != string.Empty)
-						//		//{
-						//		//    productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(productionDefectTable.Rows[j]["DefectDeductionNum"]);
-						//		//}
-						//		if (!string.IsNullOrEmpty(productionDefectTable.Rows[j]["DefectDeductionNum"] + ""))
-						//		{
-						//			productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(productionDefectTable.Rows[j]["DefectDeductionNum"]);
-						//		}
-						//		productionDefectEntity.ScrapResponFlag = "0";
-						//		productionDefectEntity.DefectID =
-						//			Convert.ToInt32(productionDefectTable.Rows[j]["DefectID"]);
-						//		productionDefectEntity.DefectCode =
-						//			productionDefectTable.Rows[j]["DefectCode"].ToString();
-						//		productionDefectEntity.DefectName =
-						//			productionDefectTable.Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
-						//		productionDefectEntity.DefectPositionID =
-						//			Convert.ToInt32(productionDefectTable.Rows[j]["DefectPositionID"]);
-						//		productionDefectEntity.DefectPositionCode =
-						//			productionDefectTable.Rows[j]["DefectPositionCode"].ToString();
-						//		productionDefectEntity.DefectPositionName =
-						//			productionDefectTable.Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
-						//		productionDefectEntity.DefectProductionDataID =
-						//			Convert.ToInt32(productionDefectTable.Rows[j]["ProductionDataID"] + "");
-
-						//		if (productionDefectEntity.DefectProductionDataID == 0)
-						//		{
-						//			productionDefectEntity.DefectProductionDataID = null;
-						//		}
-						//		if (productionDefectTable.Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
-						//			Convert.ToInt32(productionDefectTable.Rows[j]["DefectProcedureID"] + "") > Constant.INT_IS_ZERO)
-						//		{
-						//			productionDefectEntity.DefectProcedureID =
-						//				Convert.ToInt32(productionDefectTable.Rows[j]["DefectProcedureID"]);
-						//		}
-						//		productionDefectEntity.DefectProcedureCode =
-						//			productionDefectTable.Rows[j]["DefectProcedureCode"].ToString();
-						//		productionDefectEntity.DefectProcedureName =
-						//			productionDefectTable.Rows[j]["DefectProcedureName"].ToString();
-						//		productionDefectEntity.DefectUserID =
-						//			Convert.ToInt32(productionDefectTable.Rows[j]["DefectUserID"]);
-						//		productionDefectEntity.DefectUserCode =
-						//			productionDefectTable.Rows[j]["DefectUserCode"].ToString();
-						//		productionDefectEntity.DefectUserName =
-						//			productionDefectTable.Rows[j]["DefectUserName"].ToString();
-						//		productionDefectEntity.DefectJobs =
-						//			Convert.ToInt32(productionDefectTable.Rows[j]["Jobs"].ToString());
-						//		productionDefectEntity.Remarks =
-						//				productionDefectTable.Rows[j]["DefectRemarks"].ToString();
-						//		productionDefectEntity.Remarks =
-						//				productionDefectTable.Rows[j]["DefectRemarks"].ToString();
-						//		if (productionDefectTable.Rows[j]["DefectFineID"].ToString() != "-1"
-						//			&& productionDefectTable.Rows[j]["DefectFineID"].ToString() != string.Empty)
-						//		{
-						//			productionDefectEntity.DefectFine = Convert.ToInt32(productionDefectTable.Rows[j]["DefectFineID"]);
-						//		}
-
-
-						//		if (productionDefectTable.Rows[j]["CheckTime"].ToString() != string.Empty)
-						//		{
-						//			//if (Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]) == Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]))
-						//			//{
-						//			productionDefectEntity.CheckTime = Convert.ToDateTime(productionDefectTable.Rows[j]["CheckTime"]);
-						//			//}
-
-						//		}
-
-						//		if (productionDefectTable.Rows[j]["MissedUserID"].ToString() != "-1"
-						//			&& productionDefectTable.Rows[j]["MissedUserID"].ToString() != string.Empty)
-						//		{
-						//			productionDefectEntity.MissedUserID = Convert.ToInt32(productionDefectTable.Rows[j]["MissedUserID"]);
-						//			productionDefectEntity.MissedUserCode = productionDefectTable.Rows[j]["MissedUserCode"].ToString();
-						//			productionDefectEntity.MissedUserName = productionDefectTable.Rows[j]["MissedUserName"].ToString();
-						//		}
-						//		// 遍历责任员工
-						//		List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
-						//		if (DSTableStaff != null && DSTableStaff.Rows.Count > 0)
-						//		{
-						//			DefectResponsibleEntity defectResponsibleEntity = null; 
-						//			foreach (DataRow drStaff in DSTableStaff.Rows)
-						//			{
-						//				if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
-						//				{
-						//					defectResponsibleEntity = new DefectResponsibleEntity();
-						//					defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
-						//					defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
-						//					defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
-						//					defectResponsibleEntity.UJobsID =
-						//						Convert.ToInt32(productionDefectTable.Rows[j]["Jobs"].ToString());
-						//					defectResponsibleEntity.SJobsID =
-						//						Convert.ToInt32(productionDefectTable.Rows[j]["Jobs"].ToString());
-						//					defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
-						//					DefectResponsibles.Add(defectResponsibleEntity);
-						//				}
-						//			}
-						//			//productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
-						//			productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
-						//		} 
-						//		// 遍历漏检责任员工
-						//		List<DefectMissedResponsibleEntity> DefectMissedResponsibles = new List<DefectMissedResponsibleEntity>();
-      //                          if (DSTableMissedStaff != null && DSTableMissedStaff.Rows.Count > 0)
-      //                          {
-      //                              DefectMissedResponsibleEntity defectMissedResponsibleEntity = null; 
-						//			foreach (DataRow drStaff in DSTableMissedStaff.Rows)
-						//			{
-						//				if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
-						//				{
-						//					defectMissedResponsibleEntity = new DefectMissedResponsibleEntity();
-						//					defectMissedResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
-						//					defectMissedResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
-						//					defectMissedResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
-						//					defectMissedResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
-						//					defectMissedResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
-						//					defectMissedResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
-						//					DefectMissedResponsibles.Add(defectMissedResponsibleEntity);
-						//				}
-						//			}
-						//			//productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles.ToArray();
-						//			productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles;
-						//		}
-      //                          // 遍历缺陷图片
-      //                          if (DSTableImage != null && DSTableImage.Rows.Count > 0)
-      //                          {
-
-      //                              List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
-						//			DefectImageEntity defectImageEntity = null; 
-						//			foreach (DataRow drImage in DSTableImage.Rows)
-						//			{
-						//				defectImageEntity = new DefectImageEntity();
-						//				defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
-						//				defectImageEntity.Image = (byte[])drImage["orgImageByte"];
-						//				defectImageEntitys.Add(defectImageEntity);
-						//			} 
-						//			productionDefectEntity.DefectImages = defectImageEntitys;
-						//		}
-						//		productionDefectEntitys.Add(productionDefectEntity);
-						//	} 
-						//	productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
-						//	}
-							#endregion
-
-						ProductionDataEntity[] productionDataEntitys = JsonHelper.FromJson<ProductionDataEntity[]>(data["productionDataEntitys"] + "");
-
-					    DataTable bomDetailTable = new DataTable();
+                        #region 转换实体
+                        //for (int i = 0; i < TableProductionData.Rows.Count; i++)
+                        //{
+                        //	if (TableProductionData.Rows[i]["ReadOnly"].ToString() == "1") //只读数据不进行保存
+                        //	{
+                        //		continue;
+                        //	}
+
+                        //	ProductionDataEntity productionDataEntity = new ProductionDataEntity();
+                        //	if (TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
+                        //	{
+                        //		productionDataEntity.ProductionDataID = Convert.ToInt32(TableProductionData.Rows[i]["ProductionDataID"]);
+                        //	}
+                        //	productionDataEntity.Barcode = TableProductionData.Rows[i]["BarCode"].ToString();
+                        //	productionDataEntity.UserID = sUserInfo.UserID;
+                        //	productionDataEntity.UserCode = sUserInfo.UserCode;
+                        //	productionDataEntity.UserName = sUserInfo.UserName; ;
+                        //	productionDataEntity.DefectFlag = Convert.ToInt32(TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 4 ? 1 : 2;
+                        //	productionDataEntity.GoodsLevelID = Convert.ToInt32(TableProductionData.Rows[i]["DefectFlagID"]);
+                        //	productionDataEntity.GoodsLevelTypeID = Convert.ToInt32(TableProductionData.Rows[i]["GoodsLevelTypeID"]);
+                        //	productionDataEntity.Remarks = TableProductionData.Rows[i]["Remarks"].ToString();
+                        //	if (TableProductionData.Rows[i]["LogoID"].ToString() != "")
+                        //	{
+                        //		productionDataEntity.LogoID = Convert.ToInt32(TableProductionData.Rows[i]["LogoID"]);
+                        //	}
+
+                        //	if (TableProductionData.Rows[i]["OPTimeStamp"].ToString() != "")
+                        //	{
+                        //		productionDataEntity.OPTimeStamp = Convert.ToDateTime(TableProductionData.Rows[i]["OPTimeStamp"]);
+                        //	}
+
+                        //	if (TableProductionData.Rows[i]["CheckTime"].ToString() != "")
+                        //	{
+                        //		productionDataEntity.CheckTime = Convert.ToDateTime(TableProductionData.Rows[i]["CheckTime"]);
+                        //	}
+                        //	if (TableProductionData.Rows[i]["OrgGoodsLevelTypeID"].ToString() != "-1")
+                        //	{
+                        //		productionDataEntity.OrgGoodsLevelTypeID = Convert.ToInt32(TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]);
+                        //	}
+                        //	if (!string.IsNullOrEmpty(TableProductionData.Rows[i]["ReworkProcedureID"].ToString()))
+                        //	{
+                        //		productionDataEntity.ReworkProcedureID = int.Parse(TableProductionData.Rows[i]["ReworkProcedureID"].ToString());
+                        //		productionDataEntity.IsReworked = 1;
+                        //	}
+                        //	productionDataEntitys[i] = productionDataEntity;
+
+                        //	List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
+                        //	ProductionDefectEntity productionDefectEntity = null;
+                        //	for (int j = 0; j < productionDefectTable.Rows.Count; j++) //缺陷列表
+                        //	{
+                        //		productionDefectEntity = new ProductionDefectEntity();
+                        //		productionDefectEntity.SpecialDefect = productionDefectTable.Rows[j]["IsOtherDefect"].ToString();
+                        //		//if (productionDefectTable.Rows[j]["DefectDeductionID"].ToString() != "-1"
+                        //		//    && productionDefectTable.Rows[j]["DefectDeductionID"].ToString() != string.Empty)
+                        //		//{
+                        //		//    productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(productionDefectTable.Rows[j]["DefectDeductionNum"]);
+                        //		//}
+                        //		if (!string.IsNullOrEmpty(productionDefectTable.Rows[j]["DefectDeductionNum"] + ""))
+                        //		{
+                        //			productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(productionDefectTable.Rows[j]["DefectDeductionNum"]);
+                        //		}
+                        //		productionDefectEntity.ScrapResponFlag = "0";
+                        //		productionDefectEntity.DefectID =
+                        //			Convert.ToInt32(productionDefectTable.Rows[j]["DefectID"]);
+                        //		productionDefectEntity.DefectCode =
+                        //			productionDefectTable.Rows[j]["DefectCode"].ToString();
+                        //		productionDefectEntity.DefectName =
+                        //			productionDefectTable.Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
+                        //		productionDefectEntity.DefectPositionID =
+                        //			Convert.ToInt32(productionDefectTable.Rows[j]["DefectPositionID"]);
+                        //		productionDefectEntity.DefectPositionCode =
+                        //			productionDefectTable.Rows[j]["DefectPositionCode"].ToString();
+                        //		productionDefectEntity.DefectPositionName =
+                        //			productionDefectTable.Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
+                        //		productionDefectEntity.DefectProductionDataID =
+                        //			Convert.ToInt32(productionDefectTable.Rows[j]["ProductionDataID"] + "");
+
+                        //		if (productionDefectEntity.DefectProductionDataID == 0)
+                        //		{
+                        //			productionDefectEntity.DefectProductionDataID = null;
+                        //		}
+                        //		if (productionDefectTable.Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
+                        //			Convert.ToInt32(productionDefectTable.Rows[j]["DefectProcedureID"] + "") > Constant.INT_IS_ZERO)
+                        //		{
+                        //			productionDefectEntity.DefectProcedureID =
+                        //				Convert.ToInt32(productionDefectTable.Rows[j]["DefectProcedureID"]);
+                        //		}
+                        //		productionDefectEntity.DefectProcedureCode =
+                        //			productionDefectTable.Rows[j]["DefectProcedureCode"].ToString();
+                        //		productionDefectEntity.DefectProcedureName =
+                        //			productionDefectTable.Rows[j]["DefectProcedureName"].ToString();
+                        //		productionDefectEntity.DefectUserID =
+                        //			Convert.ToInt32(productionDefectTable.Rows[j]["DefectUserID"]);
+                        //		productionDefectEntity.DefectUserCode =
+                        //			productionDefectTable.Rows[j]["DefectUserCode"].ToString();
+                        //		productionDefectEntity.DefectUserName =
+                        //			productionDefectTable.Rows[j]["DefectUserName"].ToString();
+                        //		productionDefectEntity.DefectJobs =
+                        //			Convert.ToInt32(productionDefectTable.Rows[j]["Jobs"].ToString());
+                        //		productionDefectEntity.Remarks =
+                        //				productionDefectTable.Rows[j]["DefectRemarks"].ToString();
+                        //		productionDefectEntity.Remarks =
+                        //				productionDefectTable.Rows[j]["DefectRemarks"].ToString();
+                        //		if (productionDefectTable.Rows[j]["DefectFineID"].ToString() != "-1"
+                        //			&& productionDefectTable.Rows[j]["DefectFineID"].ToString() != string.Empty)
+                        //		{
+                        //			productionDefectEntity.DefectFine = Convert.ToInt32(productionDefectTable.Rows[j]["DefectFineID"]);
+                        //		}
+
+
+                        //		if (productionDefectTable.Rows[j]["CheckTime"].ToString() != string.Empty)
+                        //		{
+                        //			//if (Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]) == Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]))
+                        //			//{
+                        //			productionDefectEntity.CheckTime = Convert.ToDateTime(productionDefectTable.Rows[j]["CheckTime"]);
+                        //			//}
+
+                        //		}
+
+                        //		if (productionDefectTable.Rows[j]["MissedUserID"].ToString() != "-1"
+                        //			&& productionDefectTable.Rows[j]["MissedUserID"].ToString() != string.Empty)
+                        //		{
+                        //			productionDefectEntity.MissedUserID = Convert.ToInt32(productionDefectTable.Rows[j]["MissedUserID"]);
+                        //			productionDefectEntity.MissedUserCode = productionDefectTable.Rows[j]["MissedUserCode"].ToString();
+                        //			productionDefectEntity.MissedUserName = productionDefectTable.Rows[j]["MissedUserName"].ToString();
+                        //		}
+                        //		// 遍历责任员工
+                        //		List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
+                        //		if (DSTableStaff != null && DSTableStaff.Rows.Count > 0)
+                        //		{
+                        //			DefectResponsibleEntity defectResponsibleEntity = null; 
+                        //			foreach (DataRow drStaff in DSTableStaff.Rows)
+                        //			{
+                        //				if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
+                        //				{
+                        //					defectResponsibleEntity = new DefectResponsibleEntity();
+                        //					defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
+                        //					defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
+                        //					defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
+                        //					defectResponsibleEntity.UJobsID =
+                        //						Convert.ToInt32(productionDefectTable.Rows[j]["Jobs"].ToString());
+                        //					defectResponsibleEntity.SJobsID =
+                        //						Convert.ToInt32(productionDefectTable.Rows[j]["Jobs"].ToString());
+                        //					defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
+                        //					DefectResponsibles.Add(defectResponsibleEntity);
+                        //				}
+                        //			}
+                        //			//productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
+                        //			productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
+                        //		} 
+                        //		// 遍历漏检责任员工
+                        //		List<DefectMissedResponsibleEntity> DefectMissedResponsibles = new List<DefectMissedResponsibleEntity>();
+                        //                          if (DSTableMissedStaff != null && DSTableMissedStaff.Rows.Count > 0)
+                        //                          {
+                        //                              DefectMissedResponsibleEntity defectMissedResponsibleEntity = null; 
+                        //			foreach (DataRow drStaff in DSTableMissedStaff.Rows)
+                        //			{
+                        //				if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
+                        //				{
+                        //					defectMissedResponsibleEntity = new DefectMissedResponsibleEntity();
+                        //					defectMissedResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
+                        //					defectMissedResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
+                        //					defectMissedResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
+                        //					defectMissedResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
+                        //					defectMissedResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
+                        //					defectMissedResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
+                        //					DefectMissedResponsibles.Add(defectMissedResponsibleEntity);
+                        //				}
+                        //			}
+                        //			//productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles.ToArray();
+                        //			productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles;
+                        //		}
+                        //                          // 遍历缺陷图片
+                        //                          if (DSTableImage != null && DSTableImage.Rows.Count > 0)
+                        //                          {
+
+                        //                              List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
+                        //			DefectImageEntity defectImageEntity = null; 
+                        //			foreach (DataRow drImage in DSTableImage.Rows)
+                        //			{
+                        //				defectImageEntity = new DefectImageEntity();
+                        //				defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
+                        //				defectImageEntity.Image = (byte[])drImage["orgImageByte"];
+                        //				defectImageEntitys.Add(defectImageEntity);
+                        //			} 
+                        //			productionDefectEntity.DefectImages = defectImageEntitys;
+                        //		}
+                        //		productionDefectEntitys.Add(productionDefectEntity);
+                        //	} 
+                        //	productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
+                        //	}
+                        #endregion
+
+                        ProductionDataEntity[] productionDataEntitys = JsonHelper.FromJson<ProductionDataEntity[]>(data["productionDataEntitys"] + "");
+
+                        DataTable bomDetailTable = new DataTable();
 
                         if (data["bomDetailTable"] != null)
                         {
-                            bomDetailTable = JsonHelper.FromJson<DataTable>(data["bomDetailTable"]+"");
+                            bomDetailTable = JsonHelper.FromJson<DataTable>(data["bomDetailTable"] + "");
                         }
                         ServiceResultEntity sre = Service.PCModuleService.FinishedCheckLogic.AddCheckBarcode(procedureID, productionDataEntitys, bomDetailTable, sUserInfo);
 

+ 1 - 1
WCF.Service/WCF.Services/PMModuleService.cs

@@ -1413,7 +1413,7 @@ namespace Dongke.IBOSS.PRD.WCF.Services
 
         public int SaveBarCodeLogo(string barcode, int logoid)
         {
-            return ServiceInvoker.Invoke<int>(this, () => PMModuleLogicDAL.SaveBarCodeLogo(barcode, logoid, SUserInfo));
+            return ServiceInvoker.Invoke<int>(this, () => PMModuleLogicDAL.SaveBarCodeLogo(barcode, logoid, SUserInfo, out string retnrnMessage));
         }
 
         public DataSet GetBarCodeLogoID(string barcode)

+ 3 - 1
WCF.Service/WCF.Services/PMModuleServiceNew.cs

@@ -480,9 +480,11 @@ namespace Dongke.IBOSS.PRD.WCF.Services
                         ServiceResultEntity sre = new ServiceResultEntity();
                         string[] barcodes = (cre.Properties["Barcodes"] + "").Split(',');
                         int logoID = Convert.ToInt32(cre.Properties["LogoID"] + "");
+                        string returnMessage = "";
 
                         sre.Result = ServiceInvoker.Invoke(this, () =>
-                            Service.PMModuleLogic.PMModuleLogicDAL.SetFinishedLogo(barcodes, logoID, SUserInfo));
+                            Service.PMModuleLogic.PMModuleLogicDAL.SetFinishedLogo(barcodes, logoID, SUserInfo, out returnMessage));
+                        sre.Message = returnMessage;
                         return sre;
                     }
                 }