|
@@ -1,5 +1,6 @@
|
|
|
package org.jeecg.modules.billet.billetHotsend.controller;
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
@@ -15,20 +17,31 @@ import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
|
|
|
import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
|
|
|
+import org.jeecg.modules.billet.billetHotsend.dto.BilletHotsendExportDTO;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.BilletBasicInfoDetails;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.RealtimeStats;
|
|
|
import org.jeecg.modules.billet.billetHotsend.service.IBilletHotsendBaseService;
|
|
|
import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
|
|
|
+import org.jeecg.modules.carUnit.service.ISysDictService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 钢坯热送基础信息
|
|
@@ -50,6 +63,9 @@ public class BilletHotsendBaseController extends JeecgController<BilletHotsend,
|
|
|
@Autowired
|
|
|
private IBilletBasicInfoService billetBasicInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDictService sysDictService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
@@ -277,4 +293,72 @@ public class BilletHotsendBaseController extends JeecgController<BilletHotsend,
|
|
|
List<BilletBasicInfoDetails> billetHotsendList = billetHotsendBaseService.queryBilletInfoByBilletNo(billetNo);
|
|
|
return Result.OK(billetHotsendList);
|
|
|
}
|
|
|
+
|
|
|
+ @AutoLog(value = "钢坯热送基础信息-EasyExcel导出")
|
|
|
+ @ApiOperation(value = "钢坯热送基础信息-EasyExcel导出", notes = "分页导出当前页数据")
|
|
|
+ @GetMapping("/exportExcel")
|
|
|
+ public void exportEasyExcel(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ BilletHotsend billetHotsend) throws IOException {
|
|
|
+
|
|
|
+ // 构造查询条件
|
|
|
+ QueryWrapper<BilletHotsend> queryWrapper = QueryGenerator.initQueryWrapper(billetHotsend, request.getParameterMap());
|
|
|
+
|
|
|
+ // 获取参数
|
|
|
+ String createTimeBegin = request.getParameter("createTime_begin");
|
|
|
+ String createTimeEnd = request.getParameter("createTime_end");
|
|
|
+
|
|
|
+ // 如果前端没有传时间范围,则默认查询最近一个月
|
|
|
+ if (StringUtils.isBlank(createTimeBegin) && StringUtils.isBlank(createTimeEnd)) {
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ LocalDateTime oneMonthAgo = now.minusMonths(1);
|
|
|
+ queryWrapper.between("create_time", oneMonthAgo, now);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 时间格式与字典准备
|
|
|
+ AtomicInteger index = new AtomicInteger(1); // 序号从 1 开始
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
+
|
|
|
+ List<BilletHotsend> billetHotsendList = billetHotsendBaseService.list(queryWrapper);
|
|
|
+
|
|
|
+ // 构造导出数据列表
|
|
|
+ List<BilletHotsendExportDTO> exportList = billetHotsendList.stream().map(item -> {
|
|
|
+ BilletHotsendExportDTO dto = new BilletHotsendExportDTO();
|
|
|
+ dto.setIndex(index.getAndIncrement());
|
|
|
+
|
|
|
+ dto.setCreateTime(item.getCreateTime() != null
|
|
|
+ ? item.getCreateTime().toInstant().atZone(zoneId).toLocalDateTime().format(formatter)
|
|
|
+ : "");
|
|
|
+
|
|
|
+ dto.setHeatNo(item.getHeatNo());
|
|
|
+ dto.setShiftGroup(sysDictService.queryDictTextByKey("lg_bz", item.getShiftGroup())); // 班组中文
|
|
|
+ dto.setShift(sysDictService.queryDictTextByKey("lg_bb", item.getShift())); // 班别中文
|
|
|
+ dto.setSteel(item.getSteel());
|
|
|
+ dto.setSpec(item.getSpec());
|
|
|
+ dto.setDecideWeight(BigDecimal.valueOf(item.getDecideWeight()));
|
|
|
+ dto.setAmountTotal(item.getAmountTotal());
|
|
|
+ dto.setBlankOutput(BigDecimal.valueOf(item.getBlankOutput()));
|
|
|
+ dto.setStackNum(item.getStackNum());
|
|
|
+ dto.setRollcluboneNum(item.getRollcluboneNum());
|
|
|
+ dto.setRollclubtwoNum(item.getRollclubtwoNum());
|
|
|
+ dto.setRollclubthreeNum(item.getRollclubthreeNum());
|
|
|
+ dto.setRollheightNum(item.getRollheightNum());
|
|
|
+ dto.setRolloutshippNum(item.getRolloutshippNum());
|
|
|
+ dto.setWasteNum(item.getWasteNum());
|
|
|
+ return dto;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 设置响应头
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("钢坯热送信息导出", StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
+
|
|
|
+ // 导出数据
|
|
|
+ EasyExcel.write(response.getOutputStream(), BilletHotsendExportDTO.class)
|
|
|
+ .sheet("钢坯热送数据")
|
|
|
+ .doWrite(exportList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|