收入与支出合同计量清单过滤

This commit is contained in:
xiaoshi 2024-12-05 18:42:42 +08:00
parent 7f1ab2e51a
commit feefdde77f
2 changed files with 90 additions and 1 deletions

View File

@ -1,9 +1,20 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.form.CloseCallBack;
import kd.bos.form.ShowFormHelper;
import kd.bos.list.ListShowParameter;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.ec.contract.formplugin.InContractMeasureBillEditPlugin;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEditPlugin {
@ -29,4 +40,82 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd
}
}
@Override
protected void doNewListEntry() {
{
boolean inContract = this.isInContract();
String formId = inContract ? "ec_intreelisting" : "ec_outtreelisting";
ListShowParameter param = ShowFormHelper.createShowListForm(formId, true, 3, true);
List<QFilter> qFilters = param.getListFilterParameter().getQFilters();
int rowCount = this.getModel().getEntryRowCount("listentry");
List<Object> listingIds = new ArrayList();
int rowIndex;
for(rowIndex = 0; rowIndex < rowCount; ++rowIndex) {
DynamicObject listing = (DynamicObject)this.getModel().getValue("listing", rowIndex);
if (listing != null) {
// listingIds.add(listing.getPkValue());
}
}
qFilters.add(new QFilter("id", "not in", listingIds));
rowIndex = this.getModel().getEntryCurrentRowIndex("listmodelentry");
String listModelId = (String)this.getModel().getValue("listmodelid", rowIndex);
qFilters.add(new QFilter("listingmodel", "=", StringUtils.isNotBlank(listModelId) ? Long.parseLong(listModelId) : 0L));
DynamicObject contract = (DynamicObject)this.getModel().getValue("contract");
if (contract != null) {
qFilters.add(new QFilter("contractid", "=", contract.getLong("id")));
}
DynamicObject project = this.getModel().getDataEntity().getDynamicObject("project");
QFilter unitprojectQFilter = null;
if (project != null && "unitproject".equals(project.getString("boqmode"))) {
DynamicObject unitproject = this.getModel().getDataEntity().getDynamicObject("unitproject");
DynamicObject contOnunit = BusinessDataServiceHelper.loadSingle("ec_in_contract", "id,onunit", new QFilter[]{new QFilter("id", "=", contract.getPkValue())});
if (contOnunit != null) {
Boolean onUnit = contOnunit.getBoolean("onunit");
if (unitproject != null) {
unitprojectQFilter = new QFilter("listunitproject", "=", unitproject.getPkValue());
} else {
List unitProjectIds;
if (onUnit) {
unitProjectIds = this.getUnitprojectIds(project);
unitprojectQFilter = new QFilter("listunitproject", "in", unitProjectIds);
} else {
unitprojectQFilter = new QFilter("listunitproject", "=", 0L);
unitProjectIds = this.getUnitprojectIds(project);
unitprojectQFilter.or(new QFilter("listunitproject", "in", unitProjectIds));
}
}
}
}
if (unitprojectQFilter != null) {
qFilters.add(unitprojectQFilter);
}
param.setCustomParam("listmodelid", listModelId);
CloseCallBack callBack = new CloseCallBack(this, "newlistentry");
param.setCloseCallBack(callBack);
this.getView().showForm(param);
}
}
private List<Long> getUnitprojectIds(DynamicObject project) {
List<Long> result = null;
DynamicObject orgObj = this.getModel().getDataEntity().getDynamicObject("org");
long orgId = orgObj == null ? 0L : orgObj.getLong("id");
QFilter qFilter = new QFilter("parent", "=", project.getPkValue());
DynamicObject ecProject = BusinessDataServiceHelper.loadSingle(project.getPkValue(), "ec_project");
DynamicObject proOrg = ecProject.getDynamicObject("projectorg");
if (proOrg != null && orgId != proOrg.getLong("id")) {
qFilter.and(new QFilter("responsibleorg", "=", orgId));
}
DynamicObject[] unitprojects = BusinessDataServiceHelper.load("ec_unitproject", "id,parent", new QFilter[]{qFilter});
result = (List) Arrays.stream(unitprojects).map((o) -> {
return o.getLong("id");
}).collect(Collectors.toList());
return result;
}
}

View File

@ -43,7 +43,7 @@ public final class CosmicLauncher {
*/
private static final String DEFAULT_COSMIT_HOME_PATH = System.getProperty("user.home").replaceAll("\\\\", "/") + "/cosmic/home";
private static final String PROJECT_HOME = "E:/Code/zhongcaidev";
private static final String PROJECT_HOME = "D:/ideazcgj";
private static final String LOCAL_IP = "127.0.0.1";