付款会计科目过滤

This commit is contained in:
程小伟 2025-04-02 14:29:19 +08:00
parent 785132b439
commit 57bf81ab2f
8 changed files with 481 additions and 3 deletions

View File

@ -43,7 +43,6 @@ public class PayBillFilterPlugin extends AbstractBillPlugIn implements Plugin, B
.or(new QFilter("number", QCP.like,"2241%"))//其他应付账款
.or(new QFilter("number", QCP.like,"1123%"))//预付账款
.or(new QFilter("number", QCP.in,list)));*/
QFilter f1 = new QFilter("number", QCP.like, "2202%");
QFilter f2 = new QFilter("number", QCP.like, "2241%");
QFilter f3 = new QFilter("number", QCP.like, "1123%");
@ -53,6 +52,7 @@ public class PayBillFilterPlugin extends AbstractBillPlugIn implements Plugin, B
qFilterList.add(numberFilter);
qFilterList.add(new QFilter("isleaf", QCP.equals,true));
arg0.setCustomQFilters(qFilterList);//设置F7选择框的筛选条件
}

View File

@ -30,8 +30,6 @@ public class ProjectEditExtUI extends ProjectEditUI {
data = args.getChangeSet()[0];
String unitProjectName = (String) data.getNewValue();
// setUnitProMustInput(unitProjectName);
}
Object projectorg = this.getModel().getValue("projectorg");

View File

@ -0,0 +1,40 @@
package zcgj.zcdev.zcdev.pr.plugin.form.demo;
import kd.bos.form.control.Control;
import kd.bos.form.control.EntryGrid;
import kd.bos.form.control.Toolbar;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.sdk.plugin.Plugin;
import kd.bos.bill.AbstractBillPlugIn;
import java.util.EventObject;
public class CheckmaterialPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void registerListener(EventObject e) {
Toolbar tb = this.getControl("advcontoolbarap");
tb.addItemClickListener(this);//监听单据体的工具栏
super.registerListener(e);
}
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
if("zcgj_advconbaritemap".equals(evt.getItemKey())){
EntryGrid entryGrid = this.getView().getControl("entryentity");//获取单据体构件
int[] selectRows = entryGrid.getSelectRows();//获取选中的行号
StringBuilder sb = new StringBuilder();
for(int i = 0 ; i < selectRows.length ; i++){
Object material = this.getModel().getValue("zcgj_materiel", selectRows[i]);//获取指定行物料基础资料内容
if(material == null){//如果物料为空添加提示信息
sb.append(selectRows[i]+1).append(",");
}
}
if(sb.length() > 0){
sb.deleteCharAt(sb.length()-1);
this.getView().showErrorNotification(""+sb.toString()+"行物料不能为空");
}
}
super.beforeItemClick(evt);
}
}

View File

@ -0,0 +1,205 @@
package zcgj.zcdev.zcdev.pr.plugin.form.demo;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.bill.BillShowParameter;
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.entity.operate.Save;
import kd.bos.form.control.Toolbar;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.events.PreOpenFormEventArgs;
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.util.EventObject;
import java.util.Map;
/**
* 单据界面插件
* PreOpenFormEventArgs e: 事件参数对象定义如下
* Object getSource:界面显示参数对象可调整此对象属性值控制界面显示
* void setCancel(boolean cancel):取消界面显示
* void setCancelMessage(String message):取消原因提示用户
*/
public class ReqBillPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void preOpenForm(PreOpenFormEventArgs e) {
BillShowParameter fsp = (BillShowParameter) e.getSource();
//设置显示参数-是否出发TimeElopsed事件
fsp.setListentimerElapsed(true);
//检查用户是否获得授权如为获得授权撤销界面显示
if(1!=1){
e.setCancel(true);
e.setCancelMessage("对不起,您无权访问该界面");
}else{
//设置显示参数 - 界面标题
fsp.setCaption("采购申请表");
}
super.preOpenForm(e);
}
/**
* 界面初始化或刷新新建数据包完毕后触发此事件
* 常用于新增页面设置初始值
* 从列表打开查看页面时不触发该方法
* @param e
*/
@Override
public void afterCreateNewData(EventObject e) {
this.getModel().setValue("zcgj_usage","用于采购订单申请");
long currentUserId = UserServiceHelper.getCurrentUserId();
this.getModel().setValue("zcgj_applicant",currentUserId);
//第一行分录的申请数量默认值为10,下表从0开始
this.getModel().setValue("zcgj_applyqty",10,0);
super.afterCreateNewData(e);
}
/**
* 触发时机界面数据包构建完成之后发送给前端之前
* 应用场景设置可见性可控性设置控件颜色类型值
* 常见问题禁止在事件中修改字段值无字段名的可以修改常见于每次打开详情时数据都是动态赋值的
* @param e
*/
@Override
public void afterBindData(EventObject e) {
Object applicant = this.getModel().getValue("zcgj_applicant");
if(applicant!=null ){
//如果申请人是xxx就单据体可见否则不可见
this.getView().setVisible(true,new String[]{"advconap"});
}else{
this.getView().setVisible(false,new String[]{"advconap"});
}
super.afterBindData(e);
}
@Override
public void registerListener(EventObject e) {
Toolbar tbmain = this.getView().getControl("tbmain");
tbmain.addItemClickListener(this);
super.registerListener(e);
}
/**
* 触发时机在正式执行itemclick事件之前
* 应用场景业务数据校验如点击下载附件之前先校验附件是否为空
* 常见问题工具栏是一个控件整体只能注册工具栏的监听
* @param evt
*/
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
if(evt.getItemKey().equals("bar_save")){
//附件字段取值附件字段继承于多选基础资料是集合类对象 这里为附件名时 报错
DynamicObjectCollection atts = (DynamicObjectCollection)this.getModel().getValue("zcgj_supplier");
if(atts!=null){
this.getView().showTipNotification("请先上传附件");
evt.setCancel(true);
}
}
super.beforeItemClick(evt);
}
/**
* 触发时机用户点击工具栏时触发此事件
* 应用场景点击下载附件时执行下载附件中所有的附件的功能
* @param evt
*/
@Override
public void itemClick(ItemClickEvent evt) {
if(evt.getItemKey().equals("bar_save1")){
//获取附件
DynamicObjectCollection atts = (DynamicObjectCollection)this.getModel().getValue("attachmentpanel");
for(DynamicObject att:atts){
//附件字段的固定结构要根据fbasedataid去获取每个附件的实体数据
DynamicObject attObj = att.getDynamicObject("fbasedataid");
String url = attObj.getString("url");
this.getView().download(url);
}
}
super.itemClick(evt);
}
/**
* 触发时机用户点击按钮菜单执行绑定的操作逻辑之前触发此事件
* 应用场景修改操作参数操作前验证如分录中的采购方式为自费时采购单价不能小于0
* @param args
*/
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
if(args.getSource() instanceof Save){
Save opp = (Save)args.getSource();//获取数据源对象
if(opp.getOperateKey().equals("save1")){
//获取采购申请单实体数据
DynamicObject dataEntity = (DynamicObject)this.getModel().getDataEntity(true);
//获取采购信息单 单据体数据
DynamicObjectCollection dynamicObjectCollection =
dataEntity.getDynamicObjectCollection("entryentity");
StringBuilder strbd = new StringBuilder();
for(int i = 0 ; i < dynamicObjectCollection.size(); i++){
//各分录行数据
DynamicObject entryObj = dynamicObjectCollection.get(i);
BigDecimal price = entryObj.getBigDecimal("zcgj_price");//高精度浮点数类
int reqWay = entryObj.getInt("zcgj_combofield");
//采购方式为自费时采购单价不能为0时
if(reqWay == 1 && price.compareTo(BigDecimal.ZERO)<1){
strbd.append(i+1);
strbd.append(",");
}
}
if(strbd.length()>0){
strbd.deleteCharAt(strbd.length()-1);
String s = strbd.toString();
this.getView().showTipNotification(""+s+"行采购方式为自费时采购单价不能小于0");
//取消操作
args.setCancel(true);
}
}
}
super.beforeDoOperation(args);
}
/**
* 触发时机用户点击按钮菜单执行完绑定的操作之后不论成功与否均会触发此事件
* 应用场景如提交之后审核通过
* @param args
*/
@Override
public void afterDoOperation(AfterDoOperationEventArgs args) {
//操作执行之后无事务保护不管成功与否直接审核通过
if(args.getOperateKey().equals("save1")&&args.getOperationResult()!=null&&
args.getOperationResult().isSuccess()){
//判断提交结果是成功的话直接审核通过
this.getView().invokeOperation("audit");
}
super.afterDoOperation(args);
}
/**
* 触发时机文本整数等简单类型字段需要开启字段的即时触发更新并且要鼠标失去焦点如果是基础资料或其他复杂字段类型字段则更新数据时即触发值更新
* 应用场景监控某字段变更时同步处理其他业务逻辑如部门自动变更时自动带出公司字段值
* @param e
*/
@Override
public void propertyChanged(PropertyChangedArgs e) {
//选择部门之后自动带出公司
String name = e.getProperty().getName();
if(name.equals("xxx")){
ChangeData[] changeSet = e.getChangeSet();
//变更之后的部门的值
DynamicObject deparment = (DynamicObject) changeSet[0].getNewValue();
Map<String,Object> companyformOrg = OrgUnitServiceHelper.getCompanyfromOrg(deparment.getPkValue());
//查出来的部门所在的公司赋给公司字段
this.getModel().setValue("zcgj_applicant",companyformOrg.get("id"));
}
super.propertyChanged(e);
}
}

View File

@ -0,0 +1,141 @@
package zcgj.zcdev.zcdev.pr.plugin.list;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.form.control.Control;
import kd.bos.form.control.Toolbar;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.field.BasedataEdit;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
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.DeleteServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import org.apache.cxf.Bus;
import java.util.ArrayList;
import java.util.EventObject;
public class CrudListDemo extends AbstractListPlugin {
@Override
public void registerListener(EventObject e) {
// 注册工具栏监听"tbmain"为工具栏标识
this.addItemClickListeners("tbmain");
super.registerListener(e);
// super.registerListener(e);
// String clickName = e.getSource().toString();
// this.addItemClickListeners("zcgj_addsave");
// Toolbar tbmain = this.getView().getControl("zcgj_addsave");
// tbmain.addItemClickListener(this);
}
@Override
public void itemClick(ItemClickEvent evt) {
String itemKey = evt.getItemKey();//获取点击的按钮
switch(itemKey){
case "zcgj_addsave":
addNewDemo();
break;
case "zcgj_query":
queryDemo();
break;
case "zcgj_edit":
editDemo();
break;
case "zcgj_delete":
deleteDemo();
break;
}
}
private void deleteDemo() {
//获取列表中选中行数据billlstap是所有标准单据列表控件的固定标识
BillList billlstap = getView().getControl("billlstap");
ListSelectedRowCollection selectedRows = billlstap.getSelectedRows();//选取选中行
ArrayList<Object> ids = new ArrayList<>();//存储中单据的主键
String entityName = "zcgj_reqbill";//单据标识
for(ListSelectedRow row : selectedRows){
Object primaryKeyValue = row.getPrimaryKeyValue();
ids.add(primaryKeyValue);
}
QFilter qFilter = new QFilter("id", QCP.equals, ids);//在数据库中过滤条件
DeleteServiceHelper deleteServiceHelper = new DeleteServiceHelper();//deleteOperate删除前会校验 delete直接删除
OperationResult result = deleteServiceHelper.deleteOperate("zcgj_reqbill", ids.toArray(new Object[ids.size()]));
if(result.isSuccess()){
this.getView().showSuccessNotification("删除数据成功");
}
}
private void editDemo() {
//获取列表中选中行数据billlstap是所有标准单据列表控件的固定标识
BillList billlstap = getView().getControl("billlstap");
ListSelectedRowCollection selectedRows = billlstap.getSelectedRows();//选取选中行
ArrayList<Object> ids = new ArrayList<>();//存储中单据的主键
String entityName = "zcgj_reqbill";//单据标识
for(ListSelectedRow row : selectedRows){
Object primaryKeyValue = row.getPrimaryKeyValue();
ids.add(primaryKeyValue);
}
QFilter qFilter = new QFilter("id", QCP.equals, ids);//在数据库中过滤条件
DynamicObject[] dojs = BusinessDataServiceHelper.load(entityName, "id,zcgj_requester,zcgj_reqentryentity.zcgj_qty", new QFilter[]{qFilter});
DynamicObject userObj = BusinessDataServiceHelper.loadSingle("bos_user", "id,name", new QFilter[]{new QFilter("name", QCP.equals, "cxw")});
for(DynamicObject doj : dojs){
doj.set("zcgj_requester", userObj);//设置申请人信息
DynamicObjectCollection entrys = doj.getDynamicObjectCollection("zcgj_reqentryentity");//获取对应的单据体
for(DynamicObject entry : entrys){
entry.set("zcgj_qty", entry.getInt("zcgj_qty")+10);//对应数量字段+10
}
}
OperationResult result = SaveServiceHelper.saveOperate(entityName, dojs, OperateOption.create());
if(result.isSuccess()){
this.getView().showSuccessNotification("编辑数据成功");
}
}
private void queryDemo() {
//建立查询条件
QFilter billnoqFilter = new QFilter("billno", QCP.equals, "C");
//查询参数 单据标识 字段名 过滤条件
DynamicObjectCollection reqObj = QueryServiceHelper.query("zcgj_reqbill", "id,billno,zcgj_requser,zcgjreqentryentity.kdec_qty", new QFilter[]{billnoqFilter});
for(DynamicObject obj : reqObj){
Object billno = obj.get("billno");
Object zcgjreqentryentity = obj.get("zcgjreqentryentity");
}
this.getView().showMessage("搜索符合的数据行:"+String.valueOf(reqObj.size()) );
}
private void addNewDemo() {
//根据表单标识新建一条空的数据包
DynamicObject doj = BusinessDataServiceHelper.newDynamicObject("zcgj_purapply");
//设置单据头
doj.set("billstatus","A");//表示单据暂存
doj.set("zcgj_usage","备注");//设置备注值
doj.set("zcgj_applicant", UserServiceHelper.getCurrentUserId());//获取当前用户申请
//设置单据体
DynamicObjectCollection entrys = doj.getDynamicObjectCollection("entryentity");//获取单据体
DynamicObject entry = entrys.addNew();//新增分录行
entry.set("zcgj_applyqty",10);//设置分类字段中 数量字段值
//数据包保存至数据库
//参数表单标识被保存的数据包操作参数
OperationResult result = SaveServiceHelper.saveOperate("zcgj_purapply", new DynamicObject[]{doj}, OperateOption.create());
if(result.isSuccess()){
this.getView().showSuccessNotification("新增数据采购");
this.getView().invokeOperation("refresh");//调用表单的刷新操作
}
}
}

View File

@ -0,0 +1,38 @@
package zcgj.zcdev.zcdev.pr.plugin.list;
import kd.bos.filter.FilterColumn;
import kd.bos.form.IPageCache;
import kd.bos.form.events.FilterContainerInitArgs;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.mvc.cache.PageCache;
import kd.ebg.aqap.formplugin.plugin.baseplugin.CompareEnum;
import java.util.List;
/**
* 触发时机1.列表界面初始化过滤面板时触发此事件2.在过滤面板点击搜索时也会重新初始化过滤面板触发此事件
* 应用场景获取到列表过滤面板中快捷过滤常用过滤方案过滤所包含的过滤字段信息并对这些过滤字段进行调整
*/
public class DemoListPlugin01 extends AbstractListPlugin {
@Override
public void filterContainerInit(FilterContainerInitArgs args) {
super.filterContainerInit(args);
//获取常用过滤字段集合对象
List<FilterColumn> commfilter = args.getCommonFilterColumns();
for(FilterColumn filterColumn : commfilter){
String fieldName = filterColumn.getFieldName();
//判断如果时创建时间字段则设置默认值
if(fieldName.equals("createtime1")){
IPageCache pageCache = this.getView().getPageCache();
//缓存操作 避免多次设置默认值 只有第一次进入才设置默认值减少计算开销
if(pageCache.get("isfirst")==null){
filterColumn.setDefaultValue(CompareEnum.THISMONTH.getId());
pageCache.put("isfirst","true");
}
}
}
}
}

View File

@ -0,0 +1,36 @@
package zcgj.zcdev.zcdev.pr.plugin.list;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import java.util.Iterator;
import java.util.List;
public class DemoListPlugin02 extends AbstractListPlugin {
/**
* 触发时机单据列表控件在构建好取数条件时准备重新取数之前触发
* 应用场景1.移除常用过滤条件 取消带组织模板的组织过滤条件2.添加单据状态=已审核按单据编号升序排序
* @param e
*/
@Override
public void setFilter(SetFilterEvent e) {
super.setFilter(e);
//移除常用过滤条件
List<QFilter> qFilters = e.getQFilters();
Iterator<QFilter> iterator = qFilters.iterator();
while (iterator.hasNext()) {
QFilter qFilter = iterator.next();//返回当前指针对象指针并指向下一个
iterator.remove();
}
//取消带组织模板的组织过滤条件
QFilter mainOrgQFilter = e.getMainOrgQFilter();
e.setMainOrgQFilter(null);
//设置过滤条件
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");
e.getQFilters().add(qFilter);
//设置列表排序
e.setOrderBy("billno asc");
}
}

View File

@ -0,0 +1,20 @@
package zcgj.zcdev.zcdev.pr.plugin.task;
import kd.bos.context.RequestContext;
import kd.bos.eye.api.log.KDException;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.schedule.executor.AbstractTask;
import java.util.Map;
import java.util.logging.Logger;
public class SampleTask extends AbstractTask {
private static final Log log = LogFactory.getLog(AbstractTask.class);
@Override
public void execute(RequestContext requestContext, Map<String , Object>map)throws KDException{
log.info("hello kingdee");
}
}