瀏覽代碼

Merge branches 'develop' and 'huangyuan-user' of http://132.232.206.88:3000/lift-manager/lift-server into huangyuan-user

黄远 5 年之前
父節點
當前提交
4ace070ef5

+ 2 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java

@@ -295,7 +295,7 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
         switch (source) {
             //电梯管理入口
             case "0":
-                if (maintenanceService.judge(mtCompanyId))
+                if (!maintenanceService.judge(mtCompanyId))
                     return RestResponse.fail(MessageUtils.get("msg.limit.num"));
                 PlatformCompanyLiftRelevance relevanceResult = saveCompanyLiftInfo(id, mtCompanyId);
                 if (Objects.isNull(relevanceResult)) {
@@ -317,7 +317,7 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
                 if (currentNum >= num) {
                     return RestResponse.fail(MessageUtils.get("msg.project.limit.num"));
                 }
-                if (maintenanceService.judge(mtCompanyId))
+                if (!maintenanceService.judge(mtCompanyId))
                     return RestResponse.fail(MessageUtils.get("msg.limit.num"));
                 //新增企业电梯关联表
                 PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(id, mtCompanyId);

+ 1 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/MtRecordResponse.java

@@ -55,7 +55,7 @@ public class MtRecordResponse extends MaintenanceRecord {
     private String workerName;
 
     /**
-     * 维修时长秒数
+     * 保养时长秒数
      */
     private long repairDiff;
 

+ 18 - 19
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenanceRecordService.java

@@ -1,6 +1,5 @@
 package cn.com.ty.lift.business.maintenance.service;
 
-import cn.com.ty.lift.business.common.CommonRequest;
 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;
@@ -22,9 +21,7 @@ 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.ty.lift.common.utils.MapHelper;
-import cn.com.ty.lift.common.verify.VerifyUtils;
 import cn.com.xwy.boot.web.dto.RestResponse;
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.IterUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
@@ -41,10 +38,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.time.LocalDateTime;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -159,15 +154,17 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         if (ObjectUtil.isEmpty(entry)) return false;
         int interval = entry.getPlanInterval();
         List<MaintenancePlan> planList = maintenancePlanService.findPlanList(liftId, projectId, mtCompanyId, request.getCurrentTime());
+        //提前保养跳过当前保养的计划
+        Iterator<MaintenancePlan> iterator = planList.iterator();
+        if (iterator.hasNext()) {
+            MaintenancePlan next = iterator.next();
+            if (Objects.nonNull(next))
+                iterator.remove();
+        }
         //获取当前时间后的维保计划列表,并清除计划
         maintenancePlanService.removeByIds(planList.stream().map(MaintenancePlan::getId).collect(Collectors.toList()));
         //按照修改时间重新生成计划
         List<MaintenancePlan> plans = maintenancePlanService.generatePlan(plan, periods, interval, request.getCurrentTime(), endDate);
-        for (MaintenancePlan p : plans) {
-            if (request.getCurrentTime().equals(p.getPlanDate())) {
-                p.setStatus(Integer.parseInt(CommonEnum.MaintenancePlanStatus.MAINTENANCE_DOING.getCode()));
-            }
-        }
         return maintenancePlanService.saveBatch(plans, plans.size());
     }
 
@@ -203,6 +200,13 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
             return RestResponse.fail(MessageUtils.get("msg.error.person.scope"));
         MaintenancePlan plan = maintenancePlanService.getOne(record.getMtPlanId());
         if (ObjectUtil.isEmpty(plan)) return RestResponse.fail(MessageUtils.get("msg.maintenance.plan.not.exist"));
+
+        plan.setStatus(Integer.parseInt(CommonEnum.MaintenancePlanStatus.MAINTENANCE_DOING.getCode()));
+        boolean planResult = maintenancePlanService.updateById(plan);
+        if (!planResult) {
+            rollback();
+            return RestResponse.fail(MessageUtils.get("msg.add.fail"));
+        }
         //若保养时间在计划时间之前,则需要修改维保计划
         boolean compareResult = request.getCurrentTime().isBefore(plan.getPlanDate());
         if (compareResult) {
@@ -210,13 +214,6 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
             if (!modifyPlan) {
                 return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
             }
-        } else {
-            plan.setStatus(Integer.parseInt(CommonEnum.MaintenancePlanStatus.MAINTENANCE_DOING.getCode()));
-            boolean planResult = maintenancePlanService.updateById(plan);
-            if (!planResult) {
-                rollback();
-                return RestResponse.fail(MessageUtils.get("msg.add.fail"));
-            }
         }
         Optional<Lift> lift = liftService.getOne(null, liftId);
         if (lift.isPresent()) {
@@ -227,6 +224,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
             record.setWorkerId1(record.getWorkerId1());
             record.setWorkDate(LocalDate.now());
             record.setPlanDate(plan.getPlanDate());
+            record.setStopDate(LocalDateTime.now());
             boolean ret = save(record);
             if (!ret) {
                 rollback();
@@ -252,6 +250,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
             return RestResponse.success(null, MessageUtils.get("msg.record.not.exist"));
 
         record.setStatus(CommonEnum.MaintenanceRecordStatus.COMPLETE.getCode());
+        record.setRecoveryDate(LocalDateTime.now());
         boolean result = updateById(record);
         if (!result) {
             return RestResponse.fail(MessageUtils.get("msg.modify.fail"));

+ 1 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectAppService.java

@@ -142,7 +142,7 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
             return RestResponse.fail(MessageUtils.get("msg.project.limit.num"));
         }
         //判断当前公司台量是否大于企业设置的台量
-        if (maintenanceService.judge(mtCompanyId))
+        if (!maintenanceService.judge(mtCompanyId))
             return RestResponse.fail(MessageUtils.get("msg.limit.num"));
 
         PlatformCompanyLiftRelevance companyLiftEntry = liftService.saveCompanyLiftInfo(liftId, mtCompanyId);

+ 4 - 4
lift-business-service/src/main/resources/mapper/maintenance/MaintenancePlanMapper.xml

@@ -150,14 +150,14 @@
 		       mp.status           AS status
 		FROM maintenance_plan mp
 				 LEFT JOIN project p ON mp.project_id = p.id
-				<if test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+				<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
 					LEFT JOIN project_user pu ON p.id = pu.project_id
 				</if>
 				 LEFT JOIN lift l ON mp.lift_id = l.id
 				 LEFT JOIN user_info ui ON mp.worker_id = ui.user_id
 		 WHERE mp.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
 		  <choose>
-			  <when test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+			  <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
 				  AND pu.user_id = #{request.userId,jdbcType=BIGINT}
 			  </when>
 		      <when test="request.userId !=null">
@@ -191,14 +191,14 @@
 				  count(1) total
 		FROM maintenance_plan mp
 				LEFT JOIN project p ON mp.project_id = p.id
-				<if test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+				<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1">
 					LEFT JOIN project_user pu ON p.id = pu.project_id
 				</if>
 				LEFT JOIN lift l ON mp.lift_id = l.id
 				LEFT JOIN user_info ui ON mp.worker_id = ui.user_id
 		WHERE mp.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
 		<choose>
-			<when test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+			<when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
 				AND pu.user_id = #{request.userId,jdbcType=BIGINT}
 			</when>
 			<when test="request.userId !=null">

+ 5 - 5
lift-business-service/src/main/resources/mapper/maintenance/MaintenanceRecordMapper.xml

@@ -121,14 +121,14 @@
 		    mr.has_evaluate     AS hasEvaluate
 		FROM maintenance_record mr
 		LEFT JOIN project p ON mr.project_id = p.id
-        <if test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
             LEFT JOIN project_user pu ON p.id = pu.project_id
         </if>
 		LEFT JOIN lift l ON mr.lift_id = l.id
 		LEFT JOIN user_info ui ON mr.worker_id = ui.user_id
 		WHERE mr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
         <choose>
-            <when test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+            <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
                 AND pu.user_id = #{request.userId,jdbcType=BIGINT}
             </when>
             <when test="request.userId !=null">
@@ -140,7 +140,7 @@
 			AND mr.status = #{request.status,jdbcType=VARCHAR}
 		</if>
         <if test="request.currentTime!=null">
-            AND <![CDATA[ mr.plan_date = #{request.currentTime}]]>
+            AND <![CDATA[ mr.work_date = #{request.currentTime}]]>
         </if>
         <if test="request.beginTime!=null">
             AND <![CDATA[ mr.plan_date >= #{request.beginTime}]]>
@@ -162,14 +162,14 @@
                  count(1) total
         FROM maintenance_record mr
                 LEFT JOIN project p ON mr.project_id = p.id
-                <if test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+                <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
                     LEFT JOIN project_user pu ON p.id = pu.project_id
                 </if>
                 LEFT JOIN lift l ON mr.lift_id = l.id
                 LEFT JOIN user_info ui ON mr.worker_id = ui.user_id
         WHERE mr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
         <choose>
-            <when test="(request.currentRoleCode == 'REGION_DIRECTOR') or (request.currentRoleCode == 'ROLEMTWORK' and request.look == 1) ">
+            <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
                 AND pu.user_id = #{request.userId,jdbcType=BIGINT}
             </when>
             <when test="request.userId !=null">

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/settings/service/impl/GlobalSetServiceImpl.java

@@ -38,7 +38,7 @@ public class GlobalSetServiceImpl extends ServiceImpl<GlobalSetMapper, GlobalSet
          *     默认值:(1)是
          */
         globalSetList.add(new GlobalSet(companyId,
-                ApiConstants.GlobalSetConstants.VALUE_YES,
+                ApiConstants.GlobalSetConstants.VALUE_NO,
                 ApiConstants.GlobalSetConstants.WORK_LIFT));
         /**
          * 名称:2.维保类型选项