Yansen 2 lat temu
rodzic
commit
0a573c7f9c

db/.back_文明创办/文明创办-backup-2023131111551.pdma.json → db/.back_文明创办/文明创办-backup-2023131183934.pdma.json Wyświetl plik

@@ -4,7 +4,7 @@
4 4
   "avatar": "",
5 5
   "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-1-31 11:14:31",
7
+  "updatedTime": "2023-1-31 18:39:19",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -1214,7 +1214,7 @@
1214 1214
           "primaryKey": false,
1215 1215
           "notNull": false,
1216 1216
           "autoIncrement": false,
1217
-          "defaultValue": "",
1217
+          "defaultValue": "1",
1218 1218
           "hideInGraph": false,
1219 1219
           "refDict": "",
1220 1220
           "extProps": {},
@@ -8631,6 +8631,158 @@
8631 8631
       ],
8632 8632
       "correlations": [],
8633 8633
       "indexes": []
8634
+    },
8635
+    {
8636
+      "id": "78C3BB38-9B37-445B-A311-168B4682FE5E",
8637
+      "env": {
8638
+        "base": {
8639
+          "nameSpace": "",
8640
+          "codeRoot": ""
8641
+        }
8642
+      },
8643
+      "defKey": "ts_stat_data",
8644
+      "defName": "常用统计",
8645
+      "comment": "",
8646
+      "properties": {},
8647
+      "nameTemplate": "{defKey}[{defName}]",
8648
+      "headers": [
8649
+        {
8650
+          "refKey": "hideInGraph",
8651
+          "hideInGraph": true
8652
+        },
8653
+        {
8654
+          "refKey": "defKey",
8655
+          "hideInGraph": false
8656
+        },
8657
+        {
8658
+          "refKey": "defName",
8659
+          "hideInGraph": false
8660
+        },
8661
+        {
8662
+          "refKey": "primaryKey",
8663
+          "hideInGraph": false
8664
+        },
8665
+        {
8666
+          "refKey": "notNull",
8667
+          "hideInGraph": true
8668
+        },
8669
+        {
8670
+          "refKey": "autoIncrement",
8671
+          "hideInGraph": true
8672
+        },
8673
+        {
8674
+          "refKey": "domain",
8675
+          "hideInGraph": true
8676
+        },
8677
+        {
8678
+          "refKey": "type",
8679
+          "hideInGraph": false
8680
+        },
8681
+        {
8682
+          "refKey": "len",
8683
+          "hideInGraph": false
8684
+        },
8685
+        {
8686
+          "refKey": "scale",
8687
+          "hideInGraph": false
8688
+        },
8689
+        {
8690
+          "refKey": "comment",
8691
+          "hideInGraph": true
8692
+        },
8693
+        {
8694
+          "refKey": "refDict",
8695
+          "hideInGraph": true
8696
+        },
8697
+        {
8698
+          "refKey": "defaultValue",
8699
+          "hideInGraph": true
8700
+        },
8701
+        {
8702
+          "refKey": "isStandard",
8703
+          "hideInGraph": false
8704
+        },
8705
+        {
8706
+          "refKey": "uiHint",
8707
+          "hideInGraph": true
8708
+        },
8709
+        {
8710
+          "refKey": "extProps",
8711
+          "hideInGraph": true
8712
+        }
8713
+      ],
8714
+      "fields": [
8715
+        {
8716
+          "defKey": "stat_no",
8717
+          "defName": "序号",
8718
+          "comment": "",
8719
+          "type": "",
8720
+          "len": "",
8721
+          "scale": "",
8722
+          "primaryKey": true,
8723
+          "notNull": true,
8724
+          "autoIncrement": true,
8725
+          "defaultValue": "",
8726
+          "hideInGraph": true,
8727
+          "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
8728
+          "refDict": "",
8729
+          "uiHint": "",
8730
+          "id": "E7763878-4C25-476F-8C26-56BF7E0A9F35"
8731
+        },
8732
+        {
8733
+          "defKey": "stat_type",
8734
+          "defName": "统计类型",
8735
+          "comment": "",
8736
+          "type": "",
8737
+          "len": "",
8738
+          "scale": "",
8739
+          "primaryKey": false,
8740
+          "notNull": false,
8741
+          "autoIncrement": false,
8742
+          "defaultValue": "",
8743
+          "hideInGraph": false,
8744
+          "refDict": "",
8745
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
8746
+          "id": "49707BF9-E174-4ABA-8527-2C6A0996FE43",
8747
+          "uiHint": ""
8748
+        },
8749
+        {
8750
+          "defKey": "name",
8751
+          "defName": "指标名称",
8752
+          "comment": "",
8753
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
8754
+          "type": "",
8755
+          "len": "",
8756
+          "scale": "",
8757
+          "primaryKey": false,
8758
+          "notNull": false,
8759
+          "autoIncrement": false,
8760
+          "defaultValue": "1",
8761
+          "hideInGraph": true,
8762
+          "refDict": "",
8763
+          "uiHint": "",
8764
+          "id": "22B03E6C-E6FD-4D4F-855B-87E5F8EF79BF"
8765
+        },
8766
+        {
8767
+          "defKey": "value",
8768
+          "defName": "统计值",
8769
+          "comment": "",
8770
+          "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
8771
+          "type": "",
8772
+          "len": "",
8773
+          "scale": "",
8774
+          "primaryKey": false,
8775
+          "notNull": false,
8776
+          "autoIncrement": false,
8777
+          "defaultValue": "",
8778
+          "hideInGraph": true,
8779
+          "refDict": "",
8780
+          "uiHint": "",
8781
+          "id": "5DC510CC-D45C-42D4-AEED-5AD9130E0D88"
8782
+        }
8783
+      ],
8784
+      "correlations": [],
8785
+      "indexes": []
8634 8786
     }
8635 8787
   ],
8636 8788
   "views": [],
@@ -9066,6 +9218,17 @@
9066 9218
       "refDiagrams": [],
9067 9219
       "refDicts": [],
9068 9220
       "id": "96B34919-1A2F-4E7A-87B9-0330F40F7DF2"
9221
+    },
9222
+    {
9223
+      "defKey": "stat",
9224
+      "defName": "查询统计",
9225
+      "refEntities": [
9226
+        "78C3BB38-9B37-445B-A311-168B4682FE5E"
9227
+      ],
9228
+      "refViews": [],
9229
+      "refDiagrams": [],
9230
+      "refDicts": [],
9231
+      "id": "49C90869-CA44-48D0-A675-ECCB8853A412"
9069 9232
     }
9070 9233
   ],
9071 9234
   "dataTypeMapping": {

+ 8
- 0
db/job_stat_issue_daily.sql Wyświetl plik

@@ -0,0 +1,8 @@
1
+DROP EVENT IF EXISTS `job_stat_issue_daily`;
2
+delimiter ;;
3
+CREATE EVENT `job_stat_issue_daily`
4
+ON SCHEDULE
5
+EVERY '1' DAY STARTS '2023-02-01 01:00:00'
6
+DO CALL pro_stat_issue('issue_daily', DATE_SUB(CURDATE(), INTERVAL 1 DAY), DATE_SUB(CURDATE(), INTERVAL 1 DAY))
7
+;;
8
+delimiter ;

+ 8
- 0
db/job_stat_issue_monthly.sql Wyświetl plik

@@ -0,0 +1,8 @@
1
+DROP EVENT IF EXISTS `job_stat_issue_monthly`;
2
+delimiter ;;
3
+CREATE EVENT `job_stat_issue_monthly`
4
+ON SCHEDULE
5
+EVERY '1' MONTH STARTS '2023-02-01 01:00:00'
6
+DO CALL pro_stat_issue('issue_monthly', DATE_ADD(LAST_DAY(DATE_SUB(NOW(), INTERVAL 2 MONTH)), INTERVAL 1 DAY), LAST_DAY(DATE_SUB(NOW(), INTERVAL 1 MONTH)))
7
+;;
8
+delimiter ;

+ 28
- 0
db/pro_stat_issue.sql Wyświetl plik

@@ -0,0 +1,28 @@
1
+DROP PROCEDURE IF EXISTS `pro_stat_issue`;
2
+delimiter ;;
3
+CREATE PROCEDURE `pro_stat_issue`(IN `ls_type` varchar(32),IN `ls_start` varchar(20),IN `ls_end` varchar(20))
4
+BEGIN
5
+	DECLARE ls_stat_name VARCHAR(20);
6
+	
7
+	IF ls_type = 'issue_daily' OR ls_type = 'issue_monthly' THEN
8
+		SET ls_stat_name = ls_start;
9
+		IF ls_type = 'issue_monthly' THEN
10
+			SET ls_stat_name = SUBSTR(ls_start FROM 1 FOR 7);
11
+		END IF;
12
+	
13
+		# 先清除数据
14
+		DELETE t FROM ts_stat_data t WHERE t.stat_type = ls_type AND t.`name` = ls_stat_name;
15
+		
16
+		# 再统计数据
17
+		INSERT INTO ts_stat_data (stat_type, `name`, `value`)
18
+		SELECT ls_type, ls_stat_name, COUNT(*)
19
+		FROM ta_issue t
20
+		WHERE t.`status` > -1
21
+		AND TO_DAYS(t.create_date) >= TO_DAYS(ls_start)
22
+		AND TO_DAYS(t.create_date) <= TO_DAYS(ls_end);
23
+		
24
+	END IF;	
25
+	
26
+END
27
+;;
28
+delimiter ;

+ 1032
- 0
db/sequence.sql
Plik diff jest za duży
Wyświetl plik


+ 164
- 1
db/文明创办.pdma.json Wyświetl plik

@@ -4,7 +4,7 @@
4 4
   "avatar": "",
5 5
   "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-1-31 11:15:51",
7
+  "updatedTime": "2023-1-31 18:39:34",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -8631,6 +8631,158 @@
8631 8631
       ],
8632 8632
       "correlations": [],
8633 8633
       "indexes": []
8634
+    },
8635
+    {
8636
+      "id": "78C3BB38-9B37-445B-A311-168B4682FE5E",
8637
+      "env": {
8638
+        "base": {
8639
+          "nameSpace": "",
8640
+          "codeRoot": ""
8641
+        }
8642
+      },
8643
+      "defKey": "ts_stat_data",
8644
+      "defName": "常用统计",
8645
+      "comment": "",
8646
+      "properties": {},
8647
+      "nameTemplate": "{defKey}[{defName}]",
8648
+      "headers": [
8649
+        {
8650
+          "refKey": "hideInGraph",
8651
+          "hideInGraph": true
8652
+        },
8653
+        {
8654
+          "refKey": "defKey",
8655
+          "hideInGraph": false
8656
+        },
8657
+        {
8658
+          "refKey": "defName",
8659
+          "hideInGraph": false
8660
+        },
8661
+        {
8662
+          "refKey": "primaryKey",
8663
+          "hideInGraph": false
8664
+        },
8665
+        {
8666
+          "refKey": "notNull",
8667
+          "hideInGraph": true
8668
+        },
8669
+        {
8670
+          "refKey": "autoIncrement",
8671
+          "hideInGraph": true
8672
+        },
8673
+        {
8674
+          "refKey": "domain",
8675
+          "hideInGraph": true
8676
+        },
8677
+        {
8678
+          "refKey": "type",
8679
+          "hideInGraph": false
8680
+        },
8681
+        {
8682
+          "refKey": "len",
8683
+          "hideInGraph": false
8684
+        },
8685
+        {
8686
+          "refKey": "scale",
8687
+          "hideInGraph": false
8688
+        },
8689
+        {
8690
+          "refKey": "comment",
8691
+          "hideInGraph": true
8692
+        },
8693
+        {
8694
+          "refKey": "refDict",
8695
+          "hideInGraph": true
8696
+        },
8697
+        {
8698
+          "refKey": "defaultValue",
8699
+          "hideInGraph": true
8700
+        },
8701
+        {
8702
+          "refKey": "isStandard",
8703
+          "hideInGraph": false
8704
+        },
8705
+        {
8706
+          "refKey": "uiHint",
8707
+          "hideInGraph": true
8708
+        },
8709
+        {
8710
+          "refKey": "extProps",
8711
+          "hideInGraph": true
8712
+        }
8713
+      ],
8714
+      "fields": [
8715
+        {
8716
+          "defKey": "stat_no",
8717
+          "defName": "序号",
8718
+          "comment": "",
8719
+          "type": "",
8720
+          "len": "",
8721
+          "scale": "",
8722
+          "primaryKey": true,
8723
+          "notNull": true,
8724
+          "autoIncrement": true,
8725
+          "defaultValue": "",
8726
+          "hideInGraph": true,
8727
+          "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
8728
+          "refDict": "",
8729
+          "uiHint": "",
8730
+          "id": "E7763878-4C25-476F-8C26-56BF7E0A9F35"
8731
+        },
8732
+        {
8733
+          "defKey": "stat_type",
8734
+          "defName": "统计类型",
8735
+          "comment": "",
8736
+          "type": "",
8737
+          "len": "",
8738
+          "scale": "",
8739
+          "primaryKey": false,
8740
+          "notNull": false,
8741
+          "autoIncrement": false,
8742
+          "defaultValue": "",
8743
+          "hideInGraph": false,
8744
+          "refDict": "",
8745
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
8746
+          "id": "49707BF9-E174-4ABA-8527-2C6A0996FE43",
8747
+          "uiHint": ""
8748
+        },
8749
+        {
8750
+          "defKey": "name",
8751
+          "defName": "指标名称",
8752
+          "comment": "",
8753
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
8754
+          "type": "",
8755
+          "len": "",
8756
+          "scale": "",
8757
+          "primaryKey": false,
8758
+          "notNull": false,
8759
+          "autoIncrement": false,
8760
+          "defaultValue": "",
8761
+          "hideInGraph": true,
8762
+          "refDict": "",
8763
+          "uiHint": "",
8764
+          "id": "22B03E6C-E6FD-4D4F-855B-87E5F8EF79BF"
8765
+        },
8766
+        {
8767
+          "defKey": "value",
8768
+          "defName": "统计值",
8769
+          "comment": "",
8770
+          "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
8771
+          "type": "",
8772
+          "len": "",
8773
+          "scale": "",
8774
+          "primaryKey": false,
8775
+          "notNull": false,
8776
+          "autoIncrement": false,
8777
+          "defaultValue": "0",
8778
+          "hideInGraph": true,
8779
+          "refDict": "",
8780
+          "uiHint": "",
8781
+          "id": "5DC510CC-D45C-42D4-AEED-5AD9130E0D88"
8782
+        }
8783
+      ],
8784
+      "correlations": [],
8785
+      "indexes": []
8634 8786
     }
8635 8787
   ],
8636 8788
   "views": [],
@@ -9066,6 +9218,17 @@
9066 9218
       "refDiagrams": [],
9067 9219
       "refDicts": [],
9068 9220
       "id": "96B34919-1A2F-4E7A-87B9-0330F40F7DF2"
9221
+    },
9222
+    {
9223
+      "defKey": "stat",
9224
+      "defName": "查询统计",
9225
+      "refEntities": [
9226
+        "78C3BB38-9B37-445B-A311-168B4682FE5E"
9227
+      ],
9228
+      "refViews": [],
9229
+      "refDiagrams": [],
9230
+      "refDicts": [],
9231
+      "id": "49C90869-CA44-48D0-A675-ECCB8853A412"
9069 9232
     }
9070 9233
   ],
9071 9234
   "dataTypeMapping": {

+ 42
- 4
src/main/java/com/example/civilizedcity/controller/StatController.java Wyświetl plik

@@ -5,7 +5,9 @@ import com.example.civilizedcity.common.ResponseBean;
5 5
 import com.example.civilizedcity.entity.SysUser;
6 6
 import com.example.civilizedcity.entity.TaPerson;
7 7
 import com.example.civilizedcity.service.TaIssueService;
8
+import com.example.civilizedcity.service.TsStatDataService;
8 9
 import com.example.civilizedcity.vo.StatVo;
10
+import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
11 13
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,16 +16,21 @@ import org.springframework.web.bind.annotation.RequestParam;
14 16
 import org.springframework.web.bind.annotation.RestController;
15 17
 
16 18
 import java.util.List;
19
+import java.util.Map;
17 20
 
18 21
 /**
19 22
  * 查询统计
20 23
  */
24
+@Api(tags = "常用统计对象功能接口")
21 25
 @RestController
22 26
 public class StatController extends BaseController {
23 27
 
24 28
     @Autowired
25 29
     TaIssueService taIssueService;
26 30
 
31
+    @Autowired
32
+    TsStatDataService tsStatDataService;
33
+
27 34
     @ApiOperation("小程序首页查询统计")
28 35
     @GetMapping("/ma/index-stat")
29 36
     public ResponseBean getMaIndex(@ApiParam("身份") @RequestParam(value = "duty", required = false) String duty) throws Exception {
@@ -35,14 +42,45 @@ public class StatController extends BaseController {
35 42
         } catch (Exception e) {
36 43
             //
37 44
         }
38
-        try {
39
-            person = currentPerson();
40
-        } catch (Exception e) {
41
-            //
45
+
46
+        person = currentPerson();
47
+        if (null == person) {
48
+            return ResponseBean.error("请在小程序端操作");
42 49
         }
43 50
 
44 51
         List<StatVo> result = taIssueService.statMaIndex(user, person, duty);
45 52
 
46 53
         return ResponseBean.success(result);
47 54
     }
55
+
56
+    @ApiOperation("管理端首页统计")
57
+    @GetMapping("/stat/admin/index-banner")
58
+    public ResponseBean statAdminIndexBanner() throws Exception {
59
+        Map<String, Object> result = tsStatDataService.statAdminIndexBanner();
60
+        return ResponseBean.success(result);
61
+    }
62
+
63
+    @ApiOperation("问题单数量查询统计")
64
+    @GetMapping("/stat/issue")
65
+    public ResponseBean statIssueData(@ApiParam("统计类型") @RequestParam String statType,
66
+                                      @ApiParam("开始日期") @RequestParam String startDate,
67
+                                      @ApiParam("结束日期") @RequestParam String endDate,
68
+                                      @ApiParam("统计条数") @RequestParam Integer num) throws Exception {
69
+        List<StatVo> result = tsStatDataService.statIssue(statType, startDate, endDate, num);
70
+        return ResponseBean.success(result);
71
+    }
72
+
73
+    @ApiOperation("单位交办统计")
74
+    @GetMapping("/stat/issue/org")
75
+    public ResponseBean statIssueOrg(@ApiParam("单位ID") @RequestParam String orgId) throws Exception {
76
+        List<StatVo> result = tsStatDataService.statIssueOrg(orgId);
77
+        return ResponseBean.success(result);
78
+    }
79
+
80
+    @ApiOperation("问题分类统计")
81
+    @GetMapping("/stat/issue/type")
82
+    public ResponseBean statIssueType() throws Exception {
83
+        List<StatVo> result = tsStatDataService.statIssueType();
84
+        return ResponseBean.success(result);
85
+    }
48 86
 }

+ 39
- 0
src/main/java/com/example/civilizedcity/entity/TsStatData.java Wyświetl plik

@@ -0,0 +1,39 @@
1
+package com.example.civilizedcity.entity;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import com.baomidou.mybatisplus.annotation.IdType;
6
+import com.baomidou.mybatisplus.annotation.TableName;
7
+import com.baomidou.mybatisplus.annotation.TableId;
8
+import java.io.Serializable;
9
+import java.time.LocalDateTime;
10
+import lombok.Data;
11
+import lombok.EqualsAndHashCode;
12
+import lombok.experimental.Accessors;
13
+
14
+ /**
15
+ * 常用统计;
16
+ * @author : http://www.chiner.pro
17
+ * @date : 2023-1-31
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+@ApiModel(value = "常用统计",description = "")
23
+@TableName("ts_stat_data")
24
+public class TsStatData implements Serializable,Cloneable{
25
+    /** 序号 */
26
+    @ApiModelProperty(name = "序号",notes = "")
27
+    @TableId(value = "stat_no", type = IdType.ASSIGN_UUID)
28
+    private Integer statNo ;
29
+    /** 统计类型 */
30
+    @ApiModelProperty(name = "统计类型",notes = "")
31
+    private String statType ;
32
+    /** 指标名称 */
33
+    @ApiModelProperty(name = "指标名称",notes = "")
34
+    private String name ;
35
+    /** 统计值 */
36
+    @ApiModelProperty(name = "统计值",notes = "")
37
+    private Integer value ;
38
+
39
+}

+ 3
- 1
src/main/java/com/example/civilizedcity/mapper/SysUserMapper.java Wyświetl plik

@@ -15,4 +15,6 @@ import java.util.List;
15 15
 @Mapper
16 16
 public interface SysUserMapper  extends BaseMapper<SysUser>{
17 17
      List<SysUser> getListByPhone(@Param("phone") String phone);
18
- }
18
+
19
+    long countAll(@Param("rootId") String rootId);
20
+}

+ 8
- 1
src/main/java/com/example/civilizedcity/mapper/TaIssueMapper.java Wyświetl plik

@@ -2,11 +2,13 @@ package com.example.civilizedcity.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.example.civilizedcity.vo.StatVo;
5 6
 import org.apache.ibatis.annotations.MapKey;
6 7
 import org.apache.ibatis.annotations.Mapper;
7 8
 import org.apache.ibatis.annotations.Param;
8 9
 import com.example.civilizedcity.entity.TaIssue;
9 10
 
11
+import java.util.List;
10 12
 import java.util.Map;
11 13
 
12 14
 /**
@@ -29,4 +31,9 @@ public interface TaIssueMapper  extends BaseMapper<TaIssue>{
29 31
 
30 32
      @MapKey("id")
31 33
      Map<String, Object> statMaIndex(@Param("userId") String userId);
32
- }
34
+
35
+     @MapKey("id")
36
+     Map<String, Object> statIssueOrg(@Param("orgId") String orgId);
37
+
38
+     List<StatVo> statIssueType();
39
+}

+ 25
- 0
src/main/java/com/example/civilizedcity/mapper/TsStatDataMapper.java Wyświetl plik

@@ -0,0 +1,25 @@
1
+package com.example.civilizedcity.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.example.civilizedcity.vo.StatVo;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+import com.example.civilizedcity.entity.TsStatData;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * 常用统计;(ts_stat_data)表数据库访问层
13
+ * @author : http://njyunzhi.com
14
+ * @date : 2023-1-31
15
+ */
16
+@Mapper
17
+public interface TsStatDataMapper  extends BaseMapper<TsStatData>{
18
+    List<StatVo> statIssueDaily(@Param("startDate") String startDate,
19
+                                @Param("endDate") String endDate,
20
+                                @Param("num") Integer num);
21
+
22
+    List<StatVo> statIssueMonthly(@Param("startDate") String startDate,
23
+                                  @Param("endDate") String endDate,
24
+                                  @Param("num") Integer num);
25
+}

+ 24
- 0
src/main/java/com/example/civilizedcity/service/TsStatDataService.java Wyświetl plik

@@ -0,0 +1,24 @@
1
+package com.example.civilizedcity.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.example.civilizedcity.entity.TsStatData;
5
+import com.example.civilizedcity.vo.StatVo;
6
+
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+/**
11
+ * 常用统计;(ts_stat_data)表服务接口
12
+ * @author : http://njyunzhi.com
13
+ * @date : 2023-1-31
14
+ */
15
+public interface TsStatDataService extends IBaseService<TsStatData> {
16
+
17
+     List<StatVo> statIssue(String statType, String startDate, String endDate, Integer num);
18
+
19
+    List<StatVo> statIssueOrg(String orgId);
20
+
21
+    List<StatVo> statIssueType();
22
+
23
+    Map<String, Object> statAdminIndexBanner();
24
+}

+ 71
- 0
src/main/java/com/example/civilizedcity/service/impl/TsStatDataServiceImpl.java Wyświetl plik

@@ -0,0 +1,71 @@
1
+package com.example.civilizedcity.service.impl;
2
+
3
+import com.example.civilizedcity.common.Constants;
4
+import com.example.civilizedcity.mapper.SysUserMapper;
5
+import com.example.civilizedcity.mapper.TaIssueMapper;
6
+import com.example.civilizedcity.vo.StatVo;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Service;
9
+import com.example.civilizedcity.entity.TsStatData;
10
+import com.example.civilizedcity.mapper.TsStatDataMapper;
11
+import com.example.civilizedcity.service.TsStatDataService;
12
+
13
+import java.util.ArrayList;
14
+import java.util.List;
15
+import java.util.Map;
16
+
17
+/**
18
+ * 常用统计;(ts_stat_data)表服务实现类
19
+ *
20
+ * @author : http://www.chiner.pro
21
+ * @date : 2023-1-31
22
+ */
23
+@Service
24
+public class TsStatDataServiceImpl extends BaseServiceImpl<TsStatDataMapper, TsStatData> implements TsStatDataService {
25
+
26
+    @Autowired
27
+    TaIssueMapper taIssueMapper;
28
+
29
+    @Autowired
30
+    SysUserMapper sysUserMapper;
31
+
32
+    @Override
33
+    public List<StatVo> statIssue(String statType, String startDate, String endDate, Integer num) {
34
+
35
+        if (statType.contains("daily")) {
36
+            return baseMapper.statIssueDaily(startDate, endDate, num);
37
+        }
38
+
39
+        if (statType.contains("monthly")) {
40
+            return baseMapper.statIssueMonthly(startDate, endDate, num);
41
+        }
42
+
43
+        return null;
44
+    }
45
+
46
+    @Override
47
+    public List<StatVo> statIssueOrg(String orgId) {
48
+        Map<String, Object> map = taIssueMapper.statIssueOrg(orgId);
49
+        List<StatVo> res = new ArrayList<>();
50
+        res.add(new StatVo().setName("已完结").setValue(map.get("endNum")));
51
+        res.add(new StatVo().setName("处理中").setValue(map.get("assignedNum")));
52
+        res.add(new StatVo().setName("已逾期").setValue(map.get("expireNum")));
53
+        return res;
54
+    }
55
+
56
+    @Override
57
+    public List<StatVo> statIssueType() {
58
+        return taIssueMapper.statIssueType();
59
+    }
60
+
61
+    @Override
62
+    public Map<String, Object> statAdminIndexBanner() {
63
+        // 总用户数
64
+        long userNum = sysUserMapper.countAll(Constants.ROOT_ID);
65
+        // 问题单统计
66
+        Map<String, Object> result = taIssueMapper.statMaIndex(null);
67
+        result.put("user_num", userNum);
68
+
69
+        return result;
70
+    }
71
+}

+ 16
- 8
src/main/resources/application.yml Wyświetl plik

@@ -8,14 +8,22 @@ spring:
8 8
     url: jdbc:mysql://110.40.183.156:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
9 9
     username: civilizedcity
10 10
     password: civilizedcity@ABCD1234
11
-#    max-idle: 10
12
-#    max-wait: 10000
13
-#    min-idle: 5
14
-#    initial-size: 5
15
-#    validation-query: SELECT 1
16
-#    test-on-borrow: false
17
-#    test-while-idle: true
18
-#    time-between-eviction-runs-millis: 18800
11
+    hikari:
12
+      # 最小空闲连接数
13
+      minimum-idle: 10
14
+      # 空闲连接存活最大时间, 默认 600000 - 10分钟
15
+      idle-timeout: 120000 # 2min
16
+      # 最大连接池数, 默认 10
17
+      maximum-pool-size: 30
18
+      # 连接池最长生命 0 无限期, 1800000 - 30分钟
19
+      max-lifetime: 180000 # 3min
20
+      # 连接超时 默认 30000 - 30秒
21
+      connection-timeout: 30000
22
+      connection-test-query: SELECT 1
23
+      # 连接活性检测 6000 - 1 分钟
24
+      keepalive-time: 6000
25
+
26
+
19 27
   mvc:
20 28
     pathmatch:
21 29
       matching-strategy: ANT_PATH_MATCHER

+ 9
- 0
src/main/resources/mapper/SysUserMapper.xml Wyświetl plik

@@ -12,4 +12,13 @@
12 12
             t.phone = #{phone}
13 13
           AND t.`status` &gt; -1
14 14
     </select>
15
+    <select id="countAll" resultType="java.lang.Long">
16
+        SELECT
17
+            count( * )
18
+        FROM
19
+            sys_user t
20
+        WHERE
21
+            t.user_id != #{rootId}
22
+	        AND t.`status` &gt; -1
23
+    </select>
15 24
 </mapper>

+ 25
- 0
src/main/resources/mapper/TaIssueMapper.xml Wyświetl plik

@@ -60,4 +60,29 @@
60 60
           </if>
61 61
           AND t.`status` > - 1
62 62
     </select>
63
+    <select id="statIssueOrg" resultType="java.util.Map">
64
+        SELECT
65
+            UUID_SHORT( ) AS id,
66
+            IFNULL( SUM( IF ( t.process_node = 'end', t.process_num, 0 ) ), 0 ) AS endNum,
67
+            IFNULL( SUM( IF ( t.process_node = 'assigned', t.process_num, 0 ) ), 0 ) AS assignedNum,
68
+            IFNULL( SUM( IF ( t.expire_date &lt;= NOW( ), t.process_num, 0 ) ), 0 ) AS expireNum
69
+        FROM
70
+            ta_issue t
71
+        WHERE
72
+            t.org_id = #{orgId}
73
+            AND t.`status` &gt; -1
74
+    </select>
75
+    <select id="statIssueType" resultType="com.example.civilizedcity.vo.StatVo">
76
+        SELECT
77
+            t.type_name AS `name`,
78
+            COUNT( 1 ) AS `value`
79
+        FROM
80
+            ta_issue t
81
+        WHERE
82
+            t.`status` &gt; -1
83
+        GROUP BY
84
+            t.type_id
85
+        ORDER BY
86
+            t.type_name ASC
87
+    </select>
63 88
 </mapper>

+ 49
- 0
src/main/resources/mapper/TsStatDataMapper.xml Wyświetl plik

@@ -0,0 +1,49 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+
4
+<mapper namespace="com.example.civilizedcity.mapper.TsStatDataMapper">
5
+
6
+    <select id="statIssueDaily" resultType="com.example.civilizedcity.vo.StatVo">
7
+        SELECT
8
+            a.`name`,
9
+            IFNULL( b.`value`, 0 )
10
+        FROM
11
+            ( SELECT DATE_ADD( #{startDate}, INTERVAL t.rownum DAY ) AS `name` FROM sequence t WHERE t.rownum &lt; #{num} ) a
12
+        LEFT JOIN (
13
+            SELECT
14
+            t.`name`,
15
+            t.`value`
16
+            FROM
17
+            ts_stat_data t
18
+            WHERE
19
+            t.stat_type = 'issue_daily'
20
+            AND t.`name` &gt;= #{startDate}
21
+            AND t.`name` &lt;= #{endDate}
22
+        ) b ON a.`name` = b.`name`
23
+        ORDER BY
24
+            a.`name` ASC
25
+    </select>
26
+    <select id="statIssueMonthly" resultType="com.example.civilizedcity.vo.StatVo">
27
+        SELECT
28
+            a.`name`,
29
+            IFNULL( b.`value`, 0 )
30
+        FROM (
31
+            SELECT DATE_FORMAT( DATE_ADD( CONCAT( #{startDate}, '-01' ), INTERVAL t.rownum MONTH ), '%Y-%m' ) AS `name`
32
+            FROM sequence t
33
+            WHERE t.rownum &lt; #{num}
34
+        ) a
35
+        LEFT JOIN (
36
+            SELECT
37
+                t.`name`,
38
+                t.`value`
39
+            FROM
40
+                ts_stat_data t
41
+            WHERE
42
+                t.stat_type = 'issue_monthly'
43
+              AND t.`name` &gt;= #{startDate}
44
+              AND t.`name` &lt;= #{endDate}
45
+        ) b ON a.`name` = b.`name`
46
+        ORDER BY
47
+            a.`name` ASC
48
+    </select>
49
+</mapper>