Browse Source

fix:【定时任务】修改

master
zhangjing 1 month ago
parent
commit
97c9389da1
14 changed files with 456 additions and 113 deletions
  1. +2
    -0
      src/main/java/com/fkzy/warn/common/constants/EntityConstants.java
  2. +14
    -0
      src/main/java/com/fkzy/warn/common/constants/LawResearchUrlConstants.java
  3. +58
    -0
      src/main/java/com/fkzy/warn/common/util/DailyTask.java
  4. +39
    -32
      src/main/java/com/fkzy/warn/common/util/Demo.java
  5. +110
    -16
      src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java
  6. +68
    -44
      src/main/java/com/fkzy/warn/common/util/ReportUtil.java
  7. +3
    -0
      src/main/java/com/fkzy/warn/model/AlarmCase.java
  8. +5
    -0
      src/main/java/com/fkzy/warn/model/LitigantInfo.java
  9. +1
    -1
      src/main/java/com/fkzy/warn/service/AlarmCaseService.java
  10. +6
    -0
      src/main/java/com/fkzy/warn/service/ReportService.java
  11. +75
    -0
      src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java
  12. +20
    -17
      src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java
  13. +54
    -3
      src/main/java/com/fkzy/warn/service/impl/ReportServiceImpl.java
  14. +1
    -0
      徐州-司法.txt

+ 2
- 0
src/main/java/com/fkzy/warn/common/constants/EntityConstants.java View File

@ -23,4 +23,6 @@ public class EntityConstants {
public static final String SHELF_MSG = "已有上架版本,请先下架";
public static final String QUARTER = "quarter";
}

+ 14
- 0
src/main/java/com/fkzy/warn/common/constants/LawResearchUrlConstants.java View File

@ -25,6 +25,20 @@ public class LawResearchUrlConstants {
//司法
public final static String QUERY_SSSXXG = "/qyss/sfss/querySssxxg";
//-------------------------------新接口--------------------
//法眼模型司法
public final static String QUERY_SXX = "/qyss/sfss/querySsxx";
//失信记录
public final static String QUERY_DISHONEST = "/qyss/fyss/queryDishonest";
//限制高消费
public final static String QUERY_LIMITCONSUMPTION = "/qyss/fyss/queryLimitConsumption";
//-------------------------------新接口--------------------
//工商
public final static String QUERY_ENT_INFO = "/qyss/cr/queryEntInfo";
//工商工商基础信

+ 58
- 0
src/main/java/com/fkzy/warn/common/util/DailyTask.java View File

@ -0,0 +1,58 @@
package com.fkzy.warn.common.util;
/**
* @author zhangjing
* @date 2025/07/08 19:29
* @description
*/
import com.fkzy.warn.model.AlarmCase;
import com.fkzy.warn.service.AlarmCaseService;
import com.fkzy.warn.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
@Component
public class DailyTask {
@Resource
ReportService reportService;
@Resource
AlarmCaseService alarmCaseService;
/**
* 在每年的3月6月9月12月的1号凌晨2点执行
* Cron表达式:
*/
@Scheduled(cron = "0 0 2 1 3,6,9,12 ?")
public void executeQuarterlyTask() {
reportService.quarterlyReport();
System.out.println("每季度定时任务开始执行,当前时间: " + new Date());
}
// 北京时间
@Scheduled(cron = "0 0 1 * * ?", zone = "Asia/Shanghai")
public void executeAtOneAMInShanghai() {
alarmCaseService.getAlarmInfo();
System.out.println("【北京时间】每天凌晨1点执行:" + new Date());
}
// @Scheduled(cron = "0 0/5 * * * ?")
// public void executeEveryFiveMinutes() {
// metadataRecordService.uploadRecord();
// System.out.println("【每5分钟执行】当前时间:" + new Date());
// }
// @Scheduled(cron = "0 * * * * ?")
// public void executeEveryMinute() {
// metadataRecordService.uploadRecord();
// System.out.println("【每分钟执行】当前时间:" + new Date());
// }
// @Scheduled(cron = "0 */3 * * * ?")
// public void executeEveryThreeMinutes() {
// metadataRecordService.uploadRecord();
// System.out.println("【每3分钟执行】当前时间:" + new Date());
// }
}

+ 39
- 32
src/main/java/com/fkzy/warn/common/util/Demo.java View File

@ -21,41 +21,48 @@ import java.util.*;
* @description
*/
public class Demo {
// public static void main(String[] args) {
// LawResearchUtil law = new LawResearchUtil();
// law.querySssxxg(null, null);
// }
public static void main(String[] args) {
LawResearchUtil law = new LawResearchUtil();
law.querySxx(null, null);
// law.queryDishonest(null, null,null,null);
// law.queryLimitConsumption(null, null,null,null);
// law.monitorQuery(null, null);
// law.delcompany(null);
law.queryMonitorCases(null,null,null);
// law.addpublic(null);
}
public static void main(String[] args) {
String filePath = "司法.txt";
String jsonOutput = convertTextToJson(filePath);
if (jsonOutput != null) {
JSONObject jsonObject = new JSONObject().parseObject(jsonOutput);
JSONArray arr = jsonObject.getJSONArray("data");
JSONObject data = arr.getJSONObject(0);
JSONObject detail = data.getJSONObject("detail");
// JSONObject detail = data.getJSONObject("sx");
JSONObject civil = detail.getJSONObject("civil");
// JSONObject civil = detail.getJSONObject("civil");
//// JSONObject civil = detail.getJSONObject("implement");
JSONArray jsonArray = civil.getJSONArray("cases");
// JSONArray jsonArray = detail.getJSONArray("sxbzxr_current");
c_dsrxx(jsonArray);
// getCaseNum(jsonArray);
// getMaxValue(jsonArray);
// getCaseYearNum(jsonArray);
// getNowYear(jsonArray);
// getImplementInfo(jsonArray);
// getCaseSlcx(jsonArray);
} else {
System.out.println("转换失败,JSON 字符串为空");
}
}
// public static void main(String[] args) {
// String filePath = "司法.txt";
// String jsonOutput = convertTextToJson(filePath);
//
// if (jsonOutput != null) {
// JSONObject jsonObject = new JSONObject().parseObject(jsonOutput);
// JSONArray arr = jsonObject.getJSONArray("data");
// JSONObject data = arr.getJSONObject(0);
// JSONObject detail = data.getJSONObject("detail");
//// JSONObject detail = data.getJSONObject("sx");
// JSONObject civil = detail.getJSONObject("civil");
//// JSONObject civil = detail.getJSONObject("civil");
////// JSONObject civil = detail.getJSONObject("implement");
// JSONArray jsonArray = civil.getJSONArray("cases");
//// JSONArray jsonArray = detail.getJSONArray("sxbzxr_current");
// c_dsrxx(jsonArray);
//
//
//// getCaseNum(jsonArray);
//// getMaxValue(jsonArray);
//// getCaseYearNum(jsonArray);
//// getNowYear(jsonArray);
//// getImplementInfo(jsonArray);
//// getCaseSlcx(jsonArray);
// } else {
// System.out.println("转换失败,JSON 字符串为空");
// }
// }
static void getSX(JSONArray jsonArray){
//qyfr 企业法人
//pjje_gj 被执行金额

+ 110
- 16
src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java View File

@ -51,10 +51,89 @@ public class LawResearchUtil {
jsonObject.put("authorize", 1);
array.add(jsonObject);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_SSSXXG,
array, null, null,
"AmL92u2kCHjcCwcF",
"Pv+mA1v2LRkgsZWqg2mAQDYM1hToAr3JmDZRYQRhZ07tHXJ2wSYEnFTWRp2ly+"
);
}
//-------------------------------新接口--------------------
public String querySxx(String name, String creditCode) {
//默认测试数据
if (name == null) {
// name = "四川无声信息技术有限公司";
// creditCode = "915101007234134581";
// name = "徐州协能建材科技有限公司";
// creditCode = "91320301MA20TF8T84";
// name = "驻马店福强实业有限公司";
// creditCode = "91411728MA47Q0KJ5B";
name = "北京图灵高斯科技服务有限公司";
creditCode = "91110102MACPFACT41";
// name = "恒大集团有限公司";
// creditCode = "91440300087909371X";
}
JSONArray array = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", name);
jsonObject.put("creditCode", creditCode);
jsonObject.put("authorize", 1);
array.add(jsonObject);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_SXX,
array, null, null,
"AmL92u2kCHjcCwcF",
"Pv+mA1v2LRkgsZWqg2mAQDYM1hToAr3JmDZRYQRhZ07tHXJ2wSYEnFTWRp2Iy+OI"
);
}
public String queryDishonest(String companyName, String fromDate, String legalPersionName, String creditcode) {
//默认测试数据
if (companyName == null) {
// companyName = "恒大集团有限公司";
// fromDate = "2022/01/01";
legalPersionName = "杨贵单";
// creditcode = "91440300087909371X";
}
JSONArray array = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", legalPersionName);
// jsonObject.put("creditCode", creditcode);
jsonObject.put("authorize", 1);
jsonObject.put("id", "623021198104204013");
jsonObject.put("type","0");
array.add(jsonObject);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_DISHONEST,
array, null, null
,"xsXnjpCBbwKYU1d5"
,"Pv+mA1v2LRkgsZWqg2mAQJPn6o18VQagRlJny8DmuavlIoK6ZY6SG9CFBpFX0Ce5"
);
}
public String queryLimitConsumption(String companyName, String fromDate, String legalPersionName, String creditcode) {
//默认测试数据
if (companyName == null) {
companyName = "恒大集团有限公司";
// fromDate = "2022/01/01";
legalPersionName = "施新桃";
creditcode = "91440300087909371X";
}
JSONArray array = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", companyName);
jsonObject.put("creditCode", creditcode);
jsonObject.put("authorize", 1);
array.add(jsonObject);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_LIMITCONSUMPTION,
array, null, null
,"Ju000$LbdkX@tjTK"
,"Pv+mA1v2LRkgsZWqg2mAQONIs4+TPrj8Zi7WRB8+xjBfG5HByVFpyzjoWwn0Wsi6"
);
}
//-------------------------------新接口上面--------------------
/**
* 工商模型
*
@ -650,7 +729,7 @@ public class LawResearchUtil {
public String addpublic(String name) {
//默认测试数据
if (name == null) {
name = "小米科技有限责任公司";
name = "平凉市宏建煤炭有限责任公司";
// creditCode = "91110108551385082Q";
}
JSONObject jsonObject = new JSONObject();
@ -659,6 +738,8 @@ public class LawResearchUtil {
array.add(jsonObject);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.ADD_PUBLIC,
array, null, null
,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
);
}
/**
@ -672,7 +753,8 @@ public class LawResearchUtil {
public String delcompany(String name) {
//默认测试数据
if (name == null) {
name = "小米科技有限责任公司";
// name = "小米科技有限责任公司";
name = "恒大集团有限公司";
// creditCode = "91110108551385082Q";
}
JSONObject jsonObject = new JSONObject();
@ -681,6 +763,8 @@ public class LawResearchUtil {
array.add(jsonObject);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.DEL_COMPANY,
array, null, null
,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
);
}
/**
@ -703,6 +787,8 @@ public class LawResearchUtil {
jsonObject.put("pageSize", pageSize);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.MONITOR_QUERY,
null, jsonObject, null
,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
);
}
/**
@ -715,19 +801,22 @@ public class LawResearchUtil {
* @author zhangjing
* @create 2024/9/19
**/
public String queryMonitorCases(String queryDate,Integer pageIndex,Integer pageSize) {
public static String queryMonitorCases(String queryDate,Integer pageIndex,Integer pageSize) {
//默认测试数据
if (queryDate == null) {
queryDate="2022-07-06";
pageIndex = 1;
pageSize = 20;
// queryDate="2022-07-06";
queryDate="2026-02-08";
// pageIndex = 1;
// pageSize = 20;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("queryDate", queryDate);
jsonObject.put("pageIndex", pageIndex);
jsonObject.put("pageSize", pageSize);
// jsonObject.put("pageIndex", pageIndex);
// jsonObject.put("pageSize", pageSize);
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_MONITOR_CASES,
null, jsonObject, null
null, jsonObject,null
,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
);
}
/**
@ -902,10 +991,15 @@ public class LawResearchUtil {
null, jsonObject, null
);
}
private String getData(String apiUrl, JSONArray array, JSONObject jsonObject, String method
) {
return "";
}
private String getData(String apiUrl, JSONArray array, JSONObject jsonObject, String method) {
private static String getData(String apiUrl, JSONArray array, JSONObject jsonObject, String method,
String key,String ticket
) {
RestTemplate restTemplate = new RestTemplate();
HttpComponentsClientHttpRequestFactory requestFactory
= new HttpComponentsClientHttpRequestFactory();
@ -915,12 +1009,12 @@ public class LawResearchUtil {
restTemplate.setRequestFactory(requestFactory);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("ticket", LawResearchUrlConstants.TICKET);
headers.set("Authorization", LawResearchUrlConstants.TICKET);
headers.set("ticket", ticket);
headers.set("Authorization", ticket);
String request = (array != null) ? array.toJSONString() : jsonObject.toJSONString();
try {
//需要对入参进行 aes 加密
String requestBody = AES.aesEncrypt(request, LawResearchUrlConstants.KEY);
String requestBody = AES.aesEncrypt(request, key);
System.out.println("requestBody=====" + requestBody);
//设置访问的 Entity
HttpEntity entity = new HttpEntity<>(requestBody, headers);
@ -934,8 +1028,8 @@ public class LawResearchUtil {
String resultData=null;
try (PrintWriter writer = new PrintWriter(new File(filePath))) {
//接收到返回结果需要进行 aes 解密
resultData = AES.aesDecrypt(result.getBody(), LawResearchUrlConstants.KEY);
// 写入内容
resultData = AES.aesDecrypt(result.getBody(), key);
//写入内容
writer.println(resultData);
// 自动关闭因为使用了 try-with-resources 语句

+ 68
- 44
src/main/java/com/fkzy/warn/common/util/ReportUtil.java View File

@ -1015,43 +1015,44 @@ public class ReportUtil {
roleCaseAmountMap.put("第三人", BigDecimal.ZERO);
roleCaseAmountMap.put("其他", BigDecimal.ZERO);
for (LawCase lawCase : caseList) {
String slcx = lawCase.getNSlcx();
String companyName = lawCase.getCompanyName();
if (slcxCaseCountMap.containsKey(slcx)) {
slcxCaseCountMap.put(slcx, slcxCaseCountMap.get(slcx) + 1);
if (lawCase.getNQsbdje()!=null){
slcxCaseAmountMap.put(slcx, slcxCaseAmountMap.getOrDefault(slcx, BigDecimal.ZERO).add(lawCase.getNQsbdje()));
if (!caseList.isEmpty()) {
for (LawCase lawCase : caseList) {
String slcx = lawCase.getNSlcx();
String companyName = lawCase.getCompanyName();
if (slcxCaseCountMap.containsKey(slcx)) {
slcxCaseCountMap.put(slcx, slcxCaseCountMap.get(slcx) + 1);
if (lawCase.getNQsbdje() != null) {
slcxCaseAmountMap.put(slcx, slcxCaseAmountMap.getOrDefault(slcx, BigDecimal.ZERO).add(lawCase.getNQsbdje()));
}
}
}
if (lawCase.getCSsdy()!=null&&provinceMap.containsKey(lawCase.getCSsdy())){
EnterpriseProvince enterpriseProvince = provinceMap.get(lawCase.getCSsdy());
enterpriseProvince.setCount(enterpriseProvince.getCount()+1);
if (lawCase.getNQsbdje()!=null){
enterpriseProvince.setAmount(enterpriseProvince.getAmount().add(lawCase.getNQsbdje()));
if (lawCase.getCSsdy() != null && provinceMap.containsKey(lawCase.getCSsdy())) {
EnterpriseProvince enterpriseProvince = provinceMap.get(lawCase.getCSsdy());
enterpriseProvince.setCount(enterpriseProvince.getCount() + 1);
if (lawCase.getNQsbdje() != null) {
enterpriseProvince.setAmount(enterpriseProvince.getAmount().add(lawCase.getNQsbdje()));
}
provinceMap.put(lawCase.getCSsdy(), enterpriseProvince);
}
provinceMap.put(lawCase.getCSsdy(),enterpriseProvince);
}
for (LitigantInfo litigantInfo : lawCase.getLitigantInfoList()) {
String role = litigantInfo.getNSsdw();
if (companyName.equals(litigantInfo.getCMc())&&roleCaseCountMap.containsKey(role)) {
roleCaseCountMap.put(role, roleCaseCountMap.get(role) + 1);
if (lawCase.getNQsbdje()!=null){
roleCaseAmountMap.put(role, roleCaseAmountMap.get(role).add(lawCase.getNQsbdje()));
for (LitigantInfo litigantInfo : lawCase.getLitigantInfoList()) {
String role = litigantInfo.getNSsdw();
if (companyName.equals(litigantInfo.getCMc()) && roleCaseCountMap.containsKey(role)) {
roleCaseCountMap.put(role, roleCaseCountMap.get(role) + 1);
if (lawCase.getNQsbdje() != null) {
roleCaseAmountMap.put(role, roleCaseAmountMap.get(role).add(lawCase.getNQsbdje()));
}
}
}
}
if (lawCase.getNQsbdje()!=null){
totalAmount = totalAmount.add(lawCase.getNQsbdje());
}
// 统计案由
String caseReason = lawCase.getNLaay();
if (caseReason != null && !caseReason.isEmpty()) {
caseReasonCountMap.put(caseReason, caseReasonCountMap.getOrDefault(caseReason, 0) + 1);
if (lawCase.getNQsbdje()!=null){
caseReasonAmontMap.put(caseReason, caseReasonAmontMap.getOrDefault(caseReason, BigDecimal.ZERO).add(lawCase.getNQsbdje()));
if (lawCase.getNQsbdje() != null) {
totalAmount = totalAmount.add(lawCase.getNQsbdje());
}
// 统计案由
String caseReason = lawCase.getNLaay();
if (caseReason != null && !caseReason.isEmpty()) {
caseReasonCountMap.put(caseReason, caseReasonCountMap.getOrDefault(caseReason, 0) + 1);
if (lawCase.getNQsbdje() != null) {
caseReasonAmontMap.put(caseReason, caseReasonAmontMap.getOrDefault(caseReason, BigDecimal.ZERO).add(lawCase.getNQsbdje()));
}
}
}
}
@ -1062,20 +1063,43 @@ public class ReportUtil {
List<Map.Entry<String, BigDecimal>> sortedCaseReasonAmonts = new ArrayList<>(caseReasonAmontMap.entrySet());
sortedCaseReasonAmonts.sort((entry1, entry2) -> entry2.getValue().compareTo(entry1.getValue()));
// 取出前三的案由金额
data.setAyAmountTop1(sortedCaseReasonAmonts.get(0).getValue());
data.setAyAmountTop2(sortedCaseReasonAmonts.get(1).getValue());
data.setAyAmountTop3(sortedCaseReasonAmonts.get(2).getValue());
data.setAyNameAmountTop1(sortedCaseReasonAmonts.get(0).getKey());
data.setAyNameAmountTop2(sortedCaseReasonAmonts.get(1).getKey());
data.setAyNameAmountTop3(sortedCaseReasonAmonts.get(2).getKey());
if (!sortedCaseReasonAmonts.isEmpty()){
// 检查是否有第1个元素
data.setAyAmountTop1(sortedCaseReasonAmonts.get(0).getValue());
data.setAyNameAmountTop1(sortedCaseReasonAmonts.get(0).getKey());
// 检查是否有第2个元素
if (sortedCaseReasonAmonts.size() > 1) {
data.setAyAmountTop2(sortedCaseReasonAmonts.get(1).getValue());
data.setAyNameAmountTop2(sortedCaseReasonAmonts.get(1).getKey());
}
// 检查是否有第3个元素
if (sortedCaseReasonAmonts.size() > 2) {
data.setAyAmountTop3(sortedCaseReasonAmonts.get(2).getValue());
data.setAyNameAmountTop3(sortedCaseReasonAmonts.get(2).getKey());
}
}
// 取出前三的案由
data.setAyCountTop1(sortedCaseReasons.get(0).getValue());
data.setAyCountTop2(sortedCaseReasons.get(1).getValue());
data.setAyCountTop3(sortedCaseReasons.get(2).getValue());
data.setAyNameTop1(sortedCaseReasons.get(0).getKey());
data.setAyNameTop2(sortedCaseReasons.get(1).getKey());
data.setAyNameTop3(sortedCaseReasons.get(2).getKey());
if (!sortedCaseReasons.isEmpty()) {
// 检查并设置 Top1
data.setAyCountTop1(sortedCaseReasons.get(0).getValue());
data.setAyNameTop1(sortedCaseReasons.get(0).getKey());
// 检查并设置 Top2
if (sortedCaseReasons.size() > 1) {
data.setAyCountTop2(sortedCaseReasons.get(1).getValue());
data.setAyNameTop2(sortedCaseReasons.get(1).getKey());
}
// 检查并设置 Top3
if (sortedCaseReasons.size() > 2) {
data.setAyCountTop3(sortedCaseReasons.get(2).getValue());
data.setAyNameTop3(sortedCaseReasons.get(2).getKey());
}
}
//审理阶段
data.setYsCount(slcxCaseCountMap.get("一审"));
data.setEsCount(slcxCaseCountMap.get("二审"));

+ 3
- 0
src/main/java/com/fkzy/warn/model/AlarmCase.java View File

@ -31,6 +31,9 @@ public class AlarmCase extends BaseField{
*/
@ApiModelProperty("企业名称")
private String companyName;
@ApiModelProperty("企业名称")
private String name;
/**
* 统一社会信用代码
*/

+ 5
- 0
src/main/java/com/fkzy/warn/model/LitigantInfo.java View File

@ -1,6 +1,7 @@
package com.fkzy.warn.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
@ -25,6 +26,10 @@ public class LitigantInfo extends BaseField{
@ApiModelProperty("案件标识")
private String nAjbs;
@ApiModelProperty("案号")
@TableField(value = "c_ah")
private String cAh;
/**
* 名称
*/

+ 1
- 1
src/main/java/com/fkzy/warn/service/AlarmCaseService.java View File

@ -34,7 +34,7 @@ public interface AlarmCaseService extends IService {
void deleteModel(List<String> ids);
void getAlarmInfo();
}

+ 6
- 0
src/main/java/com/fkzy/warn/service/ReportService.java View File

@ -47,4 +47,10 @@ public interface ReportService extends IService {
Map<String,Object> generateReport(GenerateReportParams params, String ticket);
/**
* 季度报告生成
* @return
*/
void quarterlyReport();
}

+ 75
- 0
src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java View File

@ -1,13 +1,29 @@
package com.fkzy.warn.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fkzy.warn.common.constants.EntityConstants;
import com.fkzy.warn.common.util.LawResearchUtil;
import com.fkzy.warn.common.util.TimeUtil;
import com.fkzy.warn.mapper.AlarmCaseMapper;
import com.fkzy.warn.model.AlarmCase;
import com.fkzy.warn.model.LawCase;
import com.fkzy.warn.model.LitigantInfo;
import com.fkzy.warn.model.MonitorUsers;
import com.fkzy.warn.service.AlarmCaseService;
import com.fkzy.warn.service.LawCaseService;
import com.fkzy.warn.service.LitigantInfoService;
import com.fkzy.warn.service.MonitorUsersService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -19,6 +35,12 @@ import java.util.List;
public class AlarmCaseServiceImpl extends ServiceImpl<AlarmCaseMapper, AlarmCase> implements
AlarmCaseService {
@Resource
LawCaseService lawCaseService;
@Resource
LitigantInfoService litigantInfoService;
@Resource
MonitorUsersService monitorUsersService;
@Override
public void saveModel(AlarmCase entity, String ticket) {
@ -39,5 +61,58 @@ public class AlarmCaseServiceImpl extends ServiceImpl
update(entity, wrapper);
}
@Override
public void getAlarmInfo() {
String result = LawResearchUtil.queryMonitorCases(TimeUtil.formatTimeStr(new Date()),null,null);
if (result==null){
return;
}
JSONObject jsonObject = new JSONObject().parseObject(result);
if (jsonObject==null){
return;
}
JSONArray arr = jsonObject.getJSONArray("data");
if (arr!=null&& !arr.isEmpty()){
List<AlarmCase> alarmCaseList = arr.toJavaList(AlarmCase.class);
if (alarmCaseList!=null&&!alarmCaseList.isEmpty()){
alarmCaseList.forEach(item ->{
MonitorUsers monitorUsers = monitorUsersService.getOne(new LambdaQueryWrapper<MonitorUsers>()
.eq(MonitorUsers::getCompanyName,item.getName())
);
item.setCompanyName(monitorUsers!=null?monitorUsers.getCompanyName():null);
item.setCreditCode(monitorUsers!=null?monitorUsers.getCreditCode():null);
item.setAlarmDate(new Date());
});
}
saveBatch(alarmCaseList);
//如果有预警需要再查司法全量数据有待考虑,先存预警信息
List<LawCase> lawCaseList = arr.toJavaList(LawCase.class);
lawCaseService.saveOrUpdateBatch(lawCaseList);
//保存原告被告
for (int i = 0; i < arr.size(); i++) {
List<LitigantInfo> litigantInfoList = new ArrayList<>();
JSONObject object = arr.getJSONObject(i);
JSONArray cDsrxx = object.getJSONArray("c_dsrxx");
String ajbs = object.getString("n_ajbs");
String ah = object.getString("n_ah");
for (int j = 0; j < cDsrxx.size(); j++) {
JSONObject obj = cDsrxx.getJSONObject(j);
LitigantInfo litigantInfo = JSON.parseObject(obj.toString(), LitigantInfo.class);
litigantInfo.setNAjbs(ajbs);
litigantInfo.setCAh(ah);
litigantInfoList.add(litigantInfo);
}
litigantInfoService.remove(new LambdaQueryWrapper<LitigantInfo>()
.eq(StringUtils.isNotBlank(ajbs),LitigantInfo::getNAjbs,ajbs)
.eq(StringUtils.isNotBlank(ah),LitigantInfo::getCAh,ah)
);
litigantInfoService.saveBatch(litigantInfoList);
};
}
}
}

+ 20
- 17
src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java View File

@ -87,7 +87,7 @@ public class LawCaseServiceImpl extends ServiceImpl impl
// 获取近三个月的案件 d_larq 立案日期字段
QueryWrapper<LawCase> query = new QueryWrapper<>();
query.ge("d_larq", threeMonthsAgo);
query.ge("credit_code", creditCode);
query.eq("credit_code", creditCode);
List<LawCase> caseList = this.list(query);
if (needLitigant){
for (LawCase lawCase : caseList) {
@ -117,7 +117,7 @@ public class LawCaseServiceImpl extends ServiceImpl impl
// 获取近三个月的案件 d_larq 立案日期字段
QueryWrapper<LawCase> query = new QueryWrapper<>();
query.ge("d_larq", threeMonthsAgo);
query.ge("credit_code", creditCode);
query.eq("credit_code", creditCode);
List<LawCase> caseList = this.list(query);
for (LawCase lawCase : caseList) {
QueryWrapper<LitigantInfo> infoQueryWrapper = new QueryWrapper<>();
@ -178,11 +178,14 @@ public class LawCaseServiceImpl extends ServiceImpl impl
@Override
public void judicialModelSave(JSONObject jsonObject) {
setAlarmInfo("915101007234134581");
setAlarmInfo("91320301MA20TF8T84");
if (true){
return;
}
// ReportModel reportModel = createReportData();
// ReportUtil.createReport(reportModel);
String filePath = "司法.txt";
String filePath = "徐州-司法.txt";
// String filePath = "工商.txt";
String jsonOutput = convertTextToJson(filePath);
if (jsonOutput == null) {
@ -210,19 +213,19 @@ public class LawCaseServiceImpl extends ServiceImpl impl
}
// 失信
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 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);

+ 54
- 3
src/main/java/com/fkzy/warn/service/impl/ReportServiceImpl.java View File

@ -17,9 +17,9 @@ import com.fkzy.warn.service.UserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
/**
* @author zhangjing
@ -81,4 +81,55 @@ public class ReportServiceImpl extends ServiceImpl impleme
result.put("basicEnterprise",enterpriseInfo);
return result;
}
@Override
public void quarterlyReport() {
List<User> user = userService.list();
List<Report> reportList = new ArrayList<>();
user.forEach(item->{
Report report = new Report();
report.setReportTime(new Date());
report.setReportType(EntityConstants.QUARTER);
report.setCompanyName(item.getCompanyName());
report.setCreditCode(item.getCreditCode());
report.setBusinessId(item.getId());
//根据当前定时判断开始时间 1月1日 3月1日 6月1日 9月1日
LocalDate start = calculateLastQuarterStartDate(LocalDate.now());
report.setStartTime(Date.from(start.atStartOfDay(ZoneId.systemDefault()).toInstant()));
report.setEndTime(new Date());
report.setIsDel(0);
report.setName(item.getCompanyName()+"-季度报告");
reportList.add(report);
});
reportService.saveBatch(reportList);
}
private LocalDate calculateLastQuarterStartDate(LocalDate currentDate) {
int currentMonth = currentDate.getMonthValue();
int currentYear = currentDate.getYear();
int startMonth;
// 3月1日执行 -> 获取Q1开始日期 (1月1日)
if (currentMonth == 3) {
startMonth = 1;
} else if (currentMonth == 6) {
// 6月1日执行 -> 获取Q2开始日期 (4月1日)
startMonth = 4;
} else if (currentMonth == 9) {
// 9月1日执行 -> 获取Q3开始日期 (7月1日)
startMonth = 7;
} else if (currentMonth == 12) {
// 12月1日执行 -> 获取Q4开始日期 (10月1日)
startMonth = 10;
} else {
// 如果任务在其他时间意外触发返回一个默认值或抛出异常
return currentDate.withDayOfMonth(1).withMonth(1);
// 默认返回今年1月1日
}
return LocalDate.of(currentYear, startMonth, 1);
}
}

+ 1
- 0
徐州-司法.txt
File diff suppressed because it is too large
View File


Loading…
Cancel
Save