baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>GXWebApi</RootNamespace>
|
||||
<AssemblyName>GXWebApi</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
<Use64BitIISExpress />
|
||||
<IISUrl>http://localhost:8080/</IISUrl>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\GuangFu.StringTracing\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\GuangFu.StringTracing\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Program Files (x86)\OPSOFT\OPSOFTV60\AP\BIN\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Kingdee.BOS.WebApi.Client">
|
||||
<HintPath>Kingdee.BOS.WebApi.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Spire.XLS.Wpf">
|
||||
<HintPath>Spire.XLS.Wpf.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Spire.XLS.Wpf, Version=7.12.39.14240, Culture=neutral, PublicKeyToken=663f351905198cb3, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Program Files (x86)\OPSOFT\OPSOFTV60\Spire.XLS.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.Web.Cors">
|
||||
<HintPath>packages\Microsoft.AspNet.Cors.5.2.7\lib\net45\System.Web.Cors.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Http">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.Cors">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Cors.5.2.7\lib\net45\System.Web.Http.Cors.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Common\CrmApi.cs" />
|
||||
<Compile Include="Common\DBHelpe.cs" />
|
||||
<Compile Include="Common\ExcelHelper.cs" />
|
||||
<Compile Include="Common\Extensions.cs" />
|
||||
<Compile Include="Common\LogHelper.cs" />
|
||||
<Compile Include="Common\MySqlUtils.cs" />
|
||||
<Compile Include="Common\ResponseStatus.cs" />
|
||||
<Compile Include="Common\WmsCommonFunction.cs" />
|
||||
<Compile Include="Controllers\AuthController.cs" />
|
||||
<Compile Include="Controllers\DifferentialController.cs" />
|
||||
<Compile Include="Controllers\ProcurementController.cs" />
|
||||
<Compile Include="Controllers\DeliverController.cs" />
|
||||
<Compile Include="Controllers\MesController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="crm_sale_order_sync.html" />
|
||||
<Content Include="delivery_dashboard.html" />
|
||||
<Content Include="delivery_dashboard_L21.html" />
|
||||
<Content Include="delivery_dashboard_L22.html" />
|
||||
<Content Include="delivery_dashboard_L31.html" />
|
||||
<Content Include="delivery_dashboard_L32.html" />
|
||||
<Content Include="delivery_dashboard_noorder2.html" />
|
||||
<Content Include="delivery_dashboard_noorder3.html" />
|
||||
<Content Include="delivery_dashboard_noorder4.html" />
|
||||
<Content Include="Global.asax" />
|
||||
<Content Include="home.html" />
|
||||
<Content Include="Images\idc_Eng.jpg" />
|
||||
<Content Include="login.html" />
|
||||
<Content Include="index.html" />
|
||||
<Content Include="procurement.html" />
|
||||
<Content Include="procurement_audit_leadtime.html" />
|
||||
<Content Include="procurement_audit_leadtime_l2.html" />
|
||||
<Content Include="procurement_audit_leadtime_l3.html" />
|
||||
<Content Include="procurement_audit_receive_l2.html" />
|
||||
<Content Include="procurement_audit_receive_l3.html" />
|
||||
<Content Include="procurement_board_list.html" />
|
||||
<Content Include="procurement_dashboard.html" />
|
||||
<Content Include="procurement_dashboard_detail.html" />
|
||||
<Content Include="procurement_dashboard_detail_items.html" />
|
||||
<Content Include="procurement_dashboard_level4.html" />
|
||||
<Content Include="procurement_detail.html" />
|
||||
<Content Include="dashboard.html" />
|
||||
<Content Include="dashboard_detail.html" />
|
||||
<Content Include="multi_detail.html" />
|
||||
<Content Include="View\common\grid.css" />
|
||||
<Content Include="View\common\grid.js" />
|
||||
<Content Include="View\Delivery\delivery_dashboard.html" />
|
||||
<Content Include="View\Delivery\delivery_dashboard_risk.html" />
|
||||
<Content Include="View\Delivery\production_delivery.html" />
|
||||
<Content Include="View\Delivery\schedule_board.html" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="log4net.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="View\MES\mes_dashboard.html" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="View\Delivery\bom_master.html" />
|
||||
<Content Include="View\Delivery\schedule.html" />
|
||||
<Content Include="View\Delivery\material_delivery.html" />
|
||||
<Content Include="View\Delivery\delivery_board.html" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="View\common\nav.js" />
|
||||
<Content Include="View\common\nav.css" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>8080</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:8080/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
@@ -0,0 +1,122 @@
|
||||
using GXWebApi.Common;
|
||||
using log4net;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace GXWebApi.Controllers
|
||||
{
|
||||
public class AuthController : ApiController
|
||||
{
|
||||
private static readonly ILog Logger = LogManager.GetLogger(typeof(AuthController));
|
||||
|
||||
/// <summary>
|
||||
/// 登录验证
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public IHttpActionResult Login([FromBody] JObject obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
string userId = obj["userId"]?.ToString() ?? "";
|
||||
string password = obj["password"]?.ToString() ?? "";
|
||||
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
return Ok(new { success = false, message = "用户名不能为空" });
|
||||
|
||||
DBHelpe db = new DBHelpe();
|
||||
DataTable dt = db.ExecuteTable($@"
|
||||
SELECT S.USER_ID, S.USER_NAME, S.GX_PASSWORD
|
||||
FROM SYS_LOGINUSER S
|
||||
WHERE S.USER_ID = '{userId.Replace("'", "''")}'");
|
||||
|
||||
if (dt.Rows.Count == 0)
|
||||
return Ok(new { success = false, message = "用户不存在" });
|
||||
|
||||
DataRow row = dt.Rows[0];
|
||||
string dbPassword = row["GX_PASSWORD"].ToStringEx();
|
||||
string userName = row["USER_NAME"].ToStringEx();
|
||||
|
||||
if (dbPassword != password)
|
||||
return Ok(new { success = false, message = "密码错误" });
|
||||
|
||||
// 查询角色
|
||||
DataTable dtRole = db.ExecuteTable($@"
|
||||
SELECT S2.FROLENAME, S2.FROLENUMBER
|
||||
FROM SYS_USERROLERELATION S1
|
||||
LEFT JOIN SYS_USERROLE S2 ON S1.FROLEID = S2.FROLENUMBER
|
||||
WHERE S1.USER_ID = '{userId.Replace("'", "''")}'");
|
||||
|
||||
List<string> roles = new List<string>();
|
||||
List<Dictionary<string, object>> roleList = new List<Dictionary<string, object>>();
|
||||
foreach (DataRow r in dtRole.Rows)
|
||||
{
|
||||
string roleNo = r["FROLENUMBER"].ToStringEx();
|
||||
string roleName = r["FROLENAME"].ToStringEx();
|
||||
roles.Add(roleNo);
|
||||
roleList.Add(new Dictionary<string, object>
|
||||
{
|
||||
["roleNumber"] = roleNo,
|
||||
["roleName"] = roleName
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = true,
|
||||
message = "登录成功",
|
||||
data = new
|
||||
{
|
||||
userId = userId,
|
||||
userName = userName,
|
||||
roles = roleList,
|
||||
roleNumbers = roles
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("登录异常:", ex);
|
||||
return Ok(new { success = false, message = "登录异常:" + ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改密码
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public IHttpActionResult ChangePassword([FromBody] JObject obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
string userId = obj["userId"]?.ToString() ?? "";
|
||||
string oldPwd = obj["oldPassword"]?.ToString() ?? "";
|
||||
string newPwd = obj["newPassword"]?.ToString() ?? "";
|
||||
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
return Ok(new { success = false, message = "用户名不能为空" });
|
||||
|
||||
DBHelpe db = new DBHelpe();
|
||||
DataTable dt = db.ExecuteTable($"SELECT GX_PASSWORD FROM SYS_LOGINUSER WHERE USER_ID = '{userId.Replace("'", "''")}'");
|
||||
|
||||
if (dt.Rows.Count == 0)
|
||||
return Ok(new { success = false, message = "用户不存在" });
|
||||
|
||||
string dbPwd = dt.Rows[0]["GX_PASSWORD"].ToStringEx();
|
||||
if (dbPwd != oldPwd)
|
||||
return Ok(new { success = false, message = "原密码错误" });
|
||||
|
||||
db.ExecuteNonQuery($"UPDATE SYS_LOGINUSER SET GX_PASSWORD = '{newPwd.Replace("'", "''")}' WHERE USER_ID = '{userId.Replace("'", "''")}'");
|
||||
|
||||
return Ok(new { success = true, message = "密码修改成功" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("修改密码异常:", ex);
|
||||
return Ok(new { success = false, message = "修改密码异常:" + ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
using GXWebApi.Common;
|
||||
using Kingdee.BOS.WebApi.Client;
|
||||
using log4net;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Web.Http;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GXWebApi.Controllers
|
||||
{
|
||||
public class DifferentialController : ApiController
|
||||
{
|
||||
private static readonly ILog Logger = LogManager.GetLogger(typeof(DifferentialController));
|
||||
|
||||
// TODO: 在此添加金蝶云星空相关的 Action 方法
|
||||
// 示例:
|
||||
[HttpGet]
|
||||
public IHttpActionResult Test()
|
||||
{
|
||||
return Ok("GXWebApi is running.");
|
||||
}
|
||||
|
||||
#region 单独更新创建CRM产品
|
||||
[HttpPost]
|
||||
public IHttpActionResult CrUpCrmProduct([FromBody] JObject obj)
|
||||
{
|
||||
#region 定义参数
|
||||
string FMaNumber = obj["FMaNumber"].ToString();
|
||||
K3CloudApiClient client = null;
|
||||
string acctID = "20191111204222978"; //登录帐套ID
|
||||
string userID = "sysmes"; //用户账号
|
||||
string password = "Admin@123"; //用户密码
|
||||
string erpURL = "https://gaoxian.ik3cloud.com/k3cloud/"; //K3URL
|
||||
int erpLaType = 2052; //语言种类4
|
||||
|
||||
#endregion
|
||||
|
||||
try
|
||||
{
|
||||
//第一步,登录金蝶系统
|
||||
client = new K3CloudApiClient(erpURL);
|
||||
var loginResult = client.ValidateLogin(acctID, userID, password, erpLaType);
|
||||
var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
|
||||
if (resultType == 1)
|
||||
{
|
||||
//ERP接口Json
|
||||
JObject QueryData = new JObject()
|
||||
{
|
||||
{ "FormId", "BD_MATERIAL" },
|
||||
{ "FieldKeys", "" } ,
|
||||
{ "OrderString", "" },
|
||||
{ "FilterString", "" } ,
|
||||
{ "TopRowCount", 0 },
|
||||
{ "StartRow", 0 } ,
|
||||
{ "Limit", 5000 }
|
||||
};
|
||||
QueryData["FieldKeys"] = "FMATERIALID,FNumber,FName,FUSEORGID.FNUMBER,FTaxRateId.FNumber,FSpecification,FForbidStatus,FIsEnable";
|
||||
QueryData["OrderString"] = "FMATERIALID";
|
||||
QueryData["FilterString"] = $" FDOCUMENTSTATUS = 'C' and FUSEORGID = '1' and FInvPtyId=10003 and FNumber = '{FMaNumber}' ";
|
||||
var QueryList = client.ExecuteBillQuery(QueryData.ToString());
|
||||
if (QueryList != null && QueryList.Count > 0)
|
||||
{
|
||||
|
||||
string firstCellValue = QueryList[0][0].ToStringEx();
|
||||
try
|
||||
{
|
||||
JToken returnToken = JToken.Parse(firstCellValue);
|
||||
if (returnToken is JObject returnInfo && returnInfo.TryGetValue("Result", out JToken VALUE))
|
||||
{
|
||||
//LogHelper.WriteLog(returnInfo["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToStringEx());//写入错误日志中(2021/10/12,经测试此代码暂时无法写入日志)
|
||||
throw new Exception(returnInfo["Result"]["ResponseStatus"]["Errors"][0]["Message"].ToStringEx());//提示错误信息,并中止此次调用
|
||||
}
|
||||
}
|
||||
catch (JsonReaderException)
|
||||
{
|
||||
// firstCellValue 不是 JSON 格式,说明是正常的查询结果数据,跳过错误检查
|
||||
}
|
||||
|
||||
foreach (var sub in QueryList)
|
||||
{
|
||||
#region 获取金蝶字段信息
|
||||
CrmApi crmApi = new CrmApi();
|
||||
string MaterialID = sub[0].ToStringEx(); //物料内码
|
||||
string MaterialNumber = sub[1].ToStringEx(); //物料内码
|
||||
string MaterialName = sub[2].ToStringEx().Replace("\0", "").Replace(@"\u0000", ""); //物料名称
|
||||
string OrgNumber = sub[3].ToStringEx(); //使用组织编码
|
||||
string FTAXRATEID = sub[4].ToStringEx(); //税率
|
||||
string FITEMMODEL = sub[5].ToStringEx(); //规格型号
|
||||
string FForbidStatus = sub[6].ToStringEx().Equals("A") ? "1" : "2"; //禁用状态
|
||||
bool FIsEnable = Convert.ToBoolean(sub[7]); //是否启用BOM版本
|
||||
if (FITEMMODEL.Length > 200)
|
||||
{
|
||||
FITEMMODEL = FITEMMODEL.Substring(0, 199);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取Token
|
||||
string SelSQL = "select id from productCategory where code__c ='" + MaterialNumber + "' ";
|
||||
string Token = crmApi.GetToken();
|
||||
if (string.IsNullOrEmpty(Token))
|
||||
{
|
||||
throw new Exception("获取CRM Token失败!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 产品(物料)
|
||||
|
||||
string SelData = string.Empty;
|
||||
|
||||
#region 获取税率
|
||||
SelSQL = "select id from taxRate__c where code__c = '" + FTAXRATEID + "'";
|
||||
SelData = crmApi.SelectSQLApi(SelSQL, Token);
|
||||
SelSQLData TAXRATEData = JsonConvert.DeserializeObject<SelSQLData>(SelData);
|
||||
int TAXRATECount = TAXRATEData.result.count;
|
||||
string TAXRATEID = string.Empty;
|
||||
if (TAXRATECount > 0)
|
||||
{
|
||||
List<Dictionary<string, object>> keys = TAXRATEData.result.records;
|
||||
TAXRATEID = keys[0]["id"].ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 判断是否已有
|
||||
string ProductID = string.Empty;
|
||||
SelSQL = "select id from product where productName ='" + MaterialNumber + "' ";
|
||||
SelData = crmApi.SelectSQLApi(SelSQL, Token);
|
||||
SelSQLData selSQLData2 = JsonConvert.DeserializeObject<SelSQLData>(SelData);
|
||||
int count2 = selSQLData2.result.count;
|
||||
|
||||
ProductRoot productRoot = new ProductRoot();
|
||||
ProductData productData = new ProductData();
|
||||
productData.entityType = "11010000400001";
|
||||
productData.customItem168__c = MaterialID;
|
||||
productData.productName = MaterialNumber;
|
||||
productData.customItem161__c = MaterialName;
|
||||
productData.fscProductModel = FITEMMODEL;
|
||||
productData.enableStatus = FForbidStatus;//禁用状态
|
||||
productData.defaultTaxRate__c = TAXRATEID;
|
||||
productData.baseUnitId = "4084356036024971"; //PCS
|
||||
productData.parentId = "4084144016153157";//产品目录
|
||||
productData.isActiveBom__c = FIsEnable;//是否启用BOM版本 1:是;0:否
|
||||
productRoot.data = productData;
|
||||
|
||||
if (count2 <= 0)
|
||||
{
|
||||
#region 创建
|
||||
string CproductReturnData = crmApi.CreateApi("product", Token, JsonConvert.SerializeObject(productRoot));
|
||||
CreateReturnData createReturnData = JsonConvert.DeserializeObject<CreateReturnData>(CproductReturnData);
|
||||
if (!createReturnData.code.Equals("200"))
|
||||
{
|
||||
throw new Exception("返回值:" + createReturnData.code + ",创建CRM产品失败:" + createReturnData.msg + "接口传入JSON:" + JsonConvert.SerializeObject(productRoot));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
#region 更新
|
||||
string F_PATC_Text_qtr = selSQLData2.result.records[0]["id"].ToString();
|
||||
string ReturnData = crmApi.UpdateApi("product", F_PATC_Text_qtr, Token, JsonConvert.SerializeObject(productRoot));
|
||||
CreateReturnData createReturnData = JsonConvert.DeserializeObject<CreateReturnData>(ReturnData);
|
||||
if (!createReturnData.code.Equals("200"))
|
||||
{
|
||||
throw new Exception("返回值:" + createReturnData.code + ",更新CRM产品失败:" + createReturnData.msg + "接口传入JSON:" + JsonConvert.SerializeObject(productRoot));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("未找到当前物料信息!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("登录云星空失败!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
success = "false",
|
||||
message = "同步失败:" + ex.Message
|
||||
});
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
success = "true",
|
||||
message = "同步成功"
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据OA费用报销单更新金蝶付款申请单部门字段
|
||||
[HttpPost]
|
||||
public IHttpActionResult UpKingdeeDept([FromBody] JObject obj)
|
||||
{
|
||||
#region 变量
|
||||
string RequestID = string.Empty;
|
||||
MySqlUtils mySqlUtils = new MySqlUtils();
|
||||
string SQL = string.Empty;
|
||||
DataTable dt = new DataTable(), dt1 = new DataTable();
|
||||
K3CloudApiClient client = null;
|
||||
string FID = string.Empty;
|
||||
#endregion
|
||||
|
||||
try
|
||||
{
|
||||
#region 检验参数
|
||||
if (obj == null || obj.Property("RequestID") == null)
|
||||
{
|
||||
throw new Exception("请检查是否传参 RequestID!");
|
||||
}
|
||||
RequestID = obj["RequestID"].ToString();
|
||||
if (RequestID.Equals(""))
|
||||
{
|
||||
throw new Exception("请检查传参是否正确!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 定义参数
|
||||
string acctID = "20191111204222978"; //登录帐套ID
|
||||
string userID = "sysmes"; //用户账号
|
||||
string password = "Admin@123"; //用户密码
|
||||
string erpURL = "https://gaoxian.ik3cloud.com/k3cloud/"; //K3URL
|
||||
//string erpDB = PBCursor["K3DB"].ToString(); //K3 账套 -- 公有云,不再支持金蝶帐套
|
||||
int erpLaType = 2052; //语言种类4
|
||||
#endregion
|
||||
|
||||
#region 连接OA数据库
|
||||
string OAConnection = ConfigurationManager.ConnectionStrings["OAConnection"].ConnectionString;
|
||||
mySqlUtils.ConnectionString = OAConnection;
|
||||
mySqlUtils.GetConnection();
|
||||
#endregion
|
||||
|
||||
#region 获取费用报销数据
|
||||
SQL = $@"select
|
||||
S1.DEPARTMENTNAME
|
||||
,S2.sqzz
|
||||
,S.djbh
|
||||
from formtable_main_24 S
|
||||
LEFT JOIN hrmdepartment S1 ON S.szbm = S1.id
|
||||
left join uf_cgsqzz S2 on S.sqzz = S2.id
|
||||
where S.requestId ='{RequestID}'";
|
||||
dt = mySqlUtils.ExecQuery(SQL);
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception("【" + RequestID + "】查询费用报销数据为空!");
|
||||
}
|
||||
SQL = $@"select jdbmbh ,jdbmmc from uf_oa_kingdee_dept
|
||||
where zzmc ='{dt.Rows[0]["sqzz"].ToString()}' and oabm = '{dt.Rows[0]["DEPARTMENTNAME"].ToString()}'";
|
||||
dt1 = mySqlUtils.ExecQuery(SQL);
|
||||
if (dt1 == null || dt1.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception("【"+ RequestID + "】,【" + dt.Rows[0]["sqzz"].ToString() + "】,【" + dt.Rows[0]["DEPARTMENTNAME"].ToString() + "】查询部门映射关系为空!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取付款申请单FID
|
||||
//第一步,登录金蝶系统
|
||||
client = new K3CloudApiClient(erpURL);
|
||||
var loginResult = client.ValidateLogin(acctID, userID, password, erpLaType);
|
||||
var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
|
||||
|
||||
//登录结果类型等于1,代表登录成功
|
||||
if (resultType == 1) //登录成功
|
||||
{
|
||||
#region 查询条件
|
||||
JObject QueryData = new JObject();
|
||||
QueryData["FormId"] = "CN_PAYAPPLY";
|
||||
QueryData["FieldKeys"] = "FID";
|
||||
QueryData["OrderString"] = "FID";
|
||||
QueryData["FilterString"] = "FBILLNO = '" + dt.Rows[0]["djbh"].ToString() + "'";
|
||||
QueryData["StartRow"] = 0;
|
||||
#endregion
|
||||
|
||||
#region 返回结果
|
||||
var QueryList = client.ExecuteBillQuery(QueryData.ToString());
|
||||
if (QueryList != null && QueryList.Count > 0)
|
||||
{
|
||||
FID = QueryList[0][0].ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 更新付款申请单部门字段
|
||||
JArray NeedUpDateFields = new JArray();
|
||||
NeedUpDateFields.Add("FDEPARTMENT");
|
||||
JObject JsonData = new JObject();
|
||||
JsonData.Add("NeedUpDateFields", NeedUpDateFields);
|
||||
JsonData.Add("IsDeleteEntry", "false");
|
||||
JObject Model = new JObject();
|
||||
Model.Add("FID", FID);
|
||||
Model.Add("FDEPARTMENT", new JObject() { { "FNUMBER", dt1.Rows[0]["jdbmbh"].ToString() } }); // 部门
|
||||
JsonData.Add("Model", Model);
|
||||
var data = JsonData.ToStringEx();
|
||||
var ret = client.Save("CN_PAYAPPLY", data);
|
||||
K3Response myK3Response = WmsCommonFunction.GetBodyData<K3Response>(ret);
|
||||
if (!myK3Response.Result.ResponseStatus.IsSuccess)
|
||||
{
|
||||
foreach (K3Error sub1 in myK3Response.Result.ResponseStatus.Errors)
|
||||
{
|
||||
throw new Exception($"{sub1.FieldName}:{sub1.Message},修改付款申请单部门Json:{data}");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("登录新云星空失败,初始数据失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog("更新金蝶付款申请单部门字段异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
#region 关闭连接
|
||||
mySqlUtils.Dispose();
|
||||
#endregion
|
||||
}
|
||||
LogHelper.WriteLog("【" + RequestID + "】更新金蝶付款申请单部门字段成功");
|
||||
return Ok();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 金蝶生产订单删除按钮删除WMS生产任务单
|
||||
[HttpPost]
|
||||
public IHttpActionResult RestoreMOInfo([FromBody] JObject obj)
|
||||
{
|
||||
#region 变量
|
||||
string SQL = string.Empty,FMOID = string.Empty;
|
||||
string FMOBillNO = obj["FMOBillNO"].ToString();
|
||||
DBHelpe db = new DBHelpe();
|
||||
#endregion
|
||||
|
||||
try
|
||||
{
|
||||
SQL = $@"SELECT FINTERID from T_PRD_MO
|
||||
where FBILLNO = '{FMOBillNO}';";
|
||||
DataTable dt = db.ExecuteTable(SQL);
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
FMOID = dt.Rows[0]["FINTERID"].ToString();
|
||||
SQL = $@"DELETE FROM T_PRD_MO WHERE FINTERID = '{FMOID}';
|
||||
DELETE FROM T_PRD_MOENTRY WHERE FINTERID = '{FMOID}';
|
||||
DELETE FROM T_PRD_MOENTRY1 WHERE FINTERID = '{FMOID}';";
|
||||
db.ExecuteNonQuery(SQL);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog("WMS删除生产任务单异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogHelper.WriteLog("金蝶生产任务单传入值:" + FMOBillNO);
|
||||
}
|
||||
return Ok(obj);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user