新火炬后端单体项目初始化代码
zhangherong
2 天以前 afb71a0770acc36a6e062aecf2dfc1c92d2d80a7
art: SAP 物料请求预留号接口调试
已添加4个文件
已修改8个文件
235 ■■■■ 文件已修改
src/main/java/org/jeecg/modules/base/controller/FactoryController.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/model/FactoryModel.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/service/IFactoryService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/FunctionConst.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/dto/MaterialRequestDTO.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/request/MaterialRequest.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/service/OrderMaterialRequestService.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/service/impl/OrderLoadServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/service/impl/OrderMaterialRequestServiceImpl.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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