| | |
| | | <artifactId>commons-io</artifactId> |
| | | <version>2.6</version> |
| | | </dependency> |
| | | |
| | | <!--中台sdk--> |
| | | <dependency> |
| | | <groupId>com.zhongtai</groupId> |
| | |
| | | <!--单点登录sdk--> |
| | | <dependency> |
| | | <groupId>com.cas</groupId> |
| | | <artifactId>cas-sdk</artifactId> |
| | | <artifactId>cas-client-oncon</artifactId> |
| | | <version>3.0.5</version> |
| | | <scope>system</scope> |
| | | <systemPath>${pom.basedir}/lib/cas-client-oncon-3.0.5.jar</systemPath> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.cas</groupId> |
| | | <artifactId>cas-sdk</artifactId> |
| | | <artifactId>cas-client-oncon-core</artifactId> |
| | | <version>1.2.2</version> |
| | | <scope>system</scope> |
| | | <systemPath>${pom.basedir}/lib/cas-client-oncon-core-1.2.2.jar</systemPath> |
| | |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <fork>true</fork><!-- 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart --> |
| | | <includeSystemScope>true</includeSystemScope> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | |
| | | |
| | | <resources> |
| | | <resource> |
| | | <directory>lib</directory> |
| | | <directory>${project.basedir}/lib</directory> |
| | | <targetPath>/BOOT-INF/lib/</targetPath> |
| | | <includes> |
| | | <include>**/*.jar</include> |
| | |
| | | import com.google.code.kaptcha.impl.DefaultKaptcha; |
| | | import com.google.code.kaptcha.util.Config; |
| | | import com.stylefeng.guns.config.properties.GunsProperties; |
| | | import com.stylefeng.guns.core.intercept.RestApiInteceptor; |
| | | import com.stylefeng.guns.core.listener.ConfigListener; |
| | | import com.stylefeng.guns.core.xss.XssFilter; |
| | | import edu.yale.its.tp.cas.client.filter.OnconMDWebCasFilter; |
| | | import org.jasig.cas.client.session.SingleSignOutFilter; |
| | | import org.jasig.cas.client.session.SingleSignOutHttpSessionListener; |
| | | import org.springframework.aop.Advisor; |
| | | import org.springframework.aop.support.DefaultPointcutAdvisor; |
| | | import org.springframework.aop.support.JdkRegexpMethodPointcut; |
| | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.context.request.RequestContextListener; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 增加对rest api鉴权的spring mvc拦截器 |
| | | */ |
| | | //舍弃原有的权限校验功能 |
| | | // @Override |
| | | // public void addInterceptors(InterceptorRegistry registry) { |
| | | // registry.addInterceptor(new RestApiInteceptor()).addPathPatterns("/api/**"); |
| | | // } |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(new RestApiInteceptor()).addPathPatterns("/api/**"); |
| | | } |
| | | |
| | | /** |
| | | * druidServlet注册 |
| | |
| | | defaultKaptcha.setConfig(config); |
| | | return defaultKaptcha; |
| | | } |
| | | |
| | | |
| | | /********************黔云通单点登录拦截器**********************/ |
| | | |
| | | // @Override |
| | | // public void addViewControllers(ViewControllerRegistry registry) { |
| | | // registry.addViewController("/index").setViewName("index"); |
| | | // } |
| | | @Bean |
| | | public FilterRegistrationBean getOnconMDWebCasFilter() { |
| | | OnconMDWebCasFilter onconMDWebCasFilter = new OnconMDWebCasFilter(); |
| | | |
| | | FilterRegistrationBean registrationBean = new FilterRegistrationBean(); |
| | | registrationBean.setFilter(onconMDWebCasFilter); |
| | | List<String> urlPatterns = new ArrayList<String>(); |
| | | urlPatterns.add("/*");//拦截路径,可以添加多个 |
| | | registrationBean.setUrlPatterns(urlPatterns); |
| | | registrationBean.setOrder(2); |
| | | |
| | | registrationBean.addInitParameter("oncon.com.security.urls", "/api/**"); |
| | | registrationBean.addInitParameter("erp.si-tech.com.cn.noCheckUrl", "/index,/ajaxgetticket.jsp,/ssoAutologin.jsp,/login.jsp,/nologingetuserinfo.jsp,/toautologin.jsp,/autologin.jsp,/remotelogin.jsp,/toremotelogin.jsp,/js/**,/remoteloginajax.jsp"); |
| | | registrationBean.addInitParameter("erp.si-tech.com.cn.nologinstatus", "/*"); |
| | | registrationBean.addInitParameter("erp.si-tech.com.cn.loginstatus", "/login.jsp,/nologingetuserinfo.jsp"); |
| | | registrationBean.addInitParameter("com.oncon.sso.urlparams.nologin", "code,code2"); |
| | | |
| | | registrationBean.addInitParameter("edu.yale.its.tp.cas.client.filter.loginUrl", "https://testsso1.teamshub.com/login"); |
| | | registrationBean.addInitParameter("edu.yale.its.tp.cas.client.filter.validateUrl", "https://testsso1.teamshub.com/serviceValidate"); |
| | | registrationBean.addInitParameter("com.oncon.md.loginUrl", "https://testsso1.teamshub.com/sso-session/login"); |
| | | registrationBean.addInitParameter("edu.yale.its.tp.cas.client.filter.serverName", "172.26.200.34:9180"); |
| | | registrationBean.addInitParameter("edu.yale.its.tp.cas.client.filter.casServiceUrlForStatic", "http://172.26.200.34:9180/sso-springboot-client/getUserInfo"); |
| | | registrationBean.addInitParameter("edu.yale.its.tp.cas.client.filter.loginatUrlForStatic", ""); |
| | | registrationBean.addInitParameter("edu.yale.its.tp.cas.client.filter.loginFailedUrlForStatic", "http://172.26.200.34:9180/error.html"); |
| | | |
| | | |
| | | return registrationBean; |
| | | } |
| | | |
| | | @Bean |
| | | public FilterRegistrationBean getSingleSignOutFilter() { |
| | | SingleSignOutFilter singleSignOutFilter = new SingleSignOutFilter(); |
| | | FilterRegistrationBean registrationBean = new FilterRegistrationBean(); |
| | | registrationBean.setFilter(singleSignOutFilter); |
| | | List<String> urlPatterns = new ArrayList<String>(); |
| | | urlPatterns.add("/api/**");//拦截路径,可以添加多个 |
| | | registrationBean.setUrlPatterns(urlPatterns); |
| | | registrationBean.setOrder(1); |
| | | |
| | | registrationBean.addInitParameter("wmall.flag", "false"); |
| | | |
| | | return registrationBean; |
| | | } |
| | | |
| | | @Bean |
| | | public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> getSingleSignOutHttpSessionListener() { |
| | | ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> servletListenerRegistrationBean |
| | | = new ServletListenerRegistrationBean<>(); |
| | | servletListenerRegistrationBean.setListener(new SingleSignOutHttpSessionListener()); |
| | | return servletListenerRegistrationBean; |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | public ResultUtil cancellation(HttpServletRequest request){ |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if(null == driverId){ |
| | | if (null == driverId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(driverId); |
| | |
| | | driverService.updateById(driver); |
| | | //开始验证当前账号是否在别处登录 |
| | | String value = redisUtil.getValue("DRIVER_" + driverId); |
| | | if(ToolUtil.isNotEmpty(value)){//将另外设备上的强迫下线 |
| | | if (ToolUtil.isNotEmpty(value)) {//将另外设备上的强迫下线 |
| | | //开始清除redis中无效的数据 |
| | | String key = redisUtil.getValue("DRIVER_" + driver.getPhone()); |
| | | redisUtil.remove(key);//删除个人信息数据 |
| | |
| | | redisUtil.remove("DRIVER_" + driverId);//清除存储的token |
| | | } |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/base/driver/getDriverInfo") |
| | | public void getDriverInfo(String lsu, String ssologinid, String ticket, HttpSession session) { |
| | | try { |
| | | String onconParam = edu.yale.its.tp.cas.client.Util.getOnconParam(session); |
| | | onconParam = new String(Base64.getDecoder().decode(onconParam), "UTF-8"); |
| | | System.err.println("lsu: " + lsu + ",ticket: " + ticket + ",ssologinid: " + ssologinid); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * 高德猎鹰服务 |
| | |
| | | */ |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | this.init(); |
| | | // this.init(); |
| | | } |
| | | |
| | | |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content="";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date=new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-",""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | log.info("【企业增加员工】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url,headers,"POST",skprivateKeyFile,timeStamp,request); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", JSON.toJSONString(request)); |
| | | log.info("【企业增加员工】请求地址:" + url); |
| | | log.info("【企业增加员工】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【企业增加员工】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if(!"0".equals(status)){ |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【企业增加员工】请求失败:" + result); |
| | | return false; |
| | | throw new RuntimeException("【企业增加员工】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【企业增加员工】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【企业增加员工】失败:" + object.toJSONString()); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content="";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date=new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-",""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | log.info("【企业修改员工信息】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url,headers,"POST",skprivateKeyFile,timeStamp,request); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", JSON.toJSONString(request)); |
| | | log.info("【企业修改员工信息】请求地址:" + url); |
| | | log.info("【企业修改员工信息】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【企业修改员工信息】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if(!"0".equals(status)){ |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【企业修改员工信息】请求失败:" + result); |
| | | return false; |
| | | throw new RuntimeException("【企业修改员工信息】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【企业修改员工信息】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【企业修改员工信息】失败:" + object.toJSONString()); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content="";//业务参数 |
| | | String content = "";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date=new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-",""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | log.info("【企业删除人员】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url,headers,"POST",skprivateKeyFile,timeStamp,request); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", JSON.toJSONString(request)); |
| | | log.info("【企业删除人员】请求地址:" + url); |
| | | log.info("【企业删除人员】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【企业删除人员】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if(!"0".equals(status)){ |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【企业删除人员】请求失败:" + result); |
| | | return false; |
| | | throw new RuntimeException("【企业删除人员】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【企业删除人员】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【企业删除人员】失败:" + object.toJSONString()); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content="";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date=new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-",""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | log.info("【根据员工ID获取人员信息】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url,headers,"GET",skprivateKeyFile,timeStamp,request); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", JSON.toJSONString(request)); |
| | | log.info("【根据员工ID获取人员信息】请求地址:" + url); |
| | | log.info("【根据员工ID获取人员信息】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【根据员工ID获取人员信息】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if(!"0".equals(status)){ |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【根据员工ID获取人员信息】请求失败:" + result); |
| | | return null; |
| | | throw new RuntimeException("【根据员工ID获取人员信息】请求失败:" + result); |
| | | } |
| | | StaffNodeInfo staffNodeInfo = jsonObject.getObject("data", StaffNodeInfo.class); |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【根据员工ID获取人员信息】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【根据员工ID获取人员信息】失败:" + object.toJSONString()); |
| | | } |
| | | StaffNodeInfo staffNodeInfo = jsonObject.getObject("object", StaffNodeInfo.class); |
| | | return staffNodeInfo; |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.open.common.util.OpenApiClient; |
| | | import com.open.common.util.SystemParameterNames; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.CheckEnterExist; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.CreateEnterpriseRequest; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.EnterpriseInfo; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.ModifyEnterpriseInfoRequest; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content = "";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> request = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | request.put("uscc", uscc); |
| | | log.info("【根据社会信用代码判断企业是否已存在】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, request); |
| | | map.put(SystemParameterNames.getAppKey(), appKey); |
| | | map.put(SystemParameterNames.getMessage_id(), messageId); |
| | | map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | map.put("content", "{\"uscc\":\"" + uscc + "\"}"); |
| | | log.info("【根据社会信用代码判断企业是否已存在】请求地址:" + url); |
| | | log.info("【根据社会信用代码判断企业是否已存在】请求参数:" + JSON.toJSONString(map)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map); |
| | | log.info("【根据社会信用代码判断企业是否已存在】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【根据社会信用代码判断企业是否已存在】请求失败:" + result); |
| | | return null; |
| | | throw new RuntimeException("【根据社会信用代码判断企业是否已存在】请求失败:" + result); |
| | | } |
| | | return jsonObject.getObject("data", CheckEnterExist.class); |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【根据社会信用代码判断企业是否已存在】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【根据社会信用代码判断企业是否已存在】失败:" + object.toJSONString()); |
| | | } |
| | | return jsonObject.getObject("object", CheckEnterExist.class); |
| | | } |
| | | |
| | | |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content = "";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> request = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | request.put("enterName", enterName); |
| | | log.info("【根据企业名称判断企业是否已存在】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, request); |
| | | map.put(SystemParameterNames.getAppKey(), appKey); |
| | | map.put(SystemParameterNames.getMessage_id(), messageId); |
| | | map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | map.put("content", "{\"enterName\":\"" + enterName + "\"}"); |
| | | log.info("【根据企业名称判断企业是否已存在】请求地址:" + url); |
| | | log.info("【根据企业名称判断企业是否已存在】请求参数:" + JSON.toJSONString(map)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map); |
| | | log.info("【根据企业名称判断企业是否已存在】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【根据企业名称判断企业是否已存在】请求失败:" + result); |
| | | return null; |
| | | throw new RuntimeException("【根据企业名称判断企业是否已存在】请求失败:" + result); |
| | | } |
| | | return jsonObject.getObject("data", CheckEnterExist.class); |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【根据企业名称判断企业是否已存在】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【根据企业名称判断企业是否已存在】失败:" + object.toJSONString()); |
| | | } |
| | | return jsonObject.getObject("object", CheckEnterExist.class); |
| | | } |
| | | |
| | | |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content = "";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> request = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | request.put("enter_code", enter_code); |
| | | log.info("【查询企业详情】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, request); |
| | | map.put(SystemParameterNames.getAppKey(), appKey); |
| | | map.put(SystemParameterNames.getMessage_id(), messageId); |
| | | map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | map.put("content", "{\"enter_code\":\"" + enter_code + "\"}"); |
| | | log.info("【查询企业详情】请求地址:" + url); |
| | | log.info("【查询企业详情】请求参数:" + JSON.toJSONString(map)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map); |
| | | log.info("【查询企业详情】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【查询企业详情】请求失败:" + result); |
| | | return null; |
| | | throw new RuntimeException("【查询企业详情】请求失败:" + result); |
| | | } |
| | | EnterpriseInfo enterpriseInfo = jsonObject.getObject("data", EnterpriseInfo.class); |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【查询企业详情】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【查询企业详情】失败:" + object.toJSONString()); |
| | | } |
| | | EnterpriseInfo enterpriseInfo = jsonObject.getObject("object", EnterpriseInfo.class); |
| | | return enterpriseInfo; |
| | | } |
| | | |
| | |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content = "";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | log.info("【修改企业基本信息】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, request); |
| | | map.put(SystemParameterNames.getAppKey(), appKey); |
| | | map.put(SystemParameterNames.getMessage_id(), messageId); |
| | | map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | map.put("content", JSON.toJSONString(request)); |
| | | log.info("【修改企业基本信息】请求地址:" + url); |
| | | log.info("【修改企业基本信息】请求参数:" + JSON.toJSONString(map)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, map); |
| | | log.info("【修改企业基本信息】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static Boolean createEnterprise(CreateEnterpriseRequest request) { |
| | | public static CreateEnterprise createEnterprise(CreateEnterpriseRequest request) { |
| | | //请求路径 |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.1/createEnterprise"; |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/createEnterprise"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | |
| | | map.put(SystemParameterNames.getMessage_id(), messageId); |
| | | map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | map.put("content", content); |
| | | Class<? extends CreateEnterpriseRequest> clazz = request.getClass(); |
| | | Field[] declaredFields = clazz.getDeclaredFields(); |
| | | for (Field declaredField : declaredFields) { |
| | | String name = declaredField.getName(); |
| | | Object invoke = null; |
| | | try { |
| | | invoke = clazz.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1)).invoke(request); |
| | | } catch (IllegalAccessException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (InvocationTargetException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (NoSuchMethodException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | map.put(name, invoke); |
| | | } |
| | | map.put("content", JSON.toJSONString(request)); |
| | | |
| | | log.info("【创建企业】请求地址:" + url); |
| | | log.info("【创建企业】请求参数:" + JSON.toJSONString(map)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map); |
| | | log.info("【创建企业】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String resCode = jsonObject.getString("resCode"); |
| | | String status = jsonObject.getString("status"); |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【创建企业】请求失败:" + result); |
| | | return null; |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【创建企业】请求失败:" + result); |
| | | return false; |
| | | return null; |
| | | } |
| | | return true; |
| | | return object.getObject("data", CreateEnterprise.class); |
| | | } |
| | | } |
| | |
| | | * 1:生产环境 |
| | | * 2:测试环境 |
| | | */ |
| | | String status = "2"; |
| | | String status = "1"; |
| | | /** |
| | | * API地址 |
| | | */ |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util.qianyuntong; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.open.common.util.OpenApiClient; |
| | | import com.open.common.util.SystemParameterNames; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 短信工具类 |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/10 10:48 |
| | | */ |
| | | @Slf4j |
| | | public class SMSUtil { |
| | | |
| | | |
| | | /** |
| | | * 获取易信验证码 |
| | | * @param mobile |
| | | * @return |
| | | */ |
| | | public static String sendVerifyCode(String mobile) { |
| | | //请求路径 |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/sendVerifyCode"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", "{\"mobile\":\"" + mobile + "\"}"); |
| | | log.info("【获取易信验证码】请求地址:" + url); |
| | | log.info("【获取易信验证码】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【获取易信验证码】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【获取易信验证码】请求失败:" + result); |
| | | throw new RuntimeException("【获取易信验证码】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【获取易信验证码】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【获取易信验证码】失败:" + object.toJSONString()); |
| | | } |
| | | return object.getString("code"); |
| | | } |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.system.util.qianyuntong; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.open.common.util.OpenApiClient; |
| | | import com.open.common.util.SystemParameterNames; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.QYTUserInfo; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.RegisterViaMobileRequest; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 用户工具类 |
| | |
| | | |
| | | |
| | | /** |
| | | * 根据手机号和企业编号查询用户信息 |
| | | * 根据手机号码获取人员信息 |
| | | * |
| | | * @param mobile 手机号码 |
| | | * @param enterNum 企业编号 |
| | | */ |
| | | public static QYTUserInfo getUserInfoByPhone(String mobile, String enterNum) { |
| | | public static List<QYTUserInfo> getUserInfoByPhone(String mobile, String enterNum) { |
| | | //请求路径 |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/getUserInfoByPhone"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content = "";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", content); |
| | | contentMap.put("mobile", mobile); |
| | | contentMap.put("enterNum", enterNum); |
| | | contentMap.put("content", "{\"mobile\":\"" + mobile + "\",\"enterNum\":\"" + enterNum + "\"}"); |
| | | log.info("【根据手机号和企业编号查询用户信息】请求地址:" + url); |
| | | log.info("【根据手机号和企业编号查询用户信息】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【根据手机号和企业编号查询用户信息】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【根据手机号和企业编号查询用户信息】请求失败:" + result); |
| | | return null; |
| | | throw new RuntimeException("【根据手机号和企业编号查询用户信息】请求失败:" + result); |
| | | } |
| | | QYTUserInfo userInfo = jsonObject.getObject("data", QYTUserInfo.class); |
| | | return userInfo; |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【根据手机号和企业编号查询用户信息】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【根据手机号和企业编号查询用户信息】失败:" + object.toJSONString()); |
| | | } |
| | | JSONArray data = object.getJSONArray("data"); |
| | | List<QYTUserInfo> list = new ArrayList<>(); |
| | | for (int i = 0; i < data.size(); i++) { |
| | | data.getJSONObject(i).getString("enter_code"); |
| | | QYTUserInfo userInfo = data.getObject(i, QYTUserInfo.class); |
| | | list.add(userInfo); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static Boolean registerViaMobile(RegisterViaMobileRequest request) { |
| | | public static RegisterViaMobile registerViaMobile(RegisterViaMobileRequest request) { |
| | | //请求路径 |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/getUserInfoByPhone"; |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/m1_register_via_mobile"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | String content = "";//业务参数 |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | request.put(SystemParameterNames.getAppKey(), appKey); |
| | | request.put(SystemParameterNames.getMessage_id(), messageId); |
| | | request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | request.put("content", content); |
| | | log.info("【根据手机号注册用户】请求参数:" + JSON.toJSONString(request)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, request); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", JSON.toJSONString(request)); |
| | | log.info("【根据手机号注册用户】请求地址:" + url); |
| | | log.info("【根据手机号注册用户】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【根据手机号注册用户】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String status = jsonObject.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【根据手机号注册用户】请求失败:" + result); |
| | | return false; |
| | | throw new RuntimeException("【根据手机号注册用户】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【根据手机号注册用户】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【根据手机号注册用户】失败:" + object.toJSONString()); |
| | | } |
| | | return jsonObject.getObject("object", RegisterViaMobile.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 易信用户修改密码 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static Boolean modifyPwd(ModifyPwdRequest request) { |
| | | //请求路径 |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/modifyPwd"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", JSON.toJSONString(request)); |
| | | log.info("【易信用户修改密码】请求地址:" + url); |
| | | log.info("【易信用户修改密码】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【易信用户修改密码】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【易信用户修改密码】请求失败:" + result); |
| | | throw new RuntimeException("【易信用户修改密码】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【易信用户修改密码】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【易信用户】失败:" + object.toJSONString()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 易信重置密码 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static Boolean resetPwd(ResetPwdRequest request) { |
| | | //请求路径 |
| | | String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/resetPwd"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = QianYunTongProperties.privateKeyPath; |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = QianYunTongProperties.appkey;//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); |
| | | contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); |
| | | contentMap.put("content", JSON.toJSONString(request)); |
| | | log.info("【易信重置密码】请求地址:" + url); |
| | | log.info("【易信重置密码】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【易信重置密码】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【易信重置密码】请求失败:" + result); |
| | | throw new RuntimeException("【易信重置密码】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【易信重置密码】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【易信重置密码】失败:" + object.toJSONString()); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | @Data |
| | | public class CheckEnterExist { |
| | | /** |
| | | * 企业ID |
| | | */ |
| | | private String id; |
| | | /** |
| | | * 是否在公有云注册,1:已注册;0:未注册 |
| | | */ |
| | | private String isReg; |
| | |
| | | @Data |
| | | public class CreateEnterprise { |
| | | /** |
| | | * |
| | | * 企业ID |
| | | */ |
| | | private String id; |
| | | /** |
| | | * 开通易信状态 |
| | | * 0:成功 1:失败 |
| | | */ |
| | | private String callYixinApi; |
| | | /** |
| | | * 开通办公门户状态 |
| | | * 0:成功 1:失败 |
| | | */ |
| | | private String callItdSaveCompany; |
| | | /** |
| | | * 开通企业官网状态 |
| | | * 0:成功 1:失败 |
| | | */ |
| | | private String callItdDredgeWebsite; |
| | | /** |
| | | * 电话号码 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 企业idcode |
| | | */ |
| | | private String idCode; |
| | | /** |
| | | * 企业节点ID |
| | | */ |
| | | private String noteId; |
| | | /** |
| | | * 是否新注册企业 |
| | | */ |
| | | private String isNew; |
| | | } |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/6 16:39 |
| | | */ |
| | | @Data |
| | | public class DeleteStafNodeRequest extends HashMap<String, Object> { |
| | | public class DeleteStafNodeRequest { |
| | | /** |
| | | * 人员ID |
| | | */ |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/6 16:32 |
| | | */ |
| | | @Data |
| | | public class EditStaffNodeRequest extends HashMap<String, Object> { |
| | | public class EditStaffNodeRequest { |
| | | /** |
| | | * 人员ID |
| | | */ |
| | |
| | | @Data |
| | | public class EnterpriseInfo { |
| | | /** |
| | | * 企业ID |
| | | */ |
| | | private String id; |
| | | /** |
| | | * 企业编号 |
| | | */ |
| | | private String enter_code; |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/6 16:42 |
| | | */ |
| | | @Data |
| | | public class GetStaffNodeRequest extends HashMap<String, Object> { |
| | | public class GetStaffNodeRequest { |
| | | /** |
| | | * 人员ID |
| | | */ |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/9 18:13 |
| | | */ |
| | | @Data |
| | | public class ModifyEnterpriseInfoRequest extends HashMap<String, Object> { |
| | | public class ModifyEnterpriseInfoRequest { |
| | | /** |
| | | * 企业编码 |
| | | */ |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util.qianyuntong.model; |
| | | |
| | | import lombok.Data; /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/10 10:42 |
| | | */ |
| | | @Data |
| | | public class ModifyPwdRequest { |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | private String mobile; |
| | | /** |
| | | * 旧密码 |
| | | */ |
| | | private String oldPwd; |
| | | /** |
| | | * 新密码 |
| | | */ |
| | | private String newPwd; |
| | | /** |
| | | * 验证码 |
| | | */ |
| | | private String code; |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util.qianyuntong.model; |
| | | |
| | | import lombok.Data; /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/10 11:34 |
| | | */ |
| | | @Data |
| | | public class RegisterViaMobile { |
| | | /** |
| | | * 响应码 |
| | | * 0:成功;1:失败;2:手机号非法;3:验证码已过期;4:验证码错误;5、用户已存在;9:弱密码 |
| | | */ |
| | | private String status; |
| | | /** |
| | | * 响应描述 |
| | | */ |
| | | private String desc; |
| | | /** |
| | | * web登录密码 |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 用户UUID |
| | | */ |
| | | private String onconUUID; |
| | | } |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/6 16:59 |
| | | */ |
| | | @Data |
| | | public class RegisterViaMobileRequest extends HashMap<String, Object> { |
| | | public class RegisterViaMobileRequest { |
| | | /** |
| | | * 手机号码 |
| | | */ |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util.qianyuntong.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/10 10:42 |
| | | */ |
| | | @Data |
| | | public class ResetPwdRequest { |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | private String mobile; |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 验证码 |
| | | */ |
| | | private String code; |
| | | /** |
| | | * 客户端appid |
| | | */ |
| | | private String appid; |
| | | } |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/6 16:22 |
| | | */ |
| | | @Data |
| | | public class SaveStaffNodeRequest extends HashMap<String, Object> { |
| | | public class SaveStaffNodeRequest { |
| | | /** |
| | | * 操作人手机号 |
| | | */ |
| | |
| | | /** |
| | | * 员工所属部分ID |
| | | */ |
| | | private String deptIds; |
| | | private Long deptIds; |
| | | /** |
| | | * 员工职务ID |
| | | */ |
| | |
| | | package com.stylefeng.guns; |
| | | |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.EnterpriseUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.CreateEnterpriseRequest; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.EmployeeUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.SaveStaffNodeRequest; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | |
| | | |
| | | @Test |
| | | public void test() throws Exception { |
| | | CreateEnterpriseRequest request = new CreateEnterpriseRequest(); |
| | | request.setName("成都喜望科技有限公司"); |
| | | request.setNickName("成都喜望"); |
| | | request.setIndustry_code("123456789"); |
| | | // CreateEnterpriseRequest request = new CreateEnterpriseRequest(); |
| | | // request.setName("成都喜望科技有限公司"); |
| | | // request.setNickName("成都喜望"); |
| | | // request.setIndustry_code("123456789"); |
| | | // request.setMobile("15828353127"); |
| | | // request.setMobileFlag("1"); |
| | | // EnterpriseUtil.createEnterprise(request); |
| | | |
| | | //短信 |
| | | // SMSUtil.sendVerifyCode("15828353127"); |
| | | |
| | | // CheckEnterExist checkEnterNameExist = EnterpriseUtil.checkEnterNameExist("成都喜望科技有限公司"); |
| | | |
| | | // EnterpriseInfo enterpriseDetail = EnterpriseUtil.getEnterpriseDetail(checkEnterNameExist.getEnterCode()); |
| | | // System.out.println(enterpriseDetail); |
| | | |
| | | // List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone("15828353127", "981100006005878"); |
| | | |
| | | // RegisterViaMobileRequest request = new RegisterViaMobileRequest(); |
| | | // request.setMobile("15828353126"); |
| | | // request.setPassword("123456"); |
| | | // request.setNickname("测试"); |
| | | // request.setVerify_code("1111"); |
| | | // request.setVerify_code_type("1"); |
| | | // RegisterViaMobile registerViaMobile = UserUtil.registerViaMobile(request); |
| | | |
| | | // ModifyPwdRequest request = new ModifyPwdRequest(); |
| | | // request.setMobile("15828353126"); |
| | | // request.setOldPwd("111111"); |
| | | // request.setNewPwd("654321"); |
| | | // request.setCode("1111"); |
| | | // UserUtil.modifyPwd(request); |
| | | |
| | | // ResetPwdRequest request = new ResetPwdRequest(); |
| | | // request.setMobile("15828353126"); |
| | | // request.setPassword("654321"); |
| | | // request.setCode("1111"); |
| | | // UserUtil.resetPwd(request); |
| | | |
| | | SaveStaffNodeRequest request = new SaveStaffNodeRequest(); |
| | | request.setMobile("15828353127"); |
| | | request.setMobileFlag("1"); |
| | | Boolean enterprise = EnterpriseUtil.createEnterprise(request); |
| | | request.setEntercode("981100006005878"); |
| | | request.setEmpName("超级管理员"); |
| | | request.setEmpNickname("超级管理员"); |
| | | request.setLoginNo("18200000000"); |
| | | request.setEmpSex("男"); |
| | | request.setMphone("18200000000"); |
| | | request.setEmail("sn93@qq.com"); |
| | | request.setDeptIds(0L); |
| | | request.setPositionId(1L); |
| | | request.setSuperLevel(0); |
| | | request.setHideMobile(0); |
| | | EmployeeUtil.saveStaffNode(request); |
| | | |
| | | // GetStaffNodeRequest request = new GetStaffNodeRequest(); |
| | | // request.setEmpId(1L); |
| | | // request.setMobile("15828353127"); |
| | | // request.setEntercode("981100006005878"); |
| | | // EmployeeUtil.getStaffNode(request); |
| | | |
| | | } |
| | | } |