a
This commit is contained in:
110
07.珠海英搏尔/GZ.LJY000.Enpower/GZ.LJY000.Enpower.csproj
Normal file
110
07.珠海英搏尔/GZ.LJY000.Enpower/GZ.LJY000.Enpower.csproj
Normal file
@@ -0,0 +1,110 @@
|
||||
<?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>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5E803185-5C3E-4C17-A356-BB3E4389FBD7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>GZ.LJY000.Enpower</RootNamespace>
|
||||
<AssemblyName>GZ.LJY000.Enpower</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, Version=8.2.830.9, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<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.BOS.ServiceHelper">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.ServiceHelper.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="Kingdee.K3.Core">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.K3.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Kingdee.K3.SCM.App">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.K3.SCM.App.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Kingdee.K3.SCM.App.Core">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.K3.SCM.App.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Kingdee.K3.SCM.App.Stock.Report">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.K3.SCM.App.Stock.Report.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Kingdee.K3.SCM.Stock.Report.PlugIn">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.K3.SCM.Stock.Report.PlugIn.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<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="InvAgeAnalyzeOverrideEx.cs" />
|
||||
<Compile Include="POSH_PRODUCTCOSTQUICKQUERY2\BillEventPlugInEx.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SAL_RETURNSTOCK\BillEventPlugInEx.cs" />
|
||||
<Compile Include="STK_MISCELLANEOUS\BillEventPlugInEx.cs" />
|
||||
<Compile Include="SUB_RETURNMTRL\BillConvertEventPlugInEx.cs" />
|
||||
<Compile Include="SUB_RETURNMTRL\BillEventPlugInEx.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\01.扩展\Extensions\ExtensionMethods.csproj">
|
||||
<Project>{beae0bf6-7ab9-4af5-83ce-d08e3c6880ef}</Project>
|
||||
<Name>ExtensionMethods</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\01.扩展\HandleUtils\HandleUtils.csproj">
|
||||
<Project>{d6a5e5a0-7529-4ffa-9f9d-b2c610919bf6}</Project>
|
||||
<Name>HandleUtils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="STK_MISCELLANEOUS\BillEventPlugInEx.py" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy $(TargetPath) "D:\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
2554
07.珠海英搏尔/GZ.LJY000.Enpower/InvAgeAnalyzeOverrideEx.cs
Normal file
2554
07.珠海英搏尔/GZ.LJY000.Enpower/InvAgeAnalyzeOverrideEx.cs
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,246 @@
|
||||
using ExtensionMethods;
|
||||
using Kingdee.BOS.Core;
|
||||
using Kingdee.BOS.Core.CommonFilter;
|
||||
using Kingdee.BOS.Core.DynamicForm;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.KDThread;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace GZ.LJY000.Enpower.POSH_PRODUCTCOSTQUICKQUERY2
|
||||
{
|
||||
[Description("产品成本还原分解汇总报表"), HotUpdate]
|
||||
public class BillEventPlugInEx : AbstractDynamicFormPlugIn
|
||||
{
|
||||
private FilterShowParameter _showParameter;
|
||||
|
||||
public BillEventPlugInEx() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按钮点击事件
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public override void BarItemClick(BarItemClickEventArgs e)
|
||||
{
|
||||
base.BarItemClick(e);
|
||||
if (e.BarItemKey.Equals("tbShowFilterForm", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
if (_showParameter == null)
|
||||
{
|
||||
_showParameter = new FilterShowParameter();
|
||||
_showParameter.FormId = "YCKE_PRODUCTCOSTQUICKQUERY_FILTER";
|
||||
_showParameter.ParentPageId = this.View.PageId;
|
||||
}
|
||||
|
||||
|
||||
this.View.ShowForm(_showParameter, (resultData) =>
|
||||
{
|
||||
var whereSql = "";
|
||||
|
||||
if (resultData != null && resultData.ReturnData != null)
|
||||
{
|
||||
var returnData = resultData.ReturnData as FilterParameter;
|
||||
var filterString = returnData.FilterString;
|
||||
|
||||
if (!filterString.IsNullOrEmptyOrWhiteSpace())
|
||||
whereSql += " AND " + filterString.Replace("FBILLNO", "t0.FPRODUCTNO");
|
||||
|
||||
var customFilter = returnData.CustomFilter;
|
||||
if (customFilter != null)
|
||||
{
|
||||
//年
|
||||
var FYear = customFilter["FYear"];
|
||||
var yearVal = FYear == null || FYear.IsNullOrEmptyOrWhiteSpace() ? 0 : FYear.Long2Int();
|
||||
//月
|
||||
var FPeriod = customFilter["FPeriod"];
|
||||
var periodVal = FPeriod == null || FPeriod.IsNullOrEmptyOrWhiteSpace() ? 0 : FPeriod.Long2Int();
|
||||
if (yearVal > 0)
|
||||
{
|
||||
whereSql += $" AND t2.FYEAR = {yearVal} ";
|
||||
if (periodVal > 0)
|
||||
whereSql += $" AND t2.FPERIOD = {yearVal} ";
|
||||
}
|
||||
|
||||
var FSelMoBillNo = customFilter["FSelMoBillNo"];
|
||||
var moBillNo = FSelMoBillNo == null ? "" : FSelMoBillNo.ToString();
|
||||
if (moBillNo != "")
|
||||
whereSql += $" AND t0.FPRODUCTNO = '{moBillNo}' ";
|
||||
}
|
||||
}
|
||||
|
||||
if (whereSql != "")
|
||||
{
|
||||
ShowProgressBar(whereSql);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进度条
|
||||
/// </summary>
|
||||
/// <param name="whereSql"></param>
|
||||
private void ShowProgressBar(string whereSql)
|
||||
{
|
||||
//
|
||||
var progressFormParameter = new DynamicFormShowParameter();
|
||||
progressFormParameter.PageId = Guid.NewGuid().ToString();
|
||||
progressFormParameter.FormId = "BOS_ReportProgressMsg";
|
||||
progressFormParameter.OpenStyle.ShowType = ShowType.Modal;
|
||||
progressFormParameter.Caption = "正在加载数据...";
|
||||
progressFormParameter.HiddenCloseButton = true;
|
||||
progressFormParameter.ParentPageId = this.View.PageId;
|
||||
//# true表示使用真实进度,在执行任务的方法中更新进度值:代码示例,this.View.Session["ProcessRateValue"] =10
|
||||
progressFormParameter.CustomParams.Add("UseTruePro", "true");
|
||||
this.View.ShowForm(progressFormParameter ,(result) =>
|
||||
{
|
||||
this.View.ShowMessage("数据加载完成!");
|
||||
});
|
||||
|
||||
MainWorker.QuequeTask(this.Context, () =>
|
||||
{
|
||||
|
||||
DocCompute(whereSql);
|
||||
|
||||
this.View.Session["ProcessRateValue"] = 100;
|
||||
}, (asynResult) =>
|
||||
{
|
||||
if (asynResult != null && asynResult.Exception != null)
|
||||
this.View.ShowErrMessage(asynResult.Exception.Message);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算数据
|
||||
/// </summary>
|
||||
/// <param name="whereSql"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DocCompute(string whereSql)
|
||||
{
|
||||
var moSqlL = $@"/*dialect*/
|
||||
DECLARE @ACCTGORGID int
|
||||
SET @ACCTGORGID = 1
|
||||
;WITH #列表数据 AS (
|
||||
SELECT t0.FPRODUCTNO
|
||||
,t0.FBILLID
|
||||
,t0.FBILLENTRYID
|
||||
,t0.FPRODUCTID
|
||||
,t0.FFORMID
|
||||
,t1.FPRODUCTDIMEID
|
||||
,t3.FQUALIFIEDINQTY AS '本期完工数量'
|
||||
,t3.FCURRINPUTQTY AS '本期投入数量'
|
||||
,t3.FSUMCURRINPUTQTY AS '累计投入数量'
|
||||
,t3.FSUMQUALIFIEDINQTY AS '累计完工数量'
|
||||
,RANK() OVER (PARTITION BY t0.FBILLID,t0.FBILLENTRYID ORDER BY (t2.FYEAR * 100 + t2.FPERIOD) DESC) 'RN'
|
||||
,(t2.FYEAR * 100 + t2.FPERIOD) AS 'FPERIOD'
|
||||
FROM T_CB_PROORDERDIME t0
|
||||
INNER JOIN V_CB_PROORDERINFO t1 on t1.FPRODUCTDIMEID = t0.FPRODUCTDIMEID
|
||||
INNER JOIN V_HS_OUTACCTG t2 on t1.FACCTGID = t2.FID
|
||||
LEFT JOIN V_CB_COSTCALEXPENSE t3 on t3.FID = t1.FID
|
||||
WHERE 1 = 1
|
||||
AND t2.FACCTGORGID = @ACCTGORGID
|
||||
AND t2.FCOMPUTEID != ''
|
||||
AND t1.FENDINITKEY = 1
|
||||
AND t0.FFORMID = 'PRD_MO'
|
||||
{whereSql}
|
||||
)
|
||||
SELECT t0.*,t1.FNUMBER,t1_l.FNAME
|
||||
FROM #列表数据 t0
|
||||
INNER JOIN T_BD_MATERIAL t1 on t1.FMATERIALID = t0.FPRODUCTID
|
||||
INNER jOIN T_BD_MATERIAL_L t1_l on t1_l.FMATERIALID = t0.FPRODUCTID AND t1_l.FLOCALEID = 2052
|
||||
WHERE t0.RN = 1";
|
||||
|
||||
Thread.Sleep(100000);
|
||||
var proEntity = this.View.Model.BusinessInfo.GetEntryEntity("FEntity");
|
||||
var proRows = this.View.Model.GetEntityDataObject(proEntity);
|
||||
this.View.Model.BeginIniti();
|
||||
proRows.Clear();
|
||||
var datas = DBServiceHelper.ExecuteDynamicObject(this.Context, moSqlL);
|
||||
if (datas != null && datas.Any())
|
||||
{
|
||||
var num = 0;
|
||||
var count = datas.Count;
|
||||
|
||||
foreach (var data in datas)
|
||||
{
|
||||
var row = new DynamicObject(proEntity.DynamicObjectType);
|
||||
|
||||
var period = data["FPERIOD"].Long2Int();
|
||||
var billNo = data["FPRODUCTNO"].ToString();
|
||||
|
||||
row["FMoBillNo"] = billNo;
|
||||
row["FProMaterialNumber"] = data["FNUMBER"];
|
||||
row["FProMaterialName"] = data["FNAME"];
|
||||
row["FQUALIFIEDINQTY"] = data["本期完工数量"];
|
||||
row["FResult"] = "计算中";
|
||||
|
||||
num++;
|
||||
|
||||
this.View.Session["ProcessRateValue"] = (num * 100 / count).Long2Int();
|
||||
this.View.Session["ProcessTips"] = $"共{count}条数据,已处理{num - 1}条数据,正在处理{billNo}";
|
||||
|
||||
var costDataList = GetExecCost(billNo, period, 1);
|
||||
|
||||
if (costDataList != null && costDataList.Count > 0)
|
||||
{
|
||||
var costData = costDataList[0];
|
||||
row["FMaterialCostQ"] = costData["原材料Q1"];
|
||||
row["FLaborCostS"] = costData["直接人工S"];
|
||||
row["FProcessCostO"] = costData["制造费用O"];
|
||||
var costR = costData["原材料Q1"].ToDecimal() + costData["直接人工S"].ToDecimal() + costData["制造费用O"].ToDecimal();
|
||||
row["FQ_O_S_T_R"] = costR;
|
||||
row["FMaterialCostT"] = costData["间接材料Q2"];
|
||||
row["FO2"] = costData["制造费用_职工薪酬"];
|
||||
row["FO3"] = costData["制造费用_股份支付"];
|
||||
row["FO4"] = costData["制造费用_劳动保护费"];
|
||||
row["FO5"] = costData["制造费用_差旅费"];
|
||||
row["FO6"] = costData["制造费用_业务招待费"];
|
||||
row["FO7"] = costData["制造费用_办公费"];
|
||||
row["FO8"] = costData["制造费用_折旧与摊销"];
|
||||
row["FO9"] = costData["制造费用_租赁费"];
|
||||
row["FO10"] = costData["制造费用_水电费"];
|
||||
row["FO11"] = costData["制造费用_物料消耗"];
|
||||
row["FO12"] = costData["制造费用_加工_修理_检测费"];
|
||||
row["FO13"] = costData["制造费用_车辆使用费"];
|
||||
row["FO14"] = costData["制造费用_其他"];
|
||||
row["FO15"] = costData["制造费用_委外加工费"];
|
||||
row["FALLHRWORKTIME"] = costData["总工时"];
|
||||
}
|
||||
|
||||
proRows.Add(row);
|
||||
}
|
||||
}
|
||||
|
||||
this.View.UpdateView("FEntity");
|
||||
this.View.Model.EndIniti();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算费用成本
|
||||
/// </summary>
|
||||
/// <param name="billNo"></param>
|
||||
/// <param name="period"></param>
|
||||
/// <param name="acctgOrgId"></param>
|
||||
/// <returns></returns>
|
||||
private List<DynamicObject> GetExecCost(string billNo, int period, int acctgOrgId)
|
||||
{
|
||||
var sqlL = $@"/*dialect*/
|
||||
EXEC TEST_CB_CPCBHYFXIBB_COMPUTE '{billNo}',{period},{acctgOrgId}
|
||||
";
|
||||
var res = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
|
||||
return res.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
07.珠海英搏尔/GZ.LJY000.Enpower/Properties/AssemblyInfo.cs
Normal file
36
07.珠海英搏尔/GZ.LJY000.Enpower/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("GZ.LJY000.Enpower")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("GZ.LJY000.Enpower")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("5e803185-5c3e-4c17-a356-bb3e4389fbd7")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
194
07.珠海英搏尔/GZ.LJY000.Enpower/SAL_RETURNSTOCK/BillEventPlugInEx.cs
Normal file
194
07.珠海英搏尔/GZ.LJY000.Enpower/SAL_RETURNSTOCK/BillEventPlugInEx.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.Metadata.FieldElement;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
|
||||
namespace GZ.LJY000.Enpower.SAL_RETURNSTOCK
|
||||
{
|
||||
[HotUpdate, Description("销售退货单")]
|
||||
public class BillEventPlugInEx : AbstractDynamicFormPlugIn
|
||||
{
|
||||
|
||||
public override void DataChanged(DataChangedEventArgs e)
|
||||
{
|
||||
base.DataChanged(e);
|
||||
if (DoDetection())
|
||||
{
|
||||
if (e.Field.Key.ToUpper().Equals("FDATE"))
|
||||
{
|
||||
var details = this.View.BusinessInfo.GetEntity("FEntity");
|
||||
if (details != null)
|
||||
{
|
||||
var entrys = this.View.Model.GetEntityDataObject(details);
|
||||
if (entrys != null && entrys.Count > 0)
|
||||
{
|
||||
var dateValue = e.NewValue.ToString();
|
||||
if (dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
return;
|
||||
var retcustIdObj = this.View.Model.GetValue("FRetcustId");
|
||||
var retcustId = retcustIdObj == null ? 0 : ((DynamicObject)retcustIdObj)["Id"].Long2Int();
|
||||
|
||||
var tableSqlL = new List<string>();
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var rowIndex = this.View.Model.GetRowIndex(details, entry);
|
||||
var materialObjValue = entry["MaterialId_Id"];
|
||||
var materialValue = materialObjValue == null ? 0 : materialObjValue.Long2Int();
|
||||
|
||||
DynamicObject entityLinkObj = null;
|
||||
var entityLinkObjList = entry["FEntity_Link"] as DynamicObjectCollection;
|
||||
|
||||
if (entityLinkObjList != null && entityLinkObjList.Count > 0)
|
||||
entityLinkObj = entityLinkObjList[0];
|
||||
|
||||
var sBillId = entityLinkObj == null ? 0 : entityLinkObj["SBillId"].Long2Int();
|
||||
var sId = entityLinkObj == null ? 0 : entityLinkObj["SId"].Long2Int();
|
||||
var sTableName = entityLinkObj == null ? "" : entityLinkObj["STableName"].ToString();
|
||||
|
||||
if (sTableName == "" || (
|
||||
!sTableName.ToUpper().Equals("T_PUR_MRBENTRY")
|
||||
&& !sTableName.ToUpper().Equals("T_SAL_INITOUTSTOCKENTRY")
|
||||
&& !sTableName.ToUpper().Equals("T_SAL_OUTSTOCKENTRY")
|
||||
))
|
||||
tableSqlL.Add($" SELECT {materialValue} AS 'FMATERIALID',{rowIndex} rowIdx ");
|
||||
}
|
||||
|
||||
if (tableSqlL.Any())
|
||||
GetPrdLot(dateValue, retcustId, string.Join(" UNION ", tableSqlL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Field.Key.ToUpper().Equals("FRETCUSTID"))
|
||||
{
|
||||
var details = this.View.BusinessInfo.GetEntity("FEntity");
|
||||
if (details != null)
|
||||
{
|
||||
var entrys = this.View.Model.GetEntityDataObject(details);
|
||||
if (entrys != null && entrys.Count > 0)
|
||||
{
|
||||
var dateValue = this.View.Model.GetValue("FDate").ToString();
|
||||
if (dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
return;
|
||||
|
||||
var retcustId = e.NewValue.Long2Int(); ;
|
||||
|
||||
var tableSqlL = new List<string>();
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var rowIndex = this.View.Model.GetRowIndex(details, entry);
|
||||
var materialObjValue = entry["MaterialId_Id"];
|
||||
var materialValue = materialObjValue == null ? 0 : materialObjValue.Long2Int();
|
||||
|
||||
tableSqlL.Add($" SELECT {materialValue} AS 'FMATERIALID',{rowIndex} rowIdx ");
|
||||
}
|
||||
|
||||
if (tableSqlL.Any())
|
||||
GetPrdLot(dateValue, retcustId, string.Join(" UNION ", tableSqlL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Field.Key.ToUpper().Equals("FMATERIALID"))
|
||||
{
|
||||
var dateObj = this.View.Model.GetValue("FDate");
|
||||
var dateValue = dateObj == null ? "" : dateObj.ToString();
|
||||
|
||||
var retcustIdObj = this.View.Model.GetValue("FRetcustId");
|
||||
var retcustId = retcustIdObj == null ? 0 : ((DynamicObject)retcustIdObj)["Id"].Long2Int();
|
||||
|
||||
//this.View.Model.SetValue("FLOT", "002", 0);
|
||||
var materialId = e.NewValue.Long2Int();
|
||||
if (materialId > 0 && !dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
GetPrdLot(dateValue, retcustId, string.Join(" UNION ", $" SELECT {materialId} AS 'FMATERIALID',{e.Row} rowIdx "));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void AfterCreateNewEntryRow(CreateNewEntryEventArgs e)
|
||||
{
|
||||
base.AfterCreateNewEntryRow(e);
|
||||
|
||||
}
|
||||
private bool DoDetection()
|
||||
{
|
||||
var orgObj = this.View.Model.GetValue("FStockOrgId") as DynamicObject;
|
||||
|
||||
if (this.Context.DBId.ToLower().Equals("66eec1c506d225"))
|
||||
return true;
|
||||
|
||||
if (orgObj["Id"].Long2Int() == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取批号
|
||||
/// </summary>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <param name="tableSql"></param>
|
||||
private void GetPrdLot(string dateTime, int retcustId, string tableSql)
|
||||
{
|
||||
var sqlL = $@"/*dialect*/
|
||||
|
||||
DECLARE @date datetime
|
||||
SET @date = '{dateTime}'
|
||||
|
||||
SELECT tt.*,t1.*--,t0b.FERPCLSID--3 委外 2 自制
|
||||
FROM ( {tableSql}
|
||||
) tt
|
||||
|
||||
INNER JOIN T_BD_MATERIALSTOCK t0s on tt.FMATERIALID = t0s.FMATERIALID AND t0s.FISBATCHMANAGE = 1
|
||||
CROSS APPLY (
|
||||
SELECT TOP 1 tt.FBILLNO,tt.FMATERIALID,tt.FREALQTY,tt.FLOT,tt.FLOT_TEXT,tt.Seq
|
||||
FROM (
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FREALQTY,t0e.FLOT,t0e.FLOT_TEXT,0 Seq
|
||||
FROM T_SAL_OUTSTOCK t0
|
||||
INNER JOIN T_SAL_OUTSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN T_BD_MATERIALBASE t1b on t1b.FMATERIALID = t0e.FMATERIALID AND t1b.FERPCLSID = '2'
|
||||
WHERE 1=1 AND t0e.FLOT != 0
|
||||
AND t0.FCUSTOMERID = {retcustId}
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE <= @date
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT '',0,0,0,RIGHT(CONVERT(varchar(100),CONVERT(int, CONVERT(VARCHAR(6),@date,112)) * 100 + DATEPART(ISO_WEEK, @date)),6),1 Seq
|
||||
) tt
|
||||
ORDER BY tt.FREALQTY DESC,tt.Seq ASC
|
||||
) t1
|
||||
|
||||
";
|
||||
|
||||
var res = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
LotField field = this.View.Model.BillBusinessInfo.GetField("FLOT") as LotField;
|
||||
|
||||
foreach (var item in res)
|
||||
{
|
||||
if (field.InputModel == LotField.Enum_InputModel.OnlySelect)
|
||||
{
|
||||
this.View.Model.SetValue("FLOT", item["FLOT"].Long2Int(), item["rowIdx"].Long2Int());
|
||||
}
|
||||
else
|
||||
{
|
||||
//this.View.Model.SetValue("FLOT", item["FLOT_TEXT"].ToString(), item["rowIdx"].Long2Int());
|
||||
this.View.Model.SetValue("FLOT", item["FLOT_TEXT"].ToString(), item["rowIdx"].Long2Int());
|
||||
}
|
||||
}
|
||||
|
||||
//this.View.UpdateView("FLOT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.Util;
|
||||
using Kingdee.BOS.Core;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.BOS.Core.Metadata.EntityElement;
|
||||
using System.ComponentModel;
|
||||
using Kingdee.BOS.Core.Metadata.FieldElement;
|
||||
using Kingdee.BOS.Core.Metadata.Operation;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace GZ.LJY000.Enpower.STK_MISCELLANEOUS
|
||||
{
|
||||
[HotUpdate, Description("其他入库批号获取")]
|
||||
public class BillEventPlugInEx : AbstractDynamicFormPlugIn
|
||||
{
|
||||
|
||||
public override void DataChanged(DataChangedEventArgs e)
|
||||
{
|
||||
base.DataChanged(e);
|
||||
if (DoDetection())
|
||||
{
|
||||
var stockDirectObj = this.View.Model.GetValue("FStockDirect");
|
||||
var stockDirectVal = stockDirectObj == null ? "" : stockDirectObj.ToString();
|
||||
if (stockDirectVal.Equals("GENERAL"))
|
||||
{
|
||||
if (e.Field.Key.ToUpper().Equals("FDATE"))
|
||||
{
|
||||
|
||||
var details = this.View.BusinessInfo.GetEntity("FEntity");
|
||||
if (details != null)
|
||||
{
|
||||
var entrys = this.View.Model.GetEntityDataObject(details);
|
||||
if (entrys != null && entrys.Count > 0)
|
||||
{
|
||||
var dateValue = e.NewValue.ToString();
|
||||
if (dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
return;
|
||||
|
||||
var tableSqlL = new List<string>();
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var rowIndex = this.View.Model.GetRowIndex(details, entry);
|
||||
var materialObjValue = entry["MaterialId_Id"];
|
||||
var materialValue = materialObjValue == null ? 0 : materialObjValue.Long2Int();
|
||||
|
||||
tableSqlL.Add($" SELECT {materialValue} AS 'FMATERIALID',{rowIndex} rowIdx ");
|
||||
}
|
||||
|
||||
if (tableSqlL.Any())
|
||||
GetPrdLot(dateValue, string.Join(" UNION ", tableSqlL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Field.Key.ToUpper().Equals("FMATERIALID"))
|
||||
{
|
||||
var dateObj = this.View.Model.GetValue("FDate");
|
||||
var dateValue = dateObj == null ? "" : dateObj.ToString();
|
||||
//this.View.Model.SetValue("FLOT", "002", 0);
|
||||
var materialId = e.NewValue.Long2Int();
|
||||
if (materialId > 0 && !dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
GetPrdLot(dateValue, string.Join(" UNION ", $" SELECT {materialId} AS 'FMATERIALID',{e.Row} rowIdx "));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void AfterCreateNewEntryRow(CreateNewEntryEventArgs e)
|
||||
{
|
||||
base.AfterCreateNewEntryRow(e);
|
||||
|
||||
}
|
||||
private bool DoDetection()
|
||||
{
|
||||
var orgObj = this.View.Model.GetValue("FStockOrgId") as DynamicObject;
|
||||
|
||||
if (this.Context.DBId.ToLower().Equals("66eec1c506d225"))
|
||||
return true;
|
||||
|
||||
if (orgObj["Id"].Long2Int() == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取批号
|
||||
/// </summary>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <param name="tableSql"></param>
|
||||
private void GetPrdLot(string dateTime, string tableSql)
|
||||
{
|
||||
var sqlL = $@"/*dialect*/
|
||||
|
||||
|
||||
DECLARE @date datetime
|
||||
SET @date = '{dateTime}'
|
||||
|
||||
;WITH #基础数据 AS (
|
||||
{tableSql}
|
||||
)
|
||||
SELECT tt.*,t1.*
|
||||
FROM #基础数据 tt
|
||||
INNER JOIN T_BD_MATERIALSTOCK t0s on tt.FMATERIALID = t0s.FMATERIALID AND t0s.FISBATCHMANAGE = 1
|
||||
CROSS APPLY (
|
||||
SELECT TOP 1 tt.FBILLNO,tt.FMATERIALID,tt.FREALQTY,tt.FLOT,tt.FLOT_TEXT,tt.Seq,ROW_NUMBER()OVER (ORDER BY tt.FREALQTY DESC,tt.FCREATEDATE DESC) RN
|
||||
FROM (
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FREALQTY,t0e.FLOT,t1.FBILLNO FLOT_TEXT,0 Seq,t0.FCREATEDATE
|
||||
FROM T_PRD_INSTOCK t0
|
||||
INNER JOIN T_PRD_INSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN T_PRD_INSTOCKENTRY_LK t0e_lk on t0e_lk.FENTRYID = t0e.FENTRYID AND t0e_lk.FSTABLENAME = 'T_PRD_MOENTRY'
|
||||
INNER JOIN T_PRD_MO t1 on t1.FID = t0e_lk.FSBILLID
|
||||
INNER JOIN T_BD_MATERIALBASE t1b on t1b.FMATERIALID = t0e.FMATERIALID AND t1b.FERPCLSID = '2'
|
||||
WHERE 1=1 AND t0e.FLOT != 0
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE <= @date
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FREALQTY,t0e.FLOT,t2.FBILLNO,0 Seq,t0.FCREATEDATE
|
||||
FROM T_STK_INSTOCK t0
|
||||
INNER JOIN T_STK_INSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN T_STK_INSTOCKENTRY_LK t0e_lk on t0e_lk.FENTRYID = t0e.FENTRYID AND t0e_lk.FSTABLENAME = 't_PUR_POOrderEntry'
|
||||
INNER JOIN T_PUR_POORDERENTRY_LK t1e_lk on t1e_lk.FENTRYID = t0e_lk.FSID AND t1e_lk.FSTABLENAME = 'T_SUB_REQORDERENTRY'
|
||||
INNER JOIN T_SUB_REQORDER t2 on t2.FID = t1e_lk.FSBILLID
|
||||
INNER JOIN T_BD_MATERIALBASE t1b on t1b.FMATERIALID = t0e.FMATERIALID AND t1b.FERPCLSID = '3'
|
||||
WHERE 1=1
|
||||
AND t0.FBUSINESSTYPE = 'WW'
|
||||
AND t0e.FLOT != 0
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE <= @date
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT '',0,0,0,RIGHT(CONVERT(varchar(100),CONVERT(int, CONVERT(VARCHAR(6),@date,112)) * 100 + DATEPART(ISO_WEEK, @date)),6),1 Seq,@date
|
||||
) tt
|
||||
--ORDER BY tt.FREALQTY DESC,tt.Seq ASC
|
||||
) t1
|
||||
|
||||
";
|
||||
|
||||
var res = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
LotField field = this.View.Model.BillBusinessInfo.GetField("FLOT") as LotField;
|
||||
|
||||
foreach (var item in res)
|
||||
{
|
||||
if (field.InputModel == LotField.Enum_InputModel.OnlySelect)
|
||||
{
|
||||
this.View.Model.SetValue("FLOT", item["FLOT"].Long2Int(), item["rowIdx"].Long2Int());
|
||||
}
|
||||
else
|
||||
{
|
||||
//this.View.Model.SetValue("FLOT", item["FLOT_TEXT"].ToString(), item["rowIdx"].Long2Int());
|
||||
this.View.Model.SetValue("FLOT", item["FLOT_TEXT"].ToString(), item["rowIdx"].Long2Int());
|
||||
}
|
||||
}
|
||||
|
||||
//this.View.UpdateView("FLOT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import clr
|
||||
clr.AddReference("System")
|
||||
clr.AddReference("Kingdee.BOS")
|
||||
clr.AddReference("Kingdee.BOS.Core")
|
||||
clr.AddReference("Kingdee.BOS.DataEntity")
|
||||
clr.AddReference("Kingdee.BOS.App")
|
||||
clr.AddReference("Kingdee.BOS.Contracts")
|
||||
clr.AddReference("Kingdee.BOS.ServiceHelper")
|
||||
|
||||
from Kingdee.BOS import *
|
||||
from Kingdee.BOS.Core import *
|
||||
from Kingdee.BOS.Core.Metadata.EntityElement import *
|
||||
from Kingdee.BOS.Orm.DataEntity import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
|
||||
from Kingdee.BOS.Util import *
|
||||
from System import *
|
||||
from System.ComponentModel import *
|
||||
from System.Collections.Generic import *
|
||||
from System.Text import*
|
||||
from Kingdee.BOS.ServiceHelper import *
|
||||
|
||||
def DataChanged(e):
|
||||
if str(e.Field.Key).upper() == "FDate":
|
||||
if DoDetection():
|
||||
|
||||
stockDirectObj = this.View.Model.GetValue("FStockDirect")
|
||||
stockDirectVal = "" if stockDirectObj == None else stockDirectObj
|
||||
if stockDirectVal == "GENERAL":
|
||||
details = this.View.BusinessInfo.GetEntity("FEntity")
|
||||
|
||||
if details != None:
|
||||
entrys = this.View.Model.GetEntityDataObject(details)
|
||||
if entrys != None and entrys.Count > 0:
|
||||
dateValue = "" if e.NewValue == None else e.NewValue
|
||||
if dateValue == "":
|
||||
return;
|
||||
|
||||
tableSqlL = List[str]();
|
||||
for entry in entrys:
|
||||
rowIndex = this.View.Model.GetRowIndex(details, entry)
|
||||
|
||||
materialObjValue = entry["MaterialId_Id"];
|
||||
materialValue = 0 if materialObjValue == None else materialObjValue
|
||||
tableSqlL.Add(" SELECT {0} AS 'FMATERIALID',{1} rowIdx ".format(materialValue,rowIndex))
|
||||
|
||||
if tableSqlL.Count() > 0:
|
||||
GetPrdLot(dateValue, " UNION ".join(tableSqlL))
|
||||
return;
|
||||
|
||||
if str(e.Field.Key).upper() == "FMATERIALID":
|
||||
dateObj = this.View.Model.GetValue("FDate")
|
||||
dateValue = "" if dateObj == None else str(dateObj)
|
||||
materialId = int(e.NewValue)
|
||||
if materialId > 0 and dateValue != "":
|
||||
GetPrdLot(dateValue," SELECT {0} AS 'FMATERIALID',{1} rowIdx ".format(materialId,e.Row))
|
||||
|
||||
|
||||
def DoDetection():
|
||||
orgObj = this.View.Model.GetValue("FStockOrgId")
|
||||
if orgObj["Id"] == 1:
|
||||
return True
|
||||
|
||||
return False
|
||||
# return True
|
||||
|
||||
def GetPrdLot(dateTime,tableSql):
|
||||
sqlL = """/*dialect*/
|
||||
DECLARE @date datetime
|
||||
SET @date = '{0}'
|
||||
|
||||
;WITH #基础数据 AS (
|
||||
{1}
|
||||
)
|
||||
SELECT tt.*,t1.*
|
||||
FROM #基础数据 tt
|
||||
INNER JOIN T_BD_MATERIALSTOCK t0s on tt.FMATERIALID = t0s.FMATERIALID AND t0s.FISBATCHMANAGE = 1
|
||||
CROSS APPLY (
|
||||
SELECT TOP 1 tt.FBILLNO,tt.FMATERIALID,tt.FREALQTY,tt.FLOT,tt.FLOT_TEXT,tt.Seq,ROW_NUMBER()OVER (ORDER BY tt.FREALQTY DESC,tt.FCREATEDATE DESC) RN
|
||||
FROM (
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FREALQTY,t0e.FLOT,t1.FBILLNO FLOT_TEXT,0 Seq,t0.FCREATEDATE
|
||||
FROM T_PRD_INSTOCK t0
|
||||
INNER JOIN T_PRD_INSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN T_PRD_INSTOCKENTRY_LK t0e_lk on t0e_lk.FENTRYID = t0e.FENTRYID AND t0e_lk.FSTABLENAME = 'T_PRD_MOENTRY'
|
||||
INNER JOIN T_PRD_MO t1 on t1.FID = t0e_lk.FSBILLID
|
||||
INNER JOIN T_BD_MATERIALBASE t1b on t1b.FMATERIALID = t0e.FMATERIALID AND t1b.FERPCLSID = '2'
|
||||
WHERE 1=1 AND t0e.FLOT != 0
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE <= @date
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FREALQTY,t0e.FLOT,t2.FBILLNO,0 Seq,t0.FCREATEDATE
|
||||
FROM T_STK_INSTOCK t0
|
||||
INNER JOIN T_STK_INSTOCKENTRY t0e on t0.FID = t0e.FID
|
||||
INNER JOIN T_STK_INSTOCKENTRY_LK t0e_lk on t0e_lk.FENTRYID = t0e.FENTRYID AND t0e_lk.FSTABLENAME = 't_PUR_POOrderEntry'
|
||||
INNER JOIN T_PUR_POORDERENTRY_LK t1e_lk on t1e_lk.FENTRYID = t0e_lk.FSID AND t1e_lk.FSTABLENAME = 'T_SUB_REQORDERENTRY'
|
||||
INNER JOIN T_SUB_REQORDER t2 on t2.FID = t1e_lk.FSBILLID
|
||||
INNER JOIN T_BD_MATERIALBASE t1b on t1b.FMATERIALID = t0e.FMATERIALID AND t1b.FERPCLSID = '3'
|
||||
WHERE 1=1
|
||||
AND t0.FBUSINESSTYPE = 'WW'
|
||||
AND t0e.FLOT != 0
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE <= @date
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT '',0,0,0,RIGHT(CONVERT(varchar(100),CONVERT(int, CONVERT(VARCHAR(6),@date,112)) * 100 + DATEPART(ISO_WEEK, @date)),6),1 Seq,@date
|
||||
) tt
|
||||
--ORDER BY tt.FREALQTY DESC,tt.Seq ASC
|
||||
) t1
|
||||
|
||||
""".format(dateTime,tableSql)
|
||||
|
||||
res = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
if res != None and res.Count > 0:
|
||||
field = this.View.Model.BillBusinessInfo.GetField("FLOT")
|
||||
for item in res:
|
||||
# if field.InputModel == LotField.Enum_InputModel.OnlySelect:
|
||||
# this.View.Model.SetValue("FLOT", item["FLOT"], item["rowIdx"])
|
||||
# else:
|
||||
this.View.Model.SetValue("FLOT", item["FLOT_TEXT"], item["rowIdx"])
|
||||
@@ -0,0 +1,102 @@
|
||||
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
|
||||
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
|
||||
using Kingdee.BOS.Core.Metadata.FieldElement;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace GZ.LJY000.Enpower.SUB_RETURNMTRL
|
||||
{
|
||||
[Description("委外退料单转换插件"), HotUpdate]
|
||||
public class BillConvertEventPlugInEx : AbstractConvertPlugIn
|
||||
{
|
||||
public override void AfterConvert(AfterConvertEventArgs e)
|
||||
{
|
||||
base.AfterConvert(e);
|
||||
|
||||
var billHead = e.Result.FindByEntityKey("FBillHead")[0].DataEntity;
|
||||
|
||||
var dateObjValue = billHead["Date"];
|
||||
var dateValue = dateObjValue == null ? "" : ((DateTime)dateObjValue).ToString("yyyy-MM-dd");
|
||||
|
||||
var tableSqlL = new List<string>();
|
||||
var entrys = billHead["Entity"] as DynamicObjectCollection;
|
||||
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var rowIndex = entry["Seq"].Long2Int() - 1;
|
||||
var materialObjValue = entry["MaterialId_Id"];
|
||||
var materialValue = materialObjValue.Long2Int();
|
||||
|
||||
var PPBomBillNoObj = entry["PPBomBillNo"];
|
||||
var PPBomBillNo = PPBomBillNoObj == null ? "" : PPBomBillNoObj.ToString();
|
||||
|
||||
tableSqlL.Add($" SELECT {materialValue} AS 'FMATERIALID',{rowIndex} rowIdx , '{PPBomBillNo}' PPBOMNO ");
|
||||
}
|
||||
|
||||
if (tableSqlL.Any())
|
||||
GetPrdLot(entrys.ToList(), dateValue, string.Join(" UNION ", tableSqlL));
|
||||
}
|
||||
|
||||
private void GetPrdLot(List<DynamicObject> entrys, string dateTime, string tableSql)
|
||||
{
|
||||
var sqlL = $@"/*dialect*/
|
||||
DECLARE @date datetime
|
||||
SET @date = '{dateTime}'
|
||||
|
||||
SELECT tt.*,t1.*
|
||||
FROM ( {tableSql}
|
||||
) tt
|
||||
INNER JOIN T_BD_MATERIALSTOCK t0s on tt.FMATERIALID = t0s.FMATERIALID AND t0s.FISBATCHMANAGE = 1
|
||||
CROSS APPLY (
|
||||
SELECT TOP 1 tt.FBILLNO,tt.FMATERIALID,tt.FREALQTY,tt.FLOT,tt.FLOT_TEXT,tt.Seq
|
||||
FROM (
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FACTUALQTY 'FREALQTY',t0e.FLOT,t0e.FLOT_TEXT, 0 seq
|
||||
FROM T_SUB_PICKMTRL t0
|
||||
INNER JOIN T_SUB_PICKMTRLDATA t0e on t0.FID = t0e.FID
|
||||
WHERE 1=1 AND t0e.FLOT != 0
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE < @date
|
||||
AND t0e.FPPBOMBILLNO = tt.PPBOMNO
|
||||
AND tt.PPBOMNO != ''
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FACTUALQTY 'FREALQTY',t0e.FLOT,t0e.FLOT_TEXT, 0 seq
|
||||
FROM T_SUB_PICKMTRL t0
|
||||
INNER JOIN T_SUB_PICKMTRLDATA t0e on t0.FID = t0e.FID
|
||||
WHERE 1=1 AND t0e.FLOT != 0
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE < @date
|
||||
AND tt.PPBOMNO = ''
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT '',0,0,0,RIGHT(CONVERT(varchar(100),CONVERT(int, CONVERT(VARCHAR(6),@date,112)) * 100 + DATEPART(ISO_WEEK, @date)),6),1 Seq
|
||||
) tt
|
||||
ORDER BY tt.FREALQTY DESC,tt.Seq ASC
|
||||
) t1
|
||||
|
||||
";
|
||||
|
||||
var res = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
|
||||
foreach (var item in res)
|
||||
{
|
||||
var rowIndex = item["rowIdx"].Long2Int();
|
||||
entrys[rowIndex]["Lot_Id"] = item["FLot"];
|
||||
entrys[rowIndex]["Lot_Text"] = item["FLot_Text"];
|
||||
//this.View.Model.SetValue("FLOT", item["FLOT_TEXT"].ToString(), item["rowIdx"].Long2Int());
|
||||
}
|
||||
|
||||
//this.View.UpdateView("FLOT");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
196
07.珠海英搏尔/GZ.LJY000.Enpower/SUB_RETURNMTRL/BillEventPlugInEx.cs
Normal file
196
07.珠海英搏尔/GZ.LJY000.Enpower/SUB_RETURNMTRL/BillEventPlugInEx.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.Metadata.FieldElement;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.ServiceHelper;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace GZ.LJY000.Enpower.SUB_RETURNMTRL
|
||||
{
|
||||
[HotUpdate, Description("委外退料单")]
|
||||
public class BillEventPlugInEx : AbstractDynamicFormPlugIn
|
||||
{
|
||||
public override void DataChanged(DataChangedEventArgs e)
|
||||
{
|
||||
base.DataChanged(e);
|
||||
if (DoDetection())
|
||||
{
|
||||
if (e.Field.Key.ToUpper().Equals("FDATE"))
|
||||
{
|
||||
|
||||
var details = this.View.BusinessInfo.GetEntity("FEntity");
|
||||
if (details != null)
|
||||
{
|
||||
var entrys = this.View.Model.GetEntityDataObject(details);
|
||||
if (entrys != null && entrys.Count > 0)
|
||||
{
|
||||
var dateValue = e.NewValue.ToString();
|
||||
if (dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
return;
|
||||
|
||||
var tableSqlL = new List<string>();
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var rowIndex = this.View.Model.GetRowIndex(details, entry);
|
||||
var materialObjValue = entry["MaterialId_Id"];
|
||||
var materialValue = materialObjValue == null ? 0 : materialObjValue.Long2Int();
|
||||
|
||||
|
||||
DynamicObject entityLinkObj = null;
|
||||
var entityLinkObjList = entry["FEntity_Link"] as DynamicObjectCollection;
|
||||
|
||||
if (entityLinkObjList != null && entityLinkObjList.Count > 0)
|
||||
entityLinkObj = entityLinkObjList[0];
|
||||
|
||||
var sBillId = entityLinkObj == null ? 0 : entityLinkObj["SBillId"].Long2Int();
|
||||
var sId = entityLinkObj == null ? 0 : entityLinkObj["SId"].Long2Int();
|
||||
var sTableName = entityLinkObj == null ? "" : entityLinkObj["STableName"].ToString();
|
||||
|
||||
if (sTableName == "" || (!sTableName.ToUpper().Equals("T_SUB_PICKMTRLDATA") && !sTableName.ToUpper().Equals("T_SUB_FEEDMTRLENTRY")))
|
||||
tableSqlL.Add($" SELECT {materialValue} AS 'FMATERIALID',{rowIndex} rowIdx ");
|
||||
}
|
||||
|
||||
if (tableSqlL.Any())
|
||||
GetPrdLot(dateValue, string.Join(" UNION ", tableSqlL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Field.Key.ToUpper().Equals("FMATERIALID"))
|
||||
{
|
||||
var dateObj = this.View.Model.GetValue("FDate");
|
||||
var dateValue = dateObj == null ? "" : dateObj.ToString();
|
||||
//this.View.Model.SetValue("FLOT", "002", 0);
|
||||
var materialId = e.NewValue.Long2Int();
|
||||
if (materialId > 0 && !dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
GetPrdLot(dateValue, string.Join(" UNION ", $" SELECT {materialId} AS 'FMATERIALID',{e.Row} rowIdx "));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void AfterCreateNewEntryRow(CreateNewEntryEventArgs e)
|
||||
{
|
||||
base.AfterCreateNewEntryRow(e);
|
||||
|
||||
if (DoDetection())
|
||||
{
|
||||
var details = this.View.BusinessInfo.GetEntity("FEntity");
|
||||
if (details != null)
|
||||
{
|
||||
var entrys = this.View.Model.GetEntityDataObject(details);
|
||||
if (entrys != null && entrys.Count > 0)
|
||||
{
|
||||
var dateObj = this.View.Model.GetValue("FDate");
|
||||
var dateValue = dateObj == null ? "" : dateObj.ToString();
|
||||
if (dateValue.IsNullOrEmptyOrWhiteSpace())
|
||||
return;
|
||||
|
||||
var tableSqlL = new List<string>();
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var rowIndex = this.View.Model.GetRowIndex(details, entry);
|
||||
var materialObjValue = entry["MaterialId_Id"];
|
||||
var materialValue = materialObjValue == null ? 0 : materialObjValue.Long2Int();
|
||||
|
||||
tableSqlL.Add($" SELECT {materialValue} AS 'FMATERIALID',{rowIndex} rowIdx ");
|
||||
|
||||
DynamicObject entityLinkObj = null;
|
||||
var entityLinkObjList = entry["FEntity_Link"] as DynamicObjectCollection;
|
||||
|
||||
if (entityLinkObjList != null && entityLinkObjList.Count > 0)
|
||||
entityLinkObj = entityLinkObjList[0];
|
||||
|
||||
var sBillId = entityLinkObj == null ? 0 : entityLinkObj["SBillId"].Long2Int();
|
||||
var sId = entityLinkObj == null ? 0 : entityLinkObj["SId"].Long2Int();
|
||||
var sTableName = entityLinkObj == null ? "" : entityLinkObj["STableName"].ToString();
|
||||
}
|
||||
|
||||
if (tableSqlL.Any())
|
||||
GetPrdLot(dateValue, string.Join(" UNION ", tableSqlL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool DoDetection()
|
||||
{
|
||||
var orgObj = this.View.Model.GetValue("FStockOrgId") as DynamicObject;
|
||||
|
||||
if (this.Context.DBId.ToLower().Equals("66eec1c506d225"))
|
||||
return true;
|
||||
|
||||
if (orgObj["Id"].Long2Int() == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取批号
|
||||
/// </summary>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <param name="tableSql"></param>
|
||||
private void GetPrdLot(string dateTime, string tableSql, string ppbomNo = "")
|
||||
{
|
||||
var hasPPBOMNO = "";
|
||||
if (ppbomNo != "")
|
||||
hasPPBOMNO = $" AND t0e.FPPBOMBILLNO = '{ppbomNo}' ";
|
||||
|
||||
var sqlL = $@"/*dialect*/
|
||||
DECLARE @date datetime
|
||||
SET @date = '{dateTime}'
|
||||
|
||||
SELECT tt.*,t1.*--,t0b.FERPCLSID--3 委外 2 自制
|
||||
FROM ( {tableSql}
|
||||
) tt
|
||||
INNER JOIN T_BD_MATERIALSTOCK t0s on tt.FMATERIALID = t0s.FMATERIALID AND t0s.FISBATCHMANAGE = 1
|
||||
CROSS APPLY (
|
||||
SELECT TOP 1 tt.FBILLNO,tt.FMATERIALID,tt.FREALQTY,tt.FLOT,tt.FLOT_TEXT,tt.Seq
|
||||
FROM (
|
||||
SELECT TOP 10 t0.FBILLNO,t0e.FMATERIALID,t0e.FACTUALQTY 'FREALQTY',t0e.FLOT,t0e.FLOT_TEXT, 0 seq
|
||||
FROM T_SUB_PICKMTRL t0
|
||||
INNER JOIN T_SUB_PICKMTRLDATA t0e on t0.FID = t0e.FID
|
||||
WHERE 1=1 AND t0e.FLOT != 0
|
||||
AND t0e.FMATERIALID = tt.FMATERIALID
|
||||
AND t0.FCREATEDATE <= @date
|
||||
{hasPPBOMNO}
|
||||
ORDER BY t0.FCREATEDATE DESC
|
||||
UNION ALL
|
||||
SELECT '',0,0,0,RIGHT(CONVERT(varchar(100),CONVERT(int, CONVERT(VARCHAR(6),@date,112)) * 100 + DATEPART(ISO_WEEK, @date)),6),1 Seq
|
||||
) tt
|
||||
ORDER BY tt.FREALQTY DESC,tt.Seq ASC
|
||||
) t1
|
||||
|
||||
";
|
||||
|
||||
var res = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL);
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
LotField field = this.View.Model.BillBusinessInfo.GetField("FLOT") as LotField;
|
||||
|
||||
foreach (var item in res)
|
||||
{
|
||||
if (field.InputModel == LotField.Enum_InputModel.OnlySelect)
|
||||
{
|
||||
this.View.Model.SetValue("FLOT", item["FLOT"].Long2Int(), item["rowIdx"].Long2Int());
|
||||
}
|
||||
else
|
||||
{
|
||||
//this.View.Model.SetValue("FLOT", item["FLOT_TEXT"].ToString(), item["rowIdx"].Long2Int());
|
||||
this.View.Model.SetValue("FLOT", item["FLOT_TEXT"].ToString(), item["rowIdx"].Long2Int());
|
||||
}
|
||||
}
|
||||
|
||||
//this.View.UpdateView("FLOT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user