| | |
| | | */ |
| | | @GetMapping("/exportGroupCodeExcel") |
| | | @VciBusinessLog(operateName = "导出集团码") |
| | | public void exportGroupCodeExcel(String codeClassifyOid, HttpServletResponse response) throws IOException{ |
| | | |
| | | public R exportGroupCodeExcel(String codeClassifyOid, HttpServletResponse response) throws IOException{ |
| | | try { |
| | | String excelName = mdmIOService.exportGroupCodeExcel(codeClassifyOid); |
| | | ControllerUtil.writeFileToResponse(response,excelName); |
| | | } catch (Throwable e) { |
| | | //如果出错,把错误信息写到text |
| | | String msg = LangBaseUtil.getErrorMsg(e); |
| | | if(StringUtils.isBlank(msg)){ |
| | | msg = "未知错误"; |
| | | } |
| | | ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); |
| | | return R.fail(msg); |
| | | // ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); |
| | | } |
| | | return R.status(true); |
| | | } |
| | | |
| | | /*** |
| | | * 集团码导入 |
| | | * @param codeClassifyOid |
| | | * @param file |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @PostMapping("/importGroupCode") |
| | | public R importGroupCode(String codeClassifyOid,MultipartFile file,HttpServletResponse response){ |
| | | |
| | | String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename(); |
| | | File file1 = new File(excelFileName); |
| | | try { |
| | | file.transferTo(new File(excelFileName)); |
| | | String excelName=mdmIOService.importGroupCode(codeClassifyOid,file1); |
| | | if(StringUtils.isNotBlank(excelName)) { |
| | | ControllerUtil.writeFileToResponse(response,excelName); |
| | | return R.fail("集团码导入出现问题,请查看文件"); |
| | | }else{ |
| | | return R.status(true); |
| | | } |
| | | }catch (Throwable e) { |
| | | logger.error("导入错误",e); |
| | | String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt"; |
| | | LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile); |
| | | String uuid=ControllerUtil.putErrorFile(errorFile); |
| | | CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO(); |
| | | codeImProtRusultVO.setRedisUuid(""); |
| | | codeImProtRusultVO.setFileOid(uuid); |
| | | codeImProtRusultVO.setFilePath(errorFile); |
| | | R r = R.fail("集团码导入失败"); |
| | | r.setData(codeImProtRusultVO); |
| | | return r; |
| | | }finally { |
| | | file1.delete(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |