科目余额工序取数
This commit is contained in:
parent
a4dc2091a3
commit
5cb700ebfa
|
@ -10,6 +10,7 @@ import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
|||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import zcgj.zcdev.zcdev.fs.utils.AccountRecord;
|
||||
import zcgj.zcdev.zcdev.fs.utils.BalanceQueryParamApi;
|
||||
|
@ -171,6 +172,14 @@ public class AssistbalanceAutoData {
|
|||
|
||||
if (!addEntities.isEmpty()) {
|
||||
try {
|
||||
|
||||
// ✅ 删除旧数据(保证每个组织、每个期间只保留一份最新的)
|
||||
Long orgId = orgObj.getLong("id");
|
||||
Long periodId = curperiod.getLong("id");
|
||||
QFilter orgFilter = new QFilter("zcgj_org", QCP.equals, orgId);
|
||||
QFilter periodFilter = new QFilter("zcgj_period", QCP.equals, periodId);
|
||||
DeleteServiceHelper.delete("zcgj_rpt_assistbalance", new QFilter[]{orgFilter.and(periodFilter)});
|
||||
|
||||
SaveServiceHelper.save(addEntities.toArray(new DynamicObject[0]));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
|
|
@ -11,6 +11,7 @@ import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
|||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.bos.util.StringUtils;
|
||||
import zcgj.zcdev.zcdev.fs.utils.AccountRecord;
|
||||
|
@ -23,27 +24,26 @@ public class SubjectbalanceAutoData {
|
|||
|
||||
private static final String[] asseestypeArrays = new String[]{"0032","0017",""};
|
||||
|
||||
public static void getData(){
|
||||
String[] selectorsArray = new String[]{"beginlocal", "endlocal", "yeardebitfor","yearcreditfor","debitlocal","creditlocal"};
|
||||
public static void getData() {
|
||||
String[] selectorsArray = new String[]{"beginlocal", "endlocal", "yeardebitfor", "yearcreditfor", "debitlocal", "creditlocal"};
|
||||
|
||||
QFilter filteraccountTable = new QFilter("number", QCP.equals, "0003");
|
||||
DynamicObject accountTableLoad = BusinessDataServiceHelper.loadSingle("bd_accounttable", "id", new QFilter[]{filteraccountTable});
|
||||
|
||||
//查询核算组织
|
||||
// 查询核算组织
|
||||
QFilter number = new QFilter("fisaccounting", "=", "1");
|
||||
QFilter structure = new QFilter("structure.longnumber", QCP.like, "10000000!10006431%");
|
||||
QFilter isleaf = new QFilter("structure.isleaf", QCP.equals, true);
|
||||
DynamicObject[] load = BusinessDataServiceHelper.load("bos_org", "id,structure.longnumber,structure.view", new QFilter[]{number, structure,isleaf});
|
||||
DynamicObject[] load = BusinessDataServiceHelper.load("bos_org", "id,structure.longnumber,structure.view", new QFilter[]{number, structure, isleaf});
|
||||
List<Long> orgIds = new ArrayList<>();
|
||||
Map<String,DynamicObject> orgNumberMap = new HashMap<>();
|
||||
for (int i = 0; i < load.length; i++) {
|
||||
DynamicObject dynamicObject = load[i];
|
||||
Map<String, DynamicObject> orgNumberMap = new HashMap<>();
|
||||
for (DynamicObject dynamicObject : load) {
|
||||
orgNumberMap.put(dynamicObject.getString("number"), dynamicObject);
|
||||
orgIds.add(dynamicObject.getLong("id"));
|
||||
}
|
||||
|
||||
DynamicObject[] costcompany = BusinessDataServiceHelper.load("zcgj_minecompany", "zcgj_costcompany", new QFilter[]{});
|
||||
if(costcompany != null){
|
||||
if (costcompany != null) {
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (DynamicObject dynamicObject : costcompany) {
|
||||
DynamicObject minecompany = dynamicObject.getDynamicObject("zcgj_costcompany");
|
||||
|
@ -57,7 +57,8 @@ public class SubjectbalanceAutoData {
|
|||
orgIds.add(dynamicObject.getLong("id"));
|
||||
}
|
||||
}
|
||||
//查询组织下对应的当前期间数据
|
||||
|
||||
// 查询组织下对应的当前期间数据
|
||||
DynamicObject[] orgByCurperiod = BusinessDataServiceHelper.load("gl_accountbook",
|
||||
"org,curperiod",
|
||||
new QFilter[]{new QFilter("enable", QCP.equals, Boolean.TRUE).
|
||||
|
@ -67,23 +68,22 @@ public class SubjectbalanceAutoData {
|
|||
orgByCurperiodMap.put(dynamicObject.getLong("org.id"), dynamicObject);
|
||||
}
|
||||
|
||||
//清除数据
|
||||
//DeleteServiceHelper.delete("zcgj_rpt_assistbalance",new QFilter[]{});
|
||||
// 标记旧数据为非最新
|
||||
List<Object[]> sqlparams = new ArrayList<>();
|
||||
Object[] sqlparam = new Object[] { false };
|
||||
Object[] sqlparam = new Object[]{false};
|
||||
sqlparams.add(sqlparam);
|
||||
DB.executeBatch(DBRoute.of("fi"),
|
||||
"update tk_zcgj_rpt_assistbalangx set fk_zcgj_isnew = ? ", sqlparams);
|
||||
|
||||
for (String asseestype : asseestypeArrays) {
|
||||
//查询科目余额配置表
|
||||
// 查询科目余额配置表
|
||||
DynamicObject[] accountConf = BusinessDataServiceHelper.load("zcgj_conf_balanceaccoungx", "zcgj_entryentity.zcgj_account,zcgj_entryentity.zcgj_asseestype", new QFilter[]{});
|
||||
Set<String> accountNumber = new HashSet<>();
|
||||
for (DynamicObject dynamicObject : accountConf) {
|
||||
DynamicObjectCollection zcgjEntryentity = dynamicObject.getDynamicObjectCollection("zcgj_entryentity");
|
||||
for (DynamicObject object : zcgjEntryentity) {
|
||||
String zcgjAsseestype = object.getString("zcgj_asseestype");
|
||||
if(asseestype.equals(zcgjAsseestype)){
|
||||
if (asseestype.equals(zcgjAsseestype)) {
|
||||
accountNumber.add(object.getDynamicObject("zcgj_account").getString("number"));
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ public class SubjectbalanceAutoData {
|
|||
for (String orgNumber : orgNumberMap.keySet()) {
|
||||
BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
|
||||
balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
|
||||
// balanceQueryParamApi.setOrgNumber("cw000102");
|
||||
balanceQueryParamApi.setOrgNumber(orgNumber);
|
||||
balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
|
||||
balanceQueryParamApi.setAccountTableNumber("0003");//科目表
|
||||
|
@ -100,30 +99,28 @@ public class SubjectbalanceAutoData {
|
|||
DynamicObject orgObj = orgNumberMap.get(orgNumber);
|
||||
DynamicObject periodObj = orgByCurperiodMap.get(orgObj.getLong("id"));
|
||||
DynamicObject curperiod = null;
|
||||
if(periodObj != null) {
|
||||
if (periodObj != null) {
|
||||
curperiod = periodObj.getDynamicObject("curperiod");
|
||||
if( curperiod!= null) {
|
||||
if (curperiod != null) {
|
||||
balanceQueryParamApi.setPeriodNumber(curperiod.getString("number")); //
|
||||
}else{
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
List<String> groupBy = new ArrayList<>();
|
||||
if(!StringUtils.isEmpty(asseestype)){
|
||||
if (!StringUtils.isEmpty(asseestype)) {
|
||||
Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
|
||||
List<Map<String, String>> li = new ArrayList<>();
|
||||
Map<String, String> map1 = new HashMap<>();
|
||||
map1.put(asseestype,"");
|
||||
map1.put(asseestype, "");
|
||||
li.add(map1);
|
||||
for (String accNum : accountNumber) {
|
||||
accountAssgrp.put(accNum,li);
|
||||
accountAssgrp.put(accNum, li);
|
||||
}
|
||||
balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
|
||||
|
||||
groupBy.add(asseestype);
|
||||
}
|
||||
groupBy.add("account");
|
||||
|
@ -131,50 +128,56 @@ public class SubjectbalanceAutoData {
|
|||
Gson gson = new Gson();
|
||||
String json = gson.toJson(balanceQueryParamApi);
|
||||
Map<String, Object> params = gson.fromJson(json,
|
||||
new TypeToken<Map<String, Object>>(){}.getType());
|
||||
new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
|
||||
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
|
||||
|
||||
List<DynamicObject> addEntities = new ArrayList<>();
|
||||
if(balanceData.isStatus()){
|
||||
if (balanceData.isStatus()) {
|
||||
String data = (String) balanceData.getData();
|
||||
Type listType = new TypeToken<List<AccountRecord>>() {}.getType();
|
||||
Type listType = new TypeToken<List<AccountRecord>>() {
|
||||
}.getType();
|
||||
List<AccountRecord> records = gson.fromJson(data, listType);
|
||||
// 示例输出
|
||||
for (AccountRecord record : records) {
|
||||
DynamicObject assistbalance
|
||||
=BusinessDataServiceHelper.newDynamicObject("zcgj_rpt_assistbalancegx");
|
||||
DynamicObject assistbalance = BusinessDataServiceHelper.newDynamicObject("zcgj_rpt_assistbalancegx");
|
||||
assistbalance.set("zcgj_debitlocal", record.getDebitlocal());
|
||||
assistbalance.set("zcgj_beginlocal", record.getBeginlocal());
|
||||
assistbalance.set("zcgj_creditlocal", record.getCreditlocal());
|
||||
assistbalance.set("zcgj_yeardebitfor", record.getYeardebitfor());
|
||||
assistbalance.set("zcgj_yearcreditfor", record.getYearcreditfor());
|
||||
assistbalance.set("zcgj_endlocal", record.getEndlocal());
|
||||
assistbalance.set("zcgj_org",orgNumberMap.get(orgNumber));
|
||||
assistbalance.set("zcgj_accounttable",accountTableLoad);
|
||||
assistbalance.set("zcgj_org", orgNumberMap.get(orgNumber));
|
||||
assistbalance.set("zcgj_accounttable", accountTableLoad);
|
||||
assistbalance.set("zcgj_account", record.getAccount());
|
||||
assistbalance.set("zcgj_period",curperiod);
|
||||
assistbalance.set("zcgj_isnew",true);
|
||||
//assistbalance.set("zcgj_pm",projectMap.get(orgNumber));
|
||||
assistbalance.set("zcgj_period", curperiod);
|
||||
assistbalance.set("zcgj_isnew", true);
|
||||
|
||||
Map<String, AccountRecord.AssGrpItem> assgrp = record.getAssgrp();
|
||||
if (assgrp.containsKey("0032")) {
|
||||
if(assgrp.get("0032")!=null){
|
||||
assistbalance.set("zcgj_processnumber",assgrp.get("0032").getNumber());
|
||||
assistbalance.set("zcgj_processname",assgrp.get("0032").getName());
|
||||
if (assgrp.get("0032") != null) {
|
||||
assistbalance.set("zcgj_processnumber", assgrp.get("0032").getNumber());
|
||||
assistbalance.set("zcgj_processname", assgrp.get("0032").getName());
|
||||
}
|
||||
}else if(assgrp.containsKey("0017")){
|
||||
if(assgrp.get("0017")!=null){
|
||||
assistbalance.set("zcgj_costcompanynumber",assgrp.get("0017").getNumber());
|
||||
assistbalance.set("zcgj_costcompanyname",assgrp.get("0017").getName());
|
||||
} else if (assgrp.containsKey("0017")) {
|
||||
if (assgrp.get("0017") != null) {
|
||||
assistbalance.set("zcgj_costcompanynumber", assgrp.get("0017").getNumber());
|
||||
assistbalance.set("zcgj_costcompanyname", assgrp.get("0017").getName());
|
||||
}
|
||||
}
|
||||
addEntities.add(assistbalance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!addEntities.isEmpty()) {
|
||||
try {
|
||||
// ✅ 删除旧数据(保证每个组织、每个期间只保留一份最新的)
|
||||
Long orgId = orgObj.getLong("id");
|
||||
Long periodId = curperiod.getLong("id");
|
||||
QFilter orgFilter = new QFilter("zcgj_org", QCP.equals, orgId);
|
||||
QFilter periodFilter = new QFilter("zcgj_period", QCP.equals, periodId);
|
||||
DeleteServiceHelper.delete("zcgj_rpt_assistbalancegx", new QFilter[]{orgFilter.and(periodFilter)});
|
||||
// 保存新数据
|
||||
SaveServiceHelper.save(addEntities.toArray(new DynamicObject[0]));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
@ -183,4 +186,5 @@ public class SubjectbalanceAutoData {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
|||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import zcgj.zcdev.zcdev.fs.utils.AccountRecord;
|
||||
import zcgj.zcdev.zcdev.fs.utils.BalanceQueryParamApi;
|
||||
|
@ -189,6 +190,18 @@ public class SuppliertbalanceAutoData {
|
|||
|
||||
if (!addEntities.isEmpty()) {
|
||||
try {
|
||||
|
||||
// ✅ 删除旧数据(保证每个组织、每个期间只保留一份最新的)
|
||||
Long orgId = orgObj.getLong("id");
|
||||
Long periodId = curperiod.getLong("id");
|
||||
QFilter orgFilter = new QFilter("zcgj_org", QCP.equals, orgId);
|
||||
QFilter periodFilter = new QFilter("zcgj_period", QCP.equals, periodId);
|
||||
if("YUFZK".equals(type)){//预付账款
|
||||
DeleteServiceHelper.delete("zcgj_rpt_assibalancegysyu", new QFilter[]{orgFilter.and(periodFilter)});
|
||||
}else if("YIFZK".equals(type)){//应付账款
|
||||
DeleteServiceHelper.delete("zcgj_rpt_assibalancegysyi", new QFilter[]{orgFilter.and(periodFilter)});
|
||||
}
|
||||
|
||||
SaveServiceHelper.save(addEntities.toArray(new DynamicObject[0]));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
|
Loading…
Reference in New Issue