添加市场法规库清下载模板,导入
This commit is contained in:
-16
@@ -157,22 +157,6 @@ public class MarketStandardController {
|
|||||||
return Result.OK("修改成功!");
|
return Result.OK("修改成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入
|
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@AutoLog(value = "外部标准库-市场法规清单-导入")
|
|
||||||
@ApiOperation(value = "外部标准库-市场法规清单-导入", notes = "外部标准库-市场法规清单-导入")
|
|
||||||
@ApiOperationSupport(order = 7)
|
|
||||||
@PostMapping(value = "/importExcel")
|
|
||||||
@RequiresPermissions("marketStandard:importExcel")
|
|
||||||
public Result<?> importExcel(@RequestParam("file") @ApiParam("文件") MultipartFile file) {
|
|
||||||
List<LawsMarketStandardDetail> errorMessages = marketStandardService.importExcel(file);
|
|
||||||
return Result.OK(errorMessages);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布
|
* 发布
|
||||||
*
|
*
|
||||||
|
|||||||
+31
@@ -56,4 +56,35 @@ public class MarketStandardDetailController {
|
|||||||
return lawsMarketStandardDetailService.getList(manifestId,manifestVersion);
|
return lawsMarketStandardDetailService.getList(manifestId,manifestVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "外部标准库-市场法规清单-导入")
|
||||||
|
@ApiOperation(value = "外部标准库-市场法规清单-导入", notes = "外部标准库-市场法规清单-导入")
|
||||||
|
@ApiOperationSupport(order = 7)
|
||||||
|
@PostMapping(value = "/importExcel")
|
||||||
|
@RequiresPermissions("marketStandard:importExcel")
|
||||||
|
public Result<?> importExcel(@RequestParam("file") @ApiParam("文件") MultipartFile file) {
|
||||||
|
List<LawsMarketStandardDetail> errorMessages = lawsMarketStandardDetailService.importExcel(file);
|
||||||
|
return Result.OK(errorMessages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载模板
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "外部标准库-市场法规清单-下载模板")
|
||||||
|
@ApiOperation(value = "外部标准库-市场法规清单-下载模板", notes = "外部标准库-市场法规清单-下载模板")
|
||||||
|
@ApiOperationSupport(order = 7)
|
||||||
|
@GetMapping(value = "/downloadTemplate")
|
||||||
|
@RequiresPermissions("marketStandard:importExcel")
|
||||||
|
public void downloadTemplate(HttpServletResponse response) {
|
||||||
|
lawsMarketStandardDetailService.downloadTemplate(response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+16
@@ -3,6 +3,10 @@ package com.jero.modules.laws.marketStandard.service;
|
|||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.modules.laws.marketStandard.entity.LawsMarketStandardDetail;
|
import com.jero.modules.laws.marketStandard.entity.LawsMarketStandardDetail;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ThinkBook
|
* @author ThinkBook
|
||||||
@@ -18,4 +22,16 @@ public interface ILawsMarketStandardDetailService extends IService<LawsMarketSta
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Result<?> getList(String manifestId,String manifestVersion);
|
Result<?> getList(String manifestId,String manifestVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入Excel
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<LawsMarketStandardDetail> importExcel(MultipartFile file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载模板
|
||||||
|
*/
|
||||||
|
void downloadTemplate(HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|||||||
-7
@@ -68,11 +68,4 @@ public interface ILawsMarketStandardService extends IService<LawsMarketStandard>
|
|||||||
* @param marketStandardDetailVO
|
* @param marketStandardDetailVO
|
||||||
*/
|
*/
|
||||||
void edit(MarketStandardDetailVO marketStandardDetailVO);
|
void edit(MarketStandardDetailVO marketStandardDetailVO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入Excel
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<LawsMarketStandardDetail> importExcel(MultipartFile file);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-4
@@ -10,13 +10,19 @@ import com.jero.modules.laws.marketStandard.mapper.LawsMarketStandardDetailMappe
|
|||||||
import com.jero.modules.laws.marketStandard.service.ILawsMarketStandardService;
|
import com.jero.modules.laws.marketStandard.service.ILawsMarketStandardService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.jeecgframework.poi.word.WordExportUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.Arrays;
|
import java.io.*;
|
||||||
import java.util.List;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Objects;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,6 +34,9 @@ import java.util.stream.Collectors;
|
|||||||
public class LawsMarketStandardDetailServiceImpl extends ServiceImpl<LawsMarketStandardDetailMapper, LawsMarketStandardDetail>
|
public class LawsMarketStandardDetailServiceImpl extends ServiceImpl<LawsMarketStandardDetailMapper, LawsMarketStandardDetail>
|
||||||
implements ILawsMarketStandardDetailService {
|
implements ILawsMarketStandardDetailService {
|
||||||
|
|
||||||
|
@Value("${jero.path.template}")
|
||||||
|
private String templatePath;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ILawsMarketStandardService marketStandardService;
|
private ILawsMarketStandardService marketStandardService;
|
||||||
|
|
||||||
@@ -57,6 +66,50 @@ public class LawsMarketStandardDetailServiceImpl extends ServiceImpl<LawsMarketS
|
|||||||
List<LawsMarketStandardDetail> list = list(queryLawsMarketStandardDetail);
|
List<LawsMarketStandardDetail> list = list(queryLawsMarketStandardDetail);
|
||||||
return Result.OK(list);
|
return Result.OK(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LawsMarketStandardDetail> importExcel(MultipartFile file) {
|
||||||
|
List<LawsMarketStandardDetail> list = new ArrayList<>();
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(2);
|
||||||
|
params.setHeadRows(1);
|
||||||
|
params.setStartRows(4);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
try {
|
||||||
|
return ExcelImportUtil.importExcel(file.getInputStream(), LawsMarketStandardDetail.class, params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
file.getInputStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadTemplate(HttpServletResponse response) {
|
||||||
|
String templateName = "导入模板-市场法规清单.xlsx";
|
||||||
|
// 模板存放地址
|
||||||
|
String templateUrl = templatePath + File.separator + templateName;
|
||||||
|
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(templateUrl));
|
||||||
|
OutputStream outputStream = response.getOutputStream()
|
||||||
|
) {
|
||||||
|
byte[] buf = new byte[1024];
|
||||||
|
int len;
|
||||||
|
while ((len = inputStream.read(buf)) > 0) {
|
||||||
|
outputStream.write(buf, 0, len);
|
||||||
|
}
|
||||||
|
response.flushBuffer();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("下载模板异常" + e.getMessage());
|
||||||
|
response.setStatus(404);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-22
@@ -84,7 +84,15 @@ public class LawsMarketStandardServiceImpl extends ServiceImpl<LawsMarketStandar
|
|||||||
queryWrapper.like(StringUtils.isNotBlank(marketStandard.getManifestName()),
|
queryWrapper.like(StringUtils.isNotBlank(marketStandard.getManifestName()),
|
||||||
"ms.manifest_name", marketStandard.getManifestName());
|
"ms.manifest_name", marketStandard.getManifestName());
|
||||||
if (StringUtils.isNotBlank(marketStandard.getCountry())) {
|
if (StringUtils.isNotBlank(marketStandard.getCountry())) {
|
||||||
queryWrapper.in("ms.country", Arrays.asList(marketStandard.getCountry().split(",")));
|
String[] str = marketStandard.getCountry().split(",");
|
||||||
|
queryWrapper.and(i->{
|
||||||
|
for (int i1 = 0; i1 < str.length; i1++) {
|
||||||
|
i.like("ms.country", str[i1]);
|
||||||
|
if(i1 != str.length - 1){
|
||||||
|
i.or();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
queryWrapper.eq(StringUtils.isNotBlank(marketStandard.getDrivePosition()),
|
queryWrapper.eq(StringUtils.isNotBlank(marketStandard.getDrivePosition()),
|
||||||
"ms.drive_position", marketStandard.getDrivePosition());
|
"ms.drive_position", marketStandard.getDrivePosition());
|
||||||
@@ -172,27 +180,6 @@ public class LawsMarketStandardServiceImpl extends ServiceImpl<LawsMarketStandar
|
|||||||
lawsMarketStandardDetailService.saveBatch(lists);
|
lawsMarketStandardDetailService.saveBatch(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LawsMarketStandardDetail> importExcel(MultipartFile file) {
|
|
||||||
List<LawsMarketStandardDetail> list = new ArrayList<>();
|
|
||||||
ImportParams params = new ImportParams();
|
|
||||||
params.setTitleRows(4);
|
|
||||||
params.setHeadRows(1);
|
|
||||||
params.setNeedSave(true);
|
|
||||||
try {
|
|
||||||
return ExcelImportUtil.importExcel(file.getInputStream(), LawsMarketStandardDetail.class, params);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(),e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
file.getInputStream().close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelAndView export(HttpServletResponse response, LawsMarketStandard marketStandard, String fileName, String sheetName, HttpServletRequest req) {
|
public ModelAndView export(HttpServletResponse response, LawsMarketStandard marketStandard, String fileName, String sheetName, HttpServletRequest req) {
|
||||||
QueryWrapper<LawsMarketStandard> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<LawsMarketStandard> queryWrapper = new QueryWrapper<>();
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ jero:
|
|||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: D://opt//upFiles
|
upload: D://opt//upFiles
|
||||||
img: /upFiles/
|
img: /upFiles/
|
||||||
|
template: D://opt//template
|
||||||
#webapp文件路径
|
#webapp文件路径
|
||||||
webapp: D://opt//webapp
|
webapp: D://opt//webapp
|
||||||
uploadCos: 1
|
uploadCos: 1
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user