|
|
|
@ -6,15 +6,13 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.fkzy.warn.common.constants.EntityConstants; |
|
|
|
import com.fkzy.warn.common.util.ReportUtil; |
|
|
|
import com.fkzy.warn.mapper.LawCaseMapper; |
|
|
|
import com.fkzy.warn.service.DishonestInfoService; |
|
|
|
import com.fkzy.warn.service.LawCaseService; |
|
|
|
import com.fkzy.warn.service.LitigantInfoService; |
|
|
|
import com.fkzy.warn.model.DishonestInfo; |
|
|
|
import com.fkzy.warn.model.EnterpriseInfo; |
|
|
|
import com.fkzy.warn.model.LawCase; |
|
|
|
import com.fkzy.warn.model.Limitation; |
|
|
|
import com.fkzy.warn.model.LitigantInfo; |
|
|
|
import com.fkzy.warn.service.LimitationService; |
|
|
|
import com.fkzy.warn.model.ReportModel; |
|
|
|
import com.fkzy.warn.service.*; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -22,16 +20,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.FileReader; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.function.BiConsumer; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.IntStream; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author zhangjing |
|
|
|
@ -52,6 +41,9 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
@Autowired |
|
|
|
private LitigantInfoService litigantInfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EnterpriseInfoService enterpriseInfoService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveModel(LawCase entity, String ticket) { |
|
|
|
save(entity); |
|
|
|
@ -73,191 +65,145 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
|
|
|
|
/** |
|
|
|
* 近三月新发案件告警 |
|
|
|
* |
|
|
|
* @return java.lang.String |
|
|
|
* @author zhangjing |
|
|
|
* @create 2024/12/15 |
|
|
|
**/ |
|
|
|
private String threeMonths() { |
|
|
|
private List<LawCase> threeMonthsCases() { |
|
|
|
// 获取当前日期 |
|
|
|
Date currentDate = new Date(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(currentDate); |
|
|
|
calendar.add(Calendar.MONTH, -3); |
|
|
|
calendar.add(Calendar.MONTH, -16); |
|
|
|
Date threeMonthsAgo = calendar.getTime(); |
|
|
|
|
|
|
|
// 获取近三个月的案件 |
|
|
|
// 获取近三个月的案件 d_larq 立案日期字段 |
|
|
|
QueryWrapper<LawCase> query = new QueryWrapper<>(); |
|
|
|
query.ge("d_larq", threeMonthsAgo); // 假设 d_larq 是案件日期字段 |
|
|
|
List<LawCase> caseList = list(query); |
|
|
|
|
|
|
|
// 初始化统计数据 |
|
|
|
int totalCases = 0; |
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO; |
|
|
|
int plaintiffCases = 0; |
|
|
|
BigDecimal plaintiffAmount = BigDecimal.ZERO; |
|
|
|
int defendantCases = 0; |
|
|
|
BigDecimal defendantAmount = BigDecimal.ZERO; |
|
|
|
int thirdPartyCases = 0; |
|
|
|
BigDecimal thirdPartyAmount = BigDecimal.ZERO; |
|
|
|
|
|
|
|
// 遍历案件列表并统计 |
|
|
|
query.ge("d_larq", threeMonthsAgo); |
|
|
|
List<LawCase> caseList = this.list(query); |
|
|
|
for (LawCase lawCase : caseList) { |
|
|
|
totalCases++; |
|
|
|
totalAmount = totalAmount.add(lawCase.getN_qsbdje()); // 使用 BigDecimal 的 add 方法 |
|
|
|
|
|
|
|
QueryWrapper<LitigantInfo> infoQueryWrapper = new QueryWrapper<>(); |
|
|
|
infoQueryWrapper.eq("n_ajbs", lawCase.getN_ajbs()); |
|
|
|
List<LitigantInfo> litigantList = litigantInfoService.list(infoQueryWrapper); |
|
|
|
|
|
|
|
for (LitigantInfo litigantInfo : litigantList) { |
|
|
|
if ("原告".equals(litigantInfo.getN_ssdw())) { |
|
|
|
plaintiffCases++; |
|
|
|
plaintiffAmount = plaintiffAmount.add(lawCase.getN_qsbdje()); |
|
|
|
} else if ("被告".equals(litigantInfo.getN_ssdw())) { |
|
|
|
defendantCases++; |
|
|
|
defendantAmount = defendantAmount.add(lawCase.getN_qsbdje()); |
|
|
|
} else if ("第三人".equals(litigantInfo.getN_ssdw())) { |
|
|
|
thirdPartyCases++; |
|
|
|
thirdPartyAmount = thirdPartyAmount.add(lawCase.getN_qsbdje()); |
|
|
|
} |
|
|
|
} |
|
|
|
infoQueryWrapper.eq("n_ajbs", lawCase.getNAjbs()); |
|
|
|
lawCase.setLitigantInfoList(litigantInfoService.list(infoQueryWrapper)); |
|
|
|
} |
|
|
|
|
|
|
|
// 构建返回字符串 |
|
|
|
StringBuilder result = new StringBuilder(); |
|
|
|
result.append("近三个月新发案件").append(totalCases).append("件,涉案金额").append(totalAmount).append("万元。\n"); |
|
|
|
result.append("其中,原告案件").append(plaintiffCases).append("件,涉诉金额").append(plaintiffAmount).append("万元;\n"); |
|
|
|
result.append("被告案件").append(defendantCases).append("件,涉诉金额").append(defendantAmount).append("万元;\n"); |
|
|
|
result.append("第三人案件").append(thirdPartyCases).append("件,涉诉金额").append(thirdPartyAmount).append("万元。"); |
|
|
|
|
|
|
|
return result.toString(); |
|
|
|
return caseList; |
|
|
|
} |
|
|
|
/** |
|
|
|
* |
|
|
|
* 案件审理阶段 |
|
|
|
* 近三年案件 |
|
|
|
* |
|
|
|
* @return java.lang.String |
|
|
|
* @author zhangjing |
|
|
|
* @create 2024/12/15 |
|
|
|
**/ |
|
|
|
private String caseStage(String companyName){ |
|
|
|
private List<LawCase> threeYearsCases() { |
|
|
|
// 获取当前日期 |
|
|
|
Date currentDate = new Date(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(currentDate); |
|
|
|
calendar.add(Calendar.MONTH, -36); |
|
|
|
Date threeMonthsAgo = calendar.getTime(); |
|
|
|
// 获取近三个月的案件 d_larq 立案日期字段 |
|
|
|
QueryWrapper<LawCase> query = new QueryWrapper<>(); |
|
|
|
query.eq("company_name",companyName); |
|
|
|
List<LawCase> caseList = list(query); |
|
|
|
// 初始化统计数据 |
|
|
|
int totalCases = 0; |
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO; |
|
|
|
int plaintiffCases = 0; |
|
|
|
BigDecimal plaintiffAmount = BigDecimal.ZERO; |
|
|
|
int defendantCases = 0; |
|
|
|
BigDecimal defendantAmount = BigDecimal.ZERO; |
|
|
|
int thirdPartyCases = 0; |
|
|
|
BigDecimal thirdPartyAmount = BigDecimal.ZERO; |
|
|
|
|
|
|
|
int ysCases = 0; |
|
|
|
int esCases = 0; |
|
|
|
int zsCases = 0; |
|
|
|
int zzsCases = 0; |
|
|
|
int zxCases = 0; |
|
|
|
|
|
|
|
// 遍历案件列表并统计 |
|
|
|
query.ge("d_larq", threeMonthsAgo); |
|
|
|
List<LawCase> caseList = this.list(query); |
|
|
|
for (LawCase lawCase : caseList) { |
|
|
|
totalCases++; |
|
|
|
totalAmount = totalAmount.add(lawCase.getN_qsbdje()); // 使用 BigDecimal 的 add 方法 |
|
|
|
|
|
|
|
QueryWrapper<LitigantInfo> infoQueryWrapper = new QueryWrapper<>(); |
|
|
|
infoQueryWrapper.eq("n_ajbs", lawCase.getN_ajbs()); |
|
|
|
List<LitigantInfo> litigantList = litigantInfoService.list(infoQueryWrapper); |
|
|
|
|
|
|
|
for (LitigantInfo litigantInfo : litigantList) { |
|
|
|
if ("原告".equals(litigantInfo.getN_ssdw())) { |
|
|
|
plaintiffCases++; |
|
|
|
plaintiffAmount = plaintiffAmount.add(lawCase.getN_qsbdje()); |
|
|
|
} else if ("被告".equals(litigantInfo.getN_ssdw())) { |
|
|
|
defendantCases++; |
|
|
|
defendantAmount = defendantAmount.add(lawCase.getN_qsbdje()); |
|
|
|
} else if ("第三人".equals(litigantInfo.getN_ssdw())) { |
|
|
|
thirdPartyCases++; |
|
|
|
thirdPartyAmount = thirdPartyAmount.add(lawCase.getN_qsbdje()); |
|
|
|
} |
|
|
|
} |
|
|
|
//n_slcx |
|
|
|
if (lawCase.getN_slcx().equals("一审")){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
infoQueryWrapper.eq("n_ajbs", lawCase.getNAjbs()); |
|
|
|
lawCase.setLitigantInfoList(litigantInfoService.list(infoQueryWrapper)); |
|
|
|
} |
|
|
|
return caseList; |
|
|
|
} |
|
|
|
|
|
|
|
// 构建返回字符串 |
|
|
|
StringBuilder result = new StringBuilder(); |
|
|
|
result.append("案件总数").append(totalCases).append("件,总涉案金额").append(totalAmount).append("万元,\n"); |
|
|
|
result.append("原告案件").append(plaintiffCases).append("件,涉诉金额").append(plaintiffAmount).append("万元;\n"); |
|
|
|
result.append("被告案件").append(defendantCases).append("件,涉诉金额").append(defendantAmount).append("万元;\n"); |
|
|
|
result.append("第三人案件").append(thirdPartyCases).append("件,涉诉金额").append(thirdPartyAmount).append("万元。"); |
|
|
|
private ReportModel createReportData(){ |
|
|
|
ReportModel reportModel = new ReportModel(); |
|
|
|
QueryWrapper<EnterpriseInfo> enterpriseInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
enterpriseInfoQueryWrapper.eq("CREDITCODE", "91440300087909371X"); |
|
|
|
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getOne(enterpriseInfoQueryWrapper); |
|
|
|
reportModel.setBackgroundJudicial(ReportUtil.backgroundJudicial(enterpriseInfo)); |
|
|
|
reportModel.setBasicEnterprise(enterpriseInfo); |
|
|
|
List<LawCase> threeMonthsCases = threeMonthsCases(); |
|
|
|
reportModel.setThreeMonthsText1(ReportUtil.threeMonthsText1(threeMonthsCases)); |
|
|
|
reportModel.setThreeMonthsCases(threeMonthsCases); |
|
|
|
reportModel.setThreeMonthsText2(ReportUtil.threeMonthsText2(threeMonthsCases)); |
|
|
|
reportModel.setThreeMonthsText3(ReportUtil.threeMonthsText3(threeMonthsCases)); |
|
|
|
List<LawCase> threeYearsCases = threeYearsCases(); |
|
|
|
reportModel.setCaseStageText1(ReportUtil.caseStageText1(threeYearsCases)); |
|
|
|
reportModel.setLocationText(ReportUtil.locationText(threeYearsCases)); |
|
|
|
reportModel.setCaseActionText1(ReportUtil.caseActionText1(threeYearsCases)); |
|
|
|
reportModel.setThreeYearsCases(threeYearsCases); |
|
|
|
reportModel.setCaseActionText2(ReportUtil.caseActionText2(threeYearsCases)); |
|
|
|
reportModel.setLitigationStatusText(ReportUtil.litigationStatusText(threeYearsCases)); |
|
|
|
reportModel.setMajorCaseText(ReportUtil.majorCase(threeYearsCases)); |
|
|
|
reportModel.setHighFrequencyText(ReportUtil.highFrequencyText(threeYearsCases)); |
|
|
|
return reportModel; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//案件总数1252件,总涉案金额18839002.77万元,原告案件21件,涉诉金额560.89万元;被告案件1219件,涉诉金额18838000.61万元;第三人案件12件,涉诉金额441.27万元。一审案件1054件、二审案件197件、再审案件5件、再审审查案件3件、执行案件2件。 |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void judicialModelSave(JSONObject jsonObject) { |
|
|
|
String filePath = "司法.txt"; |
|
|
|
String jsonOutput = convertTextToJson(filePath); |
|
|
|
if (jsonOutput == null) { |
|
|
|
logger.error("转换失败,JSON 字符串为空"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
jsonObject = new JSONObject().parseObject(jsonOutput); |
|
|
|
JSONArray arr = jsonObject.getJSONArray("data"); |
|
|
|
if (arr == null || arr.isEmpty()) { |
|
|
|
logger.error("数据数组为空"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
JSONObject data = arr.getJSONObject(0); |
|
|
|
String info = data.getString("id"); |
|
|
|
String companyName = null; |
|
|
|
String creditCode = null; |
|
|
|
if (info != null) { |
|
|
|
String[] items = info.split(":"); |
|
|
|
if (items.length == 2) { |
|
|
|
companyName = items[0]; |
|
|
|
creditCode = items[1]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 失信 |
|
|
|
JSONObject sx = data.getJSONObject("sx"); |
|
|
|
JSONArray sxbzxrCurrent = sx.getJSONArray("sxbzxr_current"); |
|
|
|
String finalCompanyName = companyName; |
|
|
|
String finalCreditCode = creditCode; |
|
|
|
List<DishonestInfo> dishonestInfoList = JSON.parseArray(sxbzxrCurrent.toString(), DishonestInfo.class) |
|
|
|
.stream() |
|
|
|
.peek(p -> { |
|
|
|
p.setCompanyName(finalCompanyName); |
|
|
|
p.setCreditCode(finalCreditCode); |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
dishonestInfoService.saveOrUpdateBatch(dishonestInfoList); |
|
|
|
ReportModel reportModel = createReportData(); |
|
|
|
ReportUtil.createReport(reportModel); |
|
|
|
// String filePath = "司法.txt"; |
|
|
|
// String filePath = "工商.txt"; |
|
|
|
// String jsonOutput = convertTextToJson(filePath); |
|
|
|
// if (jsonOutput == null) { |
|
|
|
// logger.error("转换失败,JSON 字符串为空"); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// jsonObject = new JSONObject().parseObject(jsonOutput); |
|
|
|
// JSONArray arr = jsonObject.getJSONArray("data"); |
|
|
|
// if (arr == null || arr.isEmpty()) { |
|
|
|
// logger.error("数据数组为空"); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// |
|
|
|
// JSONObject data = arr.getJSONObject(0); |
|
|
|
// String info = data.getString("id"); |
|
|
|
// String companyName = null; |
|
|
|
// String creditCode = null; |
|
|
|
// if (info != null) { |
|
|
|
// String[] items = info.split(":"); |
|
|
|
// if (items.length == 2) { |
|
|
|
// companyName = items[0]; |
|
|
|
// creditCode = items[1]; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 失信 |
|
|
|
// JSONObject sx = data.getJSONObject("sx"); |
|
|
|
// JSONArray sxbzxrCurrent = sx.getJSONArray("sxbzxr_current"); |
|
|
|
// String finalCompanyName = companyName; |
|
|
|
// String finalCreditCode = creditCode; |
|
|
|
// List<DishonestInfo> dishonestInfoList = JSON.parseArray(sxbzxrCurrent.toString(), DishonestInfo.class) |
|
|
|
// .stream() |
|
|
|
// .peek(p -> { |
|
|
|
// p.setCompanyName(finalCompanyName); |
|
|
|
// p.setCreditCode(finalCreditCode); |
|
|
|
// }) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// dishonestInfoService.saveOrUpdateBatch(dishonestInfoList); |
|
|
|
// |
|
|
|
// // 八类案件 |
|
|
|
// JSONObject detail = data.getJSONObject("detail"); |
|
|
|
// setCases(detail, companyName, creditCode); |
|
|
|
// |
|
|
|
// // 限高 |
|
|
|
// JSONObject xg = data.getJSONObject("xg"); |
|
|
|
// JSONArray xgbzxrCurrent = xg.getJSONArray("xgbzxr_current"); |
|
|
|
// |
|
|
|
// List<Limitation> limitationList = JSON.parseArray(xgbzxrCurrent.toString(), Limitation.class) |
|
|
|
// .stream() |
|
|
|
// .peek(p -> { |
|
|
|
// p.setCompanyName(finalCompanyName); |
|
|
|
// p.setCreditCode(finalCreditCode); |
|
|
|
// }) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// limitationService.saveOrUpdateBatch(limitationList); |
|
|
|
} |
|
|
|
|
|
|
|
// 八类案件 |
|
|
|
JSONObject detail = data.getJSONObject("detail"); |
|
|
|
setCases(detail, companyName, creditCode); |
|
|
|
|
|
|
|
// 限高 |
|
|
|
JSONObject xg = data.getJSONObject("xg"); |
|
|
|
JSONArray xgbzxrCurrent = xg.getJSONArray("xgbzxr_current"); |
|
|
|
|
|
|
|
List<Limitation> limitationList = JSON.parseArray(xgbzxrCurrent.toString(), Limitation.class) |
|
|
|
.stream() |
|
|
|
.peek(p -> { |
|
|
|
p.setCompanyName(finalCompanyName); |
|
|
|
p.setCreditCode(finalCreditCode); |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
limitationService.saveOrUpdateBatch(limitationList); |
|
|
|
} |
|
|
|
|
|
|
|
private void setCases(JSONObject detail, String companyName, String creditCode) { |
|
|
|
List<Map.Entry<String, JSONArray>> entries = Arrays.asList( |
|
|
|
@ -268,8 +214,7 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
new AbstractMap.SimpleEntry<>("implement", detail.getJSONObject("implement").getJSONArray("cases")), |
|
|
|
new AbstractMap.SimpleEntry<>("bankrupt", detail.getJSONObject("bankrupt").getJSONArray("cases")), |
|
|
|
new AbstractMap.SimpleEntry<>("jurisdict", detail.getJSONObject("jurisdict").getJSONArray("cases")), |
|
|
|
new AbstractMap.SimpleEntry<>("compensate", detail.getJSONObject("compensate").getJSONArray("cases")) |
|
|
|
); |
|
|
|
new AbstractMap.SimpleEntry<>("compensate", detail.getJSONObject("compensate").getJSONArray("cases"))); |
|
|
|
entries.forEach(entry -> saveCases(entry.getValue(), entry.getKey(), companyName, creditCode)); |
|
|
|
} |
|
|
|
|
|
|
|
@ -277,100 +222,122 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
private void saveCases(JSONArray jsonArray, String type, String companyName, String creditCode) { |
|
|
|
List<LawCase> caseList = new ArrayList<>(); |
|
|
|
List<LitigantInfo> litigantInfoList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<String> nAjbsList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i); |
|
|
|
LawCase lawCase = JSON.parseObject(jsonObject.toString(), LawCase.class); |
|
|
|
lawCase.setCompanyName(companyName); |
|
|
|
lawCase.setCreditCode(creditCode); |
|
|
|
lawCase.setCaseType(type); |
|
|
|
if (lawCase.getN_ajbs() != null) { |
|
|
|
if (lawCase.getNAjbs() != null) { |
|
|
|
caseList.add(lawCase); |
|
|
|
} |
|
|
|
|
|
|
|
JSONArray cDsrxx = jsonObject.getJSONArray("c_dsrxx"); |
|
|
|
if (cDsrxx != null && lawCase.getN_ajbs() != null) { |
|
|
|
nAjbsList.add(lawCase.getNAjbs()); |
|
|
|
if (cDsrxx != null && lawCase.getNAjbs() != null) { |
|
|
|
for (int j = 0; j < cDsrxx.size(); j++) { |
|
|
|
JSONObject obj = cDsrxx.getJSONObject(j); |
|
|
|
LitigantInfo litigantInfo = JSON.parseObject(obj.toString(), LitigantInfo.class); |
|
|
|
litigantInfo.setN_ajbs(lawCase.getN_ajbs()); |
|
|
|
litigantInfo.setNAjbs(lawCase.getNAjbs()); |
|
|
|
litigantInfoList.add(litigantInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!caseList.isEmpty()) { |
|
|
|
saveOrUpdateCases(caseList); |
|
|
|
} |
|
|
|
// if (!caseList.isEmpty()) { |
|
|
|
// saveOrUpdateCases(caseList); |
|
|
|
// } |
|
|
|
if (!litigantInfoList.isEmpty()) { |
|
|
|
QueryWrapper<LitigantInfo> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.in("n_ajbs", nAjbsList); |
|
|
|
litigantInfoService.remove(queryWrapper); |
|
|
|
saveOrUpdateLitigantInfo(litigantInfoList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 批量大小 |
|
|
|
private static final int BATCH_SIZE = 500; |
|
|
|
|
|
|
|
|
|
|
|
private static final int THREAD_COUNT = 3; |
|
|
|
|
|
|
|
public void saveOrUpdateCases(List<LawCase> lawCaseList) { |
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); |
|
|
|
AtomicInteger counter = new AtomicInteger(0); |
|
|
|
|
|
|
|
for (int i = 0; i < lawCaseList.size(); i += BATCH_SIZE) { |
|
|
|
int start = i; |
|
|
|
int end = Math.min(i + BATCH_SIZE, lawCaseList.size()); |
|
|
|
List<LawCase> batch = lawCaseList.subList(start, end); |
|
|
|
int finalCounter = counter.getAndIncrement(); |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
this.saveOrUpdateBatch(batch, BATCH_SIZE); |
|
|
|
} catch (Exception e) { |
|
|
|
// 处理异常 |
|
|
|
System.err.println("Error processing batch " + finalCounter + ": " + e.getMessage()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
executorService.shutdown(); |
|
|
|
try { |
|
|
|
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
throw new RuntimeException("Interrupted while waiting for tasks to complete", e); |
|
|
|
private static final int BATCH_SIZE = 20; |
|
|
|
|
|
|
|
|
|
|
|
private static final int THREAD_COUNT = 1; |
|
|
|
public void saveOrUpdateCases(List<LawCase> entityList) { |
|
|
|
int batchSize=20; |
|
|
|
int size = entityList.size(); // 总记录数 |
|
|
|
for (int i = 0; i < size; i += batchSize) { |
|
|
|
int toIndex = Math.min(i + batchSize, size); // 计算当前批次的结束索引 |
|
|
|
List<LawCase> batch = entityList.subList(i, toIndex); // 提取当前批次的记录 |
|
|
|
// 执行批量插入或更新操作 |
|
|
|
this.saveOrUpdateBatch(batch); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateLitigantInfo(List<LitigantInfo> litigantInfoList) { |
|
|
|
// QueryWrapper<LitigantInfo> query = new QueryWrapper<LitigantInfo>(); |
|
|
|
// query.eq("n_ajbs", litigantInfoList.get(0).getN_ajbs()); |
|
|
|
// litigantInfoService.remove(query); |
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); |
|
|
|
AtomicInteger counter = new AtomicInteger(0); |
|
|
|
|
|
|
|
for (int i = 0; i < litigantInfoList.size(); i += BATCH_SIZE) { |
|
|
|
int start = i; |
|
|
|
int end = Math.min(i + BATCH_SIZE, litigantInfoList.size()); |
|
|
|
List<LitigantInfo> batch = litigantInfoList.subList(start, end); |
|
|
|
int finalCounter = counter.getAndIncrement(); |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
litigantInfoService.saveOrUpdateBatch(batch, BATCH_SIZE); |
|
|
|
} catch (Exception e) { |
|
|
|
// 处理异常 |
|
|
|
System.err.println("Error processing batch LitigantInfo" + finalCounter + ": " + e.getMessage()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
executorService.shutdown(); |
|
|
|
try { |
|
|
|
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
throw new RuntimeException("Interrupted while waiting for tasks to complete", e); |
|
|
|
} |
|
|
|
// public void saveOrUpdateCases(List<LawCase> lawCaseList) { |
|
|
|
// ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); |
|
|
|
// AtomicInteger counter = new AtomicInteger(0); |
|
|
|
// |
|
|
|
// for (int i = 0; i < lawCaseList.size(); i += BATCH_SIZE) { |
|
|
|
// int start = i; |
|
|
|
// int end = Math.min(i + BATCH_SIZE, lawCaseList.size()); |
|
|
|
// List<LawCase> batch = lawCaseList.subList(start, end); |
|
|
|
// int finalCounter = counter.getAndIncrement(); |
|
|
|
// executorService.submit(() -> { |
|
|
|
// try { |
|
|
|
// this.saveOrUpdateBatch(batch, BATCH_SIZE); |
|
|
|
// } catch (Exception e) { |
|
|
|
// // 处理异常 |
|
|
|
// System.err.println("Error processing batch " + finalCounter + ": " + e.getMessage()); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// executorService.shutdown(); |
|
|
|
// try { |
|
|
|
// executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); |
|
|
|
// } catch (InterruptedException e) { |
|
|
|
// Thread.currentThread().interrupt(); |
|
|
|
// throw new RuntimeException("Interrupted while waiting for tasks to complete", e); |
|
|
|
// } |
|
|
|
// } |
|
|
|
public void saveOrUpdateLitigantInfo(List<LitigantInfo> entityList) { |
|
|
|
int batchSize=20; |
|
|
|
int size = entityList.size(); // 总记录数 |
|
|
|
for (int i = 0; i < size; i += batchSize) { |
|
|
|
int toIndex = Math.min(i + batchSize, size); // 计算当前批次的结束索引 |
|
|
|
List<LitigantInfo> batch = entityList.subList(i, toIndex); // 提取当前批次的记录 |
|
|
|
// 执行批量插入或更新操作 |
|
|
|
litigantInfoService.saveOrUpdateBatch(batch); |
|
|
|
} |
|
|
|
} |
|
|
|
// public void saveOrUpdateLitigantInfo(List<LitigantInfo> litigantInfoList) { |
|
|
|
//// QueryWrapper<LitigantInfo> query = new QueryWrapper<LitigantInfo>(); |
|
|
|
//// query.eq("n_ajbs", litigantInfoList.get(0).getN_ajbs()); |
|
|
|
//// litigantInfoService.remove(query); |
|
|
|
// ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); |
|
|
|
// AtomicInteger counter = new AtomicInteger(0); |
|
|
|
// |
|
|
|
// for (int i = 0; i < litigantInfoList.size(); i += BATCH_SIZE) { |
|
|
|
// int start = i; |
|
|
|
// int end = Math.min(i + BATCH_SIZE, litigantInfoList.size()); |
|
|
|
// List<LitigantInfo> batch = litigantInfoList.subList(start, end); |
|
|
|
// int finalCounter = counter.getAndIncrement(); |
|
|
|
// executorService.submit(() -> { |
|
|
|
// try { |
|
|
|
// litigantInfoService.saveOrUpdateBatch(batch, BATCH_SIZE); |
|
|
|
// } catch (Exception e) { |
|
|
|
// // 处理异常 |
|
|
|
// System.err.println("Error processing batch LitigantInfo" + finalCounter + ": " + e.getMessage()); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// executorService.shutdown(); |
|
|
|
// try { |
|
|
|
// executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); |
|
|
|
// } catch (InterruptedException e) { |
|
|
|
// Thread.currentThread().interrupt(); |
|
|
|
// throw new RuntimeException("Interrupted while waiting for tasks to complete", e); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
public String convertTextToJson(String filePath) { |
|
|
|
StringBuilder contentBuilder = new StringBuilder(); |
|
|
|
|