yuxc
2023-12-05 27614920e2f36407f0635d73e931e6cea852298f
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
@@ -90,6 +90,72 @@
    * @param response 响应对象
    * @throws IOException 抛出异常
    */
   @GetMapping("/downloadExcelBatchEdit")
   @VciBusinessLog(operateName = "下载批量申请编码的导入模板")
   public void downloadImportExcelBatchEdit(String codeClassifyOid, HttpServletResponse response) throws IOException{
      String excelName = mdmIOService.downloadImportExcelBatchEdit(codeClassifyOid);
      try {
         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);
      }
   }
   /**
    * 导入批量编辑数据
    * @param codeClassifyOid 分类的主键
    * @param classifyAttr 分类路径使用的属性
    * @param file 文件的内容
    */
   @VciBusinessLog(operateName = "导入批量编辑数据")
   @PostMapping("/batchImportEdit")
   public R batchImportEdit(String codeClassifyOid, String classifyAttr,MultipartFile file,HttpServletResponse response) throws Throwable {
      String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename();
      File file1 = new File(excelFileName);
      try {
         file.transferTo(new File(excelFileName));
         CodeImProtRusultVO codeImProtRusultVO =mdmIOService.batchImportEdit(codeClassifyOid, classifyAttr,file1);
         if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())||StringUtils.isNotBlank(codeImProtRusultVO.getRedisUuid())){
            //放到map里
            R result = R.fail("导入失败");
            if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())) {
               String filedUUid = ControllerUtil.putErrorFile(codeImProtRusultVO.getFilePath());
               codeImProtRusultVO.setFileOid(filedUUid);
            }
            result.setData(codeImProtRusultVO);
            return result;
         }else {
            return R.success("操作成功!");
         }
      }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();
      }
   }
   /**
    * 下载批量申请的导入模板
    * @param codeClassifyOid 分类的主键
    * @param response 响应对象
    * @throws IOException 抛出异常
    */
   @GetMapping("/downloadTopImportExcel")
   @VciBusinessLog(operateName = "下载批量申请编码的导入模板")
   public void downloadTopImportExcel(String codeClassifyOid,HttpServletResponse response) throws IOException{
@@ -312,7 +378,7 @@
         s = engineService.addSaveCode(orderDTO);
         saveLogUtil.operateLog("编码申请",false,orderDTO.toString());
      }catch (Exception e){
         saveLogUtil.operateLog("编码申请",true,e.getMessage());
         saveLogUtil.operateLog("编码申请",true,e.toString());
         throw e;
      }
      return R.success(s);
@@ -791,4 +857,15 @@
         ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
      }
   }
   /**
    * 获取统计分析数据
    * @param btmNames 业务类型
    * @return
    */
   @GetMapping("/getStatisticAnalysis")
   @VciBusinessLog(operateName = "获取统计分析数据")
   public R getStatisticAnalysis(String btmNames) {
      return engineService.getStatisticAnalysis(btmNames);
   }
}