Commit 9e960058 by wang_jiaxing

更新log4j版本,修改为多线程执行模式

parent a00873e7
......@@ -20,7 +20,7 @@
<hutool.version>5.4.5</hutool.version>
<guava.version>29.0-jre</guava.version>
<spring-boot.version>2.2.6.RELEASE</spring-boot.version>
<log4j2.version>2.15.0</log4j2.version>
<log4j2.version>2.17.0</log4j2.version>
</properties>
<dependencies>
......@@ -228,7 +228,7 @@
<repositories>
<repository>
<id>founder</id>
<url>http://39.99.224.27:8081/nexus/content/groups/public/</url>
<url>http://47.92.223.200:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
......
......@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -13,4 +14,7 @@ public interface XjxzFlwsMapper {
void update(@Param("xxzjbh") String xxzjbh, @Param("bytes") byte[] bytes);
List<String> getNoFileFlwsXxzjbh(@Param("flwsList") List<Map<String, String>> flwsList);
List<Map<String, String>> getFlwsWzByDate(@Param("date") Date date, @Param("xxzjbh") String xxzjbh, @Param("begin") Integer page, @Param("end") Integer rows);
Integer getFlwsCountWzByDate(@Param("date") Date date, @Param("xxzjbh") String xxzjbh);
}
package com.founder.file.service.impl;
import com.founder.file.dao.jzzjk.JzzjkFlwsMapper;
import com.founder.file.dao.xjxz.XjxzFlwsMapper;
import com.founder.file.service.XjFlwsService;
import com.founder.util.HttpUtil;
......@@ -8,6 +7,7 @@ import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
......@@ -16,45 +16,54 @@ import java.util.concurrent.FutureTask;
@Service
public class XjFlwsServiceImpl implements XjFlwsService {
@Autowired
private JzzjkFlwsMapper jzzjkFlwsMapper;
@Autowired
private XjxzFlwsMapper xjxzFlwsMapper;
@Override
public String getJzzjkFlwsnrToXjxz(Date date, String xxzjbh) throws IOException {
Integer count = jzzjkFlwsMapper.getFlwsCountWzByDate(date, xxzjbh);
Integer count = xjxzFlwsMapper.getFlwsCountWzByDate(date, xxzjbh);
int page = (count / 1000) + 1;
ArrayList<FutureTask<Map<String, Integer>>> list = new ArrayList<>();
for (int i = 0; i < page; i++) {
int limit = 1000;
int begin = i * limit;
int end = (i+1) * limit;
int end = (i + 1) * limit;
int finalI = i;
FutureTask<Map<String, Integer>> xsAjTask = new FutureTask<>(() -> {
HashMap<String, Integer> map = new HashMap<>();
List<Map<String, String>> flwsList = jzzjkFlwsMapper.getFlwsWzByDate(date, xxzjbh, begin, end);
List<String> xxzjbhList = xjxzFlwsMapper.getNoFileFlwsXxzjbh(flwsList);
HashSet<String> set = new HashSet<>(xxzjbhList);
map.put("flws", set.size());
List<Map<String, String>> flwsList = xjxzFlwsMapper.getFlwsWzByDate(date, xxzjbh, begin, end);
ArrayList<Exception> exceptions = new ArrayList<>();
System.out.println("+++++++++++++" + flwsList.size());
int j = 1;
int flwsCount = 0;
int wuNrCount = 0;
for (Map<String, String> flws : flwsList) {
if (!set.contains(flws.get("XXZJBH"))){
continue;
}
try {
String flwsUrl = flws.get("FWDZ") + flws.get("TXLJ");
System.out.println(flwsUrl);
InputStream is = HttpUtil.getInputStreamByUrl(flwsUrl);
byte[] bytes = IOUtils.toByteArray(is);
xjxzFlwsMapper.update(flws.get("XXZJBH"), bytes);
if (is != null) {
byte[] bytes = IOUtils.toByteArray(is);
if (bytes != null && bytes.length > 0) {
xjxzFlwsMapper.update(flws.get("XXZJBH"), bytes);
flwsCount++;
} else {
System.out.println("文件已损害,无内容");
wuNrCount++;
}
}
} catch (FileNotFoundException e) {
System.out.println("404,文件找不到");
wuNrCount++;
} catch (Exception e) {
e.printStackTrace();
exceptions.add(e);
}
System.out.println("线程" + finalI + "++++++++++++++" + (j++));
}
map.put("exceptions", flwsList.size());
map.put("flws", flwsCount);
map.put("wuNrCount", wuNrCount);
System.out.println("=============" + exceptions.size());
return map;
});
......@@ -62,17 +71,19 @@ public class XjFlwsServiceImpl implements XjFlwsService {
list.add(xsAjTask);
}
int flsws = 0;
int wuNrCount = 0;
int exc = 0;
for (FutureTask<Map<String, Integer>> task : list) {
try {
Map<String, Integer> map = task.get();
flsws += map.get("flws");
wuNrCount += map.get("wuNrCount");
exc += map.get("exceptions");
} catch (Exception e) {
e.printStackTrace();
exc += 1;
}
}
return "共更新了" + flsws + "个法律文书,其中出错" + exc + "个法律文书";
return "更新了" + flsws + "个法律文书,出错了" + exc + "个法律文书,有" + wuNrCount + "个法律文书404或已损坏";
}
}
......@@ -33,3 +33,6 @@ xxcx:
orc: http://39.99.224.27:8866/predict/chinese_ocr_db_crnn_mobile
ce: http://39.99.224.27:8866/predict/chinese_ocr_db_crnn_mobile
ce1: http://39.99.224.27:8866/predict/ocr_system
ocrURL: http://39.99.224.27:8866/predict/chinese_ocr_db_crnn_mobile
lacURL: http://39.99.224.27:8866/predict/chinese_ocr_db_crnn_mobile
......@@ -10,4 +10,41 @@
#{flws.XXZJBH}
</foreach>
</select>
<select id="getFlwsWzByDate" resultType="java.util.Map">
select *
from (select rownum r, t.*
from (
select dz.FWDZ as fwdz,
dz.TXLJ as txlj,
fl.XXZJBH as xxzjbh
from JZZJK.AJ_DZJZXX dz, JZZJK.AJ_FLWS fl, TB_ST_ASJ_FLWS flws
where dz.flwsbh = fl.flwsbh
and dz.ajbh = fl.ajbh
and dz.txsx = fl.txsx
and dz.txlj = fl.txlj
and fl.xxzjbh = flws.xxzjbh
and flws.flws_dzwjnr is null
and flws.xxrsksj <![CDATA[>=]]> #{date}
<if test="xxzjbh != null and xxzjbh != ''">
and dz.TZTXBH = #{xxzjbh}
</if>) t
where rownum <![CDATA[ <= ]]> #{end})
where r <![CDATA[ > ]]> #{begin}
</select>
<select id="getFlwsCountWzByDate" resultType="java.lang.Integer">
select count(1)
from JZZJK.AJ_DZJZXX dz, JZZJK.AJ_FLWS fl, TB_ST_ASJ_FLWS flws
where dz.flwsbh = fl.flwsbh
and dz.ajbh = fl.ajbh
and dz.txsx = fl.txsx
and dz.txlj = fl.txlj
and fl.xxzjbh = flws.xxzjbh
and flws.flws_dzwjnr is null
-- and to_date(DJRQ, 'yyyyMMdd') <![CDATA[>=]]> #{date}
and flws.xxrsksj <![CDATA[>=]]> #{date}
<if test="xxzjbh != null and xxzjbh != ''">
and dz.TZTXBH = #{xxzjbh}
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment