郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package com.gkhy.safePlatform.doublePrevention.service.baseService.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.safePlatform.commons.enums.E;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.AusinessException;
import com.gkhy.safePlatform.commons.exception.BusinessException;
import com.gkhy.safePlatform.doublePrevention.entity.PreventRiskControlMeasure;
import com.gkhy.safePlatform.doublePrevention.entity.dto.req.PreventHandReportConfigReqDTO;
import com.gkhy.safePlatform.doublePrevention.repository.PreventRiskControlMeasureRepository;
import com.gkhy.safePlatform.doublePrevention.repository.param.HandlerReportParam;
import com.gkhy.safePlatform.doublePrevention.repository.param.PreventRiskControlMeasureDeleteParams;
import com.gkhy.safePlatform.doublePrevention.repository.param.PreventRiskControlMeasureQueryParams;
import com.gkhy.safePlatform.doublePrevention.repository.param.PreventRiskControlMeasureUpdateParams;
import com.gkhy.safePlatform.doublePrevention.service.baseService.PreventRiskControlMeasureService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service("PreventRiskControlMeasureService")
public class PreventRiskControlMeasureServiceImpl extends ServiceImpl<PreventRiskControlMeasureRepository, PreventRiskControlMeasure> implements PreventRiskControlMeasureService {
 
    @Autowired
    private PreventRiskControlMeasureRepository preventRiskControlMeasureRepository;
 
    /**
     * 管控措施-分页查询
     */
    @Override
    public IPage<PreventRiskControlMeasure> getRiskControlMeasurePage(@Param("page")Page<Object> page, @Param("queryParams")PreventRiskControlMeasureQueryParams queryParams) {
        return preventRiskControlMeasureRepository.getRiskControlMeasurePage(page, queryParams);
        //queryParams.getControlWay(), queryParams.getRiskEventId()
    }
 
    /**
     * 管控措施-根据RiskEventId查询
     */
    @Override
    public List<PreventRiskControlMeasure> getRiskControlMeasureByRiskEventId(Long riskEventId) {
        return preventRiskControlMeasureRepository.getRiskControlMeasureByRiskEventId(riskEventId);
    }
 
    /**
     * 管控措施-新增
     */
    @Override
    public int saveRiskControlMeasure(PreventRiskControlMeasure controlMeasure) {
        int insertResult = preventRiskControlMeasureRepository.insert(controlMeasure);
        if (insertResult == 0 ){
            throw new AusinessException(E.ADD_FAIL, "新增失败");
        }
        return insertResult;
    }
    /**
     * 管控措施-根据措施编码与riskEventId查询
     */
    @Override
    public PreventRiskControlMeasure getRiskControlMeasureByCodeAndEventId(Long riskEventId, String controlMeasureCode) {
        return preventRiskControlMeasureRepository.getRiskControlMeasureByCodeAndEventId(riskEventId, controlMeasureCode);
    }
 
    /**
     * 管控措施-修改
     */
    @Override
    public int updateRiskControlMeasure(PreventRiskControlMeasureUpdateParams updateParams) {
        return preventRiskControlMeasureRepository.updateRiskControlMeasure(updateParams);
    }
    /**
     * 管控措施-根据id查询
     */
    @Override
    public PreventRiskControlMeasure getControlMeasureById(Long id) {
        return preventRiskControlMeasureRepository.selectByMeasureId(id);
    }
 
    /**
     * 管控措施-删除
     */
    @Override
    public int deleteRiskControlMeasure(PreventRiskControlMeasureDeleteParams deleteParams) {
        return preventRiskControlMeasureRepository.deleteRiskControlMeasure(deleteParams);
    }
    /**
     * 任务单元、任务关联修改,设置为空
     * 管控措施-修改管控措施
     */
    @Override
    public void updateControlMeasureByUnitId(Long unitId) {
        int result =  preventRiskControlMeasureRepository.updateControlMeasureByUnitId(unitId);
        if (result < 0){
            throw new AusinessException(E.UPDATE_FAIL, "重置管控措施与单元关联失败");
        }
    }
 
    /**
     * 管控措施-根据measureCode查询
     */
    @Override
    public PreventRiskControlMeasure getControlMeasureByCode(String measureCode) {
        return preventRiskControlMeasureRepository.getControlMeasureByCode(measureCode);
    }
 
    /**
     * 管控措施-根据measureCode
     * 修改关联checkWorkId
     */
    @Override
    public PreventRiskControlMeasure updateWorkIdByMeasureCode(String controlMeasureCode, Long checkWorkId) {
        return preventRiskControlMeasureRepository.updateWorkIdByMeasureCode(controlMeasureCode, checkWorkId);
    }
 
    /**
     * 管控措施-根据WorkId查询
     */
    @Override
    public List<PreventRiskControlMeasure> getControlMeasureByWorkId(Long workId) {
        return preventRiskControlMeasureRepository.getControlMeasureByWorkId(workId);
    }
 
    /**
     * 管控措施-根据单元id查找对应措施id列表
     */
    @Override
    public List<PreventRiskControlMeasure> getlistByUnitId(Long taskUnitId) {
 
        return preventRiskControlMeasureRepository.getListByUnitId(taskUnitId);
    }
    /**
     * 管控措施-根据measureId修改关联的任务taskId
     */
    @Override
    public void updateControlMeasureByMeasureIdAndUnitId(Long measureId, Long taskUnitId) {
        int result = preventRiskControlMeasureRepository.updateControlMeasureByMeasureIdAndUnitId(measureId, taskUnitId);
        if (result == 0) {
            throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR);
        }
    }
    /**
     * 安全风险事件-手工上报-配置
     */
    @Override
    public int updateMeasuresReport(PreventHandReportConfigReqDTO preventHandReportConfigReqDTO) {
        return preventRiskControlMeasureRepository.updateRiskEventReport(preventHandReportConfigReqDTO);
    }
 
    /**
     * 措施-手工上报-配置
     */
    @Override
    public List<PreventRiskControlMeasure> listReportMeasure() {
        return preventRiskControlMeasureRepository.listReportMeasure();
    }
    /**
     * 管控措施- 管控措施列表
     */
    @Override
    public List<PreventRiskControlMeasure> listControlMeasure() {
        return preventRiskControlMeasureRepository.listControlMeasure();
    }
 
    /**
     * 管控措施- 管控措施UUid
     */
    @Override
    public PreventRiskControlMeasure getControlMeasureByUuid(String measureUuid) {
        return preventRiskControlMeasureRepository.getControlMeasureByUuid(measureUuid);
    }
    /**
     * 管控措施- 上报状态更新
     */
    @Override
    public void updateMeasureReportStatus(HandlerReportParam handlerReportParam) {
        int result = preventRiskControlMeasureRepository.updateMeasureReportStatus(handlerReportParam);
        if (result == 0) {
            throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR);
        }
    }
}