345 lines
15 KiB
C#
345 lines
15 KiB
C#
using Kingdee.BOS;
|
|
using Kingdee.BOS.Core.List;
|
|
using Kingdee.BOS.BusinessEntity.BillTrack;
|
|
using Kingdee.BOS.Core.DynamicForm;
|
|
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
|
using Kingdee.BOS.Core.List.PlugIn.Args;
|
|
using Kingdee.BOS.Core.Metadata;
|
|
using Kingdee.BOS.Core.Metadata.ConvertElement;
|
|
using Kingdee.BOS.Core.Metadata.EntityElement;
|
|
//using Kingdee.BOS.Core.Report.PlugIn;
|
|
//using Kingdee.BOS.Core.Report.PlugIn.Args;
|
|
using Kingdee.BOS.Orm.DataEntity;
|
|
using Kingdee.K3.Core.MFG.EntityHelper;
|
|
using Kingdee.BOS.Resource;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Kingdee.BOS.BusinessEntity.BusinessFlow;
|
|
using Kingdee.BOS.Core.BusinessFlow.ServiceArgs;
|
|
using Kingdee.BOS.ServiceHelper;
|
|
using Kingdee.K3.MFG.ServiceHelper.SFC;
|
|
|
|
namespace HW.ProductionMaterialsReport
|
|
{
|
|
public class TablePlugIn : AbstractDynamicFormPlugIn
|
|
{
|
|
private readonly string _fromId;
|
|
|
|
//public override void FormatCellValue(FormatCellValueArgs args)
|
|
//{
|
|
// var billParam = new BillShowParameter();
|
|
|
|
//}
|
|
|
|
//public override void CellDbClick(CellEventArgs args)
|
|
//{
|
|
// base.CellDbClick(args);
|
|
|
|
//}
|
|
private void ListShowFrom()
|
|
{
|
|
//ListShowParameter showParam = new ListShowParameter();
|
|
//showParam.IsLookUp = false;
|
|
//showParam.OpenStyle.ShowType = ShowType.Modal;
|
|
//showParam.FormId = "YourFormId";
|
|
//showParam.Width = 1000;
|
|
//showParam.Height = 600;
|
|
//showParam.IsShowQuickFilter = false;
|
|
|
|
//ListRegularFilterParameter regularFilterPara = new ListRegularFilterParameter();
|
|
//string filter = "YourFilterCondition";
|
|
//regularFilterPara.Filter = filter;
|
|
//showParam.ListFilterParameter = regularFilterPara;
|
|
|
|
//this.View.ShowForm(showParam);
|
|
}
|
|
|
|
protected void TrckDown()
|
|
{
|
|
List<DynamicObject> selectedRows = this.GetSelectedRows();
|
|
if (selectedRows.Count == 0)
|
|
{
|
|
this.View.ShowMessage(ResManager.LoadKDString("请选择需要下查的的分录!", "015649000004851", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
return;
|
|
}
|
|
ViewLinkDataParameter viewLinkDataParameter = this.BuildViewLinkDataParameter();
|
|
ShowConvertOpFormEventArgs thirdConvertEventArgs = null;
|
|
List<ConvertBillElement> list = this.LoadConvertBills(viewLinkDataParameter, out thirdConvertEventArgs);
|
|
if (list == null || list.Count == 0)
|
|
{
|
|
this.View.ShowMessage(ResManager.LoadKDString("没有关联业务数据!", "015649000004852", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
return;
|
|
}
|
|
if (!this.ExistsTrackerData(viewLinkDataParameter, thirdConvertEventArgs))
|
|
{
|
|
this.View.ShowMessage(ResManager.LoadKDString("没有关联业务数据!", "015649000004852", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
return;
|
|
}
|
|
this.ShowLookUpTrackerForm(viewLinkDataParameter, list, thirdConvertEventArgs);
|
|
}
|
|
|
|
private bool ExistsTrackerData(ViewLinkDataParameter viewParameter, ShowConvertOpFormEventArgs thirdConvertEventArgs)
|
|
{
|
|
if (thirdConvertEventArgs.ReplaceRelations != null && thirdConvertEventArgs.ReplaceRelations.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
if (viewParameter.Instances.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
string formId = viewParameter.BillInfo.FormId;
|
|
foreach (KeyValuePair<string, List<BusinessFlowInstance>> keyValuePair in viewParameter.Instances)
|
|
{
|
|
string key = keyValuePair.Key;
|
|
List<BusinessFlowInstance> value = keyValuePair.Value;
|
|
TableDefine tableDefine = BusinessFlowServiceHelper.LoadTableDefine(this.View.Context, formId, key);
|
|
List<BusinessFlowInstance> list = new List<BusinessFlowInstance>();
|
|
foreach (BusinessFlowInstance businessFlowInstance in value)
|
|
{
|
|
if (!this.ValidateInstance(businessFlowInstance, viewParameter.LookUpType, tableDefine.TableNumber))
|
|
{
|
|
list.Add(businessFlowInstance);
|
|
}
|
|
}
|
|
foreach (BusinessFlowInstance item in list)
|
|
{
|
|
value.Remove(item);
|
|
}
|
|
}
|
|
foreach (KeyValuePair<string, List<BusinessFlowInstance>> keyValuePair2 in viewParameter.Instances)
|
|
{
|
|
List<BusinessFlowInstance> value2 = keyValuePair2.Value;
|
|
if (value2.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool ValidateInstance(BusinessFlowInstance instance, ViewLinkDataParameter.Enum_LookUpType lookUpType, string tableNumber)
|
|
{
|
|
if (instance.FirstNode == null)
|
|
{
|
|
return false;
|
|
}
|
|
List<RouteTreeNode> list = instance.SerarchTargetFormNodes(tableNumber);
|
|
if (lookUpType == ViewLinkDataParameter.Enum_LookUpType.Down)
|
|
{
|
|
using (List<RouteTreeNode>.Enumerator enumerator = list.GetEnumerator())
|
|
{
|
|
while (enumerator.MoveNext())
|
|
{
|
|
RouteTreeNode routeTreeNode = enumerator.Current;
|
|
if (routeTreeNode.ChildNodes.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
foreach (RouteTreeNode routeTreeNode2 in list)
|
|
{
|
|
if (routeTreeNode2.ParentNode != null)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private FormMetadata _oplanMeta;
|
|
|
|
protected FormMetadata OPlanMetaData
|
|
{
|
|
get
|
|
{
|
|
if (this._oplanMeta == null)
|
|
{
|
|
this._oplanMeta = (MetaDataServiceHelper.Load(this.View.Context, "SFC_OperationPlanning", true) as FormMetadata);
|
|
}
|
|
return this._oplanMeta;
|
|
}
|
|
}
|
|
|
|
protected List<ConvertBillElement> LoadConvertBills(ViewLinkDataParameter viewParameter, out ShowConvertOpFormEventArgs thirdConvertEventArgs)
|
|
{
|
|
List<ConvertBillElement> list = ConvertServiceHelper.GetConvertBills(this.View.Context, FormOperationEnum.Push, viewParameter.BillInfo.FormId, false);
|
|
DynamicFormViewPlugInProxy service = this.View.GetService<DynamicFormViewPlugInProxy>();
|
|
thirdConvertEventArgs = new ShowConvertOpFormEventArgs(FormOperationEnum.TrackDown, list);
|
|
if (service != null)
|
|
{
|
|
new List<ListSelectedRow>();
|
|
thirdConvertEventArgs.SelectedRows = this.GetSelectedEntityRows();
|
|
list = (thirdConvertEventArgs.Bills as List<ConvertBillElement>);
|
|
}
|
|
if (list == null || list.Count == 0)
|
|
{
|
|
this.View.ShowMessage(ResManager.LoadKDString("从启用的单据转换流程中找不到可下查的单据", "015649000004854", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
return new List<ConvertBillElement>();
|
|
}
|
|
return list;
|
|
}
|
|
|
|
public ListSelectedRow[] GetSelectedEntityRows()
|
|
{
|
|
List<ListSelectedRow> list = new List<ListSelectedRow>();
|
|
List<DynamicObject> selectedRows = this.GetSelectedRows();
|
|
foreach (DynamicObject dynamicObject in selectedRows)
|
|
{
|
|
long dynamicObjectItemValue = dynamicObject.GetDynamicObjectItemValue("OperId", 0L);
|
|
list.Add(new ListSelectedRow(this.currNodeID, dynamicObjectItemValue.ToString(), 0, this._oplanMeta.Id)
|
|
{
|
|
EntryEntityKey = "FENTITY"
|
|
});
|
|
}
|
|
if (list.Count == 0)
|
|
{
|
|
ListSelectedRow item = new ListSelectedRow(this.currNodeID, "0", 0, this._oplanMeta.Id);
|
|
list.Add(item);
|
|
}
|
|
return list.ToArray();
|
|
}
|
|
|
|
private ViewLinkDataParameter BuildViewLinkDataParameter()
|
|
{
|
|
if (!this.CheckSelectDataId() && this.GetSelectedRows().Count == 0)
|
|
{
|
|
this.View.ShowMessage(ResManager.LoadKDString("没有选择要下查的数据!", "015649000004853", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
return null;
|
|
}
|
|
Dictionary<string, List<Tuple<long, long>>> linkIds = this.GetLinkIds();
|
|
ViewLinkDataParameter viewLinkDataParameter = new ViewLinkDataParameter(this.OPlanMetaData.Id, ViewLinkDataParameter.Enum_LookUpType.Down);
|
|
foreach (KeyValuePair<string, List<Tuple<long, long>>> keyValuePair in linkIds)
|
|
{
|
|
string key = keyValuePair.Key;
|
|
List<Tuple<long, long>> value = keyValuePair.Value;
|
|
foreach (Tuple<long, long> tuple in value)
|
|
{
|
|
ViewLinkDataRowInfo item = new ViewLinkDataRowInfo(key, tuple.Item1, tuple.Item2);
|
|
viewLinkDataParameter.BillInfo.Rows.Add(item);
|
|
}
|
|
}
|
|
this.BuildInstanceParameter(viewLinkDataParameter, linkIds);
|
|
return viewLinkDataParameter;
|
|
}
|
|
|
|
private string currNodeID = string.Empty;
|
|
|
|
protected Dictionary<string, List<Tuple<long, long>>> GetLinkIds()
|
|
{
|
|
Dictionary<string, List<Tuple<long, long>>> dictionary = new Dictionary<string, List<Tuple<long, long>>>();
|
|
List<long> list = new List<long>();
|
|
List<Tuple<long, long>> list2 = new List<Tuple<long, long>>();
|
|
long num = Convert.ToInt64(this.currNodeID);
|
|
list.Add(num);
|
|
list2.Add(new Tuple<long, long>(num, num));
|
|
dictionary.Add("FBILLHEAD", list2);
|
|
List<long> list3 = new List<long>();
|
|
List<Tuple<long, long>> list4 = new List<Tuple<long, long>>();
|
|
List<DynamicObject> selectedRows = this.GetSelectedRows();
|
|
foreach (DynamicObject dynamicObject in selectedRows)
|
|
{
|
|
long dynamicObjectItemValue = dynamicObject.GetDynamicObjectItemValue("SeqId", 0L);
|
|
if (!list3.Contains(dynamicObjectItemValue))
|
|
{
|
|
list3.Add(dynamicObjectItemValue);
|
|
list4.Add(new Tuple<long, long>(num, dynamicObjectItemValue));
|
|
}
|
|
}
|
|
if (list3.Count > 0)
|
|
{
|
|
dictionary.Add("FENTITY", list4);
|
|
}
|
|
return dictionary;
|
|
}
|
|
|
|
|
|
private bool CheckSelectDataId()
|
|
{
|
|
bool result = true;
|
|
object value = this.Model.GetValue("FOPlanID");
|
|
if (value == null)
|
|
{
|
|
result = false;
|
|
this.View.ShowMessage(ResManager.LoadKDString("没有选择工序计划!", "015376000004785", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
}
|
|
long num = Convert.ToInt64(value);
|
|
if (num == 0L)
|
|
{
|
|
result = false;
|
|
this.View.ShowMessage(ResManager.LoadKDString("没有选择工序计划!", "015376000004785", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
}
|
|
if (!ShopWorkBenchServiceHelper.IsExistOPlan(base.Context, num))
|
|
{
|
|
result = false;
|
|
this.View.ShowMessage(ResManager.LoadKDString("工序计划已经删除,请刷新界面或重新选择其他工序计划!", "015376000004804", SubSystemType.MFG, new object[0]), MessageBoxType.Notice);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private void BuildInstanceParameter(ViewLinkDataParameter viewParameter, Dictionary<string, List<Tuple<long, long>>> allEntityIds)
|
|
{
|
|
string formId = viewParameter.BillInfo.FormId;
|
|
foreach (KeyValuePair<string, List<Tuple<long, long>>> keyValuePair in allEntityIds)
|
|
{
|
|
string key = keyValuePair.Key;
|
|
List<Tuple<long, long>> value = keyValuePair.Value;
|
|
List<long> list = (from p in value
|
|
select p.Item2).ToList<long>();
|
|
BusinessFlowInstanceCollection businessFlowInstanceCollection = this.LoadInstances(this.View.Context, formId, key, list.ToArray());
|
|
List<BusinessFlowInstance> list2 = new List<BusinessFlowInstance>();
|
|
foreach (BusinessFlowInstance businessFlowInstance in businessFlowInstanceCollection)
|
|
{
|
|
if (businessFlowInstance.FirstNode != null)
|
|
{
|
|
list2.Add(businessFlowInstance);
|
|
}
|
|
}
|
|
if (list2.Count > 0)
|
|
{
|
|
viewParameter.Instances[key] = list2;
|
|
}
|
|
}
|
|
}
|
|
|
|
public BusinessFlowInstanceCollection LoadInstances(Context ctx, string formId, string entityKey, long[] entityIds)
|
|
{
|
|
LoadInstancesByEntityIdArgs args = new LoadInstancesByEntityIdArgs(formId, entityKey, entityIds);
|
|
return BusinessFlowDataServiceHelper.LoadInstancesByEntityId(ctx, args);
|
|
}
|
|
|
|
private bool ShowLookUpTrackerForm(ViewLinkDataParameter viewParamter, List<ConvertBillElement> convertBills, ShowConvertOpFormEventArgs thirdConvertEventArgs)
|
|
{
|
|
if (convertBills != null && convertBills.Count > 0)
|
|
{
|
|
string key = "LookUpTrackerParam";
|
|
Dictionary<string, object> dictionary = new Dictionary<string, object>();
|
|
dictionary["ViewParameter"] = viewParamter;
|
|
dictionary["ConvertBills"] = convertBills;
|
|
dictionary["PlugParam"] = thirdConvertEventArgs;
|
|
this.View.Session[key] = dictionary;
|
|
DynamicFormShowParameter dynamicFormShowParameter = new DynamicFormShowParameter();
|
|
dynamicFormShowParameter.FormId = "BF_LookUpTracker";
|
|
dynamicFormShowParameter.ParentPageId = this.View.PageId;
|
|
dynamicFormShowParameter.OpenStyle.ShowType = ShowType.Default;
|
|
this.View.ShowForm(dynamicFormShowParameter);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private List<DynamicObject> GetSelectedRows()
|
|
{
|
|
EntryEntity entryEntity = this.View.BusinessInfo.GetEntryEntity("FDetailEntity");
|
|
List<DynamicObject> list = new List<DynamicObject>();
|
|
return (from w in this.Model.GetEntityDataObject(entryEntity)
|
|
where w.GetDynamicObjectItemValue("IsSelect", false)
|
|
select w).ToList();
|
|
}
|
|
}
|
|
}
|