Merge remote-tracking branch 'origin/develop' into develop
						commit
						0fa6d45ddf
					
				| 
						 | 
				
			
			@ -45,7 +45,7 @@ public class WebInterceptorConfiguration implements InterceptorConfiguration {
 | 
			
		|||
            "/v1/logview", "/v1/logzip", "/status/**", "/v1/tokens", "/v1/config/captcha/install", "/v1/status/sid",
 | 
			
		||||
            "/v1/config/license/install", "/v1/config/status/", "/v1/status/sids", "/status", "/status/db",
 | 
			
		||||
            "/error", "/v1/*/info", "/v1/*/status", "/v1/config/**", "/v1/status/**", "/v1/config/license",
 | 
			
		||||
            "/v3/api-docs/**", "/v1/autologin", "/v1/single/login", "/v1/token/check"};
 | 
			
		||||
            "/v3/api-docs/**", "/v1/autologin", "/v1/single/login", "/v1/token/check", "/v1/trx/**"};
 | 
			
		||||
    private static final String[] LOG_EXCLUDES = new String[]{"/*/*.css",
 | 
			
		||||
            "/*/*.js", "/*/*.png", "/*/*.jpg", "/*/*.jpeg", "/*.html", "/*/*.html", "/swagger-resources/**", "/favicon.ico",
 | 
			
		||||
            "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/error", "/v3/api-docs/**"};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ public class WhiteApiCache implements InitializingBean {
 | 
			
		|||
        taskExecutor.execute(() -> {
 | 
			
		||||
            //设置白名单
 | 
			
		||||
            List<String> whiteList = Lists.newArrayList("^GET:/v1/users/permissions$",
 | 
			
		||||
                    "^GET:/v1/login/detail$", "^GET:/v1/messages$", "^GET:/v1/token$","^POST:/v1/token/check$",
 | 
			
		||||
                    "^GET:/v1/login/detail$", "^GET:/v1/trx/randomstr$", "^POST:/v1/trx/login$", "^POST:/v1/trx/logout$", "^GET:/v1/messages$", "^GET:/v1/token$","^POST:/v1/token/check$",
 | 
			
		||||
                    "^POST:/v1/users/logout$", "^POST:/v1/tenants/logout$", "^GET:/v1/config/license$", "^GET:/v1/roles/ids$");
 | 
			
		||||
            redisTemplate.opsForValue().set("permission_white", JSONObject.toJSONString(whiteList));
 | 
			
		||||
        });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,9 +28,87 @@ public class IndexDataController {
 | 
			
		|||
    private IndexService indexService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 待办工单列表
 | 
			
		||||
     * @param pager
 | 
			
		||||
     * @param requestContext
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @GetMapping("/doneWorkOrder")
 | 
			
		||||
    @Operation(summary = "待办工单列表")
 | 
			
		||||
    public GeneralResult list(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
    public GeneralResult doneWorkOrder(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
        return indexService.doneWorkOrder(pager, requestContext);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 工单统计
 | 
			
		||||
     * @param pager
 | 
			
		||||
     * @param requestContext
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @GetMapping("/workOrder/stattic")
 | 
			
		||||
    @Operation(summary = "工单统计")
 | 
			
		||||
    public GeneralResult workOrderStatic( @Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
        return indexService.workOrderStatic(requestContext);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前用户首页数据展示模块的数据查询
 | 
			
		||||
     * @param pager
 | 
			
		||||
     * @param requestContext
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @GetMapping("/userData/static")
 | 
			
		||||
    @Operation(summary = "当前用户首页数据展示模块的数据查询")
 | 
			
		||||
    public GeneralResult userStatic(@Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
        return indexService.userDataStatic(requestContext);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前用户授权应用列表
 | 
			
		||||
     * @param pager
 | 
			
		||||
     * @param requestContext
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @GetMapping("/userAppList")
 | 
			
		||||
    @Operation(summary = "当前用户首页数据展示模块的数据查询")
 | 
			
		||||
    public GeneralResult userAppList(@Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
        return indexService.userAppList(requestContext);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 近7日告警趋势
 | 
			
		||||
     * @param pager
 | 
			
		||||
     * @param requestContext
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @GetMapping("/sevenDayWarnTrend")
 | 
			
		||||
    @Operation(summary = "近7日告警趋势")
 | 
			
		||||
    public GeneralResult sevenDayWarnTrend(@Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
        return indexService.sevenDayWarnTrend(requestContext);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 单日告警统计
 | 
			
		||||
     * @param pager
 | 
			
		||||
     * @param requestContext
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @GetMapping("/oneDayWarnCount")
 | 
			
		||||
    @Operation(summary = "单日告警统计")
 | 
			
		||||
    public GeneralResult oneDayWarnCount(@Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
        return indexService.oneDayWarnCount(requestContext);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 告警列表
 | 
			
		||||
     * @param pager
 | 
			
		||||
     * @param requestContext
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @GetMapping("/warnList")
 | 
			
		||||
    @Operation(summary = "告警列表")
 | 
			
		||||
    public GeneralResult warnList(@Value(Common.REQ_CONTEXT) RequestContext requestContext) {
 | 
			
		||||
        return indexService.warnList(requestContext);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,4 +9,16 @@ import java.util.List;
 | 
			
		|||
 | 
			
		||||
public interface IndexService {
 | 
			
		||||
    GeneralResult doneWorkOrder(Pager pager, RequestContext requestContext);
 | 
			
		||||
 | 
			
		||||
    GeneralResult workOrderStatic(RequestContext requestContext);
 | 
			
		||||
 | 
			
		||||
    GeneralResult userDataStatic(RequestContext requestContext);
 | 
			
		||||
 | 
			
		||||
    GeneralResult userAppList(RequestContext requestContext);
 | 
			
		||||
 | 
			
		||||
    GeneralResult sevenDayWarnTrend(RequestContext requestContext);
 | 
			
		||||
 | 
			
		||||
    GeneralResult oneDayWarnCount(RequestContext requestContext);
 | 
			
		||||
 | 
			
		||||
    GeneralResult warnList(RequestContext requestContext);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,14 @@
 | 
			
		|||
package com.bocloud.sms.service;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSON;
 | 
			
		||||
import com.alibaba.fastjson.JSONArray;
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import com.bocloud.sms.entity.User;
 | 
			
		||||
import com.bocloud.sms.enums.WarnInfo;
 | 
			
		||||
import com.bocloud.sms.enums.YkInfo;
 | 
			
		||||
import com.bocloud.sms.interfaces.IndexService;
 | 
			
		||||
import com.bocloud.sms.repository.UserRepository;
 | 
			
		||||
import com.bocloud.sms.utils.WarnUtil;
 | 
			
		||||
import com.bocloud.sms.utils.YkUtil;
 | 
			
		||||
import com.megatron.common.model.GeneralResult;
 | 
			
		||||
import com.megatron.common.model.Pager;
 | 
			
		||||
| 
						 | 
				
			
			@ -14,6 +17,11 @@ import lombok.extern.slf4j.Slf4j;
 | 
			
		|||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
@Service("IndexService")
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class IndexServiceImpl implements IndexService {
 | 
			
		||||
| 
						 | 
				
			
			@ -22,23 +30,160 @@ public class IndexServiceImpl implements IndexService {
 | 
			
		|||
    private YkUtil ykUtil;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private UserRepository userRepository;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private WarnUtil warnUtil;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult doneWorkOrder(Pager pager, RequestContext requestContext) {
 | 
			
		||||
        try {
 | 
			
		||||
            JSONObject param = new JSONObject();
 | 
			
		||||
            User user = userRepository.query(requestContext.getTarget());
 | 
			
		||||
            param.put("userId",user.getUserId());
 | 
			
		||||
            param.put("page",pager.getPage());
 | 
			
		||||
            param.put("limit",pager.getRows());
 | 
			
		||||
            param.put("userId", "1111");
 | 
			
		||||
            param.put("page", pager.getPage());
 | 
			
		||||
            param.put("limit", pager.getRows());
 | 
			
		||||
            String result = ykUtil.call(YkInfo.getTaskList, param, JSONArray.class);
 | 
			
		||||
 | 
			
		||||
            log.info("result");
 | 
			
		||||
            JSONArray dataArray = JSONArray.parseArray(result);
 | 
			
		||||
            return new GeneralResult(true, dataArray,"查询成功");
 | 
			
		||||
            JSONObject jsonObject = JSONArray.parseObject(result, JSONObject.class);
 | 
			
		||||
            return new GeneralResult(true, jsonObject, "查询成功");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("查询失败",e);
 | 
			
		||||
            log.info("查询失败", e);
 | 
			
		||||
            return new GeneralResult(false, "查询失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult workOrderStatic(RequestContext requestContext) {
 | 
			
		||||
        try {
 | 
			
		||||
 | 
			
		||||
            JSONObject jsonObject = getTaskList(requestContext);
 | 
			
		||||
            Integer total = jsonObject.getInteger("total");
 | 
			
		||||
 | 
			
		||||
            Map<String, Object> resultMap = new HashMap<>();
 | 
			
		||||
            resultMap.put("orderTotal", total);
 | 
			
		||||
 | 
			
		||||
            List<JSONObject> data = JSONObject.parseObject(jsonObject.getString("data"), List.class);
 | 
			
		||||
            Integer waitDoneTotal = 0;
 | 
			
		||||
            Integer doneTotal = 0;
 | 
			
		||||
            for (JSONObject obj : data) {
 | 
			
		||||
                if ("0".equals(obj.getString("approve_status"))) {
 | 
			
		||||
                    waitDoneTotal++;
 | 
			
		||||
                } else {
 | 
			
		||||
                    doneTotal++;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            resultMap.put("waitDoneTotal", waitDoneTotal);
 | 
			
		||||
            resultMap.put("doneTotal", doneTotal);
 | 
			
		||||
 | 
			
		||||
            return new GeneralResult(true, resultMap, "查询成功");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("查询失败", e);
 | 
			
		||||
            return new GeneralResult(false, "查询失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private JSONObject getTaskList(RequestContext requestContext) throws Exception {
 | 
			
		||||
        JSONObject param = new JSONObject();
 | 
			
		||||
        User user = userRepository.query(requestContext.getTarget());
 | 
			
		||||
        param.put("userId", "1111");
 | 
			
		||||
        param.put("page", 1);
 | 
			
		||||
        param.put("limit", Integer.MAX_VALUE);
 | 
			
		||||
        String result = ykUtil.call(YkInfo.getTaskList, param, JSONArray.class);
 | 
			
		||||
        JSONObject jsonObject = JSONArray.parseObject(result, JSONObject.class);
 | 
			
		||||
        return jsonObject;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult userDataStatic(RequestContext requestContext) {
 | 
			
		||||
        try {
 | 
			
		||||
            //获取用户数据权限申请数量
 | 
			
		||||
            JSONObject userParam = new JSONObject();
 | 
			
		||||
            userParam.put("userId", "1111");
 | 
			
		||||
            String data = ykUtil.call(YkInfo.getCountTaskByUser, userParam, JSONArray.class);
 | 
			
		||||
            List<JSONObject> list = JSONObject.parseObject(data, List.class);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            return new GeneralResult(true, list, "查询成功");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("查询失败", e);
 | 
			
		||||
            return new GeneralResult(false, "查询失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult userAppList(RequestContext requestContext) {
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            //获取所有的appList
 | 
			
		||||
            //查询当前用户授权应用
 | 
			
		||||
            JSONObject param = new JSONObject();
 | 
			
		||||
            param.put("type", "user");
 | 
			
		||||
            param.put("page", 1);
 | 
			
		||||
            param.put("limit", Integer.MAX_VALUE);
 | 
			
		||||
            String result = ykUtil.call(YkInfo.getAllAppList, param, JSONArray.class);
 | 
			
		||||
            JSONObject allAppJson = JSONObject.parseObject(result, JSONObject.class);
 | 
			
		||||
            List<JSONObject> allAppList = JSONObject.parseObject(allAppJson.getString("list"), List.class);
 | 
			
		||||
 | 
			
		||||
            List<JSONObject> userAppList = getUserAppList(requestContext);
 | 
			
		||||
            List<String> appIdList = userAppList.stream().map(jsonObject -> jsonObject.getString("appId")).collect(Collectors.toList());
 | 
			
		||||
            for (JSONObject data : allAppList) {
 | 
			
		||||
                if (appIdList.contains(data.getString("appId"))) {
 | 
			
		||||
                    data.put("enable", "1");
 | 
			
		||||
                } else {
 | 
			
		||||
 | 
			
		||||
                    data.put("enable", "0");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return new GeneralResult(true, allAppList, "查询成功");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("查询失败", e);
 | 
			
		||||
            return new GeneralResult(false, "查询失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult sevenDayWarnTrend(RequestContext requestContext) {
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            String result = warnUtil.call(WarnInfo.get7DayWarnTrend.getUrl(), "GET");
 | 
			
		||||
            log.info("result:"+result);
 | 
			
		||||
            return new GeneralResult(true, "查询成功");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("查询失败", e);
 | 
			
		||||
            return new GeneralResult(false, "查询失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult oneDayWarnCount(RequestContext requestContext) {
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            String result = warnUtil.call(WarnInfo.get1DayWarnCount.getUrl(), "GET");
 | 
			
		||||
            log.info("result:"+result);
 | 
			
		||||
            return new GeneralResult(true, "查询成功");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("查询失败", e);
 | 
			
		||||
            return new GeneralResult(false, "查询失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult warnList(RequestContext requestContext) {
 | 
			
		||||
        try {
 | 
			
		||||
            String result = warnUtil.call(WarnInfo.getWarnList.getUrl(), "GET");
 | 
			
		||||
            log.info("result:"+result);
 | 
			
		||||
            return new GeneralResult(true, "查询成功");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.info("查询失败", e);
 | 
			
		||||
            return new GeneralResult(false, "查询失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private List<JSONObject> getUserAppList(RequestContext requestContext) throws Exception {
 | 
			
		||||
        //查询当前用户授权应用
 | 
			
		||||
        JSONObject param = new JSONObject();
 | 
			
		||||
        param.put("userId", "1111");
 | 
			
		||||
        param.put("type", "user");
 | 
			
		||||
        String result = ykUtil.call(YkInfo.getUserAppList, param, JSONArray.class);
 | 
			
		||||
        return JSONObject.parseObject(result, List.class);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,16 +80,20 @@ public class ManagerServiceImpl implements ManagerService {
 | 
			
		|||
        User user = userRepository.query(context.getTarget());
 | 
			
		||||
        List<Long> qxAppModuleIds = new ArrayList<>();
 | 
			
		||||
        if (null != user.getUserId()) {
 | 
			
		||||
            // 天融信用户获取权限系统菜单权限
 | 
			
		||||
            log.info("开始获取天融信登录用户所拥有权限系统列表");
 | 
			
		||||
            List<AppModule> appModules = trxServiceImpl.queryQxCategoryList(trxToken, user.getUserId());
 | 
			
		||||
            if (CollectionUtils.isEmpty(appModules)) {
 | 
			
		||||
                log.error("获取天融信登录用户所拥有权限系统列表失败");
 | 
			
		||||
                return new GeneralResult<>(false, "获取权限系统菜单信息失败");
 | 
			
		||||
            }
 | 
			
		||||
            for (AppModule appModule : appModules) {
 | 
			
		||||
                long id = Long.parseLong(appModule.getId());
 | 
			
		||||
                qxAppModuleIds.add(id);
 | 
			
		||||
            try {
 | 
			
		||||
                // 天融信用户获取权限系统菜单权限
 | 
			
		||||
                log.info("开始获取天融信登录用户所拥有权限系统列表");
 | 
			
		||||
                List<AppModule> appModules = trxServiceImpl.queryQxCategoryList(trxToken, user.getUserId());
 | 
			
		||||
                if (CollectionUtils.isEmpty(appModules)) {
 | 
			
		||||
                    log.error("获取天融信登录用户所拥有权限系统列表失败");
 | 
			
		||||
                    return new GeneralResult<>(false, "获取权限系统菜单信息失败");
 | 
			
		||||
                }
 | 
			
		||||
                for (AppModule appModule : appModules) {
 | 
			
		||||
                    long id = Long.parseLong(appModule.getId());
 | 
			
		||||
                    qxAppModuleIds.add(id);
 | 
			
		||||
                }
 | 
			
		||||
            } catch (Exception e) {
 | 
			
		||||
                log.error("获取天融信登录用户所拥有权限系统列表失败:", e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,14 +57,21 @@ public class TrxServiceImpl implements TrxService {
 | 
			
		|||
        Map<String, Object> paramsMap = new HashMap<>();
 | 
			
		||||
        paramsMap.put("isToken", false);
 | 
			
		||||
        paramsMap.put("ngx_cookie", ngxCookie);
 | 
			
		||||
        JSONObject result = JSONObject.parseObject(HttpUtil.get(url, paramsMap));
 | 
			
		||||
        if ("-1".equals(result.getString("result"))) {
 | 
			
		||||
            return new GeneralResult(false, "获取随机数失败" + result.getString("errmsg"));
 | 
			
		||||
        JSONObject result = new JSONObject();
 | 
			
		||||
        try {
 | 
			
		||||
            log.info("调用天融信获取随机字符串接口, url:" + url + ", 参数:" + JSONObject.toJSONString(paramsMap));
 | 
			
		||||
            result = JSONObject.parseObject(HttpUtil.get(url, paramsMap, 10000));
 | 
			
		||||
            if ("-1".equals(result.getString("result"))) {
 | 
			
		||||
                return new GeneralResult(false, "获取随机数失败" + result.getString("errmsg"));
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.error("调用天融信获取随机字符串失败", e);
 | 
			
		||||
            return new GeneralResult(false, "获取随机数失败" + e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        return new GeneralResult(true, result.getString("result"), "获取随机数成功");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 获取天融信用户信息
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public GeneralResult getAuthToken(TrxAuthModel trxAuthModel) {
 | 
			
		||||
        String url = trxUrl + "/userAuthen";
 | 
			
		||||
| 
						 | 
				
			
			@ -72,21 +79,34 @@ public class TrxServiceImpl implements TrxService {
 | 
			
		|||
        paramsMap.put("cookie", trxAuthModel.getClientHello());
 | 
			
		||||
        paramsMap.put("certMd5", trxAuthModel.getServerHello());
 | 
			
		||||
        paramsMap.put("client_ip", trxAuthModel.getClientIp());
 | 
			
		||||
        JSONObject result = JSONObject.parseObject(HttpUtil.post(url, paramsMap));
 | 
			
		||||
        if (!"0".equals(result.getString("result"))) {
 | 
			
		||||
            return new GeneralResult(false, "用户登录失败" + result.getString("errmsg"));
 | 
			
		||||
        JSONObject result = new JSONObject();
 | 
			
		||||
        GeneralResult<Map<String, Object>> login = new GeneralResult<>();
 | 
			
		||||
        try {
 | 
			
		||||
            log.info("调用天融信登录接口, url:" + url + ", 参数:" + JSONObject.toJSONString(paramsMap));
 | 
			
		||||
            result = JSONObject.parseObject(HttpUtil.post(url, paramsMap, 10000));
 | 
			
		||||
            if (!"0".equals(result.getString("result"))) {
 | 
			
		||||
                return new GeneralResult(false, "用户登录天融信失败" + result.getString("errmsg"));
 | 
			
		||||
            }
 | 
			
		||||
            String trxToken = result.getString("token");
 | 
			
		||||
            String userId = result.getString("userId");
 | 
			
		||||
 | 
			
		||||
            // 处理ukey登录用户
 | 
			
		||||
            log.info("开始uKey登录用户入库, userId:" + userId);
 | 
			
		||||
            saveUserByTrx(userId);
 | 
			
		||||
            log.info("uKey登录用户入库结束");
 | 
			
		||||
            // 登录
 | 
			
		||||
            log.info("开始uKey登录用户登录云管平台");
 | 
			
		||||
            User user = userRepository.getByUserId(userId);
 | 
			
		||||
            Encryptor encryptor = new AESEncryptor();
 | 
			
		||||
            String password = encryptor.encrypt(userId + "CMP", null);
 | 
			
		||||
            login = userServiceImpl.login(user.getAccount(), password, null, null, true);
 | 
			
		||||
            login.getData().put("trxToken", trxToken);
 | 
			
		||||
            log.info("uKey登录用户登录云管平台结束");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.error("用户登录失败:", e);
 | 
			
		||||
            return new GeneralResult(false, "用户登录失败" + e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        String trxToken = result.getString("token");
 | 
			
		||||
        String userId = result.getString("userId");
 | 
			
		||||
        // 处理ukey登录用户
 | 
			
		||||
        saveUserByTrx(userId);
 | 
			
		||||
        // 登录
 | 
			
		||||
        User user = userRepository.getByUserId(userId);
 | 
			
		||||
        Encryptor encryptor = new AESEncryptor();
 | 
			
		||||
        String password = encryptor.encrypt(userId + "CMP", null);
 | 
			
		||||
        GeneralResult<Map<String, Object>> login = userServiceImpl.login(user.getAccount(), password, null, null, true);
 | 
			
		||||
        login.getData().put("trxToken", trxToken);
 | 
			
		||||
        return new GeneralResult(true, login, "用户登录成功");
 | 
			
		||||
        return login;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void saveUserByTrx(String userId) {
 | 
			
		||||
| 
						 | 
				
			
			@ -148,10 +168,15 @@ public class TrxServiceImpl implements TrxService {
 | 
			
		|||
 | 
			
		||||
    //确认天融信token是否有效
 | 
			
		||||
    public GeneralResult getTokenOnline(String trxToken) {
 | 
			
		||||
        String url = trxUrl + "/tokenOnline";
 | 
			
		||||
        JSONObject result = JSONObject.parseObject(HttpUtil.post(url, trxToken));
 | 
			
		||||
        if (!"0".equals(result.getString("result"))) {
 | 
			
		||||
            return new GeneralResult(false, "当前token无效" + result.getString("errmsg"));
 | 
			
		||||
        try {
 | 
			
		||||
            String url = trxUrl + "/tokenOnline";
 | 
			
		||||
            JSONObject result = JSONObject.parseObject(HttpUtil.post(url, trxToken, 10000));
 | 
			
		||||
            if (!"0".equals(result.getString("result"))) {
 | 
			
		||||
                return new GeneralResult(false, "当前token无效" + result.getString("errmsg"));
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.error("获取天融信token状态失败:", e);
 | 
			
		||||
            return new GeneralResult(false, "获取天融信token状态失败" + e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        return new GeneralResult(true, "当前token有效");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ package com.bocloud.sms.service.utils;
 | 
			
		|||
import cn.hutool.http.HttpUtil;
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import com.bocloud.sms.model.QxReqVo;
 | 
			
		||||
import com.megatron.common.model.GeneralResult;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Value;
 | 
			
		||||
| 
						 | 
				
			
			@ -11,9 +12,9 @@ import org.springframework.stereotype.Component;
 | 
			
		|||
@Component
 | 
			
		||||
public class QxUtils {
 | 
			
		||||
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 | 
			
		||||
    @Value("${qx.queryAppUrl}")
 | 
			
		||||
    @Value("${qx.queryAppUrl:http://117.47.88.120:8081/authority/api/v1/apps}")
 | 
			
		||||
    private String queryAppUrl;
 | 
			
		||||
    @Value("${qx.queryAppModulesUrl}")
 | 
			
		||||
    @Value("${qx.queryAppModulesUrl:http://117.47.88.120:8081/authority/api/v1/appModules}")
 | 
			
		||||
    private String queryAppModulesUrl;
 | 
			
		||||
 | 
			
		||||
    public String queryApp(String userToken, String userId){
 | 
			
		||||
| 
						 | 
				
			
			@ -27,13 +28,17 @@ public class QxUtils {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    public String call(String url, QxReqVo qxReqVo){
 | 
			
		||||
        String str = JSONObject.toJSONString(qxReqVo);
 | 
			
		||||
        logger.info("call method[{}] req params[{}]",url,str);
 | 
			
		||||
        JSONObject result = JSONObject.parseObject(HttpUtil.post(url,str));
 | 
			
		||||
        if (!"200".equals(result.getString("status"))) {
 | 
			
		||||
            throw new IllegalArgumentException("调用权限系统接口异常" + result.getString("msg"));
 | 
			
		||||
        try {
 | 
			
		||||
            String str = JSONObject.toJSONString(qxReqVo);
 | 
			
		||||
            logger.info("call method[{}] req params[{}]",url,str);
 | 
			
		||||
            JSONObject result = JSONObject.parseObject(HttpUtil.post(url,str, 10000));
 | 
			
		||||
            if (!"200".equals(result.getString("status"))) {
 | 
			
		||||
                throw new IllegalArgumentException("调用权限系统接口异常" + result.getString("msg"));
 | 
			
		||||
            }
 | 
			
		||||
            return result.getString("data");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            logger.error("获取天融信token状态失败:", e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return result.getString("data");
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,13 +13,13 @@ import org.springframework.stereotype.Component;
 | 
			
		|||
public class YkUtils {
 | 
			
		||||
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 | 
			
		||||
	//参考application.yml配置文件
 | 
			
		||||
    @Value("${yk.url}")
 | 
			
		||||
    @Value("${yk.url:http://36.111.150.83:9527/}")
 | 
			
		||||
    private String url;
 | 
			
		||||
 | 
			
		||||
    @Value("${yk.reqUserId}")
 | 
			
		||||
    @Value("${yk.reqUserId:1}")
 | 
			
		||||
    private String reqUserId;
 | 
			
		||||
 | 
			
		||||
    @Value("${yk.systemId}")
 | 
			
		||||
    @Value("${yk.systemId:1}")
 | 
			
		||||
    private String systemId;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ public class YkUtils {
 | 
			
		|||
        String str = JSONObject.toJSONString(reqVo);
 | 
			
		||||
        logger.info("call yk url [{}]" , url);
 | 
			
		||||
        logger.info("call yk method[{}] req params[{}]",reqVo.getMethod(),str);
 | 
			
		||||
        String resultStr = HttpUtil.post(url, str);
 | 
			
		||||
        String resultStr = HttpUtil.post(url, str, 10000);
 | 
			
		||||
        //logger.info("call method[{}] resp params[{}]",reqVo.getMethod(),resultStr);
 | 
			
		||||
        JSONObject result = JSONObject.parseObject(resultStr);
 | 
			
		||||
        logger.info("call yk result [{}]" , result.toString());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
package com.bocloud.sms.enums;
 | 
			
		||||
 | 
			
		||||
public enum WarnInfo {
 | 
			
		||||
 | 
			
		||||
    //单日告警统计
 | 
			
		||||
    get1DayWarnCount("/alistar/api/v1/alarm/current/statistics/7d"),
 | 
			
		||||
    //告警列表
 | 
			
		||||
    getWarnList("/alistar/api/v1/alarm/current"),
 | 
			
		||||
    //近7日告警趋势统计
 | 
			
		||||
    get7DayWarnTrend("/alistar/api/v1/alarm/current/today/all");
 | 
			
		||||
 | 
			
		||||
    private String url;
 | 
			
		||||
 | 
			
		||||
    WarnInfo(String url) {
 | 
			
		||||
        this.url = url;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getUrl() {
 | 
			
		||||
        return url;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -7,6 +7,16 @@ public enum YkInfo {
 | 
			
		|||
    getAppList("/system/sysapp/getAppList"),
 | 
			
		||||
    //获取运维工单接口
 | 
			
		||||
    getTaskList("/activiti/rwMainTask/getTaskList"),
 | 
			
		||||
    //用户授权应用接口
 | 
			
		||||
    getUserAppList("/system/sysapp/getRoleOrUserHaveAppList"),
 | 
			
		||||
    //获取所有app接口
 | 
			
		||||
    getAllAppList("/system/sysapp/getAppList"),
 | 
			
		||||
    //获取用户角色信息
 | 
			
		||||
    getUserRoles("/system/user/queryUserRoles"),
 | 
			
		||||
    //数据展示
 | 
			
		||||
    getCountTaskByUser("/system/task/countTaskByUser"),
 | 
			
		||||
    //用户数据权限信息查询接口
 | 
			
		||||
    getUserDataAuth("/system/user/queryUserAuthres"),
 | 
			
		||||
 | 
			
		||||
    getTaskByUser("/system/task/countTaskByUser");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,7 +137,7 @@ public class UserRepository extends JdbcGenericDao<User, Long> {
 | 
			
		|||
    public User getByUserId(String userId) {
 | 
			
		||||
        String sql =
 | 
			
		||||
                "select u.*, t.account tenant_account,t.name tenant_name, t.discount discount from users u left join tenant t on u.tenant_id = t.id where u.is_deleted = 0 and u.user_id = :userId ";
 | 
			
		||||
        Map<String, Object> params = MapTools.simpleMap("user_id", userId);
 | 
			
		||||
        Map<String, Object> params = MapTools.simpleMap("userId", userId);
 | 
			
		||||
        List<User> list = this.list(User.class, sql, params);
 | 
			
		||||
//        Assert.isTrue(list.size() <= 1, "该天融信用户已存在");
 | 
			
		||||
        return list.isEmpty() ? null : list.get(0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,63 @@
 | 
			
		|||
package com.bocloud.sms.utils;
 | 
			
		||||
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Value;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.net.HttpURLConnection;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.util.Base64;
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class WarnUtil {
 | 
			
		||||
 | 
			
		||||
    @Value("${warn.url:127.0.0.1:1234}")
 | 
			
		||||
    private String url;
 | 
			
		||||
    @Value("${warn.user:alistar}")
 | 
			
		||||
    private String user;
 | 
			
		||||
    @Value("${warn.password:alistarapi123}")
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        String user = "alistar:alistarapi123";
 | 
			
		||||
        System.out.println(Base64.getEncoder().encodeToString(user.getBytes()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public String call(String urlSuffix, String method) throws Exception {
 | 
			
		||||
        URL obj = new URL(url + urlSuffix);
 | 
			
		||||
        HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
 | 
			
		||||
 | 
			
		||||
        // 设置请求方法
 | 
			
		||||
        connection.setRequestMethod(method);
 | 
			
		||||
 | 
			
		||||
        // 添加Basic Auth鉴权头
 | 
			
		||||
        String auth = user + ":" + password;
 | 
			
		||||
        String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes());
 | 
			
		||||
        String authHeaderValue = "Basic " + encodedAuth;
 | 
			
		||||
        connection.setRequestProperty("Authorization", authHeaderValue);
 | 
			
		||||
 | 
			
		||||
        // 发起请求并获取响应码
 | 
			
		||||
        int responseCode = connection.getResponseCode();
 | 
			
		||||
        log.info("Response Code: " + responseCode);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // 读取响应数据
 | 
			
		||||
        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
 | 
			
		||||
        String inputLine;
 | 
			
		||||
        StringBuilder response = new StringBuilder();
 | 
			
		||||
 | 
			
		||||
        while ((inputLine = in.readLine()) != null) {
 | 
			
		||||
            response.append(inputLine);
 | 
			
		||||
        }
 | 
			
		||||
        in.close();
 | 
			
		||||
 | 
			
		||||
        // 输出响应
 | 
			
		||||
        log.info("Response: " + response.toString());
 | 
			
		||||
        return response.toString();
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue