Compare commits
3 Commits
fd69e727ec
...
d2574fda05
Author | SHA1 | Date |
---|---|---|
|
d2574fda05 | |
|
e645995b8d | |
|
eced8b9638 |
|
@ -0,0 +1,185 @@
|
|||
package zcgj.zcdev.zcdev.fs.plugin.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.openapi.common.result.OpenApiResult;
|
||||
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.SaveServiceHelper;
|
||||
import zcgj.zcdev.zcdev.fs.utils.AccountRecord;
|
||||
import zcgj.zcdev.zcdev.fs.utils.BalanceQueryParamApi;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public class SubjectbalanceAutoData {
|
||||
|
||||
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});
|
||||
List<Long> orgIds = new ArrayList<>();
|
||||
Map<String,DynamicObject> orgNumberMap = new HashMap<>();
|
||||
for (int i = 0; i < load.length; i++) {
|
||||
DynamicObject dynamicObject = load[i];
|
||||
orgNumberMap.put(dynamicObject.getString("number"), dynamicObject);
|
||||
orgIds.add(dynamicObject.getLong("id"));
|
||||
}
|
||||
|
||||
DynamicObject[] costcompany = BusinessDataServiceHelper.load("zcgj_minecompany", "zcgj_costcompany", new QFilter[]{});
|
||||
if(costcompany != null){
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (DynamicObject dynamicObject : costcompany) {
|
||||
DynamicObject minecompany = dynamicObject.getDynamicObject("zcgj_costcompany");
|
||||
long id = minecompany.getLong("id");
|
||||
ids.add(id);
|
||||
}
|
||||
QFilter idFilter = new QFilter("id", QCP.in, ids);
|
||||
DynamicObject[] org = BusinessDataServiceHelper.load("bos_org", "id,structure.longnumber,structure.view", new QFilter[]{idFilter});
|
||||
for (DynamicObject dynamicObject : org) {
|
||||
orgNumberMap.put(dynamicObject.getString("number"), dynamicObject);
|
||||
orgIds.add(dynamicObject.getLong("id"));
|
||||
}
|
||||
}
|
||||
|
||||
//查询科目余额配置表
|
||||
DynamicObject[] accountConf = BusinessDataServiceHelper.load("zcgj_conf_balanceaccoungx", "zcgj_entryentity.zcgj_account", new QFilter[]{});
|
||||
Set<String> accountNumber = new HashSet<>();
|
||||
for (DynamicObject dynamicObject : accountConf) {
|
||||
DynamicObjectCollection zcgjEntryentity = dynamicObject.getDynamicObjectCollection("zcgj_entryentity");
|
||||
for (DynamicObject object : zcgjEntryentity) {
|
||||
accountNumber.add(object.getDynamicObject("zcgj_account").getString("number"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//查询组织下对应的当前期间数据
|
||||
DynamicObject[] orgByCurperiod = BusinessDataServiceHelper.load("gl_accountbook",
|
||||
"org,curperiod",
|
||||
new QFilter[]{new QFilter("enable", QCP.equals, Boolean.TRUE).
|
||||
and("status", QCP.equals, "C").and("org.id", QCP.in, orgIds)});
|
||||
Map<Long, DynamicObject> orgByCurperiodMap = new HashMap<>();
|
||||
for (DynamicObject dynamicObject : orgByCurperiod) {
|
||||
orgByCurperiodMap.put(dynamicObject.getLong("org.id"), dynamicObject);
|
||||
}
|
||||
|
||||
//获取核算组织的项目
|
||||
/*Map<String,DynamicObject> projectMap = new HashMap<>();
|
||||
//ec_project
|
||||
DynamicObject[] projects = BusinessDataServiceHelper.load("ec_project",
|
||||
"fiaccountorg,zcgj_pm",
|
||||
new QFilter[]{new QFilter("billstatus", QCP.equals, "C").
|
||||
and("fiaccountorg", QCP.in, orgIds)});
|
||||
for (DynamicObject project : projects) {
|
||||
DynamicObject fiaccountorg = project.getDynamicObject("fiaccountorg");
|
||||
DynamicObject pm = project.getDynamicObject("zcgj_pm");
|
||||
if(fiaccountorg!=null){
|
||||
projectMap.put(fiaccountorg.getString("number"), pm);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//清除数据
|
||||
//DeleteServiceHelper.delete("zcgj_rpt_assistbalance",new QFilter[]{});
|
||||
List<Object[]> sqlparams = new ArrayList<>();
|
||||
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 orgNumber : orgNumberMap.keySet()) {
|
||||
BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
|
||||
balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
|
||||
// balanceQueryParamApi.setOrgNumber("cw000102");
|
||||
balanceQueryParamApi.setOrgNumber(orgNumber);
|
||||
balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
|
||||
balanceQueryParamApi.setAccountTableNumber("0003");//科目表
|
||||
|
||||
DynamicObject orgObj = orgNumberMap.get(orgNumber);
|
||||
DynamicObject periodObj = orgByCurperiodMap.get(orgObj.getLong("id"));
|
||||
DynamicObject curperiod = null;
|
||||
if(periodObj != null) {
|
||||
curperiod = periodObj.getDynamicObject("curperiod");
|
||||
if( curperiod!= null) {
|
||||
balanceQueryParamApi.setPeriodNumber(curperiod.getString("number")); //
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
|
||||
List<Map<String, String>> li = new ArrayList<>();
|
||||
Map<String, String> map1 = new HashMap<>();
|
||||
map1.put("0032","");
|
||||
li.add(map1);
|
||||
for (String accNum : accountNumber) {
|
||||
accountAssgrp.put(accNum,li);
|
||||
}
|
||||
balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
|
||||
List<String> groupBy = new ArrayList<>();
|
||||
groupBy.add("0032");
|
||||
groupBy.add("account");
|
||||
balanceQueryParamApi.setGroupBys(groupBy);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(balanceQueryParamApi);
|
||||
Map<String, Object> params = gson.fromJson(json,
|
||||
new TypeToken<Map<String, Object>>(){}.getType());
|
||||
|
||||
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
|
||||
|
||||
List<DynamicObject> addEntities = new ArrayList<>();
|
||||
if(balanceData.isStatus()){
|
||||
String data = (String) balanceData.getData();
|
||||
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");
|
||||
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_account", record.getAccount());
|
||||
assistbalance.set("zcgj_period",curperiod);
|
||||
assistbalance.set("zcgj_isnew",true);
|
||||
//assistbalance.set("zcgj_pm",projectMap.get(orgNumber));
|
||||
Map<String, AccountRecord.AssGrpItem> assgrp = record.getAssgrp();
|
||||
if (assgrp.containsKey("0032")) {
|
||||
assistbalance.set("zcgj_processnumber",assgrp.get("0032").getNumber());
|
||||
assistbalance.set("zcgj_processname",assgrp.get("0032").getName());
|
||||
}
|
||||
addEntities.add(assistbalance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!addEntities.isEmpty()) {
|
||||
try {
|
||||
SaveServiceHelper.save(addEntities.toArray(new DynamicObject[0]));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package zcgj.zcdev.zcdev.fs.plugin.form;
|
||||
|
||||
import kd.bos.form.control.events.ItemClickEvent;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import zcgj.zcdev.zcdev.fs.plugin.common.SubjectbalanceAutoData;
|
||||
|
||||
/**
|
||||
* 核算维度余额取数表(矿山二开)
|
||||
*/
|
||||
public class SubjectbalancePlugin extends AbstractListPlugin implements Plugin {
|
||||
private static final Log log = LogFactory.getLog(SubjectbalancePlugin.class);
|
||||
|
||||
public static String ksNumberTop = "10006431"; //矿山总部组织编码
|
||||
@Override
|
||||
public void itemClick(ItemClickEvent evt) {
|
||||
super.itemClick(evt);
|
||||
String itemKey = evt.getItemKey();
|
||||
if("zcgj_gatdata".equals(itemKey)) {
|
||||
//科目余额表自动取数
|
||||
SubjectbalanceAutoData.getData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -43,16 +43,22 @@ public class InvoiceDeductionCheckOp extends AbstractOperationServicePlugIn {
|
|||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||
DynamicObject costCompany = dataEntity.getDynamicObject("costcompany");//费用承担公司
|
||||
String formid = dataEntity.getDynamicObjectType().getName();
|
||||
if (costCompany != null) {
|
||||
Long companyId = costCompany.getLong("id");
|
||||
if (OrgCheckUtils.isKS(companyId)) {
|
||||
DynamicObjectCollection expenseentryentity = dataEntity.getDynamicObjectCollection("expenseentryentity");//费用明细
|
||||
boolean isCkInvoice= false;
|
||||
boolean isCkInvoicezp= false;
|
||||
DynamicObjectCollection expenseentryentity = dataEntity.getDynamicObjectCollection("expenseentryentity");//费用明细
|
||||
for (DynamicObject dynamicObject : expenseentryentity) {
|
||||
boolean offset = dynamicObject.getBoolean("offset");
|
||||
boolean offset = dynamicObject.getBoolean("offset");//可抵扣
|
||||
if(offset){
|
||||
isCkInvoice = offset;
|
||||
}
|
||||
boolean specialInvoice = dynamicObject.getBoolean("is_special_invoice");//专票
|
||||
if(specialInvoice){
|
||||
isCkInvoicezp = specialInvoice;
|
||||
}
|
||||
}
|
||||
if(isCkInvoice){
|
||||
String zcgjInvoiceremark = dataEntity.getString("zcgj_invoiceremark");
|
||||
|
@ -61,6 +67,13 @@ public class InvoiceDeductionCheckOp extends AbstractOperationServicePlugIn {
|
|||
String message = String.format("费用可抵扣,必须上传发票 或 填写特殊说明 才能提交");
|
||||
this.addFatalErrorMessage(extendedDataEntity, message);
|
||||
}
|
||||
}else if(isCkInvoicezp){
|
||||
String zcgjInvoiceremark = dataEntity.getString("zcgj_invoiceremark");
|
||||
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
||||
if( (invoiceentry == null || invoiceentry.isEmpty()) && StringUtils.isEmpty(zcgjInvoiceremark) ){
|
||||
String message = String.format("费用包含专票,必须上传发票 或 填写特殊说明 才能提交");
|
||||
this.addFatalErrorMessage(extendedDataEntity, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import kd.bos.logging.LogFactory;
|
|||
import kd.bos.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import zcgj.zcdev.zcdev.fs.plugin.common.AssistbalanceAutoData;
|
||||
import zcgj.zcdev.zcdev.fs.plugin.common.SubjectbalanceAutoData;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -23,5 +24,9 @@ public class AssistbalanceTask extends AbstractTask {
|
|||
log.info("AssistbalanceTask,进入到后台任务中-开始");
|
||||
AssistbalanceAutoData.getData();
|
||||
log.info("AssistbalanceTask,进入到后台任务中-结束");
|
||||
|
||||
log.info("SubjectbalanceTask,进入到后台任务中-开始");
|
||||
// SubjectbalanceAutoData.getData();
|
||||
log.info("SubjectbalanceTask,进入到后台任务中-结束");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ public class MaterialInAmountToItemEntryWorkFlowPlugin implements IWorkflowPlugi
|
|||
calAllTypeAmount(outContractSettle);
|
||||
SaveServiceHelper.save(new DynamicObject[]{outContractSettle});
|
||||
OperateOption option= OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.STRICTVALIDATION, String.valueOf(false));
|
||||
option.setVariableValue(OperateOptionConst.IGNOREINTERACTION, String.valueOf(true));
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(true));
|
||||
//option.add(OperateOptionConst.SKIP_PERMISSION_CHECK);
|
||||
OperationResult result = OperationServiceHelper.executeOperate("submit", "ec_out_contract_settle", new DynamicObject[]{outContractSettle}, option);
|
||||
log.info("MaterialInAmountToItemEntryWorkFlowPlugin-result:"+result.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue