From 462d48dd2fbe5612e5a538c273d320cc7176cc60 Mon Sep 17 00:00:00 2001 From: zhangjing <924187658@qq.com> Date: Fri, 13 Mar 2026 15:40:49 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E3=80=90=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E3=80=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fkzy/warn/common/util/DailyTask.java | 15 +-- .../com/fkzy/warn/common/util/LawResearchUtil.java | 59 +++++++++--- .../fkzy/warn/mapper/InvocationRecordMapper.java | 14 +++ .../java/com/fkzy/warn/model/Authorization.java | 12 +++ src/main/java/com/fkzy/warn/model/CaseTree.java | 32 ++++--- .../java/com/fkzy/warn/model/InvocationRecord.java | 76 +++++++++++++++ .../java/com/fkzy/warn/model/MonitorUsers.java | 11 +++ .../fkzy/warn/service/InvocationRecordService.java | 48 ++++++++++ .../java/com/fkzy/warn/service/LawCaseService.java | 7 ++ .../com/fkzy/warn/service/MonitorUsersService.java | 7 +- .../warn/service/impl/AlarmCaseServiceImpl.java | 83 ++++++++--------- .../service/impl/InvocationRecordServiceImpl.java | 57 ++++++++++++ .../fkzy/warn/service/impl/LawCaseServiceImpl.java | 85 ++++++++++++++--- .../warn/service/impl/MonitorUsersServiceImpl.java | 102 ++++++++++++++++++++- 14 files changed, 517 insertions(+), 91 deletions(-) create mode 100644 src/main/java/com/fkzy/warn/mapper/InvocationRecordMapper.java create mode 100644 src/main/java/com/fkzy/warn/model/InvocationRecord.java create mode 100644 src/main/java/com/fkzy/warn/service/InvocationRecordService.java create mode 100644 src/main/java/com/fkzy/warn/service/impl/InvocationRecordServiceImpl.java diff --git a/src/main/java/com/fkzy/warn/common/util/DailyTask.java b/src/main/java/com/fkzy/warn/common/util/DailyTask.java index 5acecc2..71da9a2 100644 --- a/src/main/java/com/fkzy/warn/common/util/DailyTask.java +++ b/src/main/java/com/fkzy/warn/common/util/DailyTask.java @@ -7,6 +7,7 @@ package com.fkzy.warn.common.util; */ import com.fkzy.warn.model.AlarmCase; import com.fkzy.warn.service.AlarmCaseService; +import com.fkzy.warn.service.MonitorUsersService; import com.fkzy.warn.service.ReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -22,6 +23,8 @@ public class DailyTask { ReportService reportService; @Resource AlarmCaseService alarmCaseService; + @Resource + MonitorUsersService monitorUsersService; /** * 在每年的3月、6月、9月、12月的1号凌晨2点执行。 * Cron表达式: 秒 分 时 日 月 周 @@ -44,15 +47,15 @@ public class DailyTask { // 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 * * * ?") // public void executeEveryThreeMinutes() { -// metadataRecordService.uploadRecord(); +// monitorUsersService.checkMonitor(); // System.out.println("【每3分钟执行】当前时间:" + new Date()); // } } diff --git a/src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java b/src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java index e11e391..22c7b0d 100644 --- a/src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java +++ b/src/main/java/com/fkzy/warn/common/util/LawResearchUtil.java @@ -2,11 +2,14 @@ package com.fkzy.warn.common.util; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.fkzy.warn.common.constants.EntityConstants; import com.fkzy.warn.common.constants.LawResearchUrlConstants; +import com.fkzy.warn.model.InvocationRecord; import org.springframework.http.*; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; +import javax.annotation.Resource; import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; @@ -25,6 +28,9 @@ public class LawResearchUtil { // code 3001 请求失败 + + + /** * 司法模型 * @@ -34,7 +40,7 @@ public class LawResearchUtil { * @author zhangjing * @create 2024/9/19 **/ - public String querySssxxg(String name, String creditCode) { + public InvocationRecord querySssxxg(String name, String creditCode) { //默认测试数据 if (name == null) { @@ -54,10 +60,11 @@ public class LawResearchUtil { array, null, null, "AmL92u2kCHjcCwcF", "Pv+mA1v2LRkgsZWqg2mAQDYM1hToAr3JmDZRYQRhZ07tHXJ2wSYEnFTWRp2ly+" + ,null ); } //-------------------------------新接口-------------------- - public static String querySxx(String name, String creditCode) { + public static InvocationRecord querySxx(String name, String creditCode) { //默认测试数据 if (name == null) { @@ -84,11 +91,12 @@ public class LawResearchUtil { return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_SXX, array, null, null, "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(); JSONObject jsonObject = new JSONObject(); @@ -112,11 +120,12 @@ public class LawResearchUtil { return getData(LawResearchUrlConstants.BASE_URL + LawResearchUrlConstants.QUERY_DISHONEST, array, null, null ,"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) { companyName = "恒大集团有限公司"; @@ -131,6 +140,7 @@ public class LawResearchUtil { array, null, null ,"Ju000$LbdkX@tjTK" ,"Pv+mA1v2LRkgsZWqg2mAQONIs4+TPrj8Zi7WRB8+xjBfG5HByVFpyzjoWwn0Wsi6" + , "限高" ); } @@ -728,7 +738,7 @@ public class LawResearchUtil { * @author zhangjing * @create 2024/9/19 **/ - public String addpublic(String name) { + public InvocationRecord addpublic(String name) { //默认测试数据 if (name == null) { name = "平凉市宏建煤炭有限责任公司"; @@ -742,6 +752,7 @@ public class LawResearchUtil { array, null, null ,"Cdi9CIzt0AnWucOe" ,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv" + , "监控名单添加接口" ); } /** @@ -752,7 +763,7 @@ public class LawResearchUtil { * @author zhangjing * @create 2024/9/19 **/ - public String delcompany(String name) { + public InvocationRecord delcompany(String name) { //默认测试数据 if (name == null) { // name = "小米科技有限责任公司"; @@ -767,6 +778,7 @@ public class LawResearchUtil { array, null, null ,"Cdi9CIzt0AnWucOe" ,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv" + , "监控名单删除接口" ); } /** @@ -778,7 +790,7 @@ public class LawResearchUtil { * @author zhangjing * @create 2024/9/19 **/ - public String monitorQuery(Integer pageIndex,Integer pageSize) { + public InvocationRecord monitorQuery(Integer pageIndex,Integer pageSize) { //默认测试数据 if (pageIndex == null) { pageIndex = 1; @@ -791,6 +803,7 @@ public class LawResearchUtil { null, jsonObject, null ,"Cdi9CIzt0AnWucOe" ,"Pv+mA1v2LRkgsZWqg2mAQL/te4UiH52wshn/McsdLfmn+SBZ3LV86JM1jNjZIxqv" + , "监控名单查询接口" ); } /** @@ -803,7 +816,7 @@ public class LawResearchUtil { * @author zhangjing * @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) { // queryDate="2022-07-06"; @@ -819,6 +832,7 @@ public class LawResearchUtil { null, jsonObject,null ,"Cdi9CIzt0AnWucOe" ,"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(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); @@ -1030,18 +1056,21 @@ public class LawResearchUtil { String resultData=null; try (PrintWriter writer = new PrintWriter(new File(filePath))) { //接收到返回结果需要进行 aes 解密 + invocationRecord.setIsSuccess(0); resultData = AES.aesDecrypt(result.getBody(), key); //写入内容 writer.println(resultData); - + invocationRecord.setIsSuccess(1); + invocationRecord.setApiResult(resultData); // 自动关闭,因为使用了 try-with-resources 语句 } catch (FileNotFoundException e) { System.err.println("文件未找到: " + e.getMessage()); } - return resultData; + } catch (Exception e) { e.printStackTrace(); + } finally { + return invocationRecord; } - return null; } } diff --git a/src/main/java/com/fkzy/warn/mapper/InvocationRecordMapper.java b/src/main/java/com/fkzy/warn/mapper/InvocationRecordMapper.java new file mode 100644 index 0000000..c6cf688 --- /dev/null +++ b/src/main/java/com/fkzy/warn/mapper/InvocationRecordMapper.java @@ -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 { +} diff --git a/src/main/java/com/fkzy/warn/model/Authorization.java b/src/main/java/com/fkzy/warn/model/Authorization.java index 3fe79e7..3d8a068 100644 --- a/src/main/java/com/fkzy/warn/model/Authorization.java +++ b/src/main/java/com/fkzy/warn/model/Authorization.java @@ -51,4 +51,16 @@ public class Authorization extends BaseField{ */ @ApiModelProperty("被授权人") private Integer userId; + + /** + * 统一社会信用代码 + */ + @ApiModelProperty("统一社会信用代码") + private String creditCode; + + /** + * 授权状态0临时1待授权 + */ + @ApiModelProperty("授权状态0临时1待授权2已授权3授权过期") + private Integer status; } diff --git a/src/main/java/com/fkzy/warn/model/CaseTree.java b/src/main/java/com/fkzy/warn/model/CaseTree.java index 16fafcf..09bf76e 100644 --- a/src/main/java/com/fkzy/warn/model/CaseTree.java +++ b/src/main/java/com/fkzy/warn/model/CaseTree.java @@ -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; @@ -16,31 +17,38 @@ import lombok.Data; @TableName("t_case_tree") 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") - private String stage_type; - /** - * - */ - @ApiModelProperty("ae0920edfe2a79216526fd45eaada6b8") - private String n_ajbs; + @TableField(value = "stage_type") + private String stageType; + /** * */ @ApiModelProperty("400") - private String case_type; + @TableField(value = "case_type") + private String caseType; /** * */ @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; } diff --git a/src/main/java/com/fkzy/warn/model/InvocationRecord.java b/src/main/java/com/fkzy/warn/model/InvocationRecord.java new file mode 100644 index 0000000..fdb4ebd --- /dev/null +++ b/src/main/java/com/fkzy/warn/model/InvocationRecord.java @@ -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; +} diff --git a/src/main/java/com/fkzy/warn/model/MonitorUsers.java b/src/main/java/com/fkzy/warn/model/MonitorUsers.java index f6b7655..b671c7e 100644 --- a/src/main/java/com/fkzy/warn/model/MonitorUsers.java +++ b/src/main/java/com/fkzy/warn/model/MonitorUsers.java @@ -53,4 +53,15 @@ public class MonitorUsers extends BaseField{ @ApiModelProperty("绑定人") private Integer bindUserId; + /** + * 是否查询0否1是 + */ + @ApiModelProperty("是否查询0否1是") + private Integer isQuery; + + /** + * 所在省 + */ + @ApiModelProperty("所在省") + private String province; } diff --git a/src/main/java/com/fkzy/warn/service/InvocationRecordService.java b/src/main/java/com/fkzy/warn/service/InvocationRecordService.java new file mode 100644 index 0000000..170c41a --- /dev/null +++ b/src/main/java/com/fkzy/warn/service/InvocationRecordService.java @@ -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 { + + /** + * 保存 + * @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 queryPage(RequestParameter parameter); + + + +} diff --git a/src/main/java/com/fkzy/warn/service/LawCaseService.java b/src/main/java/com/fkzy/warn/service/LawCaseService.java index c6fd9d4..cab9757 100644 --- a/src/main/java/com/fkzy/warn/service/LawCaseService.java +++ b/src/main/java/com/fkzy/warn/service/LawCaseService.java @@ -51,4 +51,11 @@ public interface LawCaseService extends IService { **/ List threeYearsCases(String creditCode); + + /** + * 生成司法统计 + * @param jsonObject + * @return + */ + void caseStatistics(JSONObject jsonObject); } diff --git a/src/main/java/com/fkzy/warn/service/MonitorUsersService.java b/src/main/java/com/fkzy/warn/service/MonitorUsersService.java index f155b5f..8c99084 100644 --- a/src/main/java/com/fkzy/warn/service/MonitorUsersService.java +++ b/src/main/java/com/fkzy/warn/service/MonitorUsersService.java @@ -43,6 +43,11 @@ public interface MonitorUsersService extends IService { */ Page queryPage(RequestParameter parameter); - + /** + * 查询监控数据 + * @param + * @return + */ + void checkMonitor(); } diff --git a/src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java b/src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java index 6a0f473..4dfe490 100644 --- a/src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java +++ b/src/main/java/com/fkzy/warn/service/impl/AlarmCaseServiceImpl.java @@ -10,11 +10,9 @@ 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.InvocationRecord; 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 javax.annotation.Resource; @@ -37,6 +35,8 @@ public class AlarmCaseServiceImpl extends ServiceImpl monitorUsersList = new ArrayList<>(); - if (arr!=null&& !arr.isEmpty()){ - List alarmCaseList = arr.toJavaList(AlarmCase.class); - if (alarmCaseList!=null&&!alarmCaseList.isEmpty()){ - alarmCaseList.forEach(item ->{ - MonitorUsers monitorUsers = monitorUsersService.getOne(new LambdaQueryWrapper() - .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 monitorUsersList = new ArrayList<>(); + if (arr != null && !arr.isEmpty()) { + List alarmCaseList = arr.toJavaList(AlarmCase.class); + if (alarmCaseList != null && !alarmCaseList.isEmpty()) { + alarmCaseList.forEach(item -> { + MonitorUsers monitorUsers = monitorUsersService.getOne(new LambdaQueryWrapper() + .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); + }); + + + } } diff --git a/src/main/java/com/fkzy/warn/service/impl/InvocationRecordServiceImpl.java b/src/main/java/com/fkzy/warn/service/impl/InvocationRecordServiceImpl.java new file mode 100644 index 0000000..80a8080 --- /dev/null +++ b/src/main/java/com/fkzy/warn/service/impl/InvocationRecordServiceImpl.java @@ -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 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 queryPage(RequestParameter parameter) { + + return userService.queryPage(parameter); + } + + +} diff --git a/src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java b/src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java index c274013..2f01540 100644 --- a/src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java +++ b/src/main/java/com/fkzy/warn/service/impl/LawCaseServiceImpl.java @@ -50,6 +50,8 @@ public class LawCaseServiceImpl extends ServiceImpl impl private AlarmCaseService alarmCaseService; @Autowired private EnterpriseProvinceService enterpriseProvinceService; + @Autowired + private CaseTreeService caseTreeService; @Override public void saveModel(LawCase entity, String ticket) { @@ -126,6 +128,13 @@ public class LawCaseServiceImpl extends ServiceImpl impl } return caseList; } + + @Override + public void caseStatistics(JSONObject jsonObject) { + String creditCode = jsonObject.getString("creditCode"); + setAlarmInfo(creditCode); + } + public List allCase(String creditCode) { QueryWrapper query = new QueryWrapper<>(); @@ -190,21 +199,19 @@ public class LawCaseServiceImpl extends ServiceImpl impl @Override 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; } - -//// 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); JSONArray arr = jsonObject.getJSONArray("data"); if (arr == null || arr.isEmpty()) { @@ -240,7 +247,22 @@ public class LawCaseServiceImpl extends ServiceImpl impl // 八类案件 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 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"); @@ -256,8 +278,43 @@ public class LawCaseServiceImpl extends ServiceImpl impl // limitationService.saveOrUpdateBatch(limitationList); } + private void saveTree(List caseTreeList) { + List allList = new ArrayList<>(); + for (CaseTree caseTree:caseTreeList){ + allList.addAll(flattenCaseTree(caseTree)); + } + caseTreeService.saveOrUpdateBatch(allList); + } + public List flattenCaseTree(CaseTree root) { + if (root == null) { + return Collections.emptyList(); + } + + List 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) { List> entries = Arrays.asList( diff --git a/src/main/java/com/fkzy/warn/service/impl/MonitorUsersServiceImpl.java b/src/main/java/com/fkzy/warn/service/impl/MonitorUsersServiceImpl.java index cdd831f..3874a7e 100644 --- a/src/main/java/com/fkzy/warn/service/impl/MonitorUsersServiceImpl.java +++ b/src/main/java/com/fkzy/warn/service/impl/MonitorUsersServiceImpl.java @@ -1,16 +1,22 @@ 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.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fkzy.warn.common.constants.EntityConstants; import com.fkzy.warn.common.request.RequestParameter; import com.fkzy.warn.common.response.ApiResponse; +import com.fkzy.warn.common.util.LawResearchUtil; 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 javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -22,6 +28,16 @@ import java.util.List; public class MonitorUsersServiceImpl extends ServiceImpl implements MonitorUsersService { + @Resource + EnterpriseInfoService enterpriseInfoService; + @Resource + LawCaseService lawCaseService; + @Resource + AuthorizationService authorizationService; + @Resource + ReportService reportService; + @Resource + InvocationRecordService invocationRecordService; @Override public ApiResponse saveModel(MonitorUsers entity, String ticket) { @@ -55,4 +71,86 @@ public class MonitorUsersServiceImpl extends ServiceImpl result = this.page(page, eWrapper); return result; } + + @Override + public void checkMonitor() { + List monitorUsersList = list(new LambdaQueryWrapper() + .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() + .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() + .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); + } }