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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.yiboshi.science.rest.v1;
import com.yiboshi.arch.base.ResponseDataModel;
import com.yiboshi.science.base.Pagination;
import com.yiboshi.science.config.security.SecurityUserHolder;
import com.yiboshi.science.entity.ComYear;
import com.yiboshi.science.entity.SelectListItem;
import com.yiboshi.science.param.dto.ComYearDTO;
import com.yiboshi.science.param.query.ComYearQueryVO;
import com.yiboshi.science.rest.BaseController;
import com.yiboshi.science.service.ComYearService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 功能:年度设置表 接口
*
* @author lkl
* @version 2021-08-26
*/
@Api(tags = "com-year", description = "年度设置表")
@RestController
@RequestMapping("/v1/science-admin/com-year")
public class ComYearController extends BaseController<ComYearService, ComYearQueryVO, ComYearDTO, ComYear> {
@Autowired
private ComYearService comYearService;
/**
* 功能:分页查询
*
* @param vo 查询条件
*/
@ApiOperation(value = "分页查询", httpMethod = "GET", notes = "根据参数获取列表")
@GetMapping
@RequestMapping("/getListByPage")
public ResponseDataModel<Pagination<ComYearDTO>> getListByPage(@Validated ComYearQueryVO vo, BindingResult bindingResult) {
vo.setUnitCode(SecurityUserHolder.getUnitCode());
Pagination<ComYearDTO> page = comYearService.getListByPage(vo);
return ResponseDataModel.ok(page);
}
/**
* 添加/更新年度设置
*
* @param vo
*/
@ApiOperation(value = "添加/更新年度设置", httpMethod = "POST", notes = "添加年度")
@RequestMapping("/addOrUpdateYearInfo")
@PostMapping
public ResponseDataModel<ComYearDTO> addOrUpdateYearInfo(@RequestBody ComYear vo) {
comYearService.addOrUpdateYearInfo(vo);
return ResponseDataModel.ok();
}
/**
* 功能:获取最大年度
*/
@ApiOperation(value = "获取项目申报年度", httpMethod = "GET", notes = "获取项目申报年度")
@GetMapping
@RequestMapping("/getReportYear")
public ResponseDataModel<Map<String, Object>> getReportYear() {
Map<String, Object> data = new HashMap<String, Object>(1) {
{
put("reportYear", comYearService.getReportYear());
}
};
return ResponseDataModel.ok(data);
}
/**
* 功能:获取申报年度下拉列表
*/
@ApiOperation(value = "获取申报年度下拉列表", httpMethod = "GET", notes = "获取申报年度下拉列表")
@GetMapping
@RequestMapping("/getYearSelectItem")
public ResponseDataModel<List<SelectListItem>> getYearSelectItem() {
Integer reportYear = comYearService.getReportYear();
Integer year = reportYear.equals(0) ? Calendar.getInstance().get(Calendar.YEAR) : reportYear;
List<SelectListItem> list = new ArrayList<>();
SelectListItem item;
for (Integer i = year; i > year - 10; i--) {
item = new SelectListItem();
item.setTitle(i + "年");
item.setKey(i.toString());
list.add(item);
}
return ResponseDataModel.ok(list);
}
@ApiOperation(value = "获取项目申报时间", httpMethod = "GET", notes = "获取项目申报时间")
@GetMapping
@RequestMapping("/getYearByTreeCode")
public ResponseDataModel<ComYearDTO> getYearByTreeCode(int type) {
ComYearDTO comYear = new ComYearDTO();
Integer reportYear = 0;
switch (type) {
case 1:
reportYear = comYearService.getReportYear();
break;
case 2:
reportYear = comYearService.getTestYear();
break;
case 3:
reportYear = comYearService.getCheckYear();
break;
}
comYear = comYearService.getYearByTreeCode(SecurityUserHolder.getUnitCode(), reportYear.equals(0) ? Calendar.getInstance().get(Calendar.YEAR) : reportYear, type);
return ResponseDataModel.ok(comYear);
}
@ApiOperation(value = "获取上级单位申报时间", httpMethod = "GET", notes = "获取上级单位申报时间")
@GetMapping
@RequestMapping("/getYearInfo")
public ResponseDataModel<ComYearDTO> getYearInfo(int type) {
return ResponseDataModel.ok(comYearService.getYearInfo(type));
}
}