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

This commit is contained in:
xiaoshi 2025-08-11 16:14:42 +08:00
commit 17257439e5
12 changed files with 857 additions and 12 deletions

View File

@ -133,6 +133,7 @@ public class AssistbalanceAutoData {
DynamicObject assistbalance
=BusinessDataServiceHelper.newDynamicObject("zcgj_rpt_assistbalance");
assistbalance.set("zcgj_debitlocal", record.getDebitlocal());
assistbalance.set("zcgj_beginlocal", record.getBeginlocal());
assistbalance.set("zcgj_creditlocal", record.getCreditlocal());
assistbalance.set("zcgj_yeardebitfor", record.getYeardebitfor());
assistbalance.set("zcgj_yearcreditfor", record.getYearcreditfor());

View File

@ -0,0 +1,126 @@
package zcgj.zcdev.zcdev.fs.plugin.operate;
import com.grapecity.documents.excel.B;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.tx.TX;
import kd.bos.db.tx.TXHandle;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.util.StringUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/**
* 付款处理单反写资金计划申请实际付款
*/
public class CasPaybillToEcFundPlanApplyOp extends AbstractOperationServicePlugIn {
private static final Log log = LogFactory.getLog(CasPaybillToEcFundPlanApplyOp.class);
@Override
public void endOperationTransaction(EndOperationTransactionArgs e) {
String operationKey = e.getOperationKey();
DynamicObject[] dataEntities = e.getDataEntities();
switch (operationKey) {
case "pay"://付款
log.info("执行CasPaybillToEcFundPlanApplyOp的付款操作开始更资金计划申请付款类型实付金额");
updateInApplyRealPayAmt(dataEntities, true);
break;
case "unpay"://取消付款
log.info("执行CasPaybillToEcFundPlanApplyOp的取消付款操作开始更资金计划申请付款类型实付金额");
updateInApplyRealPayAmt(dataEntities, false);
break;
}
}
/*public void endOperationTransaction(EndOperationTransactionArgs e) {
}*/
protected void updateInApplyRealPayAmt(DynamicObject[] dataEntities, boolean isPay){
List<DynamicObject> updateData = new ArrayList<>();
for (DynamicObject dataEntity : dataEntities) {
long id = dataEntity.getLong("id");
// idList.add(id);
Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills("cas_paybill", new Long[]{id});
HashSet<Long> zcgjEcFundingplanapply = sourceBills.get("zcgj_ec_fundingplanapply");
if(zcgjEcFundingplanapply != null && !zcgjEcFundingplanapply.isEmpty()) {
Long dataId = (Long)zcgjEcFundingplanapply.toArray()[0];
//计算实际付款金额
DynamicObject paybill = BusinessDataServiceHelper.loadSingle(id, "cas_paybill");
DynamicObject settletype = paybill.getDynamicObject("settletype");
String typeString = "";
if(settletype!=null){
String type = settletype.getString("number");
if("002".equals(type)){ //司库-对公
//现金
typeString = "XJ";
}else if("JSFS07".equals(type)){ //银行承兑汇票
//银行承兑
typeString = "YHCD";
}else if("JSFS06".equals(type)){ //商业承兑汇票
//商业承兑
typeString = "SYCD";
}else if("JSFS26".equals(type)){ //供应链
//供应链
typeString = "GYL";
}else if("JSFS27".equals(type)){ //其他金融产品
//其他金融产品
typeString = "QTJRCP";
}
}
DynamicObjectCollection entryCpllection = paybill.getDynamicObjectCollection("entry");
BigDecimal allActamt = BigDecimal.ZERO;
for (DynamicObject entry : entryCpllection) {
BigDecimal eActamt = entry.getBigDecimal("e_actamt");//获取实付金额
allActamt = allActamt.add(eActamt);
}
//读取资金计划申请
DynamicObject fundingplanapply = BusinessDataServiceHelper.loadSingle(dataId, "zcgj_ec_fundingplanapply");
DynamicObjectCollection zcgjFinApprovedAmount = fundingplanapply.getDynamicObjectCollection("zcgj_fin_approved_amount");
for (DynamicObject dynamicObject : zcgjFinApprovedAmount) {
String zcgjSetttype = dynamicObject.getString("zcgj_setttype");
if(typeString.equals(zcgjSetttype)){
BigDecimal zcgjAmountRecommended = dynamicObject.getBigDecimal("zcgj_amountpaid");//实际付款金额
BigDecimal amountrecommended = BigDecimal.ZERO;
if(!isPay){
amountrecommended = allActamt;
allActamt = allActamt.multiply(BigDecimal.ZERO.subtract(BigDecimal.ONE));//取相反数
}
allActamt = allActamt.add(zcgjAmountRecommended);
dynamicObject.set("zcgj_amountpaid", allActamt);//实付金额
dynamicObject.set("zcgj_amount_inpayment",amountrecommended);//
//zcgj_amount_remaining = zcgj_hdamount - zcgj_amount_inpayment - zcgj_amountpaid
//剩余待拨付金额 = 财务核定金额 - 付款处理中金额 - 实付金额
BigDecimal hdamount = dynamicObject.getBigDecimal("zcgj_hdamount");
if(hdamount !=null && isPay){
BigDecimal subtract = hdamount.subtract(amountrecommended).subtract(allActamt);
dynamicObject.set("zcgj_amount_remaining",subtract);
}else if(hdamount != null){
BigDecimal subtract = hdamount.add(amountrecommended).subtract(allActamt);//实付金额已经成为相反数
dynamicObject.set("zcgj_amount_remaining",subtract);
}
}
}
updateData.add(fundingplanapply);
}
}
if(!updateData.isEmpty()){
try (TXHandle txType = TX.requiresNew("updateAmt")) {
SaveServiceHelper.save(updateData.toArray(new DynamicObject[0]));
}
}
}
}

View File

@ -0,0 +1,85 @@
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.metadata.dynamicobject.DynamicObjectType;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.field.RefBillEdit;
import kd.bos.form.field.events.BeforeF7SelectEvent;
import kd.bos.form.field.events.BeforeF7SelectListener;
import kd.bos.isc.util.misc.StringUtil;
import kd.bos.list.ListShowParameter;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
/**
* 目标成本评审表单插件
* 说明以项目和可用版本过滤工序成本预算字段且将工序成本预算内的字段赋值到项目成本预算分录中
*/
public class AimCostReViewBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
RefBillEdit refBillEdit = getView().getControl("zcgj_aimcostbill");//工序成本预算
refBillEdit.addBeforeF7SelectListener(this);
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String key = e.getProperty().getName();
if (StringUtil.equals(key, "zcgj_aimcostbill")) {
//工序成本预算
ChangeData[] changeSet = e.getChangeSet();
ChangeData changeData = changeSet[0];
DynamicObject aimCostBill = (DynamicObject) changeData.getNewValue();//新值
DynamicObjectCollection costEntryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("costentryentity");//项目成本预算分录
DynamicObjectType costEntryEntityType = costEntryEntityCollection.getDynamicObjectType();
costEntryEntityCollection.clear();
if (aimCostBill != null) {
DynamicObject aimCostBillCbs = BusinessDataServiceHelper.loadSingle(aimCostBill.getPkValue(), "ecco_aimcostbillcbs");//工序成本预算单
if (aimCostBillCbs != null) {
DynamicObject newCostEntryEntity = new DynamicObject(costEntryEntityType);
newCostEntryEntity.set("costbillno", aimCostBillCbs.get("billno"));//单据编号
newCostEntryEntity.set("costbillname", aimCostBillCbs.get("name"));//单据名称
newCostEntryEntity.set("costunitproject", aimCostBillCbs.get("unitproject"));//单位工程/标段
newCostEntryEntity.set("budcost", aimCostBillCbs.get("totalamount"));//预算成本金额
newCostEntryEntity.set("costexecutable", aimCostBillCbs.get("isenable"));//执行版本
newCostEntryEntity.set("costversion", aimCostBillCbs.get("versionno"));//版本号
newCostEntryEntity.set("costfrom", "CBS");//数据来源
newCostEntryEntity.set("costfromid", aimCostBillCbs.get("id"));//数据id
costEntryEntityCollection.add(newCostEntryEntity);
}
}
this.getView().updateView("costentryentity");//刷新项目成本预算分录
} else if (StringUtil.equals(key, "project")) {
ChangeData[] changeSet = e.getChangeSet();
ChangeData changeData = changeSet[0];
Object newValue = changeData.getNewValue();//新值
if (newValue == null) {
this.getModel().setValue("zcgj_aimcostbill", null);
}
}
}
@Override
public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
List<QFilter> qFilter = new ArrayList<>();
DynamicObject project = (DynamicObject) this.getModel().getValue("project");//项目
if (project != null) {
qFilter.add(new QFilter("project", "=", project.getPkValue()));
qFilter.add(new QFilter("isenable", "=", true));
} else {
qFilter.add(new QFilter("project", "=", 1234567890));
}
formShowParameter.getListFilterParameter().setQFilters(qFilter);
}
}

View File

@ -11,7 +11,10 @@ import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.math.BigDecimal;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;
/*
* 使用插件注册位置支出合同结算表单插件
@ -57,11 +60,12 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明
processAllocEntityCollection.add(newProcessAllocEntity);
}
}
}
// 添加合并逻辑按工序和税率组合合并相同项
mergeProcessAllocEntriesByProcessAndRate(processAllocEntityCollection);
}
this.getView().updateView("zcgj_processallocatentity");//工序分摊
} else {
@ -124,14 +128,87 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明
processAllocEntityCollection.add(newProcessAllocEntity);
}
}
}
}
}
// 添加合并逻辑按工序和税率组合合并相同项
mergeProcessAllocEntriesByProcessAndRate(processAllocEntityCollection);
this.getView().updateView("zcgj_processallocatentity");//工序分摊
}
}
/**
* 按工序和税率组合合并工序分摊条目
*
* @param processAllocEntityCollection 工序分摊集合
*/
private void mergeProcessAllocEntriesByProcessAndRate(DynamicObjectCollection processAllocEntityCollection) {
// 使用Map来存储已存在的工序+税率组合避免嵌套循环
Map<String, DynamicObject> processRateMap = new HashMap<>();
for (int i = 0; i < processAllocEntityCollection.size(); i++) {
DynamicObject currentEntry = processAllocEntityCollection.get(i);
Object currentProcess = currentEntry.get("zcgj_pa_process"); // 工序
Object currentRate = currentEntry.get("zcgj_rateval"); // 税率
// 创建唯一键值工序ID + 税率值
String key = (currentProcess != null ? currentProcess.toString() : "null") +
"_" +
(currentRate != null ? currentRate.toString() : "null");
if (processRateMap.containsKey(key)) {
// 如果已存在相同组合则合并数值
DynamicObject existingEntry = processRateMap.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));
// 移除当前条目
processAllocEntityCollection.remove(i);
i--; // 调整索引
} else {
// 如果不存在相同组合则添加到Map中
processRateMap.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;
}
}
}
}

View File

@ -0,0 +1,133 @@
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.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.field.BasedataEdit;
import kd.bos.form.field.events.BeforeF7SelectEvent;
import kd.bos.form.field.events.BeforeF7SelectListener;
import kd.bos.isc.util.misc.StringUtil;
import kd.bos.list.ListShowParameter;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
/*
* 设备命令单表单插件
* 说明1设备编码带出资产编码2:过滤设备编码字段3调出调入项目带出调出调入负责人
*/
public class EquipmentCommandBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
BasedataEdit realCard = this.getControl("zcgj_realcard"); //设备编码
realCard.addBeforeF7SelectListener(this);
BasedataEdit outProject = this.getControl("zcgj_outproject"); //调出项目
outProject.addBeforeF7SelectListener(this);
BasedataEdit inProject = this.getControl("zcgj_inproject"); //调入项目
inProject.addBeforeF7SelectListener(this);
// BasedataEdit outUser = this.getControl("zcgj_outuser"); //调出负责人
// outUser.addBeforeF7SelectListener(this);
// BasedataEdit inUser = this.getControl("zcgj_inuser"); //调入负责人
// inUser.addBeforeF7SelectListener(this);
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String key = e.getProperty().getName();
if (StringUtil.equals(key, "zcgj_realcard")) {
//设备编码
ChangeData[] changeSet = e.getChangeSet();
ChangeData changeData = changeSet[0];
int rowIndex = changeData.getRowIndex();
DynamicObject realCard = (DynamicObject) changeData.getNewValue();//新值
if (realCard != null) {
String realCardNumber = realCard.getString("number");//设备编码-设备编码
DynamicObject org = (DynamicObject) realCard.get("org");//管理组织
QFilter[] qFilters = new QFilter[]{new QFilter("number", QCP.equals, realCardNumber).and("org.id", QCP.equals, org.get("id"))};
DynamicObject fa_card_real_base = BusinessDataServiceHelper.loadSingle("fa_card_real_base", "id", qFilters);//实物卡片基础资料
this.getModel().setValue("zcgj_realcardsw", fa_card_real_base, rowIndex);//资产编码
} else {
this.getModel().setValue("zcgj_realcardsw", null, rowIndex);//资产编码
}
} else if (StringUtil.equals(key, "zcgj_outorg") || StringUtil.equals(key, "zcgj_inorg")) {
//调出组织调入组织
ChangeData[] changeSet = e.getChangeSet();
ChangeData changeData = changeSet[0];
Object newValue = changeData.getNewValue();//新值
Object oldValue = changeData.getOldValue();//旧值
if (newValue == null || !newValue.equals(oldValue)) {
if (StringUtil.equals(key, "zcgj_outorg")) {
//调出组织
DynamicObjectCollection dispatchEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_dispatchentry");//调出资产详情分录
dispatchEntryCollection.clear();
this.getView().updateView("zcgj_dispatchentry");//刷新分录
this.getModel().setValue("zcgj_outproject", null);//清空调出项目
} else {
//调入组织
this.getModel().setValue("zcgj_inproject", null);//清空调入项目
}
}
} else if (StringUtil.equals(key, "zcgj_outproject") || StringUtil.equals(key, "zcgj_inproject")) {
//调出项目调入项目
ChangeData[] changeSet = e.getChangeSet();
ChangeData changeData = changeSet[0];
Object newValue = changeData.getNewValue();//新值
if (newValue != null) {
DynamicObject newValueDy = (DynamicObject) newValue;
QFilter[] qFilters = new QFilter[]{new QFilter("billno", QCP.equals, newValueDy.getString("number"))};
DynamicObject ec_project = BusinessDataServiceHelper.loadSingle("ec_project", "id,zcgj_pm", qFilters);//项目
if (ec_project != null) {
if (StringUtil.equals(key, "zcgj_outproject")) {
//调出项目
this.getModel().setValue("zcgj_outuser", ec_project.get("zcgj_pm"));//调出负责人
} else {
this.getModel().setValue("zcgj_inuser", ec_project.get("zcgj_pm"));//调出负责人
}
}
}
}
}
@Override
public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
String propertyName = beforeF7SelectEvent.getProperty().getName();
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
List<QFilter> qFilter = new ArrayList<>();
if (StringUtil.equals(propertyName, "zcgj_realcard") || StringUtil.equals(propertyName, "zcgj_outproject")) {
//设备编码调出项目
Object outOrg = this.getModel().getValue("zcgj_outorg");//调出组织
if (outOrg == null) {
this.getView().showErrorNotification("请先填写调出组织!");
beforeF7SelectEvent.setCancel(true);
return;
}
DynamicObject outOrgDy = (DynamicObject) outOrg;
if (StringUtil.equals(propertyName, "zcgj_realcard")) {
//设备编码
qFilter.add(new QFilter("org.id", "=", outOrgDy.get("id")));
} else {
//调出项目
qFilter.add(new QFilter("fiaccountorg.id", "=", outOrgDy.get("id")));
}
} else if (StringUtil.equals(propertyName, "zcgj_inproject")) {
//调入项目
Object inOrg = this.getModel().getValue("zcgj_inorg");//调入组织
if (inOrg == null) {
this.getView().showErrorNotification("请先填写调入组织!");
beforeF7SelectEvent.setCancel(true);
return;
}
DynamicObject inOrgDy = (DynamicObject) inOrg;
qFilter.add(new QFilter("fiaccountorg.id", "=", inOrgDy.get("id")));
}
formShowParameter.getListFilterParameter().setQFilters(qFilter);
}
}

View File

@ -6,6 +6,7 @@ import kd.bos.bill.OperationStatus;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.entity.MulBasedataDynamicObjectCollection;
import kd.bos.entity.datamodel.events.BizDataEventArgs;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
@ -40,22 +41,82 @@ public class FundingplanapplyPlugin extends AbstractBillPlugIn implements Plugin
//设置期间
DynamicObject org = (DynamicObject) this.getModel().getValue("zcgj_org");
if(org!=null){
//查询组织下对应的当前期间数据
/*//查询组织下对应的当前期间数据
DynamicObject[] orgByCurperiod = BusinessDataServiceHelper.load("gl_accountbook",
"org,curperiod",
new QFilter[]{new QFilter("enable", QCP.equals, Boolean.TRUE).
and("status", QCP.equals, "C").and("org.id", QCP.equals, org.getLong("id"))});
if(orgByCurperiod!=null && orgByCurperiod.length>0){
this.getModel().setValue("zcgj_period",orgByCurperiod[0].getDynamicObject("curperiod"));
}
}*/
//设置期间
carryCurrentPeriodAndDate();
//初始化值
initData(org);
}
}
}
/**
* 自动带入 今年最新的 年初应收余额年初应付余额
*/
public void initData(DynamicObject org){
int year = LocalDate.now().getYear();
List<QFilter> searchFilterList = new ArrayList<>();
//查询申请人下的今年的探亲差旅单据
searchFilterList.add(new QFilter("zcgj_org", QCP.equals, org.getLong("id")));
searchFilterList.add( new QFilter("zcgj_period.number", QCP.like, year+"%"));
DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_ec_fundingplanapply",
"zcgj_period," +
"zcgj_infundproject_entry.zcgj_in_fundproject,zcgj_infundproject_entry.zcgj_in_custom,zcgj_infundproject_entry.zcgj_iinitialreceivable " +
",zcgj_outfundproject_entry.zcgj_out_fundproject,zcgj_outfundproject_entry.zcgj_out_supplier,zcgj_outfundproject_entry.zcgj_openingpayable" +
",createtime",
searchFilterList.toArray(new QFilter[]{}), "createtime desc");
if(load!=null && load.length>0){
DynamicObject data = load[0];
DynamicObjectCollection indataentry = data.getDynamicObjectCollection("zcgj_infundproject_entry");
DynamicObjectCollection inentry = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_infundproject_entry");
inentry.clear();
for (DynamicObject dynamicObject : indataentry) {
DynamicObject newData = inentry.addNew();
newData.set("zcgj_in_fundproject",dynamicObject.get("zcgj_in_fundproject"));
DynamicObjectCollection collection = new DynamicObjectCollection();
for (DynamicObject zcgjInCustom :dynamicObject.getDynamicObjectCollection("zcgj_in_custom")) {
DynamicObject basedataObj = zcgjInCustom.getDynamicObject("fbasedataid");
DynamicObject newObj = new DynamicObject(newData.getDynamicObjectCollection("zcgj_in_custom").getDynamicObjectType());
newObj.set("fbasedataid", basedataObj);
newObj.set("fbasedataid_id", basedataObj.getPkValue());
collection.add(newObj);
}
newData.set("zcgj_in_custom",collection);
newData.set("zcgj_iinitialreceivable",dynamicObject.get("zcgj_iinitialreceivable"));
}
this.getView().updateView("zcgj_infundproject_entry");
DynamicObjectCollection outdataentry = data.getDynamicObjectCollection("zcgj_outfundproject_entry");
DynamicObjectCollection outentry = this.getModel().getDataEntity().getDynamicObjectCollection("zcgj_outfundproject_entry");
outentry.clear();
for (DynamicObject dynamicObject : outdataentry) {
DynamicObject newData = outentry.addNew();
newData.set("zcgj_out_fundproject",dynamicObject.get("zcgj_out_fundproject"));
DynamicObjectCollection collection = new DynamicObjectCollection();
for (DynamicObject zcgjInCustom : (MulBasedataDynamicObjectCollection) dynamicObject.get("zcgj_out_supplier")) {
DynamicObject basedataObj = zcgjInCustom.getDynamicObject("fbasedataid");
DynamicObject newObj = new DynamicObject(newData.getDynamicObjectCollection("zcgj_out_supplier").getDynamicObjectType());
newObj.set("fbasedataid", basedataObj);
newObj.set("fbasedataid_id", basedataObj.getPkValue());
collection.add(newObj);
}
newData.set("zcgj_out_supplier",collection);
newData.set("zcgj_openingpayable",dynamicObject.get("zcgj_openingpayable"));
}
this.getView().updateView("zcgj_outfundproject_entry");
}
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
@ -81,6 +142,35 @@ public class FundingplanapplyPlugin extends AbstractBillPlugIn implements Plugin
this.getView().updateView("zcgj_setttype",rowIndex);
}
}
}else if(name.equals("zcgj_org")){
DynamicObject org = (DynamicObject) changeData.getNewValue();
initData(org);
}
}
// 获取某年份的第一天
public static LocalDate getFirstDayOfYear(int year) {
return LocalDate.of(year, 1, 1);
}
// 获取某年份的最后一天
public static LocalDate getLastDayOfYear(int year) {
return LocalDate.of(year, 12, 31);
}
protected void carryCurrentPeriodAndDate() {
Calendar cal = Calendar.getInstance();
int year = cal.get(1);
int month = cal.get(2) + 1;
QFilter yearFilter = new QFilter("periodyear", "=", year);
QFilter monthFilter = new QFilter("periodnumber", "=", month);
DynamicObject bdPeriod = BusinessDataServiceHelper.loadSingle("bd_period", "id,name,begindate,enddate", new QFilter[]{yearFilter, monthFilter});
if (bdPeriod != null) {
this.getModel().setValue("zcgj_period", bdPeriod.getPkValue());
//this.getModel().setValue("begindate", bdPeriod.get("begindate"));
// this.getModel().setValue("enddate", bdPeriod.get("enddate"));
}
}
}

View File

@ -0,0 +1,79 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.field.BasedataEdit;
import kd.bos.form.field.RefBillEdit;
import kd.bos.form.field.events.BeforeF7SelectEvent;
import kd.bos.form.field.events.BeforeF7SelectListener;
import kd.bos.isc.util.misc.StringUtil;
import kd.bos.list.ListShowParameter;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
/**
* 工序期间成本预算表单插件
* 说明通过项目与期间带出工序成本预算字段内容
**/
public class PeriodCostBillCbsPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
RefBillEdit refBillEdit = getView().getControl("zcgj_aimcostbill");//工序成本预算
refBillEdit.addBeforeF7SelectListener(this);
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String key = e.getProperty().getName();
if (StringUtil.equals(key, "project") || StringUtil.equals(key, "period")) {
//项目期间
DynamicObject project = (DynamicObject) this.getModel().getValue("project");//项目
DynamicObject period = (DynamicObject) this.getModel().getValue("period");//期间
if (project != null && period != null) {
int periodYear = (int) period.get("periodyear");//期间-年度
String periodValue = String.valueOf(periodYear - 2024);
QFilter filter = new QFilter("project", "=", project.getPkValue());
filter.and(new QFilter("zcgj_periodyear", "=", periodValue));
filter.and(new QFilter("isenable", "=", true));
DynamicObject ecco_aimcostbillcbs = BusinessDataServiceHelper.loadSingle("ecco_aimcostbillcbs", "id", new QFilter[]{filter});//工序成本预算
this.getModel().setValue("zcgj_aimcostbill", ecco_aimcostbillcbs);
} else {
this.getModel().setValue("zcgj_aimcostbill", null);
}
}
}
@Override
public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
List<QFilter> qFilter = new ArrayList<>();
DynamicObject project = (DynamicObject) this.getModel().getValue("project");//项目
DynamicObject period = (DynamicObject) this.getModel().getValue("period");//期间
if (project != null && period != null) {
int periodYear = (int) period.get("periodyear");//期间-年度
String periodValue = String.valueOf(periodYear - 2024);
QFilter filter = new QFilter("project", "=", project.getPkValue());
filter.and(new QFilter("zcgj_periodyear", "=", periodValue));
filter.and(new QFilter("isenable", "=", true));
DynamicObject ecco_aimcostbillcbs = BusinessDataServiceHelper.loadSingle("ecco_aimcostbillcbs", "id", new QFilter[]{filter});//工序成本预算
if (ecco_aimcostbillcbs != null) {
qFilter.add(new QFilter("id", QCP.equals, ecco_aimcostbillcbs.get("id")));
} else {
qFilter.add(new QFilter("id", QCP.equals, 123456));
}
} else {
qFilter.add(new QFilter("id", QCP.equals, 123456));
}
formShowParameter.getListFilterParameter().setQFilters(qFilter);
}
}

View File

@ -1,4 +1,4 @@
package zcgj.zcdev.zcdev.pr.plugin;
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.ExtendedDataEntity;
@ -12,7 +12,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.math.BigDecimal;
//工序成本预算单保存提交操作插件验证项目和年份的组合是否已经存在且只有一个
public class AimcostcbsBllSubmitOp extends AbstractOperationServicePlugIn {
public class AimCostCbsBllSaveOrSubOp extends AbstractOperationServicePlugIn {
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
@ -25,7 +25,7 @@ public class AimcostcbsBllSubmitOp extends AbstractOperationServicePlugIn {
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
e.getValidators().add(new ValidatorExt());
e.getValidators().add(new AimCostCbsBllSaveOrSubOp.ValidatorExt());
}
class ValidatorExt extends AbstractValidator {

View File

@ -0,0 +1,148 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package zcgj.zcdev.zcdev.pr.plugin.operate;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.BeforeOperationArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.ec.eceq.common.enums.EquipmentUseStatusEnum;
import kd.ec.eceq.common.enums.UseStatusEnum;
import kd.ec.eceq.opplugin.EquipmentHelper;
import kd.ec.eceq.opplugin.validator.EquipExitValidator;
/**
* 设备退场审核反审核操作按钮
* 说明去除不存在设备进厂逻辑
*/
public class EquipmentExitOpExt extends AbstractOperationServicePlugIn {
public EquipmentExitOpExt() {
}
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("exitdate");
e.getFieldKeys().add("entryentity");
e.getFieldKeys().add("equipmentid");
e.getFieldKeys().add("equipsnapshot_tag");
e.getFieldKeys().add("approachrow");
e.getFieldKeys().add("approachid");
}
public void onAddValidators(AddValidatorsEventArgs e) {
e.addValidator(new EquipExitValidator());
}
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
switch (e.getOperationKey()) {
case "audit":
this.doAudit(e);
break;
case "unaudit":
this.doUnAudit(e);
}
}
protected void doAudit(BeforeOperationArgs e) {
DynamicObject[] dataEntities = e.getDataEntities();
if (dataEntities.length > 0) {
DynamicObject[] var3 = dataEntities;
int var4 = dataEntities.length;
for(int var5 = 0; var5 < var4; ++var5) {
DynamicObject entity = var3[var5];
Date exitDate = entity.getDate("exitdate");
DynamicObjectCollection entry = entity.getDynamicObjectCollection("entryentity");
ArrayList<DynamicObject> updateList = new ArrayList();
ArrayList<DynamicObject> updateApproachList = new ArrayList();
Iterator var11 = entry.iterator();
while(var11.hasNext()) {
DynamicObject row = (DynamicObject)var11.next();
long approachRowId = row.getLong("approachrow");
if (approachRowId == 0L){
return;
}
DynamicObject approachEquip = BusinessDataServiceHelper.loadSingle(approachRowId, "eceq_approachequipf7");
boolean isExit = approachEquip.getBoolean("isexit");
if (!isExit) {
approachEquip.set("isexit", true);
approachEquip.set("exitdate", exitDate);
updateApproachList.add(approachEquip);
DynamicObject equipment = row.getDynamicObject("equipmentid");
if (equipment != null) {
JSONObject snapshot = EquipmentHelper.generateSnapshot(equipment);
row.set("equipsnapshot_tag", snapshot.toJSONString());
String property = equipment.getString("property");
equipment.set("equipstatus", EquipmentUseStatusEnum.FREE.getValue());
equipment.set("usestatus", UseStatusEnum.EXITED.getValue());
equipment.set("project", (Object)null);
equipment.set("useorg", (Object)null);
equipment.set("approachdate", (Object)null);
equipment.set("exitdate", exitDate);
updateList.add(equipment);
}
}
}
SaveServiceHelper.update((DynamicObject[])updateList.toArray(new DynamicObject[0]));
SaveServiceHelper.update((DynamicObject[])updateApproachList.toArray(new DynamicObject[0]));
}
}
}
protected void doUnAudit(BeforeOperationArgs e) {
DynamicObject[] dataEntities = e.getDataEntities();
if (dataEntities.length > 0) {
DynamicObject[] var3 = dataEntities;
int var4 = dataEntities.length;
for(int var5 = 0; var5 < var4; ++var5) {
DynamicObject entity = var3[var5];
DynamicObjectCollection entry = entity.getDynamicObjectCollection("entryentity");
ArrayList<DynamicObject> updateList = new ArrayList();
ArrayList<DynamicObject> updateApproachList = new ArrayList();
Iterator var10 = entry.iterator();
while(var10.hasNext()) {
DynamicObject row = (DynamicObject)var10.next();
long approachRowId = row.getLong("approachrow");
if (approachRowId == 0L){
return;
}
DynamicObject approachEquip = BusinessDataServiceHelper.loadSingle(approachRowId, "eceq_approachequipf7");
boolean isExit = approachEquip.getBoolean("isexit");
if (isExit) {
approachEquip.set("isexit", false);
approachEquip.set("exitdate", (Object)null);
updateApproachList.add(approachEquip);
DynamicObject equipment = row.getDynamicObject("equipmentid");
if (equipment != null) {
String equipSnapshotJsonStr = row.getString("equipsnapshot_tag");
JSONObject snapshot = JSONObject.parseObject(equipSnapshotJsonStr);
EquipmentHelper.recoverBySnapshot(equipment, snapshot);
updateList.add(equipment);
}
}
}
SaveServiceHelper.update((DynamicObject[])updateList.toArray(new DynamicObject[0]));
SaveServiceHelper.update((DynamicObject[])updateApproachList.toArray(new DynamicObject[0]));
}
}
}
}

View File

@ -0,0 +1,51 @@
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
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.validate.AbstractValidator;
import java.util.HashSet;
import java.util.Set;
public class FundingplanapplyOp extends AbstractOperationServicePlugIn {
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
e.getFieldKeys().add("zcgj_fin_approved_amount");
}
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
//当前所在的组织是属于矿山下的
e.getValidators().add(new ValidatorExt());
}
class ValidatorExt extends AbstractValidator {
@Override
public void validate() {
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
DynamicObjectCollection finApprovedAmount = dataEntity.getDynamicObjectCollection("zcgj_fin_approved_amount");
if (!finApprovedAmount.isEmpty()) {
Set<String> typeSet = new HashSet<>();
for (DynamicObject dynamicObject : finApprovedAmount) {
String sSetttype = dynamicObject.getString("zcgj_setttype");
if(typeSet.contains(sSetttype)) {
this.addFatalErrorMessage(extendedDataEntity, "财务部核定金额的结算方式不允许重复!");
return;
}else{
typeSet.add(sSetttype);
}
}
}
}
}
}
}

View File

@ -0,0 +1,56 @@
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
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.validate.AbstractValidator;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.math.BigDecimal;
/**
* 工序期间成本预算保存提交操作插件;
* 说明校验项目加期间加版本的组合是否存在存在便提示不可重复创建
*/
public class PeriodCostBSaveOrSubOp extends AbstractOperationServicePlugIn {
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("period");//期间
e.getFieldKeys().add("project");//项目
e.getFieldKeys().add("versionno");//版本号
}
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
e.getValidators().add(new PeriodCostBSaveOrSubOp.ValidatorExt());
}
class ValidatorExt extends AbstractValidator {
@Override
public void validate() {
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
DynamicObject extendedData = extendedDataEntity.getDataEntity();
DynamicObject project = extendedData.getDynamicObject("project");//项目
DynamicObject period = extendedData.getDynamicObject("period");//期间
BigDecimal versionNo = extendedData.getBigDecimal("versionno");//版本号
QFilter filter = new QFilter("project", "=", project.getPkValue());
filter.and(new QFilter("period", "=", period.getPkValue()));
filter.and(new QFilter("versionno", "=", versionNo));
DynamicObject ecco_periodcostbillcbs = BusinessDataServiceHelper.loadSingle("ecco_periodcostbillcbs", "id", new QFilter[]{filter});
if (ecco_periodcostbillcbs != null) {
if (extendedData.getPkValue().equals(ecco_periodcostbillcbs.getPkValue())){
continue;
}
this.addFatalErrorMessage(extendedDataEntity, "该期间的项目已编制预算,请勿重复创建!");
}
}
}
}
}

View File

@ -49,7 +49,6 @@ public class OutContractSettleFiConfirmWorkFlowPlugin implements IWorkflowPlugin
outFinaceconfirm.set("zcgj_invoice_org",outContractSettle.getDynamicObject("project").getDynamicObject("projectorg"));
outFinaceconfirm.set("zcgj_jscustomer",outContractSettle.getDynamicObject("zcgj_jscustomer"));
outFinaceconfirm.set("billstatus","A");
outFinaceconfirm.set("zcgj_is_reversabillid",true);
outFinaceconfirm.set("creator",outContractSettle.getDynamicObject("creator"));
DynamicObjectCollection itementry = outContractSettle.getDynamicObjectCollection("itementry");