#
luxiaotao1123
2021-03-05 53b6192e1349121af872d3f040f47c26b45c7bb6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package zy.cloud.wms.manager.controller;
 
import com.core.common.Cools;
import com.core.common.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zy.cloud.wms.common.web.BaseController;
 
import java.util.Optional;
 
/**
 * Created by vincent on 2021/3/5
 */
@RestController
@RequestMapping("console")
public class ConsoleController extends BaseController {
 
    @Autowired
    private JdbcTemplate jdbcTemplate;
 
    /**
     * 当天数据:select * from tableName where datediff(day, 字段名,getdate())=0
     * 本周数据:select * from tableName where datediff(week, 字段名,getdate())=0
     * 本月:select * from tableName where datediff(month, 字段名,getdate())=0
     * 本季度:内select * from tableName where datediff(quarter, 字段名,getdate())=0
     * 本年:select * from tableName where datediff(year, 字段名,getdate())=0
     */
    @RequestMapping(value = "/header/auth")
    public R header() {
        Integer combQtyDay = jdbcTemplate.queryForObject("select count(*) from man_comb where datediff(day, create_time, getdate())=0", Integer.class);
        Integer combQty = jdbcTemplate.queryForObject("select count(*) from man_comb", Integer.class);
 
        Integer matQty = jdbcTemplate.queryForObject("select count(*) from man_mat", Integer.class);
        Integer nodeQty = jdbcTemplate.queryForObject("select count(*) from man_node where type = 3", Integer.class);
 
        Integer pakoutQty = jdbcTemplate.queryForObject("select count(*) from man_pakout", Integer.class);
        Integer pakoutQtyMonth = jdbcTemplate.queryForObject("select count(*) from man_pakout where datediff(month, create_time, getdate())=0", Integer.class);
 
        Integer usersQty = jdbcTemplate.queryForObject("select count(*) from sys_user", Integer.class);
        Integer deptQty = jdbcTemplate.queryForObject("select count(*) from sys_dept", Integer.class);
 
        return R.ok().add(Cools
                .add("combQtyDay", Optional.ofNullable(combQtyDay).orElse(0)) // 组托数量(当天)
                .add("combQty、", Optional.ofNullable(combQty).orElse(0)) // 组托数量
                .add("matQty", Optional.ofNullable(matQty).orElse(0)) // 物料数量
                .add("nodeQty、", Optional.ofNullable(nodeQty).orElse(0)) // 货位数量
                .add("pakoutQty", Optional.ofNullable(pakoutQty).orElse(0)) // 总出库单数
                .add("pakoutQtyMonth、", Optional.ofNullable(pakoutQtyMonth).orElse(0)) // 总出库单数(当月)
                .add("usersQty", Optional.ofNullable(usersQty).orElse(0)) // 用户数量
                .add("deptQty", Optional.ofNullable(deptQty).orElse(0)) // 部门数量
        );
    }
 
}