13246659623 3 dias atrás
pai
commit
caccede5f8

+ 51 - 5
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/fi/cas/opplugin/PayBillToolUtil.java

@@ -1,6 +1,7 @@
 package fi.cas.opplugin;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.encrypt.Encrypters;
 import kd.bos.entity.EntityMetadataCache;
 import kd.bos.logging.Log;
 import kd.bos.logging.LogFactory;
@@ -8,12 +9,10 @@ import kd.bos.orm.query.QFilter;
 import kd.bos.servicehelper.BusinessDataServiceHelper;
 
 import java.io.*;
+import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 import kd.bos.servicehelper.operation.OperationServiceHelper;
 import kd.bos.servicehelper.operation.SaveServiceHelper;
@@ -124,6 +123,25 @@ public class PayBillToolUtil {
 
             // 获取分录数据
             DynamicObjectCollection entryList = info.getDynamicObjectCollection("entry");
+            Map<String, BigDecimal> decodeAmount = new HashMap(entryList.size());
+
+            for(int i = 0; i < entryList.size(); ++i) {
+                DynamicObject entry = (DynamicObject)entryList.get(i);
+                String encryptLocalAmtStr;
+                if (entry.getDataEntityType().getProperties().get("e_encryptamount") != null) {
+                    encryptLocalAmtStr = entry.getString("e_encryptamount");
+                    if (encryptLocalAmtStr != null && !encryptLocalAmtStr.trim().isEmpty()) {
+                        entry.set("e_amount", getDecodeAmount(encryptLocalAmtStr, decodeAmount));
+                    }
+                }
+
+                if (entry.getDataEntityType().getProperties().get("e_encryptlocalamt") != null) {
+                    encryptLocalAmtStr = entry.getString("e_encryptlocalamt");
+                    if (encryptLocalAmtStr != null && !encryptLocalAmtStr.trim().isEmpty()) {
+                        entry.set("e_localamt", getDecodeAmount(encryptLocalAmtStr, decodeAmount));
+                    }
+                }
+            }
 
             for (int i = 0; i < entryList.size(); i++) {
                 DynamicObject entry = entryList.get(i);
@@ -137,6 +155,7 @@ public class PayBillToolUtil {
                 //收款行行号
                 entrydata.put("RECE_CNAPS", entry.get("payeebanknumber") + "");
                 //付款金额,待补充
+
                 entrydata.put("AMOUNT", entry.getBigDecimal("e_amount").setScale(2, RoundingMode.DOWN).toString());
                 //明细用途
                 entrydata.put("PURPOSE", "用途:" + info.get("nckd_usage"));
@@ -180,8 +199,35 @@ public class PayBillToolUtil {
 
 
 
+    private static BigDecimal getDecodeAmount(String encryptLocalAmtStr, Map<String, BigDecimal> decodeAmount) {
+        BigDecimal amount = (BigDecimal)decodeAmount.get(encryptLocalAmtStr);
+        if (amount == null) {
+            decodeAmount.put(encryptLocalAmtStr, decodeAmount(encryptLocalAmtStr));
+        }
 
-
+        return (BigDecimal)decodeAmount.get(encryptLocalAmtStr);
+    }
+    public static BigDecimal decodeAmount(String encryptAmount) {
+        if (encryptAmount != null && !encryptAmount.trim().isEmpty()) {
+            String decode = "";
+            if (Encrypters.isEncrypted(encryptAmount)) {
+                decode = Encrypters.decode(encryptAmount);
+                return new BigDecimal(decode);
+            } else {
+                return decodeAmountOld(encryptAmount);
+            }
+        } else {
+            return BigDecimal.ZERO;
+        }
+    }
+    public static BigDecimal decodeAmountOld(String encryptAmount) {
+        if (encryptAmount != null && !encryptAmount.trim().isEmpty()) {
+            byte[] decode = Base64.getDecoder().decode(encryptAmount);
+            return new BigDecimal(new String(decode));
+        } else {
+            return BigDecimal.ZERO;
+        }
+    }
     /***
      * 拼接json对象
      */