Browse Source

Merge branch 'feature-bieao' of lift-manager/lift-server into develop

bieao 5 năm trước cách đây
mục cha
commit
51c019de43

+ 16 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/controller/LiftController.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.Map;
 
 /**
  * @author bieao
@@ -52,6 +53,21 @@ public class LiftController {
         return RestResponse.success(page, MessageUtils.get("msg.query.success"));
     }
 
+    /**
+     * @param request 公司id
+     * @return 数量集合
+     * @description 根据公司id查询服务中电梯和维修中的电梯数量
+     * @date 2020/1/19 2:34 下午
+     */
+    @PostMapping("countAll")
+    public RestResponse countAll(@Valid @RequestBody LiftChooseRequest request) {
+        Map<String, Object> resultMap = platformService.countAll(request.getMtCompanyId());
+        if (CollUtil.isEmpty(resultMap)) {
+            return RestResponse.success();
+        }
+        return RestResponse.success(resultMap, MessageUtils.get("msg.query.detail.success"));
+    }
+
     /**
      * @param request 电梯列表查询条件
      * @return RestResponse 项目下电梯列表

+ 2 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/mapper/PlatformCompanyLiftRelevanceMapper.java

@@ -2,6 +2,7 @@ package cn.com.ty.lift.business.library.dao.mapper;
 
 import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * @author bieao
@@ -10,4 +11,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface PlatformCompanyLiftRelevanceMapper extends BaseMapper<PlatformCompanyLiftRelevance> {
 
+    int count(@Param("mtCompanyId") Long mtCompanyId, @Param("projectStatus") String projectStatus);
 }

+ 33 - 9
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/PlatformCompanyLiftRelevanceService.java

@@ -23,10 +23,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -37,9 +34,6 @@ import java.util.stream.Collectors;
 @Service
 public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCompanyLiftRelevanceMapper, PlatformCompanyLiftRelevance> {
 
-    @Resource
-    private PlatformCompanyLiftRelevanceMapper mapper;
-
     @Resource
     private ProjectService projectService;
 
@@ -71,6 +65,36 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
         return save(companyLiftEntry) ? companyLiftEntry : null;
     }
 
+    /**
+     * @param mtCompanyId 公司id
+     * @return 数量集合
+     * @description 根据公司id查询服务中电梯和维修中的电梯数量
+     * @date 2020/1/19 2:34 下午
+     */
+    public Map<String, Object> countAll(Long mtCompanyId) {
+        LambdaQueryWrapper<PlatformCompanyLiftRelevance> lambdaQueryWrapper = new QueryWrapper<PlatformCompanyLiftRelevance>().lambda();
+        lambdaQueryWrapper.eq(PlatformCompanyLiftRelevance::getMtCompanyId, mtCompanyId);
+        lambdaQueryWrapper.ne(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.STOP_INSURANCE.getCode());
+        int inService = count(lambdaQueryWrapper);
+        lambdaQueryWrapper.eq(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.EMERGENCY_REPAIR.getCode());
+        int emergency = count(lambdaQueryWrapper);
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("inService", inService);
+        resultMap.put("emergency", emergency);
+        return resultMap;
+    }
+
+    /**
+     * @param mtCompanyId   公司id
+     * @param projectStatus 项目状态
+     * @return 条数
+     * @description 根据公司id和项目状态查询停保电梯
+     * @date 2020/1/19 2:15 下午
+     */
+    public int count(Long mtCompanyId, String projectStatus) {
+        return baseMapper.count(mtCompanyId, projectStatus);
+    }
+
     /**
      * @param paramMap 电梯id,公司id
      * @return 是否存在
@@ -109,7 +133,7 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
         //根据项目id和公司id查询电梯列表
         List<ProjectLiftRelevance> liftList = projectLiftRelevanceService.findLiftList(mtCompanyId, projectId);
         Collection<Long> list = liftList.stream().map(ProjectLiftRelevance::getRelevanceId).collect(Collectors.toList());
-        return mapper.selectBatchIds(list);
+        return baseMapper.selectBatchIds(list);
     }
 
     /**
@@ -220,7 +244,7 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
         //公司电梯关联表主键id列表
         List<Long> companyIdList = request.getRelevanceIdList();
         //批量查询公司下电梯数据
-        List<PlatformCompanyLiftRelevance> list = mapper.selectBatchIds(companyIdList);
+        List<PlatformCompanyLiftRelevance> list = baseMapper.selectBatchIds(companyIdList);
         if (CollUtil.isEmpty(list)) {
             return RestResponse.success();
         }

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

@@ -86,7 +86,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         if (!ret) {
             return RestResponse.fail(MessageUtils.get("msg.add.fail"));
         }
-        return RestResponse.success(null, MessageUtils.get("msg.add.success"));
+        return RestResponse.success(record.getId(), MessageUtils.get("msg.add.success"));
     }
 
     /**

+ 15 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/controller/ProjectController.java

@@ -55,6 +55,21 @@ public class ProjectController {
         return RestResponse.success(page, MessageUtils.get("msg.query.success"));
     }
 
+    /**
+     * @param request 公司id,项目状态
+     * @return 项目数量、电梯数量、停保电梯数量
+     * @description 查询项目数量、电梯数量、停保电梯数量
+     * @date 2020/1/19 11:30 上午
+     */
+    @PostMapping("countAll")
+    public RestResponse countAll(@Valid @RequestBody ProjectCountRequest request) {
+        Map<String, Object> resultMap = projectService.countAll(request.getMtCompanyId(), request.getProjectStatus());
+        if (CollUtil.isEmpty(resultMap)) {
+            return RestResponse.success();
+        }
+        return RestResponse.success(resultMap, MessageUtils.get("msg.query.detail.success"));
+    }
+
     /**
      * @param request 公司项目查询条件
      * @return RestResponse 公司项目分页列表结果

+ 26 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/entity/model/request/ProjectCountRequest.java

@@ -0,0 +1,26 @@
+package cn.com.ty.lift.business.project.dao.entity.model.request;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author bieao
+ * @date 2020/1/19
+ * @description 项目统计请求
+ */
+@Data
+public class ProjectCountRequest {
+    /**
+     * 公司id
+     */
+    @NotNull(message = "notEmpty")
+    private Long mtCompanyId;
+
+    /**
+     * 项目状态
+     */
+    @NotEmpty(message = "notEmpty")
+    private String projectStatus;
+}

+ 1 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/mapper/ProjectLiftRelevanceMapper.java

@@ -16,4 +16,5 @@ public interface ProjectLiftRelevanceMapper extends BaseMapper<ProjectLiftReleva
 
     IPage<ProjectRelevanceResponse> selectListByUserId(IPage<ProjectRelevanceResponse> page, @Param("request") ProjectLiftRelevanceRequest request);
 
+    int count(@Param("mtCompanyId") Long mtCompanyId, @Param("projectStatus") String projectStatus);
 }

+ 11 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectLiftRelevanceService.java

@@ -52,6 +52,17 @@ public class ProjectLiftRelevanceService extends ServiceImpl<ProjectLiftRelevanc
         return RestResponse.success(null, MessageUtils.get("msg.delete.success"));
     }
 
+    /**
+     * @param mtCompanyId   公司id
+     * @param projectStatus 项目状态
+     * @return 条数
+     * @description 根据公司id和项目状态查询电梯
+     * @date 2020/1/19 2:15 下午
+     */
+    public int count(Long mtCompanyId, String projectStatus) {
+        return baseMapper.count(mtCompanyId, projectStatus);
+    }
+
     /**
      * @param request  电梯扩展请求
      * @param id       平台企业电梯主键id

+ 40 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java

@@ -2,6 +2,7 @@ package cn.com.ty.lift.business.project.service;
 
 import cn.com.ty.lift.business.common.Judge;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
+import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
 import cn.com.ty.lift.business.project.dao.entity.*;
 import cn.com.ty.lift.business.project.dao.entity.model.ProjectImportModel;
 import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
@@ -24,6 +25,7 @@ import cn.com.xwy.boot.web.dto.RestResponse;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@@ -56,6 +58,12 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
     @Resource
     private ProjectMapper projectMapper;
 
+    @Resource
+    private ProjectLiftRelevanceService projectLiftRelevanceService;
+
+    @Resource
+    private PlatformCompanyLiftRelevanceService platformCompanyService;
+
     @Resource
     private ProjectHistoryMapper projectHistoryMapper;
 
@@ -102,6 +110,38 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
         return projectMapper.findByCondition(page, request);
     }
 
+    /**
+     * @param mtCompanyId   公司id
+     * @param projectStatus 项目状态
+     * @return 项目数量、电梯数量、停保电梯数量
+     * @description 查询项目数量、电梯数量、停保电梯数量
+     * @date 2020/1/19 11:30 上午
+     */
+    public Map<String, Object> countAll(Long mtCompanyId, String projectStatus) {
+        int projectCount = count(mtCompanyId, projectStatus);
+        int liftCount = projectLiftRelevanceService.count(mtCompanyId, projectStatus);
+        int stopLiftCount = platformCompanyService.count(mtCompanyId, projectStatus);
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("projectCount", projectCount);
+        resultMap.put("liftCount", liftCount);
+        resultMap.put("stopLiftCount", stopLiftCount);
+        return resultMap;
+    }
+
+    /**
+     * @param mtCompanyId   公司id
+     * @param projectStatus 项目状态
+     * @return 符合条件的项目数量
+     * @description 根据项目状态和公司id查询项目数量
+     * @date 2020/1/19 11:30 上午
+     */
+    public int count(Long mtCompanyId, String projectStatus) {
+        LambdaQueryWrapper<Project> lambdaQueryWrapper = new QueryWrapper<Project>().lambda();
+        lambdaQueryWrapper.eq(Project::getMtCompanyId, mtCompanyId);
+        lambdaQueryWrapper.eq(Project::getProjectStatus, projectStatus);
+        return count(lambdaQueryWrapper);
+    }
+
     /**
      * @param request 公司项目查询条件
      * @return IPage<ProjectResponse> 公司项目分页列表结果

+ 10 - 0
lift-business-service/src/main/resources/mapper/lift/PlatformCompanyLiftRelevanceMapper.xml

@@ -7,4 +7,14 @@
 		<result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
 		<result column="lift_company_status" property="liftCompanyStatus" jdbcType="TINYINT" />
 	</resultMap>
+
+	<select id="count" resultType="java.lang.Integer">
+		SELECT count(1)
+		FROM platform_company_lift_relevance pclr
+				 LEFT JOIN project_lift_relevance plr ON pclr.lift_id = plr.lift_id
+				 LEFT JOIN project p ON plr.project_id = p.id
+		WHERE pclr.mt_company_id = #{mtCompanyId}
+		  AND p.project_status = #{projectStatus}
+		  AND lift_company_status = '1'
+	</select>
 </mapper>

+ 8 - 0
lift-business-service/src/main/resources/mapper/project/ProjectLiftRelevanceMapper.xml

@@ -39,4 +39,12 @@
 		  LEFT JOIN lift l ON plr.lift_id = l.id
 		WHERE plr.worker_id = #{request.workerId,jdbcType=BIGINT}
 	</select>
+
+	<select id="count" resultType="java.lang.Integer">
+		SELECT count(1)
+		FROM project_lift_relevance plr
+				 LEFT JOIN project p ON plr.project_id = p.id
+		WHERE plr.mt_company_id = #{mtCompanyId}
+		  AND p.project_status = #{projectStatus}
+	</select>
 </mapper>