src/main/java/org/jeecg/modules/base/controller/FactoryController.java
@@ -221,25 +221,14 @@ return result; } @ApiOperation(value = "产线表éå", notes = "产线表éå") @GetMapping(value = "/queryTreeAppList") public Result<List<FactoryModel>> queryTreeAppList() { Result<List<FactoryModel>> result = new Result<>(); try { List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>() .eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0) .orderByAsc(Factory::getSorter)); List<FactoryModel> factoryModels = factoryList.stream() .map(factory -> new FactoryModel(factory.getId(), factory.getFactoryName())) .collect(Collectors.toList()); result.setSuccess(true); result.setResult(factoryModels); } catch (Exception e) { log.error(e.getMessage(), e); } return result; @ApiOperation(value = "è·åææäº§çº¿å表", notes = "è·åææäº§çº¿å表") @GetMapping(value = "/queryProductionLineList") public Result<List<FactoryModel>> queryProductionLineList() { List<Factory> factoryList = factoryService.queryProductionLineList(); List<FactoryModel> factoryModels = factoryList.stream() .map(factory -> new FactoryModel(factory.getId(), factory.getFactoryName())) .collect(Collectors.toList()); return Result.ok(factoryModels); } src/main/java/org/jeecg/modules/base/model/FactoryModel.java
@@ -4,30 +4,15 @@ @Data public class FactoryModel { // getteråsetteræ¹æ³ private String value; // 产线ID private String text; // 产线åç§° public FactoryModel() {} public FactoryModel() { } public FactoryModel(String value, String text) { this.value = value; this.text = text; } // getteråsetteræ¹æ³ public String getValue() { return value; } public void setValue(String value) { this.value = value; } public String getText() { return text; } public void setText(String text) { this.text = text; } } src/main/java/org/jeecg/modules/base/service/IFactoryService.java
@@ -45,4 +45,10 @@ List<Factory> queryFacByPid(String pid); List<String> recursionChildren(String factoryId); /** * æ¥è¯¢æ¥è¯¢å表 * @return */ List<Factory> queryProductionLineList(); } src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java
@@ -175,6 +175,15 @@ return this.baseMapper.recursionChildren(factoryId); } @Override public List<Factory> queryProductionLineList() { LambdaQueryWrapper<Factory> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0); queryWrapper.eq(Factory::getFactoryCategory, "PRODUCTION_LINE"); queryWrapper.orderByAsc(Factory::getSorter); return super.list(queryWrapper); } /** * æå¼ ç¶èç¹ å 以ä¸çmdcæ è®° * @param parentId src/main/java/org/jeecg/modules/sap/FunctionConst.java
@@ -13,4 +13,6 @@ public static final String ZMES_GOODSMVT_CREATE_2301 = "ZMES_GOODSMVT_CREATE_2301"; //6.ç产订åå ³éæ¥å£ public static final String ZPPF_019 = "ZPPF_019"; //7.SAPé¢çå·å建æ¥å£ public static final String ZMES_RESERVATION_CREATE = "ZMES_RESERVATION_CREATE"; } src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.sap.request.MaterialRequest; import org.jeecg.modules.sap.request.OrderLoadRequest; import org.jeecg.modules.sap.request.OrderReportRequest; import org.jeecg.modules.sap.request.ProductionOrderSyncRequest; @@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @Api(tags = "SAPéææµè¯") @@ -46,6 +48,8 @@ private OrderLoadService orderLoadService; @Autowired private OrderCloseService orderCloseService; @Autowired private OrderMaterialRequestService orderMaterialRequestService; @ApiOperation(value = "SAPéææµè¯-ç产订å忥æ¥å£", notes = "SAPéææµè¯-ç产订å忥æ¥å£") @PostMapping("/syncProductionOrder") @@ -113,4 +117,12 @@ Map<String, Object> resultMap = orderCloseService.productionOrderClose(orderCode); return Result.ok(resultMap); } @ApiOperation(value = "SAPéææµè¯-ç©ææå¨", notes = "SAPéææµè¯-ç©ææå¨") @PostMapping("/orderMaterialRequest") public Result<?> orderMaterialRequest(@RequestParam(value = "factoryCode") String factoryCode, @RequestParam(value = "warehouseCode") String warehouseCode, @RequestBody List<MaterialRequest> request) throws Exception { // String orderCode = "10698749"; Map<String, Object> resultMap = orderMaterialRequestService.orderMaterialRequest(factoryCode, warehouseCode, request); return Result.ok(resultMap); } } src/main/java/org/jeecg/modules/sap/dto/MaterialRequestDTO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,13 @@ package org.jeecg.modules.sap.dto; import lombok.Data; @Data public class MaterialRequestDTO { /** æåæ è®° Y-OK N-NG */ private String O_IS_OK; /** é¢ç/ç¸å ³éæ±çç¼å· */ private String O_SAP_RESV; /** æ¶æ¯ææ¬ */ private String O_MESSAGE; } src/main/java/org/jeecg/modules/sap/request/MaterialRequest.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,16 @@ package org.jeecg.modules.sap.request; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; @Data public class MaterialRequest implements Serializable { /** ç©æå· */ private String materialNumber; /** æ°é */ private BigDecimal quantity; /** åè´§åºåå°ç¹ */ private String warehouseCode; } src/main/java/org/jeecg/modules/sap/service/OrderMaterialRequestService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,21 @@ package org.jeecg.modules.sap.service; import org.jeecg.modules.sap.request.MaterialRequest; import java.util.List; import java.util.Map; /** * ç©ææå¨ï¼é¢çå·è¯·æ± */ public interface OrderMaterialRequestService { /** * ç©ææå¨è¯·æ± * @param factoryCode å·¥åç¼ç * @param receiveWarehouseCode æ¥æ¶åºåå°ç¹ * @param request ç©ææå¨ä¿¡æ¯ * @return * @throws Exception */ Map<String, Object> orderMaterialRequest(String factoryCode, String receiveWarehouseCode, List<MaterialRequest> request) throws Exception; } src/main/java/org/jeecg/modules/sap/service/impl/OrderLoadServiceImpl.java
@@ -7,7 +7,6 @@ import org.jeecg.config.sap.SapRfcConnectionManager; import org.jeecg.modules.sap.FunctionConst; import org.jeecg.modules.sap.dto.OrderLoadDTO; import org.jeecg.modules.sap.dto.OrderReportDTO; import org.jeecg.modules.sap.request.OrderLoadRequest; import org.jeecg.modules.sap.service.OrderLoadService; import org.springframework.beans.factory.annotation.Autowired; src/main/java/org/jeecg/modules/sap/service/impl/OrderMaterialRequestServiceImpl.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,96 @@ package org.jeecg.modules.sap.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; import com.fasterxml.jackson.databind.ObjectMapper; import com.sap.conn.jco.*; 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; import org.jeecg.modules.sap.FunctionConst; import org.jeecg.modules.sap.dto.MaterialRequestDTO; import org.jeecg.modules.sap.request.MaterialRequest; import org.jeecg.modules.sap.service.OrderMaterialRequestService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Service @Slf4j public class OrderMaterialRequestServiceImpl implements OrderMaterialRequestService { @Autowired private SapRfcConnectionManager connectionManager; @Autowired private ObjectMapper objectMapper; @Override @ApiLog(apiName = "SAPé¢çå·å建(ZMES_RESERVATION_CREATE)", apiCategory = ApiLogCategoryEnum.SAP) public Map<String, Object> orderMaterialRequest(String factoryCode, String receiveWarehouseCode, List<MaterialRequest> request) throws Exception { Map<String, Object> resultMap = new HashMap<>(); JCoDestination destination = connectionManager.getDestination(); JCoRepository repository = destination.getRepository(); JCoFunction function = repository.getFunction(FunctionConst.ZMES_RESERVATION_CREATE); if (function == null) { throw new RuntimeException("RFC 彿° ZMES_RESERVATION_CREATE æªæ¾å°ï¼"); } if (StringUtils.isBlank(factoryCode) || StringUtils.isBlank(receiveWarehouseCode) || CollectionUtil.isEmpty(request)) { resultMap.put("zmess", "å·¥åç¼ç ãæ¥æ¶åºåå°ä¸ºç©ºæç©æä¿¡æ¯ä¸ºç©º"); resultMap.put("ztype", "-1"); resultMap.put("importParameters", factoryCode + "|" + receiveWarehouseCode + "|" + (request == null ? 0 : request.size())); resultMap.put("result", null); return resultMap; } // 设置è¾å ¥åæ° List<JSONObject> items = new ArrayList<>(); //æ°ç«ç¬ JCoParameterList importParameterList = function.getImportParameterList(); importParameterList.setValue("I_SITE", factoryCode); //ç»è£ 请æ±åæ° JSONObject item = new JSONObject(); item.put("I_SITE", factoryCode); items.add(item); //æ¥æ¶åºåå° importParameterList.setValue("I_TO_STORGE_LOC", receiveWarehouseCode); //ç»è£ 请æ±åæ° item = new JSONObject(); item.put("I_TO_STORGE_LOC", factoryCode); items.add(item); JCoTable itemTable = function.getTableParameterList().getTable("T_ITEMS"); for (MaterialRequest itemReq : request) { itemTable.appendRow(); itemTable.setValue("ITEM", itemReq.getMaterialNumber()); itemTable.setValue("PULL_QTY", itemReq.getQuantity()); itemTable.setValue("FROM_STORGE_LOC", itemReq.getWarehouseCode()); //ç»è£ 请æ±åæ° String json = objectMapper.writeValueAsString(itemReq); item = JSONObject.parseObject(json, Feature.OrderedField); items.add(item); } // æ§è¡è°ç¨ function.execute(destination); //è·åè¿åç»æ MaterialRequestDTO response = new MaterialRequestDTO(); String zmess = function.getExportParameterList().getValue("O_IS_OK").toString(); String ztype = function.getExportParameterList().getValue("O_MESSAGE").toString();//S æ è¯ æå String resv = function.getExportParameterList().getValue("O_SAP_RESV").toString();//S æ è¯ æå response.setO_IS_OK(ztype); response.setO_MESSAGE(zmess); response.setO_SAP_RESV(resv); //è¿åç»æ resultMap.put("zmess", zmess); resultMap.put("ztype", ztype); resultMap.put("importParameters", items); resultMap.put("result", response); return resultMap; } } src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java
@@ -1,20 +1,25 @@ package org.jeecg.modules.sap.service.impl; import com.alibaba.fastjson.JSONObject; import com.sap.conn.jco.*; import com.sap.conn.jco.JCoDestination; import com.sap.conn.jco.JCoFunction; 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; import org.jeecg.modules.sap.FunctionConst; import org.jeecg.modules.sap.dto.OrderBomDTO; import org.jeecg.modules.sap.dto.OrderProcessDTO; import org.jeecg.modules.sap.service.OrderProcessSync; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Service @Slf4j