|
@@ -2,10 +2,13 @@ package cn.com.ty.lift.business.maintenance.service;
|
|
|
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.BatchMaintenancePlanRequest;
|
|
|
+import cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenancePlanRequest;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.UpdateMaintenancePlanReq;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.Project;
|
|
|
import cn.com.ty.lift.business.project.service.ProjectService;
|
|
|
+import cn.com.ty.lift.common.base.ExportRequest;
|
|
|
+import cn.com.ty.lift.common.export.ExportUtils;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -29,14 +32,27 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
@Resource
|
|
|
private MaintenancePlanMapper planMapper;
|
|
|
|
|
|
+
|
|
|
+ private Map<String, String> paramMap = new HashMap<String, String>() {{
|
|
|
+ put("projectCode", "项目编号");
|
|
|
+ put("projectName", "项目名称");
|
|
|
+ put("regionName", "区域名称");
|
|
|
+ put("registrationCode", "注册代码");
|
|
|
+ put("devicePosition", "电梯位置");
|
|
|
+ put("workerName", "维保工");
|
|
|
+ put("", "间隔");
|
|
|
+ put("liftStatus", "电梯维保状态");
|
|
|
+ put("planDate", "计划时间");
|
|
|
+ }};
|
|
|
+
|
|
|
/**
|
|
|
- * @param planList 电梯列表
|
|
|
+ * @param request 电梯列表
|
|
|
* @return 是否成功
|
|
|
* @description 批量生成维保计划
|
|
|
* @date 2019/12/16 2:14 PM
|
|
|
*/
|
|
|
- public boolean insertBatch(List<MaintenancePlan> planList) {
|
|
|
- List<MaintenancePlan> resultList = generatePlan(planList);
|
|
|
+ public boolean insertBatch(MaintenancePlanRequest request) {
|
|
|
+ List<MaintenancePlan> resultList = generatePlan(request);
|
|
|
return saveBatch(resultList, resultList.size());
|
|
|
}
|
|
|
|
|
@@ -55,12 +71,13 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param plans 需要保养的电梯
|
|
|
+ * @param request 需要保养的电梯
|
|
|
* @return List<MaintenancePlan> 维保计划列表
|
|
|
* @description 生成维保计划
|
|
|
* @date 2019/12/16 1:21 PM
|
|
|
*/
|
|
|
- public List<MaintenancePlan> generatePlan(List<MaintenancePlan> plans) {
|
|
|
+ public List<MaintenancePlan> generatePlan(MaintenancePlanRequest request) {
|
|
|
+ List<MaintenancePlan> plans = request.getPlanList();
|
|
|
//返回维保计划列表
|
|
|
List<MaintenancePlan> planList = new ArrayList<>();
|
|
|
//保养类型 1.半月,2.季度,3.半年,4.全年
|
|
@@ -68,9 +85,9 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
int times = 0;
|
|
|
for (MaintenancePlan plan : plans) {
|
|
|
//获取从第几期开始
|
|
|
- int periods = plan.getPeriods();
|
|
|
+ int periods = request.getPeriods();
|
|
|
//获取保养间隔
|
|
|
- int interval = plan.getInterval();
|
|
|
+ int interval = request.getInterval();
|
|
|
Project project = projectService.detail(plan.getProjectId());
|
|
|
if (project != null) {
|
|
|
Date beginTime = project.getStartDate();
|
|
@@ -122,7 +139,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
//获取时间间隔
|
|
|
Long interval = DateUtil.betweenDay(currentTime, updateTime, false);
|
|
|
int offset = interval.intValue();
|
|
|
- //获取当前时间后的保养时间
|
|
|
+ //获取当前时间后的维保计划id列表
|
|
|
List<MaintenancePlan> idList = planMapper.findIdList(currentTime);
|
|
|
for (MaintenancePlan entry : idList) {
|
|
|
Date planDate;
|
|
@@ -134,7 +151,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
entry.setPlanDate(planDate);
|
|
|
resultList.add(entry);
|
|
|
}
|
|
|
- return updateBatchById(resultList, resultList.size());
|
|
|
+ return updateBatchById(resultList, resultList.size());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -147,4 +164,16 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
|
|
|
log.info("批量清空维保计划");
|
|
|
return removeByIds(request.getIds());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param request 导出项目数据列表
|
|
|
+ * @return RestResponse 状态码和返回消息
|
|
|
+ * @description 导出维保计划
|
|
|
+ * @date 2019/12/19 11:27 AM
|
|
|
+ */
|
|
|
+ public void export(ExportRequest request) {
|
|
|
+ List<MaintenancePlan> projectList = planMapper.selectBatchIds(request.getIds());
|
|
|
+ ExportUtils utils = new ExportUtils();
|
|
|
+ utils.export(projectList, paramMap, request.getExportPath());
|
|
|
+ }
|
|
|
}
|