|
@@ -21,11 +21,13 @@ import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
|
|
|
import cn.com.ty.lift.business.project.service.ProjectService;
|
|
|
import cn.com.ty.lift.business.push.service.PushUserService;
|
|
|
import cn.com.ty.lift.common.base.ExportRequest;
|
|
|
-import cn.com.ty.lift.common.export.ExportUtils;
|
|
|
import cn.com.ty.lift.common.model.PushMessage;
|
|
|
import cn.com.ty.lift.common.model.PushUserInfo;
|
|
|
+import cn.com.ty.lift.common.utils.DateUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.poi.excel.ExcelUtil;
|
|
|
+import cn.hutool.poi.excel.ExcelWriter;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -38,6 +40,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
@@ -74,14 +79,14 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
@Resource
|
|
|
private PushUserService pushUserService;
|
|
|
|
|
|
- private Map<String, String> paramMap = new HashMap<String, String>() {{
|
|
|
+ private Map<String, String> headsMap = new LinkedHashMap<String, String>() {{
|
|
|
put("projectCode", "项目编号");
|
|
|
put("projectName", "项目名称");
|
|
|
put("regionName", "区域名称");
|
|
|
put("registrationCode", "注册代码");
|
|
|
put("devicePosition", "电梯位置");
|
|
|
put("workerName", "维保工");
|
|
|
- put("", "间隔");
|
|
|
+ put("planInterval", "间隔");
|
|
|
put("liftStatus", "电梯维保状态");
|
|
|
put("planDate", "计划时间");
|
|
|
}};
|
|
@@ -99,6 +104,10 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
return baseMapper.findByCondition(request.getPage(), request);
|
|
|
}
|
|
|
|
|
|
+ public List<Map<String,String>> exportList(List<String> ids){
|
|
|
+ return baseMapper.exportList(ids);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param request 公司id,项目id,电梯id
|
|
|
* @return 1.成功, 0.失败, 消息描述
|
|
@@ -486,15 +495,28 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param request 导出项目数据列表
|
|
|
+ * @param request 导出维保计划数据列表
|
|
|
* @return RestResponse 状态码和返回消息
|
|
|
* @description 导出维保计划
|
|
|
* @date 2019/12/19 11:27 AM
|
|
|
*/
|
|
|
- public void export(ExportRequest request) {
|
|
|
- List<MaintenancePlan> projectList = baseMapper.selectBatchIds(request.getIds());
|
|
|
- ExportUtils utils = new ExportUtils();
|
|
|
- utils.export(projectList, paramMap, request.getExportPath());
|
|
|
+ public void export(ExportRequest request, HttpServletResponse response) {
|
|
|
+ List<String> ids = request.getIds();
|
|
|
+ List<Map<String, String>> planList = exportList(ids);
|
|
|
+ ExcelWriter writer = ExcelUtil.getWriter(true);
|
|
|
+ //设置列别名
|
|
|
+ headsMap.forEach(writer::addHeaderAlias);
|
|
|
+ String fileName = DateUtils.generateCode() + ".xlsx";
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
|
|
+ try (ServletOutputStream out = response.getOutputStream()) {
|
|
|
+ writer.write(planList, true);
|
|
|
+ writer.autoSizeColumnAll();
|
|
|
+ writer.flush(out, true);
|
|
|
+ writer.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("维保计划导出失败", e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|