Переглянути джерело

Merge branch 'wanghaicheng' of http://132.232.206.88:3000/lift-manager/lift-server into wanghaicheng

wang-hai-cheng 4 роки тому
батько
коміт
50b1ffb7fa

+ 3 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/MaintenancePlanMapper.java

@@ -58,4 +58,7 @@ public interface MaintenancePlanMapper extends BaseMapper<MaintenancePlan> {
     @Select("SELECT count FROM maintenance_plan WHERE id = #{planId}")
     Long getCountByPlanId(Long planId);
 
+    @Select("select (select value from global_set where company_id = #{mtCompanyId}  and code = 'sameUnits') >" +
+            "       (select count(*) from maintenance_record where mt_company_id=#{mtCompanyId} and worker_id1 = #{workerId1} and status = '1')")
+    boolean selectLiftMaintainableBy(Long workerId1, Long mtCompanyId);
 }

+ 17 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenanceRecordService.java

@@ -6,7 +6,9 @@ import cn.com.ty.lift.business.evaluation.dao.entity.Evaluation;
 import cn.com.ty.lift.business.evaluation.service.EvaluationService;
 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.service.LiftService;
+import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
 import cn.com.ty.lift.business.maintenance.dao.entity.*;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceRecordRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtRecordRequest;
@@ -89,6 +91,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
     private MaintenanceOptionMapper maintenanceOptionMapper;
     private MaintenancePlanMapper maintenancePlanMapper;
     MaintenanceOptionService maintenanceOptionService;
+    private PlatformCompanyLiftRelevanceService platformCompanyLiftRelevanceService;
 
     @Autowired
     private Environment env;
@@ -231,6 +234,11 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         boolean result = calc(liftCoordinate, coordinate);
         if (result)
             return RestResponse.fail(MessageUtils.get("msg.error.person.scope"));
+        log.debug("根据全局设置判断当前维保工是否可以继续维保电梯");
+        boolean maintainable = maintenancePlanService.getBaseMapper().selectLiftMaintainableBy(request.getUserId(), request.getMtCompanyId());
+        if (!maintainable) {
+            return RestResponse.fail("超出公司设置的维保工可维保电梯上限数量");
+        }
         MaintenancePlan plan = maintenancePlanService.getOne(record.getMtPlanId());
         if (ObjectUtil.isEmpty(plan)) return RestResponse.fail(MessageUtils.get("msg.maintenance.plan.not.exist"));
 
@@ -291,6 +299,15 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         } else {
             return RestResponse.fail(MessageUtils.get("msg.add.fail"));
         }
+        log.debug("根据公司和电梯id设置电梯状态为维保中");
+        boolean update = platformCompanyLiftRelevanceService.update(Wrappers.<PlatformCompanyLiftRelevance>update().
+                eq("mt_company_id", request.getMtCompanyId()).
+                eq("lift_id", request.getRecord().getLiftId()).
+                set("lift_company_status", CommonEnum.LiftStatus.MAINTENANCE.getCode()));
+        if (!update) {
+            rollback();
+            return RestResponse.fail("无法转换电梯状态到维保中");
+        }
         return RestResponse.success(record.getId(), MessageUtils.get("msg.add.success"));
     }