采购退货申请关闭

This commit is contained in:
sez 2025-11-05 18:25:08 +08:00
parent d93069b4a0
commit 39fe6130d7
3 changed files with 236 additions and 0 deletions

View File

@ -0,0 +1,90 @@
package tqq9.lc123.cloud.app.plugin.form.result;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.util.StringUtils;
import tqq9.lc123.cloud.app.plugin.utils.BillCloseCancelUtils;
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
import java.util.EventObject;
//采购退货申请单单据取消
public class PmPurRefundApplyBillPlugin extends AbstractBillPlugIn {
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
this.addItemClickListeners("tbmain");
}
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
super.beforeItemClick(evt);
String itemKey = evt.getItemKey();
if ("tqq9_close".equals(itemKey)) {
boolean tqq9_isclose = (boolean) this.getModel().getValue("tqq9_isclose");
if (tqq9_isclose) {
this.getView().showMessage("该单据已关闭");
evt.setCancel(true);
}
}
}
@Override
public void itemClick(ItemClickEvent evt) {
super.itemClick(evt);
String itemKey = evt.getItemKey();
if ("tqq9_close".equals(itemKey)) {
String billNo = (String) this.getModel().getValue("billno");
String message = null;
DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_purrefundapplybill", "id,billno,org,billentry.tqq9_thck",
new QFilter[]{new QFilter("billno", QCP.equals, billNo)});
String entityType = "pm_purrefundapplybill";
String entityName;
String label = "tqq9_isclose";
DynamicObject org = dataEntity.getDynamicObject("org");//收货组织
if (null != org) {
String number = org.getString("number");
if ("SHLC".equals(number)) {
DynamicObjectCollection billentry = dataEntity.getDynamicObjectCollection("billentry");
String warehouseCode = null;
for (DynamicObject dynamicObject : billentry) {
DynamicObject warehouse = dynamicObject.getDynamicObject("tqq9_thck");
if (null != warehouse) {
warehouseCode = warehouse.getString("number");
}
}
String orderType = "CGTH";
entityName = "WMS-SH-收货通知单取消";
message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label);
} else if ("BJLC".equals(number)) {
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
entityName = "WMS-BJ-收货通知单取消";
message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, BJ_URL, entityType, entityName, label);
} else if ("GZLC".equals(number)) {
String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL");
entityName = "WMS-GZ-收货通知单取消";
message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, GZURL, entityType, entityName, label);
}
if (StringUtils.isNotEmpty(message)) {
this.getView().showMessage(String.valueOf(message));
}
}
}
}
}

View File

@ -0,0 +1,112 @@
package tqq9.lc123.cloud.app.plugin.form.result;
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.form.control.events.BeforeItemClickEvent;
import kd.bos.form.control.events.ItemClickEvent;
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.util.StringUtils;
import tqq9.lc123.cloud.app.plugin.utils.BillCloseCancelUtils;
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
import java.util.EventObject;
import java.util.List;
import java.util.stream.Collectors;
//采购退货申请单单据取消
public class PmPurRefundApplyListPlugin extends AbstractListPlugin {
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
//标准单据列表模板为bos_list需使用该模板中的控件标识如工具栏标识toolbarap进行监听
// 列表插件继承AbstractListPlugin时底层已默认注册工具栏监听无需重复注册
}
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
super.beforeItemClick(evt);
String itemKey = evt.getItemKey();
if ("tqq9_close".equals(itemKey)) {
BillList billList = this.getControl("billlistap");
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
List<String> billnoList = selectedRows.stream().map(ListSelectedRow::getBillNo).distinct().collect(Collectors.toList());
if (billnoList.size() > 1) {
this.getView().showMessage("请选择一张单据");
evt.setCancel(true);
return;
}
DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_purrefundapplybill", "id,billno,tqq9_isclose",
new QFilter[]{new QFilter("billno", QCP.in, billnoList)});
if (null != dataEntity) {
/* boolean tqq9_isclose = dataEntity.getBoolean("tqq9_isclose");
if (tqq9_isclose) {
this.getView().showMessage("该单据已关闭");
evt.setCancel(true);
}*/
}
}
}
@Override
public void itemClick(ItemClickEvent evt) {
super.itemClick(evt);
String itemKey = evt.getItemKey();
if ("tqq9_close".equals(itemKey)) {
BillList billList = this.getControl("billlistap");
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
List<String> billnoList = selectedRows.stream().map(ListSelectedRow::getBillNo).distinct().collect(Collectors.toList());
for (String billNo : billnoList) {
String message = null;
DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_purrefundapplybill", "id,billno,org,billentry.tqq9_thck",
new QFilter[]{new QFilter("billno", QCP.equals, billNo)});
String entityType = "pm_purrefundapplybill";
String entityName;
String label = "tqq9_isclose";
DynamicObject org = dataEntity.getDynamicObject("org");//收货组织
if (null != org) {
String number = org.getString("number");
if ("SHLC".equals(number)) {
DynamicObjectCollection billentry = dataEntity.getDynamicObjectCollection("billentry");
String warehouseCode = null;
for (DynamicObject dynamicObject : billentry) {
DynamicObject warehouse = dynamicObject.getDynamicObject("tqq9_thck");
if (null != warehouse) {
warehouseCode = warehouse.getString("number");
}
}
String orderType = "CGTH";
entityName = "WMS-SH-采购退货申请单取消";
message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label);
} else if ("BJLC".equals(number)) {
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
entityName = "WMS-BJ-采购退货申请单取消";
message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, BJ_URL, entityType, entityName, label);
} else if ("GZLC".equals(number)) {
String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL");
entityName = "WMS-GZ-采购退货申请单取消";
message = BillCloseCancelUtils.BGPuCancelPurReturn(billNo, GZURL, entityType, entityName, label);
}
if (StringUtils.isNotEmpty(message)) {
this.getView().showMessage(String.valueOf(message));
}
}
}
}
}
}

View File

@ -181,4 +181,38 @@ public class BillCloseCancelUtils {
} }
return message; return message;
} }
/**
* 北广 采购退货申请单取消采购退货拦截
*
* @param billNo 单据编号
* @param url 接口地址北京还是广州
* @param entityType 单据标识
* @param entityName 单据名称
* @param label 推送标识
* @return 关闭结果
*/
public static String BGPuCancelPurReturn(String billNo, String url, String entityType, String entityName, String label) {
String message = null;
String method = "/api/PU/Cancel_PurReturn";
Map<String, Object> bj_map = new HashMap<>();
bj_map.put("cPRCode", billNo);
String bjjsonBody = JSON.toJSONString(bj_map);
try {
String result = HttpRequestUtils.postJson(url + method, bjjsonBody, null);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(result);
if (null != rootNode) {
message = String.valueOf(rootNode.get("message"));
String code = String.valueOf(rootNode.get("code"));
LCLogServiceImpl lcLogService = new LCLogServiceImpl();
lcLogService.savelog(entityName, url, true, code.equals("0"), bjjsonBody, result);
lcLogService.isSuccess(entityType, billNo, "billno", label, code.equals("0"));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return message;
}
} }