Ver código fonte

鄂州办一网通接口

shuzhan 8 meses atrás
pai
commit
16a74c5623

+ 8 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/UiasService.java

@@ -2,6 +2,7 @@ package com.jpsoft.campus.modules.base.service;
 
 import com.github.pagehelper.Page;
 import com.jpsoft.campus.modules.base.entity.SchoolInfo;
+import com.jpsoft.campus.modules.base.entity.UserInformationProvincial;
 import com.jpsoft.campus.modules.common.dto.Sort;
 
 import java.util.List;
@@ -9,4 +10,11 @@ import java.util.Map;
 
 public interface UiasService {
 	String getToken(String code);
+	String logOut(String uiasId);
+
+	//省级
+	String getProvincialToken(String path,String appId,String appSecret);
+	String applyno(String path,String token);
+	String submitAll(String path, String token,UserInformationProvincial provincial);
+
 }

+ 105 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/impl/UiasServiceImpl.java

@@ -3,9 +3,14 @@ package com.jpsoft.campus.modules.base.service.impl;
 
 import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSONObject;
+import com.jpsoft.campus.modules.base.entity.ApplicationPrimary;
+import com.jpsoft.campus.modules.base.entity.UserInformationProvincial;
+import com.jpsoft.campus.modules.base.service.ApplicationPrimaryService;
 import com.jpsoft.campus.modules.base.service.UiasService;
 import com.jpsoft.campus.modules.common.utils.FileUtil;
+import com.jpsoft.campus.modules.common.utils.HttpConnectionUtil;
 import com.jpsoft.campus.modules.common.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
@@ -54,4 +59,104 @@ public class UiasServiceImpl implements UiasService {
 			return "";
 		}
 	}
+
+	@Override
+	public String logOut(String uiasId){
+		HashMap<String, Object> map = new HashMap<>();
+		map.put("sessionId","uiasId");
+		map.put("goBack","");
+
+		String body = HttpRequest.post("https://oauth.hubei.gov.cn:8443/uias/uias/LogOut").form(map).execute().body();
+		JSONObject jsonBody = JSONObject.parseObject(body);
+
+		if (jsonBody!=null) {
+			String accessToken = jsonBody.getString("access_token");
+//			Integer expiresIn = jsonBody.getInteger("expires_in");
+
+//			if (StringUtils.isNotBlank(accessToken) && expiresIn!=null) {
+			if (StringUtils.isNotBlank(accessToken)) {
+//				valueOperations.set("hikCloud_accessToken", accessToken, expiresIn, TimeUnit.SECONDS);
+				return accessToken;
+			} else {
+				return "";
+			}
+		}
+		else{
+			return "";
+		}
+	}
+
+	@Override
+	public String getProvincialToken(String path,String appId,String appSecret){
+		HashMap<String, Object> map = new HashMap<>();
+		map.put("key",appId);
+
+		String body = HttpRequest.post(path + "/gateway/api/getToken").form(map).execute().body();
+		JSONObject jsonBody = JSONObject.parseObject(body);
+
+		if (jsonBody!=null) {
+			String accessToken = jsonBody.toString();
+			if (StringUtils.isNotBlank(accessToken)) {
+				return accessToken;
+			} else {
+				return "";
+			}
+		}
+		else{
+			return "";
+		}
+	}
+
+	@Override
+	public String applyno(String path,String token){
+		HashMap<String, Object> map = new HashMap<>();
+		map.put("sceneNo","42PC08017123");
+		map.put("sceneBusiness",4);
+
+		HashMap<String, String> headersMap = new HashMap<>();
+		map.put("Authorization",token);
+
+		String body = HttpRequest.post(path + "/gateway/api/sbk/declare/ownerDeclare/applyno").header("Authorization",token).form(map).execute().body();
+		JSONObject jsonBody = JSONObject.parseObject(body);
+
+		if (jsonBody!=null) {
+			String code = jsonBody.getString("code");
+			String data = jsonBody.getString("data");
+
+			return data;
+		}
+		else{
+			return "";
+		}
+	}
+
+	@Autowired
+	private ApplicationPrimaryService applicationPrimaryService;
+	@Override
+	public String submitAll(String path,String token, UserInformationProvincial provincial){
+		HashMap<String, Object> map = new HashMap<>();
+		map.put("declare",provincial);
+
+		HashMap<String, String> headersMap = new HashMap<>();
+		map.put("Authorization",token);
+
+		String body = HttpRequest.post(path + "/gateway/api/sbk/declare/subDeclare/submitAll").header("Authorization",token).form(map).execute().body();
+		JSONObject jsonBody = JSONObject.parseObject(body);
+
+		if (jsonBody!=null) {
+			String code = jsonBody.getString("code");
+			String data = jsonBody.getString("data");
+
+			ApplicationPrimary applicationPrimary = applicationPrimaryService.get(provincial.getApplicantId());
+			applicationPrimary.setCode(code);
+			applicationPrimary.setApplyNo(provincial.getApplyNo());
+			applicationPrimary.setSubNos(data);
+			applicationPrimaryService.update(applicationPrimary);
+
+			return data;
+		}
+		else{
+			return "";
+		}
+	}
 }

+ 3 - 3
web/src/main/java/com/jpsoft/campus/modules/mobile/controller/PersonInfoApiController.java

@@ -663,8 +663,7 @@ public class PersonInfoApiController {
             List<UserInformationProvincial> primaryList = applicationPrimaryService.findOfficeByProvincial(applyNo,limit);
             List<Map> returnList = new ArrayList<>();
             for(UserInformationProvincial provincial : primaryList){
-                Map userMap = new HashMap();
-                userMap.put("declare",provincial);
+
 
                 UserInformationProvincialSubDeclares subDeclares = new UserInformationProvincialSubDeclares();
                 subDeclares.setApplicantName(provincial.getApplicantName());
@@ -687,7 +686,8 @@ public class PersonInfoApiController {
                 provincial.setSubDeclares(subDeclaresList);
 
 
-
+                Map userMap = new HashMap();
+                userMap.put("declare",provincial);
                 returnList.add(userMap);
             }
 

+ 91 - 2
web/src/main/java/com/jpsoft/campus/modules/mobile/controller/UiasApiController.java

@@ -1,10 +1,11 @@
 package com.jpsoft.campus.modules.mobile.controller;
 
 
-import com.jpsoft.campus.modules.base.entity.PersonInfo;
+import com.jpsoft.campus.modules.base.entity.*;
 import com.jpsoft.campus.modules.base.service.*;
 import com.jpsoft.campus.modules.common.dto.MessageResult;
 import com.jpsoft.campus.modules.common.utils.JwtUtil;
+import com.jpsoft.campus.modules.common.utils.StringUtils;
 import com.jpsoft.campus.modules.sys.service.SysLogService;
 import com.wfl.uias.dto.JITObject;
 import com.wfl.uias.http.HttpClientExecutor;
@@ -53,10 +54,21 @@ public class UiasApiController {
             String code = (String)request.getParameter("code");
             String appCode = (String)request.getParameter("appCode");
             String state = (String)request.getParameter("state");
+            String p03 = (String)request.getParameter("p03");
+            String p04 = (String)request.getParameter("p04");
+            String p05 = (String)request.getParameter("p05");
+            String p06 = (String)request.getParameter("p06");
+            String p07 = (String)request.getParameter("p07");
+            String p08 = (String)request.getParameter("p08");
+            String p09 = (String)request.getParameter("p09");
+            String p10 = (String)request.getParameter("p10");
 
 
 //            String url = "http://wsbm.xiaoxinda.com/#/external/index" + "?code=" + code + "&state=" + state;
 
+            String html = "http://wsbm.xiaoxinda.com/#/external/index";
+            String mobile = "http://wsbm.xiaoxinda.com/#/external/mobile";
+
             String token = uiasService.getToken(code);
 
             PersonInfo personInfo = personInfoService.findByUiasId(token);
@@ -118,7 +130,13 @@ public class UiasApiController {
             }
 
             String personToken = JwtUtil.createToken(jwtSecret, String.valueOf(personInfo.getId()), DateTime.now().plusHours(6).toDate());
-            String url = "http://wsbm.xiaoxinda.com/#/external/index" + "?token=" + personToken;
+
+            String url = html + "?token=" + personToken;
+
+            if("02".equals(p10)){
+                url = mobile + "?token=" + personToken;
+            }
+
             response.setContentType("application/json;charset=utf-8");
             response.sendRedirect(url);
         } catch (Exception ex){
@@ -171,6 +189,77 @@ public class UiasApiController {
         return messageResult;
     }
 
+    @Autowired
+    private ApplicationPrimaryService applicationPrimaryService;
+
+    @PostMapping("uploadProvincialUser")
+    @ApiOperation(value = "上传省级数据")
+    @ResponseBody
+    public MessageResult<Map> uploadProvincialUser(
+            @RequestParam(value="schoolType",defaultValue="test") String status
+            ) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+            String path = "https://59.208.149.51:10087";
+            String appId = "key_onethingApi_test_ztsbk_421000000000_jyzspt_13ee24a0c4244cdba2a10bdbf541516e";
+            String appSecret = "secret_onethingApi_test_ztsbk_421000000000_jyzspt_b3670cf58542411c8605df86cee70a2e";
+            if("real".equals(status)) {
+                path = "https://59.208.149.51:10086/";//正式
+                appId = "";
+                appSecret = "";
+            }
+            String token = uiasService.getProvincialToken(path,appId,appSecret);
+            String applyNo = uiasService.applyno(path,token);
+            Integer limit = 10;
+
+            List<UserInformationProvincial> primaryList = applicationPrimaryService.findOfficeByProvincial(applyNo,limit);
+            List<Map> returnList = new ArrayList<>();
+            for(UserInformationProvincial provincial : primaryList){
+                UserInformationProvincialSubDeclares subDeclares = new UserInformationProvincialSubDeclares();
+                subDeclares.setApplicantName(provincial.getApplicantName());
+                subDeclares.setApplicantPhone(provincial.getApplicantPhone());
+                subDeclares.setApplyNo(applyNo);
+                subDeclares.setLiceseNo(provincial.getLicenseNo());
+                subDeclares.setTargetId(provincial.getTargetId());
+                subDeclares.setTargetName(provincial.getTargetName());
+
+                UserInformationProvincialFileDeclares fileDeclares = new UserInformationProvincialFileDeclares();
+                fileDeclares.setApplyNo(applyNo);
+
+                List<UserInformationProvincialFileDeclares> fileDeclaresList = new ArrayList<>();
+                fileDeclaresList.add(fileDeclares);
+
+                subDeclares.setFileDeclares(fileDeclaresList);
+
+                List<UserInformationProvincialSubDeclares> subDeclaresList = new ArrayList<>();
+                subDeclaresList.add(subDeclares);
+                provincial.setSubDeclares(subDeclaresList);
+
+                Map userMap = new HashMap();
+                userMap.put("declare",provincial);
+                returnList.add(userMap);
+
+
+                String data = uiasService.submitAll(path,token,provincial);
+            }
+
+//            for(Map map : returnList){
+//                uiasService.submitAll(path,token,map.get("declare"));
+//            }
+
+
+            messageResult.setResult(true);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
     public static void main(String[] args) {
         String name = "舒展1232";