索道运输
This commit is contained in:
parent
b8f8d6da1b
commit
beeb6cb350
|
|
@ -12,9 +12,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,4 +125,36 @@ public class TbTowerController {
|
||||||
return ServerResponse.createErroe("杆塔管理-查询所有");
|
return ServerResponse.createErroe("杆塔管理-查询所有");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 杆塔管理导出
|
||||||
|
* @param file
|
||||||
|
* @param tbTowerVo
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/tbTowerImport")
|
||||||
|
@DecryptAndVerify(decryptedClass = TbTowerVo.class)
|
||||||
|
@LogAnnotation(operModul = "杆塔管理-导出", operation = "导出", operDesc = "系统级事件",operType="导出")
|
||||||
|
public ServerResponse tbTowerExport(MultipartFile file, TbTowerVo tbTowerVo) throws IOException {
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
if (fileName != null) {
|
||||||
|
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||||
|
long fileSize = file.getSize();
|
||||||
|
if (!fileExtension.equalsIgnoreCase("xls") && !fileExtension.equalsIgnoreCase("xlsx")) {
|
||||||
|
// 文件后缀名不符合要求
|
||||||
|
return ServerResponse.createErroe("文件后缀名不符合要求");
|
||||||
|
} else if (fileSize > 10 * 1024 * 1024) {
|
||||||
|
// 文件大小超过10M
|
||||||
|
return ServerResponse.createErroe("文件大小超过10M");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExcelUtil<TbTowerVo> util = new ExcelUtil<TbTowerVo>(TbTowerVo.class);
|
||||||
|
List<TbTowerVo> tbTowerVoList = util.importExcel(file.getInputStream());
|
||||||
|
if (tbTowerVoList.size()>3000){
|
||||||
|
return ServerResponse.createErroe("文件条数超过3000");
|
||||||
|
}
|
||||||
|
String message = tbTowerService.importMaProp(tbTowerVoList, tbTowerVo);
|
||||||
|
return ServerResponse.createSuccess(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,4 +47,12 @@ public interface TbTowerService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<TbTowerVo> tbProjectExport(TbTowerVo data);
|
List<TbTowerVo> tbProjectExport(TbTowerVo data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 杆塔管理导入
|
||||||
|
* @param tbTowerVoList
|
||||||
|
* @param tbTowerVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String importMaProp(List<TbTowerVo> tbTowerVoList, TbTowerVo tbTowerVo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,4 +159,32 @@ public class TbTowerServiceImpl implements TbTowerService {
|
||||||
List<TbTowerVo> tbTowerVoList = tbTowerMapper.getTbProjectList(data);
|
List<TbTowerVo> tbTowerVoList = tbTowerMapper.getTbProjectList(data);
|
||||||
return tbTowerVoList;
|
return tbTowerVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 杆塔管理导入
|
||||||
|
* @param tbTowerVoList
|
||||||
|
* @param tbTowerVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String importMaProp(List<TbTowerVo> tbTowerVoList, TbTowerVo tbTowerVo) {
|
||||||
|
if (tbTowerVoList.size()>0){
|
||||||
|
int num = 1;
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < tbTowerVoList.size(); i++) {
|
||||||
|
TbTowerVo tbTower = new TbTowerVo();
|
||||||
|
tbTower.setProId(tbTowerVo.getProId());
|
||||||
|
tbTower.setUploadType(tbTowerVo.getUploadType());
|
||||||
|
addTbTower(tbTower);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("第{}条数据导入失败,错误信息为:{}",num,e.getMessage());
|
||||||
|
}
|
||||||
|
return "导入成功";
|
||||||
|
}else {
|
||||||
|
return "数据不能为空";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue