瀏覽代碼

新增梅花积分对外接口,新增常住人口信息导入修改数据

Administrator 2 年之前
父節點
當前提交
740da00345

+ 13 - 6
boman-api/boman-domain/src/main/java/com/boman/domain/CzrkJzdz.java

@@ -9,6 +9,8 @@ import lombok.experimental.SuperBuilder;
 
 import java.util.List;
 
+import static com.boman.domain.annotation.Excel.Type.IMPORT;
+
 /**
  * 常住人口对应的居住地址对象 czrk_jzdz
  *
@@ -37,7 +39,7 @@ public class CzrkJzdz {
     /**
      * 身份证号码
      */
-    //@Excel(name = "身份证号码")
+    @Excel(name = "身份证号码",type = IMPORT)
     private String idCard;
 
     /**
@@ -97,32 +99,37 @@ public class CzrkJzdz {
     /**
      * 居住地的镇
      */
-    //@Excel(name = "居住地的镇")
+    @Excel(name = "居住地的镇Id",type = IMPORT)
     private String townId;
 
     /**
      * 居住地的镇
      */
-    //@Excel(name = "居住地的镇")
+    @Excel(name = "居住地的镇",type = IMPORT)
     private String town;
 
     /**
      * 居住地的村
      */
-    //@Excel(name = "居住地的村")
+    @Excel(name = "居住地的村Id",type = IMPORT)
     private String villageId;
 
     /**
      * 居住地的村
      */
-    //@Excel(name = "居住地的村")
+    @Excel(name = "居住地的村",type = IMPORT)
     private String village;
 
     /**
      * 居住地的详细地址
      */
-    @Excel(name = "居住详细地址")
+    @Excel(name = "居住详细地址",type = IMPORT)
     private String nowIn;
+    @Excel(name = "居住地的组Id",type = IMPORT)
+    private String villagerGroupId;
+
+    @Excel(name = "居住地的组",type = IMPORT)
+    private String villagerGroup;
 
     /**
      * Y有效地址,N无效地址

+ 11 - 1
boman-web-core/src/main/java/com/boman/web/core/controller/CzrkController.java

@@ -221,13 +221,23 @@ public class CzrkController extends BaseController {
     /**
      * 暂未测试
      * 外部访问czrk的字段
-     * RSE加密请求
+     * RSA加密请求
+     * todo 需要对方配合才能使用,需要两对密钥对
      */
     @PostMapping("/open/getInfoJson")
     public AjaxResult getInfoJson(@RequestBody  JsonRequest jsonRequest) {
         return czrkService.getInfoJson(jsonRequest);
     }
 
+
+    /**
+     * 梅花积分对外接口
+     */
+    @GetMapping("/open/getInfoMeihua/{appId}/{idCard}")
+    public AjaxResult getInfoMeihua(@PathVariable("appId") String appId,@PathVariable("idCard") String idCard) {
+        return czrkService.getInfoMeihua(appId,idCard);
+    }
+
     /**
      * 人员数据导出
      *

+ 19 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/CzrkJzdzController.java

@@ -8,10 +8,12 @@ import com.boman.common.security.annotation.PreAuthorize;
 import com.boman.domain.Czrk;
 import com.boman.domain.CzrkJzdz;
 import com.boman.domain.TableDataInfo;
+import com.boman.domain.ThirdPartInfo;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.web.core.service.czrk.ICzrkJzdzService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -40,6 +42,23 @@ public class CzrkJzdzController extends BaseController {
         return getDataTable(list);
     }
 
+
+    /**
+     * 常住人口信息导入
+     * @param file
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/importData")
+    public AjaxResult importData(MultipartFile file) throws Exception
+    {
+        ExcelUtil<CzrkJzdz> util = new ExcelUtil<CzrkJzdz>(CzrkJzdz.class);
+        List<CzrkJzdz> czrkJzdzList = util.importExcel(file.getInputStream());
+        return czrkJzdzService.importCzrkJzdz(czrkJzdzList);
+    }
+
+
+
     /**
      * 导出常住人口对应的居住地址列表
      */

+ 7 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/CzrkJzdzMapper.java

@@ -86,4 +86,11 @@ import java.util.List;
 
     List<CzrkJzdz> getCzrkJzdzByTime(@Param("todayStartStr")String todayStartStr, @Param("todayEndStr")String todayEndStr,
                                      @Param("regionId")String regionId, @Param("status")String status);
+
+    /**
+     * 根据行政规划表id查询对应行政名称
+     * @param areaId
+     * @return
+     */
+  String  selectChinaArea(String areaId);
 }

+ 54 - 0
boman-web-core/src/main/java/com/boman/web/core/service/czrk/CzrkJzdzServiceImpl.java

@@ -10,6 +10,7 @@ import com.boman.common.core.web.page.TableSupport;
 import com.boman.domain.Czrk;
 import com.boman.domain.CzrkJzdz;
 import com.boman.domain.SysUser;
+import com.boman.domain.dto.AjaxResult;
 import com.boman.web.core.mapper.CzrkJzdzMapper;
 import com.boman.web.core.mapper.CzrkMapper;
 import com.boman.web.core.utils.AuthUtils;
@@ -42,6 +43,8 @@ public class CzrkJzdzServiceImpl implements ICzrkJzdzService {
     @Resource
     private CzrkMapper czrkMapper;
 
+
+
     /**
      * 查询常住人口对应的居住地址
      *
@@ -208,6 +211,57 @@ public class CzrkJzdzServiceImpl implements ICzrkJzdzService {
         return czrkList;
     }
 
+    /**
+     * 常住 人口信息导入
+     * 根据身份证进行更改常住人口信息(必须常住人口表czrk_jzdz有数据)
+     * @param czrkJzdzList
+     * @return
+     */
+    @Override
+    public AjaxResult importCzrkJzdz(List<CzrkJzdz> czrkJzdzList) {
+        if (czrkJzdzList == null || czrkJzdzList.size() < 1){
+            return AjaxResult.error("当前表格数据为空");
+        }
+        StringBuilder sb = new StringBuilder();
+        for (CzrkJzdz czrkJzdz : czrkJzdzList) {
+            czrkJzdz.setProvinceId("12");
+            czrkJzdz.setProvince("安徽省");
+            czrkJzdz.setCityId("340800000000");
+            czrkJzdz.setCity("安庆市");
+            czrkJzdz.setRegionId("340882000000");
+            czrkJzdz.setRegionId("潜山市");
+            String townId = czrkJzdz.getTownId();
+            if (StringUtils.isNotEmpty(townId)){
+                //根据行政规划Id去查询行政规划的名称
+                String tow = czrkJzdzMapper.selectChinaArea(townId);
+                czrkJzdz.setTown(tow);
+            }
+            String villageId = czrkJzdz.getVillageId();
+            if (StringUtils.isNotEmpty(villageId)){
+                //根据行政规划Id去查询行政规划的名称
+                String village = czrkJzdzMapper.selectChinaArea(villageId);
+                czrkJzdz.setVillage(village);
+            }
+            String villagerGroupId = czrkJzdz.getVillagerGroupId();
+            if (StringUtils.isNotEmpty(villagerGroupId)){
+                //根据行政规划Id去查询行政规划的名称
+                String villagerGroup = czrkJzdzMapper.selectChinaArea(villagerGroupId);
+                czrkJzdz.setVillagerGroup(villagerGroup);
+            }
+            czrkJzdz.setStatus("Y");
+            int i = czrkJzdzMapper.updateByIdCard(czrkJzdz);
+            if (i == 0){
+                sb.append(czrkJzdz.getIdCard()).append("---");
+            }
+        }
+        if (sb.length() > 0){
+            sb.append("不存在或者信息无需修改");
+        }else {
+            sb.append("处理完成:").append(czrkJzdzList.size()).append("条");
+        }
+        return AjaxResult.success(sb.toString());
+    }
+
     /**
      * 根据czrdId查询对应的居住地址
      *

+ 41 - 2
boman-web-core/src/main/java/com/boman/web/core/service/czrk/CzrkServiceImpl.java

@@ -2699,8 +2699,8 @@ public class CzrkServiceImpl implements ICzrkService {
     }
 
     /**
-     * RSE加密请求
-     * 用RSE加密 ase的key(因为res加密有长度限制,ase没有,ase只有一个秘钥,所以使用rse来加密ase)
+     * RSA加密请求
+     * 用RSA加密 ase的key(因为res加密有长度限制,ase没有,ase只有一个秘钥,所以使用rse来加密ase)
      * 公钥对ase进行加密
      * 私钥对签名进行加密
      * 加密前的ase对请求参数进行加密
@@ -2791,6 +2791,45 @@ public class CzrkServiceImpl implements ICzrkService {
         return AjaxResult.success(czrk);
     }
 
+    /**
+     * 对外梅花积分接口
+     * @param appId
+     * @param idCard
+     * @return
+     */
+    @Override
+    public AjaxResult getInfoMeihua(String appId, String idCard) {
+        if (StringUtils.isBlank(appId)) {
+            return AjaxResult.error("缺少appId参数");
+        }
+        if (StringUtils.isBlank(idCard)) {
+            return AjaxResult.error("缺少身份证信息参数");
+        }
+        //拿着appid去查询对应的密钥对
+        JSONObject ipTimes = ipTimesService.selectByAppId(appId);
+        if (ipTimes == null || ipTimes.size() == 0) {
+            return AjaxResult.error("该appId不存在");
+        }
+        String today = DateUtils.getDate();
+        String redisKey = APPID_TIMES + appId + ":" + today;
+        Integer cacheTimes = redisService.getCacheObject(redisKey);
+        if (cacheTimes == null) cacheTimes = 0;
+        int times = ipTimes.getIntValue("times");
+        if (++cacheTimes > times) {
+            log.error("ip:{}, 时间:{}, 访问超次数, 已经查询了 {} 次", ipTimes.getString("ip"), today, cacheTimes);
+            return AjaxResult.error("今日访问次数已用尽,请明日再试");
+        }
+        //增加查询次数
+        long time = DateUtils.getTodayEnd().getTime(), time1 = DateUtils.getNowDate().getTime();
+        redisService.setCacheObject(redisKey, cacheTimes, ((time - time1) / 1000), TimeUnit.SECONDS);
+
+        Czrk czrk = czrkMapper.selectCzrkByIdCard(idCard);
+        if (czrk != null){
+            return AjaxResult.success();
+        }
+        return AjaxResult.error();
+    }
+
     /**
      * 一键确认家庭成员
      *

+ 7 - 0
boman-web-core/src/main/java/com/boman/web/core/service/czrk/ICzrkJzdzService.java

@@ -3,6 +3,7 @@ package com.boman.web.core.service.czrk;
 
 import com.boman.domain.Czrk;
 import com.boman.domain.CzrkJzdz;
+import com.boman.domain.dto.AjaxResult;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -97,4 +98,10 @@ public interface ICzrkJzdzService {
     List<CzrkJzdz> getCzrkJzdzByTime(String todayStartStr, String todayEndStr, String regionId, String status);
 
     List<Czrk> exportQianShanCz();
+
+    /**
+     * 常住人口导入
+     * @return
+     */
+    AjaxResult importCzrkJzdz(List<CzrkJzdz> czrkJzdzList);
 }

+ 8 - 0
boman-web-core/src/main/java/com/boman/web/core/service/czrk/ICzrkService.java

@@ -113,6 +113,14 @@ public interface ICzrkService {
     AjaxResult getInfo(String appKey, String appSecret, String idCard);
     AjaxResult getInfoJson(JsonRequest jsonRequest);
 
+    /**
+     * 对外梅花积分接口
+     * @param appId
+     * @param idCard
+     * @return
+     */
+    AjaxResult getInfoMeihua(String appId,String idCard);
+
     /**
      * 一键确认家庭成员
      * @param ids

+ 18 - 1
boman-web-core/src/main/resources/mapper/CzrkJzdzMapper.xml

@@ -21,6 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="town"    column="town"    />
         <result property="villageId"    column="village_id"    />
         <result property="village"    column="village"    />
+        <result property="villagerGroupId"    column="villager_group_id"    />
+        <result property="villagerGroup"    column="villager_group"    />
         <result property="nowIn"    column="now_in"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
@@ -30,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectCzrkJzdzVo">
-        select id, czrk_id, id_card, user_name, sort, dept_id, province_id, province, city_id, city, region_id, region, town_id, town, village_id, village, now_in, create_by, create_time, update_by, update_time, status from czrk_jzdz
+        select id, czrk_id, id_card, user_name, sort, dept_id, province_id, province, city_id, city, region_id, region, town_id, town, village_id, village,villager_group,villager_group_id now_in, create_by, create_time, update_by, update_time, status from czrk_jzdz
     </sql>
 
     <select id="selectCzrkJzdzList" resultMap="CzrkJzdzResult">
@@ -130,6 +132,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="town != null">town,</if>
             <if test="villageId != null">village_id,</if>
             <if test="village != null">village,</if>
+            <if test="villagerGroupId != null">villager_group_id,</if>
+            <if test="villagerGroup != null">villager_group,</if>
             <if test="nowIn != null">now_in,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
@@ -153,6 +157,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="town != null">#{town},</if>
             <if test="villageId != null">#{villageId},</if>
             <if test="village != null">#{village},</if>
+            <if test="villagerGroupId != null">#{villagerGroupId},</if>
+            <if test="villagerGroup != null">#{villagerGroup},</if>
             <if test="nowIn != null">#{nowIn},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
@@ -180,6 +186,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="town != null">town = #{town},</if>
             <if test="villageId != null">village_id = #{villageId},</if>
             <if test="village != null">village = #{village},</if>
+            <if test="villagerGroupId != null">villager_group_id = #{villagerGroupId},</if>
+            <if test="villagerGroup != null">villager_group = #{villagerGroup},</if>
             <if test="nowIn != null">now_in = #{nowIn},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
@@ -208,6 +216,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="town != null">town = #{town},</if>
             <if test="villageId != null">village_id = #{villageId},</if>
             <if test="village != null">village = #{village},</if>
+            <if test="villagerGroupId != null">villager_group_id = #{villagerGroupId},</if>
+            <if test="villagerGroup != null">villager_group = #{villagerGroup},</if>
             <if test="nowIn != null">now_in = #{nowIn},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
@@ -236,6 +246,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="town != null">town = #{town},</if>
             <if test="villageId != null">village_id = #{villageId},</if>
             <if test="village != null">village = #{village},</if>
+            <if test="villagerGroupId != null">villager_group_id = #{villagerGroupId},</if>
+            <if test="villagerGroup != null">villager_group = #{villagerGroup},</if>
             <if test="nowIn != null">now_in = #{nowIn},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
@@ -360,4 +372,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where 1=1 and status = #{status} and create_time &gt;= #{todayStartStr} and create_time &lt;= #{todayEndStr} and region_id = #{regionId}
         group by id_card
     </select>
+
+
+    <select id="selectChinaArea" resultType="java.lang.String">
+        select a.name from china_area as a where area_id = #{areaId}
+    </select>
 </mapper>