财务共享,我的任务业务单据付款状态校验

This commit is contained in:
zhangzhiguo 2025-05-27 18:13:13 +08:00
parent 93cf520923
commit 7110952a39
2 changed files with 126 additions and 1 deletions

View File

@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import kd.ai.ids.core.utils.JsonUtils;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.form.ShowType;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.BillList;
@ -24,6 +26,7 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.sdk.plugin.Plugin;
import java.util.*;
@ -112,7 +115,8 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
}
this.getView().showForm(listShowParameter);
}
}else if("zcgj_deletevoucher".equals(itemKey)){
}
else if("zcgj_deletevoucher".equals(itemKey)){
BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
//获取到选中行的数据
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
@ -185,6 +189,29 @@ public class TaskListBuildVoucherPlugin extends AbstractListPlugin implements Pl
this.getView().invokeOperation("refresh");//调用表单的刷新操作
}
/*else if("zcgj_bar_payp".equals(itemKey)){
BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
//获取到选中行的数据
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
if(selectedRows.isEmpty()){
this.getView().showTipNotification(String.format("请选择需要付款的数据。"));
return;
}
for (ListSelectedRow selectedRow : selectedRows) {
Long pk = (Long) selectedRow.getPrimaryKeyValue();
DynamicObject taskobj = BusinessDataServiceHelper.loadSingle(pk, "task_task");
DynamicObject billtype = taskobj.getDynamicObject("billtype");
DynamicObject bindbill = billtype.getDynamicObject("bindbill"); //源单
String entityName = bindbill.getString("number");
String billid = taskobj.getString("billid");
OperateOption operateOption = OperateOption.create();
QFilter accountTableFilter = new QFilter("id", QCP.equals,Long.valueOf(billid));
DynamicObject sourceBillObject = BusinessDataServiceHelper.loadSingle(entityName, new QFilter[]{accountTableFilter});
OperationResult opResult= OperationServiceHelper.executeOperate("pushpaybill", entityName, new DynamicObject[] {sourceBillObject},operateOption );
//OperationResult opResult= OperationServiceHelper.executeOperate("pushpaybill", entityName, new DynamicObject[] {sourceBillObject},operateOption );
log.info(opResult.toString());
}
}*/
}
}

View File

@ -0,0 +1,98 @@
package zcgj.zcdev.zcdev.fs.plugin.operate;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.entity.LocaleString;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.datamodel.events.PackageDataEvent;
import kd.bos.entity.list.column.TextColumnDesc;
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.form.control.events.ItemClickEvent;
import kd.bos.form.events.BeforeCreateListColumnsArgs;
import kd.bos.list.ListColumn;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 共享任务中心-我的任务-审批时校验是否完成付款
*/
public class TaskListPayStatusCkOp extends AbstractOperationServicePlugIn {
private static final Log log = LogFactory.getLog(TaskListPayStatusCkOp.class);
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("sscid"); //共享中心
e.getFieldKeys().add("billtype"); //源单类型
e.getFieldKeys().add("billtype.bindbill"); //源单类型
e.getFieldKeys().add("billid"); //源单id
e.getFieldKeys().add("tasktypeid"); //任务类型
e.getFieldKeys().add("billnumber"); //单据编号
e.getFieldKeys().add("subject"); //主题
}
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
Long currentUserId = UserServiceHelper.getCurrentUserId();
// 当前用户所属组织
Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId);
//当前切换选择的组织
Long currentOrgId = RequestContext.get().getOrgId();
//当前所在的组织是属于矿山下的
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();
String billnumber = dataEntity.getString("billnumber");
String subject = dataEntity.getString("subject");
DynamicObject tasktypeid = dataEntity.getDynamicObject("tasktypeid");
DynamicObject sscid = dataEntity.getDynamicObject("sscid");
QFilter tasktypeFilter = new QFilter("orgfield.id", QCP.equals,sscid.getLong("id"));
tasktypeFilter.and(new QFilter("tasklevel", QCP.equals,"2"));
DynamicObject[] tasktypeArray = BusinessDataServiceHelper.load("task_tasktype", "id", new QFilter[]{tasktypeFilter});
if(tasktypeArray != null && tasktypeArray.length > 0){
DynamicObject tasktype = tasktypeArray[0];
if(tasktypeid.getLong("id") == tasktype.getLong("id")) {
long billid = dataEntity.getLong("billid");
DynamicObject billtype = dataEntity.getDynamicObject("billtype"); //源单类型
DynamicObject bindbill = billtype.getDynamicObject("bindbill");//源单
String entityName = bindbill.getString("number");
QFilter accountTableFilter = new QFilter("id", QCP.equals,billid);
DynamicObject sourceBillObject = BusinessDataServiceHelper.loadSingle(entityName, new QFilter[]{accountTableFilter});
String billstatus = sourceBillObject.getString("billstatus");
if(!"G".equals(billstatus)) {
if("er_repaymentbill".equals(entityName)) {
this.addFatalErrorMessage(extendedDataEntity, String.format("审批结算任务:【%s-%s】的收款未完成请完成收款后操作。",billnumber,subject));
}else{
this.addFatalErrorMessage(extendedDataEntity, String.format("审批结算任务:【%s-%s】的付款未完成请完成付款后操作。",billnumber,subject));
}
}
}
}
}
}
}
}