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);