物料保存关闭类(MaterialSaveClosePlugin)、删除(物料审核后 修改审核人、修改人为待审批人)类,物料保存操作后,将是否个性字段置为false(MaterialSaveOp)
This commit is contained in:
parent
ac4a5cc856
commit
b5c6660495
|
|
@ -1,39 +1,59 @@
|
|||
package tqq9.lc123.cloud.app.plugin.form.sys;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.form.IFormView;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import tqq9.lc123.cloud.app.plugin.operate.sys.MaterialSaveOp;
|
||||
|
||||
/**
|
||||
* 单据界面插件
|
||||
* 物料保存后关闭单据的插件
|
||||
*/
|
||||
public class MaterialSaveClosePlugin extends AbstractBillPlugIn implements Plugin {
|
||||
private static final Log log = LogFactory.getLog(MaterialSaveClosePlugin.class);
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
// FormOperate operation = (FormOperate) args.getSource();
|
||||
// String key = operation.getOperateKey();
|
||||
// if (StringUtils.equals("save", key)) {
|
||||
// args.setCancel(Boolean.TRUE);
|
||||
// // 弹出操作成功提示消息
|
||||
// boolean showInParentView = true;
|
||||
// IFormView view = this.getView().getViewNoPlugin(this.getView().getFormShowParameter().getParentPageId());
|
||||
// if (view == null) {
|
||||
// view = this.getView();
|
||||
// showInParentView = false;
|
||||
// }
|
||||
// view.showSuccessNotification(String.format(ResManager.loadKDString("保存成功", "DefaultEntityOperate_5", "bos-entity-business", new Object[0]), operation.getOperateName().toString()));
|
||||
// if (showInParentView) {
|
||||
// this.getView().sendFormAction(view);
|
||||
// }
|
||||
//
|
||||
// this.getModel().setDataChanged(Boolean.FALSE);
|
||||
// // 关闭新增窗口
|
||||
// this.getView().close();
|
||||
// }
|
||||
FormOperate operation = (FormOperate) args.getSource();
|
||||
String key = operation.getOperateKey();
|
||||
if (StringUtils.equals("save", key)) {
|
||||
args.setCancel(Boolean.TRUE);
|
||||
//保存校验 当前单据数据
|
||||
DynamicObject dataEntity = this.getModel().getDataEntity(true);
|
||||
OperationResult result = OperationServiceHelper.executeOperate("save", "bd_material", new DynamicObject[]{dataEntity}, OperateOption.create());
|
||||
if (result.isSuccess()) {
|
||||
log.info(dataEntity.getString("number") + "保存成功");
|
||||
} else {
|
||||
getView().showErrorNotification("保存失败");
|
||||
log.info(dataEntity.getString("number") + "保存失败,原因:" + result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 弹出操作成功提示消息
|
||||
boolean showInParentView = true;
|
||||
IFormView view = this.getView().getViewNoPlugin(this.getView().getFormShowParameter().getParentPageId());
|
||||
if (view == null) {
|
||||
view = this.getView();
|
||||
showInParentView = false;
|
||||
}
|
||||
view.showSuccessNotification(String.format(ResManager.loadKDString("保存成功", "DefaultEntityOperate_5", "bos-entity-business", new Object[0]), operation.getOperateName().toString()));
|
||||
if (showInParentView) {
|
||||
this.getView().sendFormAction(view);
|
||||
}
|
||||
this.getModel().setDataChanged(Boolean.FALSE);
|
||||
// 关闭新增窗口
|
||||
this.getView().close();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* 单据操作插件
|
||||
* 审核后 修改审核人、修改人为待审批人
|
||||
*/
|
||||
public class MaterialAuditOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
for (DynamicObject material : dataEntities) {
|
||||
material = BusinessDataServiceHelper.loadSingle(material.getPkValue(), material.getDynamicObjectType().getName());
|
||||
DynamicObject tqq9_auditor = material.getDynamicObject("tqq9_auditor");
|
||||
if (tqq9_auditor != null) {
|
||||
material.set("modifier", tqq9_auditor);
|
||||
material.set("approverid", tqq9_auditor);
|
||||
SaveServiceHelper.save(new DynamicObject[]{material});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
||||
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* 单据操作插件
|
||||
* 物料保存操作后,将是否个性字段置为false
|
||||
*/
|
||||
public class MaterialSaveOp extends AbstractOperationServicePlugIn implements Plugin {
|
||||
private static final Log log = LogFactory.getLog(MaterialSaveOp.class);
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
OperationResult operationResult = this.getOperationResult();
|
||||
if (operationResult.isSuccess()) {
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
for (DynamicObject material : dataEntities) {
|
||||
material = BusinessDataServiceHelper.loadSingle(material.getPkValue(), material.getDynamicObjectType().getName());
|
||||
material.set("tqq9_checkboxfield", false);
|
||||
OperationResult opResult = OperationServiceHelper.executeOperate("save", "bd_material", new DynamicObject[]{material}, OperateOption.create());
|
||||
if (opResult.isSuccess()) {
|
||||
log.info( material.getString("number")+"保存成功");
|
||||
}
|
||||
else {
|
||||
log.info( material.getString("number")+"保存失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue