Browse Source

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

bieao 5 years ago
parent
commit
6ca23a64a4

+ 0 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/model/request/LiftDetailRequest.java

@@ -21,6 +21,5 @@ public class LiftDetailRequest {
     /**
      * 项目ID
      */
-    @NotNull(message = "notEmpty")
     private Long projectId;
 }

+ 9 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/request/MaintenancePlanPrintRequest.java

@@ -4,6 +4,8 @@ import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
 import lombok.Data;
 
 import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -17,7 +19,7 @@ public class MaintenancePlanPrintRequest {
     /**
      * 公司id
      */
-    @NotEmpty(message = "notEmpty")
+    @NotNull(message = "notEmpty")
     private Long mtCompanyId;
 
     /**
@@ -26,4 +28,10 @@ public class MaintenancePlanPrintRequest {
     @NotEmpty(message = "notEmpty")
     private List<MaintenancePlan> liftList;
 
+    /**
+     * 当前年月日
+     */
+    @NotNull(message = "notEmpty")
+    private LocalDate beginTime;
+
 }

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

@@ -1,9 +1,9 @@
 package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
 
-import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
 import lombok.Data;
 
-import java.util.Collection;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author bieao
@@ -35,5 +35,5 @@ public class LiftPrintResponse {
     /**
      * 维保计划列表
      */
-    private Collection<MaintenancePlan> planList;
+    private List<Map<String,Object>> planList;
 }

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

@@ -20,10 +20,14 @@ public class MaintenanceRecordResponse {
      * 上次保养类型
      */
     private String type;
+    /**
+     * 项目id
+     */
+    private Long projectId;
     /**
      * 电梯id
      */
-    private String liftId;
+    private Long liftId;
     /**
      * 电梯位置
      */

+ 36 - 24
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenancePlanService.java

@@ -3,13 +3,10 @@ package cn.com.ty.lift.business.maintenance.service;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.business.library.service.LiftService;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.*;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.response.LiftPrintResponse;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenancePlanPrintResponse;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtPlanResponse;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.*;
 import cn.com.ty.lift.business.project.dao.entity.ProjectLiftRelevance;
 import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
 import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenancePlanResponse;
 import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper;
 import cn.com.ty.lift.business.project.dao.entity.Project;
 import cn.com.ty.lift.business.project.service.ProjectService;
@@ -21,7 +18,6 @@ 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.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -29,7 +25,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.time.LocalDate;
+import java.time.Month;
 import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -378,47 +376,60 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         utils.export(projectList, paramMap, request.getExportPath());
     }
 
-
     /**
-     * @param request 电梯列表
-     * @return List<MaintenancePlanPrintResponse> 维保计划打印列表
-     * @description 维保计划打印列表
-     * @date 2020/2/13 3:39 下午
+     * @param mtCompanyId 公司id
+     * @param liftIdList 电梯id列表
+     * @param beginTime 开始时间
+     * @return List<LiftPrintResponse> 电梯维保计划列表
+     * @description 根据公司id和电梯id列表查询维保计划列表,并组装电梯列表数据
+     * @date 2020/3/2 4:39 下午
      */
-    public List<MaintenancePlanPrintResponse> planPrint(MaintenancePlanPrintRequest request) {
-        List<Long> liftIdList = request.getLiftList().stream().map(MaintenancePlan::getLiftId).collect(Collectors.toList());
+    public List<LiftPrintResponse> getLiftMaintenancePlanList(Long mtCompanyId, List<Long> liftIdList, LocalDate beginTime) {
         //根据电梯id列表查询电梯列表
         List<LiftPrintResponse> liftList = liftService.queryLiftListByIdList(liftIdList);
 
-        //拼接查询维保计划的条件
-        List<String> projectLiftList = new ArrayList<>();
-        for (MaintenancePlan entry : request.getLiftList()) {
-            String builder = entry.getProjectId() + "-" + entry.getLiftId();
-            projectLiftList.add(builder);
-        }
-
+        LocalDate endTime = beginTime.with(TemporalAdjusters.lastDayOfMonth());
         Map<String, Object> paramMap = new HashMap<>();
-        paramMap.put("mtCompanyId", request.getMtCompanyId());
-        paramMap.put("projectLiftList", projectLiftList);
-        //根据电梯id、项目id、公司id查询维保计划列表
+        paramMap.put("mtCompanyId", mtCompanyId);
+        paramMap.put("liftIdList", liftIdList);
+        paramMap.put("beginTime", beginTime);
+        paramMap.put("endTime", endTime);
+        //根据电梯id、公司id查询维保计划列表
         List<MaintenancePlan> planList = baseMapper.queryPlanListByIds(paramMap);
 
         //组装电梯列表中的维保计划数据
         for (LiftPrintResponse entry : liftList) {
-            List<MaintenancePlan> plans = new ArrayList<>();
+            List<Map<String,Object>> plans = new ArrayList<>();
             for (MaintenancePlan plan : planList) {
                 if (entry.getProjectId().equals(plan.getProjectId())
                         && entry.getLiftId().equals(plan.getLiftId())
                         && entry.getMtCompanyId().equals(plan.getMtCompanyId())){
-                    plans.add(plan);
+                    Map<String,Object> map = new HashMap<>();
+                    map.put("planDate",plan.getPlanDate());
+                    map.put("type",plan.getType());
+                    plans.add(map);
                 }
             }
             entry.setPlanList(plans);
         }
+        return liftList;
+    }
+
+
+    /**
+     * @param request 电梯列表
+     * @return List<MaintenancePlanPrintResponse> 维保计划打印列表
+     * @description 维保计划打印列表
+     * @date 2020/2/13 3:39 下午
+     */
+    public List<MaintenancePlanPrintResponse> planPrint(MaintenancePlanPrintRequest request) {
+        List<Long> liftIdList = request.getLiftList().stream().map(MaintenancePlan::getLiftId).collect(Collectors.toList());
+
         List<Long> projectIdList = request.getLiftList().stream().map(MaintenancePlan::getProjectId).collect(Collectors.toList());
         //根据项目id列表查询项目列表
         List<MaintenancePlanPrintResponse> projectList = projectService.queryProjectListByIdList(projectIdList);
 
+        List<LiftPrintResponse> liftList = getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList, request.getBeginTime());
         //组装项目列表中的电梯数据
         for (MaintenancePlanPrintResponse project : projectList) {
             List<LiftPrintResponse> liftPrintResponses = new ArrayList<>();
@@ -429,6 +440,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
                 }
             }
             project.setLiftList(liftPrintResponses);
+            project.setNum(project.getLiftList().size());
         }
      return projectList;
     }

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

@@ -2,6 +2,7 @@ package cn.com.ty.lift.business.project.controller;
 
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenancePlanPrintResponse;
 import cn.com.ty.lift.business.project.dao.entity.Project;
 import cn.com.ty.lift.business.project.dao.entity.ProjectHistory;
 import cn.com.ty.lift.business.project.dao.entity.model.request.*;
@@ -11,6 +12,7 @@ import cn.com.ty.lift.common.base.ExportRequest;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -177,6 +179,21 @@ public class ProjectController {
         return projectService.projectLockOrUnLock(request);
     }
 
+    /**
+     * @param request 公司id,项目id
+     * @return 1.成功, 0.失败, 消息描述
+     * @description 项目管理-维保计划打印列表
+     * @date 2020/3/2 4:55 下午
+     */
+    @PostMapping("plan/print")
+    public RestResponse printPlan(@Valid @RequestBody ProjectPrintRequest request){
+        MaintenancePlanPrintResponse detail = projectService.planPrint(request);
+        if (ObjectUtil.isEmpty(detail)) {
+            return RestResponse.success();
+        }
+        return RestResponse.success(detail, MessageUtils.get("msg.query.success"));
+    }
+
     /**
      * @param request 导出项目数据列表
      * @return 1.成功, 0.失败, 消息描述

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

@@ -0,0 +1,31 @@
+package cn.com.ty.lift.business.project.dao.entity.model.request;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.time.LocalDate;
+
+/**
+ * @author bieao
+ * @date 2020/3/2
+ * @description 项目管理计划打印
+ */
+@Data
+public class ProjectPrintRequest {
+    /**
+     * 公司id
+     */
+    @NotNull(message = "notEmpty")
+    private Long mtCompanyId;
+
+    /**
+     * 项目id
+     */
+    @NotNull(message = "notEmpty")
+    private Long id;
+
+    /**
+     * 当前年月日
+     */
+    private LocalDate beginTime;
+}

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

@@ -55,4 +55,12 @@ public interface ProjectMapper extends BaseMapper<Project> {
      */
     List<MaintenancePlanPrintResponse> queryProjectListByIdList(@Param("list") List<Long> projectIdList);
 
+    /**
+     * @param request 项目id
+     * @return MaintenancePlanPrintResponse 项目详情
+     * @description 根据项目id查询项目详情
+     * @date 2020/3/2 4:48 下午
+     */
+    MaintenancePlanPrintResponse findProjectByIdAndCompanyId(@Param("request") ProjectPrintRequest request);
+
 }

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

@@ -3,7 +3,9 @@ package cn.com.ty.lift.business.project.service;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
 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.dao.entity.model.response.MaintenancePlanPrintResponse;
+import cn.com.ty.lift.business.maintenance.service.MaintenancePlanService;
 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.project.dao.entity.model.request.*;
@@ -14,8 +16,8 @@ import cn.com.ty.lift.business.project.dao.mapper.ProjectMapper;
 import cn.com.ty.lift.common.base.ExportRequest;
 import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.export.ExportUtils;
-import cn.com.ty.lift.common.verify.Verify;
 import cn.com.ty.lift.common.utils.DateUtils;
+import cn.com.ty.lift.common.verify.Verify;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
@@ -62,6 +64,8 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
     private RegionService regionService;
     @Resource
     private ProjectUserService projectUserService;
+    @Resource
+    private MaintenancePlanService maintenancePlanService;
 
     private Map<String, String> paramMap = new HashMap<String, String>() {{
         put("projectCode", "项目编号");
@@ -292,6 +296,28 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
         }
         return RestResponse.success(null, MessageUtils.get("msg.modify.success"));
     }
+
+    /**
+     * @param request 公司id,项目id
+     * @return List<MaintenancePlanPrintResponse> 项目管理-维保计划打印列表
+     * @description 项目管理-维保计划打印列表
+     * @date 2020/3/2 4:54 下午
+     */
+    public MaintenancePlanPrintResponse planPrint(ProjectPrintRequest request) {
+        //根据项目id查询项目详情
+        MaintenancePlanPrintResponse project = baseMapper.findProjectByIdAndCompanyId(request);
+
+        //根据项目id和公司id查询项目下电梯列表
+        List<ProjectLiftRelevance> liftList = projectLiftRelevanceService.findLiftList(request.getMtCompanyId(), request.getId());
+
+        List<Long> liftIdList = liftList.stream().map(ProjectLiftRelevance::getLiftId).collect(Collectors.toList());
+        //根据公司id和电梯id列表查询维保计划列表
+        List<LiftPrintResponse> liftMaintenancePlanList = maintenancePlanService.getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList,request.getBeginTime());
+        project.setLiftList(liftMaintenancePlanList);
+        project.setNum(liftList.size());
+        return project;
+    }
+
     private void rollback(){
         //强制手动事务回滚
         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

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

@@ -92,12 +92,12 @@
 	</select>
 
 	<select id="queryPlanListByIds" parameterType="java.util.Map" resultMap="BaseResultMap">
-		SELECT t.*
-		FROM (SELECT *, concat(project_id,'-',lift_id) AS projectLift
-			  FROM maintenance_plan) t
-		WHERE t.mt_company_id = #{paramMap.mtCompanyId,jdbcType=VARCHAR}
-		  AND t.projectLift IN
-		<foreach collection="paramMap.projectLiftList" item="id" index="index" open="(" close=")" separator=",">
+        SELECT <include refid="Base_Column_List"/>
+			  FROM maintenance_plan
+		WHERE mt_company_id = #{paramMap.mtCompanyId,jdbcType=VARCHAR}
+		  AND plan_date BETWEEN #{paramMap.beginTime} AND #{paramMap.endTime}
+		  AND lift_id IN
+		<foreach collection="paramMap.liftIdList" item="id" index="index" open="(" close=")" separator=",">
 			#{id}
 		</foreach>
 	</select>

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

@@ -57,7 +57,8 @@
 				mr.type               AS type,
 				mr.lift_id            AS liftId,
 				l.device_position     AS devicePosition,
-				p.project_name        AS projectName
+				p.project_name        AS projectName,
+		        p.id                  AS projectId
 		FROM maintenance_record mr
 				LEFT JOIN project p ON mr.project_id = p.id
 				LEFT JOIN lift l ON mr.lift_id = l.id

+ 18 - 3
lift-business-service/src/main/resources/mapper/project/ProjectMapper.xml

@@ -158,7 +158,7 @@
 		LEFT JOIN project p ON plr.project_id = p.id
 		WHERE 1=1
 		<if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
-			AND plr.mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR}
+			AND plr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
 		</if>
 		<if test="request.projectName!=null and request.projectName!=''">
 			AND p.project_name LIKE CONCAT('%',#{request.projectName,jdbcType=VARCHAR},'%')
@@ -181,7 +181,7 @@
 		  LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
 		  WHERE 1=1
 		<if test="request.id!=null and request.id!=''">
-			AND plr.project_id = #{request.id,jdbcType=VARCHAR}
+			AND plr.project_id = #{request.id,jdbcType=BIGINT}
 		</if>
 		<if test="request.registrationCode!=null and request.registrationCode!=''">
 			AND l.registration_code LIKE CONCAT('%',#{request.registrationCode,jdbcType=VARCHAR},'%')
@@ -216,11 +216,26 @@
 				 LEFT JOIN property_company pc ON p.pp_company_id = pc.id
 		WHERE 1=1
 		<if test="request.id!=null and request.id!=''">
-			AND p.id = #{request.id,jdbcType=VARCHAR}
+			AND p.id = #{request.id,jdbcType=BIGINT}
 		</if>
 		    ) t
 		LEFT JOIN property_contact pcc ON t.contact_id = pcc.id
 		LEFT JOIN user_info ui ON ui.user_id = t.clerk_id
 	</select>
 
+	<select id="findProjectByIdAndCompanyId" parameterType="cn.com.ty.lift.business.project.dao.entity.model.request.ProjectPrintRequest"
+			resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenancePlanPrintResponse">
+		SELECT p.id            AS projectId,
+			   p.mt_company_id AS mtCompanyId,
+			   p.project_name  AS projectName,
+			   p.project_code  AS projectCode,
+			   pc.name         AS ppCompanyName,
+			   mc.name         AS mtCompanyName
+		FROM project p
+				 LEFT JOIN property_company pc ON p.pp_company_id = pc.id
+				 LEFT JOIN maintenance_company mc ON p.mt_company_id = mc.id
+        WHERE p.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
+        AND p.id = #{request.id,jdbcType=BIGINT}
+	</select>
+
 </mapper>