From 580e5563dbb1a6f3e6782f57f0e83b1ec170726b Mon Sep 17 00:00:00 2001 From: sjh Date: Mon, 21 Oct 2024 08:56:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=9E=8B1=EF=BC=9A?= =?UTF-8?q?=E6=A1=88=E4=BB=B6=E8=AD=A6=E6=83=85=E7=96=91=E4=BC=BC=E6=9C=AA?= =?UTF-8?q?=E5=8F=8A=E6=97=B6=E5=8F=97=E7=90=86=E6=A1=88=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supervision/service/ModelClueService.java | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/biutag/supervision/service/ModelClueService.java b/src/main/java/com/biutag/supervision/service/ModelClueService.java index f3d5246..8787045 100644 --- a/src/main/java/com/biutag/supervision/service/ModelClueService.java +++ b/src/main/java/com/biutag/supervision/service/ModelClueService.java @@ -13,15 +13,20 @@ import com.biutag.supervision.pojo.entity.*; import com.biutag.supervision.pojo.model.ModelClueModel; import com.biutag.supervision.pojo.param.ModelClueQueryParam; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +@Slf4j @RequiredArgsConstructor @Service public class ModelClueService extends ServiceImpl { @@ -139,7 +144,7 @@ public class ModelClueService extends ServiceImpl { List modelClues = new ArrayList<>(); if (!Objects.isNull(model)) { if (model.getModelSql() != null) { - modelClues.addAll(getModelClueBySql(model.getModelSql())); + modelClues.addAll(getModelClueBySql(model.getModelSql(), modelId)); } } if (!modelClues.isEmpty()) { @@ -159,7 +164,7 @@ public class ModelClueService extends ServiceImpl { } } - public List getModelClueBySql(String sql) { + public List getModelClueBySql(String sql, Integer modelId) { List modelClues = modelClueDataMapper.selectDataByDynamicSql(sql); List uniqueKeys = modelClues.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList(); String newSql = generateNewSql(sql, uniqueKeys); @@ -170,6 +175,17 @@ public class ModelClueService extends ServiceImpl { String keyColumn = (String) data.get(originalFieldName); if (Objects.equals(keyColumn, modelClue.getUniqueKey())) { modelClue.setData(JSONObject.toJSONString(data)); + List modelNos = new ArrayList<>(List.of(1)); + if (modelNos.contains(modelId)) { + String thingDesc = modelClue.getThingDesc(); + modelClue.setThingDesc("该" + data.get("AJBZmc") + + "案件 编号为" + data.get("AJBH") + + ",报案日期为" + getDateString(data.get("BARQ")) + + ",受理日期为" + getDateString(data.get("SLRQ")) + + ",当前案件状态为“" + data.get("AJZTmc") + + "”,已经超过" + "30" + + "日仍未受理。案件详情:" + thingDesc); + } break; } } @@ -177,6 +193,26 @@ public class ModelClueService extends ServiceImpl { return modelClues; } + 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) {} + 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); + } catch (Exception e) { + log.info("日期转换异常", e); + } + } + return " "; + } + public static String generateNewSql(String originalSql, List uniqueKeys) { Pattern tablePattern = Pattern.compile("FROM\\s+(\\w+)", Pattern.CASE_INSENSITIVE); Matcher tableMatcher = tablePattern.matcher(originalSql);