Yansen 2 年之前
父節點
當前提交
b6470a0144

+ 2
- 0
src/main/java/com/example/civilizedcity/common/Constants.java 查看文件

@@ -26,6 +26,8 @@ public class Constants {
26 26
     public final static String ATTACH_SOURCE_ISSUE = "issue";
27 27
     // 单位问题单
28 28
     public final static String ATTACH_SOURCE_ORG_ISSUE = "org-issue";
29
+    // 测评答案
30
+    public final static String ATTACH_SOURCE_CHECK_ANSWER = "check-answer";
29 31
 
30 32
     // 督察员上报
31 33
     public final static String ISSUE_SOURCE_INSPECTOR = "inspector";

+ 40
- 25
src/main/java/com/example/civilizedcity/controller/TaCheckAnswerItemController.java 查看文件

@@ -4,8 +4,14 @@ 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;
9
+
8 10
 import java.util.List;
11
+
12
+import com.example.civilizedcity.entity.SysUser;
13
+import com.example.civilizedcity.entity.TaAttach;
14
+import com.example.civilizedcity.service.TaAttachService;
9 15
 import io.swagger.annotations.Api;
10 16
 import io.swagger.annotations.ApiOperation;
11 17
 import io.swagger.annotations.ApiParam;
@@ -14,8 +20,9 @@ import org.springframework.web.bind.annotation.*;
14 20
 import com.example.civilizedcity.entity.TaCheckAnswerItem;
15 21
 import com.example.civilizedcity.service.TaCheckAnswerItemService;
16 22
 
17
- /**
23
+/**
18 24
  * 测评作答详情;(ta_check_answer_item)表控制层
25
+ *
19 26
  * @author : http://njyunzhi.com
20 27
  * @date : 2022-12-13
21 28
  */
@@ -23,12 +30,15 @@ import com.example.civilizedcity.service.TaCheckAnswerItemService;
23 30
 @RestController
24 31
 @RequestMapping("/")
25 32
 public class TaCheckAnswerItemController extends BaseController {
26
-    
33
+
27 34
     @Autowired
28 35
     private TaCheckAnswerItemService taCheckAnswerItemService;
29
-    
30
-    /** 
31
-     * 通过ID查询单条数据 
36
+
37
+    @Autowired
38
+    private TaAttachService taAttachService;
39
+
40
+    /**
41
+     * 通过ID查询单条数据
32 42
      *
33 43
      * @param itemId 主键
34 44
      * @return 实例对象
@@ -38,28 +48,33 @@ public class TaCheckAnswerItemController extends BaseController {
38 48
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
39 49
         return ResponseBean.success(taCheckAnswerItemService.getById(id));
40 50
     }
41
-    
42
-    /** 
51
+
52
+    /**
43 53
      * 分页查询
44 54
      *
45
-     * @param pageNum 当前页码
46
-     * @param pageSize 每页条数
55
+     * @param quId  问题ID
56
+     * @param isMine 我的
47 57
      * @return 查询结果
48 58
      */
49 59
     @ApiOperation("分页查询")
50 60
     @GetMapping("/taCheckAnswerItem")
51
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
53
-        
54
-        IPage<TaCheckAnswerItem> pg = new Page<>(pageNum, pageSize);
55
-        // QueryWrapper<TaCheckAnswerItem> queryWrapper = new QueryWrapper<>();
56
-        // queryWrapper.orderByDesc("create_date");
57
-        IPage<TaCheckAnswerItem> result = taCheckAnswerItemService.page(pg);
58
-        
61
+    public ResponseBean list(@ApiParam("问题ID") @RequestParam(value = "quId") String quId,
62
+                             @ApiParam("我的") @RequestParam(value = "isMine") Boolean isMine) throws Exception {
63
+
64
+        SysUser sysUser = currentUser();
65
+        List<TaCheckAnswerItem> result = taCheckAnswerItemService.getListBy(quId, isMine, sysUser);
66
+
67
+        if (null != result && result.size() > 0) {
68
+            for(TaCheckAnswerItem item : result) {
69
+                List<TaAttach> attachList = taAttachService.getListBy(Constants.ATTACH_SOURCE_CHECK_ANSWER, item.getItemId());
70
+                item.setAttachList(attachList);
71
+            }
72
+        }
73
+
59 74
         return ResponseBean.success(result);
60 75
     }
61
-    
62
-    /** 
76
+
77
+    /**
63 78
      * 新增数据
64 79
      *
65 80
      * @param taCheckAnswerItem 实例对象
@@ -71,8 +86,8 @@ public class TaCheckAnswerItemController extends BaseController {
71 86
         taCheckAnswerItemService.save(taCheckAnswerItem);
72 87
         return ResponseBean.success(taCheckAnswerItem);
73 88
     }
74
-    
75
-    /** 
89
+
90
+    /**
76 91
      * 更新数据
77 92
      *
78 93
      * @param taCheckAnswerItem 实例对象
@@ -81,12 +96,12 @@ public class TaCheckAnswerItemController extends BaseController {
81 96
     @ApiOperation("更新数据")
82 97
     @PutMapping("/taCheckAnswerItem/{id}")
83 98
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaCheckAnswerItem taCheckAnswerItem,
84
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
99
+                             @ApiParam("对象ID") @PathVariable String id) throws Exception {
85 100
         taCheckAnswerItemService.updateById(taCheckAnswerItem);
86 101
         return ResponseBean.success(taCheckAnswerItem);
87 102
     }
88
-    
89
-    /** 
103
+
104
+    /**
90 105
      * 通过主键删除数据
91 106
      *
92 107
      * @param itemId 主键
@@ -94,7 +109,7 @@ public class TaCheckAnswerItemController extends BaseController {
94 109
      */
95 110
     @ApiOperation("通过主键删除数据")
96 111
     @DeleteMapping("/taCheckAnswerItem/{id}")
97
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
112
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
98 113
         taCheckAnswerItemService.removeLogicById(id);
99 114
         return ResponseBean.success("success");
100 115
     }

+ 5
- 4
src/main/java/com/example/civilizedcity/controller/TaCheckController.java 查看文件

@@ -3,10 +3,7 @@ package com.example.civilizedcity.controller;
3 3
 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
-import com.example.civilizedcity.common.BaseController;
7
-import com.example.civilizedcity.common.Constants;
8
-import com.example.civilizedcity.common.ResponseBean;
9
-import com.example.civilizedcity.common.StringUtils;
6
+import com.example.civilizedcity.common.*;
10 7
 import com.example.civilizedcity.service.TaCheckItemService;
11 8
 import io.swagger.annotations.Api;
12 9
 import io.swagger.annotations.ApiOperation;
@@ -57,12 +54,16 @@ public class TaCheckController extends BaseController {
57 54
     public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
58 55
                              @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
59 56
                              @ApiParam("测评名称") @RequestParam(value = "title", required = false) String title,
57
+                             @ApiParam("是否有效") @RequestParam(value = "isValid", required = false) Boolean isValid,
60 58
                              @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
61 59
                              @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate) throws Exception {
62 60
 
61
+        String today = DateUtils.today();
62
+
63 63
         IPage<TaCheck> pg = new Page<>(pageNum, pageSize);
64 64
         QueryWrapper<TaCheck> queryWrapper = new QueryWrapper<>();
65 65
         queryWrapper.like(!StringUtils.isEmpty(title), "title", title);
66
+        queryWrapper.nested(null != isValid && isValid, q -> q.le("start_date", today).and(f -> f.ge("end_date", today)));
66 67
 
67 68
         if (!StringUtils.isEmpty(startDate)) {
68 69
             queryWrapper.le("start_date", endDate);

+ 41
- 18
src/main/java/com/example/civilizedcity/controller/TaCheckItemController.java 查看文件

@@ -6,18 +6,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.example.civilizedcity.common.*;
7 7
 
8 8
 import java.time.LocalDateTime;
9
+import java.util.HashMap;
9 10
 import java.util.List;
10 11
 
11 12
 import com.example.civilizedcity.entity.*;
12
-import com.example.civilizedcity.service.TaCheckAnswerService;
13
-import com.example.civilizedcity.service.TaCheckService;
14
-import com.example.civilizedcity.service.TdLocTypeService;
13
+import com.example.civilizedcity.service.*;
15 14
 import io.swagger.annotations.Api;
16 15
 import io.swagger.annotations.ApiOperation;
17 16
 import io.swagger.annotations.ApiParam;
18 17
 import org.springframework.beans.factory.annotation.Autowired;
19 18
 import org.springframework.web.bind.annotation.*;
20
-import com.example.civilizedcity.service.TaCheckItemService;
21 19
 
22 20
 /**
23 21
  * 测评点位;(ta_check_item)表控制层
@@ -42,6 +40,9 @@ public class TaCheckItemController extends BaseController {
42 40
     @Autowired
43 41
     private TaCheckAnswerService taCheckAnswerService;
44 42
 
43
+    @Autowired
44
+    private TaCheckItemQuService taCheckItemQuService;
45
+
45 46
     /**
46 47
      * 通过ID查询单条数据
47 48
      *
@@ -51,7 +52,12 @@ public class TaCheckItemController extends BaseController {
51 52
     @ApiOperation("通过ID查询单条数据")
52 53
     @GetMapping("/taCheckItem/{id}")
53 54
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
54
-        return ResponseBean.success(taCheckItemService.getById(id));
55
+        TaCheckItem taCheckItem = taCheckItemService.getById(id);
56
+        if (null == taCheckItem || Constants.STATUS_DELETE == taCheckItem.getStatus()) {
57
+            return ResponseBean.error("未找到测评项目");
58
+        }
59
+
60
+        return ResponseBean.success(taCheckItem);
55 61
     }
56 62
 
57 63
     /**
@@ -91,10 +97,12 @@ public class TaCheckItemController extends BaseController {
91 97
     public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
92 98
                              @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
93 99
                              @ApiParam("模拟测评ID") @RequestParam(value = "checkId") String checkId,
94
-                             @ApiParam("项目类型") @RequestParam(value = "itemType") String itemType) throws Exception {
100
+                             @ApiParam("项目类型") @RequestParam(value = "itemType") String itemType,
101
+                             @ApiParam("是否校验") @RequestParam(value = "mustValid", defaultValue = "false") Boolean mustValid) throws Exception {
95 102
 
103
+        SysUser sysUser = currentUser();
96 104
         IPage<TaCheckItem> pg = new Page<>(pageNum, pageSize);
97
-        IPage<TaCheckItem> result = taCheckItemService.getPageBy(pg, checkId, itemType);
105
+        IPage<TaCheckItem> result = taCheckItemService.getPageBy(pg, checkId, itemType, mustValid, sysUser);
98 106
 
99 107
         return ResponseBean.success(result);
100 108
     }
@@ -146,33 +154,48 @@ public class TaCheckItemController extends BaseController {
146 154
     public ResponseBean checkAnswer(@ApiParam("对象ID") @PathVariable String id) throws Exception {
147 155
         TaCheckItem taCheckItem = taCheckItemService.getById(id);
148 156
         if (null == taCheckItem || taCheckItem.getStatus() == Constants.STATUS_DELETE) {
149
-            return ResponseBean.error("未找到有效的答题信息");
157
+            return ResponseBean.success(new HashMap<String, Object>(){{
158
+                put("errorCode", -1);   // 负数代表不能进行任何操作, 包括查看
159
+                put("message", "未找到有效的答题信息");
160
+            }});
150 161
         }
151 162
 
152 163
         TaCheck taCheck = taCheckService.getById(taCheckItem.getCheckId());
153 164
         if (null == taCheck || taCheck.getStatus() == Constants.STATUS_DELETE) {
154
-            return ResponseBean.error("未找到有效的测评信息");
165
+            return ResponseBean.success(new HashMap<String, Object>(){{
166
+                put("errorCode", -2);
167
+                put("message", "未找到有效的测评信息");
168
+            }});
155 169
         }
156 170
 
157 171
         if (LocalDateTime.now().isAfter(DateUtils.day2LocalDateime(taCheck.getEndDate()))) {
158
-            return ResponseBean.error("本次测评已结束");
172
+            return ResponseBean.success(new HashMap<String, Object>(){{
173
+                put("errorCode", 1);    // 正数代表, 只能查看
174
+                put("message", "本次测评已结束");
175
+            }});
159 176
         }
160 177
 
161 178
         SysUser sysUser = currentUser();
162 179
         int count = taCheckAnswerService.getCountByUser(taCheckItem.getItemId(), sysUser.getUserId());
163 180
         if (count > 0) {
164
-            return ResponseBean.error("本次测题您已作答完毕");
181
+            return ResponseBean.success(new HashMap<String, Object>(){{
182
+                put("errorCode", 2);
183
+                put("message", "本次测题您已作答完毕");
184
+            }});
165 185
         }
166 186
 
167
-        if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
168
-            // 如果是实地问卷
169
-            int cnt = taCheckAnswerService.countByItem(taCheckItem.getItemId());
170
-            if (cnt >= taCheckItem.getNum()) {
171
-                return ResponseBean.error("当前实地问卷已收齐, 无须作答");
172
-            }
187
+        int cnt = taCheckAnswerService.countByItem(taCheckItem.getItemId());
188
+        if (cnt >= taCheckItem.getNum()) {
189
+            return ResponseBean.success(new HashMap<String, Object>(){{
190
+                put("errorCode", 3);
191
+                put("message", "当前问卷已收齐, 无须作答");
192
+            }});
173 193
         }
174 194
 
175
-        return ResponseBean.success(null);
195
+        return ResponseBean.success(new HashMap<String, Object>(){{
196
+            put("errorCode", 0);    // 0 代表可以答题
197
+            put("message", null);
198
+        }});
176 199
     }
177 200
 
178 201
     /**

+ 58
- 31
src/main/java/com/example/civilizedcity/entity/TaCheckAnswerItem.java 查看文件

@@ -1,54 +1,81 @@
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;
6 7
 import com.baomidou.mybatisplus.annotation.TableName;
7 8
 import com.baomidou.mybatisplus.annotation.TableId;
9
+
8 10
 import java.io.Serializable;
9 11
 import java.time.LocalDateTime;
12
+import java.util.List;
13
+
10 14
 import lombok.Data;
11 15
 import lombok.EqualsAndHashCode;
12 16
 import lombok.experimental.Accessors;
13 17
 
14
- /**
18
+/**
15 19
  * 测评作答详情;
20
+ *
16 21
  * @author : http://www.chiner.pro
17 22
  * @date : 2022-12-13
18 23
  */
19 24
 @Data
20 25
 @EqualsAndHashCode(callSuper = false)
21 26
 @Accessors(chain = true)
22
-@ApiModel(value = "测评作答详情",description = "")
27
+@ApiModel(value = "测评作答详情", description = "")
23 28
 @TableName("ta_check_answer_item")
24
-public class TaCheckAnswerItem implements Serializable,Cloneable{
25
-     /** 答案ID */
26
-     @ApiModelProperty(name = "答案ID",notes = "")
27
-     @TableId(value = "item_id", type = IdType.ASSIGN_UUID)
28
-     private String itemId ;
29
-     /** 问题ID;来源点位问题 */
30
-     @ApiModelProperty(name = "问题ID",notes = "来源点位问题")
31
-     private String quId ;
32
-     /** 作答ID;来源测评作答 */
33
-     @ApiModelProperty(name = "作答ID",notes = "来源测评作答")
34
-     private String answerId ;
35
-     /** 答案选项 */
36
-     @ApiModelProperty(name = "答案选项",notes = "")
37
-     private String answerCode ;
38
-     /** 答案 */
39
-     @ApiModelProperty(name = "答案",notes = "")
40
-     private String answer ;
41
-     /** 得分 */
42
-     @ApiModelProperty(name = "得分",notes = "")
43
-     private Double score ;
44
-     /** 状态 */
45
-     @ApiModelProperty(name = "状态",notes = "")
46
-     private Integer status ;
47
-     /** 作答人 */
48
-     @ApiModelProperty(name = "作答人",notes = "")
49
-     private String createUser ;
50
-     /** 作答时间 */
51
-     @ApiModelProperty(name = "作答时间",notes = "")
52
-     private LocalDateTime createDate ;
29
+public class TaCheckAnswerItem implements Serializable, Cloneable {
30
+    /**
31
+     * 答案ID
32
+     */
33
+    @ApiModelProperty(name = "答案ID", notes = "")
34
+    @TableId(value = "item_id", type = IdType.ASSIGN_UUID)
35
+    private String itemId;
36
+    /**
37
+     * 问题ID;来源点位问题
38
+     */
39
+    @ApiModelProperty(name = "问题ID", notes = "来源点位问题")
40
+    private String quId;
41
+    /**
42
+     * 作答ID;来源测评作答
43
+     */
44
+    @ApiModelProperty(name = "作答ID", notes = "来源测评作答")
45
+    private String answerId;
46
+    /**
47
+     * 答案选项
48
+     */
49
+    @ApiModelProperty(name = "答案选项", notes = "")
50
+    private String answerCode;
51
+    /**
52
+     * 答案
53
+     */
54
+    @ApiModelProperty(name = "答案", notes = "")
55
+    private String answer;
56
+    /**
57
+     * 得分
58
+     */
59
+    @ApiModelProperty(name = "得分", notes = "")
60
+    private Double score;
61
+    /**
62
+     * 状态
63
+     */
64
+    @ApiModelProperty(name = "状态", notes = "")
65
+    private Integer status;
66
+    /**
67
+     * 作答人
68
+     */
69
+    @ApiModelProperty(name = "作答人", notes = "")
70
+    private String createUser;
71
+    /**
72
+     * 作答时间
73
+     */
74
+    @ApiModelProperty(name = "作答时间", notes = "")
75
+    private LocalDateTime createDate;
76
+
77
+    @TableField(exist = false)
78
+    @ApiModelProperty(name = "图片列表", notes = "")
79
+    List<TaAttach> attachList;
53 80
 
54 81
 }

+ 66
- 37
src/main/java/com/example/civilizedcity/entity/TaCheckItem.java 查看文件

@@ -1,60 +1,89 @@
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;
6 7
 import com.baomidou.mybatisplus.annotation.TableName;
7 8
 import com.baomidou.mybatisplus.annotation.TableId;
9
+
8 10
 import java.io.Serializable;
9 11
 import java.time.LocalDateTime;
12
+
10 13
 import lombok.Data;
11 14
 import lombok.EqualsAndHashCode;
12 15
 import lombok.experimental.Accessors;
13 16
 
14
- /**
17
+/**
15 18
  * 测评点位;
19
+ *
16 20
  * @author : http://www.chiner.pro
17 21
  * @date : 2022-12-13
18 22
  */
19 23
 @Data
20 24
 @EqualsAndHashCode(callSuper = false)
21 25
 @Accessors(chain = true)
22
-@ApiModel(value = "测评点位",description = "")
26
+@ApiModel(value = "测评点位", description = "")
23 27
 @TableName("ta_check_item")
24
-public class TaCheckItem implements Serializable,Cloneable{
25
-       /** 点位ID */
26
-       @ApiModelProperty(name = "点位ID",notes = "")
27
-       @TableId(value = "item_id", type = IdType.ASSIGN_UUID)
28
-       private String itemId ;
29
-       /** 所属测评 */
30
-       @ApiModelProperty(name = "所属测评",notes = "")
31
-       private String checkId ;
32
-       /** 项目类型;loc点位,survey问卷调查 */
33
-       @ApiModelProperty(name = "项目类型",notes = "loc点位,survey问卷调查")
34
-       private String itemType ;
35
-        /** 点位ID */
36
-        @ApiModelProperty(name = "点位ID",notes = "")
37
-        private String typeId ;
38
-       /** 名称 */
39
-       @ApiModelProperty(name = "名称",notes = "")
40
-       private String name ;
41
-       /** 满分 */
42
-       @ApiModelProperty(name = "满分",notes = "")
43
-       private Double fullScore ;
44
-       /** 得分 */
45
-       @ApiModelProperty(name = "得分",notes = "")
46
-       private Double score ;
47
-       /** 数量 */
48
-       @ApiModelProperty(name = "数量",notes = "")
49
-       private Integer num ;
50
-       /** 状态 */
51
-       @ApiModelProperty(name = "状态",notes = "")
52
-       private Integer status ;
53
-       /** 创建人 */
54
-       @ApiModelProperty(name = "创建人",notes = "")
55
-       private String createUser ;
56
-       /** 创建时间 */
57
-       @ApiModelProperty(name = "创建时间",notes = "")
58
-       private LocalDateTime createDate ;
28
+public class TaCheckItem implements Serializable, Cloneable {
29
+    /**
30
+     * 点位ID
31
+     */
32
+    @ApiModelProperty(name = "点位ID", notes = "")
33
+    @TableId(value = "item_id", type = IdType.ASSIGN_UUID)
34
+    private String itemId;
35
+    /**
36
+     * 所属测评
37
+     */
38
+    @ApiModelProperty(name = "所属测评", notes = "")
39
+    private String checkId;
40
+    /**
41
+     * 项目类型;loc点位,survey问卷调查
42
+     */
43
+    @ApiModelProperty(name = "项目类型", notes = "loc点位,survey问卷调查")
44
+    private String itemType;
45
+    /**
46
+     * 点位ID
47
+     */
48
+    @ApiModelProperty(name = "点位ID", notes = "")
49
+    private String typeId;
50
+    /**
51
+     * 名称
52
+     */
53
+    @ApiModelProperty(name = "名称", notes = "")
54
+    private String name;
55
+    /**
56
+     * 满分
57
+     */
58
+    @ApiModelProperty(name = "满分", notes = "")
59
+    private Double fullScore;
60
+    /**
61
+     * 得分
62
+     */
63
+    @ApiModelProperty(name = "得分", notes = "")
64
+    private Double score;
65
+    /**
66
+     * 数量
67
+     */
68
+    @ApiModelProperty(name = "数量", notes = "")
69
+    private Integer num;
70
+    /**
71
+     * 状态
72
+     */
73
+    @ApiModelProperty(name = "状态", notes = "")
74
+    private Integer status;
75
+    /**
76
+     * 创建人
77
+     */
78
+    @ApiModelProperty(name = "创建人", notes = "")
79
+    private String createUser;
80
+    /**
81
+     * 创建时间
82
+     */
83
+    @ApiModelProperty(name = "创建时间", notes = "")
84
+    private LocalDateTime createDate;
59 85
 
86
+    @TableField(exist = false)
87
+    @ApiModelProperty(name = "是否只读, 只读代表不需要答题")
88
+    private Boolean readonly;
60 89
 }

+ 4
- 0
src/main/java/com/example/civilizedcity/mapper/TaCheckAnswerItemMapper.java 查看文件

@@ -19,4 +19,8 @@ public interface TaCheckAnswerItemMapper extends BaseMapper<TaCheckAnswerItem> {
19 19
     List<TaCheckAnswerItem> getListBy(@Param("answerId") String answerId);
20 20
 
21 21
     int getCountByAnswer(@Param("answerId") String answerId);
22
+
23
+    List<TaCheckAnswerItem> getListByQu(@Param("quId") String quId,
24
+                                        @Param("isMine") Boolean isMine,
25
+                                        @Param("userId") String userId);
22 26
 }

+ 6
- 1
src/main/java/com/example/civilizedcity/mapper/TaCheckItemMapper.java 查看文件

@@ -2,6 +2,7 @@ package com.example.civilizedcity.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.example.civilizedcity.entity.SysUser;
5 6
 import org.apache.ibatis.annotations.Mapper;
6 7
 import org.apache.ibatis.annotations.Param;
7 8
 import com.example.civilizedcity.entity.TaCheckItem;
@@ -16,7 +17,11 @@ import java.util.List;
16 17
 @Mapper
17 18
 public interface TaCheckItemMapper  extends BaseMapper<TaCheckItem>{
18 19
 
19
-     IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, @Param("checkId") String checkId, @Param("itemType") String itemType);
20
+     IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg,
21
+                                  @Param("checkId") String checkId,
22
+                                  @Param("itemType") String itemType,
23
+                                  @Param("mustValid") Boolean mustValid,
24
+                                  @Param("userId") String userId);
20 25
 
21 26
      int createNewLocItems(@Param("checkId") String checkId);
22 27
 

+ 7
- 4
src/main/java/com/example/civilizedcity/service/TaCheckAnswerItemService.java 查看文件

@@ -1,13 +1,16 @@
1 1
 package com.example.civilizedcity.service;
2 2
 
3
-import com.baomidou.mybatisplus.extension.service.IService;
3
+import com.example.civilizedcity.entity.SysUser;
4 4
 import com.example.civilizedcity.entity.TaCheckAnswerItem;
5 5
 
6
- /**
6
+import java.util.List;
7
+
8
+/**
7 9
  * 测评作答详情;(ta_check_answer_item)表服务接口
8 10
  * @author : http://njyunzhi.com
9 11
  * @date : 2022-12-13
10 12
  */
11 13
 public interface TaCheckAnswerItemService extends IBaseService<TaCheckAnswerItem> {
12
-    
13
-}
14
+
15
+     List<TaCheckAnswerItem> getListBy(String quId, Boolean isMine, SysUser sysUser);
16
+ }

+ 5
- 1
src/main/java/com/example/civilizedcity/service/TaCheckItemQuService.java 查看文件

@@ -3,7 +3,9 @@ package com.example.civilizedcity.service;
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.example.civilizedcity.entity.TaCheckItemQu;
5 5
 
6
- /**
6
+import java.util.List;
7
+
8
+/**
7 9
  * 点位问题;(ta_check_item_qu)表服务接口
8 10
  * @author : http://njyunzhi.com
9 11
  * @date : 2022-12-13
@@ -11,4 +13,6 @@ import com.example.civilizedcity.entity.TaCheckItemQu;
11 13
 public interface TaCheckItemQuService extends IBaseService<TaCheckItemQu> {
12 14
 
13 15
      int getMaxNoBy(String itemId);
16
+
17
+     List<TaCheckItemQu> getListBy(String itemId);
14 18
  }

+ 2
- 1
src/main/java/com/example/civilizedcity/service/TaCheckItemService.java 查看文件

@@ -1,6 +1,7 @@
1 1
 package com.example.civilizedcity.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.example.civilizedcity.entity.SysUser;
4 5
 import com.example.civilizedcity.entity.TaCheck;
5 6
 import com.example.civilizedcity.entity.TaCheckAnswer;
6 7
 import com.example.civilizedcity.entity.TaCheckItem;
@@ -12,7 +13,7 @@ import com.example.civilizedcity.entity.TaCheckItem;
12 13
  */
13 14
 public interface TaCheckItemService extends IBaseService<TaCheckItem> {
14 15
 
15
-     IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, String checkId, String itemType);
16
+     IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, String checkId, String itemType, Boolean mustValid, SysUser sysUser);
16 17
 
17 18
      void createNewItems(TaCheck taCheck);
18 19
 

+ 11
- 3
src/main/java/com/example/civilizedcity/service/impl/TaCheckAnswerItemServiceImpl.java 查看文件

@@ -1,16 +1,24 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3
-import org.springframework.beans.factory.annotation.Autowired;
3
+import com.example.civilizedcity.entity.SysUser;
4 4
 import org.springframework.stereotype.Service;
5 5
 import com.example.civilizedcity.entity.TaCheckAnswerItem;
6 6
 import com.example.civilizedcity.mapper.TaCheckAnswerItemMapper;
7 7
 import com.example.civilizedcity.service.TaCheckAnswerItemService;
8
- /**
8
+
9
+import java.util.List;
10
+
11
+/**
9 12
  * 测评作答详情;(ta_check_answer_item)表服务实现类
13
+ *
10 14
  * @author : http://www.chiner.pro
11 15
  * @date : 2022-12-13
12 16
  */
13 17
 @Service
14 18
 public class TaCheckAnswerItemServiceImpl extends BaseServiceImpl<TaCheckAnswerItemMapper, TaCheckAnswerItem> implements TaCheckAnswerItemService {
15
-    
19
+
20
+    @Override
21
+    public List<TaCheckAnswerItem> getListBy(String quId, Boolean isMine, SysUser sysUser) {
22
+        return baseMapper.getListByQu(quId, isMine, sysUser.getUserId());
23
+    }
16 24
 }

+ 7
- 0
src/main/java/com/example/civilizedcity/service/impl/TaCheckItemQuServiceImpl.java 查看文件

@@ -7,6 +7,8 @@ import com.example.civilizedcity.entity.TaCheckItemQu;
7 7
 import com.example.civilizedcity.mapper.TaCheckItemQuMapper;
8 8
 import com.example.civilizedcity.service.TaCheckItemQuService;
9 9
 
10
+import java.util.List;
11
+
10 12
 /**
11 13
  * 点位问题;(ta_check_item_qu)表服务实现类
12 14
  *
@@ -26,4 +28,9 @@ public class TaCheckItemQuServiceImpl extends BaseServiceImpl<TaCheckItemQuMappe
26 28
         TaCheckItemQu one = getOne(queryWrapper);
27 29
         return null == one ? 0 : one.getSortNo();
28 30
     }
31
+
32
+    @Override
33
+    public List<TaCheckItemQu> getListBy(String itemId) {
34
+        return baseMapper.getListBy(itemId);
35
+    }
29 36
 }

+ 23
- 2
src/main/java/com/example/civilizedcity/service/impl/TaCheckItemServiceImpl.java 查看文件

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
10 10
 import com.example.civilizedcity.service.TaCheckItemService;
11 11
 import org.springframework.transaction.annotation.Transactional;
12 12
 
13
+import java.time.LocalDateTime;
13 14
 import java.util.List;
14 15
 
15 16
 /**
@@ -33,9 +34,12 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
33 34
     @Autowired
34 35
     TaCheckAnswerMapper taCheckAnswerMapper;
35 36
 
37
+    @Autowired
38
+    TaAttachMapper taAttachMapper;
39
+
36 40
     @Override
37
-    public IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, String checkId, String itemType) {
38
-        return baseMapper.getPageBy(pg, checkId, itemType);
41
+    public IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, String checkId, String itemType, Boolean mustValid, SysUser sysUser) {
42
+        return baseMapper.getPageBy(pg, checkId, itemType, mustValid, sysUser.getUserId());
39 43
     }
40 44
 
41 45
     @Override
@@ -77,6 +81,7 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
77 81
             }
78 82
         }
79 83
 
84
+
80 85
         double[] scores = answerItems(taCheckItem, taCheckAnswer, quList, answerItemList);
81 86
 
82 87
         if (Constants.CHECK_OF_SURVEY.equals(taCheckItem.getItemType())) {
@@ -121,6 +126,7 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
121 126
      */
122 127
     private double[] answerItems(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer, List<TaCheckItemQu> quList, List<TaCheckAnswerItem> answerItemList) throws Exception {
123 128
 
129
+        LocalDateTime now = LocalDateTime.now();
124 130
         double negativeScore = 0.0; // 扣分
125 131
         double positiveScore = 0.0; // 得分
126 132
         for(TaCheckAnswerItem item : answerItemList) {
@@ -154,6 +160,9 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
154 160
             item.setItemId(StringUtils.uuid());
155 161
             item.setAnswerId(taCheckAnswer.getAnswerId());
156 162
             item.setScore(score);
163
+            item.setCreateDate(now);
164
+            item.setCreateUser(taCheckAnswer.getCreateUser());
165
+            item.setStatus(Constants.STATUS_NORMAL);
157 166
             taCheckAnswerItemMapper.insert(item);
158 167
 
159 168
             if (score > 0) {
@@ -161,6 +170,18 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
161 170
             } else {
162 171
                 negativeScore += score;
163 172
             }
173
+
174
+            // 保存附件
175
+            if (null != item.getAttachList()) {
176
+                for (TaAttach taAttach : item.getAttachList()) {
177
+                    taAttach.setOwnerType(Constants.ATTACH_SOURCE_CHECK_ANSWER);
178
+                    taAttach.setOwnerId(item.getItemId());
179
+                    taAttach.setStatus(Constants.STATUS_NORMAL);
180
+                    taAttach.setCreateUser(taCheckAnswer.getCreateUser());
181
+                    taAttach.setCreateDate(now);
182
+                    taAttachMapper.insert(taAttach);
183
+                }
184
+            }
164 185
         }
165 186
 
166 187
         return new double[] {positiveScore, negativeScore};

+ 15
- 0
src/main/resources/mapper/TaCheckAnswerItemMapper.xml 查看文件

@@ -21,4 +21,19 @@
21 21
             t.answer_id = #{answerId}
22 22
           AND t.`status` &gt; -1
23 23
     </select>
24
+    <select id="getListByQu" resultType="com.example.civilizedcity.entity.TaCheckAnswerItem">
25
+        SELECT
26
+            t.*
27
+        FROM
28
+            ta_check_answer_item t
29
+                INNER JOIN ta_check_answer s ON s.answer_id = t.answer_id
30
+        WHERE
31
+            t.qu_id = #{quId}
32
+          <if test="null != isMine and isMine">
33
+              AND s.create_user = #{userId}
34
+          </if>
35
+          AND t.`status` &gt; -1
36
+        ORDER BY
37
+            t.create_date ASC
38
+    </select>
24 39
 </mapper>

+ 21
- 0
src/main/resources/mapper/TaCheckItemMapper.xml 查看文件

@@ -20,12 +20,33 @@
20 20
 
21 21
     <select id="getPageBy" resultType="com.example.civilizedcity.entity.TaCheckItem">
22 22
         SELECT
23
+        <if test="null != mustValid and mustValid">
24
+            now() &lt; c.start_date
25
+            OR now() &gt; c.end_date
26
+            OR m.num &gt; t.num
27
+            OR IFNULL( m.answered, 0 ) &gt; 0 as readonly,
28
+        </if>
23 29
             t.*
24 30
         FROM
25 31
             ta_check_item t
32
+            INNER JOIN ta_check c ON c.check_id = t.check_id
26 33
             <if test="itemType != null and itemType == 'loc'">
27 34
                 INNER JOIN td_loc_type s ON t.type_id = s.type_id
28 35
             </if>
36
+            <if test="null != mustValid and mustValid">
37
+                LEFT JOIN (
38
+                    SELECT
39
+                        a.item_id,
40
+                        COUNT( * ) AS num,
41
+                        SUM( IF ( a.create_user = #{userId}, 1, 0 ) ) AS answered
42
+                    FROM
43
+                        ta_check_answer a
44
+                    WHERE
45
+                        a.check_id = #{checkId}
46
+                    GROUP BY
47
+                        a.item_id
48
+                ) m ON m.item_id = t.item_id
49
+            </if>
29 50
         WHERE
30 51
             t.check_id = #{checkId}
31 52
           AND t.item_type = #{itemType}

+ 1
- 0
src/main/resources/mapper/TaCheckItemQuMapper.xml 查看文件

@@ -18,5 +18,6 @@
18 18
             ta_check_item_qu t
19 19
         WHERE
20 20
             t.item_id = #{itemId}
21
+        ORDER BY t.sort_no ASC
21 22
     </select>
22 23
 </mapper>