Bladeren bron

feat(announcements): 实现政策公告功能的完整业务逻辑

- 添加公告表单基础插件,实现创建新数据、绑定数据等核心方法
- 集成OperationStatus枚举,优化表单操作状态管理
- 实现公告发布、撤回、置顶、取消置顶、下架等操作的业务处理
- 添加单据状态管理和权限控制逻辑
- 新增公告列表插件,处理批量操作和状态更新功能
- 实现数据实体的动态加载和保存机制
- 添加用户界面的状态同步和可见性控制
turborao 4 dagen geleden
bovenliggende
commit
6e7d7a8012

+ 35 - 7
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/tsc/plugin/form/AnnouncementsBasePlugin.java

@@ -1,17 +1,17 @@
 package nckd.jxccl.hr.tsc.plugin.form;
 
+import kd.bos.bill.OperationStatus;
 import kd.bos.dataentity.entity.DynamicObject;
-import kd.bos.entity.datamodel.events.BizDataEventArgs;
 import kd.bos.form.events.BeforeDoOperationEventArgs;
 import kd.bos.form.operate.FormOperate;
 import kd.bos.servicehelper.user.UserServiceHelper;
-
 import kd.bos.base.AbstractBasePlugIn;
 import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
 import kd.sdk.plugin.Plugin;
-
 import nckd.jxccl.base.common.constant.FormConstant;
 import nckd.jxccl.base.swc.helper.SWCHelper;
+
+import java.util.EventObject;
 import java.util.List;
 
 /**
@@ -22,12 +22,11 @@ import java.util.List;
 @SuppressWarnings("unused")
 public class AnnouncementsBasePlugin extends AbstractBasePlugIn implements Plugin {
 
+
     @Override
-    public void createNewData(BizDataEventArgs e) {
-        super.createNewData(e);
+    public void afterCreateNewData(EventObject e) {
 
         Long userId = UserServiceHelper.getCurrentUserId();
-
         DynamicObject personUserDyn = SWCHelper.queryOne(FormConstant.HRPI_PERSONUSERREL, "employee.id","user",userId);
 
         Long empId = 0L;
@@ -47,6 +46,8 @@ public class AnnouncementsBasePlugin extends AbstractBasePlugIn implements Plugi
         if(empDyns != null && empDyns.length > 0){
             Long companyId = empDyns[0].getLong("company.id");
             this.getModel().setValue("nckd_hradminorg", companyId);
+            this.getModel().setValue("nckd_billstatus", "A");
+            this.getModel().setValue("nckd_istop", false);
         }
 
     }
@@ -55,7 +56,7 @@ public class AnnouncementsBasePlugin extends AbstractBasePlugIn implements Plugi
     public void beforeDoOperation(BeforeDoOperationEventArgs args) {
         FormOperate source = (FormOperate)args.getSource();
         String formOp = source.getOperateKey();
-        DynamicObject data = this.getModel().getDataEntity();
+        DynamicObject data = this.getModel().getDataEntity(true);
         String  billstatus =  data.getString("nckd_billstatus");
         HRBaseServiceHelper hrBaseServiceHelper = new HRBaseServiceHelper(FormConstant.NCKD_ANNOUNCEMENTS);
         if ("publish".equals(formOp)) {
@@ -84,4 +85,31 @@ public class AnnouncementsBasePlugin extends AbstractBasePlugIn implements Plugi
         }
     }
 
+    @Override
+    public void afterBindData(EventObject e) {
+        super.afterBindData(e);
+        DynamicObject data = this.getModel().getDataEntity(true);
+        setEnable(data);
+    }
+
+    public void setEnable(DynamicObject data) {
+        String  billstatus =  data.getString("nckd_billstatus");
+        if("A".equals(billstatus)){
+            this.getView().setStatus(OperationStatus.EDIT);
+            this.getView().setEnable(Boolean.TRUE, "nckd_downdate");
+            this.getView().setVisible(Boolean.TRUE, "bar_save");
+            this.getView().setVisible(Boolean.TRUE, "bar_modify");
+            this.getView().setVisible(Boolean.TRUE, "nckd_publish");
+            this.getView().setVisible(Boolean.FALSE, "nckd_withdrawn");
+        }else {
+            this.getView().setStatus(OperationStatus.VIEW);
+            this.getView().setEnable(Boolean.FALSE, "nckd_downdate");
+            this.getView().setVisible(Boolean.FALSE, "bar_save");
+            this.getView().setVisible(Boolean.FALSE, "bar_delete");
+            this.getView().setVisible(Boolean.FALSE, "bar_modify");
+            this.getView().setVisible(Boolean.FALSE, "nckd_publish");
+            this.getView().setVisible(Boolean.TRUE, "nckd_withdrawn");
+
+        }
+    }
 }

+ 89 - 0
code/hr/nckd-jxccl-hr/src/main/java/nckd/jxccl/hr/tsc/plugin/form/AnnouncementsListPlugin.java

@@ -0,0 +1,89 @@
+package nckd.jxccl.hr.tsc.plugin.form;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.entity.EntityMetadataCache;
+import kd.bos.entity.MainEntityType;
+import kd.bos.entity.datamodel.ListSelectedRowCollection;
+import kd.bos.form.events.AfterDoOperationEventArgs;
+import kd.bos.form.operate.FormOperate;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
+import kd.bos.servicehelper.user.UserServiceHelper;
+import kd.sdk.plugin.Plugin;
+import nckd.jxccl.base.common.constant.FormConstant;
+
+/**
+ * 政策公告列表插件
+ * @author turborao
+ * 时间 2026/1/13 16:05
+ */
+@SuppressWarnings("unused")
+public class AnnouncementsListPlugin extends AbstractListPlugin implements Plugin {
+
+    public void afterDoOperation(AfterDoOperationEventArgs args) {
+        super.afterDoOperation(args);
+        FormOperate formOperate = (FormOperate)args.getSource();
+        String key = formOperate.getOperateKey();
+        switch (key) {
+            case "publish":
+                setBillStatus("C",key);
+                break;
+            case "withdraw":
+                setBillStatus("A",key);
+                break;
+            case "top":
+                setBillStatus("A",key);
+                break;
+            case "untop":
+                setBillStatus("A",key);
+                break;
+            case "takedown":
+                setBillStatus("A",key);
+                break;
+        }
+    }
+
+    /**
+     * 设置单据状态
+     * @param billStatus
+     * A	待处理
+     * D	处理中
+     * C	已处理
+     * F	已忽略
+     */
+    public void setBillStatus(String billStatus,String operateKey) {
+        ListSelectedRowCollection selectedRows = this.getSelectedRows();
+        MainEntityType entityType= EntityMetadataCache.getDataEntityType(FormConstant.NCKD_ANNOUNCEMENTS);
+        DynamicObject[] billDyns = BusinessDataServiceHelper.load(selectedRows.getPrimaryKeyValues(), entityType);
+        for (DynamicObject billDyn : billDyns){
+            String billno = billDyn.getString("billno");
+            if(operateKey.equals("takedown") ){
+                billDyn.set("nckd_billstatus", billStatus);
+            }
+            if(operateKey.equals("withdraw") ){
+                billDyn.set("nckd_billstatus", billStatus);
+                billDyn.set("nckd_publishdate", null);
+                billDyn.set("nckd_publishuser", null);
+            }
+            if(operateKey.equals("publish") ){
+                billDyn.set("nckd_billstatus", "C");
+                billDyn.set("nckd_publishdate", new java.util.Date());
+                billDyn.set("nckd_publishuser", UserServiceHelper.getCurrentUserId());
+            }
+            if(operateKey.equals("untop") ){
+                billDyn.set("nckd_istop", false);
+            }
+            if(operateKey.equals("top") ){
+                billDyn.set("nckd_istop", true);
+            }
+        }
+
+        Object[] update = SaveServiceHelper.save(billDyns);
+        this.getView().showSuccessNotification(update.length + "条,操作成功", 3000);
+
+        this.getView().updateView();
+
+    }
+
+}