拦截关闭
This commit is contained in:
parent
2bde310dea
commit
5b4dc55bc3
|
|
@ -1,16 +1,18 @@
|
|||
package tqq9.lc123.cloud.app.plugin.form.result;
|
||||
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.CloneUtils;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.botp.runtime.BFRow;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
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.botp.BFTrackerServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -19,56 +21,53 @@ import java.util.Map;
|
|||
public class CloneBill extends AbstractOperationServicePlugIn {
|
||||
private final static Log logger = LogFactory.getLog(CloneBill.class);
|
||||
|
||||
//先调用拦截,没有回传则调用,然后调用关闭
|
||||
@Override
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
||||
super.beforeExecuteOperationTransaction(e);
|
||||
DynamicObject[] dataEntities1 = e.getDataEntities();
|
||||
for (DynamicObject dynamicObject : dataEntities1) {
|
||||
StringBuilder billnoSet = new StringBuilder();
|
||||
Map<Long, List<BFRow>> sourceBillsMap = BFTrackerServiceHelper.findDirtSourceBills(dynamicObject.getDataEntityType().getName(), new Long[]{dynamicObject.getLong("id")});
|
||||
if (null != sourceBillsMap && sourceBillsMap.size() > 0) {
|
||||
List<BFRow> bfRows = sourceBillsMap.get(dynamicObject.getLong("id"));
|
||||
if (null != bfRows) {
|
||||
for (BFRow bfRow : bfRows) {
|
||||
Long billId = bfRow.getSId().getBillId();//获取到采购退货申请id
|
||||
DynamicObject[] pm_purrefundapplybill = BusinessDataServiceHelper.load("pm_purrefundapplybill", "billno",
|
||||
new QFilter[]{new QFilter("id", "=", billId)});
|
||||
|
||||
for (int i = 0; i < pm_purrefundapplybill.length; i++) {
|
||||
DynamicObject object = pm_purrefundapplybill[i];
|
||||
String billno = object.getString("billno");
|
||||
billnoSet.append(billno);
|
||||
if (i < pm_purrefundapplybill.length-1) {
|
||||
billnoSet.append("、");
|
||||
}
|
||||
public static void cloneOperation(DynamicObject dynamicObject) {
|
||||
String entityNumber = dynamicObject.getDataEntityType().getName();
|
||||
StringBuilder billnoSet = new StringBuilder();
|
||||
//找直接上游单据,将上游单据编号存在复制的单据上面
|
||||
Map<Long, List<BFRow>> sourceBillsMap = BFTrackerServiceHelper.findDirtSourceBills(entityNumber, new Long[]{dynamicObject.getLong("id")});
|
||||
if (null != sourceBillsMap && sourceBillsMap.size() > 0) {
|
||||
List<BFRow> bfRows = sourceBillsMap.get(dynamicObject.getLong("id"));
|
||||
if (null != bfRows) {
|
||||
for (BFRow bfRow : bfRows) {
|
||||
Long billId = bfRow.getSId().getBillId();//获取到采购退货申请id
|
||||
DynamicObject[] pm_purrefundapplybill = BusinessDataServiceHelper.load("pm_purrefundapplybill", "billno",
|
||||
new QFilter[]{new QFilter("id", "=", billId)});
|
||||
|
||||
for (int i = 0; i < pm_purrefundapplybill.length; i++) {
|
||||
DynamicObject object = pm_purrefundapplybill[i];
|
||||
String billno = object.getString("billno");
|
||||
billnoSet.append(billno);
|
||||
if (i < pm_purrefundapplybill.length - 1) {
|
||||
billnoSet.append("、");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
dynamicObject = BusinessDataServiceHelper.loadSingle(dynamicObject.getDataEntityType().getName(),
|
||||
new QFilter[]{new QFilter("id", QCP.equals, dynamicObject.getLong("id"))});
|
||||
DynamicObject newData = (DynamicObject) new CloneUtils(false, true).clone(dynamicObject);
|
||||
newData.set("billno", dynamicObject.getString("billno"));
|
||||
newData.set("billstatus", "C");
|
||||
newData.set("tqq9_sourcebillno",billnoSet);
|
||||
SaveServiceHelper.save(new DynamicObject[]{newData});
|
||||
StringBuilder message = new StringBuilder();
|
||||
/*OperateOption option = OperateOption.create();
|
||||
OperationResult unauditResult = OperationServiceHelper.executeOperate("unaudit", dynamicObject.getDataEntityType().getName(), new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||
if (unauditResult.isSuccess()) {
|
||||
OperationResult deleteResult = OperationServiceHelper.executeOperate("delete", dynamicObject.getDataEntityType().getName(), new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||
}
|
||||
dynamicObject = BusinessDataServiceHelper.loadSingle(entityNumber, new QFilter[]{new QFilter("id", QCP.equals, dynamicObject.getLong("id"))});
|
||||
DynamicObject newData = (DynamicObject) new CloneUtils(false, true).clone(dynamicObject);
|
||||
newData.set("billno", dynamicObject.getString("billno"));
|
||||
newData.set("billstatus", "C");
|
||||
newData.set("tqq9_sourcebillno", billnoSet);
|
||||
SaveServiceHelper.save(new DynamicObject[]{newData});
|
||||
StringBuilder message = new StringBuilder();
|
||||
OperationResult unauditResult = OperationServiceHelper.executeOperate("unaudit", entityNumber, new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||
if (unauditResult.isSuccess()) {
|
||||
OperationResult deleteResult = OperationServiceHelper.executeOperate("delete", entityNumber, new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||
|
||||
deleteResult.getAllErrorOrValidateInfo().forEach((error) -> {
|
||||
message.append(error.getMessage());
|
||||
});
|
||||
deleteResult.getAllErrorOrValidateInfo().forEach((error) -> {
|
||||
message.append(error.getMessage());
|
||||
});
|
||||
|
||||
} else {
|
||||
unauditResult.getAllErrorOrValidateInfo().forEach((error) -> {
|
||||
message.append(error.getMessage());
|
||||
});
|
||||
}*/
|
||||
logger.info(dynamicObject.getString("billno") + "删除失败:" + message);
|
||||
} else {
|
||||
unauditResult.getAllErrorOrValidateInfo().forEach((error) -> {
|
||||
message.append(error.getMessage());
|
||||
});
|
||||
logger.info(dynamicObject.getString("billno") + "反审核失败:" + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
|||
|
||||
import java.util.EventObject;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//其他入库申请单(单据取消)
|
||||
|
||||
public class OtherInApplyFormPlugin extends AbstractBillPlugIn {
|
||||
|
|
@ -95,7 +97,7 @@ public class OtherInApplyFormPlugin extends AbstractBillPlugIn {
|
|||
}
|
||||
|
||||
entityName = "WMS-SH-其他入库申请单取消";
|
||||
message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
} else if ("BJLC".equals(number)) {
|
||||
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
|
||||
entityName = "WMS-BJ-其他入库申请单取消";
|
||||
|
|
@ -107,6 +109,9 @@ public class OtherInApplyFormPlugin extends AbstractBillPlugIn {
|
|||
message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import java.util.EventObject;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//其他入库申请单(单据取消)
|
||||
|
||||
public class OtherInApplyListPlugin extends AbstractListPlugin {
|
||||
|
|
@ -127,7 +129,7 @@ public class OtherInApplyListPlugin extends AbstractListPlugin {
|
|||
|
||||
|
||||
entityName = "WMS-SH-其他入库申请单取消";
|
||||
message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
} else if ("BJLC".equals(number)) {
|
||||
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
|
||||
|
||||
|
|
@ -141,6 +143,9 @@ public class OtherInApplyListPlugin extends AbstractListPlugin {
|
|||
message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
|||
|
||||
import java.util.EventObject;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//其他出库申请单(单据取消)
|
||||
|
||||
public class OtherOutApplyFormPlugin extends AbstractBillPlugIn {
|
||||
|
|
@ -107,6 +109,9 @@ public class OtherOutApplyFormPlugin extends AbstractBillPlugIn {
|
|||
entityName = "WMS-GZ-其他出库申请单取消";
|
||||
message = BillCloseCancelUtils.BGCloseOtherVouchOut(billNo, GZURL, entityType, entityName, label, orderType);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import java.util.EventObject;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//其他出库申请单(单据取消)
|
||||
|
||||
public class OtherOutApplyListPlugin extends AbstractListPlugin {
|
||||
|
|
@ -139,6 +141,9 @@ public class OtherOutApplyListPlugin extends AbstractListPlugin {
|
|||
entityName = "WMS-GZ-其他出库申请单取消";
|
||||
message = BillCloseCancelUtils.BGCloseOtherVouchOut(billNo, GZURL, entityType, entityName, label, orderType);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
|||
|
||||
import java.util.EventObject;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//采购退货申请单(单据取消)
|
||||
|
||||
public class PmPurRefundApplyBillPlugin extends AbstractBillPlugIn {
|
||||
|
|
@ -86,6 +88,9 @@ public class PmPurRefundApplyBillPlugin extends AbstractBillPlugIn {
|
|||
message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import java.util.EventObject;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//采购退货申请单(单据取消)
|
||||
|
||||
public class PmPurRefundApplyListPlugin extends AbstractListPlugin {
|
||||
|
|
@ -119,6 +121,9 @@ public class PmPurRefundApplyListPlugin extends AbstractListPlugin {
|
|||
message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
|||
|
||||
import java.util.EventObject;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//收货通知单(单据取消)
|
||||
|
||||
public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn {
|
||||
|
|
@ -74,7 +76,7 @@ public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn {
|
|||
}
|
||||
String orderType = "CGRK";
|
||||
entityName = "WMS-SH-收货通知单取消";
|
||||
message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
} else if ("BJLC".equals(number)) {
|
||||
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
|
||||
entityName = "WMS-BJ-收货通知单取消";
|
||||
|
|
@ -86,6 +88,9 @@ public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn {
|
|||
message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import java.util.EventObject;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//收货通知单(单据取消)
|
||||
|
||||
public class PmReceiptNoticeListPlugin extends AbstractListPlugin {
|
||||
|
|
@ -108,7 +110,7 @@ public class PmReceiptNoticeListPlugin extends AbstractListPlugin {
|
|||
}
|
||||
String orderType = "CGRK";
|
||||
entityName = "WMS-SH-收货通知单取消";
|
||||
message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, billNo, entityType, entityName, label);
|
||||
} else if ("BJLC".equals(number)) {
|
||||
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
|
||||
entityName = "WMS-BJ-收货通知单取消";
|
||||
|
|
@ -120,6 +122,9 @@ public class PmReceiptNoticeListPlugin extends AbstractListPlugin {
|
|||
message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
|||
|
||||
import java.util.EventObject;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//发货通知单(单据取消)
|
||||
|
||||
public class SmDeliverNoticeBillPlugin extends AbstractBillPlugIn {
|
||||
|
|
@ -82,6 +84,9 @@ public class SmDeliverNoticeBillPlugin extends AbstractBillPlugIn {
|
|||
message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import java.util.EventObject;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
|
||||
|
||||
//发货通知单(单据取消)
|
||||
|
||||
public class SmDeliverNoticeListPlugin extends AbstractListPlugin {
|
||||
|
|
@ -113,7 +115,9 @@ public class SmDeliverNoticeListPlugin extends AbstractListPlugin {
|
|||
String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL");
|
||||
entityName = "WMS-GZ-发货通知单取消";
|
||||
message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, GZURL, entityType, entityName, label);
|
||||
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
|
||||
cloneOperation(dataEntity);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
this.getView().showMessage(String.valueOf(message));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class BillCloseCancelUtils {
|
|||
|
||||
|
||||
/**
|
||||
* 通天晓单据取消接口
|
||||
* 通天晓单据取消接口-出库调用
|
||||
*
|
||||
* @param orderType 单据类型
|
||||
* @param warehouseCode 仓库编号
|
||||
|
|
@ -267,7 +267,7 @@ public class BillCloseCancelUtils {
|
|||
|
||||
|
||||
/**
|
||||
* 通天晓单据部分关闭
|
||||
* 通天晓单据部分关闭-入库调用
|
||||
*
|
||||
* @param orderType 单据类型
|
||||
* @param warehouseCode 仓库编号
|
||||
|
|
|
|||
Loading…
Reference in New Issue