|
@@ -1,12 +1,14 @@
|
|
|
package cn.com.ty.lift.business.library.service;
|
|
|
|
|
|
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.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.common.constants.CommonEnum;
|
|
@@ -21,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @author bieao
|
|
@@ -42,6 +45,9 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
@Resource
|
|
|
private MaintenancePlanService maintenancePlanService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MaintenanceService maintenanceService;
|
|
|
+
|
|
|
/**
|
|
|
* @param id 电梯id
|
|
|
* @param mtCompanyId 公司id
|
|
@@ -77,7 +83,7 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
* @description 查询维保公司下的实际电梯台量
|
|
|
* @date 2019/12/12 5:16 PM
|
|
|
*/
|
|
|
- public Integer countLiftNum(Long mtCompanyId) {
|
|
|
+ public int countLiftNum(Long mtCompanyId) {
|
|
|
QueryWrapper<PlatformCompanyLiftRelevance> queryWrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<PlatformCompanyLiftRelevance> lambdaQueryWrapper = queryWrapper.lambda();
|
|
|
lambdaQueryWrapper.eq(PlatformCompanyLiftRelevance::getMtCompanyId, mtCompanyId);
|
|
@@ -109,7 +115,7 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
switch (operate) {
|
|
|
//恢复服务
|
|
|
case "1":
|
|
|
- boolean judgeResult = liftService.judge(request.getMtCompanyId());
|
|
|
+ boolean judgeResult = maintenanceService.judge(request.getMtCompanyId());
|
|
|
if (!judgeResult) {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.limit.num"));
|
|
|
}
|
|
@@ -148,22 +154,26 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
* @param request mtCompanyId 公司id
|
|
|
* @param request liftId 电梯id
|
|
|
* @return 1.成功, 0.失败, 消息描述
|
|
|
- * @description 更新电梯状态为停保, 并清除维保计划
|
|
|
+ * @description 更新电梯状态为停保或恢复为正常, 并清除维保计划
|
|
|
* @date 2019/12/5 5:24 PM
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public RestResponse stopInsurance(PlatformCompanyRequest request) {
|
|
|
+ public RestResponse stopOrRecover(PlatformCompanyRequest request) {
|
|
|
PlatformCompanyLiftRelevance entry = new PlatformCompanyLiftRelevance();
|
|
|
entry.setId(request.getRelevanceId());
|
|
|
- entry.setLiftCompanyStatus(CommonEnum.LiftStatus.STOP_INSURANCE.getCode());
|
|
|
- boolean result = updateById(entry);
|
|
|
- if (!result) {
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
- }
|
|
|
- //清除维保计划
|
|
|
- boolean ret = maintenancePlanService.cleanPlan(request.getMtCompanyId(), request.getLiftId());
|
|
|
- if (!ret) {
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
+ //恢复电梯为正常状态
|
|
|
+ if ("0".equals(request.getOperate())) {
|
|
|
+ Optional<Lift> lift = liftService.getOne(null, request.getLiftId());
|
|
|
+ String liftStatus = lift.map(Lift::getLiftStatus).orElse(null);
|
|
|
+ // 1:弃用 2:正常
|
|
|
+ if ("1".equals(liftStatus)) return RestResponse.fail(MessageUtils.get("msg.error.lift.status"));
|
|
|
+ entry.setLiftCompanyStatus(CommonEnum.LiftStatus.NORMAL.getCode());
|
|
|
+ updateById(entry);
|
|
|
+ } else {
|
|
|
+ entry.setLiftCompanyStatus(CommonEnum.LiftStatus.STOP_INSURANCE.getCode());
|
|
|
+ updateById(entry);
|
|
|
+ //清除维保计划
|
|
|
+ maintenancePlanService.cleanPlan(request.getMtCompanyId(), request.getLiftId());
|
|
|
}
|
|
|
return RestResponse.success(null, MessageUtils.get("msg.modify.success"));
|
|
|
}
|
|
@@ -192,10 +202,7 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.batch.fail"));
|
|
|
}
|
|
|
//批量清除维保计划
|
|
|
- boolean ret = maintenancePlanService.removeMaintenancePlan(request.getMtCompanyId(), request.getLiftList());
|
|
|
- if (!ret) {
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.modify.batch.fail"));
|
|
|
- }
|
|
|
+ maintenancePlanService.removeMaintenancePlan(request.getMtCompanyId(), request.getLiftList());
|
|
|
return RestResponse.success(null, MessageUtils.get("msg.modify.batch.success"));
|
|
|
}
|
|
|
|