Browse Source

Merge branch 'wanghaicheng' of lift-manager/lift-server into develop

wanghaicheng 4 years ago
parent
commit
2b0810b1bb

+ 19 - 8
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/service/LiftDataService.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
 
 /**
@@ -154,22 +155,32 @@ public class LiftDataService {
                         }
                         return "暂无";
                     }));
+            LocalDateTime startTimeDate = liftDataRequest.getStartTimeDate();
             //封装区域电梯信息
             regionNameToLiftData.forEach((key, value) -> {
                 RegionLiftResponse regionLiftResponse = new RegionLiftResponse();
                 regionLiftResponse.setRegionName(key);
                 //总电梯数
                 long totalLiftNums = value.size();
-                //计算新增电梯的数量
-                long newLiftNums = value.stream()
-                        .filter(a -> a.getLiftStatus() == 1).count();
-                regionLiftResponse.setNewLiftNums(newLiftNums);
+                //计算新增电梯和丢失电梯的数量
+                AtomicLong newLiftNums = new AtomicLong(0);
+                AtomicLong lostLiftNums = new AtomicLong(0);
+                value.forEach(a -> {
+                    if (a.getConnectTime() != null && a.getConnectTime().isAfter(startTimeDate)) {
+                        if (a.getLiftStatus() == 1) {
+                            newLiftNums.getAndIncrement();
+                        }
+                        if (a.getLiftStatus() == 3) {
+                            lostLiftNums.getAndIncrement();
+                        }
+                    }
+                });
+                //新增台量
+                regionLiftResponse.setNewLiftNums(newLiftNums.get());
                 //丢失电梯台量
-                long lostLiftNums = value.stream()
-                        .filter(a -> a.getLiftStatus() == 3).count();
-                regionLiftResponse.setLostLiftNums(lostLiftNums);
+                regionLiftResponse.setLostLiftNums(lostLiftNums.get());
                 //实际总台量
-                regionLiftResponse.setTotalLiftNums(totalLiftNums - lostLiftNums);
+                regionLiftResponse.setTotalLiftNums(totalLiftNums - lostLiftNums.get());
                 finalRegionLiftResponseList.add(regionLiftResponse);
             });
             //通过丢失台量排序并获取前五的数据

+ 6 - 6
lift-batch-service/src/main/resources/mapper/LiftDataMapper.xml

@@ -33,12 +33,12 @@
             p.region_id = r.id
         where
             pclr.mt_company_id = #{mtCompanyId} and r.mt_company_id = pclr.mt_company_id
-        <if test = "startTimeDateStr != null and startTimeDateStr != ''">
-            and (
-                pclr.create_date <![CDATA[ >= ]]> #{startTimeDateStr}
-                or
-                pclr.create_date is null)
-        </if>
+<!--        <if test = "startTimeDateStr != null and startTimeDateStr != ''">-->
+<!--            and (-->
+<!--                pclr.create_date <![CDATA[ >= ]]> #{startTimeDateStr}-->
+<!--                or-->
+<!--                pclr.create_date is null)-->
+<!--        </if>-->
         <if test = "endTimeDateStr != null and endTimeDateStr != ''">
             and (
                 pclr.create_date <![CDATA[ <= ]]> #{endTimeDateStr}

+ 7 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/controller/EmergencyRepairController.java

@@ -421,6 +421,13 @@ public class EmergencyRepairController {
         EmergencyRepair entity = emergencyRepairService.getById(request.getId());
         Validate.notNull(entity, ValuePool.EMERGENCY_NOT_EXIST);
 
+        log.debug("根据当前公司和用户id获取当前用户是否是急修工");
+        Integer repairFlag = emergencyRepairService.getBaseMapper().selectRepairFlagFromMtCompanyUserBy(request.getMtCompanyId(), request.getUserId());
+        if (repairFlag != 1) {
+            log.debug("当前用户不是急修工");
+            return RestResponse.fail("请使用急修工账号开始急修");
+        }
+
         Validate.equals(entity.getStatus(), ValuePool.EMERGENCY_STATE_TO_DO, ValuePool.EMERGENCY_MUST_TO_DO);
         LocalDateTime assignTime = entity.getAssignTime();
         LocalDateTime takingTime = request.getTakingTime();

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/mapper/EmergencyRepairMapper.java

@@ -8,6 +8,7 @@ import cn.com.ty.lift.business.emergency.entity.EmergencyRepair;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 
@@ -38,4 +39,7 @@ public interface EmergencyRepairMapper extends BaseMapper<EmergencyRepair> {
     long countDoingByUser(@Param("cond") CommonRequest request);
 
     EmergencyCount countEmergencyByUserId(@Param("request") RepairRequest request);
+
+    @Select("select repair_flag from mt_company_user where mt_company_id = #{mtCompanyId} and user_id = #{userId}")
+    Integer selectRepairFlagFromMtCompanyUserBy(Long mtCompanyId, Long userId);
 }

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/entity/model/response/ProjectLiftResponse.java

@@ -33,4 +33,8 @@ public class ProjectLiftResponse {
      * 使用公司代码
      */
     private String useCompanyCode;
+    /**
+     * 电梯是否锁定
+     */
+    private boolean liftLocked;
 }

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

@@ -177,6 +177,9 @@
 		<if test="request.endTime!=null">
 			AND <![CDATA[ mp.plan_date <= #{request.endTime}]]>
 		</if>
+		<if test="request.userId!=null">
+			order by IF(mp.worker_id = ${request.userId}, 0, 1)
+		</if>
 	</select>
 
 	<!--app端 保养任务统计 (0:待保养、-1:超期) -->

+ 2 - 1
lift-business-service/src/main/resources/mapper/project/ProjectMapper.xml

@@ -196,7 +196,8 @@
 		  l.lift_code         AS liftCode,
 		  lb.name             AS liftBrand,
 		  l.lift_type         AS liftType,
-		  l.use_company_code  AS useCompanyCode
+		  l.use_company_code  AS useCompanyCode,
+		  plr.lift_locked     AS liftLocked
 		FROM project_lift_relevance plr
 		<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
 			LEFT JOIN project_user pu ON plr.project_id = pu.project_id