删除保存关闭类(MaterialSaveClosePlugin),个性字段置为false用save直接保存(MaterialSaveOp),采购单点击关闭操作后,将已关闭数量=数量-已入库数量(PurOlderCloseCountOp)
This commit is contained in:
parent
1b538f0c73
commit
f875770855
|
|
@ -1,59 +0,0 @@
|
||||||
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);
|
|
||||||
//保存校验 当前单据数据
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package tqq9.lc123.cloud.app.plugin.operate.pm;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
|
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据操作插件
|
||||||
|
* 采购单点击关闭操作后,将已关闭数量=数量-已入库数量
|
||||||
|
*/
|
||||||
|
public class PurOlderCloseCountOp extends AbstractOperationServicePlugIn implements Plugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||||
|
super.beforeExecuteOperationTransaction(e);
|
||||||
|
DynamicObject[] dataEntities = e.getDataEntities();
|
||||||
|
String operationKey = e.getOperationKey();
|
||||||
|
if(dataEntities.length>0 && "bizclose".equals(operationKey)){
|
||||||
|
for(DynamicObject purOlder:dataEntities){
|
||||||
|
purOlder = BusinessDataServiceHelper.loadSingle(purOlder.getPkValue(), "pm_purorderbill");
|
||||||
|
DynamicObjectCollection billentry = purOlder.getDynamicObjectCollection("billentry");
|
||||||
|
if(billentry.size()>0){
|
||||||
|
for (DynamicObject dynamicObject : billentry) {
|
||||||
|
Integer invqty = dynamicObject.getInt("invqty");//已入库数量
|
||||||
|
Integer qty = dynamicObject.getInt("qty");//数量
|
||||||
|
Integer tqq9_qtyfield = qty-invqty;//已关闭数量
|
||||||
|
dynamicObject.set("tqq9_qtyfield",tqq9_qtyfield);
|
||||||
|
}
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{purOlder});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,7 @@ import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -26,13 +27,7 @@ public class MaterialSaveOp extends AbstractOperationServicePlugIn implements Pl
|
||||||
for (DynamicObject material : dataEntities) {
|
for (DynamicObject material : dataEntities) {
|
||||||
material = BusinessDataServiceHelper.loadSingle(material.getPkValue(), material.getDynamicObjectType().getName());
|
material = BusinessDataServiceHelper.loadSingle(material.getPkValue(), material.getDynamicObjectType().getName());
|
||||||
material.set("tqq9_checkboxfield", false);
|
material.set("tqq9_checkboxfield", false);
|
||||||
OperationResult opResult = OperationServiceHelper.executeOperate("save", "bd_material", new DynamicObject[]{material}, OperateOption.create());
|
SaveServiceHelper.save(new DynamicObject[]{material});
|
||||||
if (opResult.isSuccess()) {
|
|
||||||
log.info( material.getString("number")+"保存成功");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.info( material.getString("number")+"保存失败");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue