|
|
@@ -0,0 +1,190 @@
|
|
|
+package nckd.fi.er.formplugin;
|
|
|
+
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.dataentity.resource.ResManager;
|
|
|
+import kd.bos.dataentity.serialization.SerializationUtils;
|
|
|
+import kd.bos.dataentity.utils.ObjectUtils;
|
|
|
+import kd.bos.dataentity.utils.StringUtils;
|
|
|
+import kd.bos.entity.datamodel.IDataModel;
|
|
|
+import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
+import kd.bos.form.*;
|
|
|
+import kd.bos.form.control.Control;
|
|
|
+import kd.bos.form.events.ClientCallBackEvent;
|
|
|
+import kd.bos.form.events.ClosedCallBackEvent;
|
|
|
+import kd.bos.form.events.MessageBoxClosedEvent;
|
|
|
+import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
+import kd.bos.openapi.form.plugin.OpenApiEntityPropertyPlugin;
|
|
|
+import kd.bos.openapi.form.util.FormOpener;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+
|
|
|
+import java.util.EventObject;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created with IntelliJ IDEA.
|
|
|
+ *
|
|
|
+ * @Author: 赵嘉琪
|
|
|
+ * @Date: 2026/01/12
|
|
|
+ * @Description:
|
|
|
+ */
|
|
|
+public class IntegraConfigFromPlugin extends AbstractFormPlugin {
|
|
|
+ //国资委数据采集平台资源表
|
|
|
+ private static final String NCKD_GZW_DATA_KEY = "nckd_gzwtdataplatform";
|
|
|
+
|
|
|
+ // 字段名常量
|
|
|
+ private static final String FIELD_NCKD_TABLE_APIFIELD = "nckd_apifield";
|
|
|
+ private static final String FIELD_NCKD_APITABLENAME = "nckd_apitablename";
|
|
|
+
|
|
|
+ private static final String FIELD_NCKD_TABLENUMBER = "nckd_tablenumber";
|
|
|
+ private static final String FIELD_NCKD_TABLENAME = "nckd_tablename";
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void registerListener(EventObject e) {
|
|
|
+ super.registerListener(e);
|
|
|
+ this.addClickListeners("nckd_combofield");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void propertyChanged(PropertyChangedArgs e) {
|
|
|
+ super.propertyChanged(e);
|
|
|
+ String fieldKey = e.getProperty().getName();
|
|
|
+
|
|
|
+ if (StringUtils.equals(NCKD_GZW_DATA_KEY, fieldKey)) {
|
|
|
+ DynamicObject newValue = (DynamicObject) e.getChangeSet()[0].getNewValue();
|
|
|
+ DynamicObject oldValue = (DynamicObject)e.getChangeSet()[0].getOldValue();
|
|
|
+
|
|
|
+ // 单据状态 已审核 / 使用状态 可用
|
|
|
+ QFilter baseQFOne = new QFilter("status", QCP.equals, "C")
|
|
|
+ .and("id", QCP.equals, newValue.getLong("id"))
|
|
|
+ .and("enable", QCP.equals, "1");
|
|
|
+
|
|
|
+ // 国资委数据采集平台资源表
|
|
|
+ DynamicObject nckdGzwtdataplatforms = BusinessDataServiceHelper.loadSingle(
|
|
|
+ "nckd_gzwtdataplatform",
|
|
|
+ "id,nckd_entryentity.nckd_tablenumber,nckd_entryentity.nckd_tablename",
|
|
|
+ baseQFOne.toArray()
|
|
|
+ );
|
|
|
+
|
|
|
+ // 国资委数据采集平台资源表 -- 单据体
|
|
|
+ DynamicObjectCollection gzwEntryentityList = nckdGzwtdataplatforms.getDynamicObjectCollection("nckd_entryentity");
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(gzwEntryentityList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("nckd_entryentity");
|
|
|
+
|
|
|
+ // 检查当前单据体是否为空
|
|
|
+ if (!ObjectUtils.isEmpty(entryEntity) && entryEntity.size() > 0) {
|
|
|
+ // 不为空时,提示用户确认是否替换数据
|
|
|
+ ConfirmCallBackListener confirmCallBackListener = new ConfirmCallBackListener("nckd_gzwtdataplatform", this);
|
|
|
+ this.getView().showConfirm("是否确认同步资源表数据至国资委资源表字段及标识?", MessageBoxOptions.YesNo, confirmCallBackListener);
|
|
|
+ } else {
|
|
|
+ this.getModel().setValue("nckd_gzwtdataform_copy", newValue);
|
|
|
+ // 直接添加数据
|
|
|
+ updateEntryData(gzwEntryentityList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
|
|
+ super.confirmCallBack(messageBoxClosedEvent);
|
|
|
+
|
|
|
+ if ("nckd_gzwtdataplatform".equals(messageBoxClosedEvent.getCallBackId()) && MessageBoxResult.Yes.equals(messageBoxClosedEvent.getResult())){
|
|
|
+ // 用户选择"是" - 更新数据
|
|
|
+ DynamicObject nckdGzwtdataplatform = (DynamicObject) this.getModel().getValue("nckd_gzwtdataplatform");
|
|
|
+ Long gzwtdataId = nckdGzwtdataplatform.getLong("id");
|
|
|
+
|
|
|
+ // 单据状态 已审核 / 使用状态 可用
|
|
|
+ QFilter baseQFOne = new QFilter("status", QCP.equals, "C")
|
|
|
+ .and("id", QCP.equals, gzwtdataId)
|
|
|
+ .and("enable", QCP.equals, "1");
|
|
|
+
|
|
|
+ DynamicObject gzwtdataplatform = BusinessDataServiceHelper.loadSingle(
|
|
|
+ "nckd_gzwtdataplatform",
|
|
|
+ "id,nckd_entryentity.nckd_tablenumber,nckd_entryentity.nckd_tablename",
|
|
|
+ baseQFOne.toArray()
|
|
|
+ );
|
|
|
+
|
|
|
+ // 国资委数据采集平台资源表 -- 单据体
|
|
|
+ DynamicObjectCollection gzwEntryentityList = gzwtdataplatform.getDynamicObjectCollection("nckd_entryentity");
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(gzwEntryentityList)) {
|
|
|
+ // 更新数据
|
|
|
+ updateEntryData(gzwEntryentityList);
|
|
|
+ } else {
|
|
|
+ this.getModel().deleteEntryData("nckd_entryentity");
|
|
|
+ }
|
|
|
+ this.getModel().setValue("nckd_gzwtdataform_copy", gzwtdataplatform);
|
|
|
+ } else {
|
|
|
+ this.getModel().beginInit();
|
|
|
+ Object nckdGzwtdataformCopy = this.getModel().getValue("nckd_gzwtdataform_copy");
|
|
|
+ // 用户选择"否" - 恢复原始基础资料
|
|
|
+
|
|
|
+ this.getModel().setValue("nckd_gzwtdataplatform", nckdGzwtdataformCopy);
|
|
|
+ this.getView().updateView("nckd_gzwtdataplatform");
|
|
|
+ this.getModel().endInit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新单据体数据
|
|
|
+ */
|
|
|
+ private void updateEntryData(DynamicObjectCollection gzwEntryentityList) {
|
|
|
+ // 清空现有数据
|
|
|
+ this.getModel().deleteEntryData("nckd_entryentity");
|
|
|
+
|
|
|
+ // 批量创建新行
|
|
|
+ this.getModel().batchCreateNewEntryRow("nckd_entryentity", gzwEntryentityList.size());
|
|
|
+
|
|
|
+ // 将数据回填到界面
|
|
|
+ int rowIndex = 0;
|
|
|
+ for (DynamicObject gzwEntity : gzwEntryentityList) {
|
|
|
+ this.getModel().setValue(FIELD_NCKD_TABLE_APIFIELD, gzwEntity.get(FIELD_NCKD_TABLENUMBER), rowIndex);
|
|
|
+ this.getModel().setValue(FIELD_NCKD_APITABLENAME, gzwEntity.get(FIELD_NCKD_TABLENAME), rowIndex);
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterCreateNewData(EventObject e) {
|
|
|
+ super.afterCreateNewData(e);
|
|
|
+ this.getModel().deleteEntryData("nckd_entryentity");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void click(EventObject evt) {
|
|
|
+ super.click(evt);
|
|
|
+ Control c = (Control) evt.getSource();
|
|
|
+ String key = c.getKey();
|
|
|
+ if (StringUtils.equals("nckd_combofield", key)) {
|
|
|
+ //业务对象
|
|
|
+ DynamicObject bizObject = (DynamicObject) getModel().getValue("nckd_entityobject");
|
|
|
+ if (null == bizObject) {
|
|
|
+ this.getView().showTipNotification("请先选择关联业务实体");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //显示关联属性界面
|
|
|
+ showEntityProperty(bizObject, "nckd_combofield");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示关联属性界面
|
|
|
+ * @param bizObject
|
|
|
+ */
|
|
|
+ private void showEntityProperty(DynamicObject bizObject, String callback) {
|
|
|
+ Map<String, Object> param = new HashMap(5);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|