|
@@ -13,7 +13,9 @@ import cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.model.response.LiftResponse;
|
|
|
import cn.com.ty.lift.business.library.dao.mapper.LiftMapper;
|
|
|
+import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.LiftPrintResponse;
|
|
|
+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.entity.ProjectLiftRelevance;
|
|
@@ -30,7 +32,6 @@ import cn.com.ty.lift.common.model.PushUserInfo;
|
|
|
import cn.com.ty.lift.common.utils.DateUtils;
|
|
|
import cn.com.ty.lift.common.utils.SendMessageUtil;
|
|
|
import cn.com.ty.lift.common.verify.Validate;
|
|
|
-import cn.com.ty.lift.common.verify.VerifyUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
@@ -95,6 +96,9 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
|
|
|
@Resource
|
|
|
private CommonMapper commonMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MaintenancePlanService maintenancePlanService;
|
|
|
+
|
|
|
private Map<String, String> headsMap = new LinkedHashMap<String,String>() {{
|
|
|
put("liftCode", "电梯号");
|
|
|
put("registrationCode", "注册代码");
|
|
@@ -404,6 +408,8 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public RestResponse modify(LiftRequest request) {
|
|
|
Lift lift = request.getLift();
|
|
|
+ Long newWorkerId = request.getWorkerId();
|
|
|
+ Long mtCompanyId = request.getMtCompanyId();
|
|
|
Optional<Lift> oldLift = getOne(null, lift.getId());
|
|
|
if (!oldLift.isPresent())
|
|
|
return RestResponse.fail(MessageUtils.get("msg.lift.not.exist"));
|
|
@@ -420,14 +426,20 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
|
|
|
Lift entry = oldLift.get();
|
|
|
+ ProjectLiftRelevance liftRelevance = projectRelevanceService.getOne(mtCompanyId, entry.getId());
|
|
|
+ Long projectId = null;
|
|
|
+ if (Objects.nonNull(liftRelevance)) {
|
|
|
+ projectId = liftRelevance.getProjectId();
|
|
|
+ }
|
|
|
String devicePosition = entry.getDevicePosition();
|
|
|
String newDevicePosition = lift.getDevicePosition();
|
|
|
if (!Objects.equals(devicePosition, newDevicePosition)) {
|
|
|
- //更新电梯定位发送推送消息
|
|
|
- sendModifyMessage(lift.getId(), request.getProjectId(), request.getMtCompanyId(), devicePosition, newDevicePosition);
|
|
|
+ if (Objects.nonNull(projectId))
|
|
|
+ //更新电梯定位发送推送消息
|
|
|
+ sendModifyMessage(lift.getId(), projectId, mtCompanyId, devicePosition, newDevicePosition);
|
|
|
}
|
|
|
//生成电梯操作记录
|
|
|
- LiftHistory history = liftHistoryService.createOperaHistory(entry, lift, request.getMtCompanyId());
|
|
|
+ LiftHistory history = liftHistoryService.createOperaHistory(entry, lift, mtCompanyId);
|
|
|
if (Objects.nonNull(history)) {
|
|
|
//保存电梯操作记录
|
|
|
boolean historyResult = liftHistoryService.save(history);
|
|
@@ -436,13 +448,24 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
}
|
|
|
}
|
|
|
- ProjectLiftRelevance liftRelevance = new ProjectLiftRelevance();
|
|
|
- liftRelevance.setId(request.getRelevanceId());
|
|
|
- liftRelevance.setWorkerId(request.getWorkerId());
|
|
|
- boolean ret = projectRelevanceService.modify(liftRelevance);
|
|
|
- if (!ret) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
+ if (Objects.nonNull(liftRelevance)) {
|
|
|
+ liftRelevance.setWorkerId(newWorkerId);
|
|
|
+ boolean ret = projectRelevanceService.modify(liftRelevance);
|
|
|
+ if (!ret) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> liftIdList = new ArrayList<>();
|
|
|
+ liftIdList.add(entry.getId());
|
|
|
+ List<MaintenancePlan> planList = maintenancePlanService.getPlanList(mtCompanyId, liftIdList);
|
|
|
+ //修改未完成的维保计划为新的维保负责人
|
|
|
+ planList.forEach(plan -> plan.setWorkerId(newWorkerId));
|
|
|
+ boolean planResult = maintenancePlanService.updateBatchById(planList);
|
|
|
+ if (!planResult) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
+ }
|
|
|
}
|
|
|
return RestResponse.success(null, MessageUtils.get("msg.modify.success"));
|
|
|
}
|