Przeglądaj źródła

fix 新增每10分钟抓取一次核酸数据

tjf 3 lat temu
rodzic
commit
0cef2992d3

+ 8 - 0
boman-api/boman-domain/src/main/java/com/boman/domain/Czrk.java

@@ -252,6 +252,14 @@ public class Czrk extends BaseEntity{
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date confirmInfoUserTime;
+    /**
+     * 是否完成核酸
+     */
+    private String isNucleicAcid;
+    /**
+     * 最后一次核酸时间
+     */
+    private String nucleicAcidTime;
 
     /**
      * 是否删除 默认为 "N"

+ 3 - 3
boman-web-core/src/main/java/com/boman/web/core/domain/AccountingData.java

@@ -15,7 +15,7 @@ public class AccountingData extends BaseEntity {
     /**
      * id
      */
-    private Long id;
+    private String id;
 
     /**
      * 检验结果出具时间(审核时间)
@@ -114,7 +114,7 @@ public class AccountingData extends BaseEntity {
      */
     private String timeSlot;
 
-    public Long getId() {
+    public String getId() {
         return id;
     }
 
@@ -143,7 +143,7 @@ public class AccountingData extends BaseEntity {
     }
 
 
-    public void setId(Long id) {
+    public void setId(String id) {
         this.id = id;
     }
 

+ 12 - 3
boman-web-core/src/main/java/com/boman/web/core/domain/vo/AccountingDataVo.java

@@ -16,7 +16,7 @@ public class AccountingDataVo extends BaseEntity {
     /**
      * id
      */
-    private Long id;
+    private String id;
 
     /**
      * 检验结果出具时间(审核时间)
@@ -207,6 +207,15 @@ public class AccountingDataVo extends BaseEntity {
     private String regionXjd;
     private String villageTownsXjd;
     private String villageXjd;
+    private String nowXjd;
+
+    public String getNowXjd() {
+        return nowXjd;
+    }
+
+    public void setNowXjd(String nowXjd) {
+        this.nowXjd = nowXjd;
+    }
 
     public String getCityXjd() {
         return cityXjd;
@@ -400,7 +409,7 @@ public class AccountingDataVo extends BaseEntity {
         this.domicileSelect = domicileSelect;
     }
 
-    public Long getId() {
+    public String getId() {
         return id;
     }
 
@@ -429,7 +438,7 @@ public class AccountingDataVo extends BaseEntity {
     }
 
 
-    public void setId(Long id) {
+    public void setId(String id) {
         this.id = id;
     }
 

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

@@ -30,4 +30,11 @@ public interface AccountingDataMapper {
      * @return
      */
    List<AccountingDataVo> selectAccountingDataJzdzList(AccountingDataVo accountingData);
+
+    /**
+     * 新增
+     * @param accountingData
+     * @return
+     */
+   int insertAccountingData(AccountingData accountingData);
 }

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

@@ -51,6 +51,13 @@ public interface CzrkMapper {
      */
     int updateCzrk(Czrk czrk);
 
+    /**
+     * 根据身份证修改户籍人口的核酸信息
+     * @param czrk
+     * @return
+     */
+    int updateCzrkByNucleicAcid(Czrk czrk);
+
     /**
      * 删除常住人口
      *

+ 56 - 10
boman-web-core/src/main/java/com/boman/web/core/service/TaskService.java

@@ -1,6 +1,7 @@
 package com.boman.web.core.service;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.alibaba.nacos.common.http.HttpUtils;
@@ -17,9 +18,11 @@ import com.boman.domain.SysUser;
 import com.boman.domain.dto.FormDataDto;
 import com.boman.system.api.RemoteDeptService;
 import com.boman.system.api.RemoteUserService;
+import com.boman.web.core.domain.AccountingData;
 import com.boman.web.core.domain.BirthRecords;
 import com.boman.web.core.mapper.CzrkMapper;
 import com.boman.web.core.mapper.GridInfoMapper;
+import com.boman.web.core.service.accounting.IAccountingDataService;
 import com.boman.web.core.service.birth.BirthRecordsService;
 import com.boman.web.core.service.common.ICommonService;
 import com.boman.web.core.service.czrk.CzrkServiceImpl;
@@ -62,16 +65,6 @@ public class TaskService {
     @Resource
     private ICzrkJzdzService czrkJzdzService;
 
-    @Resource
-    private GridInfoMapper gridInfoMapper;
-    @Resource
-    private IpTimesService ipTimesService;
-    @Resource
-    private CzrkServiceImpl czrkServiceImpl;
-
-    @Autowired
-    private TokenService tokenService;
-
     @Resource
     private TableServiceCmdService tableServiceCmdService;
 
@@ -83,6 +76,9 @@ public class TaskService {
 
     @Resource
     private ICommonService commonService;
+
+    @Resource
+    private IAccountingDataService accountingDataService;
     private static final String tableName= "attendance_table";
 
     /**
@@ -569,4 +565,54 @@ public class TaskService {
             e.printStackTrace();
         }
     }
+
+
+
+    /**
+     * 获取政务网token
+     */
+    public  String getToken(){
+        String token = "";
+        Map<String, String> paramMap = new HashMap<>();
+        paramMap.put("client_id","acdf50bd13be4901b64c62b1fee862c0");
+        paramMap.put("client_secret","a3650d67fc034b2d8ea259182b3d99f3");
+        String http = "http://60.171.171.235:9090/oauth/tocken";
+        try {
+            String data = HttpClientUtils.doGet(http,paramMap);
+            JSONObject jsonObject = JSONObject.parseObject(data);
+            token = jsonObject.getString("access_token");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return token;
+    }
+    /***
+     * 抓取核酸数据每10分钟抓取一次
+     */
+    @Scheduled(cron = "0 0/10 * * * ? ")
+    /**
+     * 抓取核酸数据每10分钟抓取一次,新增到accounting_data
+     */
+    public void insertAccountingData(){
+        String token = getToken();
+        if (StringUtils.isNotBlank(token)){
+            Map<String, String> paramMap = new HashMap<>();
+            paramMap.put("client_id","acdf50bd13be4901b64c62b1fee862c0");
+            paramMap.put("access_token",token);
+            paramMap.put("sfzhm","");
+            String http = "http://60.171.171.235:9090/service/api/wjw/qshssjsjc";
+            try {
+                String data = HttpClientUtils.doGet(http,paramMap);
+                if (StringUtils.isNotBlank(data)){
+                    List<AccountingData> list = JSONObject.parseArray(data, AccountingData.class);
+                    if (list != null && list.size() > 0){
+                        //插入数据
+                        accountingDataService.insertAccountingData(list);
+                    }
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 }

+ 43 - 22
boman-web-core/src/main/java/com/boman/web/core/service/accounting/AccountingDataServiceImpl.java

@@ -12,9 +12,13 @@ import com.boman.domain.SysUser;
 import com.boman.web.core.domain.AccountingData;
 import com.boman.web.core.domain.vo.AccountingDataVo;
 import com.boman.web.core.mapper.AccountingDataMapper;
+import com.boman.web.core.mapper.CzrkMapper;
 import com.boman.web.core.utils.AuthUtils;
 import com.boman.web.core.utils.CzrkUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -36,6 +40,12 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
     @Resource
     private AccountingDataMapper accountingDataMapper;
 
+    @Resource
+    private SqlSessionFactory sqlSessionFactory;
+
+    @Resource
+    private CzrkMapper czrkMapper;
+
     /**
      * 潜山核酸数据列表页(户籍地址)
      * @param accountingData
@@ -46,17 +56,7 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
         SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
         log.info("{}于{}查询核酸户籍人口列表,查询条件:{}"
                 , sysUser.getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(accountingData));
-        //获取时段
-        String timeSlot = accountingData.getTimeSlot();
-        if (StringUtils.isNotBlank(timeSlot)){
-            //开始时间
-            String startTime = DateUtils.minusDayOfDate(Integer.parseInt(timeSlot));
-            Date endTime = DateUtils.getNowDate();
-            Map<String,Object> map = new HashMap<>();
-            map.put("startTime",startTime);
-            map.put("endTime",endTime);
-            accountingData.setParams(map);
-        }
+
         //设置查询列表权限
         setQueryRole(accountingData, sysUser, Czrk.HJ);
         List<AccountingDataVo> list = accountingDataMapper.selectAccountingDataHjList(accountingData);
@@ -79,17 +79,6 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
         SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
         log.info("{}于{}查询核酸居住人口列表,查询条件:{}"
                 , sysUser.getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(accountingData));
-        //获取时段
-        String timeSlot = accountingData.getTimeSlot();
-        if (StringUtils.isNotBlank(timeSlot)){
-            //开始时间
-            String startTime = DateUtils.minusDayOfDate(Integer.parseInt(timeSlot));
-            Date endTime = DateUtils.getNowDate();
-            Map<String,Object> map = new HashMap<>();
-            map.put("startTime",startTime);
-            map.put("endTime",endTime);
-            accountingData.setParams(map);
-        }
         //设置查询列表权限
         setQueryRole(accountingData, sysUser, Czrk.CZ);
         List<AccountingDataVo> list = accountingDataMapper.selectAccountingDataJzdzList(accountingData);
@@ -101,4 +90,36 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
         CzrkUtils.packAddrNucleicAcid(list);
         return list;
     }
+
+    /**
+     * 新增
+     * @param accountingDataList
+     * @return
+     */
+    @Override
+    public int insertAccountingData(List<AccountingData> accountingDataList) {
+        SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
+        AccountingDataMapper mapper = sqlSession.getMapper(AccountingDataMapper.class);
+
+        System.out.println("batchInsert 插入开始========");
+        long start = System.currentTimeMillis();
+        Czrk czrk = new Czrk();
+        for (int i = 0; i < accountingDataList.size(); i++) {
+            AccountingData accountingData = accountingDataList.get(i);
+            String zjhm = accountingData.getZjhm();
+            if (StringUtils.isNotBlank(zjhm)){
+                czrk.setIdCard(zjhm);
+                czrk.setNucleicAcidTime(accountingData.getCjsj());
+                //去更新常住人口表中数据
+                czrkMapper.updateCzrkByNucleicAcid(czrk);
+            }
+            String mainKey = accountingData.getMainKey();
+            accountingData.setId(mainKey);
+            mapper.insertAccountingData(accountingData);
+        }
+        sqlSession.flushStatements();
+        long end = System.currentTimeMillis();
+        System.out.println("---------------插入核酸数据耗时" + (start - end) + "---------------");
+        return 0;
+    }
 }

+ 7 - 0
boman-web-core/src/main/java/com/boman/web/core/service/accounting/IAccountingDataService.java

@@ -23,4 +23,11 @@ public interface IAccountingDataService {
      * @return
      */
     List<AccountingDataVo> nucleicAcidJzdzList(AccountingDataVo accountingData);
+
+    /**
+     * 插入数据
+     * @param accountingDataVoList
+     * @return
+     */
+    int insertAccountingData(List<AccountingData> accountingDataVoList);
 }

+ 66 - 15
boman-web-core/src/main/resources/mapper/AccountingDateMapper.xml

@@ -4,12 +4,12 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.boman.web.core.mapper.AccountingDataMapper">
 
-    <resultMap type="AccountingData" id="AccountingDataResult">
+    <resultMap type="com.boman.web.core.domain.vo.AccountingDataVo" id="AccountingDataResult">
         <result property="id" column="id"/>
         <result property="jcsj" column="jcsj"/>
         <result property="lxdh" column="lxdh"/>
         <result property="address" column="address"/>
-        <result property="batcNumber" column="batch_number"/>
+        <result property="batchNumber" column="batch_number"/>
         <result property="focusPerson" column="focus_person"/>
         <result property="jcjg" column="jcjg"/>
         <result property="fromCity" column="from_city"/>
@@ -60,45 +60,96 @@
     <select id="selectAccountingDataHjList" parameterType="com.boman.web.core.domain.vo.AccountingDataVo"
             resultMap="AccountingDataResult">
         SELECT
-        r.id,r.user_name,r.id_card as zjhm,r.province,r.city,r.region,r.village_towns,r.village,r.now_in,r.phone_num,d.lxdh,d.jcsj,d.jcdd
+        r.id,r.user_name as xm,r.id_card as zjhm,r.province,r.city,r.region,r.village_towns,r.village,r.now_in,r.phone_num,d.lxdh,d.jcsj,d.jcdd,d.cjdd,d.cjsj
         FROM czrk r left join `accounting_data` d on r.id_card = d.zjhm
         <where>
             r.is_del = 'N'
             and r.status = '1'
             and d.is_del = 'N'
-            <if test="idCard != null  and idCard != ''">and r.id_card = #{idCard}</if>
-            <if test="userName != null  and userName != ''">and r.user_name like concat(#{userName}, '%')</if>
-            <if test="params.startTime != null  and params.startTime != ''">and DATE_FORMAT(d.jcsj,'%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT(#{params.startTime},'%Y-%m-%d %H:%i:%s')</if>
-            <if test="params.endTime != null  and params.endTime != ''">and DATE_FORMAT(d.jcsj,'%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{params.endTime},'%Y-%m-%d %H:%i:%s')</if>
-            <if test="isNucleicAcid != null  and isNucleicAcid != '' and isNucleicAcid == 'N'">and DATE_FORMAT(d.jcsj,'%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT('1900-01-01 00:00:00','%Y-%m-%d %H:%i:%s')</if>
+            <if test="zjhm != null  and zjhm != ''">and r.id_card = #{zjhm}</if>
+            <if test="xm != null  and xm != ''">and r.user_name like concat(#{xm}, '%')</if>
+            <if test="params.startTime != null  and params.startTime != ''">and DATE_FORMAT(d.cjsj,'%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT(#{params.startTime},'%Y-%m-%d %H:%i:%s')</if>
+            <if test="params.endTime != null  and params.endTime != ''">and DATE_FORMAT(d.cjsj,'%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{params.endTime},'%Y-%m-%d %H:%i:%s')</if>
+            <if test="isNucleicAcid != null  and isNucleicAcid != ''">and r.is_nucleicAcid = #{isNucleicAcid}</if>
             <if test="provinceId != null  and provinceId != ''">and r.province_id = #{provinceId}</if>
             <if test="cityId != null  and cityId != ''">and r.city_id = #{cityId}</if>
             <if test="regionId != null  and regionId != ''">and r.region_id = #{regionId}</if>
             <if test="villageTownsId != null  and villageTownsId != ''">and r.village_towns_id = #{villageTownsId}</if>
             <if test="villageId != null  and villageId != ''">and r.village_id = #{villageId}</if>
         </where>
+        order by d.jcsj DESC
     </select>
 
     <select id="selectAccountingDataJzdzList" parameterType="com.boman.web.core.domain.vo.AccountingDataVo"
             resultMap="AccountingDataResult">
-        select r.user_name, r.phone_num, r.id_card as zjhm,
-        z.province as provinceXjd , z.city as cityXjd,z.region as regionXjd , z.town as villageTownsXjd, z.village as villageXjd,z.now_in as nowXjd,d.lxdh,d.jcsj,d.jcdd
+        select r.user_name as xm, r.phone_num, r.id_card as zjhm,
+        z.province as provinceXjd , z.city as cityXjd,z.region as regionXjd , z.town as villageTownsXjd, z.village as villageXjd,z.now_in,d.lxdh,d.jcsj,d.jcdd,d.cjdd,d.cjsj
         from czrk r left join czrk_jzdz z on r.id =z.czrk_id
         left join `accounting_data` d on r.id_card = d.zjhm
         <where>
             r.is_del = 'N'
             and r.status = '1'
             and d.is_del = 'N'
-            <if test="idCard != null  and idCard != ''">and r.id_card = #{idCard}</if>
-            <if test="userName != null  and userName != ''">and r.user_name like concat(#{userName}, '%')</if>
-            <if test="params.startTime != null  and params.startTime != ''">and DATE_FORMAT(d.jcsj,'%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT(#{params.startTime},'%Y-%m-%d %H:%i:%s')</if>
-            <if test="params.endTime != null  and params.endTime != ''">and DATE_FORMAT(d.jcsj,'%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{params.endTime},'%Y-%m-%d %H:%i:%s')</if>
-            <if test="isNucleicAcid != null  and isNucleicAcid != ''">and DATE_FORMAT(d.jcsj,'%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT('1900-01-01 00:00:00','%Y-%m-%d %H:%i:%s')</if>
+            <if test="zjhm != null  and zjhm != ''">and r.id_card = #{zjhm}</if>
+            <if test="xm != null  and xm != ''">and r.user_name like concat(#{xm}, '%')</if>
+            <if test="params.startTime != null  and params.startTime != ''">and DATE_FORMAT(d.cjsj,'%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT(#{params.startTime},'%Y-%m-%d %H:%i:%s')</if>
+            <if test="params.endTime != null  and params.endTime != ''">and DATE_FORMAT(d.cjsj,'%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{params.endTime},'%Y-%m-%d %H:%i:%s')</if>
+            <if test="isNucleicAcid != null  and isNucleicAcid != ''">and r.is_nucleicAcid = #{isNucleicAcid}</if>
             <if test="provinceIdXjd != null and provinceIdXjd != ''">and z.province_id = #{provinceIdXjd}</if>
             <if test="cityIdXjd != null and cityIdXjd != ''">and z.city_id = #{cityIdXjd}</if>
             <if test="regionIdXjd != null and regionIdXjd != ''">and z.region_id = #{regionIdXjd}</if>
             <if test="villageTownsIdXjd != null and villageTownsIdXjd != ''">and z.town_id = #{villageTownsIdXjd}</if>
             <if test="villageIdXjd != null and villageIdXjd != ''">and z.village_id = #{villageIdXjd}</if>
         </where>
+        order by d.jcsj DESC
     </select>
+
+
+    <insert id="insertAccountingData" useGeneratedKeys="true" keyProperty="id">
+        insert into accounting_data
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="jcsj != null">jcsj,</if>
+            <if test="lxdh != null">lxdh,</if>
+            <if test="address != null">address,</if>
+            <if test="batchNumber != null">batch_number,</if>
+            <if test="focusPerson != null">focus_person,</if>
+            <if test="jcjg != null">jcjg,</if>
+            <if test="fromCity != null">from_city,</if>
+            <if test="jcdd != null">jcdd,</if>
+            <if test="cjdd != null">cjdd,</if>
+            <if test="toCity != null">to_city,</if>
+            <if test="source != null">source,</if>
+            <if test="zjhm != null">zjhm,</if>
+            <if test="cjsj != null">cjsj,</if>
+            <if test="certificateNoType != null">certificate_no_type,</if>
+            <if test="xm != null">xm,</if>
+            <if test="collectorName != null">collector_name,</if>
+            <if test="cjssxq != null">cjssxq,</if>
+            <if test="createBy != null">create_by,</if>
+            create_time
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="lxdh != null">#{lxdh},</if>
+            <if test="address != null">#{address},</if>
+            <if test="batchNumber != null">#{batchNumber},</if>
+            <if test="focusPerson != null">#{focusPerson},</if>
+            <if test="jcjg != null">#{jcjg},</if>
+            <if test="fromCity != null">#{fromCity},</if>
+            <if test="jcdd != null">#{jcdd},</if>
+            <if test="cjdd != null">#{cjdd},</if>
+            <if test="toCity != null">#{toCity},</if>
+            <if test="source != null">#{source},</if>
+            <if test="zjhm != null">#{zjhm},</if>
+            <if test="cjsj != null">#{cjsj},</if>
+            <if test="certificateNoType != null">#{certificateNoType},</if>
+            <if test="workUnit != null">#{workUnit},</if>
+            <if test="xm != null">#{xm},</if>
+            <if test="collectorName != null">#{collectorName},</if>
+            <if test="cjssxq != null">#{cjssxq},</if>
+            <if test="createBy != null">#{createBy},</if>
+            sysdate()
+        </trim>
+    </insert>
 </mapper>

+ 6 - 0
boman-web-core/src/main/resources/mapper/CzrkMapper.xml

@@ -806,6 +806,12 @@
         where id = #{id}
     </update>
 
+    <update id="updateCzrkByNucleicAcid">
+        update czrk
+        set is_nucleicAcid = 'Y',nucleicAcid_time = #{nucleicAcidTime}
+        where id_card = #{idCard}
+    </update>
+
     <delete id="deleteCzrkById" parameterType="Long">
         delete from czrk where id = #{id}
     </delete>