ibm 对接提交

This commit is contained in:
lmc 2024-11-18 14:56:14 +08:00
parent fc3c2bd71c
commit e2b09733cd
5 changed files with 400 additions and 329 deletions

View File

@ -214,6 +214,28 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.15</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>1.69</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.69</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.69</version>
</dependency>
<!-- JAX-WS API --> <!-- JAX-WS API -->
<dependency> <dependency>
<groupId>javax.xml.ws</groupId> <groupId>javax.xml.ws</groupId>

View File

@ -6,10 +6,12 @@ import cn.zhxu.okhttps.HttpResult;
import cn.zhxu.okhttps.OkHttps; import cn.zhxu.okhttps.OkHttps;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.ruoyi.common.task.forest.MyTaskClient; import com.ruoyi.common.task.forest.MyTaskClient;
import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.sign.Md5Utils; import com.ruoyi.common.utils.sign.Md5Utils;
import com.ruoyi.project.oil.domain.monitor.ThDevice; import com.ruoyi.project.oil.domain.monitor.ThDevice;
import com.ruoyi.project.oil.mapper.ThDeviceMapper;
import com.ruoyi.project.outside.service.OutSideService; import com.ruoyi.project.outside.service.OutSideService;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +20,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
@Component @Component
public class EquTask { public class EquTask {
@ -28,6 +31,8 @@ public class EquTask {
private MyTaskClient myClient; private MyTaskClient myClient;
@Autowired @Autowired
private OutSideService outSideService; private OutSideService outSideService;
@Autowired
private ThDeviceMapper thDeviceMapper;
/** /**
* 港口原有设备对接 * 港口原有设备对接
*/ */
@ -42,11 +47,9 @@ public class EquTask {
JSONObject tokenByJson = httpResult.getBody().toBean(JSONObject.class); JSONObject tokenByJson = httpResult.getBody().toBean(JSONObject.class);
JSONObject dataByJson = tokenByJson.getJSONObject("data"); JSONObject dataByJson = tokenByJson.getJSONObject("data");
String token = dataByJson.getString("token"); String token = dataByJson.getString("token");
ArrayList<ThDevice> equLists = new ArrayList<>(); //查询 数据库 获取 港口以前的 设备信息
ThDevice thDevice = new ThDevice(); ThDevice thDevice = new ThDevice();
thDevice.setSn("e75153fd53d243289057ffec33f36cb9"); thDevice.setDeptId(5l);
thDevice.setName("油气回收voc监测设备3#"); List<ThDevice> equLists = thDeviceMapper.selectDeviceList(thDevice);
equLists.add(thDevice);
equLists.forEach(e->{ equLists.forEach(e->{
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
@ -55,12 +58,17 @@ public class EquTask {
HttpResult result = OkHttps.sync("http://10.201.35.30:8090/enviSensor/select?" + HttpResult result = OkHttps.sync("http://10.201.35.30:8090/enviSensor/select?" +
"page=1&pageSize=20&valid=0&type=5&sensorUId={sensorUId}&label={label}") "page=1&pageSize=20&valid=0&type=5&sensorUId={sensorUId}&label={label}")
.addPathPara(map) .addPathPara(map)
.addHeader("token", token) .addHeader("token", token)
.get(); .get();
JSONObject vocByJson = result.getBody().toBean(JSONObject.class); JSONObject vocByJson = result.getBody().toBean(JSONObject.class);
JSONObject vocDataByJson = vocByJson.getJSONObject("data"); JSONObject vocDataByJson = vocByJson.getJSONObject("data");
JSONArray vocByArray = vocDataByJson.getJSONArray("array"); JSONArray vocByArray = vocDataByJson.getJSONArray("array");
System.out.println(vocByArray.toJSONString()); System.out.println(vocByArray.toString());
try {
Integer integer = outSideService.insertOldDeviceData(vocByArray.toJSONString());
} catch (JsonProcessingException jsonProcessingException) {
jsonProcessingException.printStackTrace();
}
}); });
} }

View File

@ -1,5 +1,6 @@
package com.ruoyi.common.wsdl; package com.ruoyi.common.wsdl;
import cn.hutool.core.lang.Console;
import cn.hutool.http.webservice.SoapClient; import cn.hutool.http.webservice.SoapClient;
@ -12,24 +13,24 @@ import javax.xml.soap.SOAPMessage;
*/ */
public class TestWsdl { public class TestWsdl {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// 创建SoapClient实例 wsdl协议请求地址:http://xxx.cn/services/GanSuInterface (去掉?wsdl)
SoapClient client = SoapClient.create("http://10.171.19.193:8080/dxpt/ws/shortMessageWs") // 新建客户端
// 设置方法名和命名空间命名空间url:http://webservice.xxx.xxx 方法名:getSydwJsonList SoapClient client = SoapClient.create("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
// tns 命名空间targetNamespace没有命名空间时直接写方法名即可 // 设置要请求的方法此接口方法前缀为web传入对应的命名空间
.setMethod("tns:returnMassages", "http://service.cxf.com") .setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
// 设置参数最后的false参数表示参数不加命名空间的前缀web // 设置参数此处自动添加方法的前缀web
.setParam("in0", "afe9cff39173ff8901917a54c90e448d", false); .setParam("phone", "18437762352")
.setParam("msg", "1112121")
//获取SOAPMessage实例此步作用是输出请求的XML参数实际开发并不需要 .setParam("dwdm", "SGJT-山港集团");
SOAPMessage message = client.getMessage();
System.out.println(client.getMsgStr(true)); // 发送请求参数true表示返回一个格式化后的XML内容
// 返回内容为XML字符串可以配合XmlUtil解析这个响应
// 发送请求true表示输出的结果格式化处理 Console.log(client.send(true));
String send = client.send(true);
// Document document = DocumentHelper.parseText(send);
// Element root = document.getRootElement();
// String value = root.getStringValue();
System.out.println(send);
// System.out.println(value);
} }
} }

View File

@ -23,7 +23,7 @@ import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
/** /**
* spring security配置 * spring security配置
* *
* @author ruoyi * @author ruoyi
*/ */
@EnableMethodSecurity(prePostEnabled = true, securedEnabled = true) @EnableMethodSecurity(prePostEnabled = true, securedEnabled = true)
@ -35,7 +35,7 @@ public class SecurityConfig
*/ */
@Autowired @Autowired
private UserDetailsService userDetailsService; private UserDetailsService userDetailsService;
/** /**
* 认证失败处理类 * 认证失败处理类
*/ */
@ -53,7 +53,7 @@ public class SecurityConfig
*/ */
@Autowired @Autowired
private JwtAuthenticationTokenFilter authenticationTokenFilter; private JwtAuthenticationTokenFilter authenticationTokenFilter;
/** /**
* 跨域过滤器 * 跨域过滤器
*/ */
@ -97,35 +97,36 @@ public class SecurityConfig
protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception
{ {
return httpSecurity return httpSecurity
// CSRF禁用因为不使用session // CSRF禁用因为不使用session
.csrf(csrf -> csrf.disable()) .csrf(csrf -> csrf.disable())
// 禁用HTTP响应标头 // 禁用HTTP响应标头
.headers((headersCustomizer) -> { .headers((headersCustomizer) -> {
headersCustomizer.cacheControl(cache -> cache.disable()).frameOptions(options -> options.sameOrigin()); headersCustomizer.cacheControl(cache -> cache.disable()).frameOptions(options -> options.sameOrigin());
}) })
// 认证失败处理类 // 认证失败处理类
.exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler)) .exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
// 基于token所以不需要session // 基于token所以不需要session
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
// 注解标记允许匿名访问的url // 注解标记允许匿名访问的url
.authorizeHttpRequests((requests) -> { .authorizeHttpRequests((requests) -> {
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
requests.antMatchers("/login", "/register", "/captchaImage","/outside/*").permitAll() requests.antMatchers("/login","/bbc/**",
// 静态资源可匿名访问 "/register", "/captchaImage","/outside/*").permitAll()
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() // 静态资源可匿名访问
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
.anyRequest().authenticated(); // 除上面外的所有请求全部需要鉴权认证
}) .anyRequest().authenticated();
// 添加Logout filter })
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler)) // 添加Logout filter
// 添加JWT filter .logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class) // 添加JWT filter
// 添加CORS filter .addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class) // 添加CORS filter
.addFilterBefore(corsFilter, LogoutFilter.class) .addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class)
.build(); .addFilterBefore(corsFilter, LogoutFilter.class)
.build();
} }
/** /**

View File

@ -1,268 +1,307 @@
//package com.ruoyi.project.system.controller; package com.ruoyi.project.system.controller;
//
//
//import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
//import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
//import com.banboocloud.Codec.BamboocloudFacade; import com.banboocloud.Codec.BamboocloudFacade;
//import com.ruoyi.common.utils.reflect.ReflectUtils; import com.ruoyi.common.utils.reflect.ReflectUtils;
//import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
//import com.ruoyi.project.system.domain.SysUser; import com.ruoyi.project.system.domain.SysUser;
//import com.ruoyi.project.system.service.ISysDeptService; import com.ruoyi.project.system.service.ISysDeptService;
//import com.ruoyi.project.system.service.ISysPostService; import com.ruoyi.project.system.service.ISysPostService;
//import com.ruoyi.project.system.service.ISysRoleService; import com.ruoyi.project.system.service.ISysRoleService;
//import com.ruoyi.project.system.service.ISysUserService; import com.ruoyi.project.system.service.ISysUserService;
//import com.ruoyi.project.system.utils.BamboocloudUtils; import com.ruoyi.project.system.utils.BamboocloudUtils;
//
//import org.slf4j.Logger; import org.slf4j.Logger;
//import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping; import org.springframework.security.core.userdetails.User;
//import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping;
// import org.springframework.web.bind.annotation.ResponseBody;
//import javax.servlet.ServletException; import org.springframework.web.bind.annotation.RestController;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse; import javax.servlet.ServletException;
//import java.io.BufferedReader; import javax.servlet.http.HttpServletRequest;
//import java.io.IOException; import javax.servlet.http.HttpServletResponse;
//import java.io.PrintWriter; import java.io.BufferedReader;
//import java.util.*; import java.io.IOException;
// import java.io.PrintWriter;
///** import java.util.*;
// * swagger 用户测试方法
// * 加密认证 /**
// * @author ruoyi * swagger 用户测试方法
// */ * 加密认证
// * @author ruoyi
//@RestController */
//@RequestMapping("/bbc/user")
//public class BbcController extends BaseController { @RestController
// @RequestMapping("/bbc/user")
// private String bimRequestId; public class BbcController extends BaseController {
//
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); private String bimRequestId;
//
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
// @Autowired
// private ISysUserService userService;
// @Autowired
// @Autowired private ISysUserService userService;
// private ISysRoleService roleService;
// @Autowired
// @Autowired private ISysRoleService roleService;
// private ISysDeptService deptService;
// @Autowired
// @Autowired private ISysDeptService deptService;
// private ISysPostService postService;
// @Autowired
//// @ApiOperation("测试") private ISysPostService postService;
// @RequestMapping()
// public JSONObject bbcUser() { // @ApiOperation("测试")
// @RequestMapping()
// JSONObject jsonObject = new JSONObject(); public JSONObject bbcUser() {
// jsonObject.put("resultCode", "0");
// jsonObject.put("message", "success"); JSONObject jsonObject = new JSONObject();
// return jsonObject; jsonObject.put("resultCode", "0");
// jsonObject.put("message", "success");
// } return jsonObject;
//
//// @ApiOperation("对象属性字段查询") }
// @PostMapping("/schemaService")
// public String SchemaService(HttpServletRequest req, HttpServletResponse resp) { // @ApiOperation("对象属性字段查询")
// @PostMapping("/schemaService")
// JSONObject jsonObject = new JSONObject(); public String SchemaService(HttpServletRequest req, HttpServletResponse resp) {
//
// // StringBuilder sb = stringBuilder(req); JSONObject jsonObject = new JSONObject();
// String bodyparam= BamboocloudUtils.getRequestBody(req);
// logger.info("json--param-->" + bodyparam); // StringBuilder sb = stringBuilder(req);
// // String bodyparam = sb.toString(); String bodyparam= BamboocloudUtils.getRequestBody(req);
// //解密json字符传 logger.info("json--param-->" + bodyparam);
// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); // String bodyparam = sb.toString();
// logger.info("json--param-->" + bodyparam); //解密json字符传
// Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam); bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES");
// //验证签名 logger.info("json--param-->" + bodyparam);
// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
// String username = (String) reqmap.get("bimRemoteUser"); //验证签名
// String password = (String) reqmap.get("bimRemotePwd"); if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) {
// //判断接口中的调用名及调用密码是否正确 String username = (String) reqmap.get("bimRemoteUser");
// if (BamboocloudUtils.checkUsernamePassword(username, password)) { String password = (String) reqmap.get("bimRemotePwd");
//// //添加返回的对象及属性字段名 //判断接口中的调用名及调用密码是否正确
//// MapJson mapJson = new MapJson(); if (BamboocloudUtils.checkUsernamePassword(username, password)) {
//// Map<String, List<Map<String, Object>>> map = new HashMap<>(); // //添加返回的对象及属性字段名
//// jsonObject.put("account", mapJson.accountList()); // MapJson mapJson = new MapJson();
//// jsonObject.put("organization", mapJson.organizationList()); Map<String, List<Map<String, Object>>> map = new HashMap<>();
//// jsonObject.put("role", mapJson.roleList()); ArrayList<HashMap<String,Object>> accountList = new ArrayList<>();
//// jsonObject.put("post", mapJson.postList()); HashMap<String, Object> nameMap = new HashMap<>();
//// jsonObject.put("dict", mapJson.dictDataList()); nameMap.put("multivalued",false);
//// jsonObject.put("bimRequestId", reqmap.get("bimRequestId")); nameMap.put("name","userName");
// String mapJs = JSON.toJSONString(jsonObject); nameMap.put("required",true);
// logger.info(jsonObject.toJSONString()); nameMap.put("type","String");
// //返回加密的json字符串 HashMap<String, Object> passMap = new HashMap<>();
// mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES"); passMap.put("multivalued",false);
// //jsonObject.put(map); passMap.put("name","password");
// //<Object> values = jsonObject.values(); passMap.put("required",true);
// return mapJs; passMap.put("type","String");
// } HashMap<String, Object> mobileMap = new HashMap<>();
// } mobileMap.put("multivalued",false);
// jsonObject.put("bimRequestId", bimRequestId); mobileMap.put("name","mobile");
// jsonObject.put("resultCode", "505"); mobileMap.put("required",true);
// jsonObject.put("message", "连接失败,请检查连接器配置的参数"); mobileMap.put("type","String");
// logger.info(jsonObject.toJSONString()); HashMap<String, Object> statusMap = new HashMap<>();
// String mapJs = JSON.toJSONString(jsonObject); statusMap.put("multivalued",false);
// //返回加密的json字符串 statusMap.put("name","status");
// mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES"); statusMap.put("required",true);
// return mapJs; statusMap.put("type","String");
// } accountList.add(nameMap);
// accountList.add(passMap);
//// @ApiOperation("新增用户") accountList.add(mobileMap);
//// @ApiImplicitParam(name = "user", value = "新增用户信息", dataType = "User") accountList.add(statusMap);
// @PostMapping("/UserCreateService") jsonObject.put("account", accountList);
// @ResponseBody // jsonObject.put("organization", mapJson.organizationList());
// public String userCreateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // jsonObject.put("role", mapJson.roleList());
// // jsonObject.put("post", mapJson.postList());
// Map<String, Object> schema = new HashMap<String, Object>(); // jsonObject.put("dict", mapJson.dictDataList());
// jsonObject.put("bimRequestId", reqmap.get("bimRequestId"));
// JSONObject jsonObject = new JSONObject(); String mapJs = JSON.toJSONString(jsonObject);
// logger.info(jsonObject.toJSONString());
// StringBuilder sb = stringBuilder(req); //返回加密的json字符串
// //修改多值的属性格式方便转换 mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES");
// String bodyparam = sb.toString(); //jsonObject.put(map);
// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); //<Object> values = jsonObject.values();
// String p = bodyparam; return mapJs;
// String z = "[\""; }
// String y = "\"]"; }
// bodyparam.indexOf(z); jsonObject.put("bimRequestId", bimRequestId);
// bodyparam.indexOf(y); jsonObject.put("resultCode", "505");
// while (bodyparam.contains(z)) { jsonObject.put("message", "连接失败,请检查连接器配置的参数");
// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); logger.info(jsonObject.toJSONString());
// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length()); String mapJs = JSON.toJSONString(jsonObject);
// } //返回加密的json字符串
// logger.info("json--param-->" + bodyparam); mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES");
// Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam); return mapJs;
// String username = (String) reqmap.get("bimRemoteUser"); }
// String password = (String) reqmap.get("bimRemotePwd");
// // @ApiOperation("新增用户")
// if (BamboocloudUtils.checkUsernamePassword(username, password)) { // @ApiImplicitParam(name = "user", value = "新增用户信息", dataType = "User")
// /** @PostMapping("/UserCreateService")
// * 新增用户 @ResponseBody
// */ public String userCreateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// //获取用户创建所需的参数
//// User user = createUpdateUser(reqmap); Map<String, Object> schema = new HashMap<String, Object>();
// SysUser user = new SysUser();
// //用户创建 JSONObject jsonObject = new JSONObject();
// userService.insertUser(user);
// //获取返回给IAM连接器的唯一标识用于后续该条数据的更新修改删除 StringBuilder sb = stringBuilder(req);
// String uid = user.getUserId() + ""; //修改多值的属性格式方便转换
// if (uid != null) { String bodyparam = sb.toString();
// schema.put("uid", uid); bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES");
// schema.put("bimRequestId", reqmap.get("bimRequestId")); String p = bodyparam;
// schema.put("resultCode", "0"); String z = "[\"";
// schema.put("message", "success"); String y = "\"]";
// } else { bodyparam.indexOf(z);
// schema.put("bimRequestId", reqmap.get("bimRequestId")); bodyparam.indexOf(y);
// schema.put("resultCode", "500"); while (bodyparam.contains(z)) {
// schema.put("message", "账号创建失败"); p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ",");
// } bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length());
// String mapJson = JSON.toJSONString(schema); }
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); logger.info("json--param-->" + bodyparam);
// return mapJson; Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
// } String username = (String) reqmap.get("bimRemoteUser");
// schema.put("bimRequestId", reqmap.get("bimRequestId")); String password = (String) reqmap.get("bimRemotePwd");
// schema.put("resultCode", "500");
// schema.put("message", "账号创建失败,请检查连接器配置的参数"); if (BamboocloudUtils.checkUsernamePassword(username, password)) {
// String mapJson = JSON.toJSONString(schema); /**
// //返回加密的json字符串 * 新增用户
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); */
// return mapJson; //获取用户创建所需的参数
// } // User user = createUpdateUser(reqmap);
// String userName = (String) reqmap.get("userName");
// String pass = (String) reqmap.get("password");
//// @ApiOperation("修改用户")
//// @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "User") logger.info("reqmap---------->"+reqmap);
// @PostMapping("/UserUpdateService") SysUser user = new SysUser();
// @ResponseBody user.setUserName(userName);
// public String userUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { user.setPassword(pass);
// //用户创建
// Map<String, Object> schema = new HashMap<String, Object>(); userService.registerUser(user);
// //获取返回给IAM连接器的唯一标识用于后续该条数据的更新修改删除
// JSONObject jsonObject = new JSONObject(); String uid = user.getUserId() + "";
// if (uid != null) {
// StringBuilder sb = stringBuilder(req); schema.put("uid", uid);
// schema.put("bimRequestId", reqmap.get("bimRequestId"));
// String bodyparam = sb.toString(); schema.put("resultCode", "0");
// schema.put("message", "success");
// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); } else {
// //修改多值的属性格式方便转换 schema.put("bimRequestId", reqmap.get("bimRequestId"));
// String p = bodyparam; schema.put("resultCode", "500");
// String bdp = bodyparam; schema.put("message", "账号创建失败");
// String z = "[\""; }
// String y = "\"]"; String mapJson = JSON.toJSONString(schema);
// bodyparam.indexOf(z); mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
// bodyparam.indexOf(y); return mapJson;
// while (bodyparam.contains(z)) { }
// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); schema.put("bimRequestId", reqmap.get("bimRequestId"));
// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length()); schema.put("resultCode", "500");
// } schema.put("message", "账号创建失败,请检查连接器配置的参数");
// logger.info("json--param-->" + bodyparam); String mapJson = JSON.toJSONString(schema);
// Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam); //返回加密的json字符串
// String username = (String) reqmap.get("bimRemoteUser"); mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
// String password = (String) reqmap.get("bimRemotePwd"); return mapJson;
// if (BamboocloudUtils.checkUsernamePassword(username, password)) { }
// SysUser user = new SysUser();
// //获取用于更新的参数
//// user = createUpdateUser(reqmap); // @ApiOperation("修改用户")
// //获取用于更新的唯一标识 // @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "User")
// user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid")))); @PostMapping("/UserUpdateService")
// //更新用户 @ResponseBody
// userService.updateUser(user); public String userUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// schema.put("bimRequestId", reqmap.get("bimRequestId"));
// schema.put("resultCode", "0"); Map<String, Object> schema = new HashMap<String, Object>();
// schema.put("message", "success");
// String mapJson = JSON.toJSONString(schema); JSONObject jsonObject = new JSONObject();
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
// logger.info("response----->" + schema); StringBuilder sb = stringBuilder(req);
// return mapJson;
// } String bodyparam = sb.toString();
// schema.put("bimRequestId", reqmap.get("bimRequestId"));
// schema.put("resultCode", "500"); bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES");
// schema.put("message", "账号更新失败,请检查连接器配置的参数"); //修改多值的属性格式方便转换
// String mapJson = JSON.toJSONString(schema); String p = bodyparam;
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); String bdp = bodyparam;
// logger.info("response----->" + schema); String z = "[\"";
// return mapJson; String y = "\"]";
// } bodyparam.indexOf(z);
// bodyparam.indexOf(y);
// while (bodyparam.contains(z)) {
// public StringBuilder stringBuilder(HttpServletRequest req) { p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ",");
// BufferedReader br = null; bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length());
// StringBuilder sb = new StringBuilder(); }
// String str = ""; logger.info("json--param-->" + bodyparam);
// try { Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
// br = req.getReader(); String username = (String) reqmap.get("bimRemoteUser");
// while ((str = br.readLine()) != null) { String password = (String) reqmap.get("bimRemotePwd");
// sb.append(str); if (BamboocloudUtils.checkUsernamePassword(username, password)) {
// } SysUser user = new SysUser();
// br.close(); //获取用于更新的参数
// } catch (IOException e) { // user = createUpdateUser(reqmap);
// e.printStackTrace(); String userName = (String) reqmap.get("userName");
// if (br != null) String pass = (String) reqmap.get("password");
// try {
// br.close(); logger.info("reqmap---------->"+reqmap);
// } catch (IOException eo) { user.setUserName(userName);
// eo.printStackTrace(); user.setPassword(pass);
// } //获取用于更新的唯一标识
// } finally { user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid"))));
// if (br != null) { //更新用户
// try { userService.updateUserStatus(user);
// br.close(); schema.put("bimRequestId", reqmap.get("bimRequestId"));
// } catch (IOException e) { schema.put("resultCode", "0");
// e.printStackTrace(); schema.put("message", "success");
// } String mapJson = JSON.toJSONString(schema);
// } mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
// } logger.info("response----->" + schema);
// return sb; return mapJson;
// } }
// schema.put("bimRequestId", reqmap.get("bimRequestId"));
//} schema.put("resultCode", "500");
// schema.put("message", "账号更新失败,请检查连接器配置的参数");
String mapJson = JSON.toJSONString(schema);
mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
logger.info("response----->" + schema);
return mapJson;
}
public StringBuilder stringBuilder(HttpServletRequest req) {
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
String str = "";
try {
br = req.getReader();
while ((str = br.readLine()) != null) {
sb.append(str);
}
br.close();
} catch (IOException e) {
e.printStackTrace();
if (br != null)
try {
br.close();
} catch (IOException eo) {
eo.printStackTrace();
}
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return sb;
}
}