ke
2024-07-19 08a962d2925baa255207fdf979e6fee794f1773b
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package cn.gistack.sm.sjztmd.controller;
 
import cn.gistack.sm.exam.vo.ExamPlanVO;
import cn.gistack.sm.sjztmd.entity.AttAdBase;
import cn.gistack.sm.sjztmd.entity.AttResBase;
import cn.gistack.sm.sjztmd.entity.AttResStagChar;
import cn.gistack.sm.sjztmd.excel.AttResBaseUserExcel;
import cn.gistack.sm.sjztmd.service.IAttAdBaseService;
import cn.gistack.sm.sjztmd.service.IAttResBaseService;
import cn.gistack.sm.sjztmd.vo.AttAdBaseVO;
import cn.gistack.sm.sjztmd.vo.AttResBaseVO;
import cn.gistack.sm.sjztmd.vo.AttResWithRainfall;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import io.swagger.annotations.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
 
/**
 * @ClassName AttResBaseController
 * @Description TODO
 * @Author aix
 * @Date 2023/4/21 20:09
 * @Version 1.0
 */
@Slf4j
@Api(tags = "中台水库")
@RestController
@RequestMapping("/sjztmd/attRes")
@AllArgsConstructor
public class AttResBaseController extends BladeController {
 
    private final IAttResBaseService attResBaseService;
 
    @ApiOperation(value = "中台水库-分页列表查询", notes = "中台水库-分页列表查询")
    @GetMapping(value = "/list")
    public R queryPageList(AttResBase attResBase, Query query) {
//        IPage<AttResBase> pageList = attResBaseService.page(Condition.getPage(query), Condition.getQueryWrapper(attResBase));
        IPage<AttResBase> pageList = attResBaseService.selectAttResBasePage(Condition.getPage(query), attResBase);
        return R.data(pageList);
    }
 
    @ApiOperation(value = "中台水库-查询该行政区下的水库", notes = "中台水库-查询该行政区下的水库")
    @GetMapping(value = "/getListByRegion")
    public R getListByRegion(@ApiIgnore @RequestParam Map<String, Object> obj,Query query) {
        IPage<AttResBaseVO> pageList = attResBaseService.getListByRegion(Condition.getPage(query),obj);
        return R.data(pageList);
    }
 
    @ApiOperation(value = "中台水库-获取水库详情", notes = "中台水库-获取水库详情")
    @GetMapping(value = "/getDetailByCode")
    public R getDetailByCode(String code) {
        AttResBase attResBase = attResBaseService.getDetailByCode(code);
        return R.data(attResBase);
    }
 
    /**
     * 获取水库对应责任人分页数据
     * @param params 条件查询参数对象
     * @param query 分页查询参数对象
     * @return
     */
    @ApiOperation(value = "中台水库-获取水库对应责任人分页数据", notes = "中台水库-获取水库对应责任人分页数据")
    @GetMapping(value = "/getAttResBaseUserPage")
    public R getAttResBaseUserPage(@RequestParam Map<String, Object> params,Query query) {
        return R.data(attResBaseService.getAttResBaseUserPage(Condition.getPage(query),params));
    }
 
 
    /**
     * 导出责任人数据
     * @param params 条件查询参数对象
     * @return
     */
    @ApiOperation(value = "中台水库-导出责任人数据", notes = "中台水库-导出责任人数据")
    @GetMapping(value = "/exportAttResBaseUser")
    public void exportAttResBaseUser(@RequestParam Map<String, Object> params, HttpServletResponse response) {
 
        List<AttResBaseUserExcel> list = attResBaseService.exportAttResBaseUser(params);
 
        /**
         * 如果不是超级管理员数据需要处理 处理逻辑如下
         * (1)大中型水库的行政责任人电话都不显示。
         * (2)省直管且是大中型的6座水库(漳河、高关、富水、王英、吴岭、蔡贤水库)的主管部门负责人手机号不显示。
         * (3)三峡、葛洲坝、隔河岩、高坝州、丹江口(以后可以手动加)除了巡查责任人外的责任人的手机号码不显示。
         */
        if (!AuthUtil.isAdministrator()) {
            for (AttResBaseUserExcel excel:list) {
                if (excel.getEngScal().equals("大(1)型") || excel.getEngScal().equals("大(2)型") || excel.getEngScal().equals("中型")) {
                    excel.setAreaPhone("");
                }
                if (excel.getName().equals("漳河水库") || excel.getName().equals("高关水库") || excel.getName().equals("富水漳河水库")
                    || excel.getName().equals("王英水库") || excel.getName().equals("吴岭水库") || excel.getName().equals("蔡贤水库")) {
                    excel.setCustomsPhone("");
                }
                if (excel.getName().equals("三峡") || excel.getName().equals("葛洲坝") || excel.getName().equals("隔河岩")
                    || excel.getName().equals("高坝州") || excel.getName().equals("丹江口")) {
                    excel.setAreaPhone("");//行政
                    excel.setCustomsPhone("");//主管
                    excel.setManageUnitPhone("");//管理单位
                    excel.setTechnologyPhone("");//技术
                }
            }
        }
 
        ExcelUtil.export(response, "水库责任人数据数据" + DateUtil.time(), "水库责任人数据表", list, AttResBaseUserExcel.class);
    }
 
 
 
    /**
     * 编辑
     *
     * @param attResBase
     * @return
     */
    @ApiOperation(value = "水库信息-编辑", notes = "水库信息-编辑")
    @PostMapping(value = "/edit")
    public R edit(@RequestBody AttResBase attResBase) {
        if (StringUtil.isBlank(attResBase.getGuid())) {
            return R.fail("参数不正确");
        }
        return R.data(attResBaseService.updateResBaseByGuid(attResBase));
    }
 
    /**
     * 根据水库编码获取行政区数据
     * @param guid
     * @return
     */
    @GetMapping(value = "/getWaterRegionInfoByResGuid")
    public R getWaterRegionInfoByResGuid(String guid) {
        return R.data(attResBaseService.getWaterRegionInfoByResGuid(guid));
    }
 
    /**
     * 更新报汛状态
     * @param ids
     * @param status
     * @return
     */
    @PostMapping(value = "/updateIsShowStatus")
    public R updateIsShowStatus(String ids,Integer status){
        return R.status(attResBaseService.updateIsShowStatus(ids,status));
    }
 
 
    /**
     * 根据预报降雨等值面图,识别出雨量范围内的水库清单
     * @param minRainfall 最小降雨量
     * @param maxRainfall 最大降雨量
     * @param dayIndex 预报的时段,0-2代表未来3天
     * @return 水库对象列表
     */
    @ApiOperation(value = "根据预报降雨等值面图,识别出雨量范围内的水库清单", notes = "根据预报降雨等值面图,识别出雨量范围内的水库清单")
    @PostMapping(value = "/getAttResByRainfall")
    public R<List<AttResWithRainfall>> getAttResByRainfall(
            @ApiParam(value = "最小降雨量") @RequestParam String minRainfall,
            @ApiParam(value = "最大降雨量") @RequestParam String maxRainfall,
            @ApiParam(value = "预报的时段,0-2代表未来3天") @RequestParam String dayIndex) {
        return R.data(attResBaseService.getAttResByRainfall(minRainfall, maxRainfall, dayIndex));
    }
 
    /**
     * 统计不同日降水量范围下的站点个数
     * @param dayIndex 预报的时段,0-2代表未来3天
     * @return 站点个数列表
     */
    @ApiOperation(value = "统计不同日降水量范围的站点个数", notes = "统计不同日降水量范围的站点个数")
    @PostMapping(value = "/getAttResNumByRainfall")
    public R<int[]> getAttResNumByRainfall(@ApiParam(value = "预报的时段,0-2代表未来3天") @RequestParam String dayIndex) {
        return R.data(attResBaseService.getAttResNumByRainfall(dayIndex));
    }
}