Your Name 2 лет назад
Родитель
Сommit
e1c9fec408
48 измененных файлов: 10963 добавлений и 388 удалений
  1. 9260
    0
      db/.back_文明创办/文明创办-backup-2023111150516.pdma.json
  2. 104
    7
      db/.back_文明创办/文明创办-backup-202318151439.pdma.json
  3. 70
    2
      db/.back_文明创办/文明创办-backup-202318194130.pdma.json
  4. 90
    1
      db/文明创办.pdma.json
  5. 10
    5
      src/main/java/com/example/civilizedcity/common/Constants.java
  6. 7
    0
      src/main/java/com/example/civilizedcity/common/StringUtils.java
  7. 54
    10
      src/main/java/com/example/civilizedcity/controller/CommController.java
  8. 40
    25
      src/main/java/com/example/civilizedcity/controller/TaCheckAnswerItemController.java
  9. 69
    25
      src/main/java/com/example/civilizedcity/controller/TaCheckController.java
  10. 197
    62
      src/main/java/com/example/civilizedcity/controller/TaCheckItemController.java
  11. 2
    2
      src/main/java/com/example/civilizedcity/controller/TaCheckItemQuController.java
  12. 22
    17
      src/main/java/com/example/civilizedcity/controller/TaIssueController.java
  13. 49
    25
      src/main/java/com/example/civilizedcity/controller/TaNoticeController.java
  14. 16
    16
      src/main/java/com/example/civilizedcity/controller/TdQuAnswerController.java
  15. 72
    40
      src/main/java/com/example/civilizedcity/controller/TdQuestionController.java
  16. 6
    0
      src/main/java/com/example/civilizedcity/entity/TaCheck.java
  17. 7
    0
      src/main/java/com/example/civilizedcity/entity/TaCheckAnswer.java
  18. 58
    37
      src/main/java/com/example/civilizedcity/entity/TaCheckAnswerItem.java
  19. 66
    37
      src/main/java/com/example/civilizedcity/entity/TaCheckItem.java
  20. 2
    0
      src/main/java/com/example/civilizedcity/entity/TaCheckItemAn.java
  21. 3
    0
      src/main/java/com/example/civilizedcity/entity/TaCheckItemQu.java
  22. 1
    1
      src/main/java/com/example/civilizedcity/entity/TaNotice.java
  23. 2
    2
      src/main/java/com/example/civilizedcity/entity/TdQuAnswer.java
  24. 28
    23
      src/main/java/com/example/civilizedcity/entity/TdQuestion.java
  25. 15
    3
      src/main/java/com/example/civilizedcity/mapper/TaCheckAnswerItemMapper.java
  26. 15
    3
      src/main/java/com/example/civilizedcity/mapper/TaCheckAnswerMapper.java
  27. 9
    3
      src/main/java/com/example/civilizedcity/mapper/TaCheckItemAnMapper.java
  28. 14
    3
      src/main/java/com/example/civilizedcity/mapper/TaCheckItemMapper.java
  29. 8
    3
      src/main/java/com/example/civilizedcity/mapper/TaCheckItemQuMapper.java
  30. 8
    3
      src/main/java/com/example/civilizedcity/service/TaCheckAnswerItemService.java
  31. 10
    2
      src/main/java/com/example/civilizedcity/service/TaCheckAnswerService.java
  32. 5
    1
      src/main/java/com/example/civilizedcity/service/TaCheckItemQuService.java
  33. 11
    3
      src/main/java/com/example/civilizedcity/service/TaCheckItemService.java
  34. 3
    2
      src/main/java/com/example/civilizedcity/service/TaCheckService.java
  35. 8
    2
      src/main/java/com/example/civilizedcity/service/TdQuAnswerService.java
  36. 16
    3
      src/main/java/com/example/civilizedcity/service/impl/TaCheckAnswerItemServiceImpl.java
  37. 20
    2
      src/main/java/com/example/civilizedcity/service/impl/TaCheckAnswerServiceImpl.java
  38. 7
    0
      src/main/java/com/example/civilizedcity/service/impl/TaCheckItemQuServiceImpl.java
  39. 181
    4
      src/main/java/com/example/civilizedcity/service/impl/TaCheckItemServiceImpl.java
  40. 153
    4
      src/main/java/com/example/civilizedcity/service/impl/TaCheckServiceImpl.java
  41. 44
    2
      src/main/java/com/example/civilizedcity/service/impl/TdQuAnswerServiceImpl.java
  42. 5
    2
      src/main/java/com/example/civilizedcity/service/impl/TdQuestionServiceImpl.java
  43. 4
    1
      src/main/resources/application.yml
  44. 43
    1
      src/main/resources/mapper/TaCheckAnswerItemMapper.xml
  45. 51
    1
      src/main/resources/mapper/TaCheckAnswerMapper.xml
  46. 21
    1
      src/main/resources/mapper/TaCheckItemAnMapper.xml
  47. 59
    1
      src/main/resources/mapper/TaCheckItemMapper.xml
  48. 18
    1
      src/main/resources/mapper/TaCheckItemQuMapper.xml

+ 9260
- 0
db/.back_文明创办/文明创办-backup-2023111150516.pdma.json
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


db/.back_文明创办/文明创办-backup-202312205256.pdma.json → db/.back_文明创办/文明创办-backup-202318151439.pdma.json Просмотреть файл

@@ -2,9 +2,9 @@
2 2
   "name": "文明创办",
3 3
   "describe": "文明创办",
4 4
   "avatar": "",
5
-  "version": "4.2.0",
5
+  "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-1-2 20:51:00",
7
+  "updatedTime": "2023-1-8 15:14:32",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -4748,6 +4748,40 @@
4748 4748
           "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
4749 4749
           "id": "0EF50BA7-C44F-4D9E-A28D-F94C3D15350F"
4750 4750
         },
4751
+        {
4752
+          "defKey": "loc_score",
4753
+          "defName": "实地测评得分",
4754
+          "comment": "",
4755
+          "type": "DECIMAL",
4756
+          "len": 6,
4757
+          "scale": 2,
4758
+          "primaryKey": false,
4759
+          "notNull": false,
4760
+          "autoIncrement": false,
4761
+          "defaultValue": "",
4762
+          "hideInGraph": false,
4763
+          "refDict": "",
4764
+          "extProps": {},
4765
+          "domain": "",
4766
+          "id": "D4F39D10-19B6-49F6-A398-D9278355E747"
4767
+        },
4768
+        {
4769
+          "defKey": "survey_score",
4770
+          "defName": "调查问卷得分",
4771
+          "comment": "",
4772
+          "type": "DECIMAL",
4773
+          "len": 6,
4774
+          "scale": 2,
4775
+          "primaryKey": false,
4776
+          "notNull": false,
4777
+          "autoIncrement": false,
4778
+          "defaultValue": "",
4779
+          "hideInGraph": false,
4780
+          "refDict": "",
4781
+          "extProps": {},
4782
+          "domain": "",
4783
+          "id": "F2E17D81-03A9-42C4-8DD7-732C8D40DC59"
4784
+        },
4751 4785
         {
4752 4786
           "defKey": "start_date",
4753 4787
           "defName": "开始日期",
@@ -5605,7 +5639,7 @@
5605 5639
       "env": {
5606 5640
         "base": {
5607 5641
           "nameSpace": "com.example.civilizedcity",
5608
-          "codeRoot": "TdLocQuestion"
5642
+          "codeRoot": "TdQuestion"
5609 5643
         },
5610 5644
         "template": {
5611 5645
           "JavaMybatisPlus": {
@@ -6449,6 +6483,23 @@
6449 6483
           "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
6450 6484
           "id": "0B03C02D-84EC-4306-8CEA-2BAF04806409"
6451 6485
         },
6486
+        {
6487
+          "defKey": "answer_code",
6488
+          "defName": "答案选项",
6489
+          "comment": "",
6490
+          "type": "VARCHAR",
6491
+          "len": 10,
6492
+          "scale": "",
6493
+          "primaryKey": false,
6494
+          "notNull": false,
6495
+          "autoIncrement": false,
6496
+          "defaultValue": "",
6497
+          "hideInGraph": false,
6498
+          "refDict": "",
6499
+          "extProps": {},
6500
+          "domain": "",
6501
+          "id": "DD78B024-C9B8-4418-BD1B-8F033743F253"
6502
+        },
6452 6503
         {
6453 6504
           "defKey": "answer",
6454 6505
           "defName": "答案",
@@ -7985,9 +8036,38 @@
7985 8036
       "id": "430EE745-314D-48CE-A20B-ED2C4D79BC92",
7986 8037
       "env": {
7987 8038
         "base": {
7988
-          "nameSpace": "",
7989
-          "codeRoot": ""
7990
-        }
8039
+          "nameSpace": "com.example.civilizedcity",
8040
+          "codeRoot": "TaMessage"
8041
+        },
8042
+        "template": {
8043
+          "JavaMybatisPlus": {
8044
+            "Controller": {
8045
+              "suffix": "controller/{{=it.codeRoot}}Controller.java",
8046
+              "enable": true
8047
+            },
8048
+            "Service": {
8049
+              "suffix": "service/{{=it.codeRoot}}Service.java",
8050
+              "enable": true
8051
+            },
8052
+            "ServiceImpl": {
8053
+              "suffix": "service/impl/{{=it. codeRoot}}ServiceImpl.java",
8054
+              "enable": true
8055
+            },
8056
+            "Mapper": {
8057
+              "suffix": "mapper/{{=it.codeRoot}}Mapper.java",
8058
+              "enable": true
8059
+            },
8060
+            "Mapper.xml": {
8061
+              "suffix": "mapper/{{=it.codeRoot}}Mapper.xml",
8062
+              "enable": true
8063
+            },
8064
+            "Entity": {
8065
+              "suffix": "entity/{{=it.codeRoot}}.java",
8066
+              "enable": true
8067
+            }
8068
+          }
8069
+        },
8070
+        "custom": {}
7991 8071
       },
7992 8072
       "defKey": "ta_message",
7993 8073
       "defName": "消息通知",
@@ -8063,7 +8143,7 @@
8063 8143
       ],
8064 8144
       "fields": [
8065 8145
         {
8066
-          "defKey": "id",
8146
+          "defKey": "msg_id",
8067 8147
           "defName": "ID",
8068 8148
           "comment": "",
8069 8149
           "type": "",
@@ -8079,6 +8159,23 @@
8079 8159
           "uiHint": "",
8080 8160
           "id": "FC7B9B05-7D57-4818-8266-F8A4D62DB212"
8081 8161
         },
8162
+        {
8163
+          "defKey": "msg_type",
8164
+          "defName": "消息类型",
8165
+          "comment": "",
8166
+          "type": "",
8167
+          "len": "",
8168
+          "scale": "",
8169
+          "primaryKey": false,
8170
+          "notNull": false,
8171
+          "autoIncrement": false,
8172
+          "defaultValue": "",
8173
+          "hideInGraph": false,
8174
+          "refDict": "",
8175
+          "extProps": {},
8176
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
8177
+          "id": "92ACF22A-5638-4B62-9656-71D9089F7D7E"
8178
+        },
8082 8179
         {
8083 8180
           "defKey": "title",
8084 8181
           "defName": "消息标题",

db/.back_文明创办/文明创办-backup-202312223659.pdma.json → db/.back_文明创办/文明创办-backup-202318194130.pdma.json Просмотреть файл

@@ -2,9 +2,9 @@
2 2
   "name": "文明创办",
3 3
   "describe": "文明创办",
4 4
   "avatar": "",
5
-  "version": "4.2.0",
5
+  "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-1-2 20:52:56",
7
+  "updatedTime": "2023-1-8 15:14:39",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -4748,6 +4748,40 @@
4748 4748
           "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
4749 4749
           "id": "0EF50BA7-C44F-4D9E-A28D-F94C3D15350F"
4750 4750
         },
4751
+        {
4752
+          "defKey": "loc_score",
4753
+          "defName": "实地测评得分",
4754
+          "comment": "",
4755
+          "type": "DECIMAL",
4756
+          "len": 6,
4757
+          "scale": 2,
4758
+          "primaryKey": false,
4759
+          "notNull": false,
4760
+          "autoIncrement": false,
4761
+          "defaultValue": "",
4762
+          "hideInGraph": false,
4763
+          "refDict": "",
4764
+          "extProps": {},
4765
+          "domain": "",
4766
+          "id": "D4F39D10-19B6-49F6-A398-D9278355E747"
4767
+        },
4768
+        {
4769
+          "defKey": "survey_score",
4770
+          "defName": "调查问卷得分",
4771
+          "comment": "",
4772
+          "type": "DECIMAL",
4773
+          "len": 6,
4774
+          "scale": 2,
4775
+          "primaryKey": false,
4776
+          "notNull": false,
4777
+          "autoIncrement": false,
4778
+          "defaultValue": "",
4779
+          "hideInGraph": false,
4780
+          "refDict": "",
4781
+          "extProps": {},
4782
+          "domain": "",
4783
+          "id": "F2E17D81-03A9-42C4-8DD7-732C8D40DC59"
4784
+        },
4751 4785
         {
4752 4786
           "defKey": "start_date",
4753 4787
           "defName": "开始日期",
@@ -6449,6 +6483,23 @@
6449 6483
           "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
6450 6484
           "id": "0B03C02D-84EC-4306-8CEA-2BAF04806409"
6451 6485
         },
6486
+        {
6487
+          "defKey": "answer_code",
6488
+          "defName": "答案选项",
6489
+          "comment": "",
6490
+          "type": "VARCHAR",
6491
+          "len": 10,
6492
+          "scale": "",
6493
+          "primaryKey": false,
6494
+          "notNull": false,
6495
+          "autoIncrement": false,
6496
+          "defaultValue": "",
6497
+          "hideInGraph": false,
6498
+          "refDict": "",
6499
+          "extProps": {},
6500
+          "domain": "",
6501
+          "id": "DD78B024-C9B8-4418-BD1B-8F033743F253"
6502
+        },
6452 6503
         {
6453 6504
           "defKey": "answer",
6454 6505
           "defName": "答案",
@@ -8108,6 +8159,23 @@
8108 8159
           "uiHint": "",
8109 8160
           "id": "FC7B9B05-7D57-4818-8266-F8A4D62DB212"
8110 8161
         },
8162
+        {
8163
+          "defKey": "msg_type",
8164
+          "defName": "消息类型",
8165
+          "comment": "",
8166
+          "type": "",
8167
+          "len": "",
8168
+          "scale": "",
8169
+          "primaryKey": false,
8170
+          "notNull": false,
8171
+          "autoIncrement": false,
8172
+          "defaultValue": "",
8173
+          "hideInGraph": false,
8174
+          "refDict": "",
8175
+          "extProps": {},
8176
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
8177
+          "id": "92ACF22A-5638-4B62-9656-71D9089F7D7E"
8178
+        },
8111 8179
         {
8112 8180
           "defKey": "title",
8113 8181
           "defName": "消息标题",

+ 90
- 1
db/文明创办.pdma.json Просмотреть файл

@@ -2,9 +2,13 @@
2 2
   "name": "文明创办",
3 3
   "describe": "文明创办",
4 4
   "avatar": "",
5
-  "version": "4.2.0",
5
+  "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
+<<<<<<< HEAD
7 8
   "updatedTime": "2023-1-25 13:26:34",
9
+=======
10
+  "updatedTime": "2023-1-11 15:05:16",
11
+>>>>>>> e4b4a6f996267b72ad50673dc9482cd50e38224e
8 12
   "dbConns": [],
9 13
   "profile": {
10 14
     "default": {
@@ -4749,6 +4753,40 @@
4749 4753
           "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
4750 4754
           "id": "0EF50BA7-C44F-4D9E-A28D-F94C3D15350F"
4751 4755
         },
4756
+        {
4757
+          "defKey": "loc_score",
4758
+          "defName": "实地测评得分",
4759
+          "comment": "",
4760
+          "type": "DECIMAL",
4761
+          "len": 6,
4762
+          "scale": 2,
4763
+          "primaryKey": false,
4764
+          "notNull": false,
4765
+          "autoIncrement": false,
4766
+          "defaultValue": "",
4767
+          "hideInGraph": false,
4768
+          "refDict": "",
4769
+          "extProps": {},
4770
+          "domain": "",
4771
+          "id": "D4F39D10-19B6-49F6-A398-D9278355E747"
4772
+        },
4773
+        {
4774
+          "defKey": "survey_score",
4775
+          "defName": "调查问卷得分",
4776
+          "comment": "",
4777
+          "type": "DECIMAL",
4778
+          "len": 6,
4779
+          "scale": 2,
4780
+          "primaryKey": false,
4781
+          "notNull": false,
4782
+          "autoIncrement": false,
4783
+          "defaultValue": "",
4784
+          "hideInGraph": false,
4785
+          "refDict": "",
4786
+          "extProps": {},
4787
+          "domain": "",
4788
+          "id": "F2E17D81-03A9-42C4-8DD7-732C8D40DC59"
4789
+        },
4752 4790
         {
4753 4791
           "defKey": "start_date",
4754 4792
           "defName": "开始日期",
@@ -6258,6 +6296,23 @@
6258 6296
           "domain": "",
6259 6297
           "id": "DD228B07-C934-4B55-BFBD-844E4CBC0A75"
6260 6298
         },
6299
+        {
6300
+          "defKey": "fill_unit",
6301
+          "defName": "填空题单位",
6302
+          "comment": "",
6303
+          "type": "",
6304
+          "len": "",
6305
+          "scale": "",
6306
+          "primaryKey": false,
6307
+          "notNull": false,
6308
+          "autoIncrement": false,
6309
+          "defaultValue": "",
6310
+          "hideInGraph": false,
6311
+          "refDict": "",
6312
+          "extProps": {},
6313
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
6314
+          "id": "C81DEB4C-049A-4D1D-B506-21C920AE4286"
6315
+        },
6261 6316
         {
6262 6317
           "defKey": "stand",
6263 6318
           "defName": "评分标准",
@@ -6450,6 +6505,23 @@
6450 6505
           "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
6451 6506
           "id": "0B03C02D-84EC-4306-8CEA-2BAF04806409"
6452 6507
         },
6508
+        {
6509
+          "defKey": "answer_code",
6510
+          "defName": "答案选项",
6511
+          "comment": "",
6512
+          "type": "VARCHAR",
6513
+          "len": 10,
6514
+          "scale": "",
6515
+          "primaryKey": false,
6516
+          "notNull": false,
6517
+          "autoIncrement": false,
6518
+          "defaultValue": "",
6519
+          "hideInGraph": false,
6520
+          "refDict": "",
6521
+          "extProps": {},
6522
+          "domain": "",
6523
+          "id": "DD78B024-C9B8-4418-BD1B-8F033743F253"
6524
+        },
6453 6525
         {
6454 6526
           "defKey": "answer",
6455 6527
           "defName": "答案",
@@ -7325,6 +7397,23 @@
7325 7397
           "domain": "",
7326 7398
           "id": "EC9AB5F8-E387-4E40-B948-2581DA3E9D4D"
7327 7399
         },
7400
+        {
7401
+          "defKey": "report_issue",
7402
+          "defName": "上报问题",
7403
+          "comment": "",
7404
+          "type": "",
7405
+          "len": "",
7406
+          "scale": "",
7407
+          "primaryKey": false,
7408
+          "notNull": false,
7409
+          "autoIncrement": false,
7410
+          "defaultValue": "0",
7411
+          "hideInGraph": false,
7412
+          "refDict": "",
7413
+          "extProps": {},
7414
+          "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
7415
+          "id": "18CF14DD-048B-4743-81D9-0D6428EDBF54"
7416
+        },
7328 7417
         {
7329 7418
           "defKey": "sort_no",
7330 7419
           "defName": "排序",

+ 10
- 5
src/main/java/com/example/civilizedcity/common/Constants.java Просмотреть файл

@@ -8,11 +8,6 @@ public class Constants {
8 8
     public final static int STATUS_READY = 0;
9 9
     public final static int STATUS_NORMAL = 1;
10 10
 
11
-
12
-    public final static String CHECK_ITEM_LOC = "loc";  // 实例调研
13
-    public final static String CHECK_ITEM_SURVEY = "survey";  // 问卷调研
14
-
15
-
16 11
     // 操作员身份
17 12
     // 督察员
18 13
     public final static String DUTY_INSPECTOR = "inspector";
@@ -31,6 +26,8 @@ public class Constants {
31 26
     public final static String ATTACH_SOURCE_ISSUE = "issue";
32 27
     // 单位问题单
33 28
     public final static String ATTACH_SOURCE_ORG_ISSUE = "org-issue";
29
+    // 测评答案
30
+    public final static String ATTACH_SOURCE_CHECK_ANSWER = "check-answer";
34 31
 
35 32
     // 督察员上报
36 33
     public final static String ISSUE_SOURCE_INSPECTOR = "inspector";
@@ -87,4 +84,12 @@ public class Constants {
87 84
     public final static String MESSAGE_TARGET_ISSUE = "issue";
88 85
     // 申请流程
89 86
     public final static String MESSAGE_TARGET_APPLY = "apply";
87
+
88
+    // 调查问卷
89
+    public final static String CHECK_OF_LOC = "loc"; // 实地调查
90
+    public final static String CHECK_OF_SURVEY = "survey"; // 调查问卷
91
+
92
+    // 题型
93
+    public final static String QU_OF_FILL = "fill"; // 填空题
94
+    public final static String QU_OF_RADIO = "radio"; // 选择题
90 95
 }

+ 7
- 0
src/main/java/com/example/civilizedcity/common/StringUtils.java Просмотреть файл

@@ -13,6 +13,9 @@ public class StringUtils {
13 13
     public static boolean isEmpty(String str) {
14 14
         return null == str || "".equals(str.trim()) || "null".equals(str) || "undefined".equals(str);
15 15
     }
16
+    public static boolean isNotEmpty(String str) {
17
+        return !isEmpty(str);
18
+    }
16 19
 
17 20
     public static String trim(String src, String...st) {
18 21
         if (null == src) return src;
@@ -53,6 +56,10 @@ public class StringUtils {
53 56
         return sb.toString();
54 57
     }
55 58
 
59
+    public static String uuid() {
60
+        return UUID.randomUUID().toString().replaceAll("-", "");
61
+    }
62
+
56 63
     public static String urlEncode(String str) {
57 64
         if (isEmpty(str)) return str;
58 65
 

+ 54
- 10
src/main/java/com/example/civilizedcity/controller/CommController.java Просмотреть файл

@@ -8,10 +8,14 @@ import io.swagger.annotations.Api;
8 8
 import io.swagger.annotations.ApiOperation;
9 9
 import io.swagger.annotations.ApiParam;
10 10
 import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.beans.factory.annotation.Value;
11 12
 import org.springframework.web.bind.annotation.*;
12 13
 import org.springframework.web.multipart.MultipartFile;
13 14
 
15
+import java.io.File;
14 16
 import java.io.IOException;
17
+import java.time.LocalDateTime;
18
+import java.time.format.DateTimeFormatter;
15 19
 import java.util.HashMap;
16 20
 import java.util.Map;
17 21
 
@@ -23,6 +27,11 @@ public class CommController extends BaseController {
23 27
     @Autowired
24 28
     OSSUtils ossUtils;
25 29
 
30
+    @Value("${yz.upload.path}")
31
+    String uploadPath;
32
+    @Value("${yz.upload.prefix}")
33
+    String uploadPrefix;
34
+
26 35
     @GetMapping("/ma/captcha")
27 36
     @ApiOperation(value="获取验证码", notes = "获取验证码", httpMethod = "GET", response = ResponseBean.class)
28 37
     public ResponseBean getCaptcha(@ApiParam("手机号码") @RequestParam("phone") String phone) throws Exception {
@@ -39,16 +48,51 @@ public class CommController extends BaseController {
39 48
     @PostMapping("/{client}/file")
40 49
     public ResponseBean uploadImage(@ApiParam("客户端") @PathVariable String client,
41 50
                                     @ApiParam("文件") @RequestParam("file") MultipartFile multipartFile,
42
-                                    @ApiParam("文件类型") @RequestParam(value = "fileType", defaultValue = "image") String fileType) {
43
-        try {
44
-            String url = ossUtils.putObject(multipartFile);
45
-
46
-            Map<String, Object> resp = new HashMap<>();
47
-            resp.put("url", url);
48
-            resp.put("fileType", fileType);
49
-            return ResponseBean.success(resp);
50
-        } catch (IOException e) {
51
-            return ResponseBean.error("上传图片失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
51
+                                    @ApiParam("文件类型") @RequestParam(value = "fileType", defaultValue = "image") String fileType) throws Exception {
52
+//        try {
53
+//            String url = ossUtils.putObject(multipartFile);
54
+//
55
+//            Map<String, Object> resp = new HashMap<>();
56
+//            resp.put("url", url);
57
+//            resp.put("fileType", fileType);
58
+//            return ResponseBean.success(resp);
59
+//        } catch (IOException e) {
60
+//            return ResponseBean.error("上传图片失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
61
+//        }
62
+
63
+
64
+        //获取文件名
65
+        String fileName = multipartFile.getOriginalFilename();
66
+        String newFileName = String.format("%s/%d-%s", getMonth(), System.currentTimeMillis(), fileName);
67
+
68
+        // 上传目录以日期分类
69
+        File tmp = new File(String.format("%s/%s", getUploadPath(), getMonth()));
70
+        if (!tmp.exists()) {
71
+            tmp.mkdir();
72
+        }
73
+
74
+        //
75
+        File upFile = new File(String.format("%s/%s", getUploadPath(), newFileName));
76
+        multipartFile.transferTo(upFile);
77
+
78
+        String url = String.format("%s/%s", uploadPrefix, newFileName);
79
+        return ResponseBean.success(new HashMap<String, Object>(){{
80
+            put("url", url);
81
+        }});
82
+    }
83
+
84
+    private String getUploadPath() {
85
+        File tmp = new File(uploadPath);
86
+        if (!tmp.exists()) {
87
+            tmp.mkdir();
52 88
         }
89
+
90
+        return uploadPath;
91
+    }
92
+
93
+    private String getMonth() {
94
+        LocalDateTime now = LocalDateTime.now();
95
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
96
+        return now.format(formatter);
53 97
     }
54 98
 }

+ 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
     }

+ 69
- 25
src/main/java/com/example/civilizedcity/controller/TaCheckController.java Просмотреть файл

@@ -1,9 +1,10 @@
1 1
 package com.example.civilizedcity.controller;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
-import com.example.civilizedcity.common.BaseController;
6
-import com.example.civilizedcity.common.ResponseBean;
6
+import com.example.civilizedcity.common.*;
7
+import com.example.civilizedcity.service.TaCheckItemService;
7 8
 import io.swagger.annotations.Api;
8 9
 import io.swagger.annotations.ApiOperation;
9 10
 import io.swagger.annotations.ApiParam;
@@ -12,8 +13,9 @@ import org.springframework.web.bind.annotation.*;
12 13
 import com.example.civilizedcity.entity.TaCheck;
13 14
 import com.example.civilizedcity.service.TaCheckService;
14 15
 
15
- /**
16
+/**
16 17
  * 模拟测评;(ta_check)表控制层
18
+ *
17 19
  * @author : http://njyunzhi.com
18 20
  * @date : 2022-12-12
19 21
  */
@@ -21,12 +23,15 @@ import com.example.civilizedcity.service.TaCheckService;
21 23
 @RestController
22 24
 @RequestMapping("/")
23 25
 public class TaCheckController extends BaseController {
24
-    
26
+
25 27
     @Autowired
26 28
     private TaCheckService taCheckService;
27
-    
28
-    /** 
29
-     * 通过ID查询单条数据 
29
+
30
+    @Autowired
31
+    private TaCheckItemService taCheckItemService;
32
+
33
+    /**
34
+     * 通过ID查询单条数据
30 35
      *
31 36
      * @param checkId 主键
32 37
      * @return 实例对象
@@ -36,28 +41,43 @@ public class TaCheckController extends BaseController {
36 41
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
37 42
         return ResponseBean.success(taCheckService.getById(id));
38 43
     }
39
-    
40
-    /** 
44
+
45
+    /**
41 46
      * 分页查询
42 47
      *
43
-     * @param pageNum 当前页码
48
+     * @param pageNum  当前页码
44 49
      * @param pageSize 每页条数
45 50
      * @return 查询结果
46 51
      */
47 52
     @ApiOperation("分页查询")
48 53
     @GetMapping("/taCheck")
49
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
50
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
51
-        
54
+    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
55
+                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
56
+                             @ApiParam("测评名称") @RequestParam(value = "title", required = false) String title,
57
+                             @ApiParam("是否有效") @RequestParam(value = "isValid", required = false) Boolean isValid,
58
+                             @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
59
+                             @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate) throws Exception {
60
+
61
+        String today = DateUtils.today();
62
+
52 63
         IPage<TaCheck> pg = new Page<>(pageNum, pageSize);
53
-        // QueryWrapper<taCheck> queryWrapper = new QueryWrapper<>();
54
-        // queryWrapper.orderByDesc("create_date");
55
-        IPage<TaCheck> result = taCheckService.page(pg);
56
-        
64
+        QueryWrapper<TaCheck> queryWrapper = new QueryWrapper<>();
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)));
67
+
68
+        if (!StringUtils.isEmpty(startDate)) {
69
+            queryWrapper.le("start_date", endDate);
70
+            queryWrapper.ge("end_date", startDate);
71
+        }
72
+
73
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
74
+        queryWrapper.orderByDesc("create_date");
75
+        IPage<TaCheck> result = taCheckService.page(pg, queryWrapper);
76
+
57 77
         return ResponseBean.success(result);
58 78
     }
59
-    
60
-    /** 
79
+
80
+    /**
61 81
      * 新增数据
62 82
      *
63 83
      * @param taCheck 实例对象
@@ -67,10 +87,14 @@ public class TaCheckController extends BaseController {
67 87
     @PostMapping("/taCheck")
68 88
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaCheck taCheck) throws Exception {
69 89
         taCheckService.save(taCheck);
90
+
91
+        // 创建成功之后, 再创建
92
+        taCheckItemService.createNewItems(taCheck);
93
+
70 94
         return ResponseBean.success(taCheck);
71 95
     }
72
-    
73
-    /** 
96
+
97
+    /**
74 98
      * 更新数据
75 99
      *
76 100
      * @param taCheck 实例对象
@@ -79,12 +103,32 @@ public class TaCheckController extends BaseController {
79 103
     @ApiOperation("更新数据")
80 104
     @PutMapping("/taCheck/{id}")
81 105
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaCheck taCheck,
82
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
106
+                             @ApiParam("对象ID") @PathVariable String id) throws Exception {
107
+        taCheck.setCheckId(id);
83 108
         taCheckService.updateById(taCheck);
84 109
         return ResponseBean.success(taCheck);
85 110
     }
86
-    
87
-    /** 
111
+
112
+
113
+    /**
114
+     * 计算分数
115
+     *
116
+     * @param id 实例ID
117
+     * @return 实例对象
118
+     */
119
+    @ApiOperation("计算分数")
120
+    @PutMapping("/taCheck/{id}/score")
121
+    public ResponseBean calcScore(@ApiParam("对象ID") @PathVariable String id) throws Exception {
122
+        TaCheck taCheck = taCheckService.getById(id);
123
+        if (null == taCheck || taCheck.getStatus() == Constants.STATUS_DELETE) {
124
+            return ResponseBean.error("未找到模拟测评信息");
125
+        }
126
+
127
+        taCheckService.calcScore(taCheck);
128
+        return ResponseBean.success(taCheck);
129
+    }
130
+
131
+    /**
88 132
      * 通过主键删除数据
89 133
      *
90 134
      * @param checkId 主键
@@ -92,7 +136,7 @@ public class TaCheckController extends BaseController {
92 136
      */
93 137
     @ApiOperation("通过主键删除数据")
94 138
     @DeleteMapping("/taCheck/{id}")
95
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
139
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
96 140
         taCheckService.removeLogicById(id);
97 141
         return ResponseBean.success("success");
98 142
     }

+ 197
- 62
src/main/java/com/example/civilizedcity/controller/TaCheckItemController.java Просмотреть файл

@@ -3,24 +3,23 @@ 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;
6
+import com.example.civilizedcity.common.*;
9 7
 
10 8
 import java.time.LocalDateTime;
9
+import java.util.HashMap;
11 10
 import java.util.List;
12 11
 
13
-import com.example.civilizedcity.common.StringUtils;
12
+import com.example.civilizedcity.entity.*;
13
+import com.example.civilizedcity.service.*;
14 14
 import io.swagger.annotations.Api;
15 15
 import io.swagger.annotations.ApiOperation;
16 16
 import io.swagger.annotations.ApiParam;
17 17
 import org.springframework.beans.factory.annotation.Autowired;
18 18
 import org.springframework.web.bind.annotation.*;
19
-import com.example.civilizedcity.entity.TaCheckItem;
20
-import com.example.civilizedcity.service.TaCheckItemService;
21 19
 
22
- /**
20
+/**
23 21
  * 测评点位;(ta_check_item)表控制层
22
+ *
24 23
  * @author : http://njyunzhi.com
25 24
  * @date : 2022-12-13
26 25
  */
@@ -28,10 +27,25 @@ import com.example.civilizedcity.service.TaCheckItemService;
28 27
 @RestController
29 28
 @RequestMapping("/")
30 29
 public class TaCheckItemController extends BaseController {
31
-    
30
+
32 31
     @Autowired
33 32
     private TaCheckItemService taCheckItemService;
34
-    
33
+
34
+    @Autowired
35
+    private TdLocTypeService tdLocTypeService;
36
+
37
+    @Autowired
38
+    private TaCheckService taCheckService;
39
+
40
+    @Autowired
41
+    private TaCheckAnswerService taCheckAnswerService;
42
+
43
+    @Autowired
44
+    private TaCheckItemQuService taCheckItemQuService;
45
+
46
+    @Autowired
47
+    private TaCheckAnswerItemService taCheckAnswerItemService;
48
+
35 49
     /**
36 50
      * 通过ID查询单条数据
37 51
      *
@@ -41,55 +55,71 @@ public class TaCheckItemController extends BaseController {
41 55
     @ApiOperation("通过ID查询单条数据")
42 56
     @GetMapping("/taCheckItem/{id}")
43 57
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
44
-        return ResponseBean.success(taCheckItemService.getById(id));
58
+        TaCheckItem taCheckItem = taCheckItemService.getById(id);
59
+        if (null == taCheckItem || Constants.STATUS_DELETE == taCheckItem.getStatus()) {
60
+            return ResponseBean.error("未找到测评项目");
61
+        }
62
+
63
+        return ResponseBean.success(taCheckItem);
45 64
     }
46 65
 
47
-     /**
48
-      * 通过测评以及点位查询数据
49
-      *
50
-      * @param checkId 测评ID
51
-      * @param typeId 点位ID
52
-      * @return 实例对象
53
-      */
54
-     @ApiOperation("通过测评以及点位查询数据")
55
-     @GetMapping("/taCheck/{checkId}/item/{typeId}")
56
-     public ResponseBean queryByCheckId(@ApiParam("测评ID") @PathVariable String checkId,
57
-                                        @ApiParam("点位ID") @PathVariable String typeId) throws Exception {
58
-
59
-         return ResponseBean.success(getByCheckAndType(checkId, typeId));
60
-     }
61
-
62
-     private TaCheckItem getByCheckAndType(String checkId, String typeId) {
63
-         QueryWrapper<TaCheckItem> queryWrapper = new QueryWrapper<>();
64
-         queryWrapper.eq("check_id", checkId);
65
-         queryWrapper.eq("item_type", Constants.CHECK_ITEM_LOC); // 只查点位
66
-         queryWrapper.eq("type_id", typeId);
67
-         queryWrapper.gt("status", Constants.STATUS_DELETE);
66
+    /**
67
+     * 通过测评以及点位查询数据
68
+     *
69
+     * @param checkId 测评ID
70
+     * @param typeId  点位ID
71
+     * @return 实例对象
72
+     */
73
+    @ApiOperation("通过测评以及点位查询数据")
74
+    @GetMapping("/taCheck/{checkId}/item/{typeId}")
75
+    public ResponseBean queryByCheckId(@ApiParam("测评ID") @PathVariable String checkId,
76
+                                       @ApiParam("点位ID 或者 调查问卷") @PathVariable String typeId) throws Exception {
77
+        TaCheckItem taCheckItem = getByCheckAndType(checkId, typeId);
78
+        if (null == taCheckItem || Constants.STATUS_DELETE == taCheckItem.getStatus()) {
79
+            return ResponseBean.error("未找到测评项目");
80
+        }
81
+
82
+        return ResponseBean.success(taCheckItem);
83
+    }
84
+
85
+    private TaCheckItem getByCheckAndType(String checkId, String typeId) {
86
+        QueryWrapper<TaCheckItem> queryWrapper = new QueryWrapper<>();
87
+        queryWrapper.eq("check_id", checkId);
88
+
89
+        if (Constants.CHECK_OF_SURVEY.equals(typeId)) {
90
+            queryWrapper.eq("item_type", Constants.CHECK_OF_SURVEY);
91
+        } else {
92
+            queryWrapper.eq("item_type", Constants.CHECK_OF_LOC); // 只查点位
93
+            queryWrapper.eq("type_id", typeId);
94
+        }
95
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
96
+        queryWrapper.last("limit 1");
68 97
 
69 98
         return taCheckItemService.getOne(queryWrapper);
70
-     }
71
-    
72
-    /** 
99
+    }
100
+
101
+    /**
73 102
      * 分页查询
74 103
      *
75
-     * @param pageNum 当前页码
104
+     * @param pageNum  当前页码
76 105
      * @param pageSize 每页条数
77 106
      * @return 查询结果
78 107
      */
79 108
     @ApiOperation("分页查询")
80 109
     @GetMapping("/taCheckItem")
81
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
82
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
83
-        
110
+    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
111
+                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
112
+                             @ApiParam("模拟测评ID") @RequestParam(value = "checkId") String checkId,
113
+                             @ApiParam("项目类型") @RequestParam(value = "itemType") String itemType) throws Exception {
114
+
115
+        SysUser sysUser = currentUser();
84 116
         IPage<TaCheckItem> pg = new Page<>(pageNum, pageSize);
85
-        // QueryWrapper<TaCheckItem> queryWrapper = new QueryWrapper<>();
86
-        // queryWrapper.orderByDesc("create_date");
87
-        IPage<TaCheckItem> result = taCheckItemService.page(pg);
88
-        
117
+        IPage<TaCheckItem> result = taCheckItemService.getPageBy(pg, checkId, itemType);
118
+
89 119
         return ResponseBean.success(result);
90 120
     }
91
-    
92
-    /** 
121
+
122
+    /**
93 123
      * 新增数据
94 124
      *
95 125
      * @param taCheckItem 实例对象
@@ -99,7 +129,24 @@ public class TaCheckItemController extends BaseController {
99 129
     @PostMapping("/taCheckItem")
100 130
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaCheckItem taCheckItem) throws Exception {
101 131
 
102
-        TaCheckItem origin = getByCheckAndType(taCheckItem.getCheckId(), taCheckItem.getItemId());
132
+        if (StringUtils.isEmpty(taCheckItem.getItemType())) {
133
+            return ResponseBean.error("测评类型不能为空");
134
+        }
135
+
136
+        if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType()) && StringUtils.isEmpty(taCheckItem.getTypeId())) {
137
+            return ResponseBean.error("测评点位不能为空");
138
+        }
139
+
140
+        if (!StringUtils.isEmpty(taCheckItem.getTypeId())) {
141
+            TdLocType tdLocType = tdLocTypeService.getById(taCheckItem.getTypeId());
142
+            if (null != tdLocType) {
143
+                taCheckItem.setName(tdLocType.getName());
144
+            } else {
145
+                return ResponseBean.error("测评点位选择不正确");
146
+            }
147
+        }
148
+
149
+        TaCheckItem origin = getByCheckAndType(taCheckItem.getCheckId(), taCheckItem.getTypeId());
103 150
         if (null == origin) {
104 151
             // 新增
105 152
             taCheckItem.setStatus(Constants.STATUS_NORMAL);
@@ -113,22 +160,110 @@ public class TaCheckItemController extends BaseController {
113 160
 
114 161
         return ResponseBean.success(taCheckItem);
115 162
     }
116
-    
117
-//    /**
118
-//     * 更新数据
119
-//     *
120
-//     * @param taCheckItem 实例对象
121
-//     * @return 实例对象
122
-//     */
123
-//    @ApiOperation("更新数据")
124
-//    @PutMapping("/taCheckItem/{id}")
125
-//    public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaCheckItem taCheckItem,
126
-//                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
127
-//        taCheckItemService.updateById(taCheckItem);
128
-//        return ResponseBean.success(taCheckItem);
129
-//    }
130
-    
131
-    /** 
163
+
164
+    @ApiOperation("答卷检测")
165
+    @PutMapping("/taCheckItem/{id}/answer/pre-check")
166
+    public ResponseBean checkAnswer(@ApiParam("对象ID") @PathVariable String id) throws Exception {
167
+        TaCheckItem taCheckItem = taCheckItemService.getById(id);
168
+        if (null == taCheckItem || taCheckItem.getStatus() == Constants.STATUS_DELETE) {
169
+            return ResponseBean.success(new HashMap<String, Object>(){{
170
+                put("errorCode", -1);   // 负数代表不能进行任何操作, 包括查看
171
+                put("message", "未找到有效的答题信息");
172
+            }});
173
+        }
174
+
175
+        TaCheck taCheck = taCheckService.getById(taCheckItem.getCheckId());
176
+        if (null == taCheck || taCheck.getStatus() == Constants.STATUS_DELETE) {
177
+            return ResponseBean.success(new HashMap<String, Object>(){{
178
+                put("errorCode", -2);
179
+                put("message", "未找到有效的测评信息");
180
+            }});
181
+        }
182
+
183
+        if (LocalDateTime.now().isAfter(DateUtils.day2LocalDateime(taCheck.getEndDate()))) {
184
+            return ResponseBean.success(new HashMap<String, Object>(){{
185
+                put("errorCode", 1);    // 正数代表, 只能查看
186
+                put("message", "本次测评已结束");
187
+            }});
188
+        }
189
+
190
+        int cnt = taCheckAnswerService.countByItem(taCheckItem.getItemId());
191
+        if (cnt >= taCheckItem.getNum()) {
192
+            return ResponseBean.success(new HashMap<String, Object>(){{
193
+                put("errorCode", 3);
194
+                put("message", "当前问卷已收齐, 无须作答");
195
+            }});
196
+        }
197
+
198
+        return ResponseBean.success(new HashMap<String, Object>(){{
199
+            put("errorCode", 0);    // 0 代表可以答题
200
+            put("message", null);
201
+        }});
202
+    }
203
+
204
+    /**
205
+     * 获取回答
206
+     *
207
+     * @param id 实例对象
208
+     * @return 实例对象
209
+     */
210
+    @ApiOperation("更新数据")
211
+    @GetMapping("/taCheckItem/{id}/answer")
212
+    public ResponseBean getAnswer(@ApiParam("对象ID") @PathVariable String id) throws Exception {
213
+
214
+        SysUser sysUser = currentUser();
215
+        List<TaCheckAnswer> answerList = taCheckAnswerService.getByUser(id, sysUser.getUserId());
216
+        return ResponseBean.success(answerList);
217
+    }
218
+
219
+    /**
220
+     * 回答问题
221
+     *
222
+     * @param taCheckAnswer 实例对象
223
+     * @return 实例对象
224
+     */
225
+    @ApiOperation("更新数据")
226
+    @PutMapping("/taCheckItem/{id}/answer")
227
+    public ResponseBean answer(@ApiParam("对象实体") @RequestBody TaCheckAnswer taCheckAnswer,
228
+                               @ApiParam("对象ID") @PathVariable String id) throws Exception {
229
+
230
+        SysUser sysUser = currentUser();
231
+        TaCheckItem taCheckItem = taCheckItemService.getById(id);
232
+        if (null == taCheckItem || taCheckItem.getStatus() == Constants.STATUS_DELETE) {
233
+            return ResponseBean.error("未找到有效的答题信息");
234
+        }
235
+
236
+        TaCheck taCheck = taCheckService.getById(taCheckItem.getCheckId());
237
+        if (null == taCheck || taCheck.getStatus() == Constants.STATUS_DELETE) {
238
+            return ResponseBean.error("未找到有效的测评信息");
239
+        }
240
+
241
+        if (LocalDateTime.now().isAfter(DateUtils.day2LocalDateime(taCheck.getEndDate()))) {
242
+            return ResponseBean.error("本次测评已结束");
243
+        }
244
+
245
+        if (StringUtils.isEmpty(taCheckAnswer.getAddr())) {
246
+            return ResponseBean.error("测评地点详情或小区名称未填写");
247
+        }
248
+
249
+        int count = taCheckAnswerService.getCountByUser(id, sysUser.getUserId());
250
+        if (count > 0) {
251
+            return ResponseBean.error("您已完成测评作答");
252
+        }
253
+
254
+        taCheckAnswer.setAnswerId(StringUtils.uuid());
255
+        taCheckAnswer.setCheckId(taCheck.getCheckId());
256
+        taCheckAnswer.setItemId(id);
257
+        taCheckAnswer.setStatus(Constants.STATUS_NORMAL);
258
+        taCheckAnswer.setOrgId(sysUser.getOrgId());
259
+        taCheckAnswer.setCreateUser(sysUser.getUserId());
260
+        taCheckAnswer.setCreateDate(LocalDateTime.now());
261
+
262
+        taCheckItemService.answer(taCheckItem, taCheckAnswer);
263
+        return ResponseBean.success(taCheckAnswer);
264
+    }
265
+
266
+    /**
132 267
      * 通过主键删除数据
133 268
      *
134 269
      * @param itemId 主键
@@ -136,7 +271,7 @@ public class TaCheckItemController extends BaseController {
136 271
      */
137 272
     @ApiOperation("通过主键删除数据")
138 273
     @DeleteMapping("/taCheckItem/{id}")
139
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
274
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
140 275
         taCheckItemService.removeLogicById(id);
141 276
         return ResponseBean.success("success");
142 277
     }

+ 2
- 2
src/main/java/com/example/civilizedcity/controller/TaCheckItemQuController.java Просмотреть файл

@@ -91,8 +91,8 @@ public class TaCheckItemQuController extends BaseController {
91 91
 
92 92
         if (StringUtils.isEmpty(quId)) {
93 93
             // 新增
94
-            int maxNo = taCheckItemQuService.getMaxNoBy(taCheckItemQu.getItemId());
95
-            taCheckItemQu.setSortNo(maxNo + 1);
94
+//            int maxNo = taCheckItemQuService.getMaxNoBy(taCheckItemQu.getItemId());
95
+//            taCheckItemQu.setSortNo(maxNo + 1);
96 96
             taCheckItemQuService.save(taCheckItemQu);
97 97
         } else {
98 98
             taCheckItemQuService.updateById(taCheckItemQu);

+ 22
- 17
src/main/java/com/example/civilizedcity/controller/TaIssueController.java Просмотреть файл

@@ -4,10 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
-import com.example.civilizedcity.common.BaseController;
8
-import com.example.civilizedcity.common.Constants;
9
-import com.example.civilizedcity.common.DateUtils;
10
-import com.example.civilizedcity.common.ResponseBean;
7
+import com.example.civilizedcity.common.*;
11 8
 
12 9
 import java.time.LocalDateTime;
13 10
 import java.util.ArrayList;
@@ -80,19 +77,23 @@ public class TaIssueController extends BaseController {
80 77
     public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
81 78
                              @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
82 79
                              @ApiParam("问题单状态") @RequestParam(value = "bizStatus", required = false) String bizStatus,
83
-                             @ApiParam("来源") @RequestParam(value = "sourceType", required = false) String sourceType) throws Exception {
80
+                             @ApiParam("来源") @RequestParam(value = "sourceType", required = false) String sourceType,
81
+                             @ApiParam("点位") @RequestParam(value = "locId", required = false) String locId,
82
+                             @ApiParam("责任单位") @RequestParam(value = "orgId", required = false) String orgId) throws Exception {
84 83
 
85 84
         SysUser sysUser = currentUser();
86
-        String orgId = Constants.ROOT_ORG.equals(sysUser.getOrgId()) ? null : sysUser.getOrgId();
85
+        boolean isRooter = Constants.ROOT_ID.equals(sysUser.getUserId());
87 86
 
88 87
         List<String> dutyList = sysUserDutyService.getListByUser(sysUser.getUserId());
89
-        if (dutyList == null || dutyList.size() < 1) {
88
+        if (!isRooter && (dutyList == null || dutyList.size() < 1)) {
90 89
             return ResponseBean.error("暂无权限查询数据");
91 90
         }
92 91
 
93
-        Boolean mine = false;
92
+        Boolean mine = true;
94 93
         Integer validateStatus = null;
95
-        if (dutyList.contains(Constants.DUTY_INSPECTOR)) {
94
+        if (isRooter) {
95
+            mine = false;
96
+        } else if (dutyList.contains(Constants.DUTY_INSPECTOR)) {
96 97
             mine = true;
97 98
         } else if (dutyList.contains(Constants.DUTY_MANAGER)) {
98 99
             mine = true;
@@ -101,9 +102,9 @@ public class TaIssueController extends BaseController {
101 102
             return ResponseBean.error("暂无权限查询数据");
102 103
         }
103 104
 
104
-
105 105
         IPage<TaIssue> pg = new Page<>(pageNum, pageSize);
106 106
         QueryWrapper<TaIssue> queryWrapper = new QueryWrapper<>();
107
+//        queryWrapper.eq("org_id", orgId);
107 108
 
108 109
         if (Constants.PROCESS_START.equals(bizStatus)) {
109 110
             // 待交办
@@ -124,15 +125,19 @@ public class TaIssueController extends BaseController {
124 125
             queryWrapper.eq("process_status", Constants.PROCESS_STATUS_REJECT);
125 126
         }
126 127
 
127
-        if (mine && null != validateStatus) {
128
-            Integer vst = validateStatus;
129
-            queryWrapper.nested(q -> q.eq("create_user", sysUser.getUserId()).or().gt("validate_status", vst));
130
-        } else if (mine) {
131
-            queryWrapper.eq(mine, "create_user", sysUser.getUserId());
132
-        } else if (null != validateStatus) {
133
-            queryWrapper.gt(null != validateStatus, "validate_status", validateStatus);
128
+        // 既是督察员又是管理员
129
+        if (!isRooter) {
130
+            if (dutyList.contains(Constants.DUTY_MANAGER)) {
131
+                // 管理员
132
+                queryWrapper.nested(q -> q.eq("create_user", sysUser.getUserId()).or().gt("validate_status", 0));
133
+            } else if (dutyList.contains(Constants.DUTY_INSPECTOR)) {
134
+                // 督察员
135
+                queryWrapper.eq("create_user", sysUser.getUserId());
136
+            }
134 137
         }
135 138
 
139
+        queryWrapper.eq(StringUtils.isNotEmpty(locId), "loc_id", locId);
140
+        queryWrapper.eq(StringUtils.isNotEmpty(orgId), "org_id", orgId);
136 141
         queryWrapper.eq(Constants.ISSUE_SOURCE_FEEDBACK.equals(sourceType), "source_type", "feedback");
137 142
         queryWrapper.ne(Constants.ISSUE_SOURCE_INSPECTOR.equals(sourceType), "source_type", "feedback");
138 143
         queryWrapper.gt("status", Constants.STATUS_DELETE);

+ 49
- 25
src/main/java/com/example/civilizedcity/controller/TaNoticeController.java Просмотреть файл

@@ -4,8 +4,13 @@ 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
+
10
+import java.time.LocalDateTime;
8 11
 import java.util.List;
12
+
13
+import com.example.civilizedcity.common.StringUtils;
9 14
 import io.swagger.annotations.Api;
10 15
 import io.swagger.annotations.ApiOperation;
11 16
 import io.swagger.annotations.ApiParam;
@@ -14,8 +19,9 @@ import org.springframework.web.bind.annotation.*;
14 19
 import com.example.civilizedcity.entity.TaNotice;
15 20
 import com.example.civilizedcity.service.TaNoticeService;
16 21
 
17
- /**
22
+/**
18 23
  * 通知公告;(ta_notice)表控制层
24
+ *
19 25
  * @author : http://njyunzhi.com
20 26
  * @date : 2022-12-12
21 27
  */
@@ -23,14 +29,14 @@ import com.example.civilizedcity.service.TaNoticeService;
23 29
 @RestController
24 30
 @RequestMapping("/")
25 31
 public class TaNoticeController extends BaseController {
26
-    
32
+
27 33
     @Autowired
28 34
     private TaNoticeService taNoticeService;
29
-    
30
-    /** 
31
-     * 通过ID查询单条数据 
35
+
36
+    /**
37
+     * 通过ID查询单条数据
32 38
      *
33
-     * @param noticeId 主键
39
+     * @param id 主键
34 40
      * @return 实例对象
35 41
      */
36 42
     @ApiOperation("通过ID查询单条数据")
@@ -38,28 +44,32 @@ public class TaNoticeController extends BaseController {
38 44
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
39 45
         return ResponseBean.success(taNoticeService.getById(id));
40 46
     }
41
-    
42
-    /** 
47
+
48
+    /**
43 49
      * 分页查询
44 50
      *
45
-     * @param pageNum 当前页码
51
+     * @param pageNum  当前页码
46 52
      * @param pageSize 每页条数
47 53
      * @return 查询结果
48 54
      */
49 55
     @ApiOperation("分页查询")
50 56
     @GetMapping("/taNotice")
51
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
53
-        
57
+    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
58
+                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
59
+                             @ApiParam("发布状态") @RequestParam(value = "status", required = false) Integer status) throws Exception {
60
+
54 61
         IPage<TaNotice> pg = new Page<>(pageNum, pageSize);
55
-        // QueryWrapper<TaNotice> queryWrapper = new QueryWrapper<>();
56
-        // queryWrapper.orderByDesc("create_date");
57
-        IPage<TaNotice> result = taNoticeService.page(pg);
58
-        
62
+        QueryWrapper<TaNotice> queryWrapper = new QueryWrapper<>();
63
+        queryWrapper.eq(null != status, "status", status);
64
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
65
+        queryWrapper.orderByDesc("weight");
66
+        queryWrapper.orderByDesc("create_date");
67
+        IPage<TaNotice> result = taNoticeService.page(pg, queryWrapper);
68
+
59 69
         return ResponseBean.success(result);
60 70
     }
61
-    
62
-    /** 
71
+
72
+    /**
63 73
      * 新增数据
64 74
      *
65 75
      * @param taNotice 实例对象
@@ -68,11 +78,19 @@ public class TaNoticeController extends BaseController {
68 78
     @ApiOperation("新增数据")
69 79
     @PostMapping("/taNotice")
70 80
     public ResponseBean add(@ApiParam("对象实体") @RequestBody TaNotice taNotice) throws Exception {
81
+        taNotice.setNoticeId(null);
82
+
83
+        if (StringUtils.isEmpty(taNotice.getTitle())) {
84
+            return ResponseBean.error("公告标题不能为空");
85
+        }
86
+
87
+        taNotice.setCreateDate(LocalDateTime.now());
88
+
71 89
         taNoticeService.save(taNotice);
72 90
         return ResponseBean.success(taNotice);
73 91
     }
74
-    
75
-    /** 
92
+
93
+    /**
76 94
      * 更新数据
77 95
      *
78 96
      * @param taNotice 实例对象
@@ -81,20 +99,26 @@ public class TaNoticeController extends BaseController {
81 99
     @ApiOperation("更新数据")
82 100
     @PutMapping("/taNotice/{id}")
83 101
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaNotice taNotice,
84
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
102
+                             @ApiParam("对象ID") @PathVariable String id) throws Exception {
103
+        taNotice.setNoticeId(id);
104
+
105
+        if (StringUtils.isEmpty(taNotice.getTitle())) {
106
+            return ResponseBean.error("公告标题不能为空");
107
+        }
108
+
85 109
         taNoticeService.updateById(taNotice);
86 110
         return ResponseBean.success(taNotice);
87 111
     }
88
-    
89
-    /** 
112
+
113
+    /**
90 114
      * 通过主键删除数据
91 115
      *
92
-     * @param noticeId 主键
116
+     * @param id 主键
93 117
      * @return 是否成功
94 118
      */
95 119
     @ApiOperation("通过主键删除数据")
96 120
     @DeleteMapping("/taNotice/{id}")
97
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
121
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
98 122
         taNoticeService.removeLogicById(id);
99 123
         return ResponseBean.success("success");
100 124
     }

+ 16
- 16
src/main/java/com/example/civilizedcity/controller/TdQuAnswerController.java Просмотреть файл

@@ -23,7 +23,7 @@ import com.example.civilizedcity.service.TdQuAnswerService;
23 23
 public class TdQuAnswerController extends BaseController {
24 24
     
25 25
     @Autowired
26
-    private TdQuAnswerService tdLocQuAnswerService;
26
+    private TdQuAnswerService tdQuAnswerService;
27 27
     
28 28
     /** 
29 29
      * 通过ID查询单条数据 
@@ -32,9 +32,9 @@ public class TdQuAnswerController extends BaseController {
32 32
      * @return 实例对象
33 33
      */
34 34
     @ApiOperation("通过ID查询单条数据")
35
-    @GetMapping("/tdLocQuAnswer/{id}")
35
+    @GetMapping("/tdQuAnswer/{id}")
36 36
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
37
-        return ResponseBean.success(tdLocQuAnswerService.getById(id));
37
+        return ResponseBean.success(tdQuAnswerService.getById(id));
38 38
     }
39 39
     
40 40
     /** 
@@ -45,14 +45,14 @@ public class TdQuAnswerController extends BaseController {
45 45
      * @return 查询结果
46 46
      */
47 47
     @ApiOperation("分页查询")
48
-    @GetMapping("/tdLocQuAnswer")
48
+    @GetMapping("/tdQuAnswer")
49 49
     public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
50 50
                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
51 51
         
52 52
         IPage<TdQuAnswer> pg = new Page<>(pageNum, pageSize);
53 53
         // QueryWrapper<TdLocQuAnswer> queryWrapper = new QueryWrapper<>();
54 54
         // queryWrapper.orderByDesc("create_date");
55
-        IPage<TdQuAnswer> result = tdLocQuAnswerService.page(pg);
55
+        IPage<TdQuAnswer> result = tdQuAnswerService.page(pg);
56 56
         
57 57
         return ResponseBean.success(result);
58 58
     }
@@ -60,28 +60,28 @@ public class TdQuAnswerController extends BaseController {
60 60
     /** 
61 61
      * 新增数据
62 62
      *
63
-     * @param tdLocQuAnswer 实例对象
63
+     * @param tdQuAnswer 实例对象
64 64
      * @return 实例对象
65 65
      */
66 66
     @ApiOperation("新增数据")
67 67
     @PostMapping("/tdLocQuAnswer")
68
-    public ResponseBean add(@ApiParam("对象实体") @RequestBody TdQuAnswer tdLocQuAnswer) throws Exception {
69
-        tdLocQuAnswerService.save(tdLocQuAnswer);
70
-        return ResponseBean.success(tdLocQuAnswer);
68
+    public ResponseBean add(@ApiParam("对象实体") @RequestBody TdQuAnswer tdQuAnswer) throws Exception {
69
+        tdQuAnswerService.save(tdQuAnswer);
70
+        return ResponseBean.success(tdQuAnswer);
71 71
     }
72 72
     
73 73
     /** 
74 74
      * 更新数据
75 75
      *
76
-     * @param tdLocQuAnswer 实例对象
76
+     * @param tdQuAnswer 实例对象
77 77
      * @return 实例对象
78 78
      */
79 79
     @ApiOperation("更新数据")
80
-    @PutMapping("/tdLocQuAnswer/{id}")
81
-    public ResponseBean edit(@ApiParam("对象实体") @RequestBody TdQuAnswer tdLocQuAnswer,
80
+    @PutMapping("/tdQuAnswer/{id}")
81
+    public ResponseBean edit(@ApiParam("对象实体") @RequestBody TdQuAnswer tdQuAnswer,
82 82
                             @ApiParam("对象ID") @PathVariable String id ) throws Exception {
83
-        tdLocQuAnswerService.updateById(tdLocQuAnswer);
84
-        return ResponseBean.success(tdLocQuAnswer);
83
+        tdQuAnswerService.updateById(tdQuAnswer);
84
+        return ResponseBean.success(tdQuAnswer);
85 85
     }
86 86
     
87 87
     /** 
@@ -91,9 +91,9 @@ public class TdQuAnswerController extends BaseController {
91 91
      * @return 是否成功
92 92
      */
93 93
     @ApiOperation("通过主键删除数据")
94
-    @DeleteMapping("/tdLocQuAnswer/{id}")
94
+    @DeleteMapping("/tdQuAnswer/{id}")
95 95
     public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
96
-        tdLocQuAnswerService.removeLogicById(id);
96
+        tdQuAnswerService.removeLogicById(id);
97 97
         return ResponseBean.success("success");
98 98
     }
99 99
 }

+ 72
- 40
src/main/java/com/example/civilizedcity/controller/TdQuestionController.java Просмотреть файл

@@ -1,9 +1,15 @@
1 1
 package com.example.civilizedcity.controller;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 6
 import com.example.civilizedcity.common.BaseController;
7
+import com.example.civilizedcity.common.Constants;
6 8
 import com.example.civilizedcity.common.ResponseBean;
9
+import com.example.civilizedcity.common.StringUtils;
10
+import com.example.civilizedcity.entity.TdQuAnswer;
11
+import com.example.civilizedcity.service.TaCheckItemAnService;
12
+import com.example.civilizedcity.service.TdQuAnswerService;
7 13
 import io.swagger.annotations.Api;
8 14
 import io.swagger.annotations.ApiOperation;
9 15
 import io.swagger.annotations.ApiParam;
@@ -12,8 +18,11 @@ import org.springframework.web.bind.annotation.*;
12 18
 import com.example.civilizedcity.entity.TdQuestion;
13 19
 import com.example.civilizedcity.service.TdQuestionService;
14 20
 
15
- /**
16
- * 点位问题;(td_loc_question)表控制层
21
+import java.util.List;
22
+
23
+/**
24
+ * 点位问题;(td_question)表控制层
25
+ *
17 26
  * @author : http://njyunzhi.com
18 27
  * @date : 2022-12-13
19 28
  */
@@ -21,79 +30,102 @@ import com.example.civilizedcity.service.TdQuestionService;
21 30
 @RestController
22 31
 @RequestMapping("/")
23 32
 public class TdQuestionController extends BaseController {
24
-    
33
+
34
+    @Autowired
35
+    private TdQuestionService tdQuestionService;
36
+
25 37
     @Autowired
26
-    private TdQuestionService tdLocQuestionService;
27
-    
28
-    /** 
29
-     * 通过ID查询单条数据 
38
+    private TdQuAnswerService tdQuAnswerService;
39
+
40
+    /**
41
+     * 通过ID查询单条数据
30 42
      *
31 43
      * @param quId 主键
32 44
      * @return 实例对象
33 45
      */
34 46
     @ApiOperation("通过ID查询单条数据")
35
-    @GetMapping("/tdLocQuestion/{id}")
47
+    @GetMapping("/tdQuestion/{id}")
36 48
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
37
-        return ResponseBean.success(tdLocQuestionService.getById(id));
49
+        return ResponseBean.success(tdQuestionService.getById(id));
38 50
     }
39
-    
40
-    /** 
51
+
52
+    /**
41 53
      * 分页查询
42 54
      *
43
-     * @param pageNum 当前页码
55
+     * @param pageNum  当前页码
44 56
      * @param pageSize 每页条数
45 57
      * @return 查询结果
46 58
      */
47 59
     @ApiOperation("分页查询")
48
-    @GetMapping("/tdLocQuestion")
49
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
50
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
51
-        
60
+    @GetMapping("/tdQuestion")
61
+    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
62
+                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
63
+                             @ApiParam("标题") @RequestParam(value = "title", required = false) String title) throws Exception {
64
+
52 65
         IPage<TdQuestion> pg = new Page<>(pageNum, pageSize);
53
-        // QueryWrapper<TdLocQuestion> queryWrapper = new QueryWrapper<>();
54
-        // queryWrapper.orderByDesc("create_date");
55
-        IPage<TdQuestion> result = tdLocQuestionService.page(pg);
56
-        
66
+        QueryWrapper<TdQuestion> queryWrapper = new QueryWrapper<>();
67
+        queryWrapper.like(!StringUtils.isEmpty(title), "title", title);
68
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
69
+        queryWrapper.orderByDesc("create_date");
70
+        IPage<TdQuestion> result = tdQuestionService.page(pg, queryWrapper);
71
+
72
+        List<TdQuestion> records = result.getRecords();
73
+        if (null != records || records.size() > 0) {
74
+            for (TdQuestion tdQuestion : records) {
75
+                List<TdQuAnswer> answerList = tdQuAnswerService.getListByQuId(tdQuestion.getQuId());
76
+                tdQuestion.setQuAnswerList(answerList);
77
+            }
78
+        }
79
+
57 80
         return ResponseBean.success(result);
58 81
     }
59
-    
60
-    /** 
82
+
83
+    /**
61 84
      * 新增数据
62 85
      *
63
-     * @param tdLocQuestion 实例对象
86
+     * @param tdQuestion 实例对象
64 87
      * @return 实例对象
65 88
      */
66 89
     @ApiOperation("新增数据")
67
-    @PostMapping("/tdLocQuestion")
68
-    public ResponseBean add(@ApiParam("对象实体") @RequestBody TdQuestion tdLocQuestion) throws Exception {
69
-        tdLocQuestionService.save(tdLocQuestion);
70
-        return ResponseBean.success(tdLocQuestion);
90
+    @PostMapping("/tdQuestion")
91
+    public ResponseBean add(@ApiParam("对象实体") @RequestBody TdQuestion tdQuestion) throws Exception {
92
+        String quId = tdQuestion.getQuId();
93
+
94
+        if (StringUtils.isEmpty(quId)) {
95
+            // 新增
96
+            tdQuestionService.save(tdQuestion);
97
+        } else {
98
+            tdQuestionService.updateById(tdQuestion);
99
+        }
100
+
101
+        tdQuAnswerService.mergeData(tdQuestion.getQuId(), tdQuestion.getQuAnswerList());
102
+        return ResponseBean.success(tdQuestion);
71 103
     }
72
-    
73
-    /** 
104
+
105
+    /**
74 106
      * 更新数据
75 107
      *
76
-     * @param tdLocQuestion 实例对象
108
+     * @param tdQuestion 实例对象
77 109
      * @return 实例对象
78 110
      */
79 111
     @ApiOperation("更新数据")
80
-    @PutMapping("/tdLocQuestion/{id}")
81
-    public ResponseBean edit(@ApiParam("对象实体") @RequestBody TdQuestion tdLocQuestion,
82
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
83
-        tdLocQuestionService.updateById(tdLocQuestion);
84
-        return ResponseBean.success(tdLocQuestion);
112
+    @PutMapping("/tdQuestion/{id}")
113
+    public ResponseBean edit(@ApiParam("对象实体") @RequestBody TdQuestion tdQuestion,
114
+                             @ApiParam("对象ID") @PathVariable String id) throws Exception {
115
+        tdQuestionService.updateById(tdQuestion);
116
+        return ResponseBean.success(tdQuestion);
85 117
     }
86
-    
87
-    /** 
118
+
119
+    /**
88 120
      * 通过主键删除数据
89 121
      *
90 122
      * @param quId 主键
91 123
      * @return 是否成功
92 124
      */
93 125
     @ApiOperation("通过主键删除数据")
94
-    @DeleteMapping("/tdLocQuestion/{id}")
95
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
96
-        tdLocQuestionService.removeLogicById(id);
126
+    @DeleteMapping("/tdQuestion/{id}")
127
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
128
+        tdQuestionService.removeLogicById(id);
97 129
         return ResponseBean.success("success");
98 130
     }
99 131
 }

+ 6
- 0
src/main/java/com/example/civilizedcity/entity/TaCheck.java Просмотреть файл

@@ -33,6 +33,12 @@ public class TaCheck implements Serializable,Cloneable{
33 33
       /** 总分 */
34 34
       @ApiModelProperty(name = "总分",notes = "")
35 35
       private Integer score ;
36
+       /** 实地测评得分 */
37
+       @ApiModelProperty(name = "实地测评得分",notes = "")
38
+       private Double locScore ;
39
+       /** 调查问卷得分 */
40
+       @ApiModelProperty(name = "调查问卷得分",notes = "")
41
+       private Double surveyScore ;
36 42
       /** 开始日期;YYYY-MM-DD */
37 43
       @ApiModelProperty(name = "开始日期",notes = "YYYY-MM-DD")
38 44
       private String startDate ;

+ 7
- 0
src/main/java/com/example/civilizedcity/entity/TaCheckAnswer.java Просмотреть файл

@@ -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;
@@ -60,4 +63,8 @@ public class TaCheckAnswer implements Serializable,Cloneable{
60 63
     @ApiModelProperty(name = "作答时间",notes = "")
61 64
     private LocalDateTime createDate ;
62 65
 
66
+    @TableField(exist = false)
67
+    @ApiModelProperty(name = "答案列表",notes = "")
68
+    private List<TaCheckAnswerItem> answerItemList ;
69
+
63 70
 }

+ 58
- 37
src/main/java/com/example/civilizedcity/entity/TaCheckAnswerItem.java Просмотреть файл

@@ -1,60 +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.INPUT)
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
-    /** 其他问题;其他问题时, qu_id 不存在 */
36
-    @ApiModelProperty(name = "其他问题",notes = "其他问题时, qu_id 不存在")
37
-    private Integer isCustom ;
38
-    /** 问题描述 */
39
-    @ApiModelProperty(name = "问题描述",notes = "")
40
-    private String quTitle ;
41
-    /** 标准答案 */
42
-    @ApiModelProperty(name = "标准答案",notes = "")
43
-    private String standAnswer ;
44
-    /** 答案 */
45
-    @ApiModelProperty(name = "答案",notes = "")
46
-    private String answer ;
47
-    /** 得分 */
48
-    @ApiModelProperty(name = "得分",notes = "")
49
-    private Double score ;
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 ;
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;
59 80
 
60 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 Integer answerNum;
60 89
 }

+ 2
- 0
src/main/java/com/example/civilizedcity/entity/TaCheckItemAn.java Просмотреть файл

@@ -42,4 +42,6 @@ public class TaCheckItemAn implements Serializable,Cloneable{
42 42
     @ApiModelProperty(name = "排序",notes = "")
43 43
     private Integer sortNo ;
44 44
 
45
+     @ApiModelProperty(name = "上报问题",notes = "")
46
+    private Boolean reportIssue;
45 47
 }

+ 3
- 0
src/main/java/com/example/civilizedcity/entity/TaCheckItemQu.java Просмотреть файл

@@ -54,6 +54,9 @@ public class TaCheckItemQu implements Serializable,Cloneable{
54 54
      @ApiModelProperty(name = "序号",notes = "")
55 55
      private Integer sortNo ;
56 56
 
57
+      @ApiModelProperty(name = "填空题单位",notes = "")
58
+     private String fillUnit;
59
+
57 60
       /**
58 61
        * 答案列表
59 62
        */

+ 1
- 1
src/main/java/com/example/civilizedcity/entity/TaNotice.java Просмотреть файл

@@ -25,7 +25,7 @@ import lombok.experimental.Accessors;
25 25
 public class TaNotice implements Serializable,Cloneable{
26 26
     /** 通知ID */
27 27
     @ApiModelProperty(name = "通知ID",notes = "")
28
-    @TableId(value = "notice_id", type = IdType.INPUT)
28
+    @TableId(value = "notice_id", type = IdType.ASSIGN_UUID)
29 29
     private String noticeId ;
30 30
     /** 标题 */
31 31
     @ApiModelProperty(name = "标题",notes = "")

+ 2
- 2
src/main/java/com/example/civilizedcity/entity/TdQuAnswer.java Просмотреть файл

@@ -20,11 +20,11 @@ import lombok.experimental.Accessors;
20 20
 @EqualsAndHashCode(callSuper = false)
21 21
 @Accessors(chain = true)
22 22
 @ApiModel(value = "点位问题答案",description = "")
23
-@TableName("td_loc_qu_answer")
23
+@TableName("td_qu_answer")
24 24
 public class TdQuAnswer implements Serializable,Cloneable{
25 25
     /** 答案ID */
26 26
     @ApiModelProperty(name = "答案ID",notes = "")
27
-    @TableId(value = "answer_id", type = IdType.INPUT)
27
+    @TableId(value = "answer_id", type = IdType.ASSIGN_UUID)
28 28
     private String answerId ;
29 29
     /** 问题ID */
30 30
     @ApiModelProperty(name = "问题ID",notes = "")

+ 28
- 23
src/main/java/com/example/civilizedcity/entity/TdQuestion.java Просмотреть файл

@@ -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;
@@ -20,29 +23,31 @@ import lombok.experimental.Accessors;
20 23
 @EqualsAndHashCode(callSuper = false)
21 24
 @Accessors(chain = true)
22 25
 @ApiModel(value = "点位问题",description = "")
23
-@TableName("td_loc_question")
26
+@TableName("td_question")
24 27
 public class TdQuestion implements Serializable,Cloneable{
25
-    /** 问题ID */
26
-    @ApiModelProperty(name = "问题ID",notes = "")
27
-    @TableId(value = "qu_id", type = IdType.INPUT)
28
-    private String quId ;
29
-    /** 点位ID */
30
-    @ApiModelProperty(name = "点位ID",notes = "")
31
-    private String locId ;
32
-    /** 问题类型;radio 单选, fill 填空题 */
33
-    @ApiModelProperty(name = "问题类型",notes = "radio 单选, fill 填空题")
34
-    private String quType ;
35
-    /** 问题描述 */
36
-    @ApiModelProperty(name = "问题描述",notes = "")
37
-    private String title ;
38
-    /** 正确答案 */
39
-    @ApiModelProperty(name = "正确答案",notes = "")
40
-    private String rightAnswers ;
41
-    /** 状态 */
42
-    @ApiModelProperty(name = "状态",notes = "")
43
-    private Integer status ;
44
-    /** 创建时间 */
45
-    @ApiModelProperty(name = "创建时间",notes = "")
46
-    private LocalDateTime createDate ;
28
+     /** 问题ID */
29
+     @ApiModelProperty(name = "问题ID",notes = "")
30
+     @TableId(value = "qu_id", type = IdType.ASSIGN_UUID)
31
+     private String quId ;
32
+     /** 问题类型;radio 单选, fill 填空题 */
33
+     @ApiModelProperty(name = "问题类型",notes = "radio 单选, fill 填空题")
34
+     private String quType ;
35
+     /** 问题描述 */
36
+     @ApiModelProperty(name = "问题描述",notes = "")
37
+     private String title ;
38
+     /** 正确答案 */
39
+     @ApiModelProperty(name = "正确答案",notes = "")
40
+     private String rightAnswers ;
41
+     /** 状态 */
42
+     @ApiModelProperty(name = "状态",notes = "")
43
+     private Integer status ;
44
+     /** 创建时间 */
45
+     @ApiModelProperty(name = "创建时间",notes = "")
46
+     private LocalDateTime createDate ;
47 47
 
48
+     /**
49
+      * 问题答案列表
50
+      */
51
+     @TableField(exist = false)
52
+     List<TdQuAnswer> quAnswerList;
48 53
 }

+ 15
- 3
src/main/java/com/example/civilizedcity/mapper/TaCheckAnswerItemMapper.java Просмотреть файл

@@ -5,12 +5,24 @@ import org.apache.ibatis.annotations.Mapper;
5 5
 import org.apache.ibatis.annotations.Param;
6 6
 import com.example.civilizedcity.entity.TaCheckAnswerItem;
7 7
 
8
- /**
8
+import java.util.List;
9
+
10
+/**
9 11
  * 测评作答详情;(ta_check_answer_item)表数据库访问层
12
+ *
10 13
  * @author : http://njyunzhi.com
11 14
  * @date : 2022-12-13
12 15
  */
13 16
 @Mapper
14
-public interface TaCheckAnswerItemMapper  extends BaseMapper<TaCheckAnswerItem>{
15
-    
17
+public interface TaCheckAnswerItemMapper extends BaseMapper<TaCheckAnswerItem> {
18
+
19
+    List<TaCheckAnswerItem> getListBy(@Param("answerId") String answerId);
20
+
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);
26
+
27
+    List<TaCheckAnswerItem> getListByAnswer(@Param("answerId") String answerId);
16 28
 }

+ 15
- 3
src/main/java/com/example/civilizedcity/mapper/TaCheckAnswerMapper.java Просмотреть файл

@@ -5,12 +5,24 @@ import org.apache.ibatis.annotations.Mapper;
5 5
 import org.apache.ibatis.annotations.Param;
6 6
 import com.example.civilizedcity.entity.TaCheckAnswer;
7 7
 
8
- /**
8
+import java.util.List;
9
+
10
+/**
9 11
  * 测评作答;(ta_check_answer)表数据库访问层
12
+ *
10 13
  * @author : http://njyunzhi.com
11 14
  * @date : 2022-12-13
12 15
  */
13 16
 @Mapper
14
-public interface TaCheckAnswerMapper  extends BaseMapper<TaCheckAnswer>{
15
-    
17
+public interface TaCheckAnswerMapper extends BaseMapper<TaCheckAnswer> {
18
+
19
+    Integer countByItem(@Param("itemId") String itemId);
20
+
21
+    List<TaCheckAnswer> getListBy(@Param("itemId") String itemId);
22
+
23
+    Double sumScore(@Param("itemId") String itemId, @Param("num") Integer num);
24
+
25
+    int getCountByUser(@Param("itemId") String itemId, @Param("userId") String userId);
26
+
27
+    List<TaCheckAnswer> getByUser(@Param("itemId") String itemId, @Param("userId") String userId);
16 28
 }

+ 9
- 3
src/main/java/com/example/civilizedcity/mapper/TaCheckItemAnMapper.java Просмотреть файл

@@ -5,12 +5,18 @@ import org.apache.ibatis.annotations.Mapper;
5 5
 import org.apache.ibatis.annotations.Param;
6 6
 import com.example.civilizedcity.entity.TaCheckItemAn;
7 7
 
8
- /**
8
+import java.util.List;
9
+
10
+/**
9 11
  * 项目问题答案;(ta_check_item_an)表数据库访问层
12
+ *
10 13
  * @author : http://njyunzhi.com
11 14
  * @date : 2022-12-16
12 15
  */
13 16
 @Mapper
14
-public interface TaCheckItemAnMapper  extends BaseMapper<TaCheckItemAn>{
15
-    
17
+public interface TaCheckItemAnMapper extends BaseMapper<TaCheckItemAn> {
18
+
19
+    List<TaCheckItemAn> getListBy(@Param("quId") String quId);
20
+
21
+    TaCheckItemAn getOneBy(@Param("quId") String quId, @Param("answerCode") String answerCode);
16 22
 }

+ 14
- 3
src/main/java/com/example/civilizedcity/mapper/TaCheckItemMapper.java Просмотреть файл

@@ -1,16 +1,27 @@
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.SysUser;
4 6
 import org.apache.ibatis.annotations.Mapper;
5 7
 import org.apache.ibatis.annotations.Param;
6 8
 import com.example.civilizedcity.entity.TaCheckItem;
7 9
 
8
- /**
10
+import java.util.List;
11
+
12
+/**
9 13
  * 测评点位;(ta_check_item)表数据库访问层
10 14
  * @author : http://njyunzhi.com
11 15
  * @date : 2022-12-13
12 16
  */
13 17
 @Mapper
14 18
 public interface TaCheckItemMapper  extends BaseMapper<TaCheckItem>{
15
-    
16
-}
19
+
20
+     IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg,
21
+                                  @Param("checkId") String checkId,
22
+                                  @Param("itemType") String itemType);
23
+
24
+     int createNewLocItems(@Param("checkId") String checkId);
25
+
26
+     List<TaCheckItem> getListBy(@Param("checkId") String checkId, @Param("itemType") String itemType);
27
+ }

+ 8
- 3
src/main/java/com/example/civilizedcity/mapper/TaCheckItemQuMapper.java Просмотреть файл

@@ -5,12 +5,17 @@ import org.apache.ibatis.annotations.Mapper;
5 5
 import org.apache.ibatis.annotations.Param;
6 6
 import com.example.civilizedcity.entity.TaCheckItemQu;
7 7
 
8
- /**
8
+import java.util.List;
9
+
10
+/**
9 11
  * 点位问题;(ta_check_item_qu)表数据库访问层
10 12
  * @author : http://njyunzhi.com
11 13
  * @date : 2022-12-13
12 14
  */
13 15
 @Mapper
14 16
 public interface TaCheckItemQuMapper  extends BaseMapper<TaCheckItemQu>{
15
-    
16
-}
17
+
18
+     Integer countByItem(@Param("itemId") String itemId);
19
+
20
+     List<TaCheckItemQu> getListBy(@Param("itemId") String itemId);
21
+ }

+ 8
- 3
src/main/java/com/example/civilizedcity/service/TaCheckAnswerItemService.java Просмотреть файл

@@ -1,13 +1,18 @@
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
-    
14
+
15
+     List<TaCheckAnswerItem> getListBy(String quId, Boolean isMine, SysUser sysUser);
16
+
17
+    List<TaCheckAnswerItem> getListByAnswer(String answerId);
13 18
 }

+ 10
- 2
src/main/java/com/example/civilizedcity/service/TaCheckAnswerService.java Просмотреть файл

@@ -3,11 +3,19 @@ package com.example.civilizedcity.service;
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.example.civilizedcity.entity.TaCheckAnswer;
5 5
 
6
- /**
6
+import java.util.List;
7
+
8
+/**
7 9
  * 测评作答;(ta_check_answer)表服务接口
10
+ *
8 11
  * @author : http://njyunzhi.com
9 12
  * @date : 2022-12-13
10 13
  */
11 14
 public interface TaCheckAnswerService extends IBaseService<TaCheckAnswer> {
12
-    
15
+
16
+    int getCountByUser(String itemId, String userId);
17
+
18
+    int countByItem(String itemId);
19
+
20
+    List<TaCheckAnswer> getByUser(String itemId, String userId);
13 21
 }

+ 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
  }

+ 11
- 3
src/main/java/com/example/civilizedcity/service/TaCheckItemService.java Просмотреть файл

@@ -1,6 +1,9 @@
1 1
 package com.example.civilizedcity.service;
2 2
 
3
-import com.baomidou.mybatisplus.extension.service.IService;
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.example.civilizedcity.entity.SysUser;
5
+import com.example.civilizedcity.entity.TaCheck;
6
+import com.example.civilizedcity.entity.TaCheckAnswer;
4 7
 import com.example.civilizedcity.entity.TaCheckItem;
5 8
 
6 9
  /**
@@ -9,5 +12,10 @@ import com.example.civilizedcity.entity.TaCheckItem;
9 12
  * @date : 2022-12-13
10 13
  */
11 14
 public interface TaCheckItemService extends IBaseService<TaCheckItem> {
12
-    
13
-}
15
+
16
+     IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, String checkId, String itemType);
17
+
18
+     void createNewItems(TaCheck taCheck);
19
+
20
+     void answer(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer) throws Exception;
21
+ }

+ 3
- 2
src/main/java/com/example/civilizedcity/service/TaCheckService.java Просмотреть файл

@@ -8,5 +8,6 @@ import com.example.civilizedcity.entity.TaCheck;
8 8
  * @date : 2022-12-12
9 9
  */
10 10
 public interface TaCheckService extends IBaseService<TaCheck> {
11
-    
12
-}
11
+
12
+     TaCheck calcScore(TaCheck taCheck);
13
+ }

+ 8
- 2
src/main/java/com/example/civilizedcity/service/TdQuAnswerService.java Просмотреть файл

@@ -1,12 +1,18 @@
1 1
 package com.example.civilizedcity.service;
2 2
 
3
+import com.example.civilizedcity.entity.TaCheckItemAn;
3 4
 import com.example.civilizedcity.entity.TdQuAnswer;
4 5
 
5
- /**
6
+import java.util.List;
7
+
8
+/**
6 9
  * 点位问题答案;(td_loc_qu_answer)表服务接口
10
+ *
7 11
  * @author : http://njyunzhi.com
8 12
  * @date : 2022-12-13
9 13
  */
10 14
 public interface TdQuAnswerService extends IBaseService<TdQuAnswer> {
11
-    
15
+    boolean mergeData(String quId, List<TdQuAnswer> quAnswerList);
16
+
17
+    List<TdQuAnswer> getListByQuId(String quId);
12 18
 }

+ 16
- 3
src/main/java/com/example/civilizedcity/service/impl/TaCheckAnswerItemServiceImpl.java Просмотреть файл

@@ -1,16 +1,29 @@
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
+    }
24
+
25
+    @Override
26
+    public List<TaCheckAnswerItem> getListByAnswer(String answerId) {
27
+        return baseMapper.getListByAnswer(answerId);
28
+    }
16 29
 }

+ 20
- 2
src/main/java/com/example/civilizedcity/service/impl/TaCheckAnswerServiceImpl.java Просмотреть файл

@@ -5,12 +5,30 @@ import org.springframework.stereotype.Service;
5 5
 import com.example.civilizedcity.entity.TaCheckAnswer;
6 6
 import com.example.civilizedcity.mapper.TaCheckAnswerMapper;
7 7
 import com.example.civilizedcity.service.TaCheckAnswerService;
8
- /**
8
+
9
+import java.util.List;
10
+
11
+/**
9 12
  * 测评作答;(ta_check_answer)表服务实现类
13
+ *
10 14
  * @author : http://www.chiner.pro
11 15
  * @date : 2022-12-13
12 16
  */
13 17
 @Service
14 18
 public class TaCheckAnswerServiceImpl extends BaseServiceImpl<TaCheckAnswerMapper, TaCheckAnswer> implements TaCheckAnswerService {
15
-    
19
+
20
+    @Override
21
+    public int getCountByUser(String itemId, String userId) {
22
+        return baseMapper.getCountByUser(itemId, userId);
23
+    }
24
+
25
+    @Override
26
+    public int countByItem(String itemId) {
27
+        return baseMapper.countByItem(itemId);
28
+    }
29
+
30
+    @Override
31
+    public List<TaCheckAnswer> getByUser(String itemId, String userId) {
32
+        return baseMapper.getByUser(itemId, userId);
33
+    }
16 34
 }

+ 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
 }

+ 181
- 4
src/main/java/com/example/civilizedcity/service/impl/TaCheckItemServiceImpl.java Просмотреть файл

@@ -1,16 +1,193 @@
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.*;
7
+import com.example.civilizedcity.mapper.*;
3 8
 import org.springframework.beans.factory.annotation.Autowired;
4 9
 import org.springframework.stereotype.Service;
5
-import com.example.civilizedcity.entity.TaCheckItem;
6
-import com.example.civilizedcity.mapper.TaCheckItemMapper;
7 10
 import com.example.civilizedcity.service.TaCheckItemService;
8
- /**
11
+import org.springframework.transaction.annotation.Transactional;
12
+
13
+import java.time.LocalDateTime;
14
+import java.util.List;
15
+
16
+/**
9 17
  * 测评点位;(ta_check_item)表服务实现类
18
+ *
10 19
  * @author : http://www.chiner.pro
11 20
  * @date : 2022-12-13
12 21
  */
13 22
 @Service
14 23
 public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, TaCheckItem> implements TaCheckItemService {
15
-    
24
+
25
+    @Autowired
26
+    TaCheckItemQuMapper taCheckItemQuMapper;
27
+
28
+    @Autowired
29
+    TaCheckItemAnMapper taCheckItemAnMapper;
30
+
31
+    @Autowired
32
+    TaCheckAnswerItemMapper taCheckAnswerItemMapper;
33
+
34
+    @Autowired
35
+    TaCheckAnswerMapper taCheckAnswerMapper;
36
+
37
+    @Autowired
38
+    TaAttachMapper taAttachMapper;
39
+
40
+    @Override
41
+    public IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, String checkId, String itemType) {
42
+        return baseMapper.getPageBy(pg, checkId, itemType);
43
+    }
44
+
45
+    @Override
46
+    public void createNewItems(TaCheck taCheck) {
47
+        // 先创建实地测试
48
+        baseMapper.createNewLocItems(taCheck.getCheckId());
49
+        // 再创建调查问卷
50
+        TaCheckItem taCheckItem = new TaCheckItem();
51
+        taCheckItem.setCheckId(taCheck.getCheckId());
52
+        taCheckItem.setItemType(Constants.CHECK_OF_SURVEY);
53
+        taCheckItem.setName("调查问卷");
54
+        save(taCheckItem);
55
+    }
56
+
57
+    @Transactional(rollbackFor = Exception.class)
58
+    @Override
59
+    public void answer(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer) throws Exception {
60
+        List<TaCheckItemQu> quList = taCheckItemQuMapper.getListBy(taCheckItem.getItemId());
61
+        if (null == quList || quList.size() < 1) {
62
+            throw new Exception("校验测评问题列表出错");
63
+        }
64
+
65
+        List<TaCheckAnswerItem> answerItemList = taCheckAnswer.getAnswerItemList();
66
+        if (null == answerItemList || answerItemList.size() != quList.size()) {
67
+            throw new Exception("未完成全部测评问题");
68
+        }
69
+
70
+        // 答案列表如果没有关联问题ID
71
+        long cnt = answerItemList.stream().filter(f -> null == f.getQuId()).count();
72
+        if (cnt > 0) {
73
+            throw new Exception("验证部分题干信息出错");
74
+        }
75
+
76
+        if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
77
+            // 如果是实地问卷, 试卷份数不能多于规定份数
78
+            int count = taCheckAnswerMapper.countByItem(taCheckItem.getItemId());
79
+            if (count >= taCheckItem.getNum()) {
80
+                throw new Exception("当前实地问卷已收齐, 无须作答");
81
+            }
82
+        }
83
+
84
+
85
+        double[] scores = answerItems(taCheckItem, taCheckAnswer, quList, answerItemList);
86
+
87
+        if (Constants.CHECK_OF_SURVEY.equals(taCheckItem.getItemType())) {
88
+            // 调查问卷不需要计算当前试卷的分数, 最后才能计算出来
89
+            taCheckAnswerMapper.insert(taCheckAnswer);
90
+
91
+            // 但是需要更新答卷份数
92
+            int count = taCheckAnswerMapper.countByItem(taCheckItem.getItemId());
93
+            taCheckItem.setNum(count);
94
+            updateById(taCheckItem);
95
+            return;
96
+        }
97
+
98
+        if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
99
+            // 实地调查, 需要计算当前这份试卷的份数
100
+            double positiveScore = scores[0];
101
+            double negativeScore = scores[1];
102
+
103
+            // 每份试卷的得分 = 总分 / 份数
104
+            double maxScore = taCheckItem.getFullScore()  / taCheckItem.getNum();
105
+            double totalScore = maxScore + negativeScore + positiveScore;
106
+
107
+            if (0 > totalScore) {
108
+                // 如果扣分项太多
109
+                totalScore = 0.0;
110
+            }
111
+            if (totalScore > maxScore) {
112
+                // 如果得分超过总分
113
+                totalScore = maxScore;
114
+            }
115
+
116
+            taCheckAnswer.setScore(totalScore);
117
+            taCheckAnswerMapper.insert(taCheckAnswer);
118
+        }
119
+    }
120
+
121
+    /**
122
+     * 计算每份试卷份数
123
+     * @param taCheckItem
124
+     * @param taCheckAnswer
125
+     * @throws Exception
126
+     */
127
+    private double[] answerItems(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer, List<TaCheckItemQu> quList, List<TaCheckAnswerItem> answerItemList) throws Exception {
128
+
129
+        LocalDateTime now = LocalDateTime.now();
130
+        double negativeScore = 0.0; // 扣分
131
+        double positiveScore = 0.0; // 得分
132
+        for(TaCheckAnswerItem item : answerItemList) {
133
+            // 找到对应的题目
134
+            TaCheckItemQu qu = getQu(quList, item.getQuId());
135
+            // + 代表得分, 否则代表扣分
136
+            int sign = "+".equals(qu.getComputeType()) ? 1 : -1;
137
+
138
+            double score = 0.0;
139
+            if (Constants.QU_OF_FILL.equals(qu.getQuType())) {
140
+                // 如果是填空题, 用户填的应该是数字, 没填就是 0
141
+                Double an = StringUtils.isEmpty(item.getAnswer()) ? 0.0 : Double.parseDouble(item.getAnswer());
142
+                score = an * qu.getAnScore();
143
+                if (score > qu.getMaxScore()) {
144
+                    score = qu.getMaxScore();
145
+                }
146
+
147
+                score *= sign;
148
+            } else if (Constants.QU_OF_RADIO.equals(qu.getQuType())) {
149
+                // 如果是选择题, 先找到对应的答案
150
+                TaCheckItemAn standAn = taCheckItemAnMapper.getOneBy(qu.getQuId(), item.getAnswerCode());
151
+
152
+                score = standAn.getScore();
153
+                if (score > qu.getMaxScore()) {
154
+                    score = qu.getMaxScore();
155
+                }
156
+
157
+                score *= sign;
158
+            }
159
+
160
+            item.setItemId(StringUtils.uuid());
161
+            item.setAnswerId(taCheckAnswer.getAnswerId());
162
+            item.setScore(score);
163
+            item.setCreateDate(now);
164
+            item.setCreateUser(taCheckAnswer.getCreateUser());
165
+            item.setStatus(Constants.STATUS_NORMAL);
166
+            taCheckAnswerItemMapper.insert(item);
167
+
168
+            if (score > 0) {
169
+                positiveScore += score;
170
+            } else {
171
+                negativeScore += score;
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
+            }
185
+        }
186
+
187
+        return new double[] {positiveScore, negativeScore};
188
+    }
189
+
190
+    private TaCheckItemQu getQu(List<TaCheckItemQu> quList, String quId) {
191
+        return quList.stream().filter(q -> q.getQuId().equals(quId)).findFirst().orElse(null);
192
+    }
16 193
 }

+ 153
- 4
src/main/java/com/example/civilizedcity/service/impl/TaCheckServiceImpl.java Просмотреть файл

@@ -1,15 +1,164 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3
+import com.example.civilizedcity.common.Constants;
4
+import com.example.civilizedcity.common.StringUtils;
5
+import com.example.civilizedcity.entity.*;
6
+import com.example.civilizedcity.mapper.*;
7
+import org.springframework.beans.factory.annotation.Autowired;
3 8
 import org.springframework.stereotype.Service;
4
-import com.example.civilizedcity.entity.TaCheck;
5
-import com.example.civilizedcity.mapper.TaCheckMapper;
6 9
 import com.example.civilizedcity.service.TaCheckService;
7
- /**
10
+import org.springframework.transaction.annotation.Transactional;
11
+
12
+import java.util.List;
13
+
14
+/**
8 15
  * 模拟测评;(ta_mock_check)表服务实现类
16
+ *
9 17
  * @author : http://www.chiner.pro
10 18
  * @date : 2022-12-12
11 19
  */
12 20
 @Service
13 21
 public class TaCheckServiceImpl extends BaseServiceImpl<TaCheckMapper, TaCheck> implements TaCheckService {
14
-    
22
+
23
+    @Autowired
24
+    TaCheckItemMapper taCheckItemMapper;
25
+
26
+    @Autowired
27
+    TaCheckItemQuMapper taCheckItemQuMapper;
28
+
29
+    @Autowired
30
+    TaCheckAnswerMapper taCheckAnswerMapper;
31
+
32
+    @Autowired
33
+    TaCheckAnswerItemMapper taCheckAnswerItemMapper;
34
+
35
+    @Transactional(rollbackFor = Exception.class)
36
+    @Override
37
+    public TaCheck calcScore(TaCheck taCheck) {
38
+
39
+        // 调查问卷分数
40
+        double surveyScore = calcSurveyScore(taCheck);
41
+
42
+        // 计算点位分数
43
+        double locScore = calcLocScore(taCheck);
44
+
45
+        taCheck.setLocScore(locScore);
46
+        taCheck.setSurveyScore(surveyScore);
47
+
48
+        updateById(taCheck);
49
+
50
+        return taCheck;
51
+    }
52
+
53
+    /**
54
+     * 计算点位分数
55
+     * 计算的前提是, 每份试卷(ta_check_answer)的分数已经计算好了
56
+     * @param taCheck
57
+     * @return
58
+     */
59
+    private double calcLocScore(TaCheck taCheck) {
60
+        List<TaCheckItem> checkItemList = taCheckItemMapper.getListBy(taCheck.getCheckId(), Constants.CHECK_OF_LOC);
61
+        if (null == checkItemList || checkItemList.size() == 0) return 0.0;
62
+
63
+        // 所有问卷得分的和
64
+        double totalScore = 0.0;
65
+        for (TaCheckItem checkItem : checkItemList) {
66
+            Double score = taCheckAnswerMapper.sumScore(checkItem.getItemId(), checkItem.getNum());
67
+            double s = null == score ? 0.0 : score;
68
+            checkItem.setScore(s);
69
+            taCheckItemMapper.updateById(checkItem);
70
+
71
+            totalScore += s;
72
+        }
73
+
74
+        return totalScore;
75
+    }
76
+
77
+    /**
78
+     * 计算调查问卷分数
79
+     * 计算的前提是, 每个题目(ta_check_answer_item)的分数已经计算好了
80
+     * 暂仅支持选择题算法
81
+     * 总分数 = 100 / 问卷分数 / 每份问卷的题数
82
+     * @param taCheck
83
+     * @return
84
+     */
85
+    private double calcSurveyScore(TaCheck taCheck) {
86
+        // 目前的需求, 此处应该只能查询到一条数据
87
+        List<TaCheckItem> checkItemList = taCheckItemMapper.getListBy(taCheck.getCheckId(), Constants.CHECK_OF_SURVEY);
88
+        if (null == checkItemList || checkItemList.size() == 0) return 0.0;
89
+
90
+        // 所有问卷得分的和
91
+        double totalScore = 0.0;
92
+        for (TaCheckItem checkItem : checkItemList) {
93
+            // 问卷份数
94
+            List<TaCheckAnswer> answerList = taCheckAnswerMapper.getListBy(checkItem.getItemId());
95
+            if (answerList == null || answerList.size() == 0) continue;
96
+            int copyNum = answerList.size();
97
+
98
+            // 题目数
99
+            List<TaCheckItemQu> quList = taCheckItemQuMapper.getListBy(checkItem.getItemId());
100
+            if (quList == null || quList.size() == 0) continue;
101
+            int quNum = quList.size();
102
+
103
+            // 每题的最大分数
104
+            double maxStandScore = 100.00 / copyNum / quNum;
105
+
106
+            // 总分
107
+            double score = 0.0;
108
+            for (TaCheckAnswer answer : answerList) {
109
+                // 获取答案列表
110
+                List<TaCheckAnswerItem> answerItemList = taCheckAnswerItemMapper.getListBy(answer.getAnswerId());
111
+                if (null == answerItemList || answerItemList.size() == 0) continue;
112
+
113
+                // 每题得分
114
+                double quScore = 0.0;
115
+                for (TaCheckAnswerItem answerItem : answerItemList) {
116
+                    if (null == answerItem.getScore() || isZero(answerItem.getScore())) {
117
+                        // 如果得分是 0
118
+                        continue;
119
+                    }
120
+
121
+                    // 查询对应的问题
122
+                    TaCheckItemQu qu = getQu(quList, answerItem.getQuId());
123
+                    if (null == qu) continue;   // 找不到对应题目不计算
124
+                    if (null == qu.getMaxScore() || isZero(qu.getMaxScore())) continue; // 题目没有维护最大分数, 不计算
125
+
126
+                    // 计算转换比
127
+                    double ratio = maxStandScore / qu.getMaxScore();
128
+
129
+                    // 当前得分
130
+                    double s = Math.abs(answerItem.getScore()) > qu.getMaxScore() ?  qu.getMaxScore() : answerItem.getScore();
131
+                    if (answerItem.getScore() < 0) {
132
+                        // 在与最大值的比较过程中, 最大值是正数, 有可能改变得分的符号
133
+                        // 所以此处要纠正过来
134
+                        s = 0 - Math.abs(s);
135
+                    }
136
+
137
+                    // 分值
138
+                    quScore += s * ratio;
139
+                }
140
+
141
+                answer.setScore(quScore);
142
+                taCheckAnswerMapper.updateById(answer);
143
+
144
+                // 分值
145
+                score += quScore;
146
+            }
147
+
148
+            checkItem.setScore(score);
149
+            taCheckItemMapper.updateById(checkItem);
150
+
151
+            totalScore += score;
152
+        }
153
+
154
+        return totalScore;
155
+    }
156
+
157
+    private TaCheckItemQu getQu(List<TaCheckItemQu> quList, String quId) {
158
+        return quList.stream().filter(q -> q.getQuId().equals(quId)).findFirst().orElse(null);
159
+    }
160
+
161
+    private boolean isZero(Double d) {
162
+        return Math.abs(d) < 0.0001;
163
+    }
15 164
 }

+ 44
- 2
src/main/java/com/example/civilizedcity/service/impl/TdQuAnswerServiceImpl.java Просмотреть файл

@@ -1,15 +1,57 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.example.civilizedcity.common.Constants;
5
+import com.example.civilizedcity.common.StringUtils;
6
+import com.example.civilizedcity.entity.TaCheckItemAn;
3 7
 import org.springframework.stereotype.Service;
4 8
 import com.example.civilizedcity.entity.TdQuAnswer;
5 9
 import com.example.civilizedcity.mapper.TdQuAnswerMapper;
6 10
 import com.example.civilizedcity.service.TdQuAnswerService;
7
- /**
11
+
12
+import java.util.HashMap;
13
+import java.util.List;
14
+
15
+/**
8 16
  * 点位问题答案;(td_loc_qu_answer)表服务实现类
17
+ *
9 18
  * @author : http://www.chiner.pro
10 19
  * @date : 2022-12-13
11 20
  */
12 21
 @Service
13 22
 public class TdQuAnswerServiceImpl extends BaseServiceImpl<TdQuAnswerMapper, TdQuAnswer> implements TdQuAnswerService {
14
-    
23
+
24
+    @Override
25
+    public boolean mergeData(String quId, List<TdQuAnswer> quAnswerList) {
26
+        if (StringUtils.isEmpty(quId)) return false;
27
+
28
+        // 先删除所有
29
+        baseMapper.deleteByMap(new HashMap<String, Object>() {{
30
+            put("qu_id", quId);
31
+        }});
32
+
33
+        if (null == quAnswerList || quAnswerList.isEmpty()) {
34
+            return true;
35
+        }
36
+
37
+        for (int i = 0; i < quAnswerList.size(); i++) {
38
+            TdQuAnswer item = quAnswerList.get(i);
39
+            item.setQuId(quId);
40
+            // 重新排序
41
+            item.setSortNo(i + 1);
42
+            save(item);
43
+        }
44
+
45
+        return true;
46
+    }
47
+
48
+    @Override
49
+    public List<TdQuAnswer> getListByQuId(String quId) {
50
+        QueryWrapper<TdQuAnswer> queryWrapper = new QueryWrapper<>();
51
+        queryWrapper.eq("qu_id", quId);
52
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
53
+        queryWrapper.orderByAsc("sort_no");
54
+
55
+        return list(queryWrapper);
56
+    }
15 57
 }

+ 5
- 2
src/main/java/com/example/civilizedcity/service/impl/TdQuestionServiceImpl.java Просмотреть файл

@@ -1,5 +1,8 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.example.civilizedcity.entity.TaCheckItemQu;
5
+import com.example.civilizedcity.entity.TdQuAnswer;
3 6
 import org.springframework.stereotype.Service;
4 7
 import com.example.civilizedcity.entity.TdQuestion;
5 8
 import com.example.civilizedcity.mapper.TdQuestionMapper;
@@ -11,5 +14,5 @@ import com.example.civilizedcity.service.TdQuestionService;
11 14
  */
12 15
 @Service
13 16
 public class TdQuestionServiceImpl extends BaseServiceImpl<TdQuestionMapper, TdQuestion> implements TdQuestionService {
14
-    
15
-}
17
+
18
+ }

+ 4
- 1
src/main/resources/application.yml Просмотреть файл

@@ -5,7 +5,7 @@ server:
5 5
 
6 6
 spring:
7 7
   datasource:
8
-    url: jdbc:mysql://110.40.183.156:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
8
+    url: jdbc:mysql://110.40.183.156:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true
9 9
     username: civilizedcity
10 10
     password: civilizedcity@ABCD1234
11 11
   mvc:
@@ -20,6 +20,9 @@ spring:
20 20
 
21 21
 ###
22 22
 yz:
23
+  upload:
24
+    path: E:\work\public-upload
25
+    prefix: http://127.0.0.1:8000
23 26
   filter:
24 27
     annList:
25 28
       - "/swagger-ui/**"

+ 43
- 1
src/main/resources/mapper/TaCheckAnswerItemMapper.xml Просмотреть файл

@@ -2,5 +2,47 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4 4
 <mapper namespace="com.example.civilizedcity.mapper.TaCheckAnswerItemMapper">
5
-    
5
+
6
+    <select id="getListBy" resultType="com.example.civilizedcity.entity.TaCheckAnswerItem">
7
+        SELECT
8
+            *
9
+        FROM
10
+            ta_check_answer_item t
11
+        WHERE
12
+            t.answer_id = #{answerId}
13
+          AND t.`status` &gt; -1
14
+    </select>
15
+    <select id="getCountByAnswer" resultType="java.lang.Integer">
16
+        SELECT
17
+            count(*)
18
+        FROM
19
+            ta_check_answer_item t
20
+        WHERE
21
+            t.answer_id = #{answerId}
22
+          AND t.`status` &gt; -1
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>
39
+    <select id="getListByAnswer" resultType="com.example.civilizedcity.entity.TaCheckAnswerItem">
40
+        SELECT
41
+            *
42
+        FROM
43
+            ta_check_answer_item t
44
+        WHERE
45
+            t.answer_id = #{answerId}
46
+          AND t.`status` &gt; -1
47
+    </select>
6 48
 </mapper>

+ 51
- 1
src/main/resources/mapper/TaCheckAnswerMapper.xml Просмотреть файл

@@ -2,5 +2,55 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4 4
 <mapper namespace="com.example.civilizedcity.mapper.TaCheckAnswerMapper">
5
-    
5
+
6
+    <select id="countByItem" resultType="java.lang.Integer">
7
+        SELECT
8
+            count( 1 )
9
+        FROM
10
+            ta_check_answer t
11
+        WHERE
12
+            t.item_id = #{itemId}
13
+          AND t.`status` &gt; -1
14
+    </select>
15
+    <select id="getListBy" resultType="com.example.civilizedcity.entity.TaCheckAnswer">
16
+        SELECT
17
+            *
18
+        FROM
19
+            ta_check_answer t
20
+        WHERE
21
+            t.item_id = #{itemId}
22
+          AND t.`status` &gt; -1
23
+    </select>
24
+    <select id="sumScore" resultType="java.lang.Double">
25
+        SELECT
26
+            sum( t.score )
27
+        FROM
28
+            ta_check_answer t
29
+        WHERE
30
+            t.item_id = #{itemId}
31
+          AND t.`status` &gt; - 1
32
+        ORDER BY
33
+            t.create_date ASC
34
+        LIMIT #{num}
35
+    </select>
36
+    <select id="getCountByUser" resultType="java.lang.Integer">
37
+        SELECT
38
+            count( 1 )
39
+        FROM
40
+            ta_check_answer t
41
+        WHERE
42
+            t.item_id = #{itemId}
43
+          AND t.create_user = #{userId}
44
+          AND t.`status` &gt; -1
45
+    </select>
46
+    <select id="getByUser" resultType="com.example.civilizedcity.entity.TaCheckAnswer">
47
+        SELECT
48
+            *
49
+        FROM
50
+            ta_check_answer t
51
+        WHERE
52
+            t.item_id = #{itemId}
53
+          AND t.create_user = #{userId}
54
+          AND t.`status` &gt; -1
55
+    </select>
6 56
 </mapper>

+ 21
- 1
src/main/resources/mapper/TaCheckItemAnMapper.xml Просмотреть файл

@@ -2,5 +2,25 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4 4
 <mapper namespace="com.example.civilizedcity.mapper.TaCheckItemAnMapper">
5
-    
5
+
6
+    <select id="getListBy" resultType="com.example.civilizedcity.entity.TaCheckItemAn">
7
+        SELECT
8
+            *
9
+        FROM
10
+            ta_check_item_an t
11
+        WHERE
12
+            t.qu_id = #{quId}
13
+        ORDER BY
14
+            t.sort_no ASC
15
+    </select>
16
+    <select id="getOneBy" resultType="com.example.civilizedcity.entity.TaCheckItemAn">
17
+        SELECT
18
+            *
19
+        FROM
20
+            ta_check_item_an t
21
+        WHERE
22
+            t.qu_id = #{quId}
23
+          AND t.answer_code = #{answerCode}
24
+        LIMIT 1
25
+    </select>
6 26
 </mapper>

+ 59
- 1
src/main/resources/mapper/TaCheckItemMapper.xml Просмотреть файл

@@ -2,5 +2,63 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4 4
 <mapper namespace="com.example.civilizedcity.mapper.TaCheckItemMapper">
5
-    
5
+    <insert id="createNewLocItems">
6
+        INSERT INTO ta_check_item (item_id, check_id, item_type, type_id, `name`)
7
+        SELECT
8
+            UUID_SHORT(),
9
+            #{checkId},
10
+            'loc',
11
+            t.type_id,
12
+            t.`name`
13
+        FROM
14
+            td_loc_type t
15
+        WHERE
16
+            t.`status` &gt; -1
17
+        ORDER BY
18
+            t.sort_no ASC
19
+    </insert>
20
+
21
+    <select id="getPageBy" resultType="com.example.civilizedcity.entity.TaCheckItem">
22
+        SELECT
23
+            IFNULL(m.num, 0) as answer_num,
24
+            t.*
25
+        FROM
26
+            ta_check_item t
27
+            INNER JOIN ta_check c ON c.check_id = t.check_id
28
+            <if test="itemType != null and itemType == 'loc'">
29
+                INNER JOIN td_loc_type s ON t.type_id = s.type_id
30
+            </if>
31
+            LEFT JOIN (
32
+                SELECT
33
+                    a.item_id,
34
+                    COUNT( * ) AS num
35
+                FROM
36
+                    ta_check_answer a
37
+                WHERE
38
+                    a.check_id = #{checkId}
39
+                GROUP BY
40
+                    a.item_id
41
+            ) m ON m.item_id = t.item_id
42
+        WHERE
43
+            t.check_id = #{checkId}
44
+          AND t.item_type = #{itemType}
45
+          AND t.`status` &gt; -1
46
+        ORDER BY
47
+        <if test="itemType != null and itemType == 'loc'">
48
+            s.sort_no ASC
49
+        </if>
50
+        <if test="itemType != null and itemType != 'loc'">
51
+            t.create_date ASC
52
+        </if>
53
+    </select>
54
+    <select id="getListBy" resultType="com.example.civilizedcity.entity.TaCheckItem">
55
+        SELECT
56
+            t.*
57
+        FROM
58
+            ta_check_item t
59
+        WHERE
60
+            t.check_id = #{checkId}
61
+          AND t.item_type = #{itemType}
62
+          AND t.`status` &gt; -1
63
+    </select>
6 64
 </mapper>

+ 18
- 1
src/main/resources/mapper/TaCheckItemQuMapper.xml Просмотреть файл

@@ -2,5 +2,22 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4 4
 <mapper namespace="com.example.civilizedcity.mapper.TaCheckItemQuMapper">
5
-    
5
+
6
+    <select id="countByItem" resultType="java.lang.Integer">
7
+        SELECT
8
+            count( 1 )
9
+        FROM
10
+            ta_check_item_qu t
11
+        WHERE
12
+            t.item_id = #{itemId}
13
+    </select>
14
+    <select id="getListBy" resultType="com.example.civilizedcity.entity.TaCheckItemQu">
15
+        SELECT
16
+            *
17
+        FROM
18
+            ta_check_item_qu t
19
+        WHERE
20
+            t.item_id = #{itemId}
21
+        ORDER BY t.sort_no ASC
22
+    </select>
6 23
 </mapper>