|
@@ -1,17 +1,30 @@
|
|
|
package com.bizmatics.service.impl;
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
import com.bizmatics.common.core.bean.CommonPage;
|
|
|
+import com.bizmatics.common.core.exception.BusinessException;
|
|
|
+import com.bizmatics.common.core.util.BeanMapperUtils;
|
|
|
+import com.bizmatics.common.core.util.FileUtils;
|
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
+import com.bizmatics.common.spring.util.GlobalUtils;
|
|
|
import com.bizmatics.model.WcBlackoutPlan;
|
|
|
import com.bizmatics.model.system.SysUser;
|
|
|
import com.bizmatics.model.vo.CorrespondDeviceVO;
|
|
|
import com.bizmatics.model.vo.PlannedOutageVo;
|
|
|
+import com.bizmatics.model.vo.WcBlackoutPlanOneVo;
|
|
|
import com.bizmatics.model.vo.WcBlackoutPlanVo;
|
|
|
import com.bizmatics.persistence.mapper.WcBlackoutPlanMapper;
|
|
|
import com.bizmatics.service.WcBlackoutPlanService;
|
|
|
import com.bizmatics.service.util.SecurityUtils;
|
|
|
+import com.bizmatics.service.vo.CorrespondDeviceExportVO;
|
|
|
+import com.bizmatics.service.vo.WcBlackoutPlanOneExportVo;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
@@ -85,4 +98,64 @@ public class WcBlackoutPlanServiceImpl extends AbstractCrudService<WcBlackoutPla
|
|
|
}
|
|
|
return new CommonPage<>(plannedOutageListOne, total, plannedOutageVo.getSize(), plannedOutageVo.getCurrent());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String outagePlanListExport(String startTime,String endTime,Integer type) {
|
|
|
+ Workbook workbook = null;
|
|
|
+ File file = null;
|
|
|
+ try {
|
|
|
+ List<WcBlackoutPlanOneVo> plannedOutageListOne = new ArrayList<>();
|
|
|
+ ExportParams params = new ExportParams(null, "停电计划列表");
|
|
|
+ workbook = ExcelExportUtil.exportBigExcel(params, WcBlackoutPlanOneExportVo.class,
|
|
|
+ (o, i) -> {
|
|
|
+ int startCurrent = (i - 1) * 30;
|
|
|
+ List<WcBlackoutPlanVo> plannedOutageList = baseMapper.plannedOutageList(startTime, endTime, type, 0,30,startCurrent);
|
|
|
+ if (plannedOutageList.size()>0){
|
|
|
+ for (int j = 0; j< plannedOutageList.size(); j++) {
|
|
|
+ WcBlackoutPlanOneVo wcBlackoutPlanVo = new WcBlackoutPlanOneVo();
|
|
|
+ wcBlackoutPlanVo.setEndTime(plannedOutageList.get(j).getEndTime());
|
|
|
+ wcBlackoutPlanVo.setContacts(plannedOutageList.get(j).getContacts());
|
|
|
+ wcBlackoutPlanVo.setStartTime(plannedOutageList.get(j).getStartTime());
|
|
|
+ wcBlackoutPlanVo.setEnable(plannedOutageList.get(j).getEnable());
|
|
|
+ wcBlackoutPlanVo.setCreator(plannedOutageList.get(j).getCreator());
|
|
|
+ wcBlackoutPlanVo.setCreateTime(plannedOutageList.get(j).getCreateTime());
|
|
|
+ wcBlackoutPlanVo.setPhone(plannedOutageList.get(j).getPhone());
|
|
|
+ wcBlackoutPlanVo.setSiteName(plannedOutageList.get(j).getSiteName());
|
|
|
+ wcBlackoutPlanVo.setId(plannedOutageList.get(j).getId());
|
|
|
+ wcBlackoutPlanVo.setPlanType(plannedOutageList.get(j).getPlanType());
|
|
|
+ wcBlackoutPlanVo.setSiteId(plannedOutageList.get(j).getSiteId());
|
|
|
+ if (plannedOutageList.get(j).getStartTime().getTime()>new Date().getTime()){
|
|
|
+ wcBlackoutPlanVo.setType("未执行");
|
|
|
+ }else if(plannedOutageList.get(j).getStartTime().getTime()<new Date().getTime()&&plannedOutageList.get(j).getEndTime().getTime()>new Date().getTime()){
|
|
|
+ wcBlackoutPlanVo.setType("执行中");
|
|
|
+ }else if (plannedOutageList.get(j).getEndTime().getTime()<new Date().getTime()){
|
|
|
+ wcBlackoutPlanVo.setType("已执行");
|
|
|
+ }
|
|
|
+ plannedOutageListOne.add(wcBlackoutPlanVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<>(BeanMapperUtils.mapList(plannedOutageList, WcBlackoutPlanVo.class, WcBlackoutPlanOneExportVo.class));
|
|
|
+ }, null);
|
|
|
+ if (null != workbook) {
|
|
|
+ file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "停电计划列表", System.currentTimeMillis() + ""));
|
|
|
+ FileUtils.createFile(file.getAbsolutePath());
|
|
|
+ FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
|
|
|
+ workbook.write(allListingFileOutputStream);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("表格数据为空");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导出文件失败", e);
|
|
|
+ throw new BusinessException("导出文件失败");
|
|
|
+ } finally {
|
|
|
+ if (workbook != null) {
|
|
|
+ try {
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("===export spec=== 关闭workbook失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return file.getName();
|
|
|
+ }
|
|
|
}
|