广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package cn.huge.module.aidata.service;
 
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.IdUtils;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import cn.huge.module.aidata.dao.mapper.AiCaseRiskMapper;
import cn.huge.module.aidata.domain.po.AiCaseRisk;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class AiCaseRiskService extends ServiceImpl<AiCaseRiskMapper, AiCaseRisk> {
 
    @Autowired
    private AiCaseRiskMapper mapper;
 
    @Autowired
    private UtilsClientImpl utilsClient;
 
    public void updateAiCaseRisk(AiCaseRisk entity) {
        try {
            mapper.updateAiCaseRisk(entity);
        } catch (Exception e) {
            log.error("[AiCaseRiskService.updateAiCaseRisk]调用失败", e);
            throw new ServiceException("案件更新失败", e);
        }
    }
 
    public void updateAiCaseRiskTerms(AiCaseRisk entity, Map<String, Object> terms) {
        try {
            mapper.updateAiCaseRiskTerms(entity, terms);
        } catch (Exception e) {
            log.error("[AiCaseRiskService.updateAiCaseRiskTerms]调用失败", e);
            throw new ServiceException("条件更新失败", e);
        }
    }
 
    public void deleteAiCaseRisk(String id) {
        try {
            mapper.deleteAiCaseRisk(id);
        } catch (Exception e) {
            log.error("[AiCaseRiskService.deleteAiCaseRisk]调用失败", e);
            throw new ServiceException("删除案件失败", e);
        }
    }
 
    public List<AiCaseRisk> listTerms(Map<String, Object> terms) {
        return mapper.listTerms(terms);
    }
 
    public long countTerms(Map<String, Object> terms) {
        return mapper.countTerms(terms);
    }
 
    public Page<AiCaseRisk> pageQuery(PageRequest page, Map<String, Object> terms) {
        long total = mapper.countTerms(terms);
        List<AiCaseRisk> content = mapper.pageTerms(page, terms);
        return new PageImpl<>(content, page, total);
    }
 
    public void saveAiCaseRisk(AiCaseRisk aiCaseRisk) {
        try {
            Date now = DateUtils.getNowDate();
            if (IdUtils.checkNewId(aiCaseRisk.getAiCaseRiskId())) {
                aiCaseRisk.setAiCaseRiskId(utilsClient.getNewTimeId());
                aiCaseRisk.setCreateTime(now);
            }
            aiCaseRisk.setUpdateTime(now);
            this.saveOrUpdate(aiCaseRisk);
        } catch (Exception e) {
            log.error("[AiCaseRiskService.saveAiCaseRisk]调用失败", e);
            throw new ServiceException("保存案件失败", e);
        }
    }
 
    /**
     * 根据条件查询案件风险评估
     * @param risk 查询条件
     * @return 符合条件的案件风险评估列表
     */
    public List<AiCaseRisk> findByConditions(AiCaseRisk risk) {
        try {
            return mapper.findByConditions(risk);
        } catch (Exception e) {
            log.error("[AiCaseRiskService.findByConditions]调用失败", e);
            throw new ServiceException("查询案件风险评估失败", e);
        }
    }
}