浏览代码

4/20的代码 各种改的bug

chendayu 2 年之前
父节点
当前提交
be350be71b

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/common/model/dto/QueryInvestigationTypeProjectNumberDTO.java

@@ -15,7 +15,7 @@ import java.io.Serializable;
 @Data
 public class QueryInvestigationTypeProjectNumberDTO implements Serializable {
     /**
-     * 应用场景
+     * 应用场景value
      */
     private Integer applicationScenario;
     /**

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/common/model/vo/ApplicationScenarioEventNumberVO.java

@@ -25,11 +25,11 @@ public class ApplicationScenarioEventNumberVO implements Serializable {
     /**
      * 应用场景直接对应的事件数量
      */
-    private Integer eventNumberFromEvent;
+    //private Integer eventNumberFromEvent;
     /**
      * 应用场景对应的专题库中事件的数量
      */
-    private Integer eventNumberFromProject;
+    //private Integer eventNumberFromProject;
     /**
      * 事件数量
      */

+ 0 - 1
PAS/src/main/java/cn/cslg/pas/common/model/vo/EventListItemVO.java

@@ -52,7 +52,6 @@ public class EventListItemVO implements Serializable {
      */
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @TableField(value = "event_date")
     private Date eventDate;
     /**
      * 租户id

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/controller/EventController.java

@@ -63,10 +63,10 @@ public class EventController {
 
     }
 
-    @Operation(summary = "查询9大应用场景分别对应的事件数量")
+    @Operation(summary = "查询9大应用场景分别对应的事件数量")
     @GetMapping("/queryApplicationScenarioEventNumber")
     public String queryApplicationScenarioEventNumber() {
-        log.info("开始处理【查询9大应用场景分别对应的事件数量】的请求");
+        log.info("开始处理【查询9大应用场景分别对应的事件数量】的请求");
         List<ApplicationScenarioEventNumberVO> queryResults = eventService.queryApplicationScenarioEventNumber();
         return Response.success(queryResults);
     }

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/controller/ProductCategoryController.java

@@ -44,7 +44,7 @@ public class ProductCategoryController {
             }
             return Response.success("新增产品类别完成");
         }
-        return Response.error("请求参数为null");
+        return Response.error("请求参数");
     }
 
     @Operation(summary = "分页查询产品类别")

+ 26 - 0
PAS/src/main/java/cn/cslg/pas/domain/ApplicationScenario.java

@@ -0,0 +1,26 @@
+package cn.cslg.pas.domain;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 应用场景实体类
+ *
+ * @Author chenyu
+ * @Date 2023/4/20
+ */
+@Accessors(chain = true)
+@Data
+public class ApplicationScenario implements Serializable {
+    /**
+     * 应用场景数值
+     */
+    private Integer applicationScenarioValue;
+    /**
+     * 应用场景名称
+     */
+    private String applicationScenarioName;
+
+}

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/domain/Type.java

@@ -6,7 +6,7 @@ import lombok.experimental.Accessors;
 import java.io.Serializable;
 
 /**
- * 调查类型
+ * 调查类型实体类
  *
  * @Author chenyu
  * @Date 2023/4/17

+ 31 - 4
PAS/src/main/java/cn/cslg/pas/mapper/EventMapper.java

@@ -1,10 +1,12 @@
 package cn.cslg.pas.mapper;
 
+import cn.cslg.pas.Application;
 import cn.cslg.pas.common.model.dto.EventQueryPageDTO;
 import cn.cslg.pas.common.model.dto.QueryInvestigationTypeProjectNumberDTO;
 import cn.cslg.pas.common.model.vo.ApplicationScenarioEventNumberVO;
 import cn.cslg.pas.common.model.vo.EventListItemVO;
 import cn.cslg.pas.common.model.vo.InvestigationTypeProjectNumberVO;
+import cn.cslg.pas.domain.ApplicationScenario;
 import cn.cslg.pas.domain.Event;
 import cn.cslg.pas.domain.Project;
 import cn.cslg.pas.domain.Type;
@@ -52,7 +54,31 @@ public interface EventMapper extends BaseMapper<Event> {
      * @param tenantId 租户id
      * @return 返回查询到的数据
      */
-    List<ApplicationScenarioEventNumberVO> queryApplicationScenarioEventNumber(Integer tenantId);
+    //List<ApplicationScenarioEventNumberVO> queryApplicationScenarioEventNumber(Integer tenantId);
+
+    /**
+     * 查询所有应用场景
+     *
+     * @return 返回查询到的数据
+     */
+    List<ApplicationScenario> queryApplicationScenarios();
+
+    /**
+     * 查询所有应用场景不是null的事件
+     *
+     * @param tenantId 租户id
+     * @return 返回查询到的数据
+     */
+    List<EventListItemVO> queryEventsDirectApplicationScenario(Integer tenantId);
+
+    /**
+     * 查询所有应用场景是null的事件(去关联专题库表查询出应用场景,就作为事件的应用场景)
+     *
+     * @param tenantId 租户id
+     * @return 返回查询到的数据
+     */
+    List<EventListItemVO> queryEventsInDirectApplicationScenario(Integer tenantId);
+
 
     /**
      * 根据应用场景查询调查类型
@@ -63,11 +89,12 @@ public interface EventMapper extends BaseMapper<Event> {
     List<Type> queryTypeid(Integer applicationScenario);
 
     /**
-     * 根据事件id查询专题库
+     * 根据应用场景和事件id查询专题库
      *
-     * @param eventId 事件id
+     * @param applicationScenario 应用场景
+     * @param eventId             事件id
      * @return 返回查询到的数据
      */
-    List<Project> queryProjects(Integer eventId);
+    List<Project> queryProjects(Integer applicationScenario, Integer eventId);
 
 }

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/mapper/ProductCategoryMapper.java

@@ -48,7 +48,7 @@ public interface ProductCategoryMapper {
      * @param productCategoryName 产品类别名称
      * @return 返回受影响的行数
      */
-    int countByProductCategoryName(String productCategoryName);
+    int countByProductCategoryName(String productCategoryName, Integer tenantId);
 
     /**
      * 根据id和名称统计数量

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/service/IEventService.java

@@ -42,7 +42,7 @@ public interface IEventService extends IService<Event> {
     JsonPage query(EventQueryPageDTO eventQueryPageDTO);
 
     /**
-     * 查询9大应用场景分别对应的事件数量
+     * 查询9大应用场景分别对应的事件数量
      *
      * @return 返回查询到的数据
      */

+ 59 - 11
PAS/src/main/java/cn/cslg/pas/service/impl/EventServiceImpl.java

@@ -9,6 +9,7 @@ import cn.cslg.pas.common.model.vo.InvestigationTypeProjectNumberVO;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.pas.common.utils.ThrowException;
+import cn.cslg.pas.domain.ApplicationScenario;
 import cn.cslg.pas.domain.Event;
 import cn.cslg.pas.domain.Project;
 import cn.cslg.pas.domain.Type;
@@ -125,7 +126,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
         List<EventAddNewDTO> oldEventAddNewDTOs = eventAddNewDTOs.stream().filter(item -> item.getId() != null).collect(Collectors.toList());
         eventAddNewDTOs.removeAll(oldEventAddNewDTOs);
 
-        //过滤后为新事件↓,新事件需要先新增事件,拿到事件ids后再做关联
+        //过滤后为新事件↓,新事件需要先新增事件,拿到事件ids后再和专题库做关联
         if (eventAddNewDTOs.size() > 0) {
             List<Integer> newEventIds = this.addNew(eventAddNewDTOs);
             eventIds.addAll(newEventIds);
@@ -184,21 +185,68 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
     }
 
     /**
-     * 查询9大应用场景分别对应的事件数量
+     * 查询9大应用场景分别对应的事件数量
      */
     @Override
     public List<ApplicationScenarioEventNumberVO> queryApplicationScenarioEventNumber() {
-        log.info("开始处理【查询9大应用场景分别对应的事件数量】的业务");
+        log.info("开始处理【查询9大应用场景分别对应的事件数量】的业务");
 
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         Integer tenantId = personnelVO.getTenantId();
+        /*
+         * 原先学到的野方法直接在sql中装载好,只需以下几行代码返回给前台(但是杰哥说这样访问数据库效率降到最低,故舍弃)
+         *         List<ApplicationScenarioEventNumberVO> applicationScenarioEventNumberVOS = eventMapper.queryApplicationScenarioEventNumber(tenantId);
+         *         //遍历给事件数量属性赋上值 (事件数量=应用场景直接对应的事件数量+应用场景对应的专题库对应的事件数量(且该部分事件没有直接应用场景))
+         *         for (ApplicationScenarioEventNumberVO n : applicationScenarioEventNumberVOS) {
+         *             n.setEventNumber(n.getEventNumberFromEvent() + n.getEventNumberFromProject());
+         *         }
+         */
+
+        //查询所有应用场景(目前为9个应用场景)
+        List<ApplicationScenario> applicationScenarios = eventMapper.queryApplicationScenarios();
+
+        //查询所有事件(分为两类:1.有应用场景的事件;2.没有应用场景的事件(该部分事件使用它们所属的专题库的应用场景))
+        List<EventListItemVO> eventsDirectApplicationScenario = eventMapper.queryEventsDirectApplicationScenario(tenantId);
+        List<EventListItemVO> eventsInDirectApplicationScenario = eventMapper.queryEventsInDirectApplicationScenario(tenantId);
+        //装载上述两类事件的应用场景
+        ArrayList<String> applicationScenarioStrs = new ArrayList<>();
+        if (eventsDirectApplicationScenario != null) {
+            for (EventListItemVO n : eventsDirectApplicationScenario) {
+                applicationScenarioStrs.add(n.getApplicationScenario());
+            }
+        }
+        if (eventsInDirectApplicationScenario != null) {
+            for (EventListItemVO n : eventsInDirectApplicationScenario) {
+                applicationScenarioStrs.add(n.getApplicationScenario());
+            }
+        }
 
-        List<ApplicationScenarioEventNumberVO> applicationScenarioEventNumberVOS = eventMapper.queryApplicationScenarioEventNumber(tenantId);
-        //遍历给事件数量属性赋上值 (事件数量=应用场景直接对应的事件数量+应用场景对应的专题库对应的事件数量(且该部分事件没有直接应用场景))
-        for (ApplicationScenarioEventNumberVO n : applicationScenarioEventNumberVOS) {
-            n.setEventNumber(n.getEventNumberFromEvent() + n.getEventNumberFromProject());
+        //开始装载9大应用场景分别对应的事件数量
+        ArrayList<ApplicationScenarioEventNumberVO> results = new ArrayList<>();
+        //遍历所有9大应用场景
+        for (ApplicationScenario applicationScenario : applicationScenarios) {
+            Integer applicationScenarioValue = applicationScenario.getApplicationScenarioValue();
+            String applicationScenarioName = applicationScenario.getApplicationScenarioName();
+            //定义当前应用场景对应的事件数量为0
+            int eventNumber = 0;
+            if (applicationScenarioStrs.size() > 0) {
+                //遍历所有事件的应用场景
+                for (String n : applicationScenarioStrs) {
+                    ArrayList<String> applicationScenarioValues = new ArrayList<>(Arrays.asList(n.split(",")));
+                    //若当前事件的应用场景集合包含当前正在遍历的应用场景,则当前正在遍历的应用场景对应事件数量 +1
+                    if (applicationScenarioValues.contains(applicationScenarioValue + "")) {
+                        eventNumber++;
+                    }
+                }
+            }
+            ApplicationScenarioEventNumberVO applicationScenarioEventNumberVO = new ApplicationScenarioEventNumberVO()
+                    .setApplicationScenarioValue(applicationScenarioValue)
+                    .setApplicationScenarioName(applicationScenarioName)
+                    .setEventNumber(eventNumber);
+            results.add(applicationScenarioEventNumberVO);
         }
-        return applicationScenarioEventNumberVOS;
+
+        return results;
     }
 
     /**
@@ -238,8 +286,8 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
         Integer eventId = queryInvestigationTypeProjectNumberDTO.getEventId();
         //1.根据应用场景查询出所有调查类型
         List<Type> types = eventMapper.queryTypeid(applicationScenario);
-        //2.根据事件id查询出所有专题库
-        List<Project> projects = eventMapper.queryProjects(eventId);
+        //2.根据应用场景和事件id查询出所有专题库
+        List<Project> projects = eventMapper.queryProjects(applicationScenario, eventId);
 
         //3.遍历调查类型,在每一个调查类型中遍历专题库,装载调查类型对应的专题库数量
         ArrayList<InvestigationTypeProjectNumberVO> results = new ArrayList<>();
@@ -248,7 +296,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
             result.setInvestigationType(type.getTypeId());
             result.setInvestigationTypeName(type.getTypeName());
             int projectNumber = 0;
-            if (projects != null) {
+            if (projects != null && projects.size() > 0) {
                 for (Project project : projects) {
                     if (project.getType() != null) {
                         String[] typeArr = project.getType().split(",");

+ 11 - 16
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -54,43 +54,40 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     public void addNew(ProductCategoryAddNewDTO productCategoryAddNewDTO, List<MultipartFile> files) {
         log.info("开始处理【新增产品类别】的业务,参数为:{}, {}", productCategoryAddNewDTO, files);
 
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        Integer tenantId = personnelVO.getTenantId();
+
         //检查产品类别名称是否被占用
         String productCategoryName = productCategoryAddNewDTO.getProductCategoryName();
         log.info("检查产品类别名称是否被占用");
-        int count = productCategoryMapper.countByProductCategoryName(productCategoryName);
+        int count = productCategoryMapper.countByProductCategoryName(productCategoryName, tenantId);
         if (count > 0) {
-            String message = "新增产品类别失败,产品类别名称【" + productCategoryName + "】已存在,请尝试更换名称";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("新增产品类别失败,产品类别名称【" + productCategoryName + "】已存在,请尝试更换名称");
         }
 
         //检查许可费率数值是否合法
         Double licenseRate = productCategoryAddNewDTO.getLicenseRate();
         if (licenseRate != null && (licenseRate < 0 || licenseRate > 1)) {
-            String message = "新增产品失败,许可费率不合法,请填写正确数值";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("新增产品类别失败,许可费率不合法,请填写正确数值");
         }
 
         //新增产品类别DTO对象赋值给产品类别表实体类
         ProductCategory productCategory = new ProductCategory();
         BeanUtils.copyProperties(productCategoryAddNewDTO, productCategory);
         //获取当前登陆人信息
-        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         productCategory
                 .setCreatePersonId(personnelVO.getId())
                 .setCreatePersonName(personnelVO.getName())
-                .setTenantId(personnelVO.getTenantId());
+                .setTenantId(tenantId);
+
         //数据入产品类别表
         log.info("数据入产品类别表");
         int rows = productCategoryMapper.insert(productCategory);
         if (rows != 1) {
-            String message = "新增产品类别失败,数据入产品类别表失败,服务器忙请稍后再次尝试";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("新增产品类别失败,数据入产品类别表失败,服务器忙请稍后再次尝试");
         }
 
-        //如果有图片,图片文件上传至服务器,后获取图片文件的名称、后缀名、url地址,赋值给产品类别图片关联表实体类
+        //如果有图片,图片文件上传至本地,获取图片文件的名称、后缀名、url地址,赋值给产品类别图片关联表实体类
         if (files != null && files.size() != 0) {
             ArrayList<AssoProductCategoryPicture> assoProductCategoryPictures = new ArrayList<>();
             for (MultipartFile file : files) {
@@ -108,9 +105,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
             log.info("数据入产品类别图片关联表");
             rows = assoProductCategoryPictureMapper.insertBatch(assoProductCategoryPictures);
             if (rows != assoProductCategoryPictures.size()) {
-                String message = "新增产品类别失败,数据入产品类别图片关联表失败,服务器忙请稍后再次尝试";
-                log.info("{}", message);
-                throw new XiaoShiException(message);
+                ThrowException.throwXiaoShiException("新增产品类别失败,数据入产品类别图片关联表失败,服务器忙请稍后再次尝试");
             }
         }
 

+ 1 - 3
PAS/src/main/java/cn/cslg/pas/service/impl/ProductServiceImpl.java

@@ -348,9 +348,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
         log.info("产品表删除数据");
         int rows = productMapper.deleteById(id);
         if (rows != 1) {
-            String message = "删除产品失败,服务器忙请稍后再次尝试!";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("删除产品失败,服务器忙请稍后再次尝试!");
         }
 
         log.info("删除产品完成");

+ 2 - 4
PAS/src/main/java/cn/cslg/pas/service/impl/StructureServiceImpl.java

@@ -377,9 +377,7 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
         //检查尝试删除的数据是否存在
         Structure queryResult = structureMapper.getStandardById(id);
         if (queryResult == null) {
-            String message = "删除架构失败,尝试访问的数据已不存在";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("删除架构失败,尝试访问的数据已不存在");
         }
 
         ArrayList<Integer> structureIds = new ArrayList<>();
@@ -396,7 +394,7 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
         wrapper.in(Project::getStructureId, structureIds);
         long count = projectService.count(wrapper);
         if (count > 0) {
-            ThrowException.throwXiaoShiException("删除架构失败,该架构或其子级架构正在被专题库使用,请尝试先删除其他关联数据");
+            ThrowException.throwXiaoShiException("删除架构失败,该架构或其子级架构正在被专题库使用,无法删除");
         }
 
         //架构专利产品专题库标引表删除数据

+ 74 - 32
PAS/src/main/resources/mapper/EventMapper.xml

@@ -137,45 +137,87 @@
 
     <!--查询9大应用场景及分别对应的事件数量-->
     <!--List<ApplicationScenarioEventNumber> queryApplicationScenarioEventNumber(Integer tenantId);-->
-    <select id="queryApplicationScenarioEventNumber" resultMap="queryApplicationScenarioEventNumberMap">
-        select label,
-               value       as applicationScenarioValue,
-               #{tenantId} as tenantId
+    <!--        <select id="queryApplicationScenarioEventNumber" resultMap="queryApplicationScenarioEventNumberMap">-->
+    <!--            select label,-->
+    <!--                   value       as applicationScenarioValue,-->
+    <!--                   #{tenantId} as tenantId-->
+    <!--            from os_system_dict-->
+    <!--            where type = "ENTERPRISE_APPLICATION_SCENARIO"-->
+    <!--        </select>-->
+
+    <!--        <resultMap id="queryApplicationScenarioEventNumberMap"-->
+    <!--                   type="cn.cslg.pas.common.model.vo.ApplicationScenarioEventNumberVO">-->
+    <!--            <result column="label" property="applicationScenarioName"/>-->
+    <!--            <result column="value" property="applicationScenarioName"/>-->
+    <!--            <collection property="eventNumberFromEvent" ofType="integer"-->
+    <!--                        select="selectEventCount1"-->
+    <!--                        column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">-->
+    <!--            </collection>-->
+    <!--            <collection property="eventNumberFromProject" ofType="integer"-->
+    <!--                        select="selectEventCount2"-->
+    <!--                        column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">-->
+    <!--            </collection>-->
+    <!--        </resultMap>-->
+
+    <!--        <select id="selectEventCount1" resultType="integer">-->
+    <!--            select count(*)-->
+    <!--            from event-->
+    <!--            where find_in_set(#{applicationScenarioValue}, application_scenario)-->
+    <!--              and tenant_id = #{tenantId}-->
+    <!--        </select>-->
+
+    <!--        <select id="selectEventCount2" resultType="integer">-->
+    <!--            select count(*)-->
+    <!--            from os_thematic proj-->
+    <!--                     join asso_event_project asso on proj.id = asso.project_id-->
+    <!--                     join event even on asso.event_id = even.id-->
+    <!--            where find_in_set(#{applicationScenarioValue}, proj.scenarioid)-->
+    <!--              and even.application_scenario is null-->
+    <!--              and tenant_id = #{tenantId}-->
+    <!--        </select>-->
+
+    <!--查询所有应用场景-->
+    <!--List<ApplicationScenario> queryApplicationScenarios();-->
+    <select id="queryApplicationScenarios" resultMap="queryApplicationScenariosMap">
+        select label, value
         from os_system_dict
         where type = "ENTERPRISE_APPLICATION_SCENARIO"
     </select>
 
-    <resultMap id="queryApplicationScenarioEventNumberMap"
-               type="cn.cslg.pas.common.model.vo.ApplicationScenarioEventNumberVO">
+    <resultMap id="queryApplicationScenariosMap" type="cn.cslg.pas.domain.ApplicationScenario">
         <result column="label" property="applicationScenarioName"/>
-        <result column="value" property="applicationScenarioName"/>
-        <collection property="eventNumberFromEvent" ofType="integer"
-                    select="selectEventCount1"
-                    column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">
-        </collection>
-        <collection property="eventNumberFromProject" ofType="integer"
-                    select="selectEventCount2"
-                    column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">
-        </collection>
+        <result column="value" property="applicationScenarioValue"/>
     </resultMap>
 
-    <select id="selectEventCount1" resultType="integer">
-        select count(*)
+    <!--查询所有应用场景不是null的事件-->
+    <!--List<EventListItemVO> queryEventsDirectApplicationScenario(Integer tenantId);-->
+    <select id="queryEventsDirectApplicationScenario" resultMap="queryEventsHaveApplicationScenarioMap">
+        select application_scenario
         from event
-        where find_in_set(#{applicationScenarioValue}, application_scenario)
+        where application_scenario is not null
           and tenant_id = #{tenantId}
     </select>
 
-    <select id="selectEventCount2" resultType="integer">
-        select count(*)
-        from os_thematic proj
-                 join asso_event_project asso on proj.id = asso.project_id
-                 join event even on asso.event_id = even.id
-        where find_in_set(#{applicationScenarioValue}, proj.scenarioid)
-          and even.application_scenario is null
-          and tenant_id = #{tenantId}
+    <resultMap id="queryEventsHaveApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
+        <result column="application_scenario" property="applicationScenario"/>
+    </resultMap>
+
+    <!--查询所有应用场景是null的事件(去关联专题库表查询出应用场景,就作为事件的应用场景)-->
+    <!--List<EventListItemVO> queryEventsInDirectApplicationScenario(Integer tenantId);-->
+    <select id="queryEventsInDirectApplicationScenario" resultMap="queryEventsInDirectApplicationScenarioMap">
+        select even.application_scenario, proj.scenarioid
+        from event even
+                 join asso_event_project asso on even.id = asso.event_id
+                 join os_thematic proj on asso.project_id = proj.id
+        where even.application_scenario is null
+          and proj.scenarioid is not null
+          and even.tenant_id = #{tenantId}
     </select>
 
+    <resultMap id="queryEventsInDirectApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
+        <result column="scenarioid" property="applicationScenario"/>
+    </resultMap>
+
     <!--根据应用场景查询调查类型-->
     <!--List<Type> queryTypeid(Integer applicationScenario);-->
     <select id="queryTypeid" resultMap="queryTypeidMap">
@@ -189,13 +231,13 @@
         <result column="DICT_CHILD_LABEL" property="typeName"/>
     </resultMap>
 
-    <!--根据事件id查询专题库-->
-    <!--List<Project> queryProjects(Integer eventId);-->
+    <!--根据应用场景和事件id查询专题库-->
+    <!--List<Project> queryProjects(Integer applicationScenario, Integer eventId);-->
     <select id="queryProjects" resultMap="queryProjectsMap">
-        select typeid
-        from asso_event_project asso
-                 join os_thematic proj on asso.project_id = proj.id
-        where event_id = #{eventId}
+        select id, typeid
+        from os_thematic
+        where find_in_set(#{applicationScenario}, scenarioid)
+          and id in (select project_id from asso_event_project where event_id = #{eventId})
     </select>
 
     <resultMap id="queryProjectsMap" type="cn.cslg.pas.domain.Project">

+ 1 - 0
PAS/src/main/resources/mapper/ProductCategoryMapper.xml

@@ -43,6 +43,7 @@
         select count(*)
         from product_category
         where product_category_name = #{productCategoryName}
+          and tenant_id = #{tenantId}
     </select>
 
     <!--根据id和名称统计数量-->