yangyj преди 3 години
родител
ревизия
25a9e3374f

+ 2 - 5
blade-service/blade-business/src/main/java/org/springblade/business/controller/DatumPointController.java

@@ -1,8 +1,6 @@
 package org.springblade.business.controller;
 
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import io.swagger.annotations.Api;
@@ -22,7 +20,6 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import java.io.IOException;
@@ -108,11 +105,11 @@ public class DatumPointController {
 
 
     @PostMapping("/import")
-    public R<String> importXy(@RequestParam("file") MultipartFile file, Integer type , Long contractId,Long projectId) throws Exception {
+    public R importXy(@RequestParam("file") MultipartFile file, Integer type , Long contractId, Long projectId) throws Exception {
         if(file != null&& type!=null && contractId!=null&&projectId!=null) {
             String fileName = Objects.requireNonNull(file.getOriginalFilename());
             if(Pattern.matches(".+(\\.xls)x?$",fileName.toLowerCase(Locale.ROOT))) {
-                return R.success(this.service.importData(file,contractId,projectId,type));
+                return this.service.importData(file,contractId,projectId,type);
             } else {
                 R.fail("文件格式不正确,请上传Excel文件");
             }

+ 12 - 11
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/DatumPointService.java

@@ -7,6 +7,7 @@ import org.springblade.business.entity.DatumPoint;
 import org.springblade.business.mapper.DatumPointMapper;
 import org.springblade.business.utils.ExcelUtil;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
@@ -25,7 +26,7 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
 
 
 
-    public String importData(MultipartFile file,  Long contractId,Long projectId, Integer dataType) throws Exception {
+    public R importData(MultipartFile file, Long contractId, Long projectId, Integer dataType) throws Exception {
         List<String> level=new ArrayList<>();
         level.add("一级");
         level.add("二级");
@@ -40,14 +41,14 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
                 String dengji= ExcelUtil.getValue(row1.getCell(2)).toString();
                 String beizhu=ExcelUtil.getValue(row1.getCell(3)).toString();
                 if( !"等级".equals(dengji)||!"备注".equals(beizhu)){
-                    return "导入的数据格式有错,请对准导入模板确认!";
+                    return  R.fail("导入的数据格式有错,请对准导入模板确认!");
                 }
             }
             if(dataType==1){
                 String dengji=ExcelUtil.getValue(row1.getCell(4)).toString();
                 String beizhu=ExcelUtil.getValue(row1.getCell(5)).toString();
                 if( !"等级".equals(dengji)||!"备注".equals(beizhu)){
-                    return "导入的数据格式有错,请对准导入模板确认!";
+                    return  R.fail("导入的数据格式有错,请对准导入模板确认!");
                 }
             }
 
@@ -68,12 +69,12 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
                         String name=(String)ExcelUtil.getValue(row.getCell(0));
                         if(StringUtil.isEmpty(name)){
                             msg="第"+i+"行,测站点名称为空,请输入!";
-                            return msg;
+                            return  R.fail(msg);
                         }
                         //判断,同一合同段下,测站点名称是否重复
                         if(this.count(Wrappers.<DatumPoint>lambdaQuery().eq(DatumPoint::getName,name).eq(DatumPoint::getContractId,contractId).eq(DatumPoint::getType,dataType))>0){
                             msg="第"+i+"行,测站点:"+name+"已存在,请修改";
-                            return msg;
+                            return  R.fail(msg);
                         }
                         switch (j) {
                             case 0:
@@ -87,7 +88,7 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
                                 if(StringUtil.isNotBlank((String) ExcelUtil.getValue(row.getCell(j)))) {
                                     if(!level.contains(value)){
                                         msg="第"+i+"行,等级应该为:一级、二级、三级 或 四级,请修改!";
-                                        return msg;
+                                        return  R.fail(msg);
                                     }
                                     obj.setLevel(value);
                                 }
@@ -118,12 +119,12 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
                         String name=(String)ExcelUtil.getValue(row.getCell(0));
                         if(StringUtil.isEmpty(name)){
                             msg="第"+i+"行,测站点名称为空,请输入!";
-                            return msg;
+                            return  R.fail(msg);
                         }
                         //判断,同一合同段下,测站点名称是否重复
                         if(this.count(Wrappers.<DatumPoint>lambdaQuery().eq(DatumPoint::getName,name).eq(DatumPoint::getContractId,contractId).eq(DatumPoint::getType,dataType))>0){
                             msg="第"+i+"行,测站点:"+name+"已存在,请修改";
-                            return msg;
+                            return  R.fail(msg);
                         }
                         switch (j) {
                             case 0:
@@ -143,7 +144,7 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
                                 if(StringUtil.isNotBlank((String) ExcelUtil.getValue(row.getCell(j)))) {
                                     if(!level.contains(value)){
                                         msg="第"+i+"行,等级应该为:一级、二级、三级 或 四级,请修改!";
-                                        return msg;
+                                        return  R.fail(msg);
                                     }
                                     obj.setLevel(value);
                                 }
@@ -165,11 +166,11 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
             }
             //批量保存
             this.saveBatch(importList);
-            return  "导入成功";
+            return   R.success("导入成功");
         } catch (Exception e){
             e.printStackTrace();
         }
-        return "执行异常";
+        return  R.fail("执行异常");
     }
 
     //导出数据