1、添加CP- PID变更申请类和属性:
名称:CP-PID变更流程申请单(com.forehope_elec.CPPIDChangeAppForm);
2、添加生命周期模板:
名称:FHEC_CP_PID_Change_Lifecycle;
3、添加对象初始化规则:
名称:FHEC_CP_PID_Change_App_Form;
4、添加工作流模板:
名称:CP-PID变更流程;
工作流模板:
5、添加表:FHEC_CP_PID_CHANGE_XMLOBJECT,具体表字段如下;
| 属性名称 | 字段中文名称 | 英文名称 | 属性类型 | 字段大小 | UI控件 | 备注 |
|---|---|---|---|---|---|---|
| pboRef | String | 30 | 保存升级请求,页面不展示 | |||
| erpChangeNumber | ERP ECN编号 | Erp Change Number | String | 50 | 自动生成,生成规则:PECN + 7位流水码 | |
| erpEffectivityDate | ERP生效日期 | Erp Effectivity Date | String | 50 | 自动生成,生成规则:yyyyMMdd | |
| pidNumber | PID 编号 | Pid Number | String | 50 | 发起变更的PID Number | |
| customCode | 客户三码 | Custom Code | String | 30 | ||
| lotType | 批次类型 | Lot Type | String | 30 | ||
| changeReason | 变更原因 | Change Reason | String | 300 | ||
| contentBeforeChange | 变更前内容 | Content Before Change | String | 300 | ||
| contentAfterChange | 变更后内容 | Content After Change | String | 300 | ||
| additionalAttachment | 附件 | Additional Attachment | AttachmentInfo | 附件属性无需添加表字段 | ||
| remark | 备注 | Remark | String | 300 |
1.利用上述信息通过申请单生成工具生成相关代码,将代码放到项目中。
特别注意 :
- 如果有附件类型的private AttachmentInfo需要手动改成下面代码。
// 附件
@WebFormAttribute(
label = @ResourceBundleKey(
resourceBundle = "ext.fhec.workflow.cp.resource.PidChangeRequestFormResource",
key = PidChangeRequestFormResource. ADDITIONAL_ATTACHMENT),
createGui = GuiComponentType.FILE_UPLOADER,
editGui = GuiComponentType.FILE_UPLOADER,
viewGui = GuiComponentType.TEXT
)
private AttachmentInfo additionalAttachment = new AttachmentInfo();
- 生成的jsp依赖可能缺少,需要从其他jsp文件中获取
2.有两个文件CpPidChangeAppFormCreateConfig和CpPidChangeAppFromWorkflowTemplate需要自己创建。
2.1.CpPidChangeAppFormCreateConfig创建时需要注意
2.2 CpPidChangeAppFromWorkflowTemplate创建时需要注意
3.表单信息页面,在这里面设置
codebase/netmarkets/jsp/ext/fhec/promotion/processFormInfo.jsp
<%
break;
case TypeAttributeConstant.FHEC_CP_PSNO_CHANGE_APP_FORM: // CP PSNO变更申请单
%>
<jsp:forward page="../cp/promotion/activity/CPPsNoChangeAppFormAppFormView.jsp"/>
4.config、templte和javabean都要在配置文件配置
5.发起申请单Delegate中 示例(CreatePidChangeRequestFormAppFormProcessorDelegate.java)
需要注意storeXmlObject方法,在保存已有的对象的时候,可能需要先查出来再保存
//先查出来数据再存
CpPidXmlObject cpPidXmlObject = (CpPidXmlObject) xmlObj;
String string = cpPidXmlObject.getIdentifier().toString().split(":")[1];
XmlObjectStoreManager storeManager = XWorksHelper.getXmlObjectStoreManager();
CpPidXmlObject cpPidXmlObject1 = (CpPidXmlObject) storeManager.load(new XmlObjectIdentifier(CpPidXmlObject.class.getName(), Long.parseLong(string)));
cpPidXmlObject1.setPackingType(cpPidXmlObject.getPackingType());
cpPidXmlObject1.setGrossDieQty(cpPidXmlObject.getGrossDieQty());
cpPidXmlObject1.setPackageSize(cpPidXmlObject.getPackageSize());
cpPidXmlObject1.setFabName(cpPidXmlObject.getFabName());
cpPidXmlObject1.setDiePart(cpPidXmlObject.getDiePart());
cpPidXmlObject1.setStorageType(cpPidXmlObject.getStorageType());
cpPidXmlObject1.setProductFeature(cpPidXmlObject.getProductFeature());
cpPidXmlObject1.setRouting(cpPidXmlObject.getRouting());
HashMap<String, ArrayList<String>> text = clientData.getText();
String deviceGroup = String.valueOf(text.get("deviceGroup"));
cpPidXmlObject1.setDeviceGroup(deviceGroup);
cpPidXmlObject1.setCreateReason(cpPidXmlObject.getCreateReason());
cpPidXmlObject1.setRemark(cpPidXmlObject.getRemark());
AppFormBean = this.getXmlObjectStoreManager().save(cpPidXmlObject1, StoreOptions.SaveOption.APPEND_AND_UPDATE);
6.在提交Delegate中,示例(EditPidChangeRequestFormAppFormProcessorDelegate.java)
需要修改copyAttributes方法,这个方法的作用是,把对象发生变化的字段赋值到原有对象上,如果不配置,会修改不成功
CpPidXmlObject cpPidXmlObject = null;
PidChangeRequestFormAppFormBean pidChangeRequestFormAppFormBean = null;
XmlObjectAttributeCollection attributeCollection = null;
if (xmlObjectFromWeb instanceof CpPidXmlObject) {
cpPidXmlObject = (CpPidXmlObject) xmlObjectFromWeb;
attributeCollection = XmlObjectAttributeConfigUtil.getCpPidXmlObjectAttr(clientData, cpPidXmlObject);
// 非附件类型属性集合
List<String> nonAttachmentAttributes = attributeCollection.getNonAttchmentAttributes();
if (CollectionUtils.isNotEmpty(nonAttachmentAttributes)) {
String[] attributeNames = nonAttachmentAttributes.toArray(new String[0]);
AttributeUtils.copyAttributes(xmlObjectFromWeb, xmlObjectInDatabase, attributeNames);
}
// 附件类型属性集合
List<String> attachmentAttributes = attributeCollection.getAttchmentAttributes();
if (CollectionUtils.isNotEmpty(attachmentAttributes)) {
String[] newAttachmentAttributes = attachmentAttributes.toArray(new String[0]);
this.handleAttachment(clientData, xmlObjectFromWeb, xmlObjectInDatabase,
newAttachmentAttributes);
}
7.发起申请单的jsp中,展示已有的对象信息,用EDIT(需要传 xmlObjectOid ),展示新建的用CREATE
例子:codebase/netmarkets/jsp/ext/fhec/cp/promotion/create/PidChangeRequestFormAppForm.jsp
获取对象
CpPid cpPid = (CpPid) PersistenceUtil.getPersistableByReferenceString(oid);
List<XmlObject> xmlObjects = PackageCodeHelper.getModuleXmlObject(cpPid, CpPidXmlObject.CP_PID_FORM_BEAN_ID);
if (xmlObjects != null && xmlObjects.size() > 0) {
cpPidXmlObject = (CpPidXmlObject) xmlObjects.get(0);
pidCreatexmlObjectOid = cpPidXmlObject.getIdentifier().toString();
}
CREATE模式
<%--PID变更基本信息--%>
<jsp:include
page="${mvc:getComponentURL('ext.fhec.workflow.cp.builder.PidChangeRequestFormAppFormAttributePanelBuilder')}">
<jsp:param name="operationType" value="CREATE"/>
<jsp:param name="oid" value="<%=oid%>"/>
<jsp:param name="contextObjectClassName" value="ext.fhec.workflow.cp.bean.PidChangeRequestFormAppFormBean"/>
<jsp:param name="componentId"
value="ext.fhec.workflow.cp.builder.PidChangeRequestFormAppFormAttributePanelBuilder "/>
<jsp:param name="layoutForView" value="<%=pidChangeLayout%>"/>
</jsp:include>
EDIT模式
<%--PID基础信息--%>
<jsp:include page="${mvc:getComponentURL('ext.fhec.workflow.cp.builder.CpPidCreateAppFormAttributePanelBuilder')}">
<jsp:param name="operationType" value="EDIT"/>
<jsp:param name="contextObjectClassName" value="ext.fhec.cp.bean.CpPidXmlObject"/>
<jsp:param name="xmlObjectOid" value="<%=pidCreatexmlObjectOid%>"/>
<jsp:param name="layoutForView" value="<%=cpPidCreateAppFormLayout%>"/>
<jsp:param name="componentId" value="ext.fhec.workflow.cp.builder.CpPidCreateAppFormAttributePanelBuilder"/>
</jsp:include>
8.通过点击按钮创建申请单参考codebase/netmarkets/jsp/ext/fhec/cp/promotion/create/initCpChangeAppForm.jsp
- 注意:在jsp页面上可以通过,获取到网址上的oid
Object oid = commandBean.getActionOid().getRefObject();
9.panelBuilder中想展示非本页的对象,可以用这个方法
@Override
public Object buildComponentData(ComponentConfig config, ComponentParams params) throws Exception {
NmHelperBean helperBean = ((JcaComponentParams) params).getHelperBean();
NmCommandBean nmCommandBean = helperBean.getNmCommandBean();
ObjectGuiComponentBuildContext buildContext = this.createObjectGuiComponentBuildContext(params);
buildContext.setComponentConfig(config);
this.prepareGuiComponentBuildContext(params, buildContext);
this.preBuildAttributePanelData(config, params, buildContext);
String cpPidXmlObject = nmCommandBean.getTextParameter("oid");
String operationType = nmCommandBean.getTextParameter("operationType");
//如果是VIEW或EDIT,我就不展示
if (operationType.equals("VIEW") || operationType.equals("EDIT")) {
Object componentData = this.buildAttributePanelData(config, params, buildContext);
return componentData;
}
if (StringUtils.isEmpty(cpPidXmlObject)) {
Object componentData = this.buildAttributePanelData(config, params, buildContext);
return componentData;
}
XmlSearchCriteria<CpPidXmlObject> criteria = new BaseXmlSearchCriteria<>(CpPidXmlObject.class);
criteria.addFilter(new ColumnFilter("pboRef", Operators.EQUAL, cpPidXmlObject));
List<XmlObject> search = XWorksHelper.getXmlObjectStoreManager().search(criteria, StoreOptions.LoadOption.ONLY_ROOT);
PidChangeRequestFormAppFormBean pidChangeRequestFormAppFormBean = new PidChangeRequestFormAppFormBean();
if (!search.isEmpty()) {
CpPidXmlObject cpPidXmlObject1 = (CpPidXmlObject) search.get(0);
// 自动生成ERP ECN编号,生成规则:PECN + 7位流水码
String nextSeq = DBUtil.getNextSequence("PECN" + "1");
DecimalFormat seqNumberFormat = new DecimalFormat("0000000");
String serialNumber = seqNumberFormat.format(Long.parseLong(nextSeq));
pidChangeRequestFormAppFormBean.setErpChangeNumber(serialNumber);
// 自动Erp Effectivity Date,生成规则:yyyyMMdd
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
String dateStr = dateFormat.format(new Date());
pidChangeRequestFormAppFormBean.setErpEffectivityDate(dateStr);
// 设置PidNumber
pidChangeRequestFormAppFormBean.setPidNumber(cpPidXmlObject1.getPidNumber());
// 设置LotType
pidChangeRequestFormAppFormBean.setLotType(cpPidXmlObject1.getLotType());
//设置客户码
pidChangeRequestFormAppFormBean.setCustomCode(cpPidXmlObject1.getCustomerCode());
}
//构建展示数据
buildContext.setContextObject(pidChangeRequestFormAppFormBean);
Object componentData = this.buildAttributePanelData(config, params, buildContext);
return componentData;
}
-
panelbuilder中的大坑,用申请单工具生成的panelbuilder
1.group1Attributes默认为空
String[] group1Attributes = {
"erpChangeNumber","erpEffectivityDate",
"customCode","lotType",
"changeReason","contentBeforeChange",
"contentAfterChange","remark",
};
2.没有这个语句,panel肯定展示不出来
panel.addComponent(group1);
注意:开发中遇到的问题
@ActivityNodeDef(
nodeId = "F1T3_PROCESS_PE_AUDIT", // 任务节点ID,在工作流任务的说明中
name = @ResourceBundleKey,
phaseName = "F1T3_PROCESS_PE_AUDIT", // 流程节点名称,和上面的流程节点定义对应起来
description = "F1T3_PROCESS_PE_AUDIT", // 代码描述,相当于注释
enableApplicationForm = true, // 是否需要启用表单
applicationFormJspPath = "/netmarkets/jsp/ext/fhec/ft/promotion/activity/FTBakingProcedureInformationApplicationFormAppFormView.jsp", // 任务页面使用的jsp
customizedTaskTab = @CustomizedTaskTab(
enabled = true, // 流程页面配置,相当于任务表格模板
` tabs = {
@TaskTab(name = "taskDetailsDetails", label = @ResourceBundleKey(resourceBundle = "ext.fhec.workflow.promotion.resource.PromotionLayoutResource", key = "WORKITEM_TASKDETAILSDETAILS_DESCRIPTION"),
actions = {
@ActionComponent(objectType = "workitem", name = "attributes"),
@ActionComponent(objectType = "workitem", name = "taskDetailExtendedFrame")
},
pboActions = {@ActionComponent(objectType = "promotionRequest", name = "edit")}
),
@TaskTab(name = "taskDetailsAdhoc", label = @ResourceBundleKey(resourceBundle = "wt.workflow.worklist.worklistResource", key = "object.taskDetailsAdhoc.description"),`
actions = {@ActionComponent(objectType = "workitem", name = "adhocActivities")}
),
})
)
String F1T3_PROCESS_PE_AUDIT = "F1T3_PROCESS_PE_AUDIT"; // 该常量仅用于承载Annotation,并没有任何实际用途
这段代码中的
customizedTaskTab = @CustomizedTaskTab( enabled = true, // 流程页面配置,相当于任务表格模板 `
tabs = { @TaskTab(name = "taskDetailsDetails", label = @ResourceBundleKey(resourceBundle = "ext.fhec.workflow.promotion.resource.PromotionLayoutResource", key = "WORKITEM_TASKDETAILSDETAILS_DESCRIPTION"), actions = { @ActionComponent(objectType = "workitem", name = "attributes"), @ActionComponent(objectType = "workitem", name = "taskDetailExtendedFrame") }, pboActions = {@ActionComponent(objectType = "promotionRequest", name = "edit")} ), @TaskTab(name = "taskDetailsAdhoc", label = @ResourceBundleKey(resourceBundle = "wt.workflow.worklist.worklistResource", key = "object.taskDetailsAdhoc.description"),` actions = {@ActionComponent(objectType = "workitem", name = "adhocActivities")} ), })
是固定的 不要随便修改,会报2025-06-27 09:35:22,299 ERROR [ajp-nio-127.0.0.1-8010-exec-7] com.ptc.xworks.workflow.builders.ExtendedWorkflowTaskPageTabDelegate wcadmin - Cannot get NmAction by workitem.a