This commit is contained in:
PastSaid
2023-12-20 09:08:21 +08:00
parent 224c74d538
commit fe71b6365c
16 changed files with 347 additions and 50 deletions

View File

@@ -0,0 +1,99 @@
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Kingdee.BOS.Contracts;
using Kingdee.BOS;
using Kingdee.BOS.Core;
using System.ComponentModel;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.DynamicForm.Operation;
using Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs;
using Kingdee.BOS.Orm;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.BusinessFlow.ServiceArgs;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.App.Core.ScheduleService;
namespace CY.SAL_OUTSTOCK
{
[Description("自动下推"), HotUpdate]
public class AutoPushLostOutStock2Pay : IScheduleService
{
public void Run(Context ctx, Schedule schedule)
{
try
{
IConvertService service = Kingdee.BOS.App.ServiceHelper.GetService<IConvertService>();
string sourceFormId = "SAL_OUTSTOCK";
string targetFormId = "AR_RECEIVABLE";
//var rules = service.GetConvertRules(ctx, sourceFormId, targetFormId);
string convertRuleId = "AR_OutStockToReceivableMap"; //销售出库单下推应付单
var ruleMeta = service.GetConvertRule(ctx, convertRuleId);
var rule = ruleMeta.Rule;
var dbList = GetDBData(ctx);
if (dbList != null && dbList.Any())
{
var groupbyList = dbList.GroupBy(x => x["FBILLNO"]);
StringBuilder stringBuilder = new StringBuilder();
foreach (var list in groupbyList)
{
try
{
List<ListSelectedRow> selectedRows = list.Select(x => new ListSelectedRow(x["FID"].ToString(), x["FENTRYID"].ToString(), 0, sourceFormId)).ToList();
PushArgs pushArgs = new PushArgs(rule, selectedRows.ToArray());//下推入口参数
OperateOption option = OperateOption.Create();//选项参数
ConvertOperationResult result = service.Push(ctx, pushArgs, option);
}
catch (Exception ex)
{
stringBuilder.AppendLine($"单据:{list.Key}下推失败");
}
}
if (stringBuilder.IsNullOrEmpty())
throw new Exception(stringBuilder.ToString());
}
}
catch (Exception ex)
{
ScheduleMsgDal _msgDal = new ScheduleMsgDal();
ScheduleMsg msg = new ScheduleMsg();
msg.MsgDetail = ex.Message;
msg.HappenTime = DateTime.Now;
msg.MsgType = 5;// 1 成功 5异常
msg.ScheduleTypeId = schedule.ScheduleTypeId;
_msgDal.InsertScheduleMsg(ctx, msg);
}
}
private DynamicObjectCollection GetDBData(Context ctx)
{
var unSql = $@"
select * from V_NOT_RECEIVABLE_OUTSTOCK
";
var dbList = DBUtils.ExecuteDynamicObject(ctx, $"/*dialect*/{unSql}");
return dbList;
}
}
}

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>
<ProjectGuid>{6A52A594-F6A9-4754-BF53-22A126B54081}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CY.SAL_OUTSTOCK</RootNamespace>
<AssemblyName>CY.SAL_OUTSTOCK</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</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\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kingdee.BOS">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.App">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.App.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.App.Core">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.App.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.Contracts">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.Contracts.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.Core">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.DataEntity">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.DataEntity.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.BD.Contracts">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.K3.BD.Contracts.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoPushLostOutStock2Pay.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="SQLServer\无关联应收单.sql" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("CY.SAL_OUTSTOCK")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CY.SAL_OUTSTOCK")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("6a52a594-f6a9-4754-bf53-22a126b54081")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,28 @@
IF EXISTS (SELECT * FROM sysobjects WHERE name='V_NOT_RECEIVABLE_OUTSTOCK') --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
DROP VIEW V_NOT_RECEIVABLE_OUTSTOCK --<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
GO
CREATE VIEW V_NOT_RECEIVABLE_OUTSTOCK
AS
SELECT
A.FID
,A.FBILLNO
,A.FSTOCKORGID
,AE.FENTRYID
,B.FID
FROM
T_SAL_OUTSTOCK A
LEFT JOIN T_SAL_OUTSTOCKENTRY AE ON A.FID = AE.FID
LEFT JOIN (SELECT
A.FID
,A.FBILLNO
,AE.FENTRYID
,BE.FORDERENTRYID
,BE_LK.FSID
FROM
T_SAL_OUTSTOCK A
LEFT JOIN T_SAL_OUTSTOCKENTRY AE ON A.FID = AE.FID
LEFT JOIN T_AR_RECEIVABLEENTRY_LK BE_LK ON BE_LK.FSBILLID = AE.FID AND BE_LK.FSID = AE.FENTRYID
LEFT JOIN T_AR_RECEIVABLEENTRY BE ON BE.FENTRYID = BE_LK.FENTRYID
WHERE
BE_LK.FSTABLENAME = 'T_SAL_OUTSTOCKENTRY') B ON A.FID = B.FID
WHERE B.FID IS NULL and a.FDOCUMENTSTATUS ='C'