| | |
| | | @Value("${excel.userurl}") |
| | | private String excelUrl; |
| | | @Value("${excel.carUrl}") |
| | | private String carUrl="http://panzhihua.nhys.cdnhxx.com/web/%e8%bd%a6%e8%be%86%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx"; |
| | | private String carUrl = "http://panzhihua.nhys.cdnhxx.com/web/%e8%bd%a6%e8%be%86%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx"; |
| | | @Value("${excel.companyUrl}") |
| | | private String companyUrl="http://panzhihua.nhys.cdnhxx.com/web/%e5%ae%9e%e6%9c%89%e5%8d%95%e4%bd%8d%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx"; |
| | | private String companyUrl = "http://panzhihua.nhys.cdnhxx.com/web/%e5%ae%9e%e6%9c%89%e5%8d%95%e4%bd%8d%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx"; |
| | | @Value("${excel.assetsUrl}") |
| | | private String assetsUrl="http://panzhihua.nhys.cdnhxx.com/web/%e5%ae%9e%e6%9c%89%e5%8d%95%e4%bd%8d%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx"; |
| | | private String assetsUrl = "http://panzhihua.nhys.cdnhxx.com/web/%e5%ae%9e%e6%9c%89%e5%8d%95%e4%bd%8d%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx"; |
| | | |
| | | // FTP 登录用户名 |
| | | @Value("${ftp.username}") |
| | |
| | | @Value("${ftp.url}") |
| | | private String url; |
| | | |
| | | @ApiOperation(value = "分页查询车辆管理列表",response = ComMngCarVO.class) |
| | | @ApiOperation(value = "分页查询车辆管理列表", response = ComMngCarVO.class) |
| | | @PostMapping("/car/page") |
| | | public R pageQueryComMngCar(@RequestBody PageComMngCarDTO pageComMngCarDTO) { |
| | | pageComMngCarDTO.setCommunityId(this.getCommunityId()); |
| | |
| | | @PostMapping(value = "/car/import", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R downloadTemplate(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | String fileName = file.getOriginalFilename(); //获取文件名 |
| | | log.info("传入文件名字【{}】",fileName); |
| | | log.info("传入文件名字【{}】", fileName); |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | EasyExcel.read(inputStream, ComMngCarExcelVO.class, new ComMngCarExcelListen(communityService,this.getCommunityId())).sheet().doRead(); |
| | | EasyExcel.read(inputStream, ComMngCarExcelVO.class, new ComMngCarExcelListen(communityService, this.getCommunityId())).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
| | |
| | | |
| | | @ApiOperation(value = "下载居民导入模板") |
| | | @GetMapping("/user/template") |
| | | @ApiImplicitParam(name ="id",value = "小区id",required = true) |
| | | public R exportUser(@RequestParam("id") Long id ){ |
| | | @ApiImplicitParam(name = "id", value = "小区id", required = true) |
| | | public R exportUser(@RequestParam("id") Long id) { |
| | | // 检查小区是否已经批量设置过房屋并且返回小区房屋门号规则 |
| | | R r=communityService.checkAreaHouse(id); |
| | | R r = communityService.checkAreaHouse(id); |
| | | if (R.isOk(r)) { |
| | | // 生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 |
| | | ComMngStructAreaVO comMngStructAreaVO= JSONObject.parseObject(JSONObject.toJSONString(r.getData()),ComMngStructAreaVO.class); |
| | | ComMngStructAreaVO comMngStructAreaVO = JSONObject.parseObject(JSONObject.toJSONString(r.getData()), ComMngStructAreaVO.class); |
| | | String areaName = comMngStructAreaVO.getAreaName(); |
| | | String roleFloor = comMngStructAreaVO.getRoleFloor(); |
| | | String roleConnector = comMngStructAreaVO.getRoleConnector(); |
| | | String roleDoor = comMngStructAreaVO.getRoleDoor(); |
| | | String doorNumber="1-1-1-"+roleFloor+roleConnector+roleDoor; |
| | | String doorNumber = "1-1-1-" + roleFloor + roleConnector + roleDoor; |
| | | // String url="http://www.psciio.com/web/excel/"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | String name=areaName + ".xlsx"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | String name = areaName + ".xlsx"; |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, EexcelUserDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(areaName+"居民导入模板").build(); |
| | | List<EexcelUserDTO> eexcelUserDTOS=new ArrayList<>(); |
| | | EexcelUserDTO eexcelUserDTO=new EexcelUserDTO(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(areaName + "居民导入模板").build(); |
| | | List<EexcelUserDTO> eexcelUserDTOS = new ArrayList<>(); |
| | | EexcelUserDTO eexcelUserDTO = new EexcelUserDTO(); |
| | | eexcelUserDTO.setOrder("例子(可不用删除)"); |
| | | eexcelUserDTO.setDoorNumber(doorNumber); |
| | | eexcelUserDTO.setIsRent("是"); |
| | |
| | | eexcelUserDTOS.add(eexcelUserDTO); |
| | | excelWriter.write(eexcelUserDTOS, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(excelUrl+areaName+".xlsx"); |
| | | return R.ok(excelUrl + areaName + ".xlsx"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | }else{ |
| | | } else { |
| | | return r; |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "居民管理导入居民") |
| | | @PostMapping("/user/import") |
| | | public R importUser(@RequestParam MultipartFile file)throws IOException { |
| | | public R importUser(@RequestParam MultipartFile file) throws IOException { |
| | | String name = file.getOriginalFilename(); |
| | | Float size = Float.parseFloat(String.valueOf(file.getSize())) / 1024; |
| | | BigDecimal b = new BigDecimal(size); |
| | | size = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); |
| | | log.info("导入文件名字【{}】,文件大小【{}】KB",name,size); |
| | | String fileType=name.substring(name.indexOf("."),name.length()); |
| | | log.info("导入文件名字【{}】,文件大小【{}】KB", name, size); |
| | | String fileType = name.substring(name.indexOf("."), name.length()); |
| | | boolean isXls = !fileType.contains("xls") && !fileType.contains("xlsx"); |
| | | if (isXls) { |
| | | return R.fail("请上传xls或者xlsx格式的文件"); |
| | | } |
| | | EasyExcel.read(file.getInputStream(), EexcelUserDTO.class, new UploadEexcelUserDTOListener(userService,name)) .extraRead(CellExtraTypeEnum.MERGE).headRowNumber(1).sheet().doRead(); |
| | | EasyExcel.read(file.getInputStream(), EexcelUserDTO.class, new UploadEexcelUserDTOListener(userService, name)).extraRead(CellExtraTypeEnum.MERGE).headRowNumber(1).sheet().doRead(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "居民管理选择导入的小区",response =ComMngStructAreaVO.class ) |
| | | @ApiOperation(value = "居民管理选择导入的小区", response = ComMngStructAreaVO.class) |
| | | @GetMapping("/user/areas") |
| | | public R listAreas() { |
| | | Long communityId = this.getCommunityId(); |
| | | return communityService.listAreas("",communityId); |
| | | return communityService.listAreas("", communityId); |
| | | } |
| | | |
| | | @ApiOperation(value = "居民管理 分页查询居民列表",response =InputUserInfoVO.class ) |
| | | @ApiOperation(value = "居民管理 分页查询居民列表", response = InputUserInfoVO.class) |
| | | @PostMapping("/user/page") |
| | | public R userPage(@RequestBody PageInputUserDTO pageInputUserDTO) { |
| | | Long communityId = this.getCommunityId(); |
| | |
| | | return userService.pageInputUser(pageInputUserDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "居民管理 居民详情",response = InputUserInfoVO.class) |
| | | @ApiOperation(value = "居民管理 居民详情", response = InputUserInfoVO.class) |
| | | @GetMapping("/user/detail") |
| | | @ApiImplicitParam(name ="id",value = "用户ID",required = true) |
| | | public R detailUser(@RequestParam("id")Long id){ |
| | | @ApiImplicitParam(name = "id", value = "用户ID", required = true) |
| | | public R detailUser(@RequestParam("id") Long id) { |
| | | return userService.inputUserDetail(id); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "居民管理 导出居民Excel" ) |
| | | @ApiOperation(value = "居民管理 导出居民Excel") |
| | | @PostMapping("/user/export") |
| | | public R export(@RequestBody ExportUserDTO exportUserDTO){ |
| | | public R export(@RequestBody ExportUserDTO exportUserDTO) { |
| | | exportUserDTO.setCommunityId(this.getCommunityId()); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | String name = uuid + ".xlsx"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | // 用户搜索了就下载搜索的用户否则下载所有用户 |
| | | R r=userService.inputUserExport(exportUserDTO); |
| | | R r = userService.inputUserExport(exportUserDTO); |
| | | if (R.isOk(r)) { |
| | | List<EexcelUserDTO>eexcelUserDTOS= JSONArray.parseArray(JSONArray.toJSONString(r.getData()),EexcelUserDTO.class); |
| | | List<EexcelUserDTO> eexcelUserDTOS = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), EexcelUserDTO.class); |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, EexcelUserDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("模板").build(); |
| | | excelWriter.write(eexcelUserDTOS, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+name); |
| | | return R.ok(url + name); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | |
| | | |
| | | /** |
| | | * 设置居民标签 |
| | | * |
| | | * @param inputUserTagsDTO 标签信息 |
| | | * @return 设置结果 |
| | | */ |
| | | @ApiOperation(value = "居民管理 设置居民标签",response = InputUserInfoVO.class) |
| | | @ApiOperation(value = "居民管理 设置居民标签", response = InputUserInfoVO.class) |
| | | @PostMapping("/user/tags") |
| | | public R putUserTag(@RequestBody InputUserTagsDTO inputUserTagsDTO){ |
| | | public R putUserTag(@RequestBody InputUserTagsDTO inputUserTagsDTO) { |
| | | return userService.setInputUserTag(inputUserTagsDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "特殊群体/分页查询特殊群体列表",response =InputUserInfoVO.class ) |
| | | @ApiOperation(value = "特殊群体/分页查询特殊群体列表", response = InputUserInfoVO.class) |
| | | @PostMapping("/special/page") |
| | | public R specialInputUser(@RequestBody PageInputUserDTO pageInputUserDTO) { |
| | | Long communityId = this.getCommunityId(); |
| | |
| | | return userService.specialInputUser(pageInputUserDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "特殊群体/删除",response =InputUserInfoVO.class ) |
| | | @ApiOperation(value = "特殊群体/删除", response = InputUserInfoVO.class) |
| | | @DeleteMapping("/special/delete") |
| | | public R deleteSpecialInputUser(@RequestParam(value = "id") Long id) { |
| | | return userService.deleteSpecialInputUser(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "特殊群体 导出特殊群体Excel" ) |
| | | @ApiOperation(value = "特殊群体 导出特殊群体Excel") |
| | | @PostMapping("/special/export") |
| | | public R exportSpecial(@RequestBody ExportSpecialUserDTO exportSpecialUserDTO){ |
| | | public R exportSpecial(@RequestBody ExportSpecialUserDTO exportSpecialUserDTO) { |
| | | exportSpecialUserDTO.setCommunityId(this.getCommunityId()); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | String name = uuid + ".xlsx"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | // 用户搜索了就下载搜索的用户否则下载所有用户 |
| | | R r=userService.specialUserExport(exportSpecialUserDTO); |
| | | R r = userService.specialUserExport(exportSpecialUserDTO); |
| | | if (R.isOk(r)) { |
| | | List<EexcelUserDTO>eexcelUserDTOS= JSONArray.parseArray(JSONArray.toJSONString(r.getData()),EexcelUserDTO.class); |
| | | List<EexcelUserDTO> eexcelUserDTOS = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), EexcelUserDTO.class); |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, EexcelUserDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("模板").build(); |
| | | excelWriter.write(eexcelUserDTOS, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+name); |
| | | return R.ok(url + name); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | |
| | | return R.fail("未查询到用户"); |
| | | } |
| | | |
| | | @ApiOperation(value = "特殊群体/分页查询标签列表",response = ComMngTagVO.class ) |
| | | @ApiOperation(value = "特殊群体/分页查询标签列表", response = ComMngTagVO.class) |
| | | @PostMapping("/special/tags/page") |
| | | public R specialInputUserTags(@RequestBody ComMngUserTagDTO comMngUserTagDTO) { |
| | | Long communityId = this.getCommunityId(); |
| | |
| | | |
| | | /** |
| | | * 新增或修改特殊群体标签 |
| | | * |
| | | * @param comMngTagVO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除特殊群体标签 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | return userService.deleteSpecialInputUserTags(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页查询单位管理列表",response = ComMngRealCompanyVO.class) |
| | | @ApiOperation(value = "分页查询单位管理列表", response = ComMngRealCompanyVO.class) |
| | | @PostMapping("/company/page") |
| | | public R pageQueryComMngRealCompany(@RequestBody PageComMngRealCompanyDTO pageComMngRealCompanyDTO) { |
| | | return communityService.pageQueryComMngRealCompany(pageComMngRealCompanyDTO); |
| | |
| | | return communityService.deleteComMngRealCompany(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "实有单位详情",response = ComMngRealCompanyVO.class) |
| | | @ApiOperation(value = "实有单位详情", response = ComMngRealCompanyVO.class) |
| | | @GetMapping("/company/detail") |
| | | public R detailComMngRealCompany(@RequestParam(value = "id") Long id) { |
| | | return communityService.detailComMngRealCompany(id); |
| | |
| | | @PostMapping(value = "/company/import", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R importRealCompany(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | String fileName = file.getOriginalFilename(); //获取文件名 |
| | | log.info("传入文件名字【{}】",fileName); |
| | | log.info("传入文件名字【{}】", fileName); |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | EasyExcel.read(inputStream, ComMngRealCompanyExcelVO.class, new ComMngRealCompanyExcelListen(communityService,this.getCommunityId())).sheet().doRead(); |
| | | EasyExcel.read(inputStream, ComMngRealCompanyExcelVO.class, new ComMngRealCompanyExcelListen(communityService, this.getCommunityId())).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "实有单位Excel" ) |
| | | @ApiOperation(value = "实有单位Excel") |
| | | @PostMapping("/company/export") |
| | | public R exportRealCompany(@RequestBody ExportRealCompanyExcelDTO exportRealCompanyExcelDTO){ |
| | | public R exportRealCompany(@RequestBody ExportRealCompanyExcelDTO exportRealCompanyExcelDTO) { |
| | | exportRealCompanyExcelDTO.setCommunityId(this.getCommunityId()); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | String name = uuid + ".xlsx"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | // 用户搜索了就下载搜索的用户否则下载所有用户 |
| | | R r=communityService.exportRealCompany(exportRealCompanyExcelDTO); |
| | | R r = communityService.exportRealCompany(exportRealCompanyExcelDTO); |
| | | if (R.isOk(r)) { |
| | | List<ComMngRealCompanyExcelVO>eexcelUserDTOS= JSONArray.parseArray(JSONArray.toJSONString(r.getData()),ComMngRealCompanyExcelVO.class); |
| | | List<ComMngRealCompanyExcelVO> eexcelUserDTOS = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngRealCompanyExcelVO.class); |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ComMngRealCompanyExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("实有单位导出").build(); |
| | | excelWriter.write(eexcelUserDTOS, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+name); |
| | | return R.ok(url + name); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | |
| | | |
| | | ///////////// |
| | | |
| | | @ApiOperation(value = "分页查询实有资产列表",response = ComMngRealAssetsVO.class) |
| | | @ApiOperation(value = "分页查询实有资产列表", response = ComMngRealAssetsVO.class) |
| | | @PostMapping("/assets/page") |
| | | public R pageQueryComMngRealAssets(@RequestBody PageComMngRealAssetsDTO pageComMngRealAssetsDTO) { |
| | | return communityService.pageQueryComMngRealAssets(pageComMngRealAssetsDTO); |
| | |
| | | return communityService.deleteComMngRealAssets(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "实有资产详情",response = ComMngRealAssetsVO.class) |
| | | @ApiOperation(value = "实有资产详情", response = ComMngRealAssetsVO.class) |
| | | @GetMapping("/assets/detail") |
| | | public R detailComMngRealAssets(@RequestParam(value = "id") Long id) { |
| | | return communityService.detailComMngRealAssets(id); |
| | |
| | | @PostMapping(value = "/assets/import", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R importRealAssets(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | String fileName = file.getOriginalFilename(); //获取文件名 |
| | | log.info("传入文件名字【{}】",fileName); |
| | | log.info("传入文件名字【{}】", fileName); |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | EasyExcel.read(inputStream, ComMngRealAssetsExcelVO.class, new ComMngRealAssetsExcelListen(communityService,this.getCommunityId())).sheet().doRead(); |
| | | EasyExcel.read(inputStream, ComMngRealAssetsExcelVO.class, new ComMngRealAssetsExcelListen(communityService, this.getCommunityId())).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "实有资产Excel" ) |
| | | @ApiOperation(value = "实有资产Excel") |
| | | @PostMapping("/assets/export") |
| | | public R exportRealAssets(@RequestBody ExportRealAssetsExcelDTO exportRealAssetsExcelDTO){ |
| | | public R exportRealAssets(@RequestBody ExportRealAssetsExcelDTO exportRealAssetsExcelDTO) { |
| | | exportRealAssetsExcelDTO.setCommunityId(this.getCommunityId()); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | String name = uuid + ".xlsx"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | // 用户搜索了就下载搜索的用户否则下载所有用户 |
| | | R r=communityService.exportRealAssets(exportRealAssetsExcelDTO); |
| | | R r = communityService.exportRealAssets(exportRealAssetsExcelDTO); |
| | | if (R.isOk(r)) { |
| | | List<ComMngRealAssetsExcelVO>eexcelUserDTOS= JSONArray.parseArray(JSONArray.toJSONString(r.getData()),ComMngRealAssetsExcelVO.class); |
| | | List<ComMngRealAssetsExcelVO> eexcelUserDTOS = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngRealAssetsExcelVO.class); |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName,password,host,port); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator+name; |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ComMngRealAssetsExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("实有单位导出").build(); |
| | | excelWriter.write(eexcelUserDTOS, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】",absolutePath,delete); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+name); |
| | | return R.ok(url + name); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | |
| | | |
| | | /** |
| | | * 查询所有省份 |
| | | * |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "查询所有省份" ,response = ComMngProvinceVO.class) |
| | | @ApiOperation(value = "查询所有省份", response = ComMngProvinceVO.class) |
| | | @GetMapping("/province") |
| | | public R getProvince() { |
| | | return communityService.getProvince(); |
| | |
| | | |
| | | /** |
| | | * 查询省份下所有的城市 |
| | | * |
| | | * @param provinceAdcode |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "查询省份下所有的城市" ,response = ComMngCityVO.class) |
| | | @ApiOperation(value = "查询省份下所有的城市", response = ComMngCityVO.class) |
| | | @GetMapping("/city") |
| | | public R getCityByProvinceCode(@ApiParam(name = "省份编码", required = true) @RequestParam(value = "provinceAdcode") Integer provinceAdcode){ |
| | | public R getCityByProvinceCode(@ApiParam(name = "省份编码", required = true) @RequestParam(value = "provinceAdcode") Integer provinceAdcode) { |
| | | return communityService.getCityByProvinceCode(provinceAdcode); |
| | | } |
| | | |
| | | /** |
| | | * 查询城市下所有的区县 |
| | | * |
| | | * @param cityAdcode |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "查询城市下所有的区县" ,response = ComMngDistrictVO.class) |
| | | @ApiOperation(value = "查询城市下所有的区县", response = ComMngDistrictVO.class) |
| | | @GetMapping("/district") |
| | | R getDistrictByCityCode(@ApiParam(name = "城市编码", required = true) @RequestParam(value = "cityAdcode") Integer cityAdcode){ |
| | | R getDistrictByCityCode(@ApiParam(name = "城市编码", required = true) @RequestParam(value = "cityAdcode") Integer cityAdcode) { |
| | | return communityService.getDistrictByCityCode(cityAdcode); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取树结构区域信息") |
| | | @GetMapping(value = "arealist") |
| | | public R getAllArea(@ApiParam(name = "城市编码:四川510000", required = true) @RequestParam(value = "provinceAdcode") Integer provinceAdcode) { |
| | | return communityService.getCityTreeByProvinceCode(provinceAdcode); |
| | | } |
| | | } |