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