bca0f7f7e2c420024c0f2ffe58eec0aaa6ad9e50.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. package org.jeecg.modules.demo.hzz.shjsgc.shxmxx.controller;
  2. import java.io.UnsupportedEncodingException;
  3. import java.io.IOException;
  4. import java.net.URLDecoder;
  5. import java.util.*;
  6. import java.util.stream.Collectors;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9. import org.jeecgframework.poi.excel.ExcelImportUtil;
  10. import org.jeecgframework.poi.excel.def.NormalExcelConstants;
  11. import org.jeecgframework.poi.excel.entity.ExportParams;
  12. import org.jeecgframework.poi.excel.entity.ImportParams;
  13. import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
  14. import org.jeecg.common.system.vo.LoginUser;
  15. import org.apache.shiro.SecurityUtils;
  16. import org.jeecg.common.api.vo.Result;
  17. import org.jeecg.common.system.query.QueryGenerator;
  18. import org.jeecg.common.util.oConvertUtils;
  19. import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.entity.RmJgjlb;
  20. import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.entity.RmShxmxxb;
  21. import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.vo.RmShxmxxbPage;
  22. import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.service.IRmShxmxxbService;
  23. import org.jeecg.modules.demo.hzz.shjsgc.shxmxx.service.IRmJgjlbService;
  24. import org.springframework.beans.BeanUtils;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.web.bind.annotation.*;
  27. import org.springframework.web.servlet.ModelAndView;
  28. import org.springframework.web.multipart.MultipartFile;
  29. import org.springframework.web.multipart.MultipartHttpServletRequest;
  30. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  31. import com.baomidou.mybatisplus.core.metadata.IPage;
  32. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  33. import lombok.extern.slf4j.Slf4j;
  34. import com.alibaba.fastjson.JSON;
  35. import io.swagger.annotations.Api;
  36. import io.swagger.annotations.ApiOperation;
  37. import org.jeecg.common.aspect.annotation.AutoLog;
  38. /**
  39. * @Description: 涉河项目信息表
  40. * @Author: jeecg-boot
  41. * @Date: 2022-02-19
  42. * @Version: V1.0
  43. */
  44. @Api(tags="涉河项目信息表")
  45. @RestController
  46. @RequestMapping("/hzz.shjsgc.shxmxx/rmShxmxxb")
  47. @Slf4j
  48. public class RmShxmxxbController {
  49. @Autowired
  50. private IRmShxmxxbService rmShxmxxbService;
  51. @Autowired
  52. private IRmJgjlbService rmJgjlbService;
  53. /**
  54. * 分页列表查询
  55. *
  56. * @param rmShxmxxb
  57. * @param pageNo
  58. * @param pageSize
  59. * @param req
  60. * @return
  61. */
  62. @AutoLog(value = "涉河项目信息表-分页列表查询")
  63. @ApiOperation(value="涉河项目信息表-分页列表查询", notes="涉河项目信息表-分页列表查询")
  64. @GetMapping(value = "/list")
  65. public Result<?> queryPageList(RmShxmxxb rmShxmxxb,
  66. @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
  67. @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
  68. HttpServletRequest req) {
  69. QueryWrapper<RmShxmxxb> queryWrapper = QueryGenerator.initQueryWrapper(rmShxmxxb, req.getParameterMap());
  70. Page<RmShxmxxb> page = new Page<RmShxmxxb>(pageNo, pageSize);
  71. IPage<RmShxmxxb> pageList = rmShxmxxbService.page(page, queryWrapper);
  72. return Result.OK(pageList);
  73. }
  74. /**
  75. * 添加
  76. *
  77. * @param rmShxmxxbPage
  78. * @return
  79. */
  80. @AutoLog(value = "涉河项目信息表-添加")
  81. @ApiOperation(value="涉河项目信息表-添加", notes="涉河项目信息表-添加")
  82. @PostMapping(value = "/add")
  83. public Result<?> add(@RequestBody RmShxmxxbPage rmShxmxxbPage) {
  84. RmShxmxxb rmShxmxxb = new RmShxmxxb();
  85. BeanUtils.copyProperties(rmShxmxxbPage, rmShxmxxb);
  86. rmShxmxxbService.saveMain(rmShxmxxb, rmShxmxxbPage.getRmJgjlbList());
  87. return Result.OK("添加成功!");
  88. }
  89. /**
  90. * 编辑
  91. *
  92. * @param rmShxmxxbPage
  93. * @return
  94. */
  95. @AutoLog(value = "涉河项目信息表-编辑")
  96. @ApiOperation(value="涉河项目信息表-编辑", notes="涉河项目信息表-编辑")
  97. @PostMapping(value = "/edit")
  98. public Result<?> edit(@RequestBody RmShxmxxbPage rmShxmxxbPage) {
  99. RmShxmxxb rmShxmxxb = new RmShxmxxb();
  100. BeanUtils.copyProperties(rmShxmxxbPage, rmShxmxxb);
  101. RmShxmxxb rmShxmxxbEntity = rmShxmxxbService.getById(rmShxmxxb.getId());
  102. if(rmShxmxxbEntity==null) {
  103. return Result.error("未找到对应数据");
  104. }
  105. rmShxmxxbService.updateMain(rmShxmxxb, rmShxmxxbPage.getRmJgjlbList());
  106. return Result.OK("编辑成功!");
  107. }
  108. /**
  109. * 通过id删除
  110. *
  111. * @param id
  112. * @return
  113. */
  114. @AutoLog(value = "涉河项目信息表-通过id删除")
  115. @ApiOperation(value="涉河项目信息表-通过id删除", notes="涉河项目信息表-通过id删除")
  116. @PostMapping(value = "/delete")
  117. public Result<?> delete(@RequestParam(name="id",required=true) String id) {
  118. rmShxmxxbService.delMain(id);
  119. return Result.OK("删除成功!");
  120. }
  121. /**
  122. * 批量删除
  123. *
  124. * @param ids
  125. * @return
  126. */
  127. @AutoLog(value = "涉河项目信息表-批量删除")
  128. @ApiOperation(value="涉河项目信息表-批量删除", notes="涉河项目信息表-批量删除")
  129. @PostMapping(value = "/deleteBatch")
  130. public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
  131. this.rmShxmxxbService.delBatchMain(Arrays.asList(ids.split(",")));
  132. return Result.OK("批量删除成功!");
  133. }
  134. /**
  135. * 通过id查询
  136. *
  137. * @param id
  138. * @return
  139. */
  140. @AutoLog(value = "涉河项目信息表-通过id查询")
  141. @ApiOperation(value="涉河项目信息表-通过id查询", notes="涉河项目信息表-通过id查询")
  142. @GetMapping(value = "/queryById")
  143. public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
  144. RmShxmxxb rmShxmxxb = rmShxmxxbService.getById(id);
  145. if(rmShxmxxb==null) {
  146. return Result.error("未找到对应数据");
  147. }
  148. return Result.OK(rmShxmxxb);
  149. }
  150. /**
  151. * 通过id查询
  152. *
  153. * @param id
  154. * @return
  155. */
  156. @AutoLog(value = "监管记录通过主表ID查询")
  157. @ApiOperation(value="监管记录主表ID查询", notes="监管记录-通主表ID查询")
  158. @GetMapping(value = "/queryRmJgjlbByMainId")
  159. public Result<?> queryRmJgjlbListByMainId(@RequestParam(name="id",required=true) String id) {
  160. List<RmJgjlb> rmJgjlbList = rmJgjlbService.selectByMainId(id);
  161. return Result.OK(rmJgjlbList);
  162. }
  163. /**
  164. * 导出excel
  165. *
  166. * @param request
  167. * @param rmShxmxxb
  168. */
  169. @RequestMapping(value = "/exportXls")
  170. public ModelAndView exportXls(HttpServletRequest request, RmShxmxxb rmShxmxxb) {
  171. // Step.1 组装查询条件查询数据
  172. QueryWrapper<RmShxmxxb> queryWrapper = QueryGenerator.initQueryWrapper(rmShxmxxb, request.getParameterMap());
  173. LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
  174. //Step.2 获取导出数据
  175. List<RmShxmxxb> queryList = rmShxmxxbService.list(queryWrapper);
  176. // 过滤选中数据
  177. String selections = request.getParameter("selections");
  178. List<RmShxmxxb> rmShxmxxbList = new ArrayList<RmShxmxxb>();
  179. if(oConvertUtils.isEmpty(selections)) {
  180. rmShxmxxbList = queryList;
  181. }else {
  182. List<String> selectionList = Arrays.asList(selections.split(","));
  183. rmShxmxxbList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
  184. }
  185. // Step.3 组装pageList
  186. List<RmShxmxxbPage> pageList = new ArrayList<RmShxmxxbPage>();
  187. for (RmShxmxxb main : rmShxmxxbList) {
  188. RmShxmxxbPage vo = new RmShxmxxbPage();
  189. BeanUtils.copyProperties(main, vo);
  190. List<RmJgjlb> rmJgjlbList = rmJgjlbService.selectByMainId(main.getId());
  191. vo.setRmJgjlbList(rmJgjlbList);
  192. pageList.add(vo);
  193. }
  194. // Step.4 AutoPoi 导出Excel
  195. ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
  196. mv.addObject(NormalExcelConstants.FILE_NAME, "涉河项目信息表列表");
  197. mv.addObject(NormalExcelConstants.CLASS, RmShxmxxbPage.class);
  198. mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("涉河项目信息表数据", "导出人:"+sysUser.getRealname(), "涉河项目信息表"));
  199. mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
  200. return mv;
  201. }
  202. /**
  203. * 通过excel导入数据
  204. *
  205. * @param request
  206. * @param response
  207. * @return
  208. */
  209. @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
  210. public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
  211. MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
  212. Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
  213. for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
  214. MultipartFile file = entity.getValue();// 获取上传文件对象
  215. ImportParams params = new ImportParams();
  216. params.setTitleRows(2);
  217. params.setHeadRows(1);
  218. params.setNeedSave(true);
  219. try {
  220. List<RmShxmxxbPage> list = ExcelImportUtil.importExcel(file.getInputStream(), RmShxmxxbPage.class, params);
  221. for (RmShxmxxbPage page : list) {
  222. RmShxmxxb po = new RmShxmxxb();
  223. BeanUtils.copyProperties(page, po);
  224. rmShxmxxbService.saveMain(po, page.getRmJgjlbList());
  225. }
  226. return Result.OK("文件导入成功!数据行数:" + list.size());
  227. } catch (Exception e) {
  228. log.error(e.getMessage(),e);
  229. return Result.error("文件导入失败:"+e.getMessage());
  230. } finally {
  231. try {
  232. file.getInputStream().close();
  233. } catch (IOException e) {
  234. e.printStackTrace();
  235. }
  236. }
  237. }
  238. return Result.OK("文件导入失败!");
  239. }
  240. /**
  241. * 总项目数
  242. *
  243. *
  244. * @return
  245. */
  246. @AutoLog(value = "涉河项目信息表-总项目数")
  247. @ApiOperation(value="涉河项目信息表-总项目数", notes="涉河项目信息表-总项目数")
  248. @PostMapping(value = "/count")
  249. public Result<?> countters(){
  250. String count = rmShxmxxbService.rmshxmcount();
  251. return Result.OK("查询成功!",count);
  252. }
  253. /**
  254. * 在建项目
  255. *
  256. *
  257. * @return
  258. */
  259. @AutoLog(value = "涉河项目信息表-在建项目")
  260. @ApiOperation(value="涉河项目信息表-在建项目", notes="涉河项目信息表-在建项目")
  261. @PostMapping(value = "/zjxm")
  262. public Result<?> zjxm(){
  263. List<HashMap<String, String>> selectjsqk = rmShxmxxbService.selectjsqk();
  264. return Result.OK("查询成功!",selectjsqk);
  265. }
  266. /**
  267. * 拟建项目
  268. *
  269. *
  270. * @return
  271. */
  272. @AutoLog(value = "涉河项目信息表-拟建项目")
  273. @ApiOperation(value="涉河项目信息表-拟建项目", notes="涉河项目信息表-拟建项目")
  274. @PostMapping(value = "/njxm")
  275. public Result<?> njxm(){
  276. List<HashMap<String, String>> selectnjqk = rmShxmxxbService.selectnjqk();
  277. return Result.OK("查询成功!",selectnjqk);
  278. }
  279. /**
  280. * 总项目数
  281. *
  282. *
  283. * @return
  284. */
  285. @AutoLog(value = "涉河项目信息表-已建项目数")
  286. @ApiOperation(value="涉河项目信息表-已建项目数", notes="涉河项目信息表-已建项目数")
  287. @PostMapping(value = "/yjcount")
  288. public Result<?> yjcountter(){
  289. String count = rmShxmxxbService.yjcount();
  290. return Result.OK("查询成功!",count);
  291. }
  292. @AutoLog(value = "涉河项目信息表-已建项目数")
  293. @ApiOperation(value="涉河项目信息表-已建项目数", notes="涉河项目信息表-已建项目数")
  294. @PostMapping(value = "/zjcount")
  295. public Result<?> zjcountter(){
  296. int count = rmShxmxxbService.zjcount();
  297. String s = Integer.toString(count);
  298. return Result.OK("查询成功!",s);
  299. }
  300. @AutoLog(value = "涉河项目信息表-拟建项目数")
  301. @ApiOperation(value="涉河项目信息表-拟建项目数", notes="涉河项目信息表-拟建项目数")
  302. @PostMapping(value = "/njcount")
  303. public Result<?> njcountter(){
  304. int count = rmShxmxxbService.njcount();
  305. String s = Integer.toString(count);
  306. return Result.OK("查询成功!",s);
  307. }
  308. @AutoLog(value = "涉河项目信息表-饼图总项目数")
  309. @ApiOperation(value="涉河项目信息表-饼图总项目数", notes="涉河项目信息表-饼图总 项目数")
  310. @PostMapping(value = "/xmlxcount")
  311. public Result<?> xmlxcountter(){
  312. List<Integer> xmcount = rmShxmxxbService.xmcount();
  313. return Result.OK("查询成功!",xmcount);
  314. }
  315. /**
  316. * 河流长度
  317. *
  318. *
  319. * @return
  320. */
  321. @AutoLog(value = "涉河项目信息表-河流长度")
  322. @ApiOperation(value="涉河项目信息表-河流长度", notes="涉河项目信息表-河流长度")
  323. @PostMapping(value = "/findAllhlcd")
  324. public Result<?> findAll(){
  325. List<Map<String, Double>> allhlcd = rmShxmxxbService.findAllhlcd();
  326. return Result.OK("查询成功!",allhlcd);
  327. }
  328. // /**
  329. // * 河流长度
  330. // *
  331. // *
  332. // * @return
  333. // */
  334. // @AutoLog(value = "涉河项目信息表-河流长度")
  335. // @ApiOperation(value="涉河项目信息表-河流长度", notes="涉河项目信息表-河流长度")
  336. // @PostMapping(value = "/xmlxtjshir")
  337. // public Result<?> xmlxtj(){
  338. // List<HashMap<String, String>> countxmlx = rmShxmxxbService.countxmlx();
  339. // return Result.OK("查询成功!",countxmlx);
  340. // }
  341. /**
  342. * 监管事件
  343. *
  344. *
  345. * @return
  346. */
  347. @AutoLog(value = "监管事件")
  348. @ApiOperation(value="监管事件", notes="监管事件")
  349. @PostMapping(value = "/countjg")
  350. public Result<?> coutjg(){
  351. List<HashMap<String, String>> countjg = rmShxmxxbService.countjg();
  352. return Result.OK("查询成功!",countjg);
  353. }
  354. }