Selaa lähdekoodia

feat: 增加风险管控相关接口

aihua 3 vuotta sitten
vanhempi
commit
008d614dc2

+ 8 - 0
pom.xml

@@ -140,6 +140,14 @@
140 140
             <groupId>org.springframework.cloud</groupId>
141 141
             <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
142 142
         </dependency>
143
+
144
+        <!-- lombok-->
145
+        <dependency>
146
+            <groupId>org.projectlombok</groupId>
147
+            <artifactId>lombok</artifactId>
148
+            <version>1.18.22</version>
149
+            <scope>provided</scope>
150
+        </dependency>
143 151
     </dependencies>
144 152
 
145 153
     <!-- 导入Spring Cloud的依赖管理 -->

+ 143 - 0
src/main/java/com/chinaitop/depot/storage/controller/RiskManagementController.java

@@ -0,0 +1,143 @@
1
+package com.chinaitop.depot.storage.controller;
2
+
3
+import com.alibaba.fastjson.JSONArray;
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.chinaitop.depot.storage.model.RiskManagement;
6
+import com.chinaitop.depot.storage.model.StorageFoodothercheck;
7
+import com.chinaitop.depot.storage.service.RiskManagementService;
8
+import com.chinaitop.depot.unissoft.model.ResponseEntity;
9
+import com.chinaitop.depot.utils.ParameterUtil;
10
+import com.github.pagehelper.PageHelper;
11
+import com.github.pagehelper.PageInfo;
12
+import com.google.common.collect.Maps;
13
+import io.swagger.annotations.Api;
14
+import io.swagger.annotations.ApiImplicitParam;
15
+import io.swagger.annotations.ApiImplicitParams;
16
+import io.swagger.annotations.ApiOperation;
17
+import lombok.RequiredArgsConstructor;
18
+import lombok.extern.slf4j.Slf4j;
19
+import org.apache.commons.lang.StringUtils;
20
+import org.springframework.http.MediaType;
21
+import org.springframework.web.bind.annotation.RequestMapping;
22
+import org.springframework.web.bind.annotation.RequestMethod;
23
+import org.springframework.web.bind.annotation.RestController;
24
+
25
+import javax.servlet.http.HttpServletRequest;
26
+import java.util.HashMap;
27
+import java.util.List;
28
+import java.util.Map;
29
+
30
+/**
31
+ * 风险管控ctrl
32
+ * @author aihua
33
+ * @date 2022-04-17 09:43
34
+ */
35
+@RestController
36
+@RequestMapping("/riskManagement")
37
+@Api(value = "RiskManagementController", description = "风险管控-主页")
38
+@RequiredArgsConstructor
39
+@Slf4j
40
+public class RiskManagementController {
41
+
42
+    private final RiskManagementService riskManagementService;
43
+
44
+    @RequestMapping(value = "/getList",produces = MediaType.APPLICATION_JSON_VALUE,method = RequestMethod.GET)
45
+    @ApiOperation(value="查询风险管控", notes = "查询风险管控信息列表,支持分页")
46
+    @ApiImplicitParams({
47
+            @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
48
+            @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
49
+            @ApiImplicitParam(name = "orgId", value = "组织机构ID", paramType = "query"),
50
+            @ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query"),
51
+            @ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query")
52
+    })
53
+    public ResponseEntity<PageInfo<RiskManagement>> listPage(Integer pageNum, Integer pageSize, Integer orgId, String startDate, String endDate){
54
+        PageInfo<RiskManagement> pageInfo = new PageInfo<>();
55
+        if (orgId == null) {
56
+            return ResponseEntity.failed("组织机构ID不能为空!");
57
+        }
58
+        Map<String, Object> queryMap = Maps.newHashMap();
59
+        queryMap.put("pageNum", (pageNum - 1) * pageSize);
60
+        queryMap.put("pageSize", pageSize);
61
+        queryMap.put("startDate", startDate);
62
+        queryMap.put("endDate", endDate);
63
+        queryMap.put("orgId", orgId);
64
+        List<RiskManagement> riskManagements = riskManagementService.selectListPage(queryMap);
65
+        pageInfo.setList(riskManagements);
66
+        pageInfo.setPages(riskManagements.size());
67
+        pageInfo.setTotal(riskManagementService.getListPageTotal(queryMap));
68
+        return ResponseEntity.ok(pageInfo);
69
+    }
70
+
71
+    @RequestMapping(value = "/saveData", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
72
+    @ApiOperation(value = "保存风险管控", notes = "保存风险管控")
73
+    @ApiImplicitParam(name = "riskJson", value = "JSON数据对象", paramType = "form")
74
+    public ResponseEntity saveData(String riskJson) {
75
+        try {
76
+            log.info(riskJson);
77
+            if (StringUtils.isNotBlank(riskJson)) {
78
+                RiskManagement riskManagement = JSONObject.parseObject(riskJson, RiskManagement.class);
79
+                riskManagementService.saveData(riskManagement);
80
+            }
81
+        } catch (Exception e) {
82
+            e.printStackTrace();
83
+            return ResponseEntity.failed(e.getMessage());
84
+        }
85
+        return ResponseEntity.ok();
86
+    }
87
+
88
+    @RequestMapping(value = "/updateData", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
89
+    @ApiOperation(value = "更新风险管控", notes = "更新风险管控")
90
+    @ApiImplicitParam(name = "riskJson", value = "JSON数据对象", paramType = "form")
91
+    public ResponseEntity updateData(String riskJson) {
92
+        try {
93
+            log.info(riskJson);
94
+            if (StringUtils.isNotBlank(riskJson)) {
95
+                RiskManagement riskManagement = JSONObject.parseObject(riskJson, RiskManagement.class);
96
+                if (riskManagement.getId() == null) {
97
+                    return ResponseEntity.failed("更新数据ID不能为空!");
98
+                }
99
+                riskManagementService.updateDate(riskManagement);
100
+            }
101
+        } catch (Exception e) {
102
+            e.printStackTrace();
103
+            return ResponseEntity.failed(e.getMessage());
104
+        }
105
+        return ResponseEntity.ok();
106
+    }
107
+
108
+    @RequestMapping(value = "/deleteRisk", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
109
+    @ApiOperation(value="根据主键id移除数据信息", notes = "根据主键id移除数据信息")
110
+    @ApiImplicitParams({
111
+            @ApiImplicitParam(name = "id", value = "数据ID", paramType = "form")
112
+    })
113
+    public ResponseEntity deleteRisk(Integer id) {
114
+        try {
115
+            if (id == null) {
116
+                return ResponseEntity.failed("数据ID不能为空!");
117
+            }
118
+            riskManagementService.deleteRisk(id);
119
+        } catch (Exception e) {
120
+            e.printStackTrace();
121
+            return ResponseEntity.failed(e.getMessage());
122
+        }
123
+        return ResponseEntity.ok();
124
+    }
125
+
126
+    @RequestMapping(value = "queryById", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
127
+    @ApiOperation(value = "根据id加载对应数据", notes = "根据id加载对应数据")
128
+    @ApiImplicitParams({
129
+            @ApiImplicitParam(name = "id", value = "id", paramType = "query"),
130
+    })
131
+    public ResponseEntity<RiskManagement> queryById(Integer id) {
132
+        try {
133
+            if (id == null) {
134
+                return ResponseEntity.failed("数据ID不能为空!");
135
+            }
136
+            return ResponseEntity.ok(riskManagementService.queryById(id));
137
+        } catch (Exception e) {
138
+            e.printStackTrace();
139
+            return ResponseEntity.failed(e.getMessage());
140
+        }
141
+
142
+    }
143
+}

+ 56 - 0
src/main/java/com/chinaitop/depot/storage/mapper/RiskManagementMapper.java

@@ -0,0 +1,56 @@
1
+package com.chinaitop.depot.storage.mapper;
2
+
3
+import com.chinaitop.depot.storage.model.RiskManagement;
4
+
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+/**
9
+ * <p>
10
+ *  Mapper 接口
11
+ * </p>
12
+ *
13
+ * @author aihua
14
+ * @since 2022-04-17
15
+ */
16
+public interface RiskManagementMapper{
17
+
18
+    /**
19
+     * 分页查询风险管控list
20
+     * @param queryMap 查询条件
21
+     * @return {@link RiskManagement} list
22
+     */
23
+    List<RiskManagement> selectListPage(Map<String, Object> queryMap);
24
+
25
+    /**
26
+     * 查询分页的总记录数
27
+     * @param queryMap 查询条件
28
+     * @return 总记录数
29
+     */
30
+    long getListPageTotal(Map<String, Object> queryMap);
31
+
32
+    /**
33
+     * 新增风险管控
34
+     * @param riskManagement 风险管控实体
35
+     */
36
+    void insert(RiskManagement riskManagement);
37
+
38
+    /**
39
+     * 更新风险管控
40
+     * @param riskManagement 风险管控实体
41
+     */
42
+    void updateById(RiskManagement riskManagement);
43
+
44
+    /**
45
+     * 根据ID查询风险管控
46
+     * @param id 主键ID
47
+     * @return 风险管控
48
+     */
49
+    RiskManagement selectById(Integer id);
50
+
51
+    /**
52
+     * 删除风险管控
53
+     * @param id 主键ID
54
+     */
55
+    void deleteById(Integer id);
56
+}

+ 137 - 0
src/main/java/com/chinaitop/depot/storage/mapper/RiskManagementMapper.xml

@@ -0,0 +1,137 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.chinaitop.depot.storage.mapper.RiskManagementMapper">
4
+
5
+    <select id="selectListPage" resultType="com.chinaitop.depot.storage.model.RiskManagement">
6
+        select skip #{pageNum} first #{pageSize}
7
+            id,
8
+            library_point_name as libraryPointName,
9
+            identify_person as identifyPerson,
10
+            link_part as linkPart,
11
+            risk_classification as riskClassification,
12
+            risk_type_id as riskTypeId,
13
+            risk_type_name as riskTypeName,
14
+            risk_identification as riskIdentification,
15
+            accident_type as accidentType,
16
+            risk_measures as riskMeasures,
17
+            responsible_dept as responsibleDept,
18
+            responsible_person as responsiblePerson,
19
+            org_id as orgId,
20
+            create_time as createTime
21
+        from
22
+            risk_management
23
+        where
24
+            org_id = #{orgId}
25
+        <if test="starDate != null and endDate != null" >
26
+            and create_time BETWEEN #{starDate} AND #{endDate}
27
+        </if>
28
+        <if test="starDate != null and endDate != null" >
29
+            and create_time &lt;= #{endDate}
30
+        </if>
31
+    </select>
32
+
33
+    <select id="getListPageTotal" resultType="long">
34
+        select count(1)
35
+        from
36
+        risk_management
37
+        where
38
+        org_id = #{orgId}
39
+        <if test="starDate != null and endDate != null" >
40
+            and create_time BETWEEN #{starDate} AND #{endDate}
41
+        </if>
42
+        <if test="starDate != null and endDate != null" >
43
+            and create_time &lt;= #{endDate}
44
+        </if>
45
+    </select>
46
+
47
+    <insert id="insert">
48
+        INSERT INTO risk_management
49
+        (id,library_point_name, identify_person, link_part, risk_classification, risk_type_id, risk_type_name, risk_identification,
50
+         accident_type, risk_measures, responsible_dept, responsible_person, org_id, create_time)
51
+        VALUES (SEQ_STORAGE_DEVICEKEEP.nextVal,
52
+                #{libraryPointName,jdbcType=VARCHAR},
53
+                #{identifyPerson,jdbcType=VARCHAR},
54
+                #{linkPart,jdbcType=VARCHAR},
55
+                #{riskClassification,jdbcType=VARCHAR},
56
+                #{riskTypeId,jdbcType=INTEGER},
57
+                #{riskTypeName,jdbcType=VARCHAR},
58
+                #{riskIdentification,jdbcType=VARCHAR},
59
+                #{accidentType,jdbcType=VARCHAR},
60
+                #{riskMeasures,jdbcType=VARCHAR},
61
+                #{responsibleDept,jdbcType=VARCHAR},
62
+                #{responsiblePerson,jdbcType=VARCHAR},
63
+                #{orgId,jdbcType=INTEGER},
64
+                #{createTime,jdbcType=VARCHAR})
65
+
66
+    </insert>
67
+
68
+    <update id="updateById">
69
+        UPDATE risk_management
70
+        <set>
71
+            <if test="libraryPointName != null">
72
+                library_point_name = #{libraryPointName,jdbcType=VARCHAR},
73
+            </if>
74
+            <if test="identifyPerson != null">
75
+                identify_person = #{identifyPerson,jdbcType=VARCHAR},
76
+            </if>
77
+            <if test="linkPart != null">
78
+                link_part = #{linkPart,jdbcType=VARCHAR},
79
+            </if>
80
+            <if test="riskClassification != null">
81
+                risk_classification = #{riskClassification,jdbcType=VARCHAR},
82
+            </if>
83
+            <if test="riskTypeId != null">
84
+                risk_type_id = #{riskTypeId,jdbcType=INTEGER},
85
+            </if>
86
+            <if test="riskTypeName != null">
87
+                risk_type_name = #{riskTypeName,jdbcType=VARCHAR},
88
+            </if>
89
+            <if test="riskIdentification != null">
90
+                risk_identification = #{riskIdentification,jdbcType=VARCHAR},
91
+            </if>
92
+            <if test="accidentType != null">
93
+                accident_type = #{accidentType,jdbcType=VARCHAR},
94
+            </if>
95
+            <if test="riskMeasures != null">
96
+                risk_measures = #{riskMeasures,jdbcType=VARCHAR},
97
+            </if>
98
+            <if test="responsibleDept != null">
99
+                responsible_dept = #{responsibleDept,jdbcType=VARCHAR},
100
+            </if>
101
+            <if test="responsiblePerson != null">
102
+                responsible_person = #{responsiblePerson,jdbcType=VARCHAR},
103
+            </if>
104
+            <if test="modifyTime != null">
105
+                modify_time = #{modifyTime,jdbcType=VARCHAR},
106
+            </if>
107
+        </set>
108
+        where id = #{id,jdbcType=INTEGER}
109
+    </update>
110
+
111
+    <select id="selectById" resultType="com.chinaitop.depot.storage.model.RiskManagement">
112
+        select
113
+            id,
114
+            library_point_name as libraryPointName,
115
+            identify_person as identifyPerson,
116
+            link_part as linkPart,
117
+            risk_classification as riskClassification,
118
+            risk_type_id as riskTypeId,
119
+            risk_type_name as riskTypeName,
120
+            risk_identification as riskIdentification,
121
+            accident_type as accidentType,
122
+            risk_measures as riskMeasures,
123
+            responsible_dept as responsibleDept,
124
+            responsible_person as responsiblePerson,
125
+            org_id as orgId,
126
+            create_time as createTime,
127
+            modify_time as modifyTime
128
+        from
129
+            risk_management
130
+        where id = #{id,jdbcType=INTEGER}
131
+    </select>
132
+
133
+    <delete id="deleteById">
134
+        delete from risk_management where id = #{id,jdbcType=INTEGER}
135
+    </delete>
136
+</mapper>
137
+

+ 91 - 0
src/main/java/com/chinaitop/depot/storage/model/RiskManagement.java

@@ -0,0 +1,91 @@
1
+package com.chinaitop.depot.storage.model;
2
+
3
+import lombok.Data;
4
+import lombok.experimental.Accessors;
5
+
6
+import java.util.Date;
7
+
8
+/**
9
+ * <p>
10
+ * 风险管控model
11
+ * </p>
12
+ *
13
+ * @author jobob
14
+ * @since 2022-04-17
15
+ */
16
+@Data
17
+@Accessors(chain = true)
18
+public class RiskManagement {
19
+
20
+    private Integer id;
21
+
22
+    /**
23
+     * 库点名称
24
+     */
25
+    private String libraryPointName;
26
+
27
+    /**
28
+     * 识别人
29
+     */
30
+    private String identifyPerson;
31
+
32
+    /**
33
+     * 环节/部位
34
+     */
35
+    private String linkPart;
36
+
37
+    /**
38
+     * 风险分级
39
+     */
40
+    private String riskClassification;
41
+
42
+    /**
43
+     * 风险类型ID
44
+     */
45
+    private Integer riskTypeId;
46
+
47
+    /**
48
+     * 风险类型名称
49
+     */
50
+    private String riskTypeName;
51
+
52
+    /**
53
+     * 风险辨识
54
+     */
55
+    private String riskIdentification;
56
+
57
+    /**
58
+     * 可能导致事故类型
59
+     */
60
+    private String accidentType;
61
+
62
+    /**
63
+     * 风险管控措施
64
+     */
65
+    private String riskMeasures;
66
+
67
+    /**
68
+     * 责任部门
69
+     */
70
+    private String responsibleDept;
71
+
72
+    /**
73
+     * 责任人
74
+     */
75
+    private String responsiblePerson;
76
+
77
+    /**
78
+     * 组织机构ID
79
+     */
80
+    private Integer orgId;
81
+
82
+    /**
83
+     * 创建时间
84
+     */
85
+    private String createTime;
86
+
87
+    /**
88
+     * 修改时间
89
+     */
90
+    private String modifyTime;
91
+}

+ 51 - 0
src/main/java/com/chinaitop/depot/storage/service/RiskManagementService.java

@@ -0,0 +1,51 @@
1
+package com.chinaitop.depot.storage.service;
2
+
3
+import com.chinaitop.depot.storage.model.RiskManagement;
4
+
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+/**
9
+ * 风险管控
10
+ * @author aihua
11
+ */
12
+public interface RiskManagementService {
13
+    /**
14
+     * 分页查询风险管控list
15
+     * @param queryMap 查询条件
16
+     * @return {@link RiskManagement} list
17
+     */
18
+    List<RiskManagement> selectListPage(Map<String, Object> queryMap);
19
+
20
+    /**
21
+     * 查询分页的总记录数
22
+     * @param queryMap 查询条件
23
+     * @return 总记录数
24
+     */
25
+    long getListPageTotal(Map<String, Object> queryMap);
26
+
27
+    /**
28
+     * 新增风险管控
29
+     * @param riskManagement 风险管控实体
30
+     */
31
+    void saveData(RiskManagement riskManagement);
32
+
33
+    /**
34
+     * 更新风险管控
35
+     * @param riskManagement 风险管控实体
36
+     */
37
+    void updateDate(RiskManagement riskManagement);
38
+
39
+    /**
40
+     * 根据ID查询风险管控
41
+     * @param id 主键ID
42
+     * @return 风险管控
43
+     */
44
+    RiskManagement queryById(Integer id);
45
+
46
+    /**
47
+     * 删除风险管控
48
+     * @param id 主键ID
49
+     */
50
+    void deleteRisk(Integer id);
51
+}

+ 84 - 0
src/main/java/com/chinaitop/depot/storage/service/impl/RiskManagementServiceImpl.java

@@ -0,0 +1,84 @@
1
+package com.chinaitop.depot.storage.service.impl;
2
+
3
+import com.chinaitop.depot.storage.mapper.RiskManagementMapper;
4
+import com.chinaitop.depot.storage.model.RiskManagement;
5
+import com.chinaitop.depot.storage.service.RiskManagementService;
6
+import com.chinaitop.depot.utils.DateUtil;
7
+import lombok.RequiredArgsConstructor;
8
+import lombok.extern.slf4j.Slf4j;
9
+import org.springframework.stereotype.Service;
10
+
11
+import java.util.List;
12
+import java.util.Map;
13
+
14
+/**
15
+ * 风险管控实现类
16
+ * @author aihua
17
+ * @date 2022-04-17 09:48
18
+ */
19
+@Service
20
+@RequiredArgsConstructor
21
+@Slf4j
22
+public class RiskManagementServiceImpl implements RiskManagementService {
23
+
24
+    private final RiskManagementMapper riskManagementMapper;
25
+
26
+    /**
27
+     * 分页查询风险管控list
28
+     * @param queryMap 查询条件
29
+     * @return {@link RiskManagement} list
30
+     */
31
+    @Override
32
+    public List<RiskManagement> selectListPage(Map<String, Object> queryMap) {
33
+        return riskManagementMapper.selectListPage(queryMap);
34
+    }
35
+
36
+    /**
37
+     * 查询分页的总记录数
38
+     * @param queryMap 查询条件
39
+     * @return 总记录数
40
+     */
41
+    @Override
42
+    public long getListPageTotal(Map<String, Object> queryMap) {
43
+        return riskManagementMapper.getListPageTotal(queryMap);
44
+    }
45
+
46
+    /**
47
+     * 新增风险管控
48
+     * @param riskManagement 风险管控实体
49
+     */
50
+    @Override
51
+    public void saveData(RiskManagement riskManagement) {
52
+        riskManagement.setCreateTime(DateUtil.getNow());
53
+        riskManagementMapper.insert(riskManagement);
54
+    }
55
+
56
+    /**
57
+     * 更新风险管控
58
+     * @param riskManagement 风险管控实体
59
+     */
60
+    @Override
61
+    public void updateDate(RiskManagement riskManagement) {
62
+        riskManagement.setModifyTime(DateUtil.getNow());
63
+        riskManagementMapper.updateById(riskManagement);
64
+    }
65
+
66
+    /**
67
+     * 根据ID查询风险管控
68
+     * @param id 主键ID
69
+     * @return 风险管控
70
+     */
71
+    @Override
72
+    public RiskManagement queryById(Integer id) {
73
+        return riskManagementMapper.selectById(id);
74
+    }
75
+
76
+    /**
77
+     * 删除风险管控
78
+     * @param id 主键ID
79
+     */
80
+    @Override
81
+    public void deleteRisk(Integer id) {
82
+        riskManagementMapper.deleteById(id);
83
+    }
84
+}

+ 18 - 0
src/main/java/com/chinaitop/depot/utils/DateUtil.java

@@ -0,0 +1,18 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import java.text.SimpleDateFormat;
4
+import java.util.Date;
5
+
6
+/**
7
+ * @author aihua
8
+ * @date 2022-04-16 14:10
9
+ */
10
+public class DateUtil {
11
+
12
+    public static final String FORMAT = "yyyy-MM-dd HH:mm:ss";
13
+
14
+    public static String getNow() {
15
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT);
16
+        return simpleDateFormat.format(new Date());
17
+    }
18
+}