| | |
| | | package org.jeecg.modules.sap.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.sap.conn.jco.JCoDestination; |
| | | import com.sap.conn.jco.JCoFunction; |
| | | import com.sap.conn.jco.JCoRepository; |
| | |
| | | import org.jeecg.config.sap.SapRfcConnectionManager; |
| | | import org.jeecg.modules.sap.FunctionConst; |
| | | import org.jeecg.modules.sap.dto.ProductionOrderDTO; |
| | | import org.jeecg.modules.sap.request.ProductionOrderSyncRequest; |
| | | import org.jeecg.modules.sap.service.ProductionOrderSync; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Override |
| | | @ApiLog(apiName = "生产订单同步(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP) |
| | | public Map<String, Object> syncProductionOrder(String factoryCode, String orderTypeCode, String productionManager, String orderStatus, String createTimeLow, String createTimeHigh, String updateTimeLow, String updateTimeHigh) throws Exception { |
| | | public Map<String, Object> syncProductionOrder(ProductionOrderSyncRequest request) throws Exception { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | JCoDestination destination = connectionManager.getDestination(); |
| | | JCoRepository repository = destination.getRepository(); |
| | |
| | | } |
| | | // 设置输入参数 |
| | | //订单号查询条件 |
| | | // JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(request.getOrderCode())) { |
| | | JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); |
| | | String[] split = request.getOrderCode().split(","); |
| | | for (String code : split) { |
| | | AUFNRTable.appendRow(); |
| | | AUFNRTable.setValue("AUFNR", code); |
| | | } |
| | | } |
| | | //订单类型 标准生产订单 |
| | | if(StringUtils.isNotBlank(orderTypeCode)){ |
| | | if (StringUtils.isNotBlank(request.getOrderTypeCode())) { |
| | | JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART"); |
| | | String[] split = orderTypeCode.split(","); |
| | | for(String code : split){ |
| | | String[] split = request.getOrderTypeCode().split(","); |
| | | for (String code : split) { |
| | | AUARTTable.appendRow(); |
| | | AUARTTable.setValue("AUART", code); |
| | | } |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("AUART", orderTypeCode); |
| | | items.add(item); |
| | | } |
| | | if(StringUtils.isNotBlank(productionManager)){ |
| | | if (StringUtils.isNotBlank(request.getProductionManager())) { |
| | | JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR"); |
| | | String[] split = productionManager.split(","); |
| | | for(String code : split){ |
| | | String[] split = request.getProductionManager().split(","); |
| | | for (String code : split) { |
| | | FEVORTable.appendRow(); |
| | | FEVORTable.setValue("FEVOR", code); |
| | | } |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("FEVOR", productionManager); |
| | | items.add(item); |
| | | } |
| | | if(StringUtils.isNotBlank(factoryCode)){ |
| | | if (StringUtils.isNotBlank(request.getFactoryCode())) { |
| | | //新火炬 |
| | | JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS"); |
| | | String[] split = factoryCode.split(","); |
| | | for(String code : split){ |
| | | String[] split = request.getFactoryCode().split(","); |
| | | for (String code : split) { |
| | | WERKSTable.appendRow(); |
| | | WERKSTable.setValue("WERKS", code); |
| | | } |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("WERKS", factoryCode); |
| | | items.add(item); |
| | | } |
| | | if(StringUtils.isNotBlank(orderStatus)) { |
| | | if (StringUtils.isNotBlank(request.getOrderStatus())) { |
| | | //新火炬 |
| | | JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04"); |
| | | String[] split = orderStatus.split(","); |
| | | for(String code : split){ |
| | | String[] split = request.getOrderStatus().split(","); |
| | | for (String code : split) { |
| | | TXT04Table.appendRow(); |
| | | TXT04Table.setValue("TXT04", code); |
| | | } |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("TXT04", orderStatus); |
| | | items.add(item); |
| | | } |
| | | if(StringUtils.isNotBlank(createTimeLow)){ |
| | | if (StringUtils.isNotBlank(request.getCreateTimeLow())) { |
| | | JCoTable UDATETable = function.getTableParameterList().getTable("ZTAB_UDATE"); |
| | | UDATETable.appendRow(); |
| | | UDATETable.setValue("LOW", createTimeLow); |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("ZTAB_UDATE_LOW", createTimeLow); |
| | | items.add(item); |
| | | UDATETable.setValue("LOW", request.getCreateTimeLow()); |
| | | } |
| | | if(StringUtils.isNotBlank(createTimeHigh)){ |
| | | if (StringUtils.isNotBlank(request.getCreateTimeHigh())) { |
| | | JCoTable UDATETable = function.getTableParameterList().getTable("ZTAB_UDATE"); |
| | | UDATETable.appendRow(); |
| | | UDATETable.setValue("HIGH", createTimeHigh); |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("ZTAB_UDATE_HIGH", createTimeHigh); |
| | | items.add(item); |
| | | UDATETable.setValue("HIGH", request.getCreateTimeHigh()); |
| | | } |
| | | if(StringUtils.isNotBlank(updateTimeLow)){ |
| | | if (StringUtils.isNotBlank(request.getUpdateTimeLow())) { |
| | | JCoTable LAEDATable = function.getTableParameterList().getTable("ZTAB_LAEDA"); |
| | | LAEDATable.appendRow(); |
| | | LAEDATable.setValue("LOW", updateTimeLow); |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("ZTAB_LAEDA_LOW", updateTimeLow); |
| | | items.add(item); |
| | | LAEDATable.setValue("LOW", request.getUpdateTimeLow()); |
| | | } |
| | | if(StringUtils.isNotBlank(updateTimeHigh)){ |
| | | if (StringUtils.isNotBlank(request.getUpdateTimeHigh())) { |
| | | JCoTable LAEDATable = function.getTableParameterList().getTable("ZTAB_LAEDA"); |
| | | LAEDATable.appendRow(); |
| | | LAEDATable.setValue("HIGH", updateTimeLow); |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("ZTAB_LAEDA_HIGH", updateTimeLow); |
| | | items.add(item); |
| | | LAEDATable.setValue("HIGH", request.getUpdateTimeHigh()); |
| | | } |
| | | // 执行调用 |
| | | function.execute(destination); |
| | |
| | | } |
| | | resultMap.put("zmess", zmess); |
| | | resultMap.put("ztype", ztype); |
| | | resultMap.put("importParameters", items); |
| | | resultMap.put("importParameters", request); |
| | | resultMap.put("result", resultList); |
| | | return resultMap; |
| | | } |