|
@@ -4,13 +4,15 @@ import cn.com.ty.lift.business.framework.util.MessageUtils;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.Lift;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.model.request.PlatformCompanyBatchRequest;
|
|
|
-import cn.com.ty.lift.business.library.dao.entity.model.request.SelectBatchPlatformCompanyRequest;
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.model.request.ProjectOperateServiceRequest;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.model.request.PlatformCompanyRequest;
|
|
|
import cn.com.ty.lift.business.library.dao.mapper.PlatformCompanyLiftRelevanceMapper;
|
|
|
import cn.com.ty.lift.business.maintenance.service.MaintenancePlanService;
|
|
|
import cn.com.ty.lift.business.maintenance.service.MaintenanceService;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.Project;
|
|
|
-import cn.com.ty.lift.business.project.dao.mapper.ProjectMapper;
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.ProjectLiftRelevance;
|
|
|
+import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
|
|
|
+import cn.com.ty.lift.business.project.service.ProjectService;
|
|
|
import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
@@ -21,9 +23,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author bieao
|
|
@@ -37,7 +41,7 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
private PlatformCompanyLiftRelevanceMapper mapper;
|
|
|
|
|
|
@Resource
|
|
|
- private ProjectMapper projectMapper;
|
|
|
+ private ProjectService projectService;
|
|
|
|
|
|
@Resource
|
|
|
private LiftService liftService;
|
|
@@ -48,6 +52,10 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
@Resource
|
|
|
private MaintenanceService maintenanceService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ProjectLiftRelevanceService projectLiftRelevanceService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param id 电梯id
|
|
|
* @param mtCompanyId 公司id
|
|
@@ -91,17 +99,43 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param request liftIdList 电梯id列表
|
|
|
- * @return 1.成功, 0.失败, 消息描述
|
|
|
- * @description 批量查询电梯状态
|
|
|
- * @date 2019/12/5 5:24 PM
|
|
|
+ * @param mtCompanyId 公司id
|
|
|
+ * @param projectId 项目id
|
|
|
+ * @return List<PlatformCompanyLiftRelevance> 公司电梯关联列表
|
|
|
+ * @description 获取公司电梯关联列表
|
|
|
+ * @date 2020/1/11 3:06 下午
|
|
|
*/
|
|
|
- public RestResponse selectBatch(SelectBatchPlatformCompanyRequest request) {
|
|
|
- List<PlatformCompanyLiftRelevance> list = mapper.selectBatchIds(request.getLiftIdList());
|
|
|
- if (CollUtil.isEmpty(list)) {
|
|
|
- return RestResponse.success();
|
|
|
- }
|
|
|
- return RestResponse.success(list, MessageUtils.get("msg.query.success"));
|
|
|
+ public List<PlatformCompanyLiftRelevance> getCompanyLiftList(Long mtCompanyId, Long projectId){
|
|
|
+ //根据项目id和公司id查询电梯列表
|
|
|
+ List<ProjectLiftRelevance> liftList = projectLiftRelevanceService.findLiftList(mtCompanyId, projectId);
|
|
|
+ Collection<Long> list = liftList.stream().map(ProjectLiftRelevance::getRelevanceId).collect(Collectors.toList());
|
|
|
+ return mapper.selectBatchIds(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param mtCompanyId 公司id
|
|
|
+ * @param projectId 项目id
|
|
|
+ * @return RestResponse 操作是否成功
|
|
|
+ * @description 确认停止服务
|
|
|
+ * @date 2020/1/11 2:45 下午
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public RestResponse confirm(Long mtCompanyId, Long projectId) {
|
|
|
+ Project project = new Project();
|
|
|
+ project.setId(projectId);
|
|
|
+ //修改项目状态为停止
|
|
|
+ project.setProjectStatus(CommonEnum.ProjectStatus.STOP_SERVICE.getCode());
|
|
|
+ projectService.modify(project);
|
|
|
+ List<PlatformCompanyLiftRelevance> resultList = getCompanyLiftList(mtCompanyId,projectId);
|
|
|
+ resultList.forEach(entry -> entry.setLiftCompanyStatus(CommonEnum.LiftStatus.STOP_INSURANCE.getCode()));
|
|
|
+ //批量停保项目下的电梯
|
|
|
+ updateBatchById(resultList);
|
|
|
+ //根据项目id和公司id查询电梯列表
|
|
|
+ List<ProjectLiftRelevance> liftList = projectLiftRelevanceService.findLiftList(mtCompanyId, projectId);
|
|
|
+ Collection<Long> list = liftList.stream().map(ProjectLiftRelevance::getLiftId).collect(Collectors.toList());
|
|
|
+ //批量清除维保计划
|
|
|
+ maintenancePlanService.removeMaintenancePlan(mtCompanyId, list);
|
|
|
+ return RestResponse.success(null, MessageUtils.get("msg.project.operate.success"));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -110,43 +144,57 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
* @description 服务操作
|
|
|
* @date 2019/12/10 5:42 PM
|
|
|
*/
|
|
|
- public RestResponse serviceOperate(SelectBatchPlatformCompanyRequest request) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public RestResponse serviceOperate(ProjectOperateServiceRequest request) {
|
|
|
String operate = request.getOperate();
|
|
|
+ Long projectId = request.getProjectId();
|
|
|
+ Long mtCompanyId = request.getMtCompanyId();
|
|
|
+ Project project = new Project();
|
|
|
+ project.setId(projectId);
|
|
|
+ boolean exist = false;
|
|
|
+ List<PlatformCompanyLiftRelevance> resultList = getCompanyLiftList(mtCompanyId,projectId);
|
|
|
switch (operate) {
|
|
|
//恢复服务
|
|
|
case "1":
|
|
|
- boolean judgeResult = maintenanceService.judge(request.getMtCompanyId());
|
|
|
+ //判断当前公司台量是否大于企业设置的台量
|
|
|
+ boolean judgeResult = maintenanceService.judge(mtCompanyId);
|
|
|
if (!judgeResult) {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.limit.num"));
|
|
|
}
|
|
|
+ project.setProjectStatus(CommonEnum.ProjectStatus.IN_SERVICE.getCode());
|
|
|
+ projectService.modify(project);
|
|
|
+ //电梯状态设置为正常
|
|
|
+ resultList.forEach(entry -> entry.setLiftCompanyStatus(CommonEnum.LiftStatus.NORMAL.getCode()));
|
|
|
+ boolean result = updateBatchById(resultList);
|
|
|
+ if (!result) {
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.modify.batch.fail"));
|
|
|
+ }
|
|
|
break;
|
|
|
//停止服务
|
|
|
case "2":
|
|
|
- //TODO 检查电梯是否有进行中的任务,并提醒,批量停保项目下的电梯,清除维保、年检、急修任务
|
|
|
- List<PlatformCompanyLiftRelevance> resultList = mapper.selectBatchIds(request.getLiftIdList());
|
|
|
- //项目下非停保状态的电梯状态修改为正常
|
|
|
for (PlatformCompanyLiftRelevance entry : resultList) {
|
|
|
- entry.setLiftCompanyStatus(CommonEnum.LiftStatus.STOP_INSURANCE.getCode());
|
|
|
- }
|
|
|
- boolean ret = updateBatchById(resultList);
|
|
|
- if (!ret) {
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.modify.batch.fail"));
|
|
|
+ String liftStatus = entry.getLiftCompanyStatus();
|
|
|
+ if (CommonEnum.LiftStatus.MAINTENANCE.getCode().equals(liftStatus)) {
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.project.lift.maintenance.status.error"));
|
|
|
+ } else if (CommonEnum.LiftStatus.EMERGENCY_REPAIR.getCode().equals(liftStatus)) {
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.project.lift.emergency.status.error"));
|
|
|
+ } else if (CommonEnum.LiftStatus.ANNUAL_INSPECTION.getCode().equals(liftStatus)) {
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.project.lift.annualinspection.success.error"));
|
|
|
+ }
|
|
|
+ exist = true;
|
|
|
}
|
|
|
+ if (exist) confirm(projectId, mtCompanyId);
|
|
|
break;
|
|
|
//继续服务
|
|
|
case "3":
|
|
|
- Project project = new Project();
|
|
|
- project.setId(request.getProjectId());
|
|
|
project.setProjectStatus(CommonEnum.ProjectStatus.IN_SERVICE.getCode());
|
|
|
- int result = projectMapper.updateById(project);
|
|
|
- if (result < 0) {
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
- }
|
|
|
+ int response = projectService.modify(project);
|
|
|
+ if (response < 0) return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- return RestResponse.success(null, MessageUtils.get("msg.add.success"));
|
|
|
+ return RestResponse.success(null, MessageUtils.get("msg.project.operate.success"));
|
|
|
}
|
|
|
|
|
|
/**
|