浏览代码

附件下载插件测试6

turborao 3 天之前
父节点
当前提交
213f4bbc53

+ 25 - 0
code/base/nckd-jimin-base-helper/src/main/java/nckd/base/helper/AttachmentDownloadListPlugin.java

@@ -1,10 +1,13 @@
 package nckd.base.helper;
 
+import kd.bos.dataentity.OperateOption;
+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.entity.operate.result.OperationResult;
 import kd.bos.ext.fi.bei.util.EmptyUtil;
+import kd.bos.ext.fi.plugin.ArApConvert.util.EmptyUtils;
 import kd.bos.fileservice.FileService;
 import kd.bos.fileservice.FileServiceFactory;
 import kd.bos.fileservice.extension.FileServiceExtFactory;
@@ -19,9 +22,13 @@ import kd.bos.metadata.dao.MetadataDao;
 import kd.bos.metadata.form.ControlAp;
 import kd.bos.metadata.form.FormMetadata;
 import kd.bos.metadata.form.control.AttachmentPanelAp;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
 import kd.bos.servicehelper.AttachmentDto;
 import kd.bos.servicehelper.AttachmentServiceHelper;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.attachment.AttachmentFieldServiceHelper;
+import kd.bos.servicehelper.operation.OperationServiceHelper;
 import kd.bos.util.StringUtils;
 import kd.sdk.plugin.Plugin;
 
@@ -29,6 +36,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -61,6 +69,23 @@ public class AttachmentDownloadListPlugin extends AbstractListPlugin implements
         }
 
         if (operationResult != null && operationResult.isSuccess() && "downloadfile".equals(operateKey)) {
+
+//            ////测试  操作生成凭证
+//            Long billid1  = 2234376512474203136L;
+//            //获取 付款单号
+//            QFilter qFilter = new QFilter("id", QCP.equals, billid1);
+//            DynamicObject paybillDyn = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{qFilter});
+//            Long billID = paybillDyn.getLong("sourcebillid");
+//            String billtype = paybillDyn.getString("sourcebilltype");
+//            if (billID > 0 && EmptyUtils.isNotEmpty(billtype)){
+//                List<Long> billIds = new ArrayList<>();
+//                billIds.add(billID);
+//                /**
+//                 * 付款单上游单据生成凭证
+//                 */
+//                OperationServiceHelper.executeOperate("nckd_rebackpayinfo", billtype, billIds.toArray(), OperateOption.create());
+//            }
+
             if (StringUtils.isEmpty(attForm) && EmptyUtil.isEmpty(billid)) {
                 this.getView().showErrorNotification("没有附件可下载!");
                 return;

+ 125 - 0
code/base/nckd-jimin-base-helper/src/main/java/nckd/base/helper/ChangeUserLoginPwd.java

@@ -0,0 +1,125 @@
+package nckd.base.helper;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.utils.StringUtils;
+import kd.bos.entity.datamodel.IDataModel;
+import kd.bos.form.ConfirmCallBackListener;
+import kd.bos.form.ConfirmTypes;
+import kd.bos.form.MessageBoxOptions;
+import kd.bos.form.MessageBoxResult;
+import kd.bos.form.control.Button;
+import kd.bos.form.control.Control;
+import kd.bos.form.control.events.BeforeClickEvent;
+import kd.bos.form.events.MessageBoxClosedEvent;
+import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.servicehelper.user.UserServiceHelper;
+import kd.sdk.plugin.Plugin;
+
+import java.util.EventObject;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/**
+ * 基础服务云->基础资料->盐业通用数据
+ * 页面编码: nckd_changeuserpwd , 修改登录pwd
+ * 动态表单
+ * author:chengchaohua
+ * date: 2025-02-07
+ */
+public class ChangeUserLoginPwd extends AbstractFormPlugin implements Plugin {
+
+    private static final Log LOGGER = LogFactory.getLog(ChangeUserLoginPwd.class);
+
+
+    @Override
+    public void registerListener(EventObject e) {
+        // 按钮点击监听
+        Button button = this.getView().getControl("nckd_updatepwd");
+        button.addClickListener(this);
+        super.registerListener(e);
+    }
+
+    @Override
+    public void beforeClick(BeforeClickEvent evt) {
+        super.beforeClick(evt);
+        String key = ((Control) evt.getSource()).getKey();
+        if ("nckd_updatepwd".equals(key)) {
+            DynamicObject userObj = (DynamicObject) this.getModel().getValue("nckd_user");
+            if (userObj == null) {
+                this.getView().showTipNotification("人员必选");
+                evt.setCancel(true);
+                return;
+            }
+
+            String pwd = (String) this.getModel().getValue("nckd_newpwd");
+            if (pwd == null || pwd.length() <= 6) {
+                this.getView().showTipNotification("密码不能少于7位");
+                evt.setCancel(true);
+                return;
+            } else {
+                if (!checkPwd(pwd)){
+                    this.getView().showTipNotification("密码只能包含数字,大小写字母和@,并至少包含一个字母");
+                    evt.setCancel(true);
+                    return;
+                }
+            }
+        }
+    }
+
+    @Override
+    public void click(EventObject evt) {
+        super.click(evt);
+        String key = ((Control) evt.getSource()).getKey();
+        if ("nckd_updatepwd".equals(key)) {
+            ConfirmCallBackListener confirmCallBacks = new ConfirmCallBackListener("updatepwd", this);
+            String confirmTip = "是否确认继续?";
+            this.getView().showConfirm(confirmTip, MessageBoxOptions.YesNo, ConfirmTypes.Default, confirmCallBacks);
+        }
+    }
+
+    /**
+     * 用户确认了交互信息后,触发此事件
+     */
+    @Override
+    public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
+        super.confirmCallBack(messageBoxClosedEvent);
+        IDataModel model = this.getModel();
+        if (StringUtils.equals("updatepwd", messageBoxClosedEvent.getCallBackId())) {
+            // 1.产品交互信息
+            if (messageBoxClosedEvent.getResult() == MessageBoxResult.Yes) {
+                // 确认执行
+                String pwd = (String) model.getValue("nckd_newpwd");
+                DynamicObject userObj = (DynamicObject) model.getValue("nckd_user");
+
+                Map<String, Object> map = UserServiceHelper.changePsw((Long) (userObj.getPkValue()), null, pwd);
+                Boolean result = (Boolean) map.get("success");
+                if (result) {
+                    this.getView().showSuccessNotification(userObj.getString("name") + ":密码更新成功");
+                    LOGGER.info("管理员修改:" + userObj.getString("name") + ",密码成功");
+                } else {
+                    this.getView().showErrorNotification("密码更新失败:" + map.get("msg"));
+                }
+            } else {
+                // 取消或关闭弹框
+                this.getView().showSuccessNotification("已取消更新");
+            }
+        }
+    }
+
+    // 校验密码字符
+    boolean checkPwd(String pwd) {
+        // 正则表达式:[a-zA-Z0-9@]+$
+        //  表示字符串的开始
+        // [a-zA-Z0-9@] 表示允许的字符集,包括小写字母、大写字母、数字和@
+        // + 表示前面的字符集可以出现一次或多次
+        // $ 表示字符串的结束
+        String regex = "(?=.*[a-zA-Z])[a-zA-Z0-9@]+$";
+
+        Pattern pattern = Pattern.compile(regex);
+        // 返回true为校验符合
+        return pattern.matcher(pwd).matches();
+    }
+
+}