liding
6 天以前 c4a1126fa6dcc12c8def6b394884ed198d55387c
ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java
@@ -10,8 +10,10 @@
import com.ruoyi.common.config.IfsProperties;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -30,58 +32,34 @@
    /**
     * 查询采购订单未检验
     */
    private String getStock(String inAttr) {
        return ifsProperties.getCustorderPort() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=QUERY_POL_RECEIPT_STD&userId=lims_user&inAttr=" + inAttr;
    public List<Map<String, Object>> getInventory(String inAttr) {
        log.info("IFS调用已禁用 - getInventory");
        return new ArrayList<>();
//        String procedureName = "QUERY_POL_RECEIPT_STD";
//        JSONObject stockMap = getJsonObject(procedureName, inAttr);
//        String body = HttpRequest.post(ifsProperties.getCustorderPort()).form(stockMap).execute().body();
//        ObjectMapper objectMapper = new ObjectMapper();
//        try {
//            Map map = objectMapper.readValue(body, Map.class);
//            List<Map<String, Object>> maps = objectMapper.readValue(JSONUtil.toJsonStr(map.get("LIST_INFO")), new TypeReference<List<Map<String, Object>>>() {
//            });
//            log.info("获取采购订单-->>" + maps);
//            return maps;
//        } catch (JsonProcessingException e) {
//            e.printStackTrace();
//            throw new RuntimeException(e);
//        }
    }
    public List<Map<String, Object>> getInventory(String inAttr) {
        String body = HttpRequest.get(getStock(inAttr)).execute().body();
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            Map map = objectMapper.readValue(body, Map.class);
            List<Map<String, Object>> maps = objectMapper.readValue(JSONUtil.toJsonStr(map.get("LIST_INFO")), new TypeReference<List<Map<String, Object>>>() {
            });
            log.info("获取采购订单-->>" + maps);
            return maps;
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
    /**
     * 登记采购检验结果STD
     */
    private String ProcurementResultsURL(String inAttr) {
        return ifsProperties.getCustorder() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=REGIST_INSPECTION_RESULTS_STD&userId=lims_user&inAttr=" + inAttr;
    }
    public Result getProcurementResults(String inAttr) {
        String body = HttpRequest.get(ProcurementResultsURL(inAttr)).execute().body();
        log.info("登记采购检验结果-->" + body);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            Map map = objectMapper.readValue(body, Map.class);
            String successFlag = map.get("SuccessFlag").toString();
            if (Integer.valueOf(successFlag) == 1) {
                return Result.success(map);
            } else {
                return Result.fail(map.get("ErrorMsg").toString());
            }
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return Result.fail(e.getMessage());
        }
        return getResult("REGIST_INSPECTION_RESULTS_STD", inAttr, ifsProperties.getCustorder(), "登记采购检验结果-->");
    }
    /**
     * 检验后移库
     */
    private String getMoveReceiptApi(String inAttr) {
        return ifsProperties.getCustorder() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=MOVE_RECEIPT_STD&userId=lims_user&inAttr=" + inAttr;
    }
    /**
     * 原材料检验-检验后移库
@@ -90,62 +68,28 @@
     * @return
     */
    public Result moveReceipt(String inAttr) {
        String body = HttpRequest.get(getMoveReceiptApi(inAttr)).execute().body();
        log.info("检验后移库-->" + body);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            Map map = objectMapper.readValue(body, Map.class);
            String successFlag = map.get("SuccessFlag").toString();
            if (Integer.valueOf(successFlag) == 1) {
                return Result.success(map);
            } else {
                return Result.fail(map.get("ErrorMsg").toString());
            }
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return Result.fail(e.getMessage());
        }
        return getResult("MOVE_RECEIPT_STD", inAttr, ifsProperties.getCustorder(), "检验后移库-->");
    }
    /**
     * 采购接收更改批号
     */
    private String getMoveReceiptLotApi(String inAttr) {
        return ifsProperties.getCustorder() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=MODIFY_PURCH_RECEIPT_LOT_STD&userId=lims_user&inAttr=" + inAttr;
    }
    /**
     * 原材料检验-检验后移库
     * 原材料检验-采购接收更改批号
     *
     * @param inAttr
     * @return
     */
    public Result updateMoveReceiptLot(String inAttr) {
        String body = HttpRequest.get(getMoveReceiptLotApi(inAttr)).execute().body();
        log.info("修改采购订单批次号-->" + body);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            Map map = objectMapper.readValue(body, Map.class);
            String successFlag = map.get("SuccessFlag").toString();
            if (Integer.valueOf(successFlag) == 1) {
                return Result.success(map);
            } else {
                return Result.fail(map.get("ErrorMsg").toString());
            }
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return Result.fail(e.getMessage());
        }
        return getResult("MODIFY_PURCH_RECEIPT_LOT_STD", inAttr, ifsProperties.getCustorder(), "修改采购订单批次号-->");
    }
    /**
     * 查询库存数据
     * 库存物料批次属性新增修改接口
     *
     * @param inAttr
     * @return
     */
    private String getIfsStockApi(String inAttr) {
        return ifsProperties.getCustorderPort() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=QUERY_INVENTORY_INFO_STD&userId=lims_user&inAttr=" + inAttr;
    public Result importPartLotAttr(String inAttr) {
        return getResult("IMPORT_PART_LOT_ATTR_STD", inAttr, ifsProperties.getCustorder(), "库存物料批次属性新增修改接口-->");
    }
    /**
@@ -155,26 +99,57 @@
     * @return
     */
    public Result getIfsStock(String inAttr) {
        return getResult("QUERY_INVENTORY_INFO_STD", inAttr, ifsProperties.getCustorderPort(), "查询库存信息-->");
    }
    /**
     * 通用接口
     * @param procedureName 方法名
     * @param inAttr  传参
     * @param url 地址
     * @param image 消息
     * @return
     */
    private Result<?> getResult(String procedureName, String inAttr, String url, String image) {
        log.info("IFS调用已禁用 - getResult: {}", procedureName);
        return Result.success();
//        JSONObject stockMap = new JSONObject();
//        stockMap.put("procedureName", procedureName);
//        stockMap.put("contract", ifsProperties.getContract());
//        stockMap.put("contractKey", ifsProperties.getContractKeyPost());
//        stockMap.put("userId", "lims_user");
//        stockMap.put("inAttr", inAttr);
//        String body = HttpRequest.post(url).form(stockMap).execute().body();
//        log.info(image + body);
//        ObjectMapper objectMapper = new ObjectMapper();
//        try {
//            Map map = objectMapper.readValue(body, Map.class);
//            String successFlag = map.get("SuccessFlag").toString();
//            if (Integer.valueOf(successFlag) == 1) {
//                return Result.success(map);
//            } else {
//                return Result.fail(map.get("ErrorMsg").toString());
//            }
//        } catch (JsonProcessingException e) {
//            e.printStackTrace();
//            return Result.fail(e.getMessage());
//        }
    }
    /**
     * 获取添加请求信息
     * @param procedureName      结构名称
     * @param inAttr             请求参数
     * @return
     */
    private JSONObject getJsonObject(String procedureName, String inAttr) {
        JSONObject stockMap = new JSONObject();
        stockMap.put("procedureName", "QUERY_INVENTORY_INFO_STD");
        stockMap.put("procedureName", procedureName);
        stockMap.put("contract", ifsProperties.getContract());
        stockMap.put("contractKey", ifsProperties.getContractKeyPost());
        stockMap.put("userId", "userId");
        stockMap.put("userId", "lims_user");
        stockMap.put("inAttr", inAttr);
        String body = HttpRequest.post(ifsProperties.getCustorderPort()).form(stockMap).execute().body();
        log.info("查询库存信息-->" + body);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            Map map = objectMapper.readValue(body, Map.class);
            String successFlag = map.get("SuccessFlag").toString();
            if (Integer.valueOf(successFlag) == 1) {
                return Result.success(map);
            } else {
                return Result.fail(map.get("ErrorMsg").toString());
            }
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return Result.fail(e.getMessage());
        }
        return stockMap;
    }
}
}