|
|
|
@ -8,10 +8,7 @@ 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.model.EnterpriseInfo; |
|
|
|
import com.fkzy.warn.model.LawCase; |
|
|
|
import com.fkzy.warn.model.LitigantInfo; |
|
|
|
import com.fkzy.warn.model.ReportModel; |
|
|
|
import com.fkzy.warn.model.*; |
|
|
|
import com.fkzy.warn.service.*; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
@ -44,6 +41,15 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
@Autowired |
|
|
|
private EnterpriseInfoService enterpriseInfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EnterpriseAlarmInfoService enterpriseAlarmInfoService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AlarmCaseService alarmCaseService; |
|
|
|
@Autowired |
|
|
|
private EnterpriseProvinceService enterpriseProvinceService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveModel(LawCase entity, String ticket) { |
|
|
|
save(entity); |
|
|
|
@ -70,7 +76,7 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
* @author zhangjing |
|
|
|
* @create 2024/12/15 |
|
|
|
**/ |
|
|
|
private List<LawCase> threeMonthsCases() { |
|
|
|
private List<LawCase> threeMonthsCases(String creditCode,boolean needLitigant) { |
|
|
|
// 获取当前日期 |
|
|
|
Date currentDate = new Date(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
@ -81,11 +87,14 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
QueryWrapper<LawCase> query = new QueryWrapper<>(); |
|
|
|
query.ge("d_larq", threeMonthsAgo); |
|
|
|
List<LawCase> caseList = this.list(query); |
|
|
|
for (LawCase lawCase : caseList) { |
|
|
|
QueryWrapper<LitigantInfo> infoQueryWrapper = new QueryWrapper<>(); |
|
|
|
infoQueryWrapper.eq("n_ajbs", lawCase.getNAjbs()); |
|
|
|
lawCase.setLitigantInfoList(litigantInfoService.list(infoQueryWrapper)); |
|
|
|
if (needLitigant){ |
|
|
|
for (LawCase lawCase : caseList) { |
|
|
|
QueryWrapper<LitigantInfo> infoQueryWrapper = new QueryWrapper<>(); |
|
|
|
infoQueryWrapper.eq("n_ajbs", lawCase.getNAjbs()); |
|
|
|
lawCase.setLitigantInfoList(litigantInfoService.list(infoQueryWrapper)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return caseList; |
|
|
|
} |
|
|
|
/** |
|
|
|
@ -95,7 +104,8 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
* @author zhangjing |
|
|
|
* @create 2024/12/15 |
|
|
|
**/ |
|
|
|
private List<LawCase> threeYearsCases() { |
|
|
|
@Override |
|
|
|
public List<LawCase> threeYearsCases(String creditCode) { |
|
|
|
// 获取当前日期 |
|
|
|
Date currentDate = new Date(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
@ -114,19 +124,19 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
return caseList; |
|
|
|
} |
|
|
|
|
|
|
|
private ReportModel createReportData(){ |
|
|
|
private ReportModel createReportData(String creditCode){ |
|
|
|
ReportModel reportModel = new ReportModel(); |
|
|
|
QueryWrapper<EnterpriseInfo> enterpriseInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
enterpriseInfoQueryWrapper.eq("CREDITCODE", "91440300087909371X"); |
|
|
|
enterpriseInfoQueryWrapper.eq("CREDITCODE", creditCode); |
|
|
|
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getOne(enterpriseInfoQueryWrapper); |
|
|
|
reportModel.setBackgroundJudicial(ReportUtil.backgroundJudicial(enterpriseInfo)); |
|
|
|
reportModel.setBasicEnterprise(enterpriseInfo); |
|
|
|
List<LawCase> threeMonthsCases = threeMonthsCases(); |
|
|
|
List<LawCase> threeMonthsCases = threeMonthsCases(creditCode,true); |
|
|
|
reportModel.setThreeMonthsText1(ReportUtil.threeMonthsText1(threeMonthsCases)); |
|
|
|
reportModel.setThreeMonthsCases(threeMonthsCases); |
|
|
|
reportModel.setThreeMonthsText2(ReportUtil.threeMonthsText2(threeMonthsCases)); |
|
|
|
reportModel.setThreeMonthsText3(ReportUtil.threeMonthsText3(threeMonthsCases)); |
|
|
|
List<LawCase> threeYearsCases = threeYearsCases(); |
|
|
|
List<LawCase> threeYearsCases = threeYearsCases(creditCode); |
|
|
|
reportModel.setCaseStageText1(ReportUtil.caseStageText1(threeYearsCases)); |
|
|
|
reportModel.setLocationText(ReportUtil.locationText(threeYearsCases)); |
|
|
|
reportModel.setCaseActionText1(ReportUtil.caseActionText1(threeYearsCases)); |
|
|
|
@ -137,21 +147,54 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
reportModel.setHighFrequencyText(ReportUtil.highFrequencyText(threeYearsCases)); |
|
|
|
return reportModel; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 案件信息汇总 |
|
|
|
* @param creditCode |
|
|
|
* @return void |
|
|
|
* @author zhangjing |
|
|
|
* @create 2024/12/24 |
|
|
|
**/ |
|
|
|
private void setAlarmInfo(String creditCode){ |
|
|
|
EnterpriseAlarmInfo data = new EnterpriseAlarmInfo(); |
|
|
|
data.setCreditCode(creditCode); |
|
|
|
//告警数 |
|
|
|
QueryWrapper<AlarmCase> alarmCaseQueryWrapper = new QueryWrapper<>(); |
|
|
|
alarmCaseQueryWrapper.eq("credit_code", creditCode); |
|
|
|
data.setAlarmCount(alarmCaseService.count(alarmCaseQueryWrapper)); |
|
|
|
//告警案件金额 |
|
|
|
List<LawCase> alarmCases = baseMapper.queryByAlarmCase(creditCode); |
|
|
|
data.setAlarmAmount(ReportUtil.getCaseAmount(alarmCases)); |
|
|
|
//近三月案件信息 |
|
|
|
List<LawCase> threeMonths = threeMonthsCases(creditCode,false); |
|
|
|
data.setThreeMonthsCount(threeMonths.size()); |
|
|
|
data.setThreeMonthsAmount(ReportUtil.getCaseAmount(threeMonths)); |
|
|
|
//近三年案件信息 |
|
|
|
List<LawCase> threeYears = threeYearsCases(creditCode); |
|
|
|
List<EnterpriseProvince> enterpriseProvinceList = new ArrayList<>(); |
|
|
|
ReportUtil.setAlarmInfo(data, threeYears,enterpriseProvinceList); |
|
|
|
QueryWrapper<EnterpriseProvince> enterpriseProvinceQueue = new QueryWrapper<>(); |
|
|
|
enterpriseProvinceQueue.eq("credit_code",creditCode); |
|
|
|
enterpriseProvinceService.remove(enterpriseProvinceQueue); |
|
|
|
enterpriseProvinceService.saveBatch(enterpriseProvinceList); |
|
|
|
enterpriseAlarmInfoService.saveOrUpdate(data); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void judicialModelSave(JSONObject jsonObject) { |
|
|
|
ReportModel reportModel = createReportData(); |
|
|
|
ReportUtil.createReport(reportModel); |
|
|
|
// setAlarmInfo("91440300087909371X"); |
|
|
|
|
|
|
|
// 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); |
|
|
|
String filePath = "工商.txt"; |
|
|
|
String jsonOutput = convertTextToJson(filePath); |
|
|
|
if (jsonOutput == null) { |
|
|
|
logger.error("转换失败,JSON 字符串为空"); |
|
|
|
return; |
|
|
|
} |
|
|
|
jsonObject = new JSONObject().parseObject(jsonOutput); |
|
|
|
enterpriseInfoService.industryModelSave(jsonObject); |
|
|
|
// JSONArray arr = jsonObject.getJSONArray("data"); |
|
|
|
// if (arr == null || arr.isEmpty()) { |
|
|
|
// logger.error("数据数组为空"); |
|
|
|
@ -257,87 +300,27 @@ public class LawCaseServiceImpl extends ServiceImpl impl |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 批量大小 |
|
|
|
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(); // 总记录数 |
|
|
|
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); // 提取当前批次的记录 |
|
|
|
// 执行批量插入或更新操作 |
|
|
|
int toIndex = Math.min(i + batchSize, size); |
|
|
|
List<LawCase> batch = entityList.subList(i, toIndex); |
|
|
|
this.saveOrUpdateBatch(batch); |
|
|
|
} |
|
|
|
} |
|
|
|
// 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(); // 总记录数 |
|
|
|
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); // 提取当前批次的记录 |
|
|
|
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(); |
|
|
|
|