采购申请添加合同物资逻辑和合同看板优化
This commit is contained in:
parent
02301f9581
commit
b4844b3dad
|
|
@ -16,6 +16,9 @@ import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合同看板二开重写系统部分代码
|
||||||
|
*/
|
||||||
public class DynamicContractViewUIExt extends DynamicContractViewUI {
|
public class DynamicContractViewUIExt extends DynamicContractViewUI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -98,4 +101,59 @@ public class DynamicContractViewUIExt extends DynamicContractViewUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateReceive(Long contractId, String payDirection) {
|
||||||
|
this.getModel().deleteEntryData("receiveentry");
|
||||||
|
String formId = "";
|
||||||
|
DynamicObject contract = BusinessDataServiceHelper.loadSingle(contractId, "ec_in_contract", "taxrate.taxRate");
|
||||||
|
if (PayDirectionEnum.IN.getValue().equals(payDirection)) {
|
||||||
|
formId = "ec_income_register";
|
||||||
|
} else {
|
||||||
|
formId = "ec_payment_register";
|
||||||
|
}
|
||||||
|
|
||||||
|
QFilter incomeFilter = new QFilter("entryentity.contract.id", "=", contractId);
|
||||||
|
incomeFilter.and(new QFilter("billStatus", "=", "C"));
|
||||||
|
DynamicObject[] incomeBillCols = BusinessDataServiceHelper.load(formId, "*", new QFilter[]{incomeFilter});
|
||||||
|
int rowIndex = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < incomeBillCols.length; ++i) {
|
||||||
|
DynamicObject incomeBillInfo = incomeBillCols[i];
|
||||||
|
incomeBillInfo = BusinessDataServiceHelper.loadSingle(incomeBillInfo.get("id"), formId);
|
||||||
|
DynamicObjectCollection incomeBillEntryCols = (DynamicObjectCollection) incomeBillInfo.get("entryentity");
|
||||||
|
|
||||||
|
for (int j = 0; j < incomeBillEntryCols.size(); ++j) {
|
||||||
|
DynamicObject incomeBillEntry = (DynamicObject) incomeBillEntryCols.get(j);
|
||||||
|
if (incomeBillEntry.get("contract.id") != null && contractId.toString().equals(incomeBillEntry.get("contract.id").toString())) {
|
||||||
|
this.getModel().createNewEntryRow("receiveentry");
|
||||||
|
BigDecimal ofTaxAmount = BigDecimal.ZERO;
|
||||||
|
if (PayDirectionEnum.IN.getValue().equals(payDirection)) {
|
||||||
|
ofTaxAmount = incomeBillEntry.getBigDecimal("receiptoftaxamount");
|
||||||
|
} else {
|
||||||
|
ofTaxAmount = incomeBillEntry.getBigDecimal("thispaymentoftaxamount");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal taxRate = BigDecimal.ZERO;
|
||||||
|
if (contract.getDynamicObject("taxrate") != null) {
|
||||||
|
taxRate = contract.getDynamicObject("taxrate").getBigDecimal("taxRate").divide(BigDecimal.valueOf(100L), 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal amount = ofTaxAmount.divide(BigDecimal.ONE.add(taxRate), 4);
|
||||||
|
BigDecimal tax = ofTaxAmount.subtract(amount);
|
||||||
|
this.getModel().setValue("incomebillno", incomeBillInfo.get("billno"), rowIndex);
|
||||||
|
this.getModel().setValue("incomebillname", incomeBillInfo.get("billname"), rowIndex);
|
||||||
|
this.getModel().setValue("incomeamount", amount, rowIndex);
|
||||||
|
this.getModel().setValue("incometaxamount", tax, rowIndex);
|
||||||
|
this.getModel().setValue("incomeoftaxamount", ofTaxAmount, rowIndex);
|
||||||
|
this.getModel().setValue("incomebizdate", incomeBillInfo.get("bizdate"), rowIndex);
|
||||||
|
this.getModel().setValue("incomecreator", incomeBillInfo.get("creator"), rowIndex);
|
||||||
|
this.getModel().setValue("createdate", incomeBillInfo.get("createtime"), rowIndex);
|
||||||
|
this.getModel().setValue("incomedesc", incomeBillEntry.get("description"), rowIndex);
|
||||||
|
this.getModel().setValue("zcgj_incomeapply", incomeBillEntry.get("incomeapply"), rowIndex);//请款单号--二开添加
|
||||||
|
++rowIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,32 @@ package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.dataentity.resource.ResManager;
|
||||||
|
import kd.bos.dataentity.utils.StringUtils;
|
||||||
|
import kd.bos.entity.EntityMetadataCache;
|
||||||
|
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||||
import kd.bos.entity.datamodel.events.ChangeData;
|
import kd.bos.entity.datamodel.events.ChangeData;
|
||||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||||
|
import kd.bos.form.CloseCallBack;
|
||||||
|
import kd.bos.form.ShowFormHelper;
|
||||||
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
|
import kd.bos.form.events.ClosedCallBackEvent;
|
||||||
import kd.bos.form.field.BasedataEdit;
|
import kd.bos.form.field.BasedataEdit;
|
||||||
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
||||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||||
|
import kd.bos.form.operate.FormOperate;
|
||||||
import kd.bos.list.ListShowParameter;
|
import kd.bos.list.ListShowParameter;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.QueryServiceHelper;
|
||||||
import kd.bos.servicehelper.user.UserServiceHelper;
|
import kd.bos.servicehelper.user.UserServiceHelper;
|
||||||
|
import kd.ec.basedata.business.model.cont.OutTreeListingConstant;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.math.BigDecimal;
|
||||||
import java.util.EventObject;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购申请单表单插件
|
* 采购申请单表单插件
|
||||||
|
|
@ -22,6 +35,7 @@ import java.util.List;
|
||||||
* 2:过滤项目:项目的项目组织与财务记账组织一致才显示
|
* 2:过滤项目:项目的项目组织与财务记账组织一致才显示
|
||||||
* 3:项目字段赋值
|
* 3:项目字段赋值
|
||||||
* 4:申请人部门过滤赋值
|
* 4:申请人部门过滤赋值
|
||||||
|
* 5:添加合同物资按钮对应逻辑
|
||||||
*/
|
*/
|
||||||
public class PurchaseAppBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
|
public class PurchaseAppBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -97,7 +111,7 @@ public class PurchaseAppBillPlugin extends AbstractBillPlugIn implements BeforeF
|
||||||
DynamicObject fiaccountorg1 = (DynamicObject) fiaccountorg;
|
DynamicObject fiaccountorg1 = (DynamicObject) fiaccountorg;
|
||||||
qFilters.add(new QFilter("projectorg.id", QCP.in, fiaccountorg1.get("id")));//项目组织
|
qFilters.add(new QFilter("projectorg.id", QCP.in, fiaccountorg1.get("id")));//项目组织
|
||||||
}
|
}
|
||||||
} else if ("zcgj_persondepart".equals(propertyName)){
|
} else if ("zcgj_persondepart".equals(propertyName)) {
|
||||||
// 申请人部门
|
// 申请人部门
|
||||||
Object applyer = this.getModel().getValue("applyer");//申请人
|
Object applyer = this.getModel().getValue("applyer");//申请人
|
||||||
if (applyer == null) {
|
if (applyer == null) {
|
||||||
|
|
@ -114,4 +128,89 @@ public class PurchaseAppBillPlugin extends AbstractBillPlugIn implements BeforeF
|
||||||
}
|
}
|
||||||
formShowParameter.getListFilterParameter().setQFilters(qFilters);
|
formShowParameter.getListFilterParameter().setQFilters(qFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||||
|
FormOperate operate = (FormOperate) args.getSource();
|
||||||
|
if ("selcontlist".equals(operate.getOperateKey())) {
|
||||||
|
//添加合同物资
|
||||||
|
this.doSelContList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doSelContList() {
|
||||||
|
DynamicObject contract = (DynamicObject) this.getModel().getValue("zcgj_contract");//物资采购合同
|
||||||
|
if (contract == null) {
|
||||||
|
this.getView().showTipNotification(ResManager.loadKDString("请先选择物资采购合同。", "MaterialInBillEditPlugin_1", "ec-ecma-formplugin", new Object[0]));
|
||||||
|
} else {
|
||||||
|
ListShowParameter parameter = ShowFormHelper.createShowListForm("ec_outtreelisting", true, 3, true);
|
||||||
|
parameter.getCustomParams().put("isFromMat", "true");
|
||||||
|
Long contId = contract.getLong("id");
|
||||||
|
parameter.getListFilterParameter().getQFilters().add(new QFilter("contractid", "=", contId));
|
||||||
|
parameter.getListFilterParameter().getQFilters().add(new QFilter("resourceitem", "!=", 0));
|
||||||
|
int rowCount = this.getModel().getEntryRowCount("purchaseentry");//采购明细单据体
|
||||||
|
List<Long> selIds = new ArrayList();
|
||||||
|
|
||||||
|
for (int i = 0; i < rowCount; ++i) {
|
||||||
|
String id = (String) this.getModel().getValue("zcgj_listingid", i);
|
||||||
|
if (StringUtils.isNotBlank(id)) {
|
||||||
|
selIds.add(Long.valueOf(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parameter.getListFilterParameter().getQFilters().add(new QFilter(OutTreeListingConstant.ID_ENTITY_PK, "not in", selIds.toArray()));
|
||||||
|
|
||||||
|
CloseCallBack callBack = new CloseCallBack(this, "selcontlist");
|
||||||
|
parameter.setCloseCallBack(callBack);
|
||||||
|
this.getView().showForm(parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
||||||
|
super.closedCallBack(closedCallBackEvent);
|
||||||
|
if ("selcontlist".equals(closedCallBackEvent.getActionId())) {
|
||||||
|
ListSelectedRowCollection rows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData();
|
||||||
|
if (rows != null && rows.size() > 0) {
|
||||||
|
List<Object> listIds = (List) rows.stream().map((obj) -> {
|
||||||
|
return obj.getPrimaryKeyValue();
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
DynamicObject[] listings = BusinessDataServiceHelper.load(listIds.toArray(new Long[listIds.size()]), EntityMetadataCache.getDataEntityType("ec_outtreelisting"));
|
||||||
|
this.fillEntryByContListing(listings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillEntryByContListing(DynamicObject[] listings) {
|
||||||
|
int rowCount = this.getModel().getEntryRowCount("purchaseentry");
|
||||||
|
Set<String> listingIdSet = new HashSet();
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < rowCount; ++i) {
|
||||||
|
String id = (String) this.getModel().getValue("zcgj_listingid", i);
|
||||||
|
if (id != null && id != " ") {
|
||||||
|
listingIdSet.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < listings.length; ++i) {
|
||||||
|
if (!listingIdSet.contains(listings[i].getString("id"))) {
|
||||||
|
int curIndex = this.getModel().createNewEntryRow("purchaseentry");
|
||||||
|
this.getModel().updateCache();
|
||||||
|
this.getModel().setValue("zcgj_listingid", listings[i].get(OutTreeListingConstant.ID_ENTITY_PK), curIndex);
|
||||||
|
DynamicObject resourceItem = listings[i].getDynamicObject("resourceitem");
|
||||||
|
this.getModel().setValue("material", resourceItem, curIndex);//资源编码
|
||||||
|
this.getModel().setValue("entrytaxrate", listings[i].get("rateobj"), curIndex);//税率
|
||||||
|
this.getModel().setValue("purchaseqty", listings[i].get("totalqty"), curIndex);//采购数量
|
||||||
|
this.getModel().setValue("price", listings[i].get("currentprice"), curIndex);//预估单价
|
||||||
|
Object pkValue = listings[i].getPkValue();
|
||||||
|
QFilter filter = new QFilter("listmodelentry.sublistentry.id", QCP.equals, pkValue);
|
||||||
|
DynamicObjectCollection ec_out_contract = QueryServiceHelper.query("ec_out_contract", "listmodelentry.sublistentry.zcgj_treeresitemmodel2", new QFilter[]{filter});
|
||||||
|
if (ec_out_contract.size() > 0) {
|
||||||
|
Object modelnum = ec_out_contract.get(0).get("listmodelentry.sublistentry.zcgj_treeresitemmodel2");
|
||||||
|
if (modelnum != null) {
|
||||||
|
this.getModel().setValue("zcgj_model", modelnum, curIndex);//规格型号
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue