From 65313ad07832ce976ae4ef524c25a571d2fd5292 Mon Sep 17 00:00:00 2001 From: sjh Date: Wed, 23 Oct 2024 18:02:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=A8=A1=E5=9E=8B2=EF=BC=9A?= =?UTF-8?q?=E8=A1=8C=E6=94=BF=E3=80=81=E5=88=91=E4=BA=8B=E6=A1=88=E4=BB=B6?= =?UTF-8?q?=E5=8F=97=E7=AB=8B=E6=A1=88=E4=B8=8D=E5=8F=8A=E6=97=B6=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E7=9B=91=E7=9D=A3=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BusinessDepartService.java | 7 +- .../supervision/service/ModelClueService.java | 110 +++++++++++++++--- 2 files changed, 100 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java index 37bd829..281048d 100644 --- a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java +++ b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java @@ -60,11 +60,16 @@ public class BusinessDepartService extends ServiceImpl { } public List getModelClueBySql(String sql, Integer modelId) { - List oldUniqueKeys = this.listObjs(new LambdaQueryWrapper().select(ModelClue::getUniqueKey).eq(ModelClue::getStatus, 0), String::valueOf); - List modelClues = modelClueDataMapper.selectDataByDynamicSql(sql); + List modelClues = new ArrayList<>(); + if (modelId == 2) { // 2号模型:行政、刑事案件受立案不及时问题监督模型 + return getModelCluesForModel2(modelClues); + } else { + modelClues = modelClueDataMapper.selectDataByDynamicSql(sql); + } List uniqueKeys = modelClues.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList(); + List oldUniqueKeys = this.listObjs(new LambdaQueryWrapper().select(ModelClue::getUniqueKey).eq(ModelClue::getStatus, 0), String::valueOf); List changeStatusIds = oldUniqueKeys.stream().filter(item -> !uniqueKeys.contains(item)).toList(); if (!changeStatusIds.isEmpty()) { modelClueMapper.update(null, new LambdaUpdateWrapper().in(ModelClue::getUniqueKey, changeStatusIds).set(ModelClue::getStatus, 1)); @@ -204,11 +211,11 @@ public class ModelClueService extends ServiceImpl { if (Objects.equals(keyColumn, modelClue.getUniqueKey())) { modelClue.setData(JSONObject.toJSONString(data)); modelClue.setStatus(0); - List modelNos = new ArrayList<>(List.of(1)); + List modelNos = new ArrayList<>(List.of(1)); // 1号模型:行政、刑事案件受理30天仍未立案问题监督模型 if (modelNos.contains(modelId)) { String thingDesc = modelClue.getThingDesc(); modelClue.setThingDesc("该" + data.get("AJBZmc") - + "案件 编号为" + data.get("AJBH") + + "案件编号为" + data.get("AJBH") + ",报案日期为" + getDateString(data.get("BARQ")) + ",受理日期为" + getDateString(data.get("SLRQ")) + ",当前案件状态为“" + data.get("AJZTmc") @@ -222,21 +229,92 @@ public class ModelClueService extends ServiceImpl { return needsInsertModelClues; } + private List getModelCluesForModel2(List modelClues) { + List modelClues1 = new ArrayList<>(); + String preSql = "SELECT a.jjdbh AS uniqueKey, a.jjdbh AS negative_id, a.gxdwmc AS involve_depart_name, a.gxdwdm AS involve_depart_id FROM dwd_asj_zhtx_jjd a WHERE a.jqxzdm NOT LIKE '11%' AND a.jqxzdm NOT LIKE '99%' AND a.bjnr LIKE '%"; + String postSql = "%' AND NOT EXISTS (SELECT 1 FROM dwd_asj_sjjhygx_jjcjxxb b WHERE b.BARLXDH = a.bjdh) AND a.cjsj BETWEEN '2024-01-01 00:00:00' AND '2024-10-23 00:00:00';"; + genarateModelCluesForModel2(preSql, postSql, modelClues1); + List uniqueKeys = modelClues1.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList(); + if (!uniqueKeys.isEmpty()) { + String newSql = "SELECT a.* FROM dwd_asj_zhtx_jjd a LEFT JOIN dwd_asj_sjjhygx_jjcjxxb b ON b.BARLXDH = a.bjdh WHERE a.jjdbh IN " + "(" + uniqueKeys.stream().map(k -> "'" + k + "'").collect(Collectors.joining(",")) + ");"; + List> allData = modelClueDataMapper.selectByUniqueKeys(newSql); + for (ModelClue modelClue : modelClues1) { + for (Map data : allData) { + String keyColumn = (String) data.get("jjdbh"); + if (Objects.equals(keyColumn, modelClue.getUniqueKey())) { + modelClue.setData(JSONObject.toJSONString(data)); + modelClue.setStatus(0); + modelClue.setThingDesc("该" + data.get("jqxzmc") + + "案件 接警单编号为" + data.get("jjdbh") + + ",报案时间为" + getDateString(data.get("bjsj")) + + ",没有匹配到立案时间,受立案不及时。"); + break; + } + } + } + modelClues.addAll(modelClues1); + } + List modelClues2 = new ArrayList<>(); + String preSql2 = "SELECT a.jjdbh AS uniqueKey, a.jjdbh AS negative_id, a.gxdwmc AS involve_depart_name, a.gxdwdm AS involve_depart_id FROM dwd_asj_zhtx_jjd a WHERE a.jqxzdm NOT LIKE '11%' AND a.jqxzdm NOT LIKE '99%' AND a.bjnr LIKE '%"; + String postSql2 = "%' AND EXISTS (SELECT 1 FROM dwd_asj_sjjhygx_jjcjxxb b WHERE b.lasj IS NOT NULL AND b.basj < DATE_SUB(STR_TO_DATE(b.lasj, '%Y%m%d%H%i%s') , INTERVAL 7 DAY) AND b.BARLXDH = a.bjdh AND STR_TO_DATE(b.lasj, '%Y%m%d%H%i%s') > a.cjsj) ORDER BY a.cjsj desc LIMIT 1;"; + genarateModelCluesForModel2(preSql2, postSql2, modelClues2); + List uniqueKeys2 = modelClues2.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList(); + if (!uniqueKeys2.isEmpty()) { + String newSql2 = "SELECT a.*, b.ajbh, b.lasj FROM dwd_asj_zhtx_jjd a LEFT JOIN dwd_asj_sjjhygx_jjcjxxb b ON b.BARLXDH = a.bjdh WHERE a.jjdbh IN " + "(" + uniqueKeys2.stream().map(k -> "'" + k + "'").collect(Collectors.joining(",")) + ");"; + List> allData2 = modelClueDataMapper.selectByUniqueKeys(newSql2); + for (ModelClue modelClue : modelClues2) { + for (Map data : allData2) { + String keyColumn = (String) data.get("jjdbh"); + if (Objects.equals(keyColumn, modelClue.getUniqueKey())) { + modelClue.setData(JSONObject.toJSONString(data)); + modelClue.setStatus(0); + modelClue.setThingDesc("该" + data.get("jqxzmc") + + "案件 编号为" + data.get("ajbh") + + ",接警单编号为" + data.get("jjdbh") + + ",报案时间为" + getDateString(data.get("bjsj")) + + ",立案时间为" + data.get("lasj") + + ",立案时间与报案时间超过7天,受立案不及时。"); + break; + } + } + } + modelClues.addAll(modelClues2); + } + return modelClues; + } + + private void genarateModelCluesForModel2(String preSql, String postSql, List modelClues) { + List modelClues1 = modelClueDataMapper.selectDataByDynamicSql(preSql + "盗" + postSql); + List modelClues2 = modelClueDataMapper.selectDataByDynamicSql(preSql + "骗" + postSql); + List modelClues3 = modelClueDataMapper.selectDataByDynamicSql(preSql + "强奸" + postSql); + List modelClues4 = modelClueDataMapper.selectDataByDynamicSql(preSql + "抢" + postSql); + List modelClues5 = modelClueDataMapper.selectDataByDynamicSql(preSql + "10岁" + postSql); + List modelClues6 = modelClueDataMapper.selectDataByDynamicSql(preSql + "11岁" + postSql); + List modelClues7 = modelClueDataMapper.selectDataByDynamicSql(preSql + "12岁" + postSql); + List modelClues8 = modelClueDataMapper.selectDataByDynamicSql(preSql + "13岁" + postSql); + List modelClues9 = modelClueDataMapper.selectDataByDynamicSql(preSql + "14岁" + postSql); + List modelClues10 = modelClueDataMapper.selectDataByDynamicSql(preSql + "15岁" + postSql); + List modelClues11 = modelClueDataMapper.selectDataByDynamicSql(preSql + "16岁" + postSql); + List modelClues12 = modelClueDataMapper.selectDataByDynamicSql(preSql + "未成年" + postSql); + modelClues.addAll(Stream.of(modelClues1, modelClues2, modelClues3, modelClues4, modelClues5, modelClues6, modelClues7, modelClues8, modelClues9, modelClues10, modelClues11, modelClues12) + .flatMap(List::stream) + .collect(Collectors.toMap(ModelClue::getUniqueKey, data -> data, (existing, replacement) -> existing)) + .values()); + } + private static String getDateString(Object param) { if (param != null) { -// try { -// Date date = (Date) param; -// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); -// return formatter.format(date); -// } catch (Exception ignored) {} + String time = null; try { - LocalDateTime localDateTime = (LocalDateTime) param; - ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault()); - Date date = Date.from(zonedDateTime.toInstant()); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - return formatter.format(date); + time = String.valueOf(param); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + Date parse = sdf.parse(time); + Instant instant = parse.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); return formatter.format(localDateTime); } catch (Exception e) { - log.info("日期转换异常", e); + log.info("日期转换异常{}", time, e); } } return " ";