1 Star 0 Fork 0

momoxxx/cq.Plugins

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
QiezhangXQDToPGD_Convert.cs 4.37 KB
一键复制 编辑 原始数据 按行查看 历史
momoxxx 提交于 2024-01-09 14:40 . 添加项目文件。
using Kingdee.BOS;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Resource;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
namespace JW.Plugins
{
[Description("切张需求列表下推-派工")]
public class QiezhangXQDToPGD_Convert : AbstractConvertPlugIn
{
public override void OnInSelectedRow(InSelectedRowEventArgs e)
{
if (!string.IsNullOrEmpty(e.SelectedRows.FirstOrDefault<ListSelectedRow>().EntryPrimaryKeyValue))
{
//下推插件,1、多选需求时需校验物料一致性
if (!e.PkKey.EqualsIgnoreCase(e.SourceBusinessInfo.GetForm().PkFieldName))
{
IEnumerable<string> values =
from p in e.SelectedRows
where !string.IsNullOrEmpty(p.EntryPrimaryKeyValue)
select p.EntryPrimaryKeyValue;
string ids = string.Join(",", values);
string text = this.chkMtrlisSame(e.Context, ids);
if (!text.Equals("1"))
{
throw new KDExceptionValidate("convert", ResManager.LoadKDString("不符合下推条件", "004002030004060", SubSystemType.SCM, new object[0]), ResManager.LoadKDString("请选择相同产品的记录进行下推!", "004002030004063", SubSystemType.SCM, new object[0]));
}
}
}
base.OnInSelectedRow(e);
}
private string GetNeedQuotaData(GetSourceDataEventArgs e)
{
string FEntryIDSTR = "";
foreach (DynamicObject current in e.SourceData)
{
string FEntryID = current["FEntity_FEntryID"].ToString();
FEntryIDSTR = FEntryID + "," + FEntryIDSTR;
}
if (FEntryIDSTR.EndsWith(","))
FEntryIDSTR = FEntryIDSTR.SubStr(0, FEntryIDSTR.Length - 1);
return FEntryIDSTR;
}
//下推插件,多选需求时需校验物料一致性
public override void OnGetSourceData(GetSourceDataEventArgs e)
{
if (e.SourceData != null && e.SourceData.Count > 0)
{
string FEntryIDSTR = "";
FEntryIDSTR = this.GetNeedQuotaData(e);
string text = this.chkMtrlisSame(e.Context, FEntryIDSTR);
if (!text.Equals("1"))
{
throw new KDExceptionValidate("convert", ResManager.LoadKDString("不符合下推条件", "004002030004060", SubSystemType.SCM, new object[0]), ResManager.LoadKDString("请选择相同产品的记录进行下推!", "004002030004063", SubSystemType.SCM, new object[0]));
}
}
base.OnGetSourceData(e);
}
private string GetCobyEntryIds(Context ctx, string ids)
{
string strSQL = string.Format("SELECT t1.FENTRYID FROM T_PUR_POORDERENTRY t1\r\njoin T_PUR_POORDERENTRY t2 on t1.FID=t2.FID and t1.FGROUP=t2.FGROUP \r\nleft join T_PUR_POORDER T3 ON T3.Fid=T1.Fid \r\nWHERE t2.FENTRYID in ({0}) AND t1.FPRODUCTTYPE<>'1' AND T3.Fbusinesstype='WW' ", ids);
List<long> values = (
from p in DBUtils.ExecuteEnumerable(ctx, strSQL, CommandType.Text, new SqlParam[0])
select Convert.ToInt64(p.GetValue(0))).ToList<long>();
return string.Join<long>(",", values);
}
/// <summary>
/// 1、多选需求时需校验物料一致性
/// </summary>
/// <param name="ctx"></param>
/// <param name="ids"></param>
/// <returns></returns>
private string chkMtrlisSame(Context ctx, string ids)
{
string strSQL = string.Format("SELECT count( distinct F_UUU_BASE_WL) cnt FROM uuu_t_Cust100035 T1 JOIN uuu_t_Cust_Entry100113 T2 ON T1.FID =T2.FID where T2.FENTRYID in ({0})", ids);
List<long> values = (
from p in DBUtils.ExecuteEnumerable(ctx, strSQL, CommandType.Text, new SqlParam[0])
select Convert.ToInt64(p.GetValue(0))).ToList<long>();
return string.Join<long>(",", values);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/momoxxx/cq.-plugins.git
git@gitee.com:momoxxx/cq.-plugins.git
momoxxx
cq.-plugins
cq.Plugins
master

搜索帮助