Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
5ac01a2245 | |
|
57bf81ab2f |
|
@ -0,0 +1,34 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* 收入/支出合同计量提交时,系统校验计量清单变动的单价,
|
||||
* 当清单项单价变动过大(超过原单价的2倍或低于0.5倍)时,
|
||||
* 弹出提醒“请注意,清单项:【xx资源名称】、【xx资源名称】的单价变动较大,
|
||||
* 请检查是否存在错误”,且对应清单项的“说明”必填。
|
||||
*/
|
||||
public class ContractPriceChangedWarnPlugin extends AbstractBillPlugIn implements Plugin {
|
||||
@Override
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
super.propertyChanged(e);
|
||||
String price = e.getProperty().getName();
|
||||
if(price.equals("currentprice")){
|
||||
ChangeData[] changeSet = e.getChangeSet();
|
||||
DynamicObject oldValue =(DynamicObject) changeSet[0].getOldValue();
|
||||
DynamicObject newValue =(DynamicObject) changeSet[0].getNewValue();
|
||||
int oldPrice = oldValue.getInt("DynamicObject");
|
||||
int newPrice = newValue.getInt("DynamicObject");
|
||||
if((newPrice >= oldPrice * 2)||(newPrice <= oldPrice * 0.5)){
|
||||
this.getView().showTipNotification(
|
||||
"请注意,清单项:【xx资源名称】、【xx资源名称】的单价变动较大,\n" +
|
||||
" 请检查是否存在错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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选择框的筛选条件
|
||||
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form.demo;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.form.*;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
import kd.bos.form.control.events.CellClickEvent;
|
||||
import kd.bos.form.control.events.CellClickListener;
|
||||
import kd.bos.form.events.ClosedCallBackEvent;
|
||||
import kd.bos.list.ListShowParameter;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
public class AlertwindowBillPlugin extends AbstractBillPlugIn implements Plugin, CellClickListener {
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
EntryGrid entryGrid = this.getView().getControl("entryentity");
|
||||
entryGrid.addCellClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellClick(CellClickEvent arg0) {
|
||||
//申请数量点击后跳出弹窗
|
||||
if(arg0.getFieldKey().equals("zcgj_applyqty")){
|
||||
DynamicObjectCollection entitys = this.getView().getModel().getEntryEntity("entryentity");
|
||||
DynamicObject object = entitys.get(arg0.getRow());//获取点击所在行分录
|
||||
// object = object.getDynamicObject("zcgj_applyqty");
|
||||
String id = object.getString("id");
|
||||
System.out.println(id);
|
||||
// //打开子页面弹窗
|
||||
// FormShowParameter formShow = new FormShowParameter();
|
||||
// OpenStyle openStyle = formShow.getOpenStyle();//设置打开风格
|
||||
// openStyle.setShowType(ShowType.Modal);//设置打开方式
|
||||
// //设置弹窗页面大小
|
||||
// StyleCss css = new StyleCss();
|
||||
// css.setHeight("600");
|
||||
// css.setWidth("300");
|
||||
// formShow.getOpenStyle().setInlineStyleCss(css);
|
||||
// formShow.setFormId("zcgj_add_new");//设置子页面编码
|
||||
// formShow.setCustomParam("id",id);//设置自定义参数 String key,Object value;
|
||||
// //CloseCallBack(plugin ,actionId)参数:插件,回调标识(用于区分不同的回调)
|
||||
// //使用场景 通常用于父页面打开子页面之后,单子页面关闭之后,父页面需要接受子页面返回的数据或执行某些操作的场景
|
||||
// //this 告诉程序是哪个父页面 actionId是用于标识回调事件,用来识别哪个子页面关闭了
|
||||
//// formShow.setCloseCallBack(new CloseCallBack(this,"回调标识"));
|
||||
// this.getView().showForm(formShow);
|
||||
|
||||
//创建弹出列表界面对象
|
||||
ListShowParameter lsp = new ListShowParameter();
|
||||
//设置FormId,列表的FormId固定为“bos_list”
|
||||
lsp.setFormId("bos_list");
|
||||
//设置Billform,为列表所对应单据的标识
|
||||
lsp.setBillFormId("zcgj_purapply");
|
||||
//设置弹窗页面标题
|
||||
lsp.setCaption("物料库存列表界面");
|
||||
//设置弹出页面的打开方式
|
||||
lsp.getOpenStyle().setShowType(ShowType.Modal);
|
||||
//设置为不能多选
|
||||
lsp.setMultiSelect(false);
|
||||
lsp.setCloseCallBack(new CloseCallBack(this,"xxx"));//设置子页面关闭回调参数,回调标识为xxx
|
||||
//弹出列表界面
|
||||
this.getView().showForm(lsp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellDoubleClick(CellClickEvent cellClickEvent) {
|
||||
|
||||
}
|
||||
//重写closedCalled 获取子页面传出的参数
|
||||
|
||||
@Override
|
||||
public void closedCallBack(ClosedCallBackEvent e) {
|
||||
super.closedCallBack(e);
|
||||
String actionId = e.getActionId();//
|
||||
if (actionId.equals("xxx")) {
|
||||
int count = (int)e.getReturnData();
|
||||
this.getModel().setValue("xxx", count,0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form.demo;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.extplugin.sample.AbstractFormPlugin;
|
||||
import kd.bos.form.events.BeforeClosedEvent;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
public class OfficeApplyformPlugin extends AbstractBillPlugIn implements Plugin {
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
//获取父页面的传参
|
||||
String id = getView().getFormShowParameter().getCustomParam("id");
|
||||
QFilter qFilter = new QFilter("id", QCP.equals, id);
|
||||
//查询物品名和库存
|
||||
DynamicObject dyn = BusinessDataServiceHelper.loadSingle("xxx", "name,count", new QFilter[]{qFilter});
|
||||
String name = dyn.getString("name");
|
||||
int count = dyn.getInt("count");
|
||||
//将查出来的值放入表中
|
||||
getModel().setValue("name", name);
|
||||
getModel().setValue("count", count);
|
||||
super.afterCreateNewData(e);
|
||||
|
||||
}
|
||||
//重写页面关闭事件
|
||||
|
||||
@Override
|
||||
public void beforeClosed(BeforeClosedEvent e) {
|
||||
super.beforeClosed(e);
|
||||
//获取页面库存数量 ,由于afterCreateNewData 设置了页面参数值,所以,可以获取弹窗页面值
|
||||
int count = (int)this.getModel().getValue("xxx");
|
||||
//通过returnDataToParent将页面关闭前,传回父页面
|
||||
this.getView().returnDataToParent(count);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form.demo;
|
||||
|
||||
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
|
||||
public class ReqOppSubmitServicePlugin extends AbstractOperationServicePlugIn {
|
||||
/**
|
||||
* 插件需要再次事件,添加需要用到的字段
|
||||
* 否则,操作引擎加载出的单据数据包,可能没有插件要用到的字段值,从而引发中断
|
||||
* @param e
|
||||
*/
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
//加载采购字段
|
||||
e.getFieldKeys().add("zcgj_combofield");
|
||||
//加载采购价格
|
||||
e.getFieldKeys().add("zcgj_price");
|
||||
// e.getFieldKeys().add("entryentity");
|
||||
}
|
||||
/**
|
||||
* 执行校验前,触发此事件
|
||||
* 插件可以在此事件,调整预置的操作校验码;或者增加自定义操作校验码
|
||||
*/
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
//添加自定义的校验器
|
||||
e.addValidator(new ReqSubmitValidator());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form.demo;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ReqSubmitValidator extends AbstractValidator {
|
||||
@Override
|
||||
public void validate() {
|
||||
for(ExtendedDataEntity extendedDataEntity:this.getDataEntities()){
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();//获取平铺的单据实体
|
||||
DynamicObjectCollection entityCollection = dataEntity.getDynamicObjectCollection("entryentity");//获取单据体
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < entityCollection.size(); i++){
|
||||
DynamicObject dynamicObject = entityCollection.get(i);
|
||||
int zcgjCombofield = dynamicObject.getInt("zcgj_combofield");
|
||||
BigDecimal price = dynamicObject.getBigDecimal("zcgj_price");
|
||||
if(zcgjCombofield == 1&&price.compareTo(BigDecimal.ZERO)<1){
|
||||
sb.append(i+1).append(",");
|
||||
}
|
||||
}
|
||||
if(sb.length()>0){
|
||||
sb.deleteCharAt(sb.length()-1);
|
||||
this.addErrorMessage(extendedDataEntity,"第"+sb.toString()+"行自费方式的单价不能小于等于0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");//调用表单的刷新操作
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.list;
|
||||
|
||||
import kd.bos.bill.BillShowParameter;
|
||||
import kd.bos.bill.OperationStatus;
|
||||
import kd.bos.entity.datamodel.ListSelectedRow;
|
||||
import kd.bos.form.ShowType;
|
||||
import kd.bos.form.events.BillListHyperLinkClickEvent;
|
||||
import kd.bos.form.events.HyperLinkClickArgs;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
|
||||
public class DemoListPlugin03 extends AbstractListPlugin {
|
||||
/**
|
||||
* 触发时机:单据列表上显示为超链接的单元格,用户点击,系统默认会打开单据维护界面
|
||||
* 应用场景:以采购申请单为例,单据列表物料字段开启超链接属性,点击物料列,打开物料详情
|
||||
* @param args
|
||||
*/
|
||||
@Override
|
||||
public void billListHyperLinkClick(HyperLinkClickArgs args) {
|
||||
super.billListHyperLinkClick(args);
|
||||
String key = args.getFieldName();//获取点击字段标识
|
||||
if(key.equals("xxx")){
|
||||
args.setCancel(true);//取消单据详情界面的打开
|
||||
int rowIndex = args.getRowIndex();
|
||||
BillListHyperLinkClickEvent event = (BillListHyperLinkClickEvent)args.getHyperLinkClickEvent();
|
||||
ListSelectedRow currentRow = event.getCurrentRow();//获取当前点击行
|
||||
Object entryPrimaryKeyValue = currentRow.getEntryPrimaryKeyValue();//获取单据id
|
||||
QueryServiceHelper.query("xxx","xx",new QFilter[]{new QFilter("xx", QCP.equals,"XXX")});
|
||||
//因为列表界面只能获取id,使用状态,单据状态字段,其他需要通过orm框架查出
|
||||
BillShowParameter billShowParameter = new BillShowParameter();
|
||||
billShowParameter.setFormId("xxx");
|
||||
billShowParameter.setPkId("xx");
|
||||
billShowParameter.setFormId("xx");
|
||||
billShowParameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||
billShowParameter.setStatus(OperationStatus.VIEW);
|
||||
this.getView().showForm(billShowParameter);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.list;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.datamodel.events.PackageDataEvent;
|
||||
import kd.bos.form.operatecol.OperationColItem;
|
||||
import kd.bos.list.column.ListOperationColumnDesc;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DemoListPlugin04 extends AbstractListPlugin {
|
||||
/**
|
||||
* 触发时机:列表初始化,或者列表重新加载时
|
||||
* 应用场景:以采购申请单为例,格式化列表金额字段并对已审核状态的数据锁定操作项,不允许操作
|
||||
* @param e
|
||||
*/
|
||||
@Override
|
||||
public void packageData(PackageDataEvent e) {
|
||||
super.packageData(e);
|
||||
String colKey = e.getColKey();//获取列表点击值
|
||||
if("zcgj_amount".equals(colKey)){
|
||||
DynamicObject rowData = e.getRowData();//获取列表值
|
||||
e.setFormatValue(rowData.getLong("zcgj_amount")*0.5);//格式化处理
|
||||
if ("yyy".equals(colKey)&& e.getSource() instanceof ListOperationColumnDesc){
|
||||
List<OperationColItem> items = (List<OperationColItem>)e.getFormatValue();
|
||||
//如果单据状态为已审核
|
||||
if("C".equals(rowData.get("billstatus"))){
|
||||
for(OperationColItem item:items){
|
||||
if("modify".equalsIgnoreCase(item.getOperationKey())
|
||||
||"delete".equalsIgnoreCase(item.getOperationKey())
|
||||
||"submit".equalsIgnoreCase(item.getOperationKey())){
|
||||
//设置锁定
|
||||
item.setLocked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.list;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import kd.bos.dataentity.entity.LocaleString;
|
||||
import kd.bos.form.IPageCache;
|
||||
import kd.bos.form.events.BeforeCreateListColumnsArgs;
|
||||
import kd.bos.form.events.FilterContainerSearchClickArgs;
|
||||
import kd.bos.list.IListColumn;
|
||||
import kd.bos.list.ListColumn;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class DemoListPlugin05 extends AbstractListPlugin {
|
||||
/**
|
||||
* 场景:以采购申请单为案例,当单据状态已为审核时,单据列表添加字段--审核人
|
||||
*/
|
||||
//获取页面缓存,并添加标志变量--是否审核
|
||||
@Override
|
||||
public void filterContainerSearchClick(FilterContainerSearchClickArgs args) {
|
||||
IPageCache pageCache = this.getView().getPageCache();
|
||||
Object billstatus = args.getFilterValue("billstatus");
|
||||
if (billstatus != null&&billstatus instanceof String && StringUtils.equals("C",(String)billstatus)){
|
||||
pageCache.put("isAudit","true");
|
||||
}else{
|
||||
pageCache.put("isAudit","false");
|
||||
}
|
||||
}
|
||||
|
||||
//根据缓存变量,动态添加审核人列
|
||||
@Override
|
||||
public void beforeCreateListColumns(BeforeCreateListColumnsArgs args) {
|
||||
IPageCache pageCache = this.getView().getPageCache();
|
||||
String isAudit = pageCache.get("isAudit");
|
||||
if(isAudit.equals("true")){
|
||||
ListColumn colUser = new ListColumn();
|
||||
colUser.setCaption(new LocaleString("审核人"));
|
||||
colUser.setKey("audit.name");
|
||||
colUser.setListFieldKey("audit.name");
|
||||
}else{
|
||||
Iterator<IListColumn> iterator = args.getListColumns().iterator();
|
||||
while(iterator.hasNext()){
|
||||
IListColumn next = iterator.next();
|
||||
if("audit.name".equals(next.getCaption())){
|
||||
next.setHeaderField(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.report;
|
||||
|
||||
import kd.bos.algo.DataSet;
|
||||
import kd.bos.algo.JoinDataSet;
|
||||
import kd.bos.algo.JoinType;
|
||||
import kd.bos.entity.report.AbstractReportListDataPlugin;
|
||||
import kd.bos.entity.report.ReportQueryParam;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
|
||||
public class EmployeeReportPlugin extends AbstractReportListDataPlugin {
|
||||
@Override
|
||||
public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
|
||||
String selectFiles = "entryentity.zcgj_name , entryentity.zcgj_salary ,entryentity.zcgj_apartmentid ";//字段名应与数据源字段一致
|
||||
|
||||
DataSet ds = QueryServiceHelper.queryDataSet(
|
||||
this.getClass().getName(), "zcgj_employee_infomation", selectFiles, null, null);
|
||||
String selectFiles1 = "zcgj_apartment_info.entryentity.zcgj_apartmentid," +
|
||||
"zcgj_apartment_info.entryentity.zcgj_apartmentname";
|
||||
DataSet ds1 = QueryServiceHelper.queryDataSet(
|
||||
this.getClass().getName(), "zcgj_apartment_info", selectFiles1, null, null);
|
||||
JoinDataSet join = ds.join(ds1, JoinType.LEFT);
|
||||
// JoinDataSet join1 = join.on("entryentity.zcgj_apartmentid", "zcgj_apartment_info.entryentity.zcgj_apartmentid");
|
||||
JoinDataSet join2 = join.select(new String[]{"entryentity.zcgj_name", "entryentity.zcgj_salary", "entryentity.zcgj_apartmentid"},
|
||||
new String[]{"zcgj_apartment_info.entryentity.zcgj_apartmentname"});
|
||||
DataSet join3 = join2.finish();
|
||||
|
||||
return ds1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.report;
|
||||
|
||||
import com.grapecity.documents.excel.S;
|
||||
import kd.bos.algo.DataSet;
|
||||
import kd.bos.algo.JoinDataSet;
|
||||
import kd.bos.algo.JoinType;
|
||||
import kd.bos.entity.report.AbstractReportListDataPlugin;
|
||||
import kd.bos.entity.report.ReportQueryParam;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
|
||||
public class PurchaseApplyReportPlugin extends AbstractReportListDataPlugin {
|
||||
private final static String APPLY_REPORT = "zcgj_purapply";//这里为源单标识
|
||||
@Override
|
||||
public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
|
||||
String selectFiles = "billno,zcgj_applicant,entryentity.zcgj_applyqty," +
|
||||
"entryentity.zcgj_amount,billstatus,entryentity.zcgj_materiel";//字段名应与数据源字段一致
|
||||
|
||||
DataSet ds = QueryServiceHelper.queryDataSet(
|
||||
this.getClass().getName(), APPLY_REPORT, selectFiles, null, null);
|
||||
|
||||
// String selectFiles1 = "billno,entryentity.zcgj_orderedqty,entryentity.zcgj_price" ;
|
||||
// DataSet ds1 = QueryServiceHelper.queryDataSet(
|
||||
// this.getClass().getName(), APPLY_REPORT, selectFiles1, null, null);
|
||||
// JoinDataSet js = ds.join(ds1, JoinType.LEFT);
|
||||
// DataSet js1 = js.on("billno", "billno").select(new String[]{"billno,zcgj_applicant,entryentity.zcgj_applyqty," +
|
||||
// "entryentity.zcgj_amount,billstatus,entryentity.zcgj_materiel"},
|
||||
// new String[]{"entryentity.zcgj_orderedqty,entryentity.zcgj_price"}).finish();
|
||||
|
||||
|
||||
return ds.orderBy(new String[]{"entryentity.zcgj_applyqty asc"});
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.workflow;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.workflow.api.AgentExecution;
|
||||
import kd.bos.workflow.engine.extitf.WorkflowPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DemoForWorkPlugin extends WorkflowPlugin {
|
||||
/**
|
||||
* 根据业务逻辑返回参与人id列表
|
||||
* 参数:AgentExecution对象,对象中可获取单据od,实体编码,当前节点信息
|
||||
* @param execution
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Long> calcUserIds(AgentExecution execution) {
|
||||
String businessKey = execution.getBusinessKey();
|
||||
|
||||
List<Long> ret = new ArrayList<Long>();
|
||||
DynamicObject dy = BusinessDataServiceHelper.loadSingle(businessKey, "zcgj_purapply", "zcgj_applicant,entryentity,entryentity.zcgj_materiel,entryentity.zcgj_applyqty");
|
||||
DynamicObjectCollection objs = (DynamicObjectCollection) dy.get("entryentity");
|
||||
for (DynamicObject obj : objs) {
|
||||
int anInt = obj.getInt("zcgj_applyqty");
|
||||
|
||||
if(anInt >0 ){
|
||||
ret.add(Long.valueOf("xxxx"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTrueCondition(AgentExecution execution) {
|
||||
String key = execution.getBusinessKey();//获取当前主键
|
||||
DynamicObject dy = BusinessDataServiceHelper.loadSingle(key, "zcgj_purapply");
|
||||
DynamicObjectCollection objs = (DynamicObjectCollection) dy.get("entryentity");
|
||||
for (DynamicObject obj : objs) {
|
||||
int anInt = obj.getInt("zcgj_applyqty");
|
||||
if(anInt < 0 ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 正向执行时 调用notify方法,撤回时调用notifyByWithdraw方法
|
||||
* @param execution
|
||||
*/
|
||||
@Override
|
||||
public void notify(AgentExecution execution) {
|
||||
super.notify(execution);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyByWithdraw(AgentExecution execution) {
|
||||
super.notifyByWithdraw(execution);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue