收货通知单据取消
This commit is contained in:
parent
d463687681
commit
3569383da8
|
|
@ -0,0 +1,101 @@
|
||||||
|
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.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.servicehelper.operation.SaveServiceHelper;
|
||||||
|
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 PmReceiptNoticeListPlugin extends AbstractListPlugin {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerListener(EventObject e) {
|
||||||
|
super.registerListener(e);
|
||||||
|
//标准单据列表模板为bos_list,需使用该模板中的控件标识(如工具栏标识toolbarap)进行监听。
|
||||||
|
// 列表插件继承AbstractListPlugin时,底层已默认注册工具栏监听,无需重复注册
|
||||||
|
}
|
||||||
|
|
||||||
|
//order.cancel
|
||||||
|
|
||||||
|
//<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
//<request>
|
||||||
|
//<warehouseCode>仓库编码, string (50),必填 ,统仓统配等无需ERP指定仓储编码的情况填OTHER</warehouseCode>
|
||||||
|
//<ownerCode>货主编码, string (50) </ownerCode>
|
||||||
|
//<orderCode>单据编码, string (50) ,必填</orderCode>
|
||||||
|
//<orderId>仓储系统单据编码, string (50) ,条件必填 </orderId>
|
||||||
|
//<orderType>单据类型, JYCK= 一般交易出库单,HHCK= 换货出库 ,BFCK= 补发出库 PTCK=普通出库单,DBCK=调拨出库 ,B2BRK=B2B入库,B2BCK=B2B出库,QTCK=其他出库, SCRK=生产入库,LYRK=领用入库,CCRK=残次品入库,CGRK=采购入库 ,DBRK= 调拨入库 ,QTRK= 其他入库 ,XTRK= 销退入库,THRK=退货入库,HHRK= 换货入库 ,CNJG= 仓内加工单 ,CGTH=采购退货出库单</orderType>
|
||||||
|
//<cancelReason>取消原因, string (500) </cancelReason>
|
||||||
|
//</request>
|
||||||
|
|
||||||
|
@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();
|
||||||
|
for (ListSelectedRow selectedRow : selectedRows) {
|
||||||
|
String billNo = selectedRow.getBillNo();
|
||||||
|
//
|
||||||
|
String method = null;//接口方法名
|
||||||
|
String message = null;
|
||||||
|
DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_receiptnotice", "id,billno,receiveorg,billentry.warehouse,tqq9_isclose,tqq9_cancelresult,tqq9_cancelresult_tag",
|
||||||
|
new QFilter[]{new QFilter("billno", QCP.equals, billNo)});
|
||||||
|
|
||||||
|
DynamicObject receiveorg = dataEntity.getDynamicObject("receiveorg");//收货组织
|
||||||
|
if (null != receiveorg) {
|
||||||
|
String number = receiveorg.getString("number");
|
||||||
|
if ("SHLC".equals(number)) {
|
||||||
|
DynamicObjectCollection billentry = dataEntity.getDynamicObjectCollection("billentry");
|
||||||
|
String warehouseCode = null;
|
||||||
|
for (DynamicObject dynamicObject : billentry) {
|
||||||
|
DynamicObject warehouse = dynamicObject.getDynamicObject("warehouse");
|
||||||
|
if (null != warehouse) {
|
||||||
|
warehouseCode = warehouse.getString("number");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String orderType = "CGRK";
|
||||||
|
message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo);
|
||||||
|
this.getView().showMessage(message);
|
||||||
|
} else if ("BJLC".equals(number)) {
|
||||||
|
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
|
||||||
|
message = BillCloseCancelUtils.BGPurOrderCancel(billNo, BJ_URL);
|
||||||
|
|
||||||
|
} else if ("GZLC".equals(number)) {
|
||||||
|
String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL");
|
||||||
|
message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(message)) {
|
||||||
|
this.getView().showMessage(String.valueOf(message));
|
||||||
|
dataEntity.set("tqq9_cancelresult", message);
|
||||||
|
dataEntity.set("tqq9_cancelresult_tag", message);
|
||||||
|
if (message.contains("成功") || message.equalsIgnoreCase("success")) {
|
||||||
|
dataEntity.set("tqq9_isclose", true);
|
||||||
|
}else {
|
||||||
|
dataEntity.set("tqq9_isclose", false);
|
||||||
|
}
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
package tqq9.lc123.cloud.app.plugin.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import kd.bos.util.StringUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
//北广、通天晓关闭、取消、接口
|
||||||
|
public class BillCloseCancelUtils {
|
||||||
|
static String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL");//广州接口地址
|
||||||
|
static String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");//北京接口地址
|
||||||
|
static String ttx_mainUrl = ConfigUtils.getThirdConfigByNumber("Ttx_MainURL");//通天晓接口地址
|
||||||
|
static String ttx_customerId = ConfigUtils.getThirdConfigByNumber("Ttx_CustomerId");//通天晓客户id
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通天晓单据取消接口
|
||||||
|
*
|
||||||
|
* @param orderType 单据类型
|
||||||
|
* @param warehouseCode 仓库编号
|
||||||
|
* @param billNo 单据编号
|
||||||
|
* @return 取消结果
|
||||||
|
*/
|
||||||
|
public static String wmsCancel(String orderType, String warehouseCode, String billNo) {
|
||||||
|
String method = "order.cancel";
|
||||||
|
String message = null;
|
||||||
|
Map<String, Object> request = new HashMap<>();
|
||||||
|
request.put("warehouseCode", warehouseCode);
|
||||||
|
request.put("ownerCode", "LICHI");
|
||||||
|
request.put("orderCode", billNo);
|
||||||
|
request.put("orderId", "");
|
||||||
|
request.put("orderType", orderType);
|
||||||
|
request.put("cancelReason", "");
|
||||||
|
Map<String, Object> finalMap = new HashMap<>();
|
||||||
|
finalMap.put("request", request);
|
||||||
|
StringBuilder xmlBuilder = new StringBuilder();
|
||||||
|
xmlBuilder.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||||
|
HttpRequestUtils.buildXml(xmlBuilder, finalMap, 0);
|
||||||
|
ttx_mainUrl = ttx_mainUrl + "?method=" + method + "&v=2.0&format=xml&customerId=" + ttx_customerId;
|
||||||
|
Map<String, String> headMap = new HashMap<>();
|
||||||
|
try {
|
||||||
|
String result = HttpRequestUtils.postXml(ttx_mainUrl, xmlBuilder.toString(), headMap);
|
||||||
|
if (StringUtils.isNotEmpty(result)) {
|
||||||
|
JSONObject jsonObject = HttpRequestUtils.xmlToJson(result);
|
||||||
|
JSONObject response = jsonObject.getJSONObject("response");
|
||||||
|
String flag = response.getString("flag");
|
||||||
|
String code = response.getString("code");
|
||||||
|
message = response.getString("message");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (
|
||||||
|
IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 北广 收货通知单关闭(采购订单关闭)
|
||||||
|
*
|
||||||
|
* @param billNo 单据编号
|
||||||
|
* @param url 接口地址,北京还是广州
|
||||||
|
* @return 关闭结果
|
||||||
|
*/
|
||||||
|
public static String BGPurOrderCancel(String billNo, String url) {
|
||||||
|
String message = null;
|
||||||
|
String method = "/api/PU/Close_PurOrder";
|
||||||
|
// String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
|
||||||
|
Map<String, Object> bj_map = new HashMap<>();
|
||||||
|
bj_map.put("cPOCode", 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"));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue