123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- package org.jeecg.modules.demo.hzz.shjsgc.shxmxx.controller;
- import java.io.UnsupportedEncodingException;
- import java.io.IOException;
- import java.net.URLDecoder;
- import java.util.*;
- import java.util.stream.Collectors;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.jeecgframework.poi.excel.ExcelImportUtil;
- import org.jeecgframework.poi.excel.def.NormalExcelConstants;
- import org.jeecgframework.poi.excel.entity.ExportParams;
- import org.jeecgframework.poi.excel.entity.ImportParams;
- import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
- import org.jeecg.common.system.vo.LoginUser;
- import org.apache.shiro.SecurityUtils;
- import org.jeecg.common.api.vo.Result;
- import org.jeecg.common.system.query.QueryGenerator;
- import org.jeecg.common.util.oConvertUtils;
- import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.entity.RmJgjlb;
- import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.entity.RmShxmxxb;
- import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.vo.RmShxmxxbPage;
- import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.service.IRmShxmxxbService;
- import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.service.IRmJgjlbService;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.web.multipart.MultipartFile;
- import org.springframework.web.multipart.MultipartHttpServletRequest;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import lombok.extern.slf4j.Slf4j;
- import com.alibaba.fastjson.JSON;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.jeecg.common.aspect.annotation.AutoLog;
- /**
- * @Description: 涉河项目信息表
- * @Author: jeecg-boot
- * @Date: 2022-02-19
- * @Version: V1.0
- */
- @Api(tags="涉河项目信息表")
- @RestController
- @RequestMapping("/hzz.shjsgc.shxmxx/rmShxmxxb")
- @Slf4j
- public class RmShxmxxbController {
- @Autowired
- private IRmShxmxxbService rmShxmxxbService;
- @Autowired
- private IRmJgjlbService rmJgjlbService;
-
- /**
- * 分页列表查询
- *
- * @param rmShxmxxb
- * @param pageNo
- * @param pageSize
- * @param req
- * @return
- */
- @AutoLog(value = "涉河项目信息表-分页列表查询")
- @ApiOperation(value="涉河项目信息表-分页列表查询", notes="涉河项目信息表-分页列表查询")
- @GetMapping(value = "/list")
- public Result<?> queryPageList(RmShxmxxb rmShxmxxb,
- @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
- @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
- HttpServletRequest req) {
- QueryWrapper<RmShxmxxb> queryWrapper = QueryGenerator.initQueryWrapper(rmShxmxxb, req.getParameterMap());
- Page<RmShxmxxb> page = new Page<RmShxmxxb>(pageNo, pageSize);
- IPage<RmShxmxxb> pageList = rmShxmxxbService.page(page, queryWrapper);
- return Result.OK(pageList);
- }
-
- /**
- * 添加
- *
- * @param rmShxmxxbPage
- * @return
- */
- @AutoLog(value = "涉河项目信息表-添加")
- @ApiOperation(value="涉河项目信息表-添加", notes="涉河项目信息表-添加")
- @PostMapping(value = "/add")
- public Result<?> add(@RequestBody RmShxmxxbPage rmShxmxxbPage) {
- RmShxmxxb rmShxmxxb = new RmShxmxxb();
- BeanUtils.copyProperties(rmShxmxxbPage, rmShxmxxb);
- rmShxmxxbService.saveMain(rmShxmxxb, rmShxmxxbPage.getRmJgjlbList());
- return Result.OK("添加成功!");
- }
-
- /**
- * 编辑
- *
- * @param rmShxmxxbPage
- * @return
- */
- @AutoLog(value = "涉河项目信息表-编辑")
- @ApiOperation(value="涉河项目信息表-编辑", notes="涉河项目信息表-编辑")
- @PostMapping(value = "/edit")
- public Result<?> edit(@RequestBody RmShxmxxbPage rmShxmxxbPage) {
- RmShxmxxb rmShxmxxb = new RmShxmxxb();
- BeanUtils.copyProperties(rmShxmxxbPage, rmShxmxxb);
- RmShxmxxb rmShxmxxbEntity = rmShxmxxbService.getById(rmShxmxxb.getId());
- if(rmShxmxxbEntity==null) {
- return Result.error("未找到对应数据");
- }
- rmShxmxxbService.updateMain(rmShxmxxb, rmShxmxxbPage.getRmJgjlbList());
- return Result.OK("编辑成功!");
- }
-
- /**
- * 通过id删除
- *
- * @param id
- * @return
- */
- @AutoLog(value = "涉河项目信息表-通过id删除")
- @ApiOperation(value="涉河项目信息表-通过id删除", notes="涉河项目信息表-通过id删除")
- @PostMapping(value = "/delete")
- public Result<?> delete(@RequestParam(name="id",required=true) String id) {
- rmShxmxxbService.delMain(id);
- return Result.OK("删除成功!");
- }
-
- /**
- * 批量删除
- *
- * @param ids
- * @return
- */
- @AutoLog(value = "涉河项目信息表-批量删除")
- @ApiOperation(value="涉河项目信息表-批量删除", notes="涉河项目信息表-批量删除")
- @PostMapping(value = "/deleteBatch")
- public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
- this.rmShxmxxbService.delBatchMain(Arrays.asList(ids.split(",")));
- return Result.OK("批量删除成功!");
- }
-
- /**
- * 通过id查询
- *
- * @param id
- * @return
- */
- @AutoLog(value = "涉河项目信息表-通过id查询")
- @ApiOperation(value="涉河项目信息表-通过id查询", notes="涉河项目信息表-通过id查询")
- @GetMapping(value = "/queryById")
- public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
- RmShxmxxb rmShxmxxb = rmShxmxxbService.getById(id);
- if(rmShxmxxb==null) {
- return Result.error("未找到对应数据");
- }
- return Result.OK(rmShxmxxb);
- }
-
- /**
- * 通过id查询
- *
- * @param id
- * @return
- */
- @AutoLog(value = "监管记录通过主表ID查询")
- @ApiOperation(value="监管记录主表ID查询", notes="监管记录-通主表ID查询")
- @GetMapping(value = "/queryRmJgjlbByMainId")
- public Result<?> queryRmJgjlbListByMainId(@RequestParam(name="id",required=true) String id) {
- List<RmJgjlb> rmJgjlbList = rmJgjlbService.selectByMainId(id);
- return Result.OK(rmJgjlbList);
- }
- /**
- * 导出excel
- *
- * @param request
- * @param rmShxmxxb
- */
- @RequestMapping(value = "/exportXls")
- public ModelAndView exportXls(HttpServletRequest request, RmShxmxxb rmShxmxxb) {
- // Step.1 组装查询条件查询数据
- QueryWrapper<RmShxmxxb> queryWrapper = QueryGenerator.initQueryWrapper(rmShxmxxb, request.getParameterMap());
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
- //Step.2 获取导出数据
- List<RmShxmxxb> queryList = rmShxmxxbService.list(queryWrapper);
- // 过滤选中数据
- String selections = request.getParameter("selections");
- List<RmShxmxxb> rmShxmxxbList = new ArrayList<RmShxmxxb>();
- if(oConvertUtils.isEmpty(selections)) {
- rmShxmxxbList = queryList;
- }else {
- List<String> selectionList = Arrays.asList(selections.split(","));
- rmShxmxxbList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
- }
- // Step.3 组装pageList
- List<RmShxmxxbPage> pageList = new ArrayList<RmShxmxxbPage>();
- for (RmShxmxxb main : rmShxmxxbList) {
- RmShxmxxbPage vo = new RmShxmxxbPage();
- BeanUtils.copyProperties(main, vo);
- List<RmJgjlb> rmJgjlbList = rmJgjlbService.selectByMainId(main.getId());
- vo.setRmJgjlbList(rmJgjlbList);
- pageList.add(vo);
- }
- // Step.4 AutoPoi 导出Excel
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
- mv.addObject(NormalExcelConstants.FILE_NAME, "涉河项目信息表列表");
- mv.addObject(NormalExcelConstants.CLASS, RmShxmxxbPage.class);
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("涉河项目信息表数据", "导出人:"+sysUser.getRealname(), "涉河项目信息表"));
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
- return mv;
- }
- /**
- * 通过excel导入数据
- *
- * @param request
- * @param response
- * @return
- */
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
- MultipartFile file = entity.getValue();// 获取上传文件对象
- ImportParams params = new ImportParams();
- params.setTitleRows(2);
- params.setHeadRows(1);
- params.setNeedSave(true);
- try {
- List<RmShxmxxbPage> list = ExcelImportUtil.importExcel(file.getInputStream(), RmShxmxxbPage.class, params);
- for (RmShxmxxbPage page : list) {
- RmShxmxxb po = new RmShxmxxb();
- BeanUtils.copyProperties(page, po);
- rmShxmxxbService.saveMain(po, page.getRmJgjlbList());
- }
- return Result.OK("文件导入成功!数据行数:" + list.size());
- } catch (Exception e) {
- log.error(e.getMessage(),e);
- return Result.error("文件导入失败:"+e.getMessage());
- } finally {
- try {
- file.getInputStream().close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return Result.OK("文件导入失败!");
- }
- /**
- * 总项目数
- *
- *
- * @return
- */
- @AutoLog(value = "涉河项目信息表-总项目数")
- @ApiOperation(value="涉河项目信息表-总项目数", notes="涉河项目信息表-总项目数")
- @PostMapping(value = "/count")
- public Result<?> countters(){
- String count = rmShxmxxbService.rmshxmcount();
- return Result.OK("查询成功!",count);
- }
- /**
- * 在建项目
- *
- *
- * @return
- */
- @AutoLog(value = "涉河项目信息表-在建项目")
- @ApiOperation(value="涉河项目信息表-在建项目", notes="涉河项目信息表-在建项目")
- @PostMapping(value = "/zjxm")
- public Result<?> zjxm(){
- List<HashMap<String, String>> selectjsqk = rmShxmxxbService.selectjsqk();
- return Result.OK("查询成功!",selectjsqk);
- }
- /**
- * 拟建项目
- *
- *
- * @return
- */
- @AutoLog(value = "涉河项目信息表-拟建项目")
- @ApiOperation(value="涉河项目信息表-拟建项目", notes="涉河项目信息表-拟建项目")
- @PostMapping(value = "/njxm")
- public Result<?> njxm(){
- List<HashMap<String, String>> selectnjqk = rmShxmxxbService.selectnjqk();
- return Result.OK("查询成功!",selectnjqk);
- }
- /**
- * 总项目数
- *
- *
- * @return
- */
- @AutoLog(value = "涉河项目信息表-已建项目数")
- @ApiOperation(value="涉河项目信息表-已建项目数", notes="涉河项目信息表-已建项目数")
- @PostMapping(value = "/yjcount")
- public Result<?> yjcountter(){
- String count = rmShxmxxbService.yjcount();
- return Result.OK("查询成功!",count);
- }
- @AutoLog(value = "涉河项目信息表-已建项目数")
- @ApiOperation(value="涉河项目信息表-已建项目数", notes="涉河项目信息表-已建项目数")
- @PostMapping(value = "/zjcount")
- public Result<?> zjcountter(){
- int count = rmShxmxxbService.zjcount();
- String s = Integer.toString(count);
- return Result.OK("查询成功!",s);
- }
- @AutoLog(value = "涉河项目信息表-拟建项目数")
- @ApiOperation(value="涉河项目信息表-拟建项目数", notes="涉河项目信息表-拟建项目数")
- @PostMapping(value = "/njcount")
- public Result<?> njcountter(){
- int count = rmShxmxxbService.njcount();
- String s = Integer.toString(count);
- return Result.OK("查询成功!",s);
- }
- @AutoLog(value = "涉河项目信息表-饼图总项目数")
- @ApiOperation(value="涉河项目信息表-饼图总项目数", notes="涉河项目信息表-饼图总 项目数")
- @PostMapping(value = "/xmlxcount")
- public Result<?> xmlxcountter(){
- List<Integer> xmcount = rmShxmxxbService.xmcount();
- return Result.OK("查询成功!",xmcount);
- }
- /**
- * 河流长度
- *
- *
- * @return
- */
- @AutoLog(value = "涉河项目信息表-河流长度")
- @ApiOperation(value="涉河项目信息表-河流长度", notes="涉河项目信息表-河流长度")
- @PostMapping(value = "/findAllhlcd")
- public Result<?> findAll(){
- List<Map<String, Double>> allhlcd = rmShxmxxbService.findAllhlcd();
- return Result.OK("查询成功!",allhlcd);
- }
- // /**
- // * 河流长度
- // *
- // *
- // * @return
- // */
- // @AutoLog(value = "涉河项目信息表-河流长度")
- // @ApiOperation(value="涉河项目信息表-河流长度", notes="涉河项目信息表-河流长度")
- // @PostMapping(value = "/xmlxtjshir")
- // public Result<?> xmlxtj(){
- // List<HashMap<String, String>> countxmlx = rmShxmxxbService.countxmlx();
- // return Result.OK("查询成功!",countxmlx);
- // }
- /**
- * 监管事件
- *
- *
- * @return
- */
- @AutoLog(value = "监管事件")
- @ApiOperation(value="监管事件", notes="监管事件")
- @PostMapping(value = "/countjg")
- public Result<?> coutjg(){
- List<HashMap<String, String>> countjg = rmShxmxxbService.countjg();
- return Result.OK("查询成功!",countjg);
- }
- }
|