Browse Source

机构数据

liujc 7 months ago
parent
commit
0e4032d580

+ 64 - 109
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantAlbumController.java

@@ -9,6 +9,7 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.admin.io.request.TenantAlbumVo;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
 import com.yonge.cooleshow.biz.dal.entity.*;
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
@@ -85,135 +86,89 @@ public class TenantAlbumController {
      * @param id 详情ID
      * @return TenantAlbum
      */
-    @PostMapping("/detail")
+    @PostMapping("/detailInfo")
     @ApiOperation(value = "查询详情", notes = "detail")
-    @PreAuthorize("@pcs.hasPermissions('tenantAlbum/detail')")
-    public HttpResponseResult<TenantAlbumWrapper.TenantAlbum> detail(@RequestParam("id") Long id) {
+    @PreAuthorize("@pcs.hasPermissions('tenantAlbum/detailInfo')")
+    public HttpResponseResult<List<TenantAlbumWrapper.TenantAlbumSheet>> detailInfo(@RequestParam("id") Long id,@RequestParam("subjectType") String subjectType) {
         TenantAlbum tenantAlbum = tenantAlbumService.detail(id);
         if (tenantAlbum == null) {
             throw new BizException("专辑信息不存在");
         }
 
-        TenantAlbumWrapper.TenantAlbum vo = JSON.parseObject(JSON.toJSONString(tenantAlbum),
-                TenantAlbumWrapper.TenantAlbum.class);
-
-        //查关联表
-        TenantAlbumRef one = tenantAlbumRefService.lambdaQuery().eq(TenantAlbumRef::getTenantAlbumId, id)
-                .last("limit 1").one();
-        vo.setTenantId(one.getTenantId().toString());
-        //查询曲目表
 
-        TenantInfo tenantInfo = tenantInfoService.getById(one.getTenantId());
-        vo.setTenantName(tenantInfo.getName());
         List<TenantAlbumMusic> tenantAlbumMusics = tenantAlbumMusicService.lambdaQuery()
-                .eq(TenantAlbumMusic::getTenantAlbumId, id)
-                .eq(TenantAlbumMusic::getDelFlag, false)
-                .list();
-
-        Map<SubjectTypeEnum, List<TenantAlbumMusic>> groupByType =
-                tenantAlbumMusics.stream().collect(Collectors.groupingBy(TenantAlbumMusic::getSubjectType));
-
-
-        List<Long> musicSheetIdlist = tenantAlbumMusics.stream()
-            .filter(o ->o.getSubjectType() !=SubjectTypeEnum.COURSEWARE)
-            .map(TenantAlbumMusic::getMusicSheetId).distinct()
-            .collect(Collectors.toList());
-        // 过滤出课件
-        List<Long> coursewareList = tenantAlbumMusics.stream()
-                .filter(o -> o.getSubjectType() == SubjectTypeEnum.COURSEWARE)
-                .map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
-        Map<Long,CbsLessonCoursewareWrapper.Entity> coursewareDtoMap = new HashMap<>();
+            .eq(TenantAlbumMusic::getTenantAlbumId, id)
+            .eq(TenantAlbumMusic::getSubjectType, SubjectTypeEnum.valueOf(subjectType))
+            .eq(TenantAlbumMusic::getDelFlag, false)
+            .orderByAsc(TenantAlbumMusic::getSortNumber,TenantAlbumMusic::getId)
+            .list();
+        if (CollectionUtils.isEmpty(tenantAlbumMusics)) {
+            return HttpResponseResult.succeed();
+        }
 
-        if (CollectionUtils.isNotEmpty(coursewareList)) {
+        if (subjectType.equals(SubjectTypeEnum.COURSEWARE.name())) {
+            List<Long> coursewareList = tenantAlbumMusics.stream().map(TenantAlbumMusic::getMusicSheetId).collect(Collectors.toList());
             List<CbsLessonCoursewareWrapper.Entity> entities = coursewareFeignService
                 .lessonCoursewareLambdaQuery(CbsLessonCoursewareWrapper.LambdaQuery.builder().ids(coursewareList).build()).feignData();
-            coursewareDtoMap.putAll(entities.stream().collect(Collectors.toMap(CbsLessonCoursewareWrapper.Entity::getId, Function.identity())));
-        }
-
-        Map<Long, MusicSheetVo> idMsMap = new HashMap<>();
-        Map<Integer,Subject> subjectMap = subjectService.getAllMap();
-        Map<Long, MusicTag> musicTagMap = musicTagService.getAllMap();
-        if (CollectionUtils.isNotEmpty(musicSheetIdlist)) {
+            return HttpResponseResult.succeed(entities.stream().map(o -> {
+                TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
+                tenantAlbumSheet.setId(o.getId().toString());
+                tenantAlbumSheet.setMusicSheetName(o.getName());
+                tenantAlbumSheet.setTitleImg(o.getCoverImg());
+                tenantAlbumSheet.setMusicSubject(o.getCourseTypeCode());
+                tenantAlbumSheet.setMusicSubjectName(ECourseType.valueOf(o.getCourseTypeCode()).getName());
+                return tenantAlbumSheet;
+            }).collect(Collectors.toList()));
+        } else {
+            List<Long> musicSheetIdlist = tenantAlbumMusics.stream().map(TenantAlbumMusic::getMusicSheetId).collect(Collectors.toList());
             StudentMusicSheetSearch search = new StudentMusicSheetSearch();
             search.setMusicSheetIdlist(musicSheetIdlist);
+            search.setProviderType(SourceTypeEnum.TENANT);
             search.setPage(1);
             search.setRows(9999);
             IPage<MusicSheetVo> records = musicSheetService.selectStudentPage(PageUtil.getPage(search), search, null);
-            idMsMap.putAll(records.getRecords().stream()
-                .collect(Collectors.toMap(MusicSheet::getId, Function.identity())));
+            return HttpResponseResult.succeed(records.getRecords().stream().map(o -> {
+                TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
+                tenantAlbumSheet.setId(o.getId().toString());
+                tenantAlbumSheet.setMusicSheetName(o.getMusicSheetName());
+                tenantAlbumSheet.setMusicTag(o.getMusicTag());
+                tenantAlbumSheet.setComposer(o.getComposer());
+                tenantAlbumSheet.setMusicSubject(o.getMusicSubject());
+                tenantAlbumSheet.setMusicSubjectName(o.getSubjectNames());
+                tenantAlbumSheet.setMusicTagName(o.getMusicTagNames());
+                return tenantAlbumSheet;
+            }).collect(Collectors.toList()));
         }
-        List<TenantAlbumWrapper.MusicSheetData> musicSheetData = vo.getMusicSheetData();
-        groupByType.forEach((key, value) -> {
-            value.sort(Comparator.comparing(TenantAlbumMusic::getSortNumber));
-            TenantAlbumWrapper.MusicSheetData sheetData = new TenantAlbumWrapper.MusicSheetData();
-            sheetData.setSubjectType(key);
-            List<TenantAlbumWrapper.TenantAlbumSheet> tenantAlbumSheets = value.stream().map(next -> {
 
-                TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
-                BeanUtils.copyProperties(next, tenantAlbumSheet);
-                Long musicSheetId = tenantAlbumSheet.getMusicSheetId();
-                switch (key) {
-                    case COURSEWARE:
-                        CbsLessonCoursewareWrapper.Entity entity = coursewareDtoMap.get(musicSheetId);
-                        if (entity != null) {
-                            tenantAlbumSheet.setMusicSheetName(entity.getName());
-                            tenantAlbumSheet.setTitleImg(entity.getCoverImg());
-                            tenantAlbumSheet.setMusicSubject(entity.getCourseTypeCode());
-                            tenantAlbumSheet.setMusicSubjectName(ECourseType.valueOf(entity.getCourseTypeCode()).getName());
-                        } else {
-                            return null;
-                        }
-                        break;
-                    case MUSIC:
-                    case SUBJECT:
-                    case ENSEMBLE:
-                    {
-                        MusicSheetVo musicSheet = idMsMap.get(musicSheetId);
-                        if (musicSheet == null) {
-                            return null;
-                        }
-                        tenantAlbumSheet.setMusicSheetName(musicSheet.getMusicSheetName());
-                        tenantAlbumSheet.setMusicTag(musicSheet.getMusicTag());
-                        tenantAlbumSheet.setComposer(musicSheet.getComposer());
-                        tenantAlbumSheet.setMusicSubject(musicSheet.getMusicSubject());
-                        tenantAlbumSheet.setMusicSubjectName(musicSheet.getSubjectNames());
-                        tenantAlbumSheet.setMusicTagName(musicSheet.getMusicTagNames());
-/*
-                        //设置对应标签名称
-                        String musicTag = tenantAlbumSheet.getMusicTag();
-                        if (StringUtils.isNotBlank(musicTag)){
-                            String[] split = musicTag.split(",");
-                            List<String> tagNames = Arrays.stream(split).map(Long::parseLong).map(musicTagMap::get)
-                                .filter(Objects::nonNull).map(MusicTag::getName).collect(Collectors.toList());
-                            tenantAlbumSheet.setMusicTagName(String.join(",", tagNames));
-                        }
-                        if (StringUtils.isNotBlank(tenantAlbumSheet.getMusicSubject())){
-                            //设置对应声部名称
-                            String subjectName = Arrays.stream(tenantAlbumSheet.getMusicSubject().split(","))
-                                .map(Integer::parseInt).map(o -> {
-
-                                Subject subject = subjectMap.get(o);
-                                if (subject != null) {
-                                    return subject.getName();
-                                }
-                                return null;
-                            }).filter(Objects::nonNull).collect(Collectors.joining(","));
-                            tenantAlbumSheet.setMusicSubjectName(subjectName);
-                        }*/
-
-                    }
-                    break;
-                    default:
-                        break;
-                }
 
-                return tenantAlbumSheet;
-            }).filter(Objects::nonNull).collect(Collectors.toList());
+    }
 
-            sheetData.setTenantAlbumSheetList(tenantAlbumSheets);
-            musicSheetData.add(sheetData);
-            vo.setMusicSheetData(musicSheetData);
-        });
+    /**
+     * 查询详情
+     *
+     * @param id 详情ID
+     * @return TenantAlbum
+     */
+    @PostMapping("/detail")
+    @ApiOperation(value = "查询详情", notes = "detail")
+    @PreAuthorize("@pcs.hasPermissions('tenantAlbum/detail')")
+    public HttpResponseResult<TenantAlbumWrapper.TenantAlbum> detail(@RequestParam("id") Long id) {
+        TenantAlbum tenantAlbum = tenantAlbumService.detail(id);
+        if (tenantAlbum == null) {
+            throw new BizException("专辑信息不存在");
+        }
+
+        TenantAlbumWrapper.TenantAlbum vo = JSON.parseObject(JSON.toJSONString(tenantAlbum),
+                TenantAlbumWrapper.TenantAlbum.class);
+
+        //查关联表
+        TenantAlbumRef one = tenantAlbumRefService.lambdaQuery().eq(TenantAlbumRef::getTenantAlbumId, id)
+                .last("limit 1").one();
+        vo.setTenantId(one.getTenantId().toString());
+        //查询曲目表
+
+        TenantInfo tenantInfo = tenantInfoService.getById(one.getTenantId());
+        vo.setTenantName(tenantInfo.getName());
 
         return HttpResponseResult.succeed(vo);
     }

+ 5 - 6
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantMusicSheetApplicationExtendController.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.dayaedu.cbs.openfeign.properties.OpenFeignClientConfigProperties;
 import com.dayaedu.cbs.openfeign.service.CbsMusicSheetService;
-import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetApplicationExtendClientWrapper;
-import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetCategoryWrapper;
-import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper;
-import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.music.*;
 import com.microsvc.toolkit.common.response.paging.PageInfo;
 import com.microsvc.toolkit.common.response.template.R;
 import com.microsvc.toolkit.common.webportal.exception.BizException;
@@ -129,9 +126,11 @@ public class TenantMusicSheetApplicationExtendController {
 
     @ApiOperation(value = "应用分类列表")
     @PostMapping("/categoryList")
-    public R<List<CbsMusicSheetCategoryWrapper.MusicSheetCategory>> categoryList() {
+    public R<List<MusicSheetCategoriesWrapper.MusicSheetCategories>> categoryList() {
 
-        return R.from(cbsMusicSheetService.categoryList(new CbsMusicSheetCategoryWrapper.MusicSheetCategoryQuery()));
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+
+        return R.from(musicFeignClientService.queryTreeByAppId(Long.parseLong(cbsTenantAppId)).feignData());
 
     }
 

+ 16 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/constant/SysConfigConstant.java

@@ -461,4 +461,20 @@ public interface SysConfigConstant {
      */
     String CBS_TENANT_APP_ID = "cbs_tenant_app_id";
 
+    /**
+     * 机构专辑声部云练分类对应
+     */
+    String TENANT_ALBUM_SUBJECT_TYPE_CATEGORY  = "tenant_album_subject_type_category";
+
+
+    /**
+     * 机构专辑合奏云练分类对应
+     */
+    String TENANT_ALBUM_ENSEMBLE_TYPE_CATEGORY = "tenant_album_ensemble_type_category";
+
+
+    /**
+     * 机构专辑独奏云练分类对应
+     */
+    String TENANT_ALBUM_MUSIC_TYPE_CATEGORY = "tenant_album_music_type_category";
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicAlbumMapper.xml

@@ -221,7 +221,7 @@
             , (
                 select count(1) as num from album_music_relate amr
                 join music_sheet ms on amr.music_sheet_id_ = ms.id_
-                where ms.del_flag_ = 0 and ms.state_ = 1 and ms.audit_status_ = 'PASS'
+                where ms.del_flag_ = 0 and ms.state_ = 1 and ms.audit_status_ = 'PASS' and find_in_set('PLATFORM',ms.provider_type_)
                 and amr.album_id_ = t.id_
             ) as musicSheetCount
             ,(

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml

@@ -317,7 +317,7 @@
         left join album_music_relate amr on t.id_ = amr.music_sheet_id_
         left join sys_user su on t.create_by_ = su.id_
         <where>
-            t.cbs_music_sheet_id_ IS NOT NULL
+            t.cbs_music_sheet_id_ IS NOT NULL and find_in_set('PLATFORM',t.provider_type_)
             <if test="param.composer != null">
                 AND t.composer_ LIKE '%${param.composer}%'
             </if>