| | |
| | | import com.sap.conn.jco.JCoRepository; |
| | | import com.sap.conn.jco.JCoTable; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.aspect.annotation.ApiLog; |
| | | import org.jeecg.common.constant.ApiLogCategoryEnum; |
| | | import org.jeecg.config.sap.SapRfcConnectionManager; |
| | |
| | | @Service |
| | | @Slf4j |
| | | public class ProductionOrderSyncImpl implements ProductionOrderSync { |
| | | //新火炬工厂编码 |
| | | private static final String factoryCode = "2301"; |
| | | //标准生产订单 |
| | | private static final String orderTypeCode1 = "Z001"; |
| | | //返工订单 暂时不用 |
| | | private static final String orderTypeCode2 = "Z002"; |
| | | //八分厂调度员 |
| | | // private static final String productionManager = "012"; |
| | | private static final String productionManager = "010"; |
| | | //生产订单状态 CRTD 新建,REL 下达,TECO 关闭 实际上,只有REL状态的工单才可以进行操作 |
| | | private static final String orderStatus = "REL"; |
| | | |
| | | @Autowired |
| | | private SapRfcConnectionManager connectionManager; |
| | | |
| | | |
| | | @Override |
| | | @ApiLog(apiName = "生产订单同步接口(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP) |
| | | public Map<String, Object> syncProductionOrder() throws Exception { |
| | | @ApiLog(apiName = "生产订单同步(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP) |
| | | public Map<String, Object> syncProductionOrder(String factoryCode, String orderTypeCode, String productionManager, String orderStatus, String createTime, String updateTime) 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<>(); |
| | | //订单类型 标准生产订单 |
| | | JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART"); |
| | | AUARTTable.appendRow(); |
| | | AUARTTable.setValue("AUART", orderTypeCode1); |
| | | //组装请求参数 |
| | | JSONObject item1 = new JSONObject(); |
| | | item1.put("AUART", orderTypeCode1); |
| | | items.add(item1); |
| | | //八分厂调度 |
| | | JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR"); |
| | | FEVORTable.appendRow(); |
| | | FEVORTable.setValue("FEVOR", productionManager); |
| | | //组装请求参数 |
| | | JSONObject item2 = new JSONObject(); |
| | | item2.put("FEVOR", productionManager); |
| | | items.add(item2); |
| | | //新火炬 |
| | | JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS"); |
| | | WERKSTable.appendRow(); |
| | | WERKSTable.setValue("WERKS", factoryCode); |
| | | //组装请求参数 |
| | | JSONObject item3 = new JSONObject(); |
| | | item3.put("WERKS", factoryCode); |
| | | items.add(item3); |
| | | //订单状态 |
| | | JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04"); |
| | | TXT04Table.appendRow(); |
| | | TXT04Table.setValue("TXT04", orderStatus); |
| | | //组装请求参数 |
| | | JSONObject item4 = new JSONObject(); |
| | | item4.put("TXT04", orderStatus); |
| | | items.add(item4); |
| | | if(StringUtils.isNotBlank(orderTypeCode)){ |
| | | JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART"); |
| | | String[] split = orderTypeCode.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)){ |
| | | JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR"); |
| | | String[] split = productionManager.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)){ |
| | | //新火炬 |
| | | JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS"); |
| | | String[] split = factoryCode.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)) { |
| | | //新火炬 |
| | | JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04"); |
| | | String[] split = orderStatus.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(createTime)){ |
| | | JCoTable UDATETable = function.getTableParameterList().getTable("ZTAB_UDATE"); |
| | | UDATETable.appendRow(); |
| | | UDATETable.setValue("LOW", createTime); |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("ZTAB_UDATE_LOW", createTime); |
| | | items.add(item); |
| | | } |
| | | if(StringUtils.isNotBlank(updateTime)){ |
| | | JCoTable LAEDATable = function.getTableParameterList().getTable("ZTAB_LAEDA"); |
| | | LAEDATable.appendRow(); |
| | | LAEDATable.setValue("LOW", updateTime); |
| | | //组装请求参数 |
| | | JSONObject item = new JSONObject(); |
| | | item.put("ZTAB_LAEDA_LOW", updateTime); |
| | | items.add(item); |
| | | } |
| | | // 执行调用 |
| | | function.execute(destination); |
| | | //获取返回结果 |