Yansen před 2 roky
rodič
revize
155069d535

+ 2
- 0
src/main/java/com/example/civilizedcity/common/Constants.java Zobrazit soubor

@@ -24,6 +24,8 @@ public class Constants {
24 24
 
25 25
     // 问题单
26 26
     public final static String ATTACH_SOURCE_ISSUE = "issue";
27
+    // 市民上报
28
+    public final static String ATTACH_SOURCE_FEEDBACK = "feedback";
27 29
     // 单位问题单
28 30
     public final static String ATTACH_SOURCE_ORG_ISSUE = "org-issue";
29 31
     // 测评答案

+ 70
- 22
src/main/java/com/example/civilizedcity/controller/TaFeedbackController.java Zobrazit soubor

@@ -4,8 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.example.civilizedcity.common.BaseController;
7
+import com.example.civilizedcity.common.Constants;
7 8
 import com.example.civilizedcity.common.ResponseBean;
8 9
 import java.util.List;
10
+
11
+import com.example.civilizedcity.common.StringUtils;
12
+import com.example.civilizedcity.entity.TaAttach;
13
+import com.example.civilizedcity.entity.TaIssue;
14
+import com.example.civilizedcity.entity.TaPerson;
15
+import com.example.civilizedcity.service.TaAttachService;
9 16
 import io.swagger.annotations.Api;
10 17
 import io.swagger.annotations.ApiOperation;
11 18
 import io.swagger.annotations.ApiParam;
@@ -26,17 +33,23 @@ public class TaFeedbackController extends BaseController {
26 33
     
27 34
     @Autowired
28 35
     private TaFeedbackService taFeedbackService;
36
+
37
+    @Autowired
38
+    private TaAttachService taAttachService;
29 39
     
30 40
     /** 
31 41
      * 通过ID查询单条数据 
32 42
      *
33
-     * @param feedbackId 主键
43
+     * @param id 主键
34 44
      * @return 实例对象
35 45
      */
36 46
     @ApiOperation("通过ID查询单条数据")
37 47
     @GetMapping("/taFeedback/{id}")
38 48
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
39
-        return ResponseBean.success(taFeedbackService.getById(id));
49
+        TaFeedback taFeedback = taFeedbackService.getById(id);
50
+        List<TaAttach> attachList = taAttachService.getListBy(Constants.ATTACH_SOURCE_FEEDBACK, taFeedback.getFeedbackId());
51
+        taFeedback.setAttachList(attachList);
52
+        return ResponseBean.success(taFeedback);
40 53
     }
41 54
     
42 55
     /** 
@@ -49,12 +62,19 @@ public class TaFeedbackController extends BaseController {
49 62
     @ApiOperation("分页查询")
50 63
     @GetMapping("/taFeedback")
51 64
     public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
65
+                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
66
+                             @ApiParam("我的") @RequestParam(value ="isMine", defaultValue = "false") Boolean isMine,
67
+                             @ApiParam("问题单状态") @RequestParam(value = "bizStatus", required = false) String bizStatus) throws Exception {
68
+
69
+        TaPerson taPerson = currentPerson();
70
+        if (null == taPerson && isMine) {
71
+            return ResponseBean.error("请在小程序中操作");
72
+        }
73
+
74
+        String personId = isMine ? taPerson.getPersonId() : null;
53 75
         
54
-        IPage<TaFeedback> pg = new Page<>(pageNum, pageSize);
55
-        // QueryWrapper<TaFeedback> queryWrapper = new QueryWrapper<>();
56
-        // queryWrapper.orderByDesc("create_date");
57
-        IPage<TaFeedback> result = taFeedbackService.page(pg);
76
+        IPage<TaIssue> pg = new Page<>(pageNum, pageSize);
77
+        IPage<TaIssue> result = taFeedbackService.getPageBy(pg, personId, bizStatus);
58 78
         
59 79
         return ResponseBean.success(result);
60 80
     }
@@ -68,23 +88,37 @@ public class TaFeedbackController extends BaseController {
68 88
     @ApiOperation("新增数据")
69 89
     @PostMapping("/taFeedback")
70 90
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaFeedback taFeedback) throws Exception {
71
-        taFeedbackService.save(taFeedback);
91
+
92
+        if (StringUtils.isEmpty(taFeedback.getContent())) {
93
+            return ResponseBean.error("请填写反馈内容");
94
+        }
95
+        if (StringUtils.isEmpty(taFeedback.getAddr())) {
96
+            return ResponseBean.error("请填写具体位置");
97
+        }
98
+
99
+        if (null == taFeedback.getAttachList() || taFeedback.getAttachList().size() == 0) {
100
+            return ResponseBean.error("请上传照片");
101
+        }
102
+
103
+        TaPerson taPerson = currentPerson();
104
+
105
+        taFeedbackService.createNew(taFeedback, taPerson);
72 106
         return ResponseBean.success(taFeedback);
73 107
     }
74 108
     
75
-    /** 
76
-     * 更新数据
77
-     *
78
-     * @param taFeedback 实例对象
79
-     * @return 实例对象
80
-     */
81
-    @ApiOperation("更新数据")
82
-    @PutMapping("/taFeedback/{id}")
83
-    public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaFeedback taFeedback,
84
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
85
-        taFeedbackService.updateById(taFeedback);
86
-        return ResponseBean.success(taFeedback);
87
-    }
109
+//    /**
110
+//     * 更新数据
111
+//     *
112
+//     * @param taFeedback 实例对象
113
+//     * @return 实例对象
114
+//     */
115
+//    @ApiOperation("更新数据")
116
+//    @PutMapping("/taFeedback/{id}")
117
+//    public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaFeedback taFeedback,
118
+//                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
119
+//        taFeedbackService.updateById(taFeedback);
120
+//        return ResponseBean.success(taFeedback);
121
+//    }
88 122
     
89 123
     /** 
90 124
      * 通过主键删除数据
@@ -94,7 +128,21 @@ public class TaFeedbackController extends BaseController {
94 128
      */
95 129
     @ApiOperation("通过主键删除数据")
96 130
     @DeleteMapping("/taFeedback/{id}")
97
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
131
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
132
+        TaPerson taPerson = currentPerson();
133
+        if (null == taPerson) {
134
+            return ResponseBean.error("请在小程序中操作");
135
+        }
136
+
137
+        TaFeedback taFeedback = taFeedbackService.getById(id);
138
+        if (null == taFeedback || taFeedback.getStatus() == Constants.STATUS_DELETE) {
139
+            return ResponseBean.error("未找到相关数据");
140
+        }
141
+
142
+        if (!taPerson.getPersonId().equals(taFeedback.getPersonId())) {
143
+            return ResponseBean.error("暂无权限");
144
+        }
145
+
98 146
         taFeedbackService.removeLogicById(id);
99 147
         return ResponseBean.success("success");
100 148
     }

+ 7
- 0
src/main/java/com/example/civilizedcity/entity/TaFeedback.java Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 package com.example.civilizedcity.entity;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.TableField;
3 4
 import io.swagger.annotations.ApiModel;
4 5
 import io.swagger.annotations.ApiModelProperty;
5 6
 import com.baomidou.mybatisplus.annotation.IdType;
@@ -7,6 +8,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
7 8
 import com.baomidou.mybatisplus.annotation.TableId;
8 9
 import java.io.Serializable;
9 10
 import java.time.LocalDateTime;
11
+import java.util.List;
12
+
10 13
 import lombok.Data;
11 14
 import lombok.EqualsAndHashCode;
12 15
 import lombok.experimental.Accessors;
@@ -66,4 +69,8 @@ public class TaFeedback implements Serializable,Cloneable{
66 69
     @ApiModelProperty(name = "创建时间",notes = "")
67 70
     private LocalDateTime createDate ;
68 71
 
72
+
73
+     @TableField(exist = false)
74
+     @ApiModelProperty(name = "文件列表",notes = "")
75
+     private List<TaAttach> attachList;
69 76
 }

+ 14
- 5
src/main/java/com/example/civilizedcity/mapper/TaFeedbackMapper.java Zobrazit soubor

@@ -1,23 +1,32 @@
1 1
 package com.example.civilizedcity.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.example.civilizedcity.entity.TaIssue;
4 6
 import org.apache.ibatis.annotations.MapKey;
5 7
 import org.apache.ibatis.annotations.Mapper;
6 8
 import org.apache.ibatis.annotations.Param;
7 9
 import com.example.civilizedcity.entity.TaFeedback;
8 10
 
11
+import java.util.List;
9 12
 import java.util.Map;
10 13
 
11 14
 /**
12 15
  * 反馈表;(ta_feedback)表数据库访问层
16
+ *
13 17
  * @author : http://njyunzhi.com
14 18
  * @date : 2023-1-30
15 19
  */
16 20
 @Mapper
17
-public interface TaFeedbackMapper  extends BaseMapper<TaFeedback>{
21
+public interface TaFeedbackMapper extends BaseMapper<TaFeedback> {
18 22
 
19
-     long countByVerifyStatus(@Param("personId") String personId, @Param("verifyStatus") String verifyStatus);
23
+    long countByVerifyStatus(@Param("personId") String personId, @Param("verifyStatus") String verifyStatus);
20 24
 
21
-     @MapKey("id")
22
-     Map<String, Object> statMaIndex(@Param("personId") String personId);
23
- }
25
+    @MapKey("id")
26
+    Map<String, Object> statMaIndex(@Param("personId") String personId);
27
+
28
+    IPage<TaIssue> getPageBy(IPage<TaIssue> pg,
29
+                             @Param("personId") String personId,
30
+                             @Param("processList") List<String> processList,
31
+                             @Param("verifyStatus") String verifyStatus);
32
+}

+ 9
- 2
src/main/java/com/example/civilizedcity/service/TaFeedbackService.java Zobrazit soubor

@@ -1,13 +1,20 @@
1 1
 package com.example.civilizedcity.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.baomidou.mybatisplus.extension.service.IService;
4 5
 import com.example.civilizedcity.entity.TaFeedback;
6
+import com.example.civilizedcity.entity.TaIssue;
7
+import com.example.civilizedcity.entity.TaPerson;
5 8
 
6
- /**
9
+/**
7 10
  * 反馈表;(ta_feedback)表服务接口
11
+ *
8 12
  * @author : http://njyunzhi.com
9 13
  * @date : 2023-1-30
10 14
  */
11 15
 public interface TaFeedbackService extends IBaseService<TaFeedback> {
12
-    
16
+
17
+    void createNew(TaFeedback taFeedback, TaPerson taPerson) throws Exception;
18
+
19
+    IPage<TaIssue> getPageBy(IPage<TaIssue> pg, String personId, String bizStatus);
13 20
 }

+ 119
- 2
src/main/java/com/example/civilizedcity/service/impl/TaFeedbackServiceImpl.java Zobrazit soubor

@@ -1,16 +1,133 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.example.civilizedcity.common.Constants;
5
+import com.example.civilizedcity.common.StringUtils;
6
+import com.example.civilizedcity.entity.TaAttach;
7
+import com.example.civilizedcity.entity.TaIssue;
8
+import com.example.civilizedcity.entity.TaPerson;
9
+import com.example.civilizedcity.mapper.TaAttachMapper;
10
+import com.example.civilizedcity.mapper.TaIssueMapper;
11
+import com.example.civilizedcity.mapper.TaPersonMapper;
3 12
 import org.springframework.beans.factory.annotation.Autowired;
4 13
 import org.springframework.stereotype.Service;
5 14
 import com.example.civilizedcity.entity.TaFeedback;
6 15
 import com.example.civilizedcity.mapper.TaFeedbackMapper;
7 16
 import com.example.civilizedcity.service.TaFeedbackService;
8
- /**
17
+import org.springframework.transaction.annotation.Transactional;
18
+
19
+import java.time.LocalDateTime;
20
+import java.util.ArrayList;
21
+import java.util.List;
22
+
23
+/**
9 24
  * 反馈表;(ta_feedback)表服务实现类
25
+ *
10 26
  * @author : http://www.chiner.pro
11 27
  * @date : 2023-1-30
12 28
  */
13 29
 @Service
14 30
 public class TaFeedbackServiceImpl extends BaseServiceImpl<TaFeedbackMapper, TaFeedback> implements TaFeedbackService {
15
-    
31
+
32
+    @Autowired
33
+    TaPersonMapper taPersonMapper;
34
+
35
+    @Autowired
36
+    TaIssueMapper taIssueMapper;
37
+
38
+    @Autowired
39
+    TaAttachMapper taAttachMapper;
40
+
41
+    @Transactional(rollbackFor = Exception.class)
42
+    @Override
43
+    public void createNew(TaFeedback taFeedback, TaPerson taPerson) throws Exception {
44
+
45
+        // 准备 TaFeedback 数据
46
+        taFeedback.setFeedbackId(StringUtils.uuid());
47
+
48
+        if (StringUtils.isEmpty(taFeedback.getName())) {
49
+            taFeedback.setName(taPerson.getName());
50
+        } else {
51
+            if (StringUtils.isEmpty(taPerson.getName())) {
52
+                taPerson.setName(taFeedback.getName());
53
+                taPersonMapper.updateById(taPerson);
54
+            }
55
+        }
56
+
57
+        if (StringUtils.isEmpty(taFeedback.getPhone())) {
58
+            taFeedback.setPhone(taPerson.getPhone());
59
+        }
60
+
61
+        taFeedback.setPersonId(taPerson.getPersonId());
62
+        taFeedback.setStatus(Constants.STATUS_NORMAL);
63
+        taFeedback.setCreateDate(LocalDateTime.now());
64
+
65
+        // 准备 TaIssue 数据
66
+        TaIssue taIssue = new TaIssue();
67
+        taIssue.setTitle(taFeedback.getTitle());
68
+        taIssue.setLocation(taFeedback.getLocation());
69
+        taIssue.setAddr(taFeedback.getAddr());
70
+        taIssue.setContent(taFeedback.getContent());
71
+
72
+        taIssue.setOrgId(null); // 暂时没有责任单位
73
+        taIssue.setProcessNode(Constants.PROCESS_START);
74
+        taIssue.setProcessStatus(Constants.PROCESS_STATUS_READY);
75
+        taIssue.setProcessNum(1);
76
+        taIssue.setSourceType(Constants.ISSUE_SOURCE_FEEDBACK);
77
+        taIssue.setStatus(Constants.STATUS_NORMAL);
78
+        taIssue.setCreateUser(taFeedback.getPersonId());
79
+        taIssue.setUserName(taFeedback.getName());
80
+        taIssue.setCreateDate(LocalDateTime.now());
81
+        taIssueMapper.insert(taIssue);
82
+        // 保存文件
83
+        List<TaAttach> attachList = taFeedback.getAttachList();
84
+        if (null != attachList && attachList.size() > 0) {
85
+            for (TaAttach item : attachList) {
86
+                item.setAttachId(null);
87
+                item.setOwnerType(Constants.ATTACH_SOURCE_ISSUE);
88
+                item.setOwnerId(taIssue.getIssueId().toString());
89
+                item.setStatus(Constants.STATUS_NORMAL);
90
+                item.setCreateDate(LocalDateTime.now());
91
+                taAttachMapper.insert(item);
92
+            }
93
+        }
94
+
95
+        taFeedback.setIssueId(taIssue.getIssueId().toString());
96
+        save(taFeedback);
97
+        // 保存文件
98
+        if (null != attachList && attachList.size() > 0) {
99
+            for (TaAttach item : attachList) {
100
+                item.setAttachId(null);
101
+                item.setOwnerType(Constants.ATTACH_SOURCE_FEEDBACK);
102
+                item.setOwnerId(taFeedback.getFeedbackId());
103
+                taAttachMapper.insert(item);
104
+            }
105
+        }
106
+
107
+    }
108
+
109
+    @Override
110
+    public IPage<TaIssue> getPageBy(IPage<TaIssue> pg, String personId, String bizStatus) {
111
+
112
+        List<String> processList = new ArrayList<>();
113
+        String verifyStatus = null;
114
+
115
+        // 未处理
116
+        if (Constants.PROCESS_START.equals(bizStatus)) {
117
+            processList.add(Constants.PROCESS_START);
118
+        }
119
+
120
+        // 已处理, 包含处理中以及已完成的
121
+        if (Constants.PROCESS_ASSIGNED.equals(bizStatus)) {
122
+            processList.add(Constants.PROCESS_ASSIGNED);
123
+            processList.add(Constants.PROCESS_END);
124
+        }
125
+
126
+        // 已打回
127
+        if (Constants.APPLY_STATUS_REJECT.equals(bizStatus)) {
128
+            verifyStatus = Constants.APPLY_STATUS_REJECT;
129
+        }
130
+
131
+        return baseMapper.getPageBy(pg, personId, processList, verifyStatus);
132
+    }
16 133
 }

+ 25
- 0
src/main/resources/mapper/TaFeedbackMapper.xml Zobrazit soubor

@@ -27,4 +27,29 @@
27 27
             t.person_id = #{personId}
28 28
           AND t.`status` &gt; -1
29 29
     </select>
30
+    <select id="getPageBy" resultType="com.example.civilizedcity.entity.TaIssue">
31
+        SELECT
32
+            s.*
33
+        FROM
34
+            ta_feedback t
35
+                INNER JOIN ta_issue s ON t.issue_id = s.issue_id
36
+        WHERE
37
+            1 = 1
38
+          <if test="null != personId and personId != ''">
39
+              AND t.person_id = #{personId}
40
+          </if>
41
+          <if test="processList != null">
42
+              AND s.process_node IN
43
+              <foreach item="item" collection="processList" separator="," open="(" close=")">
44
+                  #{item}
45
+              </foreach>
46
+          </if>
47
+        <if test="null != verifyStatus and verifyStatus != ''">
48
+          AND t.verify_status = #{verifyStatus}
49
+        </if>
50
+          AND t.`status` &gt; -1
51
+          AND s.`status` &gt; -1
52
+        ORDER BY
53
+            t.create_date DESC
54
+    </select>
30 55
 </mapper>