diff --git a/shkd-cosmic-debug/src/main/java/shkd/fi/fa/plugin/SaveFaAssetCardApiSavePlugin.java b/shkd-cosmic-debug/src/main/java/shkd/fi/fa/plugin/SaveFaAssetCardApiSavePlugin.java index a7fe1de..b3e3a7b 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/fi/fa/plugin/SaveFaAssetCardApiSavePlugin.java +++ b/shkd-cosmic-debug/src/main/java/shkd/fi/fa/plugin/SaveFaAssetCardApiSavePlugin.java @@ -3,6 +3,7 @@ package shkd.fi.fa.plugin; import kd.bos.openapi.api.plugin.ApiSavePlugin; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -10,7 +11,87 @@ import java.util.Map; public class SaveFaAssetCardApiSavePlugin implements ApiSavePlugin { @Override public List> preHandleRequestData(List> reqData) { - - return reqData; + List> reqData2 = new ArrayList>(); + List> finentryList = null; + Map finentry = null; + Map tempNumber = null; + for(Map temp1 : reqData) { + // 核算组织.编码 默认值 B-021B-061 + if(!temp1.containsKey("org")) { + tempNumber = new HashMap(); + tempNumber.put("number", "B-021B-061"); + temp1.put("org", tempNumber); + } + // 资产组织.编码 默认值 B-021B-061 + if(!temp1.containsKey("assetunit")){ + tempNumber = new HashMap(); + tempNumber.put("number", "B-021B-061"); + temp1.put("assetunit", tempNumber); + } + // 来源方式.编码 默认值 01.01 购入 + if(!temp1.containsKey("originmethod")){ + tempNumber = new HashMap(); + tempNumber.put("number", "01.01"); + temp1.put("originmethod", tempNumber); + } + // 存放地点.编码 默认值 021 上海 + if(!temp1.containsKey("storeplace")){ + tempNumber = new HashMap(); + tempNumber.put("number", "021"); + temp1.put("storeplace", tempNumber); + } + //使用状态.编码 默认值:正常使用 + tempNumber = new HashMap(); + tempNumber.put("number", "00101"); + temp1.put("usestatus", tempNumber); + //使用部门.编码 默认值:16005873 晨曦控股目前用不了 + tempNumber = new HashMap(); + tempNumber.put("number", "16002062"); + temp1.put("headusedept", tempNumber); + // 资产数量 + Integer assetamount = (Integer)temp1.get("assetamount"); + // 财务分录 + finentry = ((List>)temp1.get("finentry")).get(0); + finentry.put("seq", 1); // seq + // 财务分录.预计寿命 默认1 + finentry.put("fin_preusingamount", BigDecimal.ONE); + // 折旧用途.编码 默认:账面折旧 + tempNumber = new HashMap(); + tempNumber.put("number", "01"); + finentry.put("fin_depreuse", tempNumber); + // 折旧方法.编码 默认:平均年限法 + tempNumber = new HashMap(); + tempNumber.put("number", "100"); + finentry.put("fin_depremethod", tempNumber); + // 财务分录.财务入账日期 默认:启用日期 + finentry.put("fin_finaccountdate", temp1.get("realaccountdate")); + //资产原值 + BigDecimal originalval = (BigDecimal)finentry.get("fin_originalval"); + BigDecimal originalval3 = BigDecimal.ZERO; + // 资产原值 除 资产数量 = 资产原值单价 + BigDecimal originalval2 = originalval.divide(BigDecimal.valueOf(assetamount), 2, BigDecimal.ROUND_DOWN); + for (int i = 0; i < assetamount; i++) { + finentryList = new ArrayList>(); + Map temp3 = new HashMap(); + finentryList.add(temp3); + temp3.putAll(finentry); + temp3.put("fin_originalval", originalval2); + Map temp2 = new HashMap(); + temp2.putAll(temp1); + // 财务分录. + temp2.put("finentry", finentryList); + // 资产数量. 默认1(接口因为需求定义为int,系统默认BigDecimal类型,否则按String类型处理) + temp2.put("assetamount", 1); + reqData2.add(temp2); + originalval3 = originalval3.add(originalval2); + } + // 分割前后的资产原值不一致的情况,差额添加到最后一件上 + if(!originalval.equals(originalval3)) { + BigDecimal originalval4 = originalval2.add((originalval.subtract(originalval3))); + ((List>)reqData2.get((reqData2.size() - 1)).get("finentry")) + .get(0).put("fin_originalval", originalval4); + } + } + return reqData2; } }