소스 검색

顽症导出调整

zhuang 10 달 전
부모
커밋
1267760460

+ 1 - 1
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxPersistentManageService.java

@@ -10,7 +10,7 @@ import java.util.Map;
 
 public interface ZhcxPersistentManageService extends IService<ZhcxPersistentManageDo> {
 
-    int wordExport(Map<String, Object> map, HttpServletResponse response);
+    void wordExport(Map<String, Object> map, HttpServletResponse response);
 
     void syncWzPlatform(List<String> ids);
 }

+ 6 - 7
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxPersistentManageServiceImpl.java

@@ -64,12 +64,12 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
     private String syncWzDataUrl;
 
     @Override
-    public int wordExport(Map<String, Object> map, HttpServletResponse response) {
+    public void wordExport(Map<String, Object> map, HttpServletResponse response) {
         Object periodObj = map.get("period");
         Object yearObj = map.get("year");
         Object paramsObj = map.get("params");
         if(ObjectUtil.isEmpty(periodObj)){
-            return 0;
+            throw new CustomException("缺少周期参数");
         }
         if(!ObjectUtil.isEmpty(paramsObj)){
             String params = (String) map.get("params");
@@ -82,7 +82,7 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
         map.put("period","第"+period+"期");
         List<ZhcxPersistentManageDo> list = zhcxPersistentManageDao.listData(map);
         if(list.size() == 0){
-            return 1;
+            throw new CustomException("当前周期暂无数据");
         }
         if(list.size() > 0){
             list.forEach(ev ->{
@@ -168,7 +168,7 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
                     } catch (Exception e) {
                         log.info("顽症导出word失败:"+e);
                     }
-                }else if (k.contains("油漆“零破坏”专项报告")){
+                }else if (k.contains("油漆“零破坏”专项")){
                     FormDataVO formDataVo = new FormDataVO();
                     formDataVo.setMainDataList(mainDataList);
 
@@ -334,11 +334,10 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
                 response.setHeader("Content-Disposition", "attachment;filename=" + "报告");
                 doc[0].save(response.getOutputStream(), com.aspose.words.SaveOptions.createSaveOptions(com.aspose.words.SaveFormat.DOCX));
             } catch (Exception e) {
-                log.info("顽症导出word失败:"+e);
-                return 1;
+                log.error("顽症导出word失败:"+e);
+                throw new CustomException("导出失败");
             }
         }
-        return 1;
     }
 
     @Override

+ 7 - 6
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxPersistentController.java

@@ -31,12 +31,13 @@ public class ZhcxPersistentController {
     @PostMapping("wordExport")
     @ApiOperation("word导出")
     public void wordExport(@RequestBody Map<String,Object> map, HttpServletResponse response){
-        int i = zhcxPersistentManageService.wordExport(map,response);
-        if(i == 0){
-            throw new CustomException("导出失败");
-        }else if(i == 1){
-            throw new CustomException("当前周期暂无数据");
-        }
+//        int i = zhcxPersistentManageService.wordExport(map,response);
+//        if(i == 0){
+//            throw new CustomException("导出失败");
+//        }else if(i == 1){
+//            throw new CustomException("当前周期暂无数据");
+//        }
+        zhcxPersistentManageService.wordExport(map,response);
     }
 
     /**