浏览代码

Merge branch 'master' of http://111.47.6.224:3000/udream-cxs/lift-server.git

Wei Ruifeng 4 年之前
父节点
当前提交
d9646d035d

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

@@ -15,4 +15,5 @@ public interface PlatformCompanyLiftRelevanceMapper extends BaseMapper<PlatformC
 
     int countCapital(@Param("mtCompanyId") Long mtCompanyId, @Param("projectStatus") String projectStatus);
 
+    int countForCompanyLiftRegistrationCode(Long companyId, String registrationCode);
 }

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

@@ -171,10 +171,14 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
             Map<String, Object> paramMap = new HashMap<>(2);
             paramMap.put("liftId", liftId);
             paramMap.put("mtCompanyId", mtCompanyId);
-            //查询该公司下是否有此电梯
+            //查询该公司下是否有此电梯id
             boolean result = platformService.findCompanyLiftExist(paramMap);
+            //查询该公司下是否有此电梯注册代码
+            int registrationCodeCount = platformService.getBaseMapper().countForCompanyLiftRegistrationCode(mtCompanyId, registrationCode);
             if (result) {
                 return RestResponse.fail(MessageUtils.get("msg.lift.exist"));
+            } else if (registrationCodeCount > 0) {
+                return RestResponse.fail(ApiConstants.ResponseMessage.LIFT_EXIST);
             } else {
                 Object detail = detail(liftId, null);
                 return RestResponse.success(detail, MessageUtils.get("msg.lift.company.exist"));

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

@@ -27,4 +27,11 @@
 		  AND cr.project_status = #{projectStatus}
 		  AND lift_company_status = '1'
 	</select>
+	<select id="countForCompanyLiftRegistrationCode" resultType="java.lang.Integer">
+		select count(*)
+		from platform_company_lift_relevance pclr
+				 left join lift l on pclr.lift_id = l.id
+		where pclr.mt_company_id = #{companyId}
+		  and l.registration_code = #{registrationCode};
+	</select>
 </mapper>

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

@@ -370,4 +370,9 @@ public class ApiConstants {
     public interface Platform {
         Long COMPANY_ID = 10086L;
     }
+
+    public interface ResponseMessage {
+        String LIFT_EXIST = "电梯已存在";
+        String REGISTRATION_CODE_EXIST = "公司已有此注册码电梯";
+    }
 }

+ 4 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/user/dao/mapper/MtCompanyUserMapper.java

@@ -6,6 +6,7 @@ import cn.com.ty.lift.system.user.dao.entity.model.ProjectInfo;
 import cn.com.ty.lift.system.user.dao.entity.model.ProjectUser;
 import cn.com.xwy.boot.mybatis.MyBatisMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
 
 import java.util.List;
 
@@ -55,4 +56,7 @@ public interface MtCompanyUserMapper extends BaseMapper<MtCompanyUser> {
      * @date 2020/5/2 11:00 下午
      */
     ProjectInfo getProjectById(Long projectId);
+
+    @Delete("delete from lift_certificate where mt_company_id=#{mtCompanyId} and owner_id=#{userId}")
+    int removeCertificate(Long userId, Long mtCompanyId);
 }

+ 3 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/MtCompanyUserService.java

@@ -201,6 +201,8 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
                 .eq("user_id", mtCompanyUser.getUserId())
                 .eq("company_id", mtCompanyUser.getMtCompanyId())
         );
+        //将用户的操作证删除
+        this.baseMapper.removeCertificate(mtCompanyUser.getUserId(), mtCompanyUser.getMtCompanyId());
         if (deleteUserRoleFlag) {
             if (this.updateById(mtCompanyUser)) {
                 //踢出成功推送消息
@@ -303,7 +305,7 @@ public class MtCompanyUserService extends ServiceImpl<MtCompanyUserMapper, MtCom
                 if (userIdToLiftUserList.size() > 0) {
                     List<LiftUser> liftUsers = userIdToLiftUserList.get(mtCompanyUser.getUserId());
                     long liftNum = 0L;
-                    if(liftUsers != null) {
+                    if (liftUsers != null) {
                         liftNum = liftUsers.size();
                     }
                     mtCompanyUserResponse.setConnectedLiftNum(liftNum);