Selaa lähdekoodia

update->修复 新增时,公司下有重复注册代码也可以新增成功问题

wang-hai-cheng 4 vuotta sitten
vanhempi
commit
563d885593

+ 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 = "公司已有此注册码电梯";
+    }
 }