浏览代码

鄂州办一网通接口

shuzhan 8 月之前
父节点
当前提交
abdffe5200

+ 1 - 0
common/src/main/java/com/jpsoft/campus/modules/base/dao/PersonInfoDAO.java

@@ -24,4 +24,5 @@ public interface PersonInfoDAO {
 
     PersonInfo findByIdCard(String idCard);
 	PersonInfo findByUiasId(String uiasId);
+	PersonInfo findByUserId(String userId);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/campus/modules/base/entity/PersonInfo.java

@@ -84,4 +84,9 @@ public class PersonInfo {
 	@ApiModelProperty(value = "一网通ID")
 	private String uiasId;
 
+	private String userId;
+
+	private String userInfo;
+	private String otherInfo;
+
 }

+ 1 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/PersonInfoService.java

@@ -18,5 +18,6 @@ public interface PersonInfoService {
     PersonInfo findByOpenId(String openId);
     PersonInfo findByIdCard(String idCard);
 	PersonInfo findByUiasId(String uiasId);
+	PersonInfo findByUserId(String userId);
 	Map findUiasUserByToken(String token);
 }

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

@@ -17,4 +17,6 @@ public interface UiasService {
 	String getProvincialToken(String path,String appId,String appSecret);
 	String applyno(String path,String token);
 	Map submitAll(String path, String token, UserInformationProvincial provincial, UserInformationProvincialSubDeclares subDeclares);
+
+	String getUserInfo(String token);
 }

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

@@ -90,6 +90,11 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 		return personInfoDAO.findByUiasId(uiasId);
 	}
 
+	@Override
+	public PersonInfo findByUserId(String userId){
+		return personInfoDAO.findByUserId(userId);
+	}
+
 	@Override
 	public Map findUiasUserByToken(String token){
 		Map<String, Object> map = null;

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

@@ -229,6 +229,28 @@ public class UiasServiceImpl implements UiasService {
 		return "";
 	}
 
+	@Override
+	public String getUserInfo(String token) {
+		HashMap<String, Object> map = new HashMap<>();
+		map.put("access_token",token);
+
+		String body = HttpRequest.post("https://oauth.hubei.gov.cn:8443/uias/unity/user_info").form(map).execute().body();
+		JSONObject jsonBody = JSONObject.parseObject(body);
+
+		if (jsonBody!=null) {
+			String result = jsonBody.getString("result");
+
+			if (StringUtils.isNotBlank(result)) {
+				return result;
+			} else {
+				return "";
+			}
+		}
+		else{
+			return "";
+		}
+	}
+
 	@Autowired
 	private ApplicationPrimaryService applicationPrimaryService;
 	@Override

+ 19 - 1
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -17,6 +17,9 @@
         <result property="houseType" column="house_type"/>
         <result property="nowAddress" column="now_address"/>
         <result property="uiasId" column="uias_id"/>
+        <result property="userId" column="user_id"/>
+        <result property="userInfo" column="user_info"/>
+        <result property="otherInfo" column="other_info"/>
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.campus.modules.base.entity.PersonInfo">
         <!--
@@ -26,7 +29,7 @@
         -->
         <![CDATA[
 		insert into base_person_info
-	    (id_,create_by,create_time,update_by,update_time,del_flag,name_,id_card,phone_,open_id,house_type,now_address,uias_id)
+	    (id_,create_by,create_time,update_by,update_time,del_flag,name_,id_card,phone_,open_id,house_type,now_address,uias_id,user_id,user_info,other_info)
 		values
 		(
             #{id,jdbcType=VARCHAR}
@@ -42,6 +45,9 @@
             ,#{houseType,jdbcType=VARCHAR}
             ,#{nowAddress,jdbcType=VARCHAR}
             ,#{uiasId,jdbcType=VARCHAR}
+            ,#{userId,jdbcType=VARCHAR}
+            ,#{userInfo,jdbcType=VARCHAR}
+            ,#{otherInfo,jdbcType=VARCHAR}
 		)
 	]]>
     </insert>
@@ -87,6 +93,15 @@
             <if test="uiasId!=null">
                 uias_id=#{uiasId,jdbcType=VARCHAR},
             </if>
+            <if test="userId!=null">
+                user_id=#{userId,jdbcType=VARCHAR},
+            </if>
+            <if test="userInfo!=null">
+                user_info=#{userInfo,jdbcType=VARCHAR},
+            </if>
+            <if test="otherInfo!=null">
+                other_info=#{otherInfo,jdbcType=VARCHAR},
+            </if>
         </set>
         where id_=#{id}
     </update>
@@ -134,4 +149,7 @@
     <select id="findByUiasId" resultMap="PersonInfoMap">
         select * from base_person_info where uias_id=#{0} and del_flag=0 limit 1
     </select>
+    <select id="findByUserId" resultMap="PersonInfoMap">
+        select * from base_person_info where user_id=#{0} and del_flag=0 limit 1
+    </select>
 </mapper>

+ 72 - 30
web/src/main/java/com/jpsoft/campus/modules/mobile/controller/UiasApiController.java

@@ -1,13 +1,11 @@
 package com.jpsoft.campus.modules.mobile.controller;
 
 
-import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
+import cn.hutool.json.JSONObject;
 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;
@@ -15,12 +13,7 @@ import com.wfl.uias.servlet.JITResponseHandler;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+
 import org.codehaus.jackson.map.ObjectMapper;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,17 +21,10 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
-import javax.net.ssl.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
+
 import java.util.*;
 
 
@@ -110,24 +96,57 @@ public class UiasApiController {
                 System.out.println("map:" + map);
                 System.out.println("用户详细信息json:" + str);
 
+
+
+                final String fullUri2 = "https://oauth.hubei.gov.cn:8443/uias/unity/user_info";
+                HttpClientExecutor executor2 = new HttpClientExecutor(fullUri2);
+                executor2.addRequestParam("access_token", token);
+
+                JITResponseHandler responseHandler2 = new JITResponseHandler();
+                executor2.execute(responseHandler2, "get", filePath, decrypto);
+                JITObject jitObject2= responseHandler2.getObj();
+
+                String str2 = jitObject2.getOriginalText();
+
+                JSONObject jsonObject = new JSONObject(str2);
+
+                String userId = jsonObject.get("userId").toString();
+
+                System.out.println("用户详细信息json2:" + str2);
+
                 if(map != null) {
                     String idCard = (String)map.get("id_card");
-                    personInfo = personInfoService.findByIdCard(idCard);
-
-                    if(personInfo == null){
-                        personInfo = new PersonInfo();
-                        personInfo.setId(UUID.randomUUID().toString());
-                        personInfo.setName((String)map.get("name"));
-                        personInfo.setIdCard((String)map.get("id_card"));
-                        personInfo.setPhone((String)map.get("mobile_phone"));
-                        personInfo.setUiasId(token);
 
-                        personInfo.setDelFlag(false);
-                        personInfo.setCreateTime(new Date());
-
-                        personInfoService.insert(personInfo);
+                    personInfo = personInfoService.findByUserId(userId);
+                    if(personInfo == null) {
+                        personInfo = personInfoService.findByIdCard(idCard);
+                        if (personInfo == null) {
+                            personInfo = new PersonInfo();
+                            personInfo.setId(UUID.randomUUID().toString());
+                            personInfo.setName((String) map.get("name"));
+                            personInfo.setIdCard((String) map.get("id_card"));
+                            personInfo.setPhone((String) map.get("mobile_phone"));
+                            personInfo.setUiasId(token);
+                            personInfo.setUserId(userId);
+                            personInfo.setOtherInfo(str);
+                            personInfo.setUserInfo(str2);
+
+                            personInfo.setDelFlag(false);
+                            personInfo.setCreateTime(new Date());
+
+                            personInfoService.insert(personInfo);
+                        } else {
+                            personInfo.setUiasId(token);
+                            personInfo.setUserId(userId);
+                            personInfo.setOtherInfo(str);
+                            personInfo.setUserInfo(str2);
+                            personInfoService.update(personInfo);
+                        }
                     }else{
                         personInfo.setUiasId(token);
+                        personInfo.setUserId(userId);
+                        personInfo.setOtherInfo(str);
+                        personInfo.setUserInfo(str2);
                         personInfoService.update(personInfo);
                     }
                 }else{
@@ -137,6 +156,9 @@ public class UiasApiController {
 //                    personInfo.setIdCard((String)map.get("id_card"));
 //                    personInfo.setPhone((String)map.get("mobile_phone"));
                     personInfo.setUiasId(token);
+                    personInfo.setUserId(userId);
+                    personInfo.setOtherInfo(str);
+                    personInfo.setUserInfo(str2);
 
                     personInfo.setDelFlag(false);
                     personInfo.setCreateTime(new Date());
@@ -178,6 +200,7 @@ public class UiasApiController {
             String filePath = path;
             //使用授权码换取token
             final String fullUri = "https://oauth.hubei.gov.cn:8443/uias/unity/other_info";
+
             HttpClientExecutor executor = new HttpClientExecutor(fullUri);
             executor.addRequestParam("access_token", uiasId);
 
@@ -186,13 +209,32 @@ public class UiasApiController {
             JITResponseHandler responseHandler = new JITResponseHandler();
             executor.execute(responseHandler, "get", filePath, decrypto);
             JITObject jitObject = responseHandler.getObj();
+
             String str = jitObject.getText();
 
+
             org.codehaus.jackson.map.ObjectMapper objectMapper = new ObjectMapper();
             map = objectMapper.readValue(str, Map.class);
             System.out.println("map:" + map);
             System.out.println("用户详细信息json:" + str);
 
+
+            final String fullUri2 = "https://oauth.hubei.gov.cn:8443/uias/unity/user_info";
+            HttpClientExecutor executor2 = new HttpClientExecutor(fullUri2);
+            executor2.addRequestParam("access_token", uiasId);
+
+            JITResponseHandler responseHandler2 = new JITResponseHandler();
+            executor2.execute(responseHandler2, "get", filePath, decrypto);
+            JITObject jitObject2= responseHandler2.getObj();
+
+            String str2 = jitObject2.getOriginalText();
+
+            JSONObject jsonObject = new JSONObject(str2);
+            String userId = jsonObject.get("userId").toString();
+
+            System.out.println("用户详细信息json2:" + str2);
+            System.out.println("用户详细信息json2:" + userId);
+
             messageResult.setData(map);
             messageResult.setResult(true);
         } catch (Exception ex) {