Selaa lähdekoodia

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

bieao 5 vuotta sitten
vanhempi
commit
542c149092
17 muutettua tiedostoa jossa 286 lisäystä ja 202 poistoa
  1. 11 2
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/controller/LiftController.java
  2. 21 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/Lift.java
  3. 0 88
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/LiftExtension.java
  4. 18 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/ProjectLiftRelevance.java
  5. 15 6
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/model/LiftExtensionRequest.java
  6. 0 13
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/mapper/LiftExtensionMapper.java
  7. 8 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/mapper/LiftMapper.java
  8. 5 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/mapper/PlatformCompanyLiftRelevanceMapper.java
  9. 71 43
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java
  10. 19 7
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/PlatformCompanyLiftRelevanceService.java
  11. 8 5
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/ProjectLiftRelevanceService.java
  12. 4 1
      lift-business-service/src/main/resources/locale/response.properties
  13. 0 28
      lift-business-service/src/main/resources/mapper/lift/LiftExtensionMapper.xml
  14. 15 8
      lift-business-service/src/main/resources/mapper/lift/LiftMapper.xml
  15. 8 1
      lift-business-service/src/main/resources/mapper/lift/PlatformCompanyLiftRelevance.xml
  16. 14 0
      lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java
  17. 69 0
      lift-common/src/main/java/cn.com.ty.lift.common/constants/CommonEnum.java

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

@@ -2,7 +2,6 @@ package cn.com.ty.lift.business.library.controller;
 
 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.LiftBrand;
 import cn.com.ty.lift.business.library.dao.entity.ProjectLiftRelevance;
 import cn.com.ty.lift.business.library.dao.entity.model.*;
 import cn.com.ty.lift.business.library.service.LiftService;
@@ -16,7 +15,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import java.util.List;
 
 /**
  * @author bieao
@@ -81,6 +79,17 @@ public class LiftController {
         return RestResponse.ok(lift, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
     }
 
+    /**
+     * @param request 公司id,电梯注册代码
+     * @return RestResponse 判断结果
+     * @description 电梯校验
+     * @date 2019/12/20 2:31 PM
+     */
+    @PostMapping("preJudgment")
+    public RestResponse preJudgment(@RequestBody LiftExtensionRequest request) {
+        return liftService.preJudgment(request.getMtCompanyId(), request.getCode());
+    }
+
     /**
      * @param request 新增电梯数据项
      * @return 1.成功, 0.失败, 消息描述

+ 21 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/Lift.java

@@ -234,4 +234,25 @@ public class Lift {
      * 显示楼层
      */
     private Byte innerFloor;
+
+    /**
+     * 年检日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date annualInspectionDate;
+
+    /**
+     * 行政区划代码
+     */
+    private String areaCode;
+
+    /**
+     * 设备ID
+     */
+    private String deviceId;
+
+    /**
+     * 设备类型
+     */
+    private String deviceType;
 }

+ 0 - 88
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/LiftExtension.java

@@ -1,88 +0,0 @@
-package cn.com.ty.lift.business.library.dao.entity;
-
-import lombok.Data;
-
-import java.util.Date;
-
-/**
- * 实体类 - 表:lift_extension
- * @author bieao
- * @since 2019-12-03 14:09:55
- */
-@Data
-public class LiftExtension {
-    /**
-     * 电梯ID
-     */
-    private Long id;
-
-    /**
-     * 维保公司ID
-     */
-    private Long mtCompanyId;
-
-    /**
-     * 项目ID
-     */
-    private Long projectId;
-
-    /**
-     * 维保工ID
-     */
-    private Long workerId;
-
-    /**
-     * 首保时间
-     */
-    private Date firstTime;
-
-    /**
-     * 停保日期
-     */
-    private Date outServiceDate;
-
-    /**
-     * 年检日期
-     */
-    private Date annualInspectionDate;
-
-    /**
-     * 行政区划代码
-     */
-    private String areaCode;
-
-    /**
-     * 电梯状态 0:删除,1:停保,2:正常,3:保养中 4:维修中
-     */
-    private Byte liftStatus;
-
-    /**
-     * 是否认证 '0 未认证(默认); 1是已认证
-     */
-    private Byte isCertificated;
-
-    /**
-     * 是否锁定 0-正常;1-锁定
-     */
-    private Byte isLocked;
-
-    /**
-     * 临时停梯时间
-     */
-    private Date stopDate;
-
-    /**
-     * 维保间隔
-     */
-    private Byte planInterval;
-
-    /**
-     * 设备ID
-     */
-    private String deviceId;
-
-    /**
-     * 设备类型
-     */
-    private Byte deviceType;
-}

+ 18 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/ProjectLiftRelevance.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
 
+import java.util.Date;
+
 /**
  * 实体类 - 表:project_lift_relevance
  *
@@ -52,4 +54,20 @@ public class ProjectLiftRelevance {
      * 是否删除 0否 1是
      */
     private Byte deleteFlag;
+    /**
+     * 首保时间
+     */
+    private Date firstTime;
+    /**
+     * 停保日期
+     */
+    private Date outServiceDate;
+    /**
+     * 临时停梯时间
+     */
+    private Date stopDate;
+    /**
+     * 维保间隔
+     */
+    private Integer planInterval;
 }

+ 15 - 6
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/model/LiftExtensionRequest.java

@@ -3,8 +3,6 @@ package cn.com.ty.lift.business.library.dao.entity.model;
 import cn.com.ty.lift.business.library.dao.entity.Lift;
 import lombok.Data;
 
-import java.time.LocalDate;
-
 /**
  * @author bieao
  * @date 2019/12/3
@@ -12,26 +10,37 @@ import java.time.LocalDate;
  */
 @Data
 public class LiftExtensionRequest {
+
     /**
-     * 年检日期
+     * 维保工
      */
-    private LocalDate annualInspectionDate;
+    private Long workerId;
 
     /**
-     * 电梯维保负责人
+     * 项目id
      */
-    private Long workerId;
+    private Long projectId;
 
     /**
      * 新增电梯来源入口 (0:从电梯管理新增,1:从项目管理中新增)
      */
     private String source;
 
+    /**
+     * 新增标记 (0:新增,1:查询后带入)
+     */
+    private String mark;
+
     /**
      * 维保公司ID
      */
     private Long mtCompanyId;
 
+    /**
+     * 电梯注册代码
+     */
+    private String code;
+
     /**
      * 电梯
      */

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

@@ -1,13 +0,0 @@
-package cn.com.ty.lift.business.library.dao.mapper;
-
-import cn.com.ty.lift.business.library.dao.entity.LiftExtension;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- * @author bieao
- * @description 电梯扩展数据层
- * @date 2019/12/3 2:32 PM
- */
-public interface LiftExtensionMapper extends BaseMapper<LiftExtension> {
-
-}

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

@@ -19,4 +19,12 @@ public interface LiftMapper extends BaseMapper<Lift> {
 
     IPage<LiftResponse> findLiftListByProjectId(IPage<LiftResponse> page, @Param("request") LiftRequest request);
 
+    /**
+     * @param registrationCode 电梯注册代码
+     * @return 条数
+     * @description 查询电梯是否存在
+     * @date 2019/12/20 11:04 AM
+     */
+    Long findLiftExist(String registrationCode);
+
 }

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

@@ -2,6 +2,9 @@ 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;
+
+import java.util.Map;
 
 /**
  * @author bieao
@@ -11,4 +14,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 public interface PlatformCompanyLiftRelevanceMapper extends BaseMapper<PlatformCompanyLiftRelevance> {
 
     Integer count(Long id);
+
+    Integer findCompanyLiftExist(@Param("paramMap") Map<String,Object> paramMap);
 }

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

@@ -2,23 +2,22 @@ package cn.com.ty.lift.business.library.service;
 
 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.LiftExtension;
 import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
 import cn.com.ty.lift.business.library.dao.entity.model.LiftExtensionRequest;
 import cn.com.ty.lift.business.library.dao.entity.model.LiftRequest;
 import cn.com.ty.lift.business.library.dao.entity.model.LiftResponse;
-import cn.com.ty.lift.business.library.dao.mapper.LiftExtensionMapper;
 import cn.com.ty.lift.business.library.dao.mapper.LiftMapper;
 import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceCompany;
 import cn.com.ty.lift.business.maintenance.service.MaintenanceService;
 import cn.com.ty.lift.common.base.ExportRequest;
 import cn.com.ty.lift.common.constants.ApiConstants;
+import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.export.ExportUtils;
 import cn.com.ty.lift.common.utils.DateUtils;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -36,9 +35,6 @@ public class LiftService {
     @Resource
     private LiftMapper liftMapper;
 
-    @Resource
-    private LiftExtensionMapper liftExtensionMapper;
-
     @Resource
     private PlatformCompanyLiftRelevanceService platformService;
 
@@ -48,9 +44,6 @@ public class LiftService {
     @Resource
     private MaintenanceService maintenanceService;
 
-    @Resource
-    private RedisTemplate redisTemplate;
-
     private Map<String, String> paramMap = new HashMap<String, String>() {{
         put("liftCode", "电梯号");
         put("registrationCode", "注册代码");
@@ -91,20 +84,34 @@ public class LiftService {
         return liftMapper.selectById(id);
     }
 
+
     /**
-     * @param request 电梯
-     * @return 电梯扩展实体
-     * @description 初始化电梯扩展实体
-     * @date 2019/12/3 3:25 PM
+     * @param mtCompanyId 公司id
+     * @param code 注册代码
+     * @return RestResponse 判断结果
+     * @description 新增电梯前置判断条件
+     * @date 2019/12/20 2:31 PM
      */
-    private LiftExtension init(LiftExtensionRequest request) {
-        Long id = request.getLift().getId();
-        Date annualInspectionDate = DateUtils.localDate2Date(request.getAnnualInspectionDate());
-        LiftExtension extension = new LiftExtension();
-        extension.setId(id);
-        extension.setAnnualInspectionDate(annualInspectionDate);
-        extension.setMtCompanyId(request.getMtCompanyId());
-        return extension;
+    public RestResponse preJudgment(Long mtCompanyId, String code) {
+        /*if (judge(mtCompanyId))
+            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
+        //查询电梯表是否有该电梯
+        Long id = findLiftExist(code);
+        if (ObjectUtil.isNotEmpty(id)) {
+            Map<String, Object> paramMap = new HashMap<>(2);
+            paramMap.put("id", id);
+            paramMap.put("mtCompanyId", mtCompanyId);
+            //查询该公司下是否有此电梯
+            boolean result = platformService.findCompanyLiftExist(paramMap);
+            if (result) {
+                return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.lift.exist"));
+            } else {
+                Lift detail = detail(id);
+                return RestResponse.ok(detail, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.lift.company.exist"));
+            }
+        } else {
+            return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.pre.judge"));
+        }
     }
 
     /**
@@ -114,12 +121,24 @@ public class LiftService {
      * @date 2019/12/12 5:27 PM
      */
     public boolean judge(Long mtCompanyId) {
+        //查询维保公司设置的最大电梯台量
         MaintenanceCompany company = maintenanceService.selectById(mtCompanyId);
         Integer limitedNum = company.getLimitedNum();
+        //获取该公司企业电梯关联表的实际电梯台量
         Integer currentNum = platformService.countLiftNum(mtCompanyId);
         return currentNum >= limitedNum;
     }
 
+    /**
+     * @param registrationCode 电梯注册代码
+     * @return 电梯id
+     * @description 查询电梯是否存在
+     * @date 2019/12/20 11:04 AM
+     */
+    public Long findLiftExist(String registrationCode) {
+        return liftMapper.findLiftExist(registrationCode);
+    }
+
     /**
      * @param request 新增电梯数据项
      * @return RestResponse 状态码和返回消息
@@ -128,45 +147,54 @@ public class LiftService {
      */
     @Transactional
     public RestResponse add(LiftExtensionRequest request) {
-        /*Long mtCompanyId = lift.getMtCompanyId();
-        if (judge(mtCompanyId))
-            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
-        //新增电梯表
+        String mark = request.getMark();
         Lift lift = request.getLift();
-        //按当前日期时间戳自动生成电梯编号
-        String liftCode = DateUtils.generateCode();
-        lift.setLiftCode("DT" + liftCode);
-        int liftResult = liftMapper.insert(lift);
-        if (liftResult == 0) {
-            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
-        }
-        //初始化电梯扩展实体
-        LiftExtension extension = init(request);
-        //新增电梯扩展表
-        int extensionResult = liftExtensionMapper.insert(extension);
-        if (extensionResult == 0) {
-            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
+        if ("0".equals(mark)){
+            //按当前日期时间戳自动生成电梯编号
+            String liftCode = ApiConstants.STRAIGHT_LADDER + DateUtils.generateCode();
+            if (CommonEnum.LiftType.STAIRCASE.getCode().equals(Objects.toString(lift.getLiftType()))) {
+                lift.setLiftCode(ApiConstants.STAIRCASE + liftCode);
+            }
+            //新增电梯表
+            int liftResult = liftMapper.insert(lift);
+            if (liftResult == 0) {
+                return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
+            }
         }
+        //电梯id
+        Long id = lift.getId();
+        //公司id
+        Long mtCompanyId = request.getMtCompanyId();
         //新增电梯来源
         String source = request.getSource();
         switch (source) {
             //电梯管理入口
             case "0":
-                //新增平台企业电梯关联表
-                PlatformCompanyLiftRelevance ret = platformService.save(extension);
+                //新增企业电梯关联表
+                PlatformCompanyLiftRelevance ret = platformService.save(id, mtCompanyId);
                 if (ret == null) {
                     return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
                 }
+                //新增平台电梯关联表
+                PlatformCompanyLiftRelevance liftRelevance = platformService.save(id, ApiConstants.PLATFORM_COMPANY_ID);
+                if (liftRelevance == null) {
+                    return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
+                }
                 break;
             //项目管理入口
             case "1":
-                //新增平台企业电梯关联表
-                PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(extension);
+                //新增企业电梯关联表
+                PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(id, mtCompanyId);
                 if (companyLiftEntry == null) {
                     return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
                 }
+                //新增平台电梯关联表
+                PlatformCompanyLiftRelevance relevance = platformService.save(id, ApiConstants.PLATFORM_COMPANY_ID);
+                if (relevance == null) {
+                    return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
+                }
                 //新增项目电梯关联表
-                boolean result = projectRelevanceService.save(extension, companyLiftEntry.getId(), request.getWorkerId());
+                boolean result = projectRelevanceService.save(request, companyLiftEntry.getId(), request.getWorkerId());
                 if (!result) {
                     return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
                 }

+ 19 - 7
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/PlatformCompanyLiftRelevanceService.java

@@ -1,7 +1,6 @@
 package cn.com.ty.lift.business.library.service;
 
 import cn.com.ty.lift.business.framework.util.MessageUtils;
-import cn.com.ty.lift.business.library.dao.entity.LiftExtension;
 import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
 import cn.com.ty.lift.business.library.dao.entity.model.SelectBatchPlatformCompanyRequest;
 import cn.com.ty.lift.business.library.dao.entity.model.UpdateBatchPlatformCompanyRequest;
@@ -16,6 +15,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author bieao
@@ -35,21 +35,33 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
     private LiftService liftService;
 
     /**
-     * @param extension
+     * @param id 电梯id
+     * @param mtCompanyId 公司id
      * @return PlatformCompanyLiftRelevance
-     * @description 新增平台企业关联表数据
+     * @description 新增平台电梯、企业电梯关联表数据
      * @date 2019/12/5 2:38 PM
      */
-    public PlatformCompanyLiftRelevance save(LiftExtension extension) {
+    public PlatformCompanyLiftRelevance save(Long id, Long mtCompanyId) {
+        //建立企业电梯关联关系
         PlatformCompanyLiftRelevance companyLiftEntry = new PlatformCompanyLiftRelevance();
-        companyLiftEntry.setLiftId(extension.getId());
-        companyLiftEntry.setCompanyId(extension.getMtCompanyId());
+        companyLiftEntry.setLiftId(id);
+        companyLiftEntry.setCompanyId(mtCompanyId);
         if (save(companyLiftEntry)) {
             return companyLiftEntry;
         }
         return null;
     }
 
+    /**
+     * @param paramMap 电梯id,公司id
+     * @return 是否存在
+     * @description 查询该公司下是否有此电梯
+     * @date 2019/12/20 11:39 AM
+     */
+    public boolean findCompanyLiftExist(Map<String,Object> paramMap) {
+        return mapper.findCompanyLiftExist(paramMap) > 0;
+    }
+
     /**
      * @param id 公司ID
      * @return 可用电梯台量
@@ -86,7 +98,7 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
             //恢复服务
             case "1":
                 boolean judgeResult = liftService.judge(request.getMtCompanyId());
-                if (!judgeResult){
+                if (!judgeResult) {
                     return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));
                 }
                 break;

+ 8 - 5
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/ProjectLiftRelevanceService.java

@@ -1,9 +1,10 @@
 package cn.com.ty.lift.business.library.service;
 
 import cn.com.ty.lift.business.framework.util.MessageUtils;
-import cn.com.ty.lift.business.library.dao.entity.LiftExtension;
+import cn.com.ty.lift.business.library.dao.entity.Lift;
 import cn.com.ty.lift.business.library.dao.entity.ProjectLiftRelevance;
 import cn.com.ty.lift.business.library.dao.entity.model.BatchUpdateLiftRequest;
+import cn.com.ty.lift.business.library.dao.entity.model.LiftExtensionRequest;
 import cn.com.ty.lift.business.library.dao.mapper.ProjectLiftRelevanceMapper;
 import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.xwy.boot.web.dto.RestResponse;
@@ -34,20 +35,22 @@ public class ProjectLiftRelevanceService extends ServiceImpl<ProjectLiftRelevanc
     }
 
     /**
-     * @param extension 电梯扩展
+     * @param request 电梯扩展请求
      * @param id        平台企业电梯主键id
      * @param workerId  维保工id
      * @return projectLiftEntry
      * @description 新增项目电梯关联数据
      * @date 2019/12/5 2:39 PM
      */
-    public boolean save(LiftExtension extension, long id, long workerId) {
+    public boolean save(LiftExtensionRequest request, long id, long workerId) {
+        Lift lift = request.getLift();
         //新增项目电梯关联表
         ProjectLiftRelevance projectLiftEntry = new ProjectLiftRelevance();
-        projectLiftEntry.setProjectId(extension.getProjectId());
-        projectLiftEntry.setLiftId(extension.getId());
+        projectLiftEntry.setProjectId(request.getProjectId());
+        projectLiftEntry.setLiftId(lift.getId());
         projectLiftEntry.setRelevanceId(id);
         projectLiftEntry.setWorkerId(workerId);
+        projectLiftEntry.setCompanyId(request.getMtCompanyId());
         return save(projectLiftEntry);
     }
 

+ 4 - 1
lift-business-service/src/main/resources/locale/response.properties

@@ -8,4 +8,7 @@ msg.modify.fail=\u4FEE\u6539\u5931\u8D25
 msg.modify.batch.success=\u6279\u91CF\u4FEE\u6539\u6210\u529F
 msg.modify.batch.fail=\u6279\u91CF\u4FEE\u6539\u5931\u8D25
 msg.limit.num=\u5F53\u524D\u7535\u68AF\u53F0\u91CF\u5927\u4E8E\u4F01\u4E1A\u8BBE\u7F6E\u7535\u68AF\u53F0\u91CF
-msg.param.empty=\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A
+msg.param.empty=\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A
+msg.lift.exist=\u516C\u53F8\u4E0B\u5DF2\u6709\u6B64\u7535\u68AF\uFF0C\u4E0D\u80FD\u91CD\u590D\u6DFB\u52A0
+msg.lift.company.exist=\u5176\u4ED6\u516C\u53F8\u5DF2\u6709\u6B64\u7535\u68AF\uFF0C\u8FD4\u56DE\u7535\u68AF\u4FE1\u606F
+msg.pre.judge=\u524D\u7F6E\u6821\u9A8C\u901A\u8FC7

+ 0 - 28
lift-business-service/src/main/resources/mapper/lift/LiftExtensionMapper.xml

@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="cn.com.ty.lift.business.library.dao.mapper.LiftExtensionMapper" >
-	<resultMap id="BaseResultMap" type="cn.com.ty.lift.business.library.dao.entity.LiftExtension" >
-		<id column="id" property="id" jdbcType="BIGINT" />
-		<result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
-		<result column="project_id" property="projectId" jdbcType="BIGINT" />
-		<result column="worker_id" property="workerId" jdbcType="BIGINT" />
-		<result column="first_time" property="firstTime" jdbcType="DATE" />
-		<result column="out_service_date" property="outServiceDate" jdbcType="DATE" />
-		<result column="annual_inspection_date" property="annualInspectionDate" jdbcType="DATE" />
-		<result column="area_code" property="areaCode" jdbcType="CHAR" />
-		<result column="lift_status" property="liftStatus" jdbcType="TINYINT" />
-		<result column="is_certificated" property="isCertificated" jdbcType="TINYINT" />
-		<result column="is_locked" property="isLocked" jdbcType="TINYINT" />
-		<result column="stop_date" property="stopDate" jdbcType="TIMESTAMP" />
-		<result column="plan_interval" property="planInterval" jdbcType="TINYINT" />
-		<result column="device_id" property="deviceId" jdbcType="VARCHAR" />
-		<result column="device_type" property="deviceType" jdbcType="TINYINT" />
-	</resultMap>
-
-	<sql id="Base_Column_List" >
-		id, mt_company_id, project_id, worker_id, first_time, out_service_date, annual_inspection_date, 
-		area_code, lift_status, is_certificated, is_locked, stop_date, plan_interval, device_id, 
-		device_type
-	</sql>
-
-</mapper>

+ 15 - 8
lift-business-service/src/main/resources/mapper/lift/LiftMapper.xml

@@ -45,6 +45,10 @@
 		<result column="reform_date" property="reformDate" jdbcType="TIMESTAMP" />
 		<result column="install_date" property="installDate" jdbcType="TIMESTAMP" />
 		<result column="inner_floor" property="innerFloor" jdbcType="TINYINT" />
+		<result column="annual_inspection_date" property="annualInspectionDate" jdbcType="DATE" />
+		<result column="area_code" property="areaCode" jdbcType="CHAR" />
+		<result column="device_id" property="deviceId" jdbcType="VARCHAR" />
+		<result column="device_type" property="deviceType" jdbcType="TINYINT" />
 	</resultMap>
 
 	<sql id="Base_Column_List" >
@@ -54,7 +58,7 @@
 		motor_power, rated_speed, layer_station_door, clamp_type, reform_company, device_position, 
 		coordinate, remarks, creator_id, create_date, steel_belt, cylinder_type, cylinder_num, 
 		top_type, control_type, mpa, factory, custom_number, use_company_code, device_position_code, 
-		agency, reform_date, install_date, inner_floor
+		agency, reform_date, install_date, inner_floor, annual_inspection_date, area_code, device_id, device_type
 	</sql>
 
 	<!-- 根据区域,项目,电梯号,电梯品牌,电梯类型,维保工查询电梯列表信息-->
@@ -70,11 +74,10 @@
 		le.first_time            AS firstMaintenanceTime,
 		p.project_name           AS projectName
         FROM platform_company_lift_relevance pclr
-        LEFT JOIN lift l ON l.id = pclr.lift_id
-		LEFT JOIN project p ON pclr.company_id = p.mt_company_id
+        LEFT JOIN lift l ON pclr.lift_id = l.id
+        LEFT JOIN project_lift_relevance plr ON pclr.company_id = plr.company_id and pclr.lift_id = plr.lift_id
+        LEFT JOIN project p ON pclr.company_id = p.mt_company_id and plr.project_id = p.id
         LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
-        LEFT JOIN lift_extension le ON le.id = pclr.lift_id AND le.mt_company_id = pclr.company_id
-        WHERE 1=1
         <if test="request.companyId!=null and request.companyId!=''">
 			AND pclr.company_id = #{request.companyId,jdbcType=BIGINT}
         </if>
@@ -104,14 +107,13 @@
           l.lift_type               AS liftType,
           l.device_position         AS devicePosition,
           lb.name                   AS liftBrand,
-          le.annual_inspection_date AS annualInspectionDate,
+          l.annual_inspection_date  AS annualInspectionDate,
           pclr.lift_company_status  AS liftStatus,
 		  ui.name                   AS workerName
         FROM project_lift_relevance plr
           LEFT JOIN lift l ON l.id = plr.lift_id
           LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
-          LEFT JOIN lift_extension le ON le.id = plr.lift_id AND le.mt_company_id = plr.company_id
-		  LEFT JOIN user_info ui ON le.worker_id = ui.user_id
+		  LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
           LEFT JOIN platform_company_lift_relevance pclr ON plr.lift_id = pclr.lift_id AND pclr.id = plr.relevance_id
         WHERE 1=1
         <if test="request.projectId!=null and request.projectId!=''">
@@ -119,4 +121,9 @@
         </if>
     </select>
 
+	<!--根据注册代码查询电梯是否存在,返回电梯id -->
+	<select id="findLiftExist" parameterType="java.lang.String" resultType="java.lang.Long">
+		SELECT id FROM lift WHERE registration_code = #{registrationCode,jdbcType=VARCHAR}
+	</select>
+
 </mapper>

+ 8 - 1
lift-business-service/src/main/resources/mapper/lift/PlatformCompanyLiftRelevance.xml

@@ -5,11 +5,18 @@
 		<id column="id" property="id" jdbcType="BIGINT" />
 		<result column="lift_id" property="liftId" jdbcType="BIGINT" />
 		<result column="company_id" property="companyId" jdbcType="BIGINT" />
-		<result column="lift_company_status" property="code" jdbcType="TINYINT" />
+		<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
 		WHERE id = #{id,jdbcType=BIGINT}
 	</select>
+
+	<!--根据电梯id和公司id查询该公司是否关联过此电梯 -->
+	<select id="findCompanyLiftExist" parameterType="map" resultType="java.lang.Integer">
+		SELECT count(1) FROM platform_company_lift_relevance
+		WHERE lift_id = #{paramMap.id,jdbcType=BIGINT}
+		AND company_id = #{paramMap.mtCompanyId,jdbcType=BIGINT}
+	</select>
 </mapper>

+ 14 - 0
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -66,6 +66,20 @@ public class ApiConstants {
      */
     public static final String AREA_PARENT_ATTR = "parent";
 
+    /**
+     * 平台公司id
+     */
+    public static final Long PLATFORM_COMPANY_ID = 10000L;
+
+    /**
+     * 直梯
+     */
+    public static final String STRAIGHT_LADDER = "ZT";
+    /**
+     * 扶梯
+     */
+    public static final String STAIRCASE = "FT";
+
     /**
      * 用户常量
      */

+ 69 - 0
lift-common/src/main/java/cn.com.ty.lift.common/constants/CommonEnum.java

@@ -2,6 +2,75 @@ package cn.com.ty.lift.common.constants;
 
 public class CommonEnum {
 
+    /**
+     * 电梯类型
+     */
+    public enum LiftType implements IEnum {
+
+        STRAIGHT_LADDER("直梯", "1"),
+        STAIRCASE("扶梯", "2");
+        /**
+         * 值
+         */
+        private String label;
+
+        /**
+         * 键
+         */
+        private String code;
+
+        /**
+         * 构造函数
+         *
+         * @param label String
+         * @param code  String
+         */
+        LiftType(String label, String code) {
+            this.label = label;
+            this.code = code;
+        }
+
+        /**
+         * 取得枚举区分
+         *
+         * @return String
+         */
+        @Override
+        public String getEnumName() {
+            return "LiftType";
+        }
+
+        /**
+         * get
+         *
+         * @return String
+         */
+        @Override
+        public String getLabel() {
+            return label;
+        }
+
+        /**
+         * set
+         *
+         * @return String
+         */
+        @Override
+        public String getCode() {
+            return code;
+        }
+
+        /**
+         * String转换,中间加横杠
+         *
+         * @return String
+         */
+        @Override
+        public String toString() {
+            return this.label;
+        }
+    }
+
     /**
      * 电梯状态
      */