记得上下班打卡 | git大法好,push需谨慎

Commit c1b3a024 authored by 胡佳晨's avatar 胡佳晨

删除重复代码 GoblinExportDataController.java

parent 29a25bf6
...@@ -243,118 +243,4 @@ public class GoblinExportDataController { ...@@ -243,118 +243,4 @@ public class GoblinExportDataController {
} }
} }
/**
* excel正在下单根据日期导出
*
* @return
*/
@GetMapping("/exportMarketGoods")
@ApiOperation(value = "正在下单-商品根据日期")
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "bDate", value = "开始时间[yyyy-MM-dd]"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "eDate", value = "结束时间[yyyy-MM-dd]"),
})
public void exportMarketGoods(@RequestParam(required = true, name = "bDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "开始日期格式有误") String beginDate,
@RequestParam(required = true, name = "eDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "结束日期格式有误") String endDate,
@RequestParam String marketId, @RequestParam String storeId, HttpServletResponse response) {
String currentUid = CurrentUtil.getCurrentUid();
ServletOutputStream servletOutputStream = null;
try {
log.debug("数据导出:正在下单-商品根据日期导出:[uid:{},storeId:{},marketId:{},date:{}~{}]", currentUid, storeId, marketId, beginDate, endDate);
String fileName = DateUtil.Formatter.yyyyMMddHHmmssTrim.format(LocalDateTime.now())
.concat(new String(("正在下单-商品根据日期导出").getBytes("gb2312"), StandardCharsets.ISO_8859_1));
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=".concat(fileName).concat(ExcelTypeEnum.XLSX.getValue()));
response.setContentType(MediaType.MULTIPART_FORM_DATA_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
servletOutputStream = response.getOutputStream();
HashMap<String, Object> paramMap = CollectionUtil.mapStringObject();
paramMap.put("storeId", storeId);
paramMap.put("marketId", GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue() + marketId);
LocalDate beginLocalDate = DateUtil.Formatter.yyyy_MM_dd.parse2LocalDate(beginDate);
LocalDate endLocalDate = DateUtil.Formatter.yyyy_MM_dd.parse2LocalDate(endDate);
paramMap.put("beginTime", null == beginLocalDate ? beginLocalDate : LocalDateTime.of(beginLocalDate, LocalTime.MIN));
paramMap.put("endTime", null == endLocalDate ? endLocalDate : LocalDateTime.of(endLocalDate, LocalTime.MAX));
if (log.isDebugEnabled()) {
log.debug("数据导出:正在下单-商品根据日期导出:[uid:{},paramMap:{}]", currentUid, JsonUtils.toJson(paramMap));
}
List<GoblinMarketGoodsExcelDto> excelDtos = iGoblinExportService.exportMarketGoods(paramMap);
if (CollectionUtils.isEmpty(excelDtos)) {
log.warn("数据导出:正在下单-商品根据日期导出:无数据,请核实:[uid:{},paramMap:{}]", currentUid, JsonUtils.toJson(paramMap));
return;
}
EasyExcel.write(servletOutputStream, GoblinMarketGoodsExcelDto.class).sheet("销售数据").doWrite(excelDtos);
} catch (IOException e) {
log.error("数据导出:正在下单-商品根据日期导出:异常[uid:{},storeId:{},marketId:{},date:{}~{},ex.msg={}]",
currentUid, storeId, marketId, beginDate, endDate, e.getLocalizedMessage());
throw new LiquidnetServiceException("-1", "导出失败,请联系网站管理员");
} finally {
if (null != servletOutputStream) {
try {
servletOutputStream.close();
} catch (Exception ignored) {
}
}
}
}
/**
* excel正在下单根据导出
*/
@GetMapping("/exportMarketGoodsUnDate")
@ApiOperation(value = "正在下单-商品导出")
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "bDate", value = "开始时间[yyyy-MM-dd HH:mm:ss]"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "eDate", value = "结束时间[yyyy-MM-dd HH:mm:ss]"),
})
public void exportMarketGoodsUnDate(@RequestParam(required = true, name = "bDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "开始日期格式有误") String beginDate,
@RequestParam(required = true, name = "eDate") @Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "结束日期格式有误") String endDate,
@RequestParam String marketId, @RequestParam String storeId, HttpServletResponse response) {
String currentUid = CurrentUtil.getCurrentUid();
ServletOutputStream servletOutputStream = null;
try {
log.debug("数据导出:正在下单-商品导出:[uid:{},storeId:{},marketId:{},date:{}~{}]", currentUid, storeId, marketId, beginDate, endDate);
String fileName = DateUtil.Formatter.yyyyMMddHHmmssTrim.format(LocalDateTime.now())
.concat(new String(("正在下单-商品导出").getBytes("gb2312"), StandardCharsets.ISO_8859_1));
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=".concat(fileName).concat(ExcelTypeEnum.XLSX.getValue()));
response.setContentType(MediaType.MULTIPART_FORM_DATA_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
servletOutputStream = response.getOutputStream();
HashMap<String, Object> paramMap = CollectionUtil.mapStringObject();
paramMap.put("storeId", storeId);
paramMap.put("marketId", GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue() + marketId);
paramMap.put("beginTime", beginDate);
paramMap.put("endTime", endDate);
if (log.isDebugEnabled()) {
log.debug("数据导出:正在下单-商品导出:[uid:{},paramMap:{}]", currentUid, JsonUtils.toJson(paramMap));
}
List<GoblinMarketGoodsUnDateExcelDto> excelDtos = iGoblinExportService.exportMarketGoodsUnDate(paramMap);
if (CollectionUtils.isEmpty(excelDtos)) {
log.warn("数据导出:正在下单-商品导出:无数据,请核实:[uid:{},paramMap:{}]", currentUid, JsonUtils.toJson(paramMap));
return;
}
EasyExcel.write(servletOutputStream, GoblinMarketGoodsUnDateExcelDto.class).sheet("销售数据").doWrite(excelDtos);
} catch (IOException e) {
log.error("数据导出:正在下单-商品导出:异常[uid:{},storeId:{},marketId:{},date:{}~{},ex.msg={}]",
currentUid, storeId, marketId, beginDate, endDate, e.getLocalizedMessage());
throw new LiquidnetServiceException("-1", "导出失败,请联系网站管理员");
} finally {
if (null != servletOutputStream) {
try {
servletOutputStream.close();
} catch (Exception ignored) {
}
}
}
}
} }
...@@ -48,16 +48,6 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -48,16 +48,6 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
return goblinStoreOrderMapper.exportZhengzaiMarketOrder(paramMap); return goblinStoreOrderMapper.exportZhengzaiMarketOrder(paramMap);
} }
@Override
public List<GoblinMarketGoodsExcelDto> exportMarketGoods(Map<String, Object> paramMap) {
return goblinStoreOrderMapper.exportMarketGoods(paramMap);
}
@Override
public List<GoblinMarketGoodsUnDateExcelDto> exportMarketGoodsUnDate(Map<String, Object> paramMap) {
return goblinStoreOrderMapper.exportMarketGoodsUnDate(paramMap);
}
@Override @Override
public ResponseDto<String> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType, String storeId) { public ResponseDto<String> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType, String storeId) {
if (!timeIsNotNull(beginTime, endTime)) { if (!timeIsNotNull(beginTime, endTime)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment