|
|
|
|
@ -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<ModelClueMapper, ModelClue> { |
|
|
|
|
@ -139,7 +144,7 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
|
|
|
|
|
List<ModelClue> 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<ModelClueMapper, ModelClue> {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<ModelClue> getModelClueBySql(String sql) { |
|
|
|
|
public List<ModelClue> getModelClueBySql(String sql, Integer modelId) { |
|
|
|
|
List<ModelClue> modelClues = modelClueDataMapper.selectDataByDynamicSql(sql); |
|
|
|
|
List<String> 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<ModelClueMapper, ModelClue> {
|
|
|
|
|
String keyColumn = (String) data.get(originalFieldName); |
|
|
|
|
if (Objects.equals(keyColumn, modelClue.getUniqueKey())) { |
|
|
|
|
modelClue.setData(JSONObject.toJSONString(data)); |
|
|
|
|
List<Integer> 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<ModelClueMapper, ModelClue> {
|
|
|
|
|
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<String> uniqueKeys) { |
|
|
|
|
Pattern tablePattern = Pattern.compile("FROM\\s+(\\w+)", Pattern.CASE_INSENSITIVE); |
|
|
|
|
Matcher tableMatcher = tablePattern.matcher(originalSql); |
|
|
|
|
|