Explorar el Código

提交查询固定企业

chenxiaofei hace 1 día
padre
commit
4a477836c2

+ 1 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEnterpriseDao.java

@@ -247,7 +247,7 @@ public interface KwsEnterpriseDao extends BaseMapper<KwsEnterprise> {
      * @param entType 企业类型
      * @return 企业信息
      */
-    KwsEnterprise findEnterpriseByNameAndType(@Param("enterpriseName") String enterpriseName, @Param("entType") Integer entType);
+    List<KwsEnterprise> findEnterpriseByNameAndType(@Param("enterpriseName") String enterpriseName, @Param("entType") Integer entType);
 
     EntInfo query(@Param("entName") String entName);
 

+ 31 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteBaseService.java

@@ -1,6 +1,8 @@
 package com.sckw.system.dubbo;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.sckw.core.common.enums.enums.ErrorCodeEnum;
+import com.sckw.core.exception.BusinessPlatfromException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.utils.BeanUtils;
@@ -21,6 +23,7 @@ import com.sckw.system.service.KwsRoleService;
 import com.sckw.system.service.KwsSpecialService;
 import com.sckw.system.service.KwsUserService;
 import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -32,6 +35,7 @@ import java.util.stream.Collectors;
  * @date 2023/7/7
  */
 @Service
+@Slf4j
 public class RemoteBaseService {
 
     @Resource
@@ -347,8 +351,14 @@ public class RemoteBaseService {
      * @return 企业信息
      */
     public KwsEnterpriseResDto findEnterpriseByNameAndType(String enterpriseName, Integer entType) {
-        KwsEnterprise kwsEnterprise = kwsEnterpriseDao.findEnterpriseByNameAndType(enterpriseName, entType);
+        if (Objects.isNull(enterpriseName) || enterpriseName.trim().isEmpty() || Objects.isNull(entType)) {
+            log.info("根据企业名称和企业类型精确查询企业参数错误,enterpriseName={}, entType={}", enterpriseName, entType);
+            return null;
+        }
+        List<KwsEnterprise> enterpriseList = kwsEnterpriseDao.findEnterpriseByNameAndType(enterpriseName, entType);
+        KwsEnterprise kwsEnterprise = resolveUniqueEnterpriseByNameAndType(enterpriseList, enterpriseName, entType);
         if (Objects.isNull(kwsEnterprise)) {
+            log.info("根据企业名称和企业类型精确查询企业结果为空,enterpriseName={}, entType={}", enterpriseName, entType);
             return null;
         }
         KwsEnterpriseResDto kwsEnterpriseResDto = new KwsEnterpriseResDto();
@@ -356,6 +366,26 @@ public class RemoteBaseService {
         return kwsEnterpriseResDto;
     }
 
+    /**
+     * 校验企业名称和企业类型共同过滤后的企业唯一性。
+     *
+     * @param enterpriseList 企业列表
+     * @param enterpriseName 企业名称
+     * @param entType 企业类型
+     * @return 唯一企业
+     */
+    static KwsEnterprise resolveUniqueEnterpriseByNameAndType(List<KwsEnterprise> enterpriseList, String enterpriseName, Integer entType) {
+        if (CollectionUtils.isEmpty(enterpriseList)) {
+            return null;
+        }
+        if (enterpriseList.size() > NumberConstant.ONE) {
+            throw new BusinessPlatfromException(
+                    ErrorCodeEnum.PARAM_ERROR,
+                    "企业名称和企业类型匹配到多条企业数据,请检查企业配置:" + enterpriseName + ",类型:" + entType);
+        }
+        return enterpriseList.get(NumberConstant.ZERO);
+    }
+
     public PageDataResult<KwsEnterpriseResDto> pageEnt(int pageNum, int pageSize, Long entId) {
         IPage<KwsEnterprise> kwsEnterprisePage = kwsEnterpriseReposiory.pageEnt(pageNum, pageSize, entId);
         List<KwsEnterprise> records = kwsEnterprisePage.getRecords();

+ 1 - 1
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -934,7 +934,7 @@
                 and b.status = 0
                 and b.del_flag = 0
           )
-        limit 1
+        order by a.id asc
     </select>
 
     <select id="query" resultType="com.sckw.system.model.vo.res.EntInfo">