Yansen 2 vuotta sitten
vanhempi
commit
408a5c6fd0

+ 68
- 5
src/main/java/com/yunzhi/nanyang/controller/StatisController.java Näytä tiedosto

@@ -1,11 +1,9 @@
1 1
 package com.yunzhi.nanyang.controller;
2 2
 
3 3
 import com.yunzhi.nanyang.common.BaseController;
4
+import com.yunzhi.nanyang.common.Constants;
4 5
 import com.yunzhi.nanyang.common.ResponseBean;
5
-import com.yunzhi.nanyang.service.ITaMachineryService;
6
-import com.yunzhi.nanyang.service.ITaOrderService;
7
-import com.yunzhi.nanyang.service.ITaOrgService;
8
-import com.yunzhi.nanyang.service.ITaPersonService;
6
+import com.yunzhi.nanyang.service.*;
9 7
 import com.yunzhi.nanyang.vo.ChartParam;
10 8
 import io.swagger.annotations.Api;
11 9
 import io.swagger.annotations.ApiOperation;
@@ -35,9 +33,14 @@ public class StatisController extends BaseController {
35 33
     @Autowired
36 34
     ITaOrderService iTaOrderService;
37 35
 
36
+    @Autowired
37
+    ITdDeviceService iTdDeviceService;
38
+
39
+    @Autowired
40
+    ISysUserService iSysUserService;
38 41
 
39 42
     @GetMapping("/summary")
40
-    @ApiOperation(value="登录", notes = "登录", httpMethod = "POST", response = ResponseBean.class)
43
+    @ApiOperation(value="首屏统计", notes = "首屏统计", httpMethod = "GET", response = ResponseBean.class)
41 44
     public ResponseBean summary() throws Exception {
42 45
 
43 46
         List<ChartParam> resp = new ArrayList<>();
@@ -60,4 +63,64 @@ public class StatisController extends BaseController {
60 63
 
61 64
         return ResponseBean.success(resp);
62 65
     }
66
+
67
+    @GetMapping("/summary2")
68
+    @ApiOperation(value="首屏统计2", notes = "首屏统计2", httpMethod = "GET", response = ResponseBean.class)
69
+    public ResponseBean summary2() throws Exception {
70
+
71
+        List<ChartParam> resp = new ArrayList<>();
72
+
73
+        // 统计注册用户
74
+        ChartParam personNum = iSysUserService.statisTotal();
75
+        resp.add(personNum);
76
+
77
+        // 合作社数
78
+        ChartParam orgNum = iTaOrgService.statisTotal();
79
+        resp.add(orgNum);
80
+
81
+        // 设备数量
82
+        ChartParam machineryNum = iTdDeviceService.statisTotal("feifang");
83
+        resp.add(machineryNum);
84
+
85
+        // 订单数
86
+        ChartParam orderNum = iTdDeviceService.statisJob("feifang", "2023-04-10");
87
+        resp.add(orderNum);
88
+
89
+        return ResponseBean.success(resp);
90
+    }
91
+
92
+    @GetMapping("/area-total-org")
93
+    @ApiOperation(value="合作社作业统计", notes = "合作社作业统计", httpMethod = "GET", response = ResponseBean.class)
94
+    public ResponseBean totalAreaByOrg() throws Exception {
95
+        List<ChartParam> resp = iTdDeviceService.statisAreaByOrgJob("feifang", "2023-04-10");
96
+        return ResponseBean.success(resp);
97
+    }
98
+
99
+    @GetMapping("/device-total-org")
100
+    @ApiOperation(value="合作社设备统计", notes = "合作社设备统计", httpMethod = "GET", response = ResponseBean.class)
101
+    public ResponseBean totalNumByOrg() throws Exception {
102
+        List<ChartParam> resp = iTdDeviceService.statisNumByOrgJob("feifang");
103
+        return ResponseBean.success(resp);
104
+    }
105
+
106
+    @GetMapping("/area-total-person")
107
+    @ApiOperation(value="人员作业统计", notes = "人员作业统计", httpMethod = "GET", response = ResponseBean.class)
108
+    public ResponseBean totalAreaByPerson() throws Exception {
109
+        List<ChartParam> resp = iTdDeviceService.statisAreaByPerson("feifang", "2023-04-10");
110
+        return ResponseBean.success(resp);
111
+    }
112
+
113
+    @GetMapping("/device-total-person")
114
+    @ApiOperation(value="人员设备统计", notes = "人员设备统计", httpMethod = "GET", response = ResponseBean.class)
115
+    public ResponseBean totalNumByPerson() throws Exception {
116
+        List<ChartParam> resp = iTdDeviceService.statisNumByPerson("feifang");
117
+        return ResponseBean.success(resp);
118
+    }
119
+
120
+    @GetMapping("/area-total-town")
121
+    @ApiOperation(value="乡镇作业统计", notes = "乡镇作业统计", httpMethod = "GET", response = ResponseBean.class)
122
+    public ResponseBean totalAreaByTown() throws Exception {
123
+        List<ChartParam> resp = iTdDeviceService.statisAreaByTown("feifang", "2023-04-10");
124
+        return ResponseBean.success(resp);
125
+    }
63 126
 }

+ 6
- 0
src/main/java/com/yunzhi/nanyang/entity/TaDeviceJob.java Näytä tiedosto

@@ -108,4 +108,10 @@ public class TaDeviceJob implements Serializable, Cloneable {
108 108
 
109 109
     @ApiModelProperty(name = "合作社ID")
110 110
     private String orgId;
111
+
112
+    @ApiModelProperty(name = "达标率", notes = "")
113
+    private Double fulfilledRate;
114
+
115
+    @ApiModelProperty(name = "达标面积", notes = "")
116
+    private Double fulfilledArea;
111 117
 }

+ 4
- 0
src/main/java/com/yunzhi/nanyang/mapper/SysUserMapper.java Näytä tiedosto

@@ -3,6 +3,7 @@ package com.yunzhi.nanyang.mapper;
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.nanyang.entity.SysUser;
5 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.nanyang.vo.ChartParam;
6 7
 import org.apache.ibatis.annotations.Mapper;
7 8
 import org.apache.ibatis.annotations.Param;
8 9
 import org.apache.ibatis.annotations.Select;
@@ -29,4 +30,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
29 30
 
30 31
     @Select("select * from sys_user where phone = #{phone} and status > -1")
31 32
     SysUser selectByPhone(@Param("phone") String phone);
33
+
34
+    @Select("SELECT 'person' as `name`, count(*) as `value`  FROM sys_user t WHERE t.phone is not null AND t.`status` > -1")
35
+    ChartParam statisTotal();
32 36
 }

+ 17
- 0
src/main/java/com/yunzhi/nanyang/mapper/TdDeviceMapper.java Näytä tiedosto

@@ -3,8 +3,10 @@ package com.yunzhi.nanyang.mapper;
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.nanyang.entity.TdDevice;
5 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.nanyang.vo.ChartParam;
6 7
 import org.apache.ibatis.annotations.Mapper;
7 8
 import org.apache.ibatis.annotations.Param;
9
+import org.apache.ibatis.annotations.Select;
8 10
 
9 11
 import java.util.List;
10 12
 
@@ -24,4 +26,19 @@ public interface TdDeviceMapper extends BaseMapper<TdDevice> {
24 26
     TdDevice getExistByDevice(@Param("deviceType") String deviceType,@Param("deviceNo") String deviceNo);
25 27
 
26 28
     List<TdDevice> getListByTypes(@Param("typeList") List<String> typeList);
29
+
30
+    @Select("SELECT 'device' as `name`, count(*) as `value`  FROM td_device t WHERE t.`device_type` = #{deviceType} AND t.`status` = 1")
31
+    ChartParam statisTotal(@Param("deviceType") String deviceType);
32
+
33
+    ChartParam statisJob(@Param("deviceKind") String deviceKind, @Param("jobDate") String jobDate);
34
+
35
+    List<ChartParam> statisAreaByOrgJob(@Param("deviceKind") String deviceKind, @Param("jobDate") String jobDate);
36
+
37
+    List<ChartParam> statisNumByOrgJob(@Param("deviceType") String deviceType);
38
+
39
+    List<ChartParam> statisAreaByPerson(@Param("deviceKind") String deviceKind, @Param("jobDate") String jobDate);
40
+
41
+    List<ChartParam> statisNumByPerson(@Param("deviceType") String deviceType);
42
+
43
+    List<ChartParam> statisAreaByTown(@Param("deviceKind") String deviceKind, @Param("jobDate") String jobDate);
27 44
 }

+ 2
- 0
src/main/java/com/yunzhi/nanyang/service/ISysUserService.java Näytä tiedosto

@@ -2,6 +2,7 @@ package com.yunzhi.nanyang.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.nanyang.entity.SysUser;
5
+import com.yunzhi.nanyang.vo.ChartParam;
5 6
 
6 7
 import java.util.Map;
7 8
 
@@ -21,4 +22,5 @@ public interface ISysUserService extends IBaseService<SysUser> {
21 22
 
22 23
     IPage<SysUser> getPageBy(IPage<SysUser> pg, String userId, String orgId, String name, String phone);
23 24
 
25
+    ChartParam statisTotal();
24 26
 }

+ 15
- 0
src/main/java/com/yunzhi/nanyang/service/ITdDeviceService.java Näytä tiedosto

@@ -3,6 +3,7 @@ package com.yunzhi.nanyang.service;
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.nanyang.entity.TdDevice;
5 5
 import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.yunzhi.nanyang.vo.ChartParam;
6 7
 
7 8
 import java.util.List;
8 9
 
@@ -21,4 +22,18 @@ public interface ITdDeviceService extends IBaseService<TdDevice> {
21 22
     TdDevice getExistByDevice(String deviceType, String deviceNo);
22 23
 
23 24
     List<TdDevice> getListByTypes(List<String> typeList);
25
+
26
+    ChartParam statisTotal(String deviceType);
27
+
28
+    ChartParam statisJob(String deviceKind, String jobDate);
29
+
30
+    List<ChartParam> statisAreaByOrgJob(String deviceKind, String jobDate);
31
+
32
+    List<ChartParam> statisNumByOrgJob(String deviceType);
33
+
34
+    List<ChartParam> statisAreaByPerson(String deviceKind, String jobDate);
35
+
36
+    List<ChartParam> statisNumByPerson(String deviceType);
37
+
38
+    List<ChartParam> statisAreaByTown(String deviceKind, String jobDate);
24 39
 }

+ 6
- 0
src/main/java/com/yunzhi/nanyang/service/impl/SysUserServiceImpl.java Näytä tiedosto

@@ -7,6 +7,7 @@ import com.yunzhi.nanyang.mapper.SysMenuMapper;
7 7
 import com.yunzhi.nanyang.mapper.SysUserMapper;
8 8
 import com.yunzhi.nanyang.service.ISysUserService;
9 9
 import com.yunzhi.nanyang.vo.AccessInfo;
10
+import com.yunzhi.nanyang.vo.ChartParam;
10 11
 import org.springframework.beans.factory.annotation.Autowired;
11 12
 import org.springframework.stereotype.Service;
12 13
 
@@ -62,4 +63,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
62 63
     public IPage<SysUser> getPageBy(IPage<SysUser> pg, String userId, String orgId, String name, String phone) {
63 64
         return baseMapper.getPageBy(pg, Constants.ADMIN_ID, userId, orgId, name, phone);
64 65
     }
66
+
67
+    @Override
68
+    public ChartParam statisTotal() {
69
+        return baseMapper.statisTotal();
70
+    }
65 71
 }

+ 36
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TdDeviceServiceImpl.java Näytä tiedosto

@@ -5,6 +5,7 @@ import com.yunzhi.nanyang.entity.TdDevice;
5 5
 import com.yunzhi.nanyang.mapper.TdDeviceMapper;
6 6
 import com.yunzhi.nanyang.service.ITdDeviceService;
7 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.yunzhi.nanyang.vo.ChartParam;
8 9
 import org.springframework.stereotype.Service;
9 10
 
10 11
 import java.util.List;
@@ -34,4 +35,39 @@ public class TdDeviceServiceImpl extends BaseServiceImpl<TdDeviceMapper, TdDevic
34 35
     public List<TdDevice> getListByTypes(List<String> typeList) {
35 36
         return baseMapper.getListByTypes(typeList);
36 37
     }
38
+
39
+    @Override
40
+    public ChartParam statisTotal(String deviceType) {
41
+        return baseMapper.statisTotal(deviceType);
42
+    }
43
+
44
+    @Override
45
+    public ChartParam statisJob(String deviceKind, String jobDate) {
46
+        return baseMapper.statisJob(deviceKind, jobDate);
47
+    }
48
+
49
+    @Override
50
+    public List<ChartParam> statisAreaByOrgJob(String deviceKind, String jobDate) {
51
+        return baseMapper.statisAreaByOrgJob(deviceKind, jobDate);
52
+    }
53
+
54
+    @Override
55
+    public List<ChartParam> statisNumByOrgJob(String deviceType) {
56
+        return baseMapper.statisNumByOrgJob(deviceType);
57
+    }
58
+
59
+    @Override
60
+    public List<ChartParam> statisAreaByPerson(String deviceKind, String jobDate) {
61
+        return baseMapper.statisAreaByPerson(deviceKind, jobDate);
62
+    }
63
+
64
+    @Override
65
+    public List<ChartParam> statisNumByPerson(String deviceType) {
66
+        return baseMapper.statisNumByPerson(deviceType);
67
+    }
68
+
69
+    @Override
70
+    public List<ChartParam> statisAreaByTown(String deviceKind, String jobDate) {
71
+        return baseMapper.statisAreaByTown(deviceKind, jobDate);
72
+    }
37 73
 }

+ 89
- 0
src/main/resources/mapper/TdDeviceMapper.xml Näytä tiedosto

@@ -58,4 +58,93 @@
58 58
         ORDER BY
59 59
             t.create_date DESC
60 60
     </select>
61
+    <select id="statisJob" resultType="com.yunzhi.nanyang.vo.ChartParam">
62
+        SELECT 'jobArea' as `name`,
63
+               sum(t.job_area) as `value`
64
+        FROM ta_device_job t
65
+        WHERE t.`device_kind` = #{deviceKind}
66
+          AND t.`job_date` &gt;= #{jobDate}
67
+    </select>
68
+    <select id="statisAreaByOrgJob" resultType="com.yunzhi.nanyang.vo.ChartParam">
69
+        SELECT
70
+            *
71
+        FROM
72
+            (
73
+                SELECT
74
+                    a.`name`,
75
+                    sum( b.job_area ) AS `value`
76
+                FROM
77
+                    ta_org a
78
+                        LEFT JOIN (
79
+                            SELECT *
80
+                            FROM ta_device_job t
81
+                            WHERE t.device_kind = #{deviceKind}
82
+                              AND t.job_date >= #{jobDate}
83
+                            ) b ON a.org_id = b.org_id
84
+                WHERE a.`status` = 1
85
+                GROUP BY
86
+                    a.`name`
87
+            ) m
88
+        ORDER BY
89
+            m.`value` DESC;
90
+    </select>
91
+    <select id="statisNumByOrgJob" resultType="com.yunzhi.nanyang.vo.ChartParam">
92
+        SELECT
93
+            t.`name`,
94
+            COUNT( DISTINCT m.device_no ) AS `value`
95
+        FROM
96
+            ta_org t
97
+                LEFT JOIN ta_machinery s ON t.org_id = s.org_id
98
+                LEFT JOIN td_device m ON m.machinery_id = s.machinery_id
99
+                AND m.device_type = #{deviceType}
100
+        WHERE
101
+            t.`status` = 1
102
+        GROUP BY
103
+            t.`name`
104
+    </select>
105
+    <select id="statisAreaByPerson" resultType="com.yunzhi.nanyang.vo.ChartParam">
106
+        SELECT
107
+            *
108
+        FROM
109
+            (
110
+                SELECT
111
+                    t.user_name AS `name`,
112
+                    sum( t.job_area ) AS `value`
113
+                FROM
114
+                    ta_device_job t
115
+                WHERE
116
+                    t.device_kind = #{deviceKind}
117
+                  AND t.job_date &gt;= #{jobDate}
118
+                GROUP BY
119
+                    t.user_name
120
+            ) a
121
+        ORDER BY
122
+            a.`value` DESC
123
+    </select>
124
+    <select id="statisNumByPerson" resultType="com.yunzhi.nanyang.vo.ChartParam">
125
+        SELECT
126
+            m.user_name as `name`,
127
+            COUNT( DISTINCT t.device_no ) AS `value`
128
+        FROM
129
+            td_device t
130
+                LEFT JOIN ta_machinery s ON t.machinery_id = s.machinery_id
131
+                LEFT JOIN sys_user m ON s.owner_id = m.user_id
132
+        WHERE
133
+            t.device_type = #{deviceType}
134
+        GROUP BY
135
+            m.user_name
136
+    </select>
137
+    <select id="statisAreaByTown" resultType="com.yunzhi.nanyang.vo.ChartParam">
138
+        SELECT
139
+            s.town as `name`,
140
+            sum( t.job_area ) AS `value`
141
+        FROM
142
+            ta_device_job t
143
+                LEFT JOIN ta_location s ON t.location = s.location
144
+        WHERE
145
+            t.device_kind = #{deviceKind}
146
+          AND t.job_date &gt;= #{jobDate}
147
+        GROUP BY
148
+            s.town
149
+    </select>
61 150
 </mapper>