Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
zhangzhiguo 2025-01-03 15:34:48 +08:00
commit 2b4c11f1ef
5 changed files with 251 additions and 82 deletions

View File

@ -128,32 +128,8 @@ public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String propName = e.getProperty().getName();
ChangeData changeData = e.getChangeSet()[0];
if (StringUtils.equals(propName, "contract")) {
this.onContractChanged(changeData);
} else if (StringUtils.equals(propName, "period")) {
this.onPeriodChanged(changeData);
} else if (!StringUtils.equals(propName, "begindate") && !StringUtils.equals(propName, "enddate")) {
if (StringUtils.equals(propName, "thisqty")) {
this.onThisQtyChanged(changeData);
} else if (StringUtils.equals(propName, "thisamount")) {
this.onThisAmountChanged(changeData);
} else if (StringUtils.equals(propName, "thisoftaxmount")) {
this.onThisOfTaxAmountChanged(changeData);
} else if (StringUtils.equals(propName, "thistax")) {
this.onThisTaxChanged(changeData);
} else if (StringUtils.equals(propName, "ismeasurebymatin")) {
this.isMeasureByMaterialInChanged(changeData);
} else if (StringUtils.equals(propName, PriceAdjustModeEnum.ADJUST_AMOUNT.getValue())) {
this.onAdjustAmountChange(changeData);
} else if (StringUtils.equals(propName, PriceAdjustModeEnum.ADJUST_TAX.getValue())) {
this.onAdjustTaxChange(changeData);
}
} else {
this.onDateChanged(changeData, propName);
}
int rowIndex = changeData.getRowIndex();
int parentRowIndex = changeData.getParentRowIndex();
if (StringUtils.equals(propName, "zcgj_hsjell")) {
@ -175,7 +151,7 @@ public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin
listentry.set("currentamt",currentprice.multiply(totalqty));
listentry.set("currenttaxamt",curtaxprice.multiply(totalqty).subtract(currentprice.multiply(totalqty)));
listentry.set("currentoftax",curtaxprice.multiply(totalqty));
this.getView().updateView();
// this.getView().updateView();
}
}
}

View File

@ -2,6 +2,7 @@ package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.metadata.IDataEntityType;
import kd.bos.form.FormShowParameter;
import kd.bos.form.field.BasedataEdit;
import kd.bos.form.field.events.BeforeF7SelectEvent;
@ -42,7 +43,11 @@ public class ContractFilterPlugin extends AbstractBillPlugIn implements Plugin,
// int row = beforeF7SelectEvent.getRow();
// if (this.getModel().getValue("contracttype") != null) {
//判断当前支出还是收入
String name = this.getModel().getDataEntity().getDataEntityType().getName();
String name = "";
IDataEntityType dataEntityType = this.getModel().getDataEntity().getDataEntityType();
if (dataEntityType != null) {
name = dataEntityType.getName();
}
String groupNum = "";
if(name.equals("ec_in_contract")){
groupNum = "01";//收入

View File

@ -12,8 +12,8 @@ public class ContractTreeListExtPlugin extends ContractTreeListingPlugin {
if(contractType != null) {
DynamicObject dynamicObject = (DynamicObject) contractType;
String number = dynamicObject.getString("number");
if(number.equals("wzcg01")||number.equals("sbcg")) {
this.getView().setVisible(false, new String[]{"treecbsnumber", "treecbsname","cbs"});
if(number.equals("wzcg01")||number.equals("sbcg")||number.equals("ZCHLX02")) {
this.getView().setVisible(false, new String[]{"treecbsnumber", "treecbsname","cbs","isincost"});
this.getView().setEnable(false,"isincost");
this.getModel().setValue("isincost",false);
}else if(number.equals("jjfb")){

View File

@ -3,13 +3,20 @@ package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.entity.LocaleString;
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.field.ComboEdit;
import kd.bos.form.field.ComboItem;
import kd.bos.orm.ORM;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
/**
* 支出合同单据界面插件
* 暂不用
@ -18,60 +25,24 @@ public class OutContractFromPlugin extends AbstractBillPlugIn implements Plugin
private String entryName = "treelistentry";//分录标识
private String ecContract = "incontract";//
private String contracttype = "contracttype";//
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String changeName = e.getProperty().getName();
if (changeName.equals(ecContract)) {//收入合同字段值改变
Object outC = this.getModel().getValue(ecContract);
if (outC != null) {
DynamicObject contractF7 = (DynamicObject) outC;
String paydirection = contractF7.getString("paydirection");//支出/收入
String contractNumber = contractF7.getString("number");//获取收入合同合同清单
if (paydirection.equals("in")) {
// QFilter f1 = new QFilter("billno", "=", contractNumber);
// DynamicObject inContract = BusinessDataServiceHelper.loadSingle("ec_in_contract", new QFilter[]{f1});
// DynamicObjectCollection listmodelentry = inContract.getDynamicObjectCollection("listmodelentry");
// for (int x = 0; x < listmodelentry.size(); x++ ) {
// DynamicObject dynamicObject = listmodelentry.get(x);
// DynamicObjectCollection listmodelentry1 = this.getModel().getEntryEntity("listmodelentry");
// DynamicObjectType dynamicObjectType = listmodelentry1.getDynamicObjectType();
// ORM orm = ORM.create();
// long listingid = orm.genLongId(dynamicObjectType);
// int entryRow = this.getModel().insertEntryRow("listmodelentry", x);
// this.getModel().setValue("modelname",dynamicObject.getString("modelname"),entryRow);
// this.getModel().setValue("cmptype",dynamicObject.getString("cmptype"),entryRow);
// this.getModel().setValue("rowamount",dynamicObject.getString("rowamount"),entryRow);
// this.getModel().setValue("rowtax",dynamicObject.getString("rowtax"),entryRow);
// this.getModel().setValue("rowoftax",dynamicObject.getString("rowoftax"),entryRow);
// this.getModel().setValue("listmodelid",listingid,entryRow);
// DynamicObjectCollection sublistentry = dynamicObject.getDynamicObjectCollection("sublistentry");
// for (int i = 0; i < sublistentry.size(); i++) {
// DynamicObject object = sublistentry.get(i);
// int row = this.getModel().insertEntryRow("sublistentry", i);
// this.getModel().setValue("sublistmodelid",listingid,row);
// this.getModel().setValue("sysnumber",object.getString("sysnumber"),row);
// this.getModel().setValue("listnumber",object.getString("listnumber"),row);
// this.getModel().setValue("listname",object.getString("listname"),row);
// this.getModel().setValue("resourceitem",object.getString("resourceitem"),row);
// this.getModel().setValue("measureunit",object.getDynamicObject("measureunit"),row);
// this.getModel().setValue("qty",object.getBigDecimal("qty"),row);
// this.getModel().setValue("price",object.getBigDecimal("price"),row);
// this.getModel().setValue("amount",object.getBigDecimal("amount"),row);
// this.getModel().setValue("rateobj",object.getDynamicObject("rateobj"),row);
// this.getModel().setValue("tax",object.getBigDecimal("tax"),row);
// this.getModel().setValue("taxprice",object.getBigDecimal("taxprice"),row);
// this.getModel().setValue("oftax",object.getBigDecimal("oftax"),row);
// this.getModel().setValue("listunitproject",object.getDynamicObject("listunitproject"),row);
// this.getModel().setValue("desc",object.getString("desc"),row);
}
if (changeName.equals(contracttype)) {//收入合同字段值改变
ChangeData changeData = e.getChangeSet()[0];
DynamicObject contractType = (DynamicObject)changeData.getNewValue();
String number = contractType.getString("number");
List<ComboItem> comboList = new ArrayList<>();
comboList.add(new ComboItem(new LocaleString("全面合作"), "A"));
comboList.add(new ComboItem(new LocaleString("局部合作"), "B"));
if(number.equals("sbzl")){
comboList.add(new ComboItem(new LocaleString("零星租赁"), "C"));
}
this.getView().updateView("listmodelentry");
this.getView().updateView("treelistentry");
ComboEdit comboEdit = getView().getControl("zcgj_cooperatemode");
comboEdit.setComboItems(comboList);
}
// this.getView().setVisible(false, new String[]{"treelistunitproject", "treelistunitprojectname"});
// this.getView().setVisible(false,"");
}
}

View File

@ -1,21 +1,238 @@
package zcgj.zcdev.zcdev.pr.plugin.operate;
import java.util.*;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.entity.LocaleString;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
import kd.bos.entity.validate.AbstractValidator;
import kd.ec.contract.opplugin.OutContractMeasureOp;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.ec.basedata.business.model.BaseConstant;
import kd.ec.basedata.common.enums.SplitBillTypeEnum;
import kd.ec.contract.common.enums.CostControlModelEnum;
import kd.ec.contract.common.utils.EcProjectHelper;
import kd.ec.contract.opplugin.validator.ContractMeasureValidator;
import java.util.List;
public class OutContractMeasurementOp extends OutContractMeasureOp{
public class OutContractMeasurementOp extends AbstractOperationServicePlugIn {
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
List<String> fields = e.getFieldKeys();
fields.add("contract");
fields.add("project");
fields.add("listmodelentry");
fields.add("listentry");
fields.add("listca");
fields.add("listcbs");
fields.add("listboq");
fields.add("entryentity");
fields.add("unitproject");
fields.add("ca");
fields.add("cbs");
fields.add("boq");
fields.add(BaseConstant.ID_ENTITY_PK);
fields.add("measunitproject");
fields.add("ismeasurebymatin");
fields.add("materialinentry");
fields.add("materialinbillid");
}
public void beginOperationTransaction(BeginOperationTransactionArgs e) {
super.beginOperationTransaction(e);
String operationKey = e.getOperationKey();
if (StringUtils.equals("audit", operationKey) || StringUtils.equals("unaudit", operationKey))
updateMaterialStatus(e, operationKey);
}
protected void updateMaterialStatus(BeginOperationTransactionArgs e, String operationKey) {
DynamicObject[] dataArr = e.getDataEntities();
for (int i = 0; i < dataArr.length; i++) {
Boolean isSettleByMatIn = Boolean.valueOf(dataArr[i].getBoolean("ismeasurebymatin"));
if (isSettleByMatIn.booleanValue()) {
List<DynamicObject> saveMatInList = new ArrayList<>();
DynamicObjectCollection matInEntryCol = dataArr[i].getDynamicObjectCollection("materialinentry");
for (int j = 0; j < matInEntryCol.size(); j++) {
Object matInBillId = ((DynamicObject)matInEntryCol.get(j)).get("materialinbillid");
DynamicObject matInObj = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", "ismeasure", new QFilter[] { new QFilter("id", "=", matInBillId) });
if (matInObj != null) {
if (StringUtils.equals("audit", operationKey)) {
matInObj.set("ismeasure", "1");
} else {
matInObj.set("ismeasure", "0");
}
saveMatInList.add(matInObj);
}
}
SaveServiceHelper.save(saveMatInList.<DynamicObject>toArray(new DynamicObject[saveMatInList.size()]));
}
}
}
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
List<AbstractValidator> validators = e.getValidators();
// 删除标品校验器
validators.removeIf(validator -> validator instanceof ContractMeasureValidator);
validators.add(new OutContractMeasureValidator());
// 添加定制二开的校验器位置放第一位优先执行
validators.add(0, new ContractMeasurementValidator());
}
private class OutContractMeasureValidator extends AbstractValidator {
private OutContractMeasureValidator() {}
public void validate() {
String operateKey = getOperateKey();
ExtendedDataEntity[] entities = getDataEntities();
Map<Object, Integer> materialInBillIds = new HashMap<>(16);
for (ExtendedDataEntity dataEntity : entities) {
DynamicObject bill = dataEntity.getDataEntity();
if (bill.getBoolean("ismeasurebymatin")) {
DynamicObjectCollection materialInEntries = bill.getDynamicObjectCollection("materialinentry");
if (materialInEntries != null && !materialInEntries.isEmpty())
for (DynamicObject materialInEntry : materialInEntries)
materialInBillIds.put(materialInEntry.get("materialinbillid"),
Integer.valueOf(1 + ((Integer)materialInBillIds.getOrDefault(materialInEntry.get("materialinbillid"), Integer.valueOf(0))).intValue()));
}
}
for (ExtendedDataEntity dataEntity : entities) {
if (StringUtils.equals(operateKey, "submit")) {
if (validateMaterialInStatus(dataEntity, materialInBillIds))
validateCostFieldInput(dataEntity);
} else if (StringUtils.equals(operateKey, "unaudit")) {
validateReference(dataEntity);
}
}
}
protected boolean validateMaterialInStatus(ExtendedDataEntity dataEntity, Map<Object, Integer> materialInBillIds) {
DynamicObject bill = dataEntity.getDataEntity();
boolean result = true;
if (bill.getBoolean("ismeasurebymatin")) {
DynamicObjectCollection matInCol = bill.getDynamicObjectCollection("materialinentry");
if (matInCol == null)
return true;
for(int i = 0; i < matInCol.size(); ++i) {
Object matInBillId = ((DynamicObject)matInCol.get(i)).get("materialinbillid");
if ((Integer)materialInBillIds.getOrDefault(matInBillId, 0) > 1) {
String formatTextx = String.format(ResManager.loadKDString("入库单列表中第%s行已被其他单据引用不能重复计量请修改数据。", "OutContractMeasureOp_8", "ec-contract-opplugin", new Object[0]), i + 1);
this.addErrorMessage(dataEntity, formatTextx);
} else {
DynamicObject matInObj = QueryServiceHelper.queryOne("ecma_materialinbill", "ismeasure", new QFilter[]{new QFilter("id", "=", matInBillId)});
String formatText;
if (matInObj != null && matInObj.getBoolean("ismeasure")) {
formatText = String.format(ResManager.loadKDString("入库单列表中第%s行已被计量不能重复计量请修改数据。", "OutContractMeasureOp_9", "ec-contract-opplugin", new Object[0]), i + 1);
this.addErrorMessage(dataEntity, formatText);
result = false;
} else if (matInObj == null) {
formatText = String.format(ResManager.loadKDString("入库单列表的第%s行对应的入库单已被删除请修改数据。", "OutContractMeasureOp_10", "ec-contract-opplugin", new Object[0]), i + 1);
this.addErrorMessage(dataEntity, formatText);
result = false;
}
}
}
}
return result;
}
protected void validateReference(ExtendedDataEntity dataEntity) {
QFilter qFilter = new QFilter("entryentity.settleid", "=", dataEntity.getBillPkId());
qFilter.and(new QFilter("entryentity.splitbilltype", "=", SplitBillTypeEnum.MEASURE.getValue()));
boolean exists = QueryServiceHelper.exists("ecco_contractcost", new QFilter[] { qFilter });
if (exists) {
LocaleString metaName = EntityMetadataCache.getDataEntityType("ecco_contractcost").getDisplayName();
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("该计量单已被%s引用不可反审核。", "OutContractMeasureOp_14", "ec-contract-opplugin", new Object[0]), metaName.getLocaleValue()));
}
}
protected void validateCostFieldInput(ExtendedDataEntity dataEntity) {
DynamicObject bill = dataEntity.getDataEntity();
DynamicObject project = bill.getDynamicObject("project");
DynamicObject contract = bill.getDynamicObject("contract");
boolean isInCost = (contract == null) ? Boolean.FALSE.booleanValue() : contract.getBoolean("isincost");
if (project == null || !isInCost)
return;
List<String> modelList = EcProjectHelper.getCostControlModelList(Long.valueOf(project.getLong("id")));
if (contract.getBoolean("isonlist")) {
DynamicObjectCollection modelEntries = bill.getDynamicObjectCollection("listmodelentry");
if (modelEntries != null && !modelEntries.isEmpty()) {
int modelIndex = 1;
StringBuilder sb = new StringBuilder();
for (DynamicObject modelEntry : modelEntries) {
sb.delete(0, sb.length());
DynamicObjectCollection subEntries = modelEntry.getDynamicObjectCollection("listentry");
if (subEntries != null && !subEntries.isEmpty()) {
StringBuilder rowSb = new StringBuilder();
int index = 1;
for(Iterator var15 = subEntries.iterator(); var15.hasNext(); ++index) {
DynamicObject subEntry = (DynamicObject)var15.next();
rowSb.delete(0, rowSb.length());
if (modelList.contains(CostControlModelEnum.CA.getValue()) && subEntry.getDynamicObject("listca") == null) {
rowSb.append(ResManager.loadKDString("“成本科目”、", "OutContractMeasureOp_1", "ec-contract-opplugin", new Object[0]));
}
// if (modelList.contains(CostControlModelEnum.CBS.getValue()) && subEntry.getDynamicObject("listcbs") == null) {
// rowSb.append(ResManager.loadKDString("“成本分解结构”、", "OutContractMeasureOp_2", "ec-contract-opplugin", new Object[0]));
// }
if (modelList.contains(CostControlModelEnum.BOQ.getValue()) && subEntry.getDynamicObject("listboq") == null) {
rowSb.append(ResManager.loadKDString("“工程量清单”、", "OutContractMeasureOp_3", "ec-contract-opplugin", new Object[0]));
}
if (rowSb.length() > 0) {
sb.append(String.format(ResManager.loadKDString("第%1$s行%2$s", "OutContractMeasureOp_11", "ec-contract-opplugin", new Object[0]), index, rowSb.substring(0, rowSb.length() - 1)));
}
}
if (sb.length() > 0) {
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("请填写“计量清单”第%1$s个卡片%2$s。", "OutContractMeasureOp_12", "ec-contract-opplugin", new Object[0]), modelIndex, sb.substring(0, sb.length() - 1)));
}
}
}
modelIndex++;
}
} else {
DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity");
if (entries != null && !entries.isEmpty()) {
boolean unitProjectMustInput = (contract.getDynamicObject("unitproject") != null);
StringBuilder sb = new StringBuilder();
int index = 1;
for (DynamicObject entry : entries) {
sb.delete(0, sb.length());
if (unitProjectMustInput && entry.getDynamicObject("unitproject") == null) {
sb.append(ResManager.loadKDString("“单位工程”、", "OutContractMeasureOp_6", "ec-contract-opplugin", new Object[0]));
}
if (modelList.contains(CostControlModelEnum.CA.getValue()) && entry.getDynamicObject("ca") == null) {
sb.append(ResManager.loadKDString("“成本科目”、", "OutContractMeasureOp_1", "ec-contract-opplugin", new Object[0]));
}
// if (modelList.contains(CostControlModelEnum.CBS.getValue()) && entry.getDynamicObject("cbs") == null) {
// sb.append(ResManager.loadKDString("“成本分解结构”、", "OutContractMeasureOp_2", "ec-contract-opplugin", new Object[0]));
// }
if (modelList.contains(CostControlModelEnum.BOQ.getValue()) && entry.getDynamicObject("boq") == null) {
sb.append(ResManager.loadKDString("“工程量清单”、", "OutContractMeasureOp_3", "ec-contract-opplugin", new Object[0]));
}
if (sb.length() > 0) {
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("请填写“计量金额明细”第%1$s行%2$s。", "OutContractMeasureOp_13", "ec-contract-opplugin", new Object[0]), index, sb.substring(0, sb.length() - 1)));
}
}
}
}
}
}
}