tangzy
2021-09-13 139987154fa26282b30cf237c13d999f5f5547a2
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
/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.modules.water.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.water.entity.water;
import org.springblade.modules.water.service.WaterService;
import org.springblade.modules.water.vo.WaterVO;
import org.springblade.modules.water.wrapper.WaterWrapper;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
 
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 *  控制器
 *
 * @author Blade
 * @since 2019-11-07
 */
@RestController
@AllArgsConstructor
@RequestMapping("/water")
@Api(value = "", tags = "接口")
public class WaterController extends BladeController {
 
    private WaterService waterService;
 
    /**
    * 详情
    */
    @ApiLog("详情")
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入tmpR")
    public R<WaterVO> detail(water waterLine) {
        water detail = waterService.getOne(Condition.getQueryWrapper(waterLine));
        return R.data(WaterWrapper.build().entityVO(detail));
    }
 
 
    /**
    * 新增
    */
    @ApiLog("新增")
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "")
    public R save(@Valid @RequestBody water waterLine) {
        return R.status(waterService.save(waterLine));
    }
 
    /**
    * 修改
    */
    @ApiLog("修改")
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入tmpR")
    public R update(@Valid @RequestBody water waterLine) {
        return R.status(waterService.updateById(waterLine));
    }
 
    /**
    * 新增或修改
    */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "")
    public R submit(@Valid @RequestBody water waterLine) {
        return R.status(waterService.saveOrUpdate(waterLine));
    }
 
    /**
     * 删除
     * @param ids
     * @return
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 8)
    public R remove(@RequestParam String ids) {
        return R.status(waterService.removeByIds(Func.toLongList(ids)));
    }
 
    /**
     * 子列表
     */
    @GetMapping("/child-list")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "code", value = "字典编号", paramType = "query", dataType = "string"),
        @ApiImplicitParam(name = "dictValue", value = "字典名称", paramType = "query", dataType = "string"),
        @ApiImplicitParam(name = "parentId", value = "字典名称", paramType = "query", dataType = "string")
    })
    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "列表", notes = "传入dict")
    public R<IPage<WaterVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId, Query query) {
        return R.data(waterService.childList(dict, parentId, query));
    }
 
    /**
     * 分页
     */
    @GetMapping("/childpage")
    @ApiOperation(value = "分页", notes = "传入tmpR")
    public R<IPage<WaterVO>> childpage(@ApiIgnore @RequestParam Map<String, Object> water, Query query) {
        IPage<water> pages = waterService.page(Condition.getPage(query), Condition.getQueryWrapper(water,water.class).orderByAsc("origin"));
        return R.data(WaterWrapper.build().pageVO(pages));
    }
 
    /**
     * 模糊查询
     */
    @PostMapping("/queryList")
    @ApiOperationSupport(order =10)
    @ApiOperation(value = "模糊查询", notes = "")
    public R queryList(String pid, String loc) {
        return R.data(waterService.queryList(pid,loc));
    }
 
    @RequestMapping(value = "/saveFile",method = RequestMethod.POST)
    @ResponseBody
    public R saveFile(@RequestParam("file") MultipartFile file) {
        waterService.upLoadFile(file);
        return R.success("成功");
    }
 
 
 
    /**
     * 河道断面
     */
    @PostMapping("/selectInfoh")
    @ApiOperation(value = "模糊查询", notes = "")
    public R selectInfoh(String stcd) {
        Map<String, Object> map = new HashMap<>(16);
        List<Map<String, Object>> lists = new ArrayList<>();
        List<Map<String, Object>> list = waterService.selectInfoh(stcd);
        List<Map<String, String>> selectZ = waterService.selectZ(stcd);
        List<Map<String, String>> maps = waterService.selectJ(stcd);
        if (maps.size() == 0){
            map.put("List",list);
            map.put("wrz",0);
            map.put("z",selectZ.get(0).get("Z"));
            map.put("obhtz",0);
            map.put("hlz",0);
        }
        else {
            map.put("List",list);
            map.put("z",selectZ.get(0).get("Z"));
            map.put("wrz",maps.get(0).get("WRZ"));
            map.put("obhtz",maps.get(0).get("OBHTZ"));
            map.put("hlz",maps.get(0).get("HLZ"));
        }
        lists.add(map);
        return R.data(lists);
    }
 
}