yxm
2024-07-01 fc2adc3521931c2f7bc5b2f3a3d94ebf407828d6
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
package cn.gistack.sm.sjztmd.controller;
 
import cn.gistack.sm.sjztmd.entity.TbDykeInvestigation;
import cn.gistack.sm.sjztmd.entity.TbDykeInvestigationState;
import cn.gistack.sm.sjztmd.service.IAttResBaseService;
import cn.gistack.sm.sjztmd.service.ITbDykeInvestigationService;
import cn.gistack.sm.sjztmd.service.ITbDykeInvestigationStateService;
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsBar;
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsParams;
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsPie;
import cn.gistack.sm.sjztmd.vo.AttResBaseGeneralInvestigationVO;
import cn.gistack.sm.sjztmd.vo.DyketionVO;
import cn.gistack.sm.sjztmd.vo.TbDykeInvestigationParam;
import cn.gistack.sm.sjztmd.vo.TbResDykeVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.StringUtil;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
 
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @PROJECT_NAME: skjcmanager
 * @DESCRIPTION:
 * @USER: aix
 * @DATE: 2024/1/3 14:39
 */
@Slf4j
@Api(tags = "堤防普查")
@RestController
@RequestMapping("/sjztmd/tbDykeInvestigation")
@AllArgsConstructor
public class TbDykeInvestigationController {
 
    private ITbDykeInvestigationService tbDykeInvestigationService;
    private ITbDykeInvestigationStateService tbDykeInvestigationStateService;
    private IAttResBaseService attResBaseService;
 
    @ApiOperation(value = "中台水库-分页列表查询", notes = "中台水库-分页列表查询")
    @GetMapping(value = "/queryPageResList")
    public R queryPageResList(AttResBaseGeneralInvestigationVO attResBase, Query query) {
        Object pageList = attResBaseService.selectAttResBaseGeneralInvestigation(Condition.getPage(query), attResBase);
        return R.data(pageList);
    }
 
    @GetMapping("/list")
    @ApiOperation(value = "分页", notes = "白蚁普查分页")
    public R list(@ApiIgnore TbDykeInvestigation param, Query query) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (null != param.getCheckState())
            queryWrapper.eq("\"check_state\"", param.getCheckState());
        if (!StringUtil.isBlank(param.getDykeName()))
            queryWrapper.like("\"dyke_name\"", param.getDykeName());
        if (!StringUtil.isBlank(param.getDykeGuid()))
            queryWrapper.eq("\"dyke_guid\"", param.getDykeGuid());
        if (!StringUtil.isBlank(param.getCreateUser()))
            queryWrapper.eq("\"create_user\"", param.getCreateUser());
        if (null != param.getTbYear())
            queryWrapper.like("\"tb_year\"", param.getTbYear());
        if (!StringUtil.isBlank(param.getTbQuarter()))
            queryWrapper.like("\"tb_quarter\"", param.getTbQuarter());
        return R.data(tbDykeInvestigationService.page(Condition.getPage(query), queryWrapper));
    }
 
    @ApiOperation(value = "白蚁普查-校核接口", notes = "白蚁普查-添加或者修改")
    @PostMapping("/checkInfoByDykeGuid")
    public R checkInfoByResGuid(@RequestBody TbDykeInvestigation tbDykeInvestigation) {
 
        if (tbDykeInvestigation.getTbStateId() == null || tbDykeInvestigation.getCheckState() == null) {
            return R.fail(-1,"参数不对");
        }
 
        //查询根据状态id查询普查记录表
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("\"tb_state_id\"", tbDykeInvestigation.getTbStateId());
        List<TbDykeInvestigation> list = tbDykeInvestigationService.list(queryWrapper);
        List<TbDykeInvestigation> editList = list.stream().map(categoryEntity -> {
                categoryEntity.setCheckState(tbDykeInvestigation.getCheckState());  // 给每个categoryEntity对象的EvaluateTaskId属性设置新值
                return categoryEntity;  // 返回修改后的对象
            })
            .collect(Collectors.toList());
 
        TbDykeInvestigationState tbDykeInvestigationState = new TbDykeInvestigationState();
        tbDykeInvestigationState.setGuid(tbDykeInvestigation.getTbStateId());
        tbDykeInvestigationState.setCheckState(tbDykeInvestigation.getCheckState());
 
 
        //更新普查记录表状态和状态表状态
        return R.status(tbDykeInvestigationService.updateBatchById(editList) && tbDykeInvestigationStateService.updateById(tbDykeInvestigationState) );
    }
 
    @ApiOperation(value = "白蚁普查-添加或者修改", notes = "白蚁普查-添加或者修改")
    @PostMapping(value = "/submit")
    public R submit(@RequestBody TbDykeInvestigation tbDykeInvestigation) {
//        if (tbDykeInvestigation.getGuid() == null) {
        tbDykeInvestigation.setCreateTime(new Date());
//        }
 
        return tbDykeInvestigationService.saveOrUpdateBy(tbDykeInvestigation);
    }
 
    @ApiOperation(value = "白蚁普查-添加或者修改", notes = "白蚁普查-添加或者修改")
    @PostMapping(value = "/submitBatch")
    public R submit(@RequestBody TbDykeInvestigationParam tbResGeneralInvestigationParam) {
 
        return tbDykeInvestigationService.saveOrUpdateByBatch(tbResGeneralInvestigationParam);
    }
 
    @PostMapping("/remove")
    @ApiOperation(value = "物理删除", notes = "传入id")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
 
//        return R.status(tbDykeInvestigationService.removeBatchByIds(Arrays.asList(ids.split(","))));
        return R.status(tbDykeInvestigationService.removeByIds(Arrays.asList(ids.split(","))));
    }
 
    @PostMapping("/getInvestigationListByStateId")
    @ApiOperation(value = "根据状态id获取普查集合", notes = "传入id")
    public R getInvestigationListByStateId(String stateId){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("\"tb_state_id\"",stateId);
 
        List<TbDykeInvestigation> list = tbDykeInvestigationService.list(queryWrapper);
        return R.data(list);
    }
 
    @GetMapping("/downloadZip")
    @ApiOperation(value = "批量导出白蚁普查的图片视频zip文件")
    public R downloadZip(Query query,String type) throws IOException {
 
        List<String> msg = tbDykeInvestigationService.downZip(Condition.getPage(query),type);
 
        return  R.data(msg);
    }
 
    @GetMapping("/downloadZipCopy")
    @ApiOperation(value = "批量导出白蚁普查的图片视频zip文件")
    public R downloadZipCopy(Query query, String type,TbResDykeVO tbResDykeVO)  {
 
        List<DyketionVO> msg = tbDykeInvestigationService.downloadZipCopy(Condition.getPage(query),type,tbResDykeVO);
 
        return  R.data(msg);
    }
 
    @GetMapping("/statisticsPie")
    public R statisticsPie(StatisticsParams statisticsParams){
        StatisticsPie statisticsPie = tbDykeInvestigationService.statisticsPie(statisticsParams);
        return R.data(statisticsPie);
    }
 
    @GetMapping("/statisticsBar")
    public R statisticsBar(StatisticsParams statisticsParams){
        List<StatisticsBar> list = tbDykeInvestigationService.statisticsBar(statisticsParams);
        return R.data(list);
    }
 
 
 
}