合同支付分录过滤
This commit is contained in:
parent
30715b4dc3
commit
a2782869eb
|
@ -0,0 +1,922 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.dataentity.entity.DataEntityBase;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.serialization.SerializationUtils;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.IDataModel;
|
||||
import kd.bos.form.*;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
import kd.bos.form.control.Search;
|
||||
import kd.bos.form.control.events.SearchEnterEvent;
|
||||
import kd.bos.form.control.events.SearchEnterListener;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.events.MessageBoxClosedEvent;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.ec.basedata.business.model.BaseConstant;
|
||||
import kd.ec.basedata.common.enums.BillStatusEnum;
|
||||
import kd.ec.basedata.common.enums.ReferBillTypeEnum;
|
||||
import kd.ec.contract.common.enums.PayDirectionEnum;
|
||||
import kd.ec.contract.formplugin.ItemDetailF7EditPlugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemDetailF7EditExtPlugin extends AbstractFormPlugin implements SearchEnterListener {
|
||||
private static final String BILLNO_BILLNAME_CONTRACT_PERIOD = "billno,billname,contract,period,";
|
||||
private static final String MEASUREITEM_ID = "506427748873442304";
|
||||
private static final long SUPPLIER_ITEM_ID = 1204312316120741888L;
|
||||
|
||||
public ItemDetailF7EditExtPlugin() {
|
||||
}
|
||||
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
Search searchAp = (Search)this.getView().getControl("searchap");
|
||||
searchAp.addEnterListener(this);
|
||||
}
|
||||
|
||||
public void search(SearchEnterEvent paramSearchEnterEvent) {
|
||||
Search search = (Search)paramSearchEnterEvent.getSource();
|
||||
if (StringUtils.equals("searchap", search.getKey())) {
|
||||
this.updateEntryBySerachText(paramSearchEnterEvent.getText());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void beforeBindData(EventObject e) {
|
||||
super.beforeBindData(e);
|
||||
this.updateEntry();
|
||||
}
|
||||
|
||||
private DynamicObjectCollection setClaimArrDataToEntry(DynamicObjectCollection entryCollection, DynamicObject[] claimArr) {
|
||||
if (claimArr != null && claimArr.length != 0) {
|
||||
DynamicObjectType entryType = entryCollection.getDynamicObjectType();
|
||||
|
||||
for(int i = 0; i < claimArr.length; ++i) {
|
||||
DynamicObject claim = claimArr[i];
|
||||
DynamicObject entryObj = new DynamicObject(entryType);
|
||||
entryObj.set("detailitem", claim.getString("billname"));
|
||||
entryObj.set("detailpayitem", claim.getDynamicObject("contpayitem"));
|
||||
entryObj.set("detailoftaxamt", claim.getBigDecimal("claimoftaxamount"));
|
||||
entryObj.set("detailtaxamt", claim.getBigDecimal("taxamount"));
|
||||
entryObj.set("detailamt", claim.getBigDecimal("claimamount"));
|
||||
entryObj.set("billnumber", claim.getString("billno"));
|
||||
entryObj.set("billname", claim.getString("billname"));
|
||||
entryObj.set("detailcreator", claim.getDynamicObject("creator"));
|
||||
entryObj.set("detailcreatetime", claim.getDate("createtime"));
|
||||
entryObj.set("detailauditor", claim.getDynamicObject("auditor"));
|
||||
entryObj.set("detailauditdate", claim.getDate("auditdate"));
|
||||
entryObj.set("referbilltype", "claim");
|
||||
entryObj.set("referbillid", claim.getPkValue());
|
||||
if (this.getPayDirection(this.getParentModel()).equals(PayDirectionEnum.IN.getValue())) {
|
||||
entryObj.set("unitproject", claim.get("unitproject"));
|
||||
}
|
||||
|
||||
entryCollection.add(entryObj);
|
||||
}
|
||||
|
||||
return entryCollection;
|
||||
} else {
|
||||
return entryCollection;
|
||||
}
|
||||
}
|
||||
private DynamicObjectCollection setVisaBillArrDataToEntry(DynamicObjectCollection entryCollection, DynamicObject[] visaBillArr) {
|
||||
if (visaBillArr !=
|
||||
null && visaBillArr.length != 0) {
|
||||
DynamicObjectType entryType = entryCollection.getDynamicObjectType();
|
||||
|
||||
for(int i = 0; i < visaBillArr.length; ++i) {
|
||||
DynamicObject visaBill = visaBillArr[i];
|
||||
DynamicObject entryObj = new DynamicObject(entryType);
|
||||
entryObj.set("detailitem", visaBill.getString("billname"));
|
||||
entryObj.set("detailpayitem", visaBill.getDynamicObject("contpayitem"));
|
||||
entryObj.set("detailoftaxamt", visaBill.getBigDecimal("visaoftaxamount"));
|
||||
entryObj.set("detailtaxamt", visaBill.getBigDecimal("taxamount"));
|
||||
entryObj.set("detailamt", visaBill.getBigDecimal("visaamount"));
|
||||
entryObj.set("billnumber", visaBill.getString("billno"));
|
||||
entryObj.set("billname", visaBill.getString("billname"));
|
||||
entryObj.set("detailcreator", visaBill.getDynamicObject("creator"));
|
||||
entryObj.set("detailcreatetime", visaBill.getDate("createtime"));
|
||||
entryObj.set("detailauditor", visaBill.getDynamicObject("auditor"));
|
||||
entryObj.set("detailauditdate", visaBill.getDate("auditdate"));
|
||||
entryObj.set("referbilltype", ReferBillTypeEnum.VISA.getValue());
|
||||
entryObj.set("referbillid", visaBill.getPkValue());
|
||||
if (this.getPayDirection(this.getParentModel()).equals(PayDirectionEnum.IN.getValue())) {
|
||||
entryObj.set("unitproject", visaBill.get("unitproject"));
|
||||
}
|
||||
|
||||
entryCollection.add(entryObj);
|
||||
}
|
||||
|
||||
return entryCollection;
|
||||
} else {
|
||||
return entryCollection;
|
||||
}
|
||||
}
|
||||
|
||||
private DynamicObjectCollection setPerformRecordArrToEntry(String serachText, Set<Long> selectedPerformEntryIdSet, DynamicObjectCollection entryCollection, DynamicObject[] performRecordArr) {
|
||||
if (performRecordArr != null && performRecordArr.length != 0) {
|
||||
DynamicObjectType entryType = entryCollection.getDynamicObjectType();
|
||||
DynamicObject[] var6 = performRecordArr;
|
||||
int var7 = performRecordArr.length;
|
||||
|
||||
for(int var8 = 0; var8 < var7; ++var8) {
|
||||
DynamicObject performRecord = var6[var8];
|
||||
DynamicObjectCollection performRecordEntryCol;
|
||||
Iterator var11;
|
||||
DynamicObject performRecordEntry;
|
||||
boolean isSettle;
|
||||
boolean isNeedSettle;
|
||||
DynamicObject entryObj;
|
||||
if (StringUtils.isNotBlank(serachText)) {
|
||||
if (!performRecord.getString("billno").contains(serachText) && !performRecord.getString("name").contains(serachText)) {
|
||||
performRecordEntryCol = performRecord.getDynamicObjectCollection("entryentity");
|
||||
var11 = performRecordEntryCol.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
performRecordEntry = (DynamicObject)var11.next();
|
||||
if (!selectedPerformEntryIdSet.contains(performRecordEntry.getPkValue()) && performRecordEntry.getString("record").contains(serachText)) {
|
||||
isSettle = performRecordEntry.getBoolean("issettle");
|
||||
isNeedSettle = performRecordEntry.getBoolean("isneedsettle");
|
||||
if (isNeedSettle && !isSettle) {
|
||||
entryObj = this.newEntry(performRecord, performRecordEntry, entryType);
|
||||
entryCollection.add(entryObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
performRecordEntryCol = performRecord.getDynamicObjectCollection("entryentity");
|
||||
var11 = performRecordEntryCol.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
performRecordEntry = (DynamicObject)var11.next();
|
||||
if (!selectedPerformEntryIdSet.contains(performRecordEntry.getPkValue())) {
|
||||
isSettle = performRecordEntry.getBoolean("issettle");
|
||||
isNeedSettle = performRecordEntry.getBoolean("isneedsettle");
|
||||
if (isNeedSettle && !isSettle) {
|
||||
entryObj = this.newEntry(performRecord, performRecordEntry, entryType);
|
||||
entryCollection.add(entryObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
performRecordEntryCol = performRecord.getDynamicObjectCollection("entryentity");
|
||||
var11 = performRecordEntryCol.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
performRecordEntry = (DynamicObject)var11.next();
|
||||
if (!selectedPerformEntryIdSet.contains(performRecordEntry.getPkValue())) {
|
||||
isSettle = performRecordEntry.getBoolean("issettle");
|
||||
isNeedSettle = performRecordEntry.getBoolean("isneedsettle");
|
||||
if (isNeedSettle && !isSettle) {
|
||||
entryObj = this.newEntry(performRecord, performRecordEntry, entryType);
|
||||
entryCollection.add(entryObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return entryCollection;
|
||||
} else {
|
||||
return entryCollection;
|
||||
}
|
||||
}
|
||||
|
||||
private DynamicObject newEntry(DynamicObject performRecord, DynamicObject performRecordEntry, DynamicObjectType entryType) {
|
||||
DynamicObject entryObj = new DynamicObject(entryType);
|
||||
entryObj.set("detailitem", performRecordEntry.getString("record"));
|
||||
entryObj.set("detailpayitem", performRecordEntry.getDynamicObject("contpayitem"));
|
||||
entryObj.set("detailoftaxamt", performRecordEntry.getBigDecimal("amount"));
|
||||
entryObj.set("detailtaxamt", performRecordEntry.getBigDecimal("tax"));
|
||||
entryObj.set("detailamt", performRecordEntry.getBigDecimal("notaxamount"));
|
||||
entryObj.set("billnumber", performRecord.getString("billno"));
|
||||
entryObj.set("billname", performRecord.getString("name"));
|
||||
entryObj.set("detailcreator", performRecord.getDynamicObject("creator"));
|
||||
entryObj.set("detailcreatetime", performRecord.getDate("createtime"));
|
||||
entryObj.set("detailauditor", performRecord.getDynamicObject("auditor"));
|
||||
entryObj.set("detailauditdate", performRecord.getDate("auditdate"));
|
||||
entryObj.set("referbilltype", "perform");
|
||||
entryObj.set("referbillid", performRecord.getPkValue());
|
||||
entryObj.set("referentryid", performRecordEntry.getPkValue());
|
||||
if (this.getPayDirection(this.getParentModel()).equals(PayDirectionEnum.IN.getValue())) {
|
||||
entryObj.set("unitproject", performRecord.get("unitproject"));
|
||||
}
|
||||
|
||||
return entryObj;
|
||||
}
|
||||
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate operate = (FormOperate)args.getSource();
|
||||
String operateKey = operate.getOperateKey();
|
||||
if (StringUtils.equals("returntoparent", operateKey)) {
|
||||
this.beforeReturnToParent(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void beforeReturnToParent(BeforeDoOperationEventArgs args) {
|
||||
EntryGrid entryGrid = (EntryGrid)this.getControl("entryentity");
|
||||
int[] selectRows = entryGrid.getSelectRows();
|
||||
Set<Long> addReferBillIds = new HashSet();
|
||||
DynamicObjectCollection collection = new DynamicObjectCollection();
|
||||
boolean flag = false;
|
||||
|
||||
for(int i = 0; i < selectRows.length; ++i) {
|
||||
Long referBillNumber = (Long)this.getModel().getValue("referbillid", selectRows[i]);
|
||||
String referBillType = (String)this.getModel().getValue("referbilltype", selectRows[i]);
|
||||
if (StringUtils.equals("perform", referBillType)) {
|
||||
addReferBillIds.add(referBillNumber);
|
||||
flag = true;
|
||||
} else {
|
||||
DynamicObject entry = this.getModel().getEntryRowEntity("entryentity", selectRows[i]);
|
||||
collection.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
args.setCancel(true);
|
||||
IPageCache pageCache = this.getPageCache();
|
||||
pageCache.put("selectPayItem", SerializationUtils.toJsonString(collection));
|
||||
this.getView().showConfirm(ResManager.loadKDString("添加履约事务将添加所选择履约事务相同单据的所有履约事务,确认添加吗?", "ItemDetailF7EditPlugin_0", "ec-contract-formplugin", new Object[0]), MessageBoxOptions.OKCancel, new ConfirmCallBackListener("addPerform", this));
|
||||
} else {
|
||||
this.getView().returnDataToParent(collection);
|
||||
this.getView().close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
||||
super.confirmCallBack(messageBoxClosedEvent);
|
||||
String callBackId = messageBoxClosedEvent.getCallBackId();
|
||||
if (messageBoxClosedEvent.getResult().equals(MessageBoxResult.Yes)) {
|
||||
if (StringUtils.equals(callBackId, "addPerform")) {
|
||||
this.addPerform();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addPerform() {
|
||||
EntryGrid entryGrid = (EntryGrid)this.getControl("entryentity");
|
||||
int[] selectRows = entryGrid.getSelectRows();
|
||||
Set<Long> addReferBillIds = new HashSet();
|
||||
DynamicObjectCollection collection = new DynamicObjectCollection();
|
||||
|
||||
for(int i = 0; i < selectRows.length; ++i) {
|
||||
Long referBillNumber = (Long)this.getModel().getValue("referbillid", selectRows[i]);
|
||||
String referBillType = (String)this.getModel().getValue("referbilltype", selectRows[i]);
|
||||
if (StringUtils.equals("perform", referBillType)) {
|
||||
addReferBillIds.add(referBillNumber);
|
||||
} else {
|
||||
DynamicObject entry = this.getModel().getEntryRowEntity("entryentity", selectRows[i]);
|
||||
collection.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("entryentity");
|
||||
Iterator var12 = entryEntity.iterator();
|
||||
|
||||
while(var12.hasNext()) {
|
||||
DynamicObject bill = (DynamicObject)var12.next();
|
||||
long referBillId = bill.getLong("referbillid");
|
||||
String referBillType = bill.getString("referbilltype");
|
||||
if (addReferBillIds.contains(referBillId) && StringUtils.equals("perform", referBillType)) {
|
||||
collection.add(bill);
|
||||
}
|
||||
}
|
||||
|
||||
this.getView().returnDataToParent(collection);
|
||||
this.getView().close();
|
||||
}
|
||||
|
||||
private void updateEntry() {
|
||||
this.updateEntryBySerachText("");
|
||||
}
|
||||
|
||||
protected IDataModel getParentModel() {
|
||||
IFormView parentView = this.getView().getParentView();
|
||||
IDataModel parentModel = parentView.getModel();
|
||||
return parentModel;
|
||||
}
|
||||
|
||||
private void updateEntryBySerachText(String serachText) {
|
||||
this.getModel().deleteEntryData("entryentity");
|
||||
QFilter performFilter = null;
|
||||
QFilter commonNumberAndNameFilter = null;
|
||||
if (StringUtils.isNotBlank(serachText)) {
|
||||
performFilter = (new QFilter("billno", "like", "%" + serachText + "%")).or(new QFilter("name", "like", "%" + serachText + "%")).or(new QFilter("entryentity.record", "like", "%" + serachText + "%"));
|
||||
commonNumberAndNameFilter = (new QFilter("billno", "like", "%" + serachText + "%")).or(new QFilter("billname", "like", "%" + serachText + "%"));
|
||||
}
|
||||
|
||||
IDataModel parentModel = this.getParentModel();
|
||||
Map<String, Set<Long>> selectedIdSetMap = this.getSelectedIdSetMap(parentModel);
|
||||
Set<Long> selectedClaimBillIdSet = (Set)selectedIdSetMap.get("claim");
|
||||
Set<Long> selectedPerformEntryIdSet = (Set)selectedIdSetMap.get("perform");
|
||||
Set<Long> selectedVisaBillIdSet = (Set)selectedIdSetMap.get("visa");
|
||||
Set<Long> selectedMeasureBillIdSet = (Set)selectedIdSetMap.get("measure");
|
||||
Set<Long> selectedMaterialOutBillIdSet = (Set)selectedIdSetMap.get("material_out");
|
||||
QFilter noSelectedClaimIdFilter = new QFilter("id", "not in", selectedClaimBillIdSet);
|
||||
QFilter noSelectedVisaIdFilter = new QFilter("id", "not in", selectedVisaBillIdSet);
|
||||
QFilter noSelectedMeasureFilter = new QFilter("id", "not in", selectedMeasureBillIdSet);
|
||||
QFilter noSelectedMaterialOutFilter = new QFilter("id", "not in", selectedMaterialOutBillIdSet);
|
||||
DynamicObject parentObject = parentModel.getDataEntity();
|
||||
this.getModel().setValue("currency", parentObject.getDynamicObject("currency"));
|
||||
String payDirection = parentObject.getString("paydirection");
|
||||
DynamicObject period = parentObject.getDynamicObject("period");
|
||||
DynamicObject contract = parentObject.getDynamicObject("contract");
|
||||
QFilter contractFilter = new QFilter("contract", "=", contract.getPkValue());
|
||||
QFilter billStatusFilter = new QFilter("billstatus", "=", "C");
|
||||
QFilter payDirectionFilter = new QFilter("paydirection", "=", payDirection);
|
||||
QFilter isNeedSettleFilter = new QFilter("isneedsettle", "=", "1");
|
||||
QFilter isNotSettleFilter = new QFilter("issettle", "=", "0");
|
||||
QFilter periodFilter = period == null ? new QFilter("period", "=", 0L) : new QFilter("period.enddate", "<=", period.getDate("enddate"));
|
||||
QFilter measureNotSettleFilter = new QFilter("issettled", "=", "0");
|
||||
QFilter notUseFilter = this.getNotUseFilter(parentModel, contract, ReferBillTypeEnum.MEASURE.getValue());
|
||||
if (StringUtils.equals(payDirection, PayDirectionEnum.OUT.getValue()) && parentObject.getBoolean("issettlebymatin")) {
|
||||
notUseFilter.and(new QFilter("paydirection", "=", PayDirectionEnum.IN.getValue()));
|
||||
}
|
||||
|
||||
QFilter materialOutFilter = new QFilter("contract", "=", contract.getPkValue());
|
||||
if (period != null) {
|
||||
materialOutFilter.and("period.number", "=", period.getString("number"));
|
||||
}
|
||||
|
||||
materialOutFilter.and("costtype", "=", "b");
|
||||
materialOutFilter.and("issettled", "=", "0");
|
||||
materialOutFilter.and("matbilltype", "=", "materialout");
|
||||
QFilter materialNotUseFilter = this.getNotUseMaterialOutFilter(contract, period, parentObject);
|
||||
DynamicObjectCollection entryCollection = this.getModel().getEntryEntity("entryentity");
|
||||
QFilter unitprojectFilter = null;
|
||||
if (PayDirectionEnum.IN.getValue().equals(payDirection)) {
|
||||
DynamicObject unitproject = (DynamicObject)parentModel.getValue("unitproject");
|
||||
if (null != unitproject) {
|
||||
unitprojectFilter = new QFilter("unitproject", "=", unitproject.getPkValue());
|
||||
} else {
|
||||
DynamicObject project = parentModel.getDataEntity().getDynamicObject("project");
|
||||
if (project != null) {
|
||||
DynamicObject proOrg = project.getDynamicObject("projectorg");
|
||||
DynamicObject orgObj = (DynamicObject)parentModel.getValue("org");
|
||||
long orgId = orgObj == null ? 0L : orgObj.getLong("id");
|
||||
if (proOrg != null && orgId != proOrg.getLong("id")) {
|
||||
unitprojectFilter = new QFilter("unitproject.responsibleorg.id", "=", orgId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QFilter[] claimQfilters = new QFilter[]{unitprojectFilter, noSelectedClaimIdFilter, commonNumberAndNameFilter, contractFilter, billStatusFilter, payDirectionFilter, isNeedSettleFilter, isNotSettleFilter, this.getNotUseFilter(parentModel, contract, ReferBillTypeEnum.CLAIM.getValue())};
|
||||
QFilter[] performRecordQfilters = new QFilter[]{unitprojectFilter, performFilter, contractFilter, billStatusFilter, payDirectionFilter, this.getNotUseFilter(parentModel, contract, ReferBillTypeEnum.PERFORM.getValue())};
|
||||
QFilter[] visaBillFilter = new QFilter[]{unitprojectFilter, noSelectedVisaIdFilter, commonNumberAndNameFilter, contractFilter, billStatusFilter, payDirectionFilter, isNeedSettleFilter, isNotSettleFilter, this.getNotUseFilter(parentModel, contract, ReferBillTypeEnum.VISA.getValue())};
|
||||
QFilter[] measureBillFilter = new QFilter[]{noSelectedMeasureFilter, commonNumberAndNameFilter, contractFilter, billStatusFilter, payDirectionFilter, periodFilter, measureNotSettleFilter, notUseFilter};
|
||||
QFilter[] materialOutBillFilter = new QFilter[]{noSelectedMaterialOutFilter, materialOutFilter, materialNotUseFilter, billStatusFilter};
|
||||
DynamicObject[] claimArr = this.getClaimArr(payDirection, claimQfilters);
|
||||
DynamicObject[] performRecordArr = this.getPerformRecordArr(payDirection, performRecordQfilters);
|
||||
DynamicObject[] visaBillArr = this.getVisaBillArr(payDirection, visaBillFilter);
|
||||
DynamicObject[] materialOutBillArr = this.getMaterialOutBillArr(materialOutBillFilter);
|
||||
String entityId = this.getView().getParentView().getEntityId();
|
||||
// if (!StringUtils.equals(entityId, "ec_out_contract_settle") || !(Boolean)parentModel.getValue("iseqsettle")) {
|
||||
// DynamicObject[] measureBillArr = this.getMeasureBillArr(measureBillFilter);
|
||||
// if (payDirection.equals(PayDirectionEnum.IN.getValue())) {
|
||||
// this.setMeasureBillDataToEntry(entryCollection, measureBillArr);
|
||||
// } else {
|
||||
// this.setMeasureBillDataToEntryOut(entryCollection, measureBillArr);
|
||||
// }
|
||||
// }
|
||||
|
||||
this.setClaimArrDataToEntry(entryCollection, claimArr);
|
||||
entryCollection = this.setPerformRecordArrToEntry(serachText, selectedPerformEntryIdSet, entryCollection, performRecordArr);
|
||||
this.setVisaBillArrDataToEntry(entryCollection, visaBillArr);
|
||||
this.setMaterialOutBillDataToEntry(entryCollection, materialOutBillArr);
|
||||
this.getModel().updateEntryCache(entryCollection);
|
||||
this.getView().updateView("entryentity");
|
||||
}
|
||||
|
||||
protected DynamicObject[] getMaterialOutBillArr(QFilter[] materialOutBillFilter) {
|
||||
return BusinessDataServiceHelper.load("ecma_materialoutbill", "id,billname,settleamt,auditdate,billno,creator,createtime,auditor", materialOutBillFilter);
|
||||
}
|
||||
|
||||
protected QFilter getNotUseMaterialOutFilter(DynamicObject contract, DynamicObject period, DynamicObject bill) {
|
||||
QFilter qFilter = new QFilter("contract", "=", contract.getPkValue());
|
||||
qFilter.and(new QFilter("billstatus", "!=", BillStatusEnum.AUDIT.getValue()));
|
||||
qFilter.and(new QFilter("period.number", "=", period.getString("number")));
|
||||
qFilter.and(new QFilter(BaseConstant.ID_ENTITY_PK, "!=", bill.getPkValue()));
|
||||
DynamicObject[] settleBills = BusinessDataServiceHelper.load("ec_out_contract_settle", "id", new QFilter[]{qFilter});
|
||||
Set<Long> materialOutBillIds = new HashSet();
|
||||
DynamicObject[] var7 = settleBills;
|
||||
int var8 = settleBills.length;
|
||||
|
||||
for(int var9 = 0; var9 < var8; ++var9) {
|
||||
DynamicObject settleBill = var7[var9];
|
||||
settleBill = BusinessDataServiceHelper.loadSingle(settleBill.getPkValue(), "ec_out_contract_settle");
|
||||
DynamicObjectCollection entries = settleBill.getDynamicObjectCollection("payitemdetailentry");
|
||||
Iterator var12 = entries.iterator();
|
||||
|
||||
while(var12.hasNext()) {
|
||||
DynamicObject entry = (DynamicObject)var12.next();
|
||||
if (StringUtils.equals(entry.getString("referbilltype"), ReferBillTypeEnum.MATERIAL_OUT.getValue())) {
|
||||
materialOutBillIds.add(entry.getLong("referbillid"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (materialOutBillIds.isEmpty()) {
|
||||
return new QFilter("id", "!=", 0L);
|
||||
} else {
|
||||
return new QFilter("id", "not in", materialOutBillIds);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setMaterialOutBillDataToEntry(DynamicObjectCollection entryCollection, DynamicObject[] materialOutBillArr) {
|
||||
if (materialOutBillArr != null && materialOutBillArr.length != 0) {
|
||||
DynamicObject supplierItem = BusinessDataServiceHelper.loadSingle(1204312316120741888L, "ec_payitem");
|
||||
DynamicObjectType entryType = entryCollection.getDynamicObjectType();
|
||||
|
||||
for(int i = 0; i < materialOutBillArr.length; ++i) {
|
||||
DynamicObject materialOutBill = materialOutBillArr[i];
|
||||
BigDecimal amount = materialOutBill.getBigDecimal("settleamt");
|
||||
DynamicObject entryObj = new DynamicObject(entryType);
|
||||
entryObj.set("detailitem", materialOutBill.getString("billname"));
|
||||
entryObj.set("detailpayitem", supplierItem);
|
||||
entryObj.set("detailoftaxamt", amount);
|
||||
entryObj.set("detailtaxamt", BigDecimal.ZERO);
|
||||
entryObj.set("detailamt", amount);
|
||||
entryObj.set("billnumber", materialOutBill.getString("billno"));
|
||||
entryObj.set("billname", materialOutBill.getString("billname"));
|
||||
entryObj.set("detailcreator", materialOutBill.getDynamicObject("creator"));
|
||||
entryObj.set("detailcreatetime", materialOutBill.getDate("createtime"));
|
||||
entryObj.set("detailauditor", materialOutBill.getDynamicObject("auditor"));
|
||||
entryObj.set("detailauditdate", materialOutBill.getDate("auditdate"));
|
||||
entryObj.set("referbilltype", ReferBillTypeEnum.MATERIAL_OUT.getValue());
|
||||
entryObj.set("referbillid", materialOutBill.getPkValue());
|
||||
entryCollection.add(entryObj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<Long, Set<Long>> getUsedMeasureEntryMap() {
|
||||
String formId = this.getSettleFormId();
|
||||
DynamicObject contract = (DynamicObject)this.getParentModel().getValue("contract");
|
||||
QFilter qFilter = new QFilter("contract", "=", contract.getPkValue());
|
||||
qFilter.and(new QFilter(BaseConstant.ID_ENTITY_PK, "!=", this.getParentModel().getDataEntity().getPkValue()));
|
||||
Map<Long, Set<Long>> ret = new HashMap();
|
||||
DynamicObject[] settleBills = BusinessDataServiceHelper.load(formId, "id", new QFilter[]{qFilter});
|
||||
DynamicObject[] var6 = settleBills;
|
||||
int var7 = settleBills.length;
|
||||
|
||||
for(int var8 = 0; var8 < var7; ++var8) {
|
||||
DynamicObject settleBill = var6[var8];
|
||||
settleBill = BusinessDataServiceHelper.loadSingle(settleBill.getPkValue(), formId);
|
||||
DynamicObjectCollection entries = settleBill.getDynamicObjectCollection("payitemdetailentry");
|
||||
Iterator var11 = entries.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
DynamicObject entry = (DynamicObject)var11.next();
|
||||
if (entry.getString("referbilltype").equals(ReferBillTypeEnum.MEASURE.getValue()) && this.getPayDirection(this.getParentModel()).equals(PayDirectionEnum.IN.getValue())) {
|
||||
long entryUnitId = entry.getLong("detailunitproject_id");
|
||||
long referbillid = entry.getLong("referbillid");
|
||||
Set<Long> orDefault = (Set)ret.getOrDefault(referbillid, new HashSet());
|
||||
orDefault.add(entryUnitId);
|
||||
ret.put(referbillid, orDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected void setMeasureBillDataToEntryOut(DynamicObjectCollection entryCollection, DynamicObject[] measureBillArr) {
|
||||
if (measureBillArr != null && measureBillArr.length != 0) {
|
||||
DynamicObject measureItem = BusinessDataServiceHelper.loadSingle(Long.parseLong("506427748873442304"), "ec_payitem");
|
||||
DynamicObjectType entryType = entryCollection.getDynamicObjectType();
|
||||
|
||||
for(int i = 0; i < measureBillArr.length; ++i) {
|
||||
DynamicObject measureBill = measureBillArr[i];
|
||||
DynamicObject entryObj = new DynamicObject(entryType);
|
||||
entryObj.set("detailitem", measureBill.getString("billname"));
|
||||
entryObj.set("detailpayitem", measureItem);
|
||||
entryObj.set("detailoftaxamt", measureBill.getBigDecimal("measureoftax"));
|
||||
entryObj.set("detailtaxamt", measureBill.getBigDecimal("measuretax"));
|
||||
entryObj.set("detailamt", measureBill.getBigDecimal("measureamount"));
|
||||
entryObj.set("billnumber", measureBill.getString("billno"));
|
||||
entryObj.set("billname", measureBill.getString("billname"));
|
||||
entryObj.set("detailcreator", measureBill.getDynamicObject("creator"));
|
||||
entryObj.set("detailcreatetime", measureBill.getDate("createtime"));
|
||||
entryObj.set("detailauditor", measureBill.getDynamicObject("auditor"));
|
||||
entryObj.set("detailauditdate", measureBill.getDate("auditdate"));
|
||||
entryObj.set("referbilltype", ReferBillTypeEnum.MEASURE.getValue());
|
||||
entryObj.set("referbillid", measureBill.getPkValue());
|
||||
if (measureBill.getBoolean("ismeasurebymatin")) {
|
||||
entryObj.set("ismeasurebymatin", "1");
|
||||
DynamicObjectCollection materialInEntries = measureBill.getDynamicObjectCollection("materialinentry");
|
||||
if (materialInEntries != null && !materialInEntries.isEmpty()) {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal ofTax = BigDecimal.ZERO;
|
||||
Iterator var11 = materialInEntries.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
DynamicObject materialInEntry = (DynamicObject)var11.next();
|
||||
if (materialInEntry.getBoolean("istranssettle")) {
|
||||
amount = amount.add(materialInEntry.getBigDecimal("transnotaxamount"));
|
||||
ofTax = ofTax.add(materialInEntry.getBigDecimal("transtaxamount"));
|
||||
}
|
||||
}
|
||||
|
||||
entryObj.set("measuretransamt", amount);
|
||||
entryObj.set("measuretransoftax", ofTax);
|
||||
}
|
||||
}
|
||||
|
||||
entryCollection.add(entryObj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void setMeasureBillDataToEntry(DynamicObjectCollection entryCollection, DynamicObject[] measureBillArr) {
|
||||
if (measureBillArr != null && measureBillArr.length != 0) {
|
||||
Map<Long, Set<Long>> usedMeasureEntryMap = this.getUsedMeasureEntryMap();
|
||||
Map<Long, Set<Long>> measureSelectedMap = this.getMeasureSelectedMap(this.getParentModel());
|
||||
Map<String, BigDecimal> amountMap = new HashMap();
|
||||
Map<String, BigDecimal> taxMap = new HashMap();
|
||||
Map<String, BigDecimal> taxOfAmountMap = new HashMap();
|
||||
Map<String, String> entryIdsMap = new HashMap();
|
||||
Map<Object, DynamicObject> measurebillMap = (Map)Arrays.stream(measureBillArr).collect(Collectors.toMap(DataEntityBase::getPkValue, Function.identity()));
|
||||
DynamicObject project = (DynamicObject)this.getParentModel().getValue("project");
|
||||
DynamicObject[] var11 = measureBillArr;
|
||||
int var12 = measureBillArr.length;
|
||||
|
||||
for(int var13 = 0; var13 < var12; ++var13) {
|
||||
DynamicObject measureBill = var11[var13];
|
||||
Long measurebillId = measureBill.getLong("id");
|
||||
DynamicObjectCollection listmodelentry = measureBill.getDynamicObjectCollection("listmodelentry");
|
||||
Iterator var17 = listmodelentry.iterator();
|
||||
|
||||
label133:
|
||||
while(var17.hasNext()) {
|
||||
DynamicObject model = (DynamicObject)var17.next();
|
||||
DynamicObjectCollection listentry = model.getDynamicObjectCollection("listentry");
|
||||
Iterator var20 = listentry.iterator();
|
||||
|
||||
while(true) {
|
||||
DynamicObject measureEntry;
|
||||
DynamicObject unitproject;
|
||||
DynamicObject proOrg;
|
||||
long orgId;
|
||||
do {
|
||||
DynamicObject headunitproject;
|
||||
long unitProjectId;
|
||||
do {
|
||||
do {
|
||||
do {
|
||||
if (!var20.hasNext()) {
|
||||
continue label133;
|
||||
}
|
||||
|
||||
measureEntry = (DynamicObject)var20.next();
|
||||
unitproject = measureEntry.getDynamicObject("entryunitproject");
|
||||
headunitproject = (DynamicObject)this.getParentModel().getValue("unitproject");
|
||||
unitProjectId = unitproject == null ? 0L : unitproject.getLong("id");
|
||||
} while(null != headunitproject && unitProjectId != headunitproject.getLong("id"));
|
||||
|
||||
long entryid = measureEntry.getLong("id");
|
||||
} while(usedMeasureEntryMap.containsKey(measurebillId) && ((Set)usedMeasureEntryMap.get(measurebillId)).contains(unitProjectId));
|
||||
} while(measureSelectedMap.containsKey(measurebillId) && ((Set)measureSelectedMap.get(measurebillId)).contains(unitProjectId));
|
||||
|
||||
if (null != headunitproject || unitproject == null || project == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
proOrg = project.getDynamicObject("projectorg");
|
||||
DynamicObject orgObj = this.getParentModel().getDataEntity().getDynamicObject("org");
|
||||
orgId = orgObj == null ? 0L : orgObj.getLong("id");
|
||||
} while(proOrg != null && orgId != proOrg.getLong("id") && unitproject.getLong("responsibleorg.id") != orgId);
|
||||
|
||||
String key = unitproject == null ? "0," + measurebillId : unitproject.getString("id") + "," + measurebillId;
|
||||
BigDecimal thisamount = measureEntry.getBigDecimal("thisamount");
|
||||
BigDecimal thistax = measureEntry.getBigDecimal("thistax");
|
||||
BigDecimal thisoftaxmount = measureEntry.getBigDecimal("thisoftaxmount");
|
||||
amountMap.put(key, ((BigDecimal)amountMap.getOrDefault(key, BigDecimal.ZERO)).add(thisamount));
|
||||
taxMap.put(key, ((BigDecimal)taxMap.getOrDefault(key, BigDecimal.ZERO)).add(thistax));
|
||||
taxOfAmountMap.put(key, ((BigDecimal)taxOfAmountMap.getOrDefault(key, BigDecimal.ZERO)).add(thisoftaxmount));
|
||||
String str = entryIdsMap.get(key) == null ? measureEntry.getString("id") : ((String)entryIdsMap.get(key)).concat(",").concat(measureEntry.getString("id"));
|
||||
entryIdsMap.put(key, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<String> iterator = amountMap.keySet().iterator();
|
||||
DynamicObjectType entryType = entryCollection.getDynamicObjectType();
|
||||
|
||||
DynamicObject entryObj;
|
||||
for(DynamicObject measureItem = BusinessDataServiceHelper.loadSingle(Long.parseLong("506427748873442304"), "ec_payitem"); iterator.hasNext(); entryCollection.add(entryObj)) {
|
||||
String key = (String)iterator.next();
|
||||
String[] split = key.split(",");
|
||||
String unitprojectId = split[0];
|
||||
DynamicObject up = null;
|
||||
if (!"0".equals(unitprojectId)) {
|
||||
up = BusinessDataServiceHelper.loadSingle(Long.valueOf(unitprojectId), "ec_ecbd_unitproject");
|
||||
}
|
||||
|
||||
String billId = split[1];
|
||||
DynamicObject measureBill = (DynamicObject)measurebillMap.get(Long.valueOf(billId));
|
||||
entryObj = new DynamicObject(entryType);
|
||||
entryObj.set("detailitem", measureBill.getString("billname"));
|
||||
entryObj.set("detailpayitem", measureItem);
|
||||
entryObj.set("detailoftaxamt", taxOfAmountMap.get(key));
|
||||
entryObj.set("detailtaxamt", taxMap.get(key));
|
||||
entryObj.set("detailamt", amountMap.get(key));
|
||||
entryObj.set("billnumber", measureBill.getString("billno"));
|
||||
entryObj.set("billname", measureBill.getString("billname"));
|
||||
entryObj.set("detailcreator", measureBill.getDynamicObject("creator"));
|
||||
entryObj.set("detailcreatetime", measureBill.getDate("createtime"));
|
||||
entryObj.set("detailauditor", measureBill.getDynamicObject("auditor"));
|
||||
entryObj.set("detailauditdate", measureBill.getDate("auditdate"));
|
||||
entryObj.set("referbilltype", ReferBillTypeEnum.MEASURE.getValue());
|
||||
entryObj.set("referbillid", measureBill.getPkValue());
|
||||
entryObj.set("relaentryid", entryIdsMap.get(key));
|
||||
entryObj.set("unitproject", up);
|
||||
if (this.getPayDirection(this.getParentModel()).equals(PayDirectionEnum.OUT.getValue()) && measureBill.getBoolean("ismeasurebymatin")) {
|
||||
entryObj.set("ismeasurebymatin", "1");
|
||||
DynamicObjectCollection materialInEntries = measureBill.getDynamicObjectCollection("materialinentry");
|
||||
if (materialInEntries != null && !materialInEntries.isEmpty()) {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal ofTax = BigDecimal.ZERO;
|
||||
Iterator var46 = materialInEntries.iterator();
|
||||
|
||||
while(var46.hasNext()) {
|
||||
DynamicObject materialInEntry = (DynamicObject)var46.next();
|
||||
if (materialInEntry.getBoolean("istranssettle")) {
|
||||
amount = amount.add(materialInEntry.getBigDecimal("transnotaxamount"));
|
||||
ofTax = ofTax.add(materialInEntry.getBigDecimal("transtaxamount"));
|
||||
}
|
||||
}
|
||||
|
||||
entryObj.set("measuretransamt", amount);
|
||||
entryObj.set("measuretransoftax", ofTax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected DynamicObject[] getMeasureBillArr(QFilter[] measureBillFilter) {
|
||||
String prop = "";
|
||||
String formId = "ec_outcontractmeasure";
|
||||
if (this.getPayDirection(this.getParentModel()).equals(PayDirectionEnum.IN.getValue())) {
|
||||
formId = "ec_incontractmeasure";
|
||||
prop = ",listmodelentry,listentry,entryunitproject,thisamount,thistax,thisoftaxmount";
|
||||
}
|
||||
|
||||
return BusinessDataServiceHelper.load(formId, "billno,billname,contract,period,ismeasurebymatin,materialinentry,materialinentry.transtaxamount,materialinentry.transnotaxamount,materialinentry.istranssettle,measureoftax,measureamount,measuretax,creator,createtime,auditor,auditdate" + prop, measureBillFilter);
|
||||
}
|
||||
|
||||
protected String getSettleFormId() {
|
||||
return StringUtils.equals(this.getPayDirection(this.getParentModel()), kd.ec.basedata.common.enums.PayDirectionEnum.OUT.getValue()) ? "ec_out_contract_settle" : "ec_in_contract_settle";
|
||||
}
|
||||
|
||||
protected QFilter getNotUseFilter(IDataModel parentModel, DynamicObject contract, String billType) {
|
||||
String formId = this.getSettleFormId();
|
||||
QFilter qFilter = new QFilter("contract", "=", contract.getPkValue());
|
||||
qFilter.and(new QFilter("billstatus", "!=", BillStatusEnum.AUDIT.getValue()));
|
||||
qFilter.and(new QFilter(BaseConstant.ID_ENTITY_PK, "!=", this.getParentModel().getDataEntity().getPkValue()));
|
||||
DynamicObject[] settleBills = BusinessDataServiceHelper.load(formId, "id", new QFilter[]{qFilter});
|
||||
Set<Long> measureBillSet = new HashSet();
|
||||
Map<Long, List<Long>> ret = new HashMap();
|
||||
DynamicObject[] var9 = settleBills;
|
||||
int var10 = settleBills.length;
|
||||
|
||||
label67:
|
||||
for(int var11 = 0; var11 < var10; ++var11) {
|
||||
DynamicObject settleBill = var9[var11];
|
||||
settleBill = BusinessDataServiceHelper.loadSingle(settleBill.getPkValue(), formId);
|
||||
DynamicObjectCollection entries = settleBill.getDynamicObjectCollection("payitemdetailentry");
|
||||
Iterator var14 = entries.iterator();
|
||||
|
||||
while(true) {
|
||||
while(true) {
|
||||
DynamicObject entry;
|
||||
do {
|
||||
do {
|
||||
if (!var14.hasNext()) {
|
||||
continue label67;
|
||||
}
|
||||
|
||||
entry = (DynamicObject)var14.next();
|
||||
} while(!StringUtils.equals(entry.getString("referbilltype"), billType));
|
||||
|
||||
if (!StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), billType) && !StringUtils.equals(ReferBillTypeEnum.PERFORM.getValue(), billType)) {
|
||||
measureBillSet.add(entry.getLong("referbillid"));
|
||||
}
|
||||
|
||||
if (StringUtils.equals(ReferBillTypeEnum.PERFORM.getValue(), billType)) {
|
||||
measureBillSet.add(entry.getLong("referentryid"));
|
||||
}
|
||||
} while(!StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), billType));
|
||||
|
||||
if (this.getPayDirection(parentModel).equals(kd.ec.basedata.common.enums.PayDirectionEnum.IN.getValue())) {
|
||||
List<String> usedIds = Arrays.asList(entry.getString("relaentryid").split(","));
|
||||
List<Long> useList = (List)usedIds.stream().filter((s) -> {
|
||||
return StringUtils.isNotBlank(s);
|
||||
}).mapToLong(Long::valueOf).boxed().collect(Collectors.toList());
|
||||
Long measureId = entry.getLong("referbillid");
|
||||
List<Long> orDefault = (List)ret.getOrDefault(measureId, new ArrayList());
|
||||
orDefault.addAll(useList);
|
||||
ret.put(measureId, orDefault);
|
||||
DynamicObject measureBill = BusinessDataServiceHelper.loadSingle(measureId, "ec_incontractmeasure");
|
||||
DynamicObjectCollection listmodelentry = measureBill.getDynamicObjectCollection("listmodelentry");
|
||||
ArrayList<Long> curBillentryids = new ArrayList();
|
||||
Iterator var23 = listmodelentry.iterator();
|
||||
|
||||
while(var23.hasNext()) {
|
||||
DynamicObject model = (DynamicObject)var23.next();
|
||||
DynamicObjectCollection listentry = model.getDynamicObjectCollection("listentry");
|
||||
List<Long> ids = (List)listentry.stream().map((o) -> {
|
||||
return o.getLong("id");
|
||||
}).collect(Collectors.toList());
|
||||
curBillentryids.addAll(ids);
|
||||
}
|
||||
|
||||
if (((List)ret.get(measureId)).containsAll(curBillentryids)) {
|
||||
measureBillSet.add(entry.getLong("referbillid"));
|
||||
}
|
||||
} else {
|
||||
measureBillSet.add(entry.getLong("referbillid"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (measureBillSet.isEmpty()) {
|
||||
return new QFilter("id", "!=", 0L);
|
||||
} else if (!StringUtils.equals(ReferBillTypeEnum.PERFORM.getValue(), billType)) {
|
||||
return new QFilter("id", "not in", measureBillSet);
|
||||
} else {
|
||||
return new QFilter("entryentity.id", "not in", measureBillSet);
|
||||
}
|
||||
}
|
||||
|
||||
protected QFilter getNotUseFilter(DynamicObject contract, String payDirection, Object billPk) {
|
||||
String formId = StringUtils.equals(payDirection, PayDirectionEnum.IN.getValue()) ? "ec_in_contract_settle" : "ec_out_contract_settle";
|
||||
QFilter qFilter = new QFilter("contract", "=", contract.getPkValue());
|
||||
qFilter.and(new QFilter("id", "!=", billPk));
|
||||
DynamicObject[] settleBills = BusinessDataServiceHelper.load(formId, "id", new QFilter[]{qFilter});
|
||||
Set<Long> measureBillSet = new HashSet();
|
||||
DynamicObject[] var8 = settleBills;
|
||||
int var9 = settleBills.length;
|
||||
|
||||
for(int var10 = 0; var10 < var9; ++var10) {
|
||||
DynamicObject settleBill = var8[var10];
|
||||
settleBill = BusinessDataServiceHelper.loadSingle(settleBill.getPkValue(), formId);
|
||||
DynamicObjectCollection entries = settleBill.getDynamicObjectCollection("payitemdetailentry");
|
||||
Iterator var13 = entries.iterator();
|
||||
|
||||
while(var13.hasNext()) {
|
||||
DynamicObject entry = (DynamicObject)var13.next();
|
||||
if (StringUtils.equals(entry.getString("referbilltype"), ReferBillTypeEnum.MEASURE.getValue())) {
|
||||
measureBillSet.add(entry.getLong("referbillid"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (measureBillSet.isEmpty()) {
|
||||
return new QFilter("id", "!=", 0L);
|
||||
} else {
|
||||
return new QFilter("id", "not in", measureBillSet);
|
||||
}
|
||||
}
|
||||
|
||||
private DynamicObject[] getClaimArr(String payDirection, QFilter[] qFilters) {
|
||||
return StringUtils.equals(PayDirectionEnum.IN.getValue(), payDirection) ? BusinessDataServiceHelper.load("ec_inclaimbill", "billno,billname,contract,period,contpayitem,claimoftaxamount,taxamount,claimamount,creator,createtime,auditor,auditdate,,isneedsettle,issettle,unitproject", qFilters) : BusinessDataServiceHelper.load("ec_outclaimbill", "billno,billname,contract,period,contpayitem,claimoftaxamount,taxamount,claimamount,creator,createtime,auditor,auditdate", qFilters);
|
||||
}
|
||||
|
||||
private DynamicObject[] getPerformRecordArr(String payDirection, QFilter[] qFilters) {
|
||||
return StringUtils.equals(PayDirectionEnum.IN.getValue(), payDirection) ? BusinessDataServiceHelper.load("ec_in_performrecords", "billno,name,contract,entryentity,entryentity.record,entryentity.tax,entryentity.amount,entryentity.notaxamount,entryentity.contpayitem,creator,createtime,auditor,auditdate,entryentity.isneedsettle,entryentity.issettle,unitproject", qFilters) : BusinessDataServiceHelper.load("ec_out_performrecords", "billno,name,contract,entryentity,entryentity.record,entryentity.tax,entryentity.amount,entryentity.notaxamount,entryentity.contpayitem,creator,createtime,auditor,auditdate,entryentity.isneedsettle,entryentity.issettle", qFilters);
|
||||
}
|
||||
|
||||
private DynamicObject[] getVisaBillArr(String payDirection, QFilter[] qFilters) {
|
||||
return StringUtils.equals(PayDirectionEnum.IN.getValue(), payDirection) ? BusinessDataServiceHelper.load("ec_invisabill", "billno,billname,contract,period,contpayitem,visaoftaxamount,taxamount,visaamount,taxrate,creator,createtime,auditor,auditdate,,isneedsettle,issettle,unitproject", qFilters) : BusinessDataServiceHelper.load("ec_outvisabill", "billno,billname,contract,period,contpayitem,visaoftaxamount,taxamount,visaamount,taxrate,creator,createtime,auditor,auditdate,,isneedsettle,issettle", qFilters);
|
||||
}
|
||||
|
||||
protected Map<Long, Set<Long>> getMeasureEntryIdMap(IDataModel parentModel) {
|
||||
DynamicObjectCollection payItemDetailEntryCol = parentModel.getEntryEntity("payitemdetailentry");
|
||||
Map<Long, Set<Long>> ret = new HashMap();
|
||||
Iterator var4 = payItemDetailEntryCol.iterator();
|
||||
|
||||
while(true) {
|
||||
DynamicObject entry;
|
||||
String referBillType;
|
||||
do {
|
||||
if (!var4.hasNext()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
entry = (DynamicObject)var4.next();
|
||||
referBillType = entry.getString("referbilltype");
|
||||
} while(!StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), referBillType));
|
||||
|
||||
Long measureId = entry.getLong("referbillid");
|
||||
DynamicObject measureBill = BusinessDataServiceHelper.loadSingle(measureId, "ec_incontractmeasure");
|
||||
DynamicObjectCollection listmodelentry = measureBill.getDynamicObjectCollection("listmodelentry");
|
||||
Set<Long> curBillentryids = new HashSet();
|
||||
Iterator var11 = listmodelentry.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
DynamicObject model = (DynamicObject)var11.next();
|
||||
DynamicObjectCollection listentry = model.getDynamicObjectCollection("listentry");
|
||||
Set<Long> ids = (Set)listentry.stream().map((o) -> {
|
||||
return o.getLong("entryunitproject_id");
|
||||
}).collect(Collectors.toSet());
|
||||
curBillentryids.addAll(ids);
|
||||
}
|
||||
|
||||
ret.put(measureId, curBillentryids);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<Long, Set<Long>> getMeasureSelectedMap(IDataModel parentModel) {
|
||||
DynamicObjectCollection payItemDetailEntryCol = parentModel.getEntryEntity("payitemdetailentry");
|
||||
Map<Long, Set<Long>> ret = new HashMap();
|
||||
Iterator var4 = payItemDetailEntryCol.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
DynamicObject entry = (DynamicObject)var4.next();
|
||||
String referBillType = entry.getString("referbilltype");
|
||||
if (StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), referBillType)) {
|
||||
Long measureId = entry.getLong("referbillid");
|
||||
Long detailUnitProId = entry.getLong("detailunitproject_id");
|
||||
Set<Long> orDefault = (Set)ret.getOrDefault(measureId, new HashSet());
|
||||
orDefault.add(detailUnitProId);
|
||||
ret.put(measureId, orDefault);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected String getPayDirection(IDataModel parentModel) {
|
||||
return (String)parentModel.getValue("paydirection");
|
||||
}
|
||||
|
||||
private Map<String, Set<Long>> getSelectedIdSetMap(IDataModel parentModel) {
|
||||
Map<String, Set<Long>> resultMap = new HashMap();
|
||||
Set<Long> selectedClaimBillIdSet = new HashSet();
|
||||
Set<Long> selectedPerformEntryIdSet = new HashSet();
|
||||
Set<Long> selectedVisaBillIdSet = new HashSet();
|
||||
Set<Long> selectedMeasureBillIdSet = new HashSet();
|
||||
Set<Long> selectedMaterialOutBillIdSet = new HashSet();
|
||||
DynamicObjectCollection payItemDetailEntryCol = parentModel.getEntryEntity("payitemdetailentry");
|
||||
Iterator var9 = payItemDetailEntryCol.iterator();
|
||||
|
||||
while(true) {
|
||||
while(var9.hasNext()) {
|
||||
DynamicObject payItemDetailEntry = (DynamicObject)var9.next();
|
||||
String referBillType = payItemDetailEntry.getString("referbilltype");
|
||||
if (StringUtils.equals(ReferBillTypeEnum.CLAIM.getValue(), referBillType)) {
|
||||
selectedClaimBillIdSet.add(payItemDetailEntry.getLong("referbillid"));
|
||||
} else if (StringUtils.equals(ReferBillTypeEnum.PERFORM.getValue(), referBillType)) {
|
||||
selectedPerformEntryIdSet.add(payItemDetailEntry.getLong("referentryid"));
|
||||
} else if (StringUtils.equals(ReferBillTypeEnum.VISA.getValue(), referBillType)) {
|
||||
selectedVisaBillIdSet.add(payItemDetailEntry.getLong("referbillid"));
|
||||
} else if (StringUtils.equals(ReferBillTypeEnum.MEASURE.getValue(), referBillType)) {
|
||||
if (this.getPayDirection(parentModel).equals(PayDirectionEnum.IN.getValue())) {
|
||||
Map<Long, Set<Long>> measureEntryIdMap = this.getMeasureEntryIdMap(parentModel);
|
||||
Map<Long, Set<Long>> measureSelectedMap = this.getMeasureSelectedMap(parentModel);
|
||||
Iterator var14 = measureEntryIdMap.keySet().iterator();
|
||||
|
||||
while(var14.hasNext()) {
|
||||
Long measureId = (Long)var14.next();
|
||||
if (((Set)measureSelectedMap.get(measureId)).containsAll((Collection)measureEntryIdMap.get(measureId))) {
|
||||
selectedMeasureBillIdSet.add(measureId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedMeasureBillIdSet.add(payItemDetailEntry.getLong("referbillid"));
|
||||
}
|
||||
} else if (StringUtils.equals(ReferBillTypeEnum.MATERIAL_OUT.getValue(), referBillType)) {
|
||||
selectedMaterialOutBillIdSet.add(payItemDetailEntry.getLong("referbillid"));
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("claim", selectedClaimBillIdSet);
|
||||
resultMap.put("perform", selectedPerformEntryIdSet);
|
||||
resultMap.put("visa", selectedVisaBillIdSet);
|
||||
resultMap.put("measure", selectedMeasureBillIdSet);
|
||||
resultMap.put("material_out", selectedMaterialOutBillIdSet);
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue