Compare commits
No commits in common. "57071d39c5c7cb57fcedfdc8519b4815ca8b46b0" and "81afbd7844b687e4dc20e4dfde4da59f1b2e5b77" have entirely different histories.
57071d39c5
...
81afbd7844
|
@ -68,23 +68,12 @@ public class ContractFilterPlugin extends AbstractBillPlugIn implements Plugin,
|
||||||
//设置F7列表左树的过滤条件
|
//设置F7列表左树的过滤条件
|
||||||
showParameter.getTreeFilterParameter().getQFilters().add(treeFilter);
|
showParameter.getTreeFilterParameter().getQFilters().add(treeFilter);
|
||||||
} else if (name1.equals("treeresourceitem")) {
|
} else if (name1.equals("treeresourceitem")) {
|
||||||
//资源编码
|
|
||||||
ListShowParameter showParameter =(ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
|
ListShowParameter showParameter =(ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
|
||||||
Object contType = this.getModel().getValue("contracttype");
|
Object contType = this.getModel().getValue("contracttype");
|
||||||
if(contType!=null){
|
if(contType!=null){
|
||||||
DynamicObject contractType = (DynamicObject)contType;
|
DynamicObject contractType = (DynamicObject)contType;
|
||||||
showParameter.setCustomParam("contractType",contractType.getString("number"));
|
showParameter.setCustomParam("contractType",contractType.getString("number"));
|
||||||
}
|
}
|
||||||
Object contractType = this.getModel().getValue("contracttype");//合同类型
|
|
||||||
if (contractType != null){
|
|
||||||
DynamicObject contractType1 = (DynamicObject)contractType;
|
|
||||||
String contractType1Number = contractType1.getString("number");//合同类型-编码
|
|
||||||
if (contractType1Number.equals("ZCHLX02")){
|
|
||||||
//合同类型为物资采购时
|
|
||||||
QFilter qFilter = new QFilter("resourcetype", QCP.equals, "03");
|
|
||||||
showParameter.getListFilterParameter().getQFilters().add(qFilter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (name1.equals("zcgj_contractprocess")) {
|
} else if (name1.equals("zcgj_contractprocess")) {
|
||||||
String name = this.getModel().getDataEntity().getDataEntityType().getName();
|
String name = this.getModel().getDataEntity().getDataEntityType().getName();
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
|
import kd.bos.algo.DataSet;
|
||||||
|
import kd.bos.algo.JoinDataSet;
|
||||||
|
import kd.bos.algo.JoinType;
|
||||||
|
import kd.bos.algo.Row;
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
|
import kd.bos.context.RequestContext;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
|
||||||
import kd.bos.dataentity.resource.ResManager;
|
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.*;
|
import kd.bos.form.*;
|
||||||
import kd.bos.form.control.events.ItemClickEvent;
|
import kd.bos.form.control.EntryGrid;
|
||||||
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
import kd.bos.form.events.ClosedCallBackEvent;
|
import kd.bos.form.events.ClosedCallBackEvent;
|
||||||
import kd.bos.form.field.BasedataEdit;
|
import kd.bos.form.field.BasedataEdit;
|
||||||
|
@ -26,6 +34,7 @@ import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库单表单插件
|
* 入库单表单插件
|
||||||
|
@ -35,7 +44,6 @@ import java.util.*;
|
||||||
* 4:申请人部门根据物资申请人过滤部门
|
* 4:申请人部门根据物资申请人过滤部门
|
||||||
* 5:申请人部门赋值逻辑
|
* 5:申请人部门赋值逻辑
|
||||||
* 6:合同编码字段赋值
|
* 6:合同编码字段赋值
|
||||||
* 7:费用汇总分录新增赋值逻辑
|
|
||||||
*/
|
*/
|
||||||
public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
|
public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +53,6 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
|
||||||
purchaseApply.addBeforeF7SelectListener(this);
|
purchaseApply.addBeforeF7SelectListener(this);
|
||||||
BasedataEdit zcgj_applidepart = getView().getControl("zcgj_applidepart");//申请人部门
|
BasedataEdit zcgj_applidepart = getView().getControl("zcgj_applidepart");//申请人部门
|
||||||
zcgj_applidepart.addBeforeF7SelectListener(this);
|
zcgj_applidepart.addBeforeF7SelectListener(this);
|
||||||
this.addItemClickListeners("advcontoolbarap");//入库单明细工具栏
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,16 +63,6 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
|
||||||
this.getModel().setValue("zcgj_applidepart", mainOrgID);//申请人部门
|
this.getModel().setValue("zcgj_applidepart", mainOrgID);//申请人部门
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void itemClick(ItemClickEvent evt) {
|
|
||||||
super.itemClick(evt);
|
|
||||||
String itemKey = evt.getItemKey();
|
|
||||||
if (itemKey.equals("delentry")) {
|
|
||||||
//入库单明细-删行
|
|
||||||
setNewExpenseSummary();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChanged(PropertyChangedArgs e) {
|
public void propertyChanged(PropertyChangedArgs e) {
|
||||||
super.propertyChanged(e);
|
super.propertyChanged(e);
|
||||||
|
@ -77,6 +74,20 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
|
||||||
Object newValue = changeData.getNewValue();//新值
|
Object newValue = changeData.getNewValue();//新值
|
||||||
Object oldValue = changeData.getOldValue();//旧值
|
Object oldValue = changeData.getOldValue();//旧值
|
||||||
if (newValue == null || !newValue.equals(oldValue)) {
|
if (newValue == null || !newValue.equals(oldValue)) {
|
||||||
|
// // 消息模板#{x}为超链接占位符,格式如“保存成功,#{0},单据详情,#{1}”
|
||||||
|
// String tempMsg = "更改采购申请单将自动清单入库单明细,您确定更改吗?";
|
||||||
|
// List<MessageBoxLink> msglinks = new ArrayList<MessageBoxLink>();
|
||||||
|
// // 消息框按钮类型
|
||||||
|
// MessageBoxOptions options = MessageBoxOptions.OKCancel;
|
||||||
|
// // 确认提示类型
|
||||||
|
// ConfirmTypes confirmTypes = ConfirmTypes.Default;
|
||||||
|
// // 确认框回调
|
||||||
|
// ConfirmCallBackListener callBack = new ConfirmCallBackListener("CALLBACKID_DEMO2", this);
|
||||||
|
// // 按钮名称
|
||||||
|
// Map<Integer, String> btnNameMaps = new HashMap<Integer, String>();
|
||||||
|
// btnNameMaps.put(2, "按钮名称2");
|
||||||
|
// btnNameMaps.put(6, "按钮名称6");
|
||||||
|
// this.getView().showConfirm(tempMsg, msglinks, options, confirmTypes, callBack, btnNameMaps);
|
||||||
DynamicObjectCollection entryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//入库单分录
|
DynamicObjectCollection entryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//入库单分录
|
||||||
entryCollection.clear();
|
entryCollection.clear();
|
||||||
this.getView().updateView("entryentity");//刷新分录
|
this.getView().updateView("entryentity");//刷新分录
|
||||||
|
@ -126,16 +137,6 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
|
||||||
DynamicObject zcgj_reqperson = (DynamicObject) newValue;//物资申请人
|
DynamicObject zcgj_reqperson = (DynamicObject) newValue;//物资申请人
|
||||||
long mainOrgID = UserServiceHelper.getUserMainOrgId((Long) zcgj_reqperson.getPkValue());//获取用户默认部门id
|
long mainOrgID = UserServiceHelper.getUserMainOrgId((Long) zcgj_reqperson.getPkValue());//获取用户默认部门id
|
||||||
this.getModel().setValue("zcgj_applidepart", mainOrgID);//申请人部门
|
this.getModel().setValue("zcgj_applidepart", mainOrgID);//申请人部门
|
||||||
} else if ("totaloftaxamount".equals(key) || "taxamount".equals(key)) {
|
|
||||||
//入库含税总金额,税额
|
|
||||||
if ("taxamount".equals(key)) {
|
|
||||||
//税额
|
|
||||||
Boolean adjustamount = (Boolean) this.getModel().getValue("adjustamount");//微调金额
|
|
||||||
if (!adjustamount) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setNewExpenseSummary();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,110 +279,4 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
|
||||||
this.getView().showForm(formShowParameter);
|
this.getView().showForm(formShowParameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNewExpenseSummary() {
|
|
||||||
DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//入库单分录
|
|
||||||
DynamicObjectCollection expenseSummaryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_expensesummary");//费用汇总分录
|
|
||||||
expenseSummaryCollection.clear();
|
|
||||||
DynamicObjectType expenseSummaryType = expenseSummaryCollection.getDynamicObjectType();
|
|
||||||
for (DynamicObject entryEntity : entryEntityCollection) {
|
|
||||||
DynamicObject newExpenseSummaryEntity = new DynamicObject(expenseSummaryType);
|
|
||||||
newExpenseSummaryEntity.set("zcgj_pa_amount", entryEntity.get("oftaxamount"));//价税合计-含税金额
|
|
||||||
newExpenseSummaryEntity.set("zcgj_amountnotax", entryEntity.get("notaxamount"));//不含税金额-金额
|
|
||||||
DynamicObject entryTaxRate = entryEntity.getDynamicObject("entrytaxrate");//税率名称
|
|
||||||
if (entryTaxRate != null) {
|
|
||||||
newExpenseSummaryEntity.set("zcgj_rateval", entryTaxRate.get("taxrate"));//税率(%)-税率名称(值
|
|
||||||
}
|
|
||||||
newExpenseSummaryEntity.set("zcgj_taxamt", entryEntity.get("taxamount"));//税额-税额
|
|
||||||
|
|
||||||
DynamicObject expenseItem = null;
|
|
||||||
DynamicObject material = entryEntity.getDynamicObject("material");//入库单分录-资源编码
|
|
||||||
if (material != null) {
|
|
||||||
DynamicObject resource = material.getDynamicObject("resource");//入库单分录-资源编码-清单分类
|
|
||||||
if (resource != null) {
|
|
||||||
String resourceNumber = resource.getString("number");//资源编码-清单分类-编码
|
|
||||||
DynamicObject ecbd_resource = BusinessDataServiceHelper.loadSingle("ecbd_resource",
|
|
||||||
"id,zcgj_expenseitem", new QFilter[]{new QFilter("number", QCP.equals, resourceNumber)});//清单分类
|
|
||||||
expenseItem = ecbd_resource.getDynamicObject("zcgj_expenseitem");//费用项目
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newExpenseSummaryEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目
|
|
||||||
|
|
||||||
expenseSummaryCollection.add(newExpenseSummaryEntity);
|
|
||||||
}
|
|
||||||
mergeExpenseSummaryEntriesByExpenseItemAndRate(expenseSummaryCollection);
|
|
||||||
this.getView().updateView("zcgj_expensesummary");//刷新分录
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 按费用项目和税率组合合并费用汇总条目
|
|
||||||
*
|
|
||||||
* @param expenseSummaryCollection 费用汇总集合
|
|
||||||
*/
|
|
||||||
private void mergeExpenseSummaryEntriesByExpenseItemAndRate(DynamicObjectCollection expenseSummaryCollection) {
|
|
||||||
// 使用Map来存储已存在的费用项目+税率组合,避免嵌套循环
|
|
||||||
Map<String, DynamicObject> expenseItemRateMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < expenseSummaryCollection.size(); i++) {
|
|
||||||
DynamicObject currentEntry = expenseSummaryCollection.get(i);
|
|
||||||
Object currentExpenseItem = currentEntry.get("zcgj_expenseitem"); // 费用项目
|
|
||||||
Object currentRate = currentEntry.get("zcgj_rateval"); // 税率
|
|
||||||
|
|
||||||
// 创建唯一键值:费用项目ID + 税率值
|
|
||||||
String key = (currentExpenseItem != null ? currentExpenseItem.toString() : "null") +
|
|
||||||
"_" +
|
|
||||||
(currentRate != null ? currentRate.toString() : "null");
|
|
||||||
|
|
||||||
if (expenseItemRateMap.containsKey(key)) {
|
|
||||||
// 如果已存在相同组合,则合并数值
|
|
||||||
DynamicObject existingEntry = expenseItemRateMap.get(key);
|
|
||||||
|
|
||||||
// 合并价税合计
|
|
||||||
BigDecimal currentAmount = toBigDecimal(existingEntry.get("zcgj_pa_amount"));
|
|
||||||
BigDecimal nextAmount = toBigDecimal(currentEntry.get("zcgj_pa_amount"));
|
|
||||||
existingEntry.set("zcgj_pa_amount", currentAmount.add(nextAmount));
|
|
||||||
|
|
||||||
// 合并不含税金额
|
|
||||||
BigDecimal currentAmountNoTax = toBigDecimal(existingEntry.get("zcgj_amountnotax"));
|
|
||||||
BigDecimal nextAmountNoTax = toBigDecimal(currentEntry.get("zcgj_amountnotax"));
|
|
||||||
existingEntry.set("zcgj_amountnotax", currentAmountNoTax.add(nextAmountNoTax));
|
|
||||||
|
|
||||||
// 合并税额
|
|
||||||
BigDecimal currentTaxAmt = toBigDecimal(existingEntry.get("zcgj_taxamt"));
|
|
||||||
BigDecimal nextTaxAmt = toBigDecimal(currentEntry.get("zcgj_taxamt"));
|
|
||||||
existingEntry.set("zcgj_taxamt", currentTaxAmt.add(nextTaxAmt));
|
|
||||||
|
|
||||||
// 移除当前条目
|
|
||||||
expenseSummaryCollection.remove(i);
|
|
||||||
i--; // 调整索引
|
|
||||||
} else {
|
|
||||||
// 如果不存在相同组合,则添加到Map中
|
|
||||||
expenseItemRateMap.put(key, currentEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将对象转换为BigDecimal类型
|
|
||||||
*
|
|
||||||
* @param obj 待转换对象
|
|
||||||
* @return BigDecimal值
|
|
||||||
*/
|
|
||||||
private BigDecimal toBigDecimal(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj instanceof BigDecimal) {
|
|
||||||
return (BigDecimal) obj;
|
|
||||||
} else if (obj instanceof Number) {
|
|
||||||
return new BigDecimal(obj.toString());
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return new BigDecimal(obj.toString());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue