xieb
2024-03-17 6de28f3d62a4f77267628eaba28fecaebec8cb27
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
package cn.gistack.sm.sjztmd.controller;
 
import cn.gistack.sm.sjztmd.entity.TbDykeInvestigation;
import cn.gistack.sm.sjztmd.service.IAttResBaseService;
import cn.gistack.sm.sjztmd.service.ITbDykeInvestigationService;
import cn.gistack.sm.sjztmd.vo.AttResBaseGeneralInvestigationVO;
import cn.gistack.sm.sjztmd.vo.TbDykeInvestigationParam;
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.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 IAttResBaseService attResBaseService;
 
    @ApiOperation(value = "中台水库-分页列表查询", notes = "中台水库-分页列表查询")
    @GetMapping(value = "/queryPageResList")
    public R queryPageResList(AttResBaseGeneralInvestigationVO attResBase, Query query) {
        IPage<AttResBaseGeneralInvestigationVO> 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.getDykeGuid() == null || tbDykeInvestigation.getCheckState() == null) {
            return R.fail(-1,"参数不对");
        }
 
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("\"dyke_guid\"", tbDykeInvestigation.getDykeGuid());
        List<TbDykeInvestigation> list = tbDykeInvestigationService.list(queryWrapper);
        List<TbDykeInvestigation> editList = list.stream().map(categoryEntity -> {
                categoryEntity.setCheckState(tbDykeInvestigation.getCheckState());  // 给每个categoryEntity对象的EvaluateTaskId属性设置新值
                return categoryEntity;  // 返回修改后的对象
            })
            .collect(Collectors.toList());
        return R.status(tbDykeInvestigationService.updateBatchById(editList));
    }
 
    @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 id) {
        return R.status(tbDykeInvestigationService.removeById(id));
    }
 
    @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);
    }
 
}