liding
6 天以前 c4a1126fa6dcc12c8def6b394884ed198d55387c
fix:mes调用同步库注释企业微信和ifs
已修改2个文件
189 ■■■■ 文件已修改
ruoyi-common/src/main/java/com/ruoyi/common/utils/WxCpUtils.java 112 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java 77 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/WxCpUtils.java
@@ -33,40 +33,41 @@
     * @throws Exception
     */
    public static void inform(String user, String content, File imageFile) throws Exception {
        WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl();
        // 注册的企业信息
        config.setCorpId(CORP_ID);
        config.setCorpSecret(CORP_SECRET);
        WxCpServiceImpl wxCpService = new WxCpServiceImpl();
        wxCpService.setWxCpConfigStorage(config);
        WxCpMessage message;
        WxCpMessageSendResult result;
        // 发送文本
        if (StringUtils.isNotBlank(content)) {
            message = WxCpMessage.TEXT()
                    .content(content)
                    // 用户id
                    .toUser(user)
                    // 应用id
                    .agentId(AGENT_ID)
                    .build();
            result = wxCpService.getMessageService().send(message);
        }
        // 发送文件
        if (imageFile != null) {
            // 获取文件id
            WxMediaUploadResult imgResult = wxCpService.getMediaService().upload("file", imageFile);
            message = WxCpMessage.IMAGE()
                    .mediaId(imgResult.getMediaId())
                    // 用户id
                    .toUser(user)
                    // 应用id
                    .agentId(AGENT_ID)
                    .build();
            result = wxCpService.getMessageService().send(message);
        }
        return;
//        WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl();
//        // 注册的企业信息
//        config.setCorpId(CORP_ID);
//        config.setCorpSecret(CORP_SECRET);
//
//        WxCpServiceImpl wxCpService = new WxCpServiceImpl();
//        wxCpService.setWxCpConfigStorage(config);
//
//        WxCpMessage message;
//        WxCpMessageSendResult result;
//        // 发送文本
//        if (StringUtils.isNotBlank(content)) {
//            message = WxCpMessage.TEXT()
//                    .content(content)
//                    // 用户id
//                    .toUser(user)
//                    // 应用id
//                    .agentId(AGENT_ID)
//                    .build();
//            result = wxCpService.getMessageService().send(message);
//        }
//        // 发送文件
//        if (imageFile != null) {
//            // 获取文件id
//            WxMediaUploadResult imgResult = wxCpService.getMediaService().upload("file", imageFile);
//            message = WxCpMessage.IMAGE()
//                    .mediaId(imgResult.getMediaId())
//                    // 用户id
//                    .toUser(user)
//                    // 应用id
//                    .agentId(AGENT_ID)
//                    .build();
//            result = wxCpService.getMessageService().send(message);
//        }
    }
    /**
@@ -77,19 +78,20 @@
     * @throws Exception
     */
    public static void informWebHook(List<String> webHookList, File file) throws Exception {
        JSONObject json = new JSONObject();
        json.putOpt("msgtype", "image");
        JSONObject image = new JSONObject();
        image.putOpt("base64", getBase64(file));
        image.putOpt("md5", getMd5(file));
        json.putOpt("image", image);
        webHookList.stream().forEach(webHook -> {
            String result = HttpRequest.post(webHook)
                    .header("Content-Type", "application/json")
                    .body(json.toString())
                    .execute().body();
        });
        return;
//        JSONObject json = new JSONObject();
//        json.putOpt("msgtype", "image");
//        JSONObject image = new JSONObject();
//        image.putOpt("base64", getBase64(file));
//        image.putOpt("md5", getMd5(file));
//        json.putOpt("image", image);
//
//        webHookList.stream().forEach(webHook -> {
//            String result = HttpRequest.post(webHook)
//                    .header("Content-Type", "application/json")
//                    .body(json.toString())
//                    .execute().body();
//        });
    }
    /**
@@ -100,7 +102,8 @@
     * @throws Exception
     */
    public static String informWebHook(String webHook, String content) {
        return informWebHook(webHook, content,"text");
        return "";
//        return informWebHook(webHook, content,"text");
    }
    /**
@@ -112,11 +115,12 @@
     * @throws Exception
     */
    public static String informWebHook(String webHook, String content,String msgType) {
        JSONObject jsonObject = new JSONObject()
                .accumulate("msgtype", msgType)
                .accumulate(msgType, new JSONObject()
                        .accumulate("content", content));
        return HttpRequest.post(webHook).header("Content-Type", "application/json").body(jsonObject.toString()).execute().body();
        return "";
//        JSONObject jsonObject = new JSONObject()
//                .accumulate("msgtype", msgType)
//                .accumulate(msgType, new JSONObject()
//                        .accumulate("content", content));
//        return HttpRequest.post(webHook).header("Content-Type", "application/json").body(jsonObject.toString()).execute().body();
    }
    public static String getMd5(File file) {
@@ -162,4 +166,4 @@
        return base64Str;
    }
}
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java
@@ -13,6 +13,7 @@
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -32,20 +33,22 @@
     * 查询采购订单未检验
     */
    public List<Map<String, Object>> getInventory(String inAttr) {
        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);
        }
        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);
//        }
    }
@@ -109,27 +112,29 @@
     * @return
     */
    private Result<?> getResult(String procedureName, String inAttr, String url, String image) {
        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());
        }
        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());
//        }
    }
    /**
@@ -147,4 +152,4 @@
        stockMap.put("inAttr", inAttr);
        return stockMap;
    }
}
}