Forráskód Böngészése

1.新增报销工作台下推设置基础资料

lisheng 1 hete
szülő
commit
15f77bc263

+ 57 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/ReimPushSettingEdit.java

@@ -0,0 +1,57 @@
+package nckd.jimin.jyyy.fi.plugin.form;
+
+import kd.bos.dataentity.entity.LocaleString;
+import kd.bos.dataentity.metadata.IDataEntityProperty;
+import kd.bos.entity.botp.ConvertRuleCache;
+import kd.bos.entity.botp.ConvertRuleElement;
+import kd.bos.entity.datamodel.events.PropertyChangedArgs;
+import kd.bos.form.field.ComboEdit;
+import kd.bos.form.field.ComboItem;
+import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.List;
+
+public class ReimPushSettingEdit extends AbstractFormPlugin {
+
+
+    @Override
+    public void propertyChanged(PropertyChangedArgs e) {
+        super.propertyChanged(e);
+        IDataEntityProperty property = e.getProperty();
+        String name = property.getName();
+        if("nckd_sourcebilltype".equals(name) || "nckd_targetbilltype".equals(name)){
+            fillRuleCombo();
+            getModel().setValue("nckd_ruleid",null);
+        }
+    }
+
+    @Override
+    public void afterBindData(EventObject e) {
+        super.afterBindData(e);
+        fillRuleCombo();
+    }
+
+    protected void fillRuleCombo(){
+        String sourceBillType = (String)getModel().getValue("nckd_sourcebilltype");
+        String targetBillType = (String)getModel().getValue("nckd_targetbilltype");
+
+        if(StringUtils.isNotEmpty(sourceBillType) && StringUtils.isNotEmpty(targetBillType)){
+            List<ComboItem> ruleItems = new ArrayList();
+            List<ConvertRuleElement> convertRuleElements = ConvertRuleCache.loadRules(sourceBillType, targetBillType);
+            for(ConvertRuleElement ruleElement : convertRuleElements ){
+                boolean enabled = ruleElement.isEnabled();
+                if(enabled){
+                    ComboItem ruleItem = new ComboItem();
+                    ruleItem.setValue(ruleElement.getId());
+                    ruleItem.setCaption(ruleElement.getName());
+                    ruleItems.add(ruleItem);
+                }
+            }
+            ComboEdit ruleEditor = (ComboEdit)this.getView().getControl("nckd_ruleid");
+            ruleEditor.setComboItems(ruleItems);
+        }
+    }
+}

+ 35 - 13
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/ReimWorkBenchesDetailFormPlugin.java

@@ -24,7 +24,6 @@ import kd.bos.exception.KDBizException;
 import kd.bos.form.ClientProperties;
 import kd.bos.form.ShowType;
 import kd.bos.form.control.EntryGrid;
-import kd.bos.form.control.Search;
 import kd.bos.form.control.events.BeforeClickEvent;
 import kd.bos.form.control.events.BeforeItemClickEvent;
 import kd.bos.form.control.events.ItemClickEvent;
@@ -37,7 +36,6 @@ import kd.bos.image.pojo.ViewImageVo;
 import kd.bos.imageplatform.util.SSCImageUtils;
 import kd.bos.logging.Log;
 import kd.bos.logging.LogFactory;
-import kd.bos.metadata.botp.ConvertRuleReader;
 import kd.bos.orm.ORM;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
@@ -163,13 +161,13 @@ public class ReimWorkBenchesDetailFormPlugin extends AbstractFormPlugin implemen
         switch (itemKey){
 
             case BTN_REIM:
-                doReim(evt);
+                doPushNew(evt,"reim");
                 break;
             case BTN_LOAN:
-                doLoan(evt);
+                doPushNew(evt,"loan");
                 break;
             case BTN_REPAY:
-                doRepay(evt);
+                doPushNew(evt,"repay");
                 break;
 
             case BTN_PRINT:
@@ -199,6 +197,31 @@ public class ReimWorkBenchesDetailFormPlugin extends AbstractFormPlugin implemen
         }
     }
 
+    protected void doPushNew(ItemClickEvent evt , String type){
+        DynamicObject selectRow = getSelectRows().get(0);
+        String sourceBillType = selectRow.getString("billtype");
+        String billid = selectRow.getString("billid");
+        // 查询配置表
+
+        DynamicObjectCollection pushSettingCol = QueryServiceHelper.query("nckd_reimpushsetting", "nckd_type,nckd_sourcebilltype,nckd_targetbilltype,nckd_ruleid", new QFilter[]{
+                new QFilter("nckd_sourcebilltype", QCP.equals, sourceBillType),
+                new QFilter("nckd_type", QCP.equals, type)
+        });
+
+        if(CollectionUtils.isEmpty(pushSettingCol)){
+            getView().showTipNotification("单据未配置报销工作台下推设置。");
+            return;
+        }
+        if(pushSettingCol.size() > 1){
+            getView().showTipNotification("单据存在多条报销工作台下推设置。");
+            return;
+        }
+        DynamicObject pushSettingInfo = pushSettingCol.get(0);
+        botpCreateBillOpen(billid,pushSettingInfo.getString("nckd_sourcebilltype"),
+                pushSettingInfo.getString("nckd_targetbilltype"),pushSettingInfo.getString("nckd_ruleid"));
+
+    }
+
     protected void doReim(ItemClickEvent evt){
         DynamicObject selectRow = getSelectRows().get(0);
         String billtype = selectRow.getString("billtype");
@@ -573,9 +596,11 @@ public class ReimWorkBenchesDetailFormPlugin extends AbstractFormPlugin implemen
             WorkflowServiceHelper.viewFlowchart(getView().getPageId(), entryRow.getString("billid"));
         }
     }
+    public void botpCreateBillOpen(String sourceBillId,String sourceBillType,String targetBillType) {
+        botpCreateBillOpen(sourceBillId,sourceBillType,targetBillType,"");
+    }
 
-
-    public void botpCreateBillOpen(String sourceBillId,String sourceBillType,String targetBillType){
+    public void botpCreateBillOpen(String sourceBillId,String sourceBillType,String targetBillType,String ruleId){
         // 校验单据权限
 
         //构建选中行数据包
@@ -583,12 +608,9 @@ public class ReimWorkBenchesDetailFormPlugin extends AbstractFormPlugin implemen
         ListSelectedRow selectedRow = new ListSelectedRow(Long.valueOf(sourceBillId));
         selectedRows.add(selectedRow);
         //获取转换规则id
-        ConvertRuleReader read=new ConvertRuleReader();
-        List<String> loadRuleIds = read.loadRuleIds(sourceBillType, targetBillType, false);
+        //ConvertRuleCache.loadRules()
+
 
-        if(CollectionUtils.isNotEmpty(loadRuleIds) && loadRuleIds.size() > 1){
-            throw new KDBizException("匹配到多条转换规则,请调整转换规则后再试。");
-        }
         // 创建下推参数
         PushArgs pushArgs = new PushArgs();
         // 源单标识,必填
@@ -600,7 +622,7 @@ public class ReimWorkBenchesDetailFormPlugin extends AbstractFormPlugin implemen
         //不检查目标单新增权限,非必填
         pushArgs.setHasRight(true);
         //传入下推使用的转换规则id,不填则使用默认规则
-        pushArgs.setRuleId(loadRuleIds.get(0));
+        pushArgs.setRuleId(ruleId);
         //下推默认保存,必填
         pushArgs.setAutoSave(true);
         // 设置源单选中的数据包,必填