diff --git a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java new file mode 100644 index 0000000..f7b5ddb --- /dev/null +++ b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java @@ -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 + + // + // + //仓库编码, string (50),必填 ,统仓统配等无需ERP指定仓储编码的情况填OTHER + //货主编码, string (50) + //单据编码, string (50) ,必填 + //仓储系统单据编码, string (50) ,条件必填 + //单据类型, JYCK= 一般交易出库单,HHCK= 换货出库 ,BFCK= 补发出库 PTCK=普通出库单,DBCK=调拨出库 ,B2BRK=B2B入库,B2BCK=B2B出库,QTCK=其他出库, SCRK=生产入库,LYRK=领用入库,CCRK=残次品入库,CGRK=采购入库 ,DBRK= 调拨入库 ,QTRK= 其他入库 ,XTRK= 销退入库,THRK=退货入库,HHRK= 换货入库 ,CNJG= 仓内加工单 ,CGTH=采购退货出库单 + //取消原因, string (500) + // + + @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}); + } + + } + + + } + } + } +} diff --git a/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java b/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java new file mode 100644 index 0000000..f626d26 --- /dev/null +++ b/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java @@ -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 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 finalMap = new HashMap<>(); + finalMap.put("request", request); + StringBuilder xmlBuilder = new StringBuilder(); + xmlBuilder.append("\n"); + HttpRequestUtils.buildXml(xmlBuilder, finalMap, 0); + ttx_mainUrl = ttx_mainUrl + "?method=" + method + "&v=2.0&format=xml&customerId=" + ttx_customerId; + Map 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 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; + } + + +}