固定资产接口0.2

This commit is contained in:
李靖 2024-05-14 16:51:40 +08:00
parent 2da61bee0b
commit 9187c6d535
1 changed files with 83 additions and 2 deletions

View File

@ -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<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
return reqData;
List<Map<String, Object>> reqData2 = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> finentryList = null;
Map<String, Object> finentry = null;
Map<String, Object> tempNumber = null;
for(Map<String, Object> temp1 : reqData) {
// 核算组织.编码 默认值 B-021B-061
if(!temp1.containsKey("org")) {
tempNumber = new HashMap<String, Object>();
tempNumber.put("number", "B-021B-061");
temp1.put("org", tempNumber);
}
// 资产组织.编码 默认值 B-021B-061
if(!temp1.containsKey("assetunit")){
tempNumber = new HashMap<String, Object>();
tempNumber.put("number", "B-021B-061");
temp1.put("assetunit", tempNumber);
}
// 来源方式.编码 默认值 01.01 购入
if(!temp1.containsKey("originmethod")){
tempNumber = new HashMap<String, Object>();
tempNumber.put("number", "01.01");
temp1.put("originmethod", tempNumber);
}
// 存放地点.编码 默认值 021 上海
if(!temp1.containsKey("storeplace")){
tempNumber = new HashMap<String, Object>();
tempNumber.put("number", "021");
temp1.put("storeplace", tempNumber);
}
//使用状态.编码 默认值正常使用
tempNumber = new HashMap<String, Object>();
tempNumber.put("number", "00101");
temp1.put("usestatus", tempNumber);
//使用部门.编码 默认值16005873 晨曦控股目前用不了
tempNumber = new HashMap<String, Object>();
tempNumber.put("number", "16002062");
temp1.put("headusedept", tempNumber);
// 资产数量
Integer assetamount = (Integer)temp1.get("assetamount");
// 财务分录
finentry = ((List<Map<String, Object>>)temp1.get("finentry")).get(0);
finentry.put("seq", 1); // seq
// 财务分录.预计寿命 默认1
finentry.put("fin_preusingamount", BigDecimal.ONE);
// 折旧用途.编码 默认账面折旧
tempNumber = new HashMap<String, Object>();
tempNumber.put("number", "01");
finentry.put("fin_depreuse", tempNumber);
// 折旧方法.编码 默认平均年限法
tempNumber = new HashMap<String, Object>();
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<String, Object>>();
Map<String, Object> temp3 = new HashMap<String, Object>();
finentryList.add(temp3);
temp3.putAll(finentry);
temp3.put("fin_originalval", originalval2);
Map<String, Object> temp2 = new HashMap<String, Object>();
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<Map<String, Object>>)reqData2.get((reqData2.size() - 1)).get("finentry"))
.get(0).put("fin_originalval", originalval4);
}
}
return reqData2;
}
}