Browse Source

fix:【定时逻辑】修改

master
zhangjing 1 month ago
parent
commit
462d48dd2f
14 changed files with 517 additions and 91 deletions
  1. +9
    -6
      src/main/java/com/fkzy/warn/common/util/DailyTask.java
  2. +44
    -15
      src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java
  3. +14
    -0
      src/main/java/com/fkzy/warn/mapper/InvocationRecordMapper.java
  4. +12
    -0
      src/main/java/com/fkzy/warn/model/Authorization.java
  5. +20
    -12
      src/main/java/com/fkzy/warn/model/CaseTree.java
  6. +76
    -0
      src/main/java/com/fkzy/warn/model/InvocationRecord.java
  7. +11
    -0
      src/main/java/com/fkzy/warn/model/MonitorUsers.java
  8. +48
    -0
      src/main/java/com/fkzy/warn/service/InvocationRecordService.java
  9. +7
    -0
      src/main/java/com/fkzy/warn/service/LawCaseService.java
  10. +6
    -1
      src/main/java/com/fkzy/warn/service/MonitorUsersService.java
  11. +42
    -41
      src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java
  12. +57
    -0
      src/main/java/com/fkzy/warn/service/impl/InvocationRecordServiceImpl.java
  13. +71
    -14
      src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java
  14. +100
    -2
      src/main/java/com/fkzy/warn/service/impl/MonitorUsersServiceImpl.java

+ 9
- 6
src/main/java/com/fkzy/warn/common/util/DailyTask.java View File

@ -7,6 +7,7 @@ package com.fkzy.warn.common.util;
*/ */
import com.fkzy.warn.model.AlarmCase; import com.fkzy.warn.model.AlarmCase;
import com.fkzy.warn.service.AlarmCaseService; import com.fkzy.warn.service.AlarmCaseService;
import com.fkzy.warn.service.MonitorUsersService;
import com.fkzy.warn.service.ReportService; import com.fkzy.warn.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -22,6 +23,8 @@ public class DailyTask {
ReportService reportService; ReportService reportService;
@Resource @Resource
AlarmCaseService alarmCaseService; AlarmCaseService alarmCaseService;
@Resource
MonitorUsersService monitorUsersService;
/** /**
* 在每年的3月6月9月12月的1号凌晨2点执行 * 在每年的3月6月9月12月的1号凌晨2点执行
* Cron表达式: * Cron表达式:
@ -44,15 +47,15 @@ public class DailyTask {
// System.out.println("【每5分钟执行】当前时间:" + new Date()); // System.out.println("【每5分钟执行】当前时间:" + new Date());
// } // }
// @Scheduled(cron = "0 * * * * ?")
// public void executeEveryMinute() {
// metadataRecordService.uploadRecord();
// System.out.println("【每分钟执行】当前时间:" + new Date());
// }
@Scheduled(cron = "0 * * * * ?")
public void executeEveryMinute() {
monitorUsersService.checkMonitor();
System.out.println("【每分钟执行】当前时间:" + new Date());
}
// @Scheduled(cron = "0 */3 * * * ?") // @Scheduled(cron = "0 */3 * * * ?")
// public void executeEveryThreeMinutes() { // public void executeEveryThreeMinutes() {
// metadataRecordService.uploadRecord();
// monitorUsersService.checkMonitor();
// System.out.println("【每3分钟执行】当前时间:" + new Date()); // System.out.println("【每3分钟执行】当前时间:" + new Date());
// } // }
} }

+ 44
- 15
src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java View File

@ -2,11 +2,14 @@ package com.fkzy.warn.common.util;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fkzy.warn.common.constants.EntityConstants;
import com.fkzy.warn.common.constants.LawResearchUrlConstants; import com.fkzy.warn.common.constants.LawResearchUrlConstants;
import com.fkzy.warn.model.InvocationRecord;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -25,6 +28,9 @@ public class LawResearchUtil {
// code 3001 请求失败 // code 3001 请求失败
/** /**
* 司法模型 * 司法模型
* *
@ -34,7 +40,7 @@ public class LawResearchUtil {
* @author zhangjing * @author zhangjing
* @create 2024/9/19 * @create 2024/9/19
**/ **/
public String querySssxxg(String name, String creditCode) {
public InvocationRecord querySssxxg(String name, String creditCode) {
//默认测试数据 //默认测试数据
if (name == null) { if (name == null) {
@ -54,10 +60,11 @@ public class LawResearchUtil {
array, null, null, array, null, null,
"AmL92u2kCHjcCwcF", "AmL92u2kCHjcCwcF",
"Pv+mA1v2LRkgsZWqg2mAQDYM1hToAr3JmDZRYQRhZ07tHXJ2wSYEnFTWRp2ly+" "Pv+mA1v2LRkgsZWqg2mAQDYM1hToAr3JmDZRYQRhZ07tHXJ2wSYEnFTWRp2ly+"
,null
); );
} }
//-------------------------------新接口-------------------- //-------------------------------新接口--------------------
public static String querySxx(String name, String creditCode) {
public static InvocationRecord querySxx(String name, String creditCode) {
//默认测试数据 //默认测试数据
if (name == null) { if (name == null) {
@ -84,11 +91,12 @@ public class LawResearchUtil {
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_SXX, return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_SXX,
array, null, null, array, null, null,
"AmL92u2kCHjcCwcF", "AmL92u2kCHjcCwcF",
"Pv+mA1v2LRkgsZWqg2mAQDYM1hToAr3JmDZRYQRhZ07tHXJ2wSYEnFTWRp2Iy+OI"
"Pv+mA1v2LRkgsZWqg2mAQDYM1hToAr3JmDZRYQRhZ07tHXJ2wSYEnFTWRp2Iy+OI",
"司法模型"
); );
} }
public String queryDishonest(String companyName, String fromDate, String legalPersionName, String creditcode) {
public InvocationRecord queryDishonest(String companyName, String fromDate, String legalPersionName, String creditcode) {
//默认测试数据 //默认测试数据
JSONArray array = new JSONArray(); JSONArray array = new JSONArray();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
@ -112,11 +120,12 @@ public class LawResearchUtil {
return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_DISHONEST, return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_DISHONEST,
array, null, null array, null, null
,"xsXnjpCBbwKYU1d5" ,"xsXnjpCBbwKYU1d5"
,"Pv+mA1v2LRkgsZWqg2mAQJPn6o18VQagRlJny8DmuavlIoK6ZY6SG9CFBpFX0Ce5"
,"Pv+mA1v2LRkgsZWqg2mAQJPn6o18VQagRlJny8DmuavlIoK6ZY6SG9CFBpFX0Ce5",
"失信"
); );
} }
public String queryLimitConsumption(String companyName, String fromDate, String legalPersionName, String creditcode) {
public InvocationRecord queryLimitConsumption(String companyName, String fromDate, String legalPersionName, String creditcode) {
//默认测试数据 //默认测试数据
if (companyName == null) { if (companyName == null) {
companyName = "恒大集团有限公司"; companyName = "恒大集团有限公司";
@ -131,6 +140,7 @@ public class LawResearchUtil {
array, null, null array, null, null
,"Ju000$LbdkX@tjTK" ,"Ju000$LbdkX@tjTK"
,"Pv+mA1v2LRkgsZWqg2mAQONIs4+TPrj8Zi7WRB8+xjBfG5HByVFpyzjoWwn0Wsi6" ,"Pv+mA1v2LRkgsZWqg2mAQONIs4+TPrj8Zi7WRB8+xjBfG5HByVFpyzjoWwn0Wsi6"
, "限高"
); );
} }
@ -728,7 +738,7 @@ public class LawResearchUtil {
* @author zhangjing * @author zhangjing
* @create 2024/9/19 * @create 2024/9/19
**/ **/
public String addpublic(String name) {
public InvocationRecord addpublic(String name) {
//默认测试数据 //默认测试数据
if (name == null) { if (name == null) {
name = "平凉市宏建煤炭有限责任公司"; name = "平凉市宏建煤炭有限责任公司";
@ -742,6 +752,7 @@ public class LawResearchUtil {
array, null, null array, null, null
,"Cdi9CIzt0AnWucOe" ,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv" ,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
, "监控名单添加接口"
); );
} }
/** /**
@ -752,7 +763,7 @@ public class LawResearchUtil {
* @author zhangjing * @author zhangjing
* @create 2024/9/19 * @create 2024/9/19
**/ **/
public String delcompany(String name) {
public InvocationRecord delcompany(String name) {
//默认测试数据 //默认测试数据
if (name == null) { if (name == null) {
// name = "小米科技有限责任公司"; // name = "小米科技有限责任公司";
@ -767,6 +778,7 @@ public class LawResearchUtil {
array, null, null array, null, null
,"Cdi9CIzt0AnWucOe" ,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv" ,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
, "监控名单删除接口"
); );
} }
/** /**
@ -778,7 +790,7 @@ public class LawResearchUtil {
* @author zhangjing * @author zhangjing
* @create 2024/9/19 * @create 2024/9/19
**/ **/
public String monitorQuery(Integer pageIndex,Integer pageSize) {
public InvocationRecord monitorQuery(Integer pageIndex,Integer pageSize) {
//默认测试数据 //默认测试数据
if (pageIndex == null) { if (pageIndex == null) {
pageIndex = 1; pageIndex = 1;
@ -791,6 +803,7 @@ public class LawResearchUtil {
null, jsonObject, null null, jsonObject, null
,"Cdi9CIzt0AnWucOe" ,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv" ,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
, "监控名单查询接口"
); );
} }
/** /**
@ -803,7 +816,7 @@ public class LawResearchUtil {
* @author zhangjing * @author zhangjing
* @create 2024/9/19 * @create 2024/9/19
**/ **/
public static String queryMonitorCases(String queryDate,Integer pageIndex,Integer pageSize) {
public static InvocationRecord queryMonitorCases(String queryDate,Integer pageIndex,Integer pageSize) {
//默认测试数据 //默认测试数据
if (queryDate == null) { if (queryDate == null) {
// queryDate="2022-07-06"; // queryDate="2022-07-06";
@ -819,6 +832,7 @@ public class LawResearchUtil {
null, jsonObject,null null, jsonObject,null
,"Cdi9CIzt0AnWucOe" ,"Cdi9CIzt0AnWucOe"
,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv" ,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv"
, "监控信息获取"
); );
} }
/** /**
@ -999,9 +1013,21 @@ public class LawResearchUtil {
} }
private static String getData(String apiUrl, JSONArray array, JSONObject jsonObject, String method,
String key,String ticket
private static InvocationRecord getData(String apiUrl, JSONArray array, JSONObject jsonObject, String method,
String key,String ticket,String apiName
) { ) {
InvocationRecord invocationRecord = new InvocationRecord();
invocationRecord.setApiKey(key);
invocationRecord.setApiTicket(ticket);
invocationRecord.setApiUrl(apiUrl);
if (array!=null){
invocationRecord.setInputArr(array.toJSONString());
}
if (jsonObject!=null){
invocationRecord.setInputObj(jsonObject.toJSONString());
}
invocationRecord.setApiName(apiName);
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
HttpComponentsClientHttpRequestFactory requestFactory HttpComponentsClientHttpRequestFactory requestFactory
= new HttpComponentsClientHttpRequestFactory(); = new HttpComponentsClientHttpRequestFactory();
@ -1030,18 +1056,21 @@ public class LawResearchUtil {
String resultData=null; String resultData=null;
try (PrintWriter writer = new PrintWriter(new File(filePath))) { try (PrintWriter writer = new PrintWriter(new File(filePath))) {
//接收到返回结果需要进行 aes 解密 //接收到返回结果需要进行 aes 解密
invocationRecord.setIsSuccess(0);
resultData = AES.aesDecrypt(result.getBody(), key); resultData = AES.aesDecrypt(result.getBody(), key);
//写入内容 //写入内容
writer.println(resultData); writer.println(resultData);
invocationRecord.setIsSuccess(1);
invocationRecord.setApiResult(resultData);
// 自动关闭因为使用了 try-with-resources 语句 // 自动关闭因为使用了 try-with-resources 语句
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.err.println("文件未找到: " + e.getMessage()); System.err.println("文件未找到: " + e.getMessage());
} }
return resultData;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
return invocationRecord;
} }
return null;
} }
} }

+ 14
- 0
src/main/java/com/fkzy/warn/mapper/InvocationRecordMapper.java View File

@ -0,0 +1,14 @@
package com.fkzy.warn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fkzy.warn.model.InvocationRecord;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangjing
* @date 2024/12/04 14:48
* @description
*/
@Mapper
public interface InvocationRecordMapper extends BaseMapper<InvocationRecord> {
}

+ 12
- 0
src/main/java/com/fkzy/warn/model/Authorization.java View File

@ -51,4 +51,16 @@ public class Authorization extends BaseField{
*/ */
@ApiModelProperty("被授权人") @ApiModelProperty("被授权人")
private Integer userId; private Integer userId;
/**
* 统一社会信用代码
*/
@ApiModelProperty("统一社会信用代码")
private String creditCode;
/**
* 授权状态0临时1待授权
*/
@ApiModelProperty("授权状态0临时1待授权2已授权3授权过期")
private Integer status;
} }

+ 20
- 12
src/main/java/com/fkzy/warn/model/CaseTree.java View File

@ -1,6 +1,7 @@
package com.fkzy.warn.model; package com.fkzy.warn.model;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -16,31 +17,38 @@ import lombok.Data;
@TableName("t_case_tree") @TableName("t_case_tree")
public class CaseTree extends BaseField{ public class CaseTree extends BaseField{
/** /**
* id
* 主键
*/ */
@ApiModelProperty("")
@TableId(type = IdType.AUTO)
private String id;
@ApiModelProperty("ae0920edfe2a79216526fd45eaada6b8")
@TableId(value = "n_ajbs",type = IdType.INPUT)
private String nAjbs;
/** /**
* *
*/ */
@ApiModelProperty("1") @ApiModelProperty("1")
private String stage_type;
/**
*
*/
@ApiModelProperty("ae0920edfe2a79216526fd45eaada6b8")
private String n_ajbs;
@TableField(value = "stage_type")
private String stageType;
/** /**
* *
*/ */
@ApiModelProperty("400") @ApiModelProperty("400")
private String case_type;
@TableField(value = "case_type")
private String caseType;
/** /**
* *
*/ */
@ApiModelProperty("(2018)京73行初3426号") @ApiModelProperty("(2018)京73行初3426号")
private String c_ah;
@TableField(value = "c_ah")
private String cAh;
/**
*后续标识
*/
@ApiModelProperty("后续标识")
@TableField(value = "next_ajbs")
private String nextAjbs;
@TableField(exist = false)
private CaseTree next;
} }

+ 76
- 0
src/main/java/com/fkzy/warn/model/InvocationRecord.java View File

@ -0,0 +1,76 @@
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;
import lombok.Data;
/**
* @author zhangjing
* @date 2026/03/12 14:42
* @description
*/
@Data
@TableName("t_invocation_record")
public class InvocationRecord extends BaseField{
/**
* id
*/
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 接口名称
*/
@ApiModelProperty("接口名称")
@TableField(value = "api_name")
private String apiName;
/**
* 请求路径
*/
@ApiModelProperty("请求路径")
@TableField(value = "api_url")
private String apiUrl;
/**
* 请求key
*/
@ApiModelProperty("请求key")
@TableField(value = "api_key")
private String apiKey;
/**
* 请求ticket
*/
@ApiModelProperty("请求ticket")
@TableField(value = "api_ticket")
private String apiTicket;
/**
* 请求result
*/
@ApiModelProperty("请求result")
@TableField(value = "api_result")
private String apiResult;
/**
* 请求inputArr
*/
@ApiModelProperty("请求inputArr")
@TableField(value = "input_arr")
private String inputArr;
/**
* 请求inputObj
*/
@ApiModelProperty("请求inputObj")
@TableField(value = "input_obj")
private String inputObj;
/**
* 请求0否1是
*/
@ApiModelProperty("请求0否1是")
@TableField(value = "is_success")
private Integer isSuccess;
}

+ 11
- 0
src/main/java/com/fkzy/warn/model/MonitorUsers.java View File

@ -53,4 +53,15 @@ public class MonitorUsers extends BaseField{
@ApiModelProperty("绑定人") @ApiModelProperty("绑定人")
private Integer bindUserId; private Integer bindUserId;
/**
* 是否查询0否1是
*/
@ApiModelProperty("是否查询0否1是")
private Integer isQuery;
/**
* 所在省
*/
@ApiModelProperty("所在省")
private String province;
} }

+ 48
- 0
src/main/java/com/fkzy/warn/service/InvocationRecordService.java View File

@ -0,0 +1,48 @@
package com.fkzy.warn.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fkzy.warn.common.request.RequestParameter;
import com.fkzy.warn.common.response.ApiResponse;
import com.fkzy.warn.model.InvocationRecord;
import com.fkzy.warn.model.User;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
public interface InvocationRecordService extends IService<InvocationRecord> {
/**
* 保存
* @param entity
* @return
*/
ApiResponse saveModel(InvocationRecord entity);
/**
* 修改
* @param entity
* @return
*/
boolean updateModel(InvocationRecord entity);
/**
* 删除
* @param entity
* @return
*/
boolean deleteModel(InvocationRecord entity);
/**
* 分页查询
* @param parameter
* @return
*/
Page<User> queryPage(RequestParameter parameter);
}

+ 7
- 0
src/main/java/com/fkzy/warn/service/LawCaseService.java View File

@ -51,4 +51,11 @@ public interface LawCaseService extends IService {
**/ **/
List<LawCase> threeYearsCases(String creditCode); List<LawCase> threeYearsCases(String creditCode);
/**
* 生成司法统计
* @param jsonObject
* @return
*/
void caseStatistics(JSONObject jsonObject);
} }

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

@ -43,6 +43,11 @@ public interface MonitorUsersService extends IService {
*/ */
Page<MonitorUsers> queryPage(RequestParameter parameter); Page<MonitorUsers> queryPage(RequestParameter parameter);
/**
* 查询监控数据
* @param
* @return
*/
void checkMonitor();
} }

+ 42
- 41
src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java View File

@ -10,11 +10,9 @@ import com.fkzy.warn.common.util.LawResearchUtil;
import com.fkzy.warn.common.util.TimeUtil; import com.fkzy.warn.common.util.TimeUtil;
import com.fkzy.warn.mapper.AlarmCaseMapper; import com.fkzy.warn.mapper.AlarmCaseMapper;
import com.fkzy.warn.model.AlarmCase; import com.fkzy.warn.model.AlarmCase;
import com.fkzy.warn.model.InvocationRecord;
import com.fkzy.warn.model.MonitorUsers; 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 com.fkzy.warn.service.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -37,6 +35,8 @@ public class AlarmCaseServiceImpl extends ServiceImpl
LitigantInfoService litigantInfoService; LitigantInfoService litigantInfoService;
@Resource @Resource
MonitorUsersService monitorUsersService; MonitorUsersService monitorUsersService;
@Resource
InvocationRecordService invocationRecordService;
@Override @Override
@ -45,7 +45,7 @@ public class AlarmCaseServiceImpl extends ServiceImpl
} }
@Override @Override
public void updateModel(AlarmCase entity,String ticket) {
public void updateModel(AlarmCase entity, String ticket) {
this.updateById(entity); this.updateById(entity);
} }
@ -60,42 +60,43 @@ public class AlarmCaseServiceImpl extends ServiceImpl
@Override @Override
public void getAlarmInfo() { 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");
List<MonitorUsers> monitorUsersList = new ArrayList<>();
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());
monitorUsersList.add(monitorUsers);
});
}
this.saveBatch(alarmCaseList);
//如果有预警需要再查司法全量数据有待考虑,先存预警信息
monitorUsersList.forEach(item ->{
String lawResult = LawResearchUtil.querySxx(item.getCompanyName(),item.getCreditCode());
JSONObject object = JSONObject.parseObject(lawResult);
lawCaseService.judicialModelSave(object);
});
}
InvocationRecord result = LawResearchUtil.queryMonitorCases(TimeUtil.formatTimeStr(new Date()), null, null);
invocationRecordService.saveModel(result);
if (result.getApiResult() == null||result.getIsSuccess().equals(0)) {
return;
}
JSONObject jsonObject = new JSONObject().parseObject(result.getApiResult());
if (jsonObject == null) {
return;
}
JSONArray arr = jsonObject.getJSONArray("data");
List<MonitorUsers> monitorUsersList = new ArrayList<>();
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());
monitorUsersList.add(monitorUsers);
});
}
this.saveBatch(alarmCaseList);
//如果有预警需要再查司法全量数据有待考虑,先存预警信息
monitorUsersList.forEach(item -> {
InvocationRecord lawResult = LawResearchUtil.querySxx(item.getCompanyName(), item.getCreditCode());
invocationRecordService.saveModel(result);
JSONObject object = JSONObject.parseObject(lawResult.getApiResult());
lawCaseService.judicialModelSave(object);
});
}
} }

+ 57
- 0
src/main/java/com/fkzy/warn/service/impl/InvocationRecordServiceImpl.java View File

@ -0,0 +1,57 @@
package com.fkzy.warn.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fkzy.warn.common.request.RequestParameter;
import com.fkzy.warn.common.response.ApiResponse;
import com.fkzy.warn.mapper.InvocationRecordMapper;
import com.fkzy.warn.model.InvocationRecord;
import com.fkzy.warn.model.User;
import com.fkzy.warn.service.InvocationRecordService;
import com.fkzy.warn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
@Service
public class InvocationRecordServiceImpl extends ServiceImpl<InvocationRecordMapper, InvocationRecord> implements
InvocationRecordService {
@Autowired
private UserService userService;
@Override
public ApiResponse saveModel(InvocationRecord entity) {
ApiResponse apiResponse = new ApiResponse();
save(entity);
return apiResponse;
}
@Override
public boolean updateModel(InvocationRecord entity) {
boolean result = this.updateById(entity);
return result;
}
@Override
public boolean deleteModel(InvocationRecord entity) {
boolean result = this.removeById(entity);
return result;
}
@Override
public Page<User> queryPage(RequestParameter parameter) {
return userService.queryPage(parameter);
}
}

+ 71
- 14
src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java View File

@ -50,6 +50,8 @@ public class LawCaseServiceImpl extends ServiceImpl impl
private AlarmCaseService alarmCaseService; private AlarmCaseService alarmCaseService;
@Autowired @Autowired
private EnterpriseProvinceService enterpriseProvinceService; private EnterpriseProvinceService enterpriseProvinceService;
@Autowired
private CaseTreeService caseTreeService;
@Override @Override
public void saveModel(LawCase entity, String ticket) { public void saveModel(LawCase entity, String ticket) {
@ -126,6 +128,13 @@ public class LawCaseServiceImpl extends ServiceImpl impl
} }
return caseList; return caseList;
} }
@Override
public void caseStatistics(JSONObject jsonObject) {
String creditCode = jsonObject.getString("creditCode");
setAlarmInfo(creditCode);
}
public List<LawCase> allCase(String creditCode) { public List<LawCase> allCase(String creditCode) {
QueryWrapper<LawCase> query = new QueryWrapper<>(); QueryWrapper<LawCase> query = new QueryWrapper<>();
@ -190,21 +199,19 @@ public class LawCaseServiceImpl extends ServiceImpl impl
@Override @Override
public void judicialModelSave(JSONObject jsonObject) { public void judicialModelSave(JSONObject jsonObject) {
setAlarmInfo("91320301MA20TF8T84");
if (true){
// ReportModel reportModel = createReportData();
// ReportUtil.createReport(reportModel);
String filePath = "丰县城市建设投资集团有限公司-司法.txt";
// String filePath = "工商.txt";
String jsonOutput = convertTextToJson(filePath);
if (jsonOutput == null) {
logger.error("转换失败,JSON 字符串为空");
return; return;
} }
//// 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);
jsonObject = new JSONObject().parseObject(jsonOutput);
// enterpriseInfoService.industryModelSave(jsonObject); // enterpriseInfoService.industryModelSave(jsonObject);
JSONArray arr = jsonObject.getJSONArray("data"); JSONArray arr = jsonObject.getJSONArray("data");
if (arr == null || arr.isEmpty()) { if (arr == null || arr.isEmpty()) {
@ -240,7 +247,22 @@ public class LawCaseServiceImpl extends ServiceImpl impl
// 八类案件 // 八类案件
JSONObject detail = data.getJSONObject("detail"); JSONObject detail = data.getJSONObject("detail");
setCases(detail, companyName, creditCode);
// setCases(detail, companyName, creditCode);
//案件树
JSONObject tree = detail.getJSONObject("cases_tree");
JSONArray civil = tree.getJSONArray("civil");
JSONArray administrative = tree.getJSONArray("administrative");
JSONArray implement = tree.getJSONArray("implement");
JSONArray criminal = tree.getJSONArray("criminal");
List<CaseTree> caseTreeList = new ArrayList<>();
caseTreeList.addAll(civil.toJavaList(CaseTree.class));
caseTreeList.addAll(administrative.toJavaList(CaseTree.class));
caseTreeList.addAll(implement.toJavaList(CaseTree.class));
caseTreeList.addAll(criminal.toJavaList(CaseTree.class));
saveTree(caseTreeList);
// //
// // 限高 // // 限高
// JSONObject xg = data.getJSONObject("xg"); // JSONObject xg = data.getJSONObject("xg");
@ -256,8 +278,43 @@ public class LawCaseServiceImpl extends ServiceImpl impl
// limitationService.saveOrUpdateBatch(limitationList); // limitationService.saveOrUpdateBatch(limitationList);
} }
private void saveTree(List<CaseTree> caseTreeList) {
List<CaseTree> allList = new ArrayList<>();
for (CaseTree caseTree:caseTreeList){
allList.addAll(flattenCaseTree(caseTree));
}
caseTreeService.saveOrUpdateBatch(allList);
}
public List<CaseTree> flattenCaseTree(CaseTree root) {
if (root == null) {
return Collections.emptyList();
}
List<CaseTree> list = new ArrayList<>();
CaseTree current = root;
// 先收集所有节点并断开 next 引用
while (current != null) {
CaseTree next = current.getNext(); // 保存下一个引用
current.setNext(null); // 清除内存引用避免序列化/MyBatis 干扰
list.add(current);
current = next;
}
// 再遍历列表设置 nextAjbs 字段
for (int i = 0; i < list.size(); i++) {
CaseTree node = list.get(i);
if (i < list.size() - 1) {
// 当前节点的 nextAjbs = 下一个节点的 nAjbs
node.setNextAjbs(list.get(i + 1).getNAjbs());
} else {
// 最后一个节点没有后续
node.setNextAjbs(null);
}
}
return list;
}
private void setCases(JSONObject detail, String companyName, String creditCode) { private void setCases(JSONObject detail, String companyName, String creditCode) {
List<Map.Entry<String, JSONArray>> entries = Arrays.asList( List<Map.Entry<String, JSONArray>> entries = Arrays.asList(

+ 100
- 2
src/main/java/com/fkzy/warn/service/impl/MonitorUsersServiceImpl.java View File

@ -1,16 +1,22 @@
package com.fkzy.warn.service.impl; package com.fkzy.warn.service.impl;
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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fkzy.warn.common.constants.EntityConstants; import com.fkzy.warn.common.constants.EntityConstants;
import com.fkzy.warn.common.request.RequestParameter; import com.fkzy.warn.common.request.RequestParameter;
import com.fkzy.warn.common.response.ApiResponse; import com.fkzy.warn.common.response.ApiResponse;
import com.fkzy.warn.common.util.LawResearchUtil;
import com.fkzy.warn.mapper.MonitorUsersMapper; import com.fkzy.warn.mapper.MonitorUsersMapper;
import com.fkzy.warn.model.MonitorUsers;
import com.fkzy.warn.service.MonitorUsersService;
import com.fkzy.warn.model.*;
import com.fkzy.warn.service.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -22,6 +28,16 @@ import java.util.List;
public class MonitorUsersServiceImpl extends ServiceImpl<MonitorUsersMapper, MonitorUsers> implements public class MonitorUsersServiceImpl extends ServiceImpl<MonitorUsersMapper, MonitorUsers> implements
MonitorUsersService { MonitorUsersService {
@Resource
EnterpriseInfoService enterpriseInfoService;
@Resource
LawCaseService lawCaseService;
@Resource
AuthorizationService authorizationService;
@Resource
ReportService reportService;
@Resource
InvocationRecordService invocationRecordService;
@Override @Override
public ApiResponse saveModel(MonitorUsers entity, String ticket) { public ApiResponse saveModel(MonitorUsers entity, String ticket) {
@ -55,4 +71,86 @@ public class MonitorUsersServiceImpl extends ServiceImpl
Page<MonitorUsers> result = this.page(page, eWrapper); Page<MonitorUsers> result = this.page(page, eWrapper);
return result; return result;
} }
@Override
public void checkMonitor() {
List<MonitorUsers> monitorUsersList = list(new LambdaQueryWrapper<MonitorUsers>()
.eq(MonitorUsers::getIsQuery,EntityConstants.NORMAL)
);
if (monitorUsersList.isEmpty()){
return;
}
monitorUsersList.forEach(item ->{
//生成授权-临时
setAuthorization(item);
//查询企业信息 暂无
setEnterpriseInfo(item);
//获取司法信息
setLawCase(item);
//生成告警统计
caseStatistics(item);
//生成首次报告
caseReport(item);
item.setIsQuery(1);
updateById(item);
});
}
private void caseReport(MonitorUsers item) {
Report now = reportService.getOne(new LambdaQueryWrapper<Report>()
.eq(Report::getCreditCode,item.getCreditCode())
.eq(Report::getReportType,"first")
,false
);
if (now!=null){
return;
}
Report report = new Report();
report.setCompanyName(item.getCompanyName());
report.setCreditCode(item.getCreditCode());
report.setReportType("first");
report.setName(item.getCompanyName());
report.setReportTime(new Date());
reportService.save(report);
}
private void setAuthorization(MonitorUsers item) {
Authorization now = authorizationService.getOne(new LambdaQueryWrapper<Authorization>()
.eq(Authorization::getUserId,item.getBindUserId())
.eq(Authorization::getCreditCode,item.getCreditCode())
,false
);
if (now!=null){
return;
}
Authorization authorization = new Authorization();
authorization.setUserId(item.getBindUserId());
authorization.setCreditCode(item.getCreditCode());
authorization.setIsDel(EntityConstants.NORMAL);
authorization.setStatus(EntityConstants.NORMAL);
authorizationService.save(authorization);
}
private void caseStatistics(MonitorUsers item) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("creditCode",item.getCreditCode());
lawCaseService.caseStatistics(jsonObject);
}
private void setLawCase(MonitorUsers item) {
InvocationRecord invocationRecord = LawResearchUtil.querySxx(item.getCompanyName(),item.getCreditCode());
invocationRecordService.saveModel(invocationRecord);
JSONObject object = JSONObject.parseObject(invocationRecord.getApiResult());
lawCaseService.judicialModelSave(object);
}
private void setEnterpriseInfo(MonitorUsers item) {
EnterpriseInfo enterpriseInfo = new EnterpriseInfo();
enterpriseInfo.setENTNAME(item.getCompanyName());
enterpriseInfo.setCREDITCODE(item.getCreditCode());
enterpriseInfo.setFRNAME(item.getLegalPerson());
enterpriseInfo.setREGORGPROVINCE(item.getProvince());
enterpriseInfoService.saveOrUpdate(enterpriseInfo);
}
} }

Loading…
Cancel
Save