| | |
| | | import com.vincent.rsf.server.api.controller.erp.params.InOutResultReportParam; |
| | | import com.vincent.rsf.server.api.controller.erp.params.InventoryAdjustReportParam; |
| | | import com.vincent.rsf.server.api.service.CloudWmsReportService; |
| | | import com.vincent.rsf.server.manager.constant.CloudWmsInoutReportMode; |
| | | import com.vincent.rsf.server.manager.entity.CloudWmsNotifyLog; |
| | | import com.vincent.rsf.server.manager.service.CloudWmsNotifyLogService; |
| | | import com.vincent.rsf.server.system.constant.GlobalConfigCode; |
| | |
| | | return s != null && s != 0; |
| | | } |
| | | |
| | | /** CLOUD_WMS_INOUT_REPORT_MODE,缺省 immediate */ |
| | | private String resolveInOutReportMode() { |
| | | try { |
| | | Config cfg = configService.getCachedOrLoad(GlobalConfigCode.CLOUD_WMS_INOUT_REPORT_MODE); |
| | | if (cfg != null && cfg.getVal() != null) { |
| | | String v = cfg.getVal().trim(); |
| | | if (!v.isEmpty()) { |
| | | return v.toLowerCase(); |
| | | } |
| | | } |
| | | } catch (Exception ignored) { |
| | | } |
| | | return CloudWmsInoutReportMode.IMMEDIATE; |
| | | } |
| | | |
| | | /** 同单多条合并上报 */ |
| | | private void dispatchPending(List<CloudWmsNotifyLog> pending) { |
| | | int rowsReported = 0; |
| | |
| | | log.debug("云仓上报派发:读取上报类型配置"); |
| | | String rtInOut = cloudWmsNotifyLogService.getReportTypeInOutResult(); |
| | | log.debug("云仓上报派发:上报类型={},读配置耗时 {} ms", rtInOut, System.currentTimeMillis() - tCfg); |
| | | String inoutMode = resolveInOutReportMode(); |
| | | boolean singleRowOnly = CloudWmsInoutReportMode.SINGLE.equals(inoutMode); |
| | | if (singleRowOnly) { |
| | | log.debug("云仓上报派发:入出库模式 single,不合并同单多条"); |
| | | } |
| | | LinkedHashMap<String, List<CloudWmsNotifyLog>> inOutGroups = new LinkedHashMap<>(); |
| | | int n = pending.size(); |
| | | for (int i = 0; i < n; i++) { |
| | |
| | | if (key == null) { |
| | | continue; |
| | | } |
| | | if (!singleRowOnly) { |
| | | inOutGroups.computeIfAbsent(key, k -> new ArrayList<>()).add(row); |
| | | } |
| | | } |
| | | log.debug("云仓上报派发:入出库可分组键 {} 个", inOutGroups.size()); |
| | | Set<Long> done = new HashSet<>(); |
| | |
| | | } |
| | | continue; |
| | | } |
| | | if (singleRowOnly) { |
| | | if (isSendingBusy(row)) { |
| | | continue; |
| | | } |
| | | log.debug("云仓上报派发:single 模式单条 id={}", rid); |
| | | if (safeProcessOne(row)) { |
| | | rowsReported++; |
| | | if (rid != null) { |
| | | done.add(rid); |
| | | } |
| | | } |
| | | continue; |
| | | } |
| | | List<CloudWmsNotifyLog> g = inOutGroups.get(key); |
| | | List<CloudWmsNotifyLog> work = new ArrayList<>(); |
| | | if (g != null) { |