diff --git a/lc123/cloud/app/plugin/form/result/OtherInApplyFormPlugin.java b/lc123/cloud/app/plugin/form/result/OtherInApplyFormPlugin.java new file mode 100644 index 0000000..a2d9b9b --- /dev/null +++ b/lc123/cloud/app/plugin/form/result/OtherInApplyFormPlugin.java @@ -0,0 +1,97 @@ +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.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 OtherInApplyFormPlugin extends AbstractBillPlugIn { + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + this.addItemClickListeners("tbmain"); + + } + + + @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("tqq9_otherinapply", + "id,billno,org,billentry.warehouse,biztype", + new QFilter[]{new QFilter("billno", QCP.equals, billNo)}); + + String entityType = "tqq9_otherinapply"; + String entityName; + String label = ""; + 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("warehouse"); + if (null != warehouse) { + warehouseCode = warehouse.getString("number"); + } + } + String orderType;// + DynamicObject biztype = dataEntity.getDynamicObject("biztype"); + String biztypeNumber = biztype.getString("number"); + switch (biztypeNumber) { + case "350": + orderType = "PYRK"; + break; + case "605": + orderType = "DBRK"; + break; + case "606": + orderType = "ZPRK"; + break; + default: + orderType = "TZRK"; + break; + } + + label = "tqq9_isclosesh"; + entityName = "WMS-SH-其他入库申请单取消"; + message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + } else if ("BJLC".equals(number)) { + String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); + label = "tqq9_isclosebj"; + entityName = "WMS-BJ-其他入库申请单取消"; + message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, BJ_URL, entityType, entityName, label); + + } else if ("GZLC".equals(number)) { + String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL"); + label = "tqq9_isclosegz"; + entityName = "WMS-GZ-其他入库申请单取消"; + message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, GZURL, entityType, entityName, label); + + } + if (StringUtils.isNotEmpty(message)) { + this.getView().showMessage(String.valueOf(message)); + } + + } + + } + } +} diff --git a/lc123/cloud/app/plugin/form/result/OtherInApplyListPlugin.java b/lc123/cloud/app/plugin/form/result/OtherInApplyListPlugin.java new file mode 100644 index 0000000..ae05edd --- /dev/null +++ b/lc123/cloud/app/plugin/form/result/OtherInApplyListPlugin.java @@ -0,0 +1,108 @@ +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.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 OtherInApplyListPlugin extends AbstractListPlugin { + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + //标准单据列表模板为bos_list,需使用该模板中的控件标识(如工具栏标识toolbarap)进行监听。 + // 列表插件继承AbstractListPlugin时,底层已默认注册工具栏监听,无需重复注册 + } + + + @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 billnoList = selectedRows.stream().map(ListSelectedRow::getBillNo).distinct().collect(Collectors.toList()); + for (String billNo : billnoList) { + String message = null; + DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("tqq9_otherinapply", "id,billno,org,billentry.warehouse,biztype", + new QFilter[]{new QFilter("billno", QCP.equals, billNo)}); + + String entityType = "tqq9_otherinapply"; + String entityName; + String label = ""; + 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("warehouse"); + if (null != warehouse) { + warehouseCode = warehouse.getString("number"); + } + } + + String orderType;// + DynamicObject biztype = dataEntity.getDynamicObject("biztype"); + String biztypeNumber = biztype.getString("number"); + switch (biztypeNumber) { + case "350": + orderType = "PYRK"; + break; + case "605": + orderType = "DBRK"; + break; + case "606": + orderType = "ZPRK"; + break; + default: + orderType = "TZRK"; + break; + } + + label = "tqq9_isclosesh"; + entityName = "WMS-SH-其他入库申请单取消"; + message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + } else if ("BJLC".equals(number)) { + String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); + label = "tqq9_isclosebj"; + entityName = "WMS-BJ-其他入库申请单取消"; + message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, BJ_URL, entityType, entityName, label); + + } else if ("GZLC".equals(number)) { + String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL"); + label = "tqq9_isclosegz"; + entityName = "WMS-GZ-其他入库申请单取消"; + message = BillCloseCancelUtils.BGCloseOtherVouchIn(billNo, GZURL, entityType, entityName, label); + + } + if (StringUtils.isNotEmpty(message)) { + this.getView().showMessage(String.valueOf(message)); + + } + + } + + } + + } + } +} diff --git a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java index 6a7ba14..ecbd2b3 100644 --- a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java +++ b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeFormPlugin.java @@ -7,7 +7,6 @@ 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.servicehelper.operation.SaveServiceHelper; import kd.bos.util.StringUtils; import tqq9.lc123.cloud.app.plugin.utils.BillCloseCancelUtils; import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; @@ -23,21 +22,9 @@ public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn { public void registerListener(EventObject e) { super.registerListener(e); this.addItemClickListeners("tbmain"); - //标准单据列表模板为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) { @@ -45,12 +32,13 @@ public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn { String itemKey = evt.getItemKey(); if ("tqq9_close".equals(itemKey)) { String billNo = (String) this.getModel().getValue("billno"); - // - String method = null;//接口方法名 String message = null; - DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_receiptnotice", "id,billno,receiveorg,billentry.warehouse,tqq9_isclose,tqq9_cancelresult,tqq9_cancelresult_tag", + DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_receiptnotice", "id,billno,receiveorg,billentry.warehouse", new QFilter[]{new QFilter("billno", QCP.equals, billNo)}); + String entityType = "pm_receiptnotice"; + String entityName; + String label = ""; DynamicObject receiveorg = dataEntity.getDynamicObject("receiveorg");//收货组织 if (null != receiveorg) { String number = receiveorg.getString("number"); @@ -64,27 +52,25 @@ public class PmReceiptNoticeFormPlugin extends AbstractBillPlugIn { } } String orderType = "CGRK"; - message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo); - this.getView().showMessage(message); + label = "tqq9_isclosesh"; + entityName = "WMS-SH-收货通知单取消"; + message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); } else if ("BJLC".equals(number)) { String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); - message = BillCloseCancelUtils.BGPurOrderCancel(billNo, BJ_URL); + label = "tqq9_isclosebj"; + entityName = "WMS-BJ-收货通知单取消"; + message = BillCloseCancelUtils.BGPurOrderCancel(billNo, BJ_URL, entityType, entityName, label); } else if ("GZLC".equals(number)) { String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL"); - message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL); + label = "tqq9_isclosegz"; + entityName = "WMS-GZ-收货通知单取消"; + message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL, entityType, entityName, label); } 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/form/result/PmReceiptNoticeListPlugin.java b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java index f7b5ddb..0b08ff5 100644 --- a/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java +++ b/lc123/cloud/app/plugin/form/result/PmReceiptNoticeListPlugin.java @@ -10,12 +10,13 @@ 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; +import java.util.List; +import java.util.stream.Collectors; //收货通知单(单据取消) @@ -29,17 +30,6 @@ public class PmReceiptNoticeListPlugin extends AbstractListPlugin { // 列表插件继承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) { @@ -48,14 +38,15 @@ public class PmReceiptNoticeListPlugin extends AbstractListPlugin { 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;//接口方法名 + List billnoList = selectedRows.stream().map(ListSelectedRow::getBillNo).distinct().collect(Collectors.toList()); + for (String billNo : billnoList) { String message = null; - DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_receiptnotice", "id,billno,receiveorg,billentry.warehouse,tqq9_isclose,tqq9_cancelresult,tqq9_cancelresult_tag", + DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("pm_receiptnotice", "id,billno,receiveorg,billentry.warehouse", new QFilter[]{new QFilter("billno", QCP.equals, billNo)}); + String entityType = "pm_receiptnotice"; + String entityName; + String label = ""; DynamicObject receiveorg = dataEntity.getDynamicObject("receiveorg");//收货组织 if (null != receiveorg) { String number = receiveorg.getString("number"); @@ -69,33 +60,31 @@ public class PmReceiptNoticeListPlugin extends AbstractListPlugin { } } String orderType = "CGRK"; - message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo); - this.getView().showMessage(message); + label = "tqq9_isclosesh"; + entityName = "WMS-SH-收货通知单取消"; + message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); } else if ("BJLC".equals(number)) { String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); - message = BillCloseCancelUtils.BGPurOrderCancel(billNo, BJ_URL); + label = "tqq9_isclosebj"; + entityName = "WMS-BJ-收货通知单取消"; + message = BillCloseCancelUtils.BGPurOrderCancel(billNo, BJ_URL, entityType, entityName, label); } else if ("GZLC".equals(number)) { String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL"); - message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL); + label = "tqq9_isclosegz"; + entityName = "WMS-GZ-收货通知单取消"; + message = BillCloseCancelUtils.BGPurOrderCancel(billNo, GZURL, entityType, entityName, label); } 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 index f626d26..f8a9251 100644 --- a/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java +++ b/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import kd.bos.util.StringUtils; +import tqq9.lc123.cloud.app.eip.iscb.impl.LCLogServiceImpl; import java.io.IOException; import java.util.HashMap; @@ -12,10 +13,7 @@ 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 + /** @@ -24,9 +22,12 @@ public class BillCloseCancelUtils { * @param orderType 单据类型 * @param warehouseCode 仓库编号 * @param billNo 单据编号 + * @param entityType 单据标识 + * @param entityName 单据名称 + * @param label 推送标识 * @return 取消结果 */ - public static String wmsCancel(String orderType, String warehouseCode, String billNo) { + public static String wmsCancel(String orderType, String warehouseCode, String billNo,String entityType,String entityName,String label) { String method = "order.cancel"; String message = null; Map request = new HashMap<>(); @@ -41,6 +42,8 @@ public class BillCloseCancelUtils { StringBuilder xmlBuilder = new StringBuilder(); xmlBuilder.append("\n"); HttpRequestUtils.buildXml(xmlBuilder, finalMap, 0); + String ttx_mainUrl = ConfigUtils.getThirdConfigByNumber("Ttx_MainURL"); + String ttx_customerId = ConfigUtils.getThirdConfigByNumber("Ttx_CustomerId"); ttx_mainUrl = ttx_mainUrl + "?method=" + method + "&v=2.0&format=xml&customerId=" + ttx_customerId; Map headMap = new HashMap<>(); try { @@ -52,15 +55,22 @@ public class BillCloseCancelUtils { String code = response.getString("code"); message = response.getString("message"); + LCLogServiceImpl lcLogService = new LCLogServiceImpl(); + lcLogService.savelog(entityName,ttx_mainUrl,true, code.equals("200"),xmlBuilder.toString(),result); + lcLogService.isSuccess(entityType,billNo,"billno",label,code.equals("200")); } } catch ( IOException e) { throw new RuntimeException(e); } + + return message; + + } /** @@ -68,14 +78,16 @@ public class BillCloseCancelUtils { * * @param billNo 单据编号 * @param url 接口地址,北京还是广州 + * @param entityType 单据标识 + * @param entityName 单据名称 + * @param label 推送标识 * @return 关闭结果 */ - public static String BGPurOrderCancel(String billNo, String url) { + public static String BGPurOrderCancel(String billNo, String url,String entityType,String entityName,String label) { 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);//成产商 + bj_map.put("cPOCode", billNo); String bjjsonBody = JSON.toJSONString(bj_map); try { String result = HttpRequestUtils.postJson(url + method, bjjsonBody, null); @@ -83,12 +95,50 @@ public class BillCloseCancelUtils { 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; } + /** + * 北广 其他入库申请单取消 + * + * @param billNo 单据编号 + * @param url 接口地址,北京还是广州 + * @param entityType 单据标识 + * @param entityName 单据名称 + * @param label 推送标识 + * @return 关闭结果 + */ + public static String BGCloseOtherVouchIn(String billNo, String url,String entityType,String entityName,String label) { + String message = null; + String method = "/api/WMS/Close_OtherVouchIn"; + Map bj_map = new HashMap<>(); + bj_map.put("cOVCode", 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; + } }