liujc 2 달 전
부모
커밋
ba9f986e5c
37개의 변경된 파일1313개의 추가작업 그리고 256개의 파일을 삭제
  1. 19 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/MusicSheetController.java
  2. 12 4
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/SysConfigController.java
  3. 102 55
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantAlbumController.java
  4. 170 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantMusicSheetApplicationExtendController.java
  5. 36 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/MusicSheetController.java
  6. 15 10
      cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/MusicSheetController.java
  7. 23 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/constant/SysConfigConstant.java
  8. 15 3
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/MusicSheetDao.java
  9. 4 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/TeacherMusicSheetAuditReq.java
  10. 21 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/MusicSheetSearch.java
  11. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/StudentMusicSheetSearch.java
  12. 45 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/MusicSheet.java
  13. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/SysMusicCompareRecord.java
  14. 3 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantAlbumMusicMapper.java
  15. 7 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/MusicSheetService.java
  16. 82 45
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CbsMusicSheetServiceImpl.java
  17. 7 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetAuthRecordServiceImpl.java
  18. 241 52
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java
  19. 12 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherTotalServiceImpl.java
  20. 45 33
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumMusicServiceImpl.java
  21. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetDetailVo.java
  22. 3 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetVo.java
  23. 10 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetVoResult.java
  24. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherMusicSheetListVo.java
  25. 72 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/MusicSheetWrapper.java
  26. 11 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumMusicWrapper.java
  27. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumWrapper.java
  28. 4 4
      cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityEvaluationMapper.xml
  29. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityRegistrationMapper.xml
  30. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseCoursewareMapper.xml
  31. 5 4
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicAlbumMapper.xml
  32. 266 18
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml
  33. 18 2
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetPracticeRecordMapper.xml
  34. 5 5
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicTagMapper.xml
  35. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/SubjectMapper.xml
  36. 34 10
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMusicMapper.xml
  37. 1 1
      pom.xml

+ 19 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/MusicSheetController.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.admin.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.microsvc.toolkit.common.response.template.R;
 import com.yonge.cooleshow.biz.dal.dto.ReasonDto;
 import com.yonge.cooleshow.biz.dal.dto.search.MusicSheetSearch;
@@ -8,11 +9,15 @@ import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetOrderSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.TeacherMusicSheetSearch;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.OrderTypeEnum;
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
+import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 import com.yonge.cooleshow.biz.dal.service.SysUserService;
 import com.yonge.cooleshow.biz.dal.service.cbs.CbsMusicScoreService;
 import com.yonge.cooleshow.biz.dal.vo.*;
 import com.yonge.cooleshow.biz.dal.wrapper.MusicSheetApplicationExtendWrapper;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
@@ -22,11 +27,13 @@ import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
 @RestController
@@ -40,6 +47,12 @@ public class MusicSheetController extends BaseController {
 	@Resource
 	private CbsMusicScoreService cbsMusicScoreService;
 
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    @Autowired
+    private MusicFeignClientService musicFeignClientService;
+
     @GetMapping("/detail/{id}")
     @ApiOperation(value = "详情", notes = "传入id")
     @PreAuthorize("@pcs.hasPermissions('music/sheet/detail')")
@@ -51,6 +64,12 @@ public class MusicSheetController extends BaseController {
     @PostMapping(value="/list", consumes="application/json", produces="application/json")
     @PreAuthorize("@pcs.hasPermissions('music/sheet/list')")
     public HttpResponseResult<PageInfo<MusicSheetVoResult>> list(@RequestBody MusicSheetSearch query) {
+        if (query.getProviderType() == SourceTypeEnum.TENANT && query.getMusicCategoryId() !=null) {
+
+            List<Integer> integers = musicFeignClientService.getAllCategoryIdList(String.valueOf(query.getMusicCategoryId())).feignData();
+            integers.add(query.getMusicCategoryId());
+            query.setTenantCategoryIds(integers);
+        }
         return succeed(PageUtil.pageInfo(musicSheetService.selectCbsPage(PageUtil.getPage(query), query)));
     }
 

+ 12 - 4
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/SysConfigController.java

@@ -17,10 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /** 
  * 系统配置控制层
@@ -106,6 +103,17 @@ public class SysConfigController extends BaseController {
 		return succeed(sysConfigService.findConfigValue(paramName));
 	}
 
+
+    @ApiOperation(value = "查询参数")
+    @GetMapping(value = "queryByParamNameList")
+    public Object queryByParamNameList(String paramNames) {
+        if(StringUtils.isBlank(paramNames)){
+            return failed("参数不能为空");
+        }
+        List<String> paramNameList = Arrays.asList(paramNames.split(","));
+        return succeed(sysConfigService.findByParamName(paramNameList));
+    }
+
 	@ApiOperation(value = "url短链接")
 	@PostMapping("shortURL")
 	public HttpResponseResult<String> shortURL(String orginURL) {

+ 102 - 55
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantAlbumController.java

@@ -4,15 +4,20 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.dayaedu.cbs.common.enums.school.ECourseType;
 import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.music.MusicSheetCategoriesWrapper;
 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;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.base.page.PageInfo;
@@ -56,14 +61,21 @@ public class TenantAlbumController {
     @Autowired
     private MusicSheetService musicSheetService;
 
+
     @Autowired
-    private SubjectService subjectService;
+    private CoursewareFeignService coursewareFeignService;
 
     @Autowired
-    private MusicTagService musicTagService;
+    private MusicFeignClientService musicFeignClientService;
+    @Autowired
+    private SysConfigService sysConfigService;
+
 
     @Autowired
-    private CoursewareFeignService coursewareFeignService;
+    private SubjectService subjectService;
+
+    @Autowired
+    private MusicTagService musicTagService;
 
     /**
      * 查询分页
@@ -85,33 +97,23 @@ public class TenantAlbumController {
      * @param id 详情ID
      * @return TenantAlbum
      */
-    @PostMapping("/detail")
+    @GetMapping("/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();
+            .eq(TenantAlbumMusic::getTenantAlbumId, id)
+            .eq(TenantAlbumMusic::getSubjectType, SubjectTypeEnum.valueOf(subjectType))
+            .eq(TenantAlbumMusic::getDelFlag, false)
+            .list();
 
         Map<SubjectTypeEnum, List<TenantAlbumMusic>> groupByType =
-                tenantAlbumMusics.stream().collect(Collectors.groupingBy(TenantAlbumMusic::getSubjectType));
+            tenantAlbumMusics.stream().collect(Collectors.groupingBy(TenantAlbumMusic::getSubjectType));
 
 
         List<Long> musicSheetIdlist = tenantAlbumMusics.stream()
@@ -120,8 +122,8 @@ public class TenantAlbumController {
             .collect(Collectors.toList());
         // 过滤出课件
         List<Long> coursewareList = tenantAlbumMusics.stream()
-                .filter(o -> o.getSubjectType() == SubjectTypeEnum.COURSEWARE)
-                .map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
+            .filter(o -> o.getSubjectType() == SubjectTypeEnum.COURSEWARE)
+            .map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
         Map<Long,CbsLessonCoursewareWrapper.Entity> coursewareDtoMap = new HashMap<>();
 
         if (CollectionUtils.isNotEmpty(coursewareList)) {
@@ -131,26 +133,24 @@ public class TenantAlbumController {
         }
 
         Map<Long, MusicSheetVo> idMsMap = new HashMap<>();
-        Map<Integer,Subject> subjectMap = subjectService.getAllMap();
-        Map<Long, MusicTag> musicTagMap = musicTagService.getAllMap();
         if (CollectionUtils.isNotEmpty(musicSheetIdlist)) {
             StudentMusicSheetSearch search = new StudentMusicSheetSearch();
             search.setMusicSheetIdlist(musicSheetIdlist);
             search.setPage(1);
             search.setRows(9999);
+            search.setProviderType(SourceTypeEnum.TENANT);
             IPage<MusicSheetVo> records = musicSheetService.selectStudentPage(PageUtil.getPage(search), search, null);
             idMsMap.putAll(records.getRecords().stream()
                 .collect(Collectors.toMap(MusicSheet::getId, Function.identity())));
         }
-        List<TenantAlbumWrapper.MusicSheetData> musicSheetData = vo.getMusicSheetData();
+        List<TenantAlbumWrapper.TenantAlbumSheet> tenantAlbumSheets = new ArrayList<>();
         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 -> {
+            tenantAlbumSheets.addAll(value.stream().map(next -> {
 
-                TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet = new TenantAlbumWrapper.TenantAlbumSheet();
-                BeanUtils.copyProperties(next, tenantAlbumSheet);
+                TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet =JSON.parseObject(JSON.toJSONString(next), TenantAlbumWrapper.TenantAlbumSheet.class);
                 Long musicSheetId = tenantAlbumSheet.getMusicSheetId();
                 switch (key) {
                     case COURSEWARE:
@@ -178,28 +178,6 @@ public class TenantAlbumController {
                         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;
@@ -208,12 +186,81 @@ public class TenantAlbumController {
                 }
 
                 return tenantAlbumSheet;
-            }).filter(Objects::nonNull).collect(Collectors.toList());
+            }).filter(Objects::nonNull).collect(Collectors.toList()));
 
-            sheetData.setTenantAlbumSheetList(tenantAlbumSheets);
-            musicSheetData.add(sheetData);
-            vo.setMusicSheetData(musicSheetData);
         });
+        return HttpResponseResult.succeed(tenantAlbumSheets);
+
+    }
+
+    private String updateCategory(List<MusicSheetCategoriesWrapper.MusicSheetCategories> musicSheetCategories,
+                                Long categoryId, String tenantCategoryId,TenantAlbumWrapper.TenantAlbumSheet tenantAlbumSheet) {
+
+        if (StringUtils.isBlank(tenantCategoryId)) {
+            return "";
+        }
+        for (MusicSheetCategoriesWrapper.MusicSheetCategories o : musicSheetCategories) {
+            if (o.getId().equals(Long.parseLong(tenantCategoryId))) {
+                return o.getName();
+            }
+            if (CollectionUtils.isNotEmpty(o.getMusicSheetCategoriesList())) {
+                String s = updateCategory( o.getMusicSheetCategoriesList(), categoryId, tenantCategoryId,tenantAlbumSheet);
+                if (!tenantAlbumSheet.getLoop()) {
+                    return s;
+                }
+                if (o.getId().equals(categoryId) && StringUtils.isNotBlank(s)) {
+                    tenantAlbumSheet.setErrFlag(false);
+//                    tenantAlbumSheet.setLoop(false);
+//                    return s;
+                }
+                if (StringUtils.isNotBlank(s)) {
+                    return o.getName() + "/" + s;
+                }
+            }
+        }
+        return "";
+    }
+
+    private Long getCategoryId(String subjectType) {
+        if (StringUtils.isBlank(subjectType)) {
+            return null;
+        }
+        if (SubjectTypeEnum.SUBJECT.name().equals(subjectType)) {
+            return Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.TENANT_ALBUM_SUBJECT_TYPE_CATEGORY));
+        } else if (SubjectTypeEnum.ENSEMBLE.name().equals(subjectType)) {
+            return Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.TENANT_ALBUM_ENSEMBLE_TYPE_CATEGORY));
+        } if (SubjectTypeEnum.MUSIC.name().equals(subjectType)) {
+            return Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.TENANT_ALBUM_MUSIC_TYPE_CATEGORY));
+        }
+        return null;
+    }
+
+    /**
+     * 查询详情
+     *
+     * @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);
     }

+ 170 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantMusicSheetApplicationExtendController.java

@@ -0,0 +1,170 @@
+package com.yonge.cooleshow.admin.controller;
+
+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.*;
+import com.microsvc.toolkit.common.response.paging.PageInfo;
+import com.microsvc.toolkit.common.response.template.R;
+import com.microsvc.toolkit.common.webportal.exception.BizException;
+import com.microsvc.toolkit.config.jwt.utils.JwtUserInfo;
+import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
+import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
+import com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("${app-config.url.admin:}/tenantMusicSheetApplicationExtend")
+@Api(tags = "曲目应用拓展表")
+public class TenantMusicSheetApplicationExtendController {
+
+    @Autowired
+    private MusicFeignClientService musicFeignClientService;
+
+    @Autowired
+    private MusicSheetService musicSheetService;
+
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/pageByApplication')")
+    @PostMapping({"/pageByApplication"})
+    public R<PageInfo<MusicSheetWrapper.MusicSheetApplication>> musicSheetPageByApplication(@RequestBody MusicSheetWrapper.MusicSheetApplicationQuery var1){
+
+        return R.from(musicSheetService.tenantPage(var1));
+    }
+
+
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/page')")
+    @PostMapping({"/page"})
+    public R<PageInfo<MusicSheetWrapper.CbsMusicSheet>> musicSheetPage(@RequestBody CbsMusicSheetWrapper.MusicSheetQuery var1){
+
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+        // 更新数据
+        var1.setAddAppId(Long.parseLong(cbsTenantAppId));
+        try {
+            PageInfo<CbsMusicSheetWrapper.MusicSheet> musicSheetPageInfo = this.musicFeignClientService.musicSheetPage(var1).feignData();
+            PageInfo<MusicSheetWrapper.CbsMusicSheet> convert = musicSheetPageInfo.convert(o -> JSONObject.parseObject(JSONObject.toJSONString(o), MusicSheetWrapper.CbsMusicSheet.class));
+
+            return R.from(convert);
+        }catch (Exception e) {
+            log.error("查询曲目应用拓展表异常", e);
+            if(e instanceof BizException) {
+                throw e;
+            }
+            throw BizException.from("内容平台服务异常");
+        }
+    }
+
+    @ApiOperation(value = "修改应用扩展信息", notes = "曲目应用拓展表- 传入 MusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend")
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/update')")
+	@PostMapping("/update")
+	public R<JSONObject> update( @RequestBody CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend addMusicSheetApplicationExtend) {
+
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+        // 更新数据
+        addMusicSheetApplicationExtend.setApplicationId(Long.parseLong(cbsTenantAppId));
+        try {
+
+            musicFeignClientService.musicSheetApplicationExtendUpdate(addMusicSheetApplicationExtend).feignData();
+        }catch (Exception e) {
+            log.error("修改应用扩展信息异常", e);
+            if(e instanceof BizException) {
+                throw e;
+            }
+            throw BizException.from("内容平台服务异常");
+        }
+
+        return R.defaultR();
+	}
+
+
+    @ApiOperation(value = "启/停用", notes = "曲目应用拓展表- 传入 MusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend")
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/status')")
+    @PostMapping("/status")
+    public R<JSONObject> status(@Validated @RequestBody CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus status) {
+
+        // 更新数据
+        try {
+
+            musicFeignClientService.musicSheetApplicationExtendStatus(status).feignData();
+        }catch (Exception e) {
+            log.error("启/停用异常", e);
+            if(e instanceof BizException) {
+                throw e;
+            }
+            throw BizException.from("内容平台服务异常");
+        }
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "批量保存扩展信息")
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/saveBatch', {'BACKEND'})")
+    @PostMapping("/saveBatch")
+    public R<JSONObject> saveBatch( @RequestBody List<CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend> list) {
+
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+        if (CollectionUtils.isEmpty(list)) {
+            throw BizException.from("参数错误");
+        }
+        for (CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend addMusicSheetApplicationExtend : list) {
+            addMusicSheetApplicationExtend.setApplicationId(Long.parseLong(cbsTenantAppId));
+        }
+        // 更新数据
+        try {
+
+            musicFeignClientService.musicSheetApplicationExtendSaveBatch(list).feignData();
+        }catch (Exception e) {
+            log.error("批量保存扩展信息异常", e);
+            if(e instanceof BizException) {
+                throw e;
+            }
+            throw BizException.from("内容平台服务异常");
+        }
+
+        return R.defaultR();
+    }
+
+
+    @ApiOperation(value = "应用分类列表")
+    @PostMapping("/categoryList")
+    public R<List<MusicSheetCategoriesWrapper.MusicSheetCategories>> categoryList(String type) {
+
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+
+        return R.from(musicFeignClientService.queryTreeByAppId(Long.parseLong(cbsTenantAppId)).feignData());
+
+    }
+
+    @ApiOperation(value = "删除应用扩展信息", notes = "曲目应用拓展表- 传入 MusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend")
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/del')")
+    @PostMapping("/del/{id}")
+    public R<JSONObject> update(@PathVariable Long id) {
+
+        // 更新数据
+        return R.from(musicFeignClientService.musicSheetApplicationExtendDel(id).feignData());
+
+    }
+
+}

+ 36 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/MusicSheetController.java

@@ -267,6 +267,11 @@ public class MusicSheetController extends BaseController {
         }
         StudentMusicSheetSearch search = new StudentMusicSheetSearch();
         search.setStudentId(sysUser.getId());
+        // 查询学生时机构还是平台
+        Student student = studentService.getById(search.getStudentId());
+        if (student != null && student.getTenantId() != null && student.getTenantId()>0) {
+            search.setProviderType(SourceTypeEnum.TENANT);
+        }
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.favoriteMusic(PageUtil.getPage(query),search, ClientEnum.STUDENT);
@@ -288,10 +293,31 @@ public class MusicSheetController extends BaseController {
         search.setStudentId(sysUser.getId());
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
+        search.setClientType(ClientEnum.STUDENT);
+        // 查询学生时机构还是平台
+        Student student = studentService.getById(search.getStudentId());
+        if (student != null && student.getTenantId() != null && student.getTenantId()>0) {
+            search.setProviderType(SourceTypeEnum.TENANT);
+        }
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.practiceMusic(PageUtil.getPage(query),search);
         return succeed(PageUtil.pageInfo(sheetVoIPage));
     }
 
+    /**
+     * 最近练习
+     */
+    @GetMapping("/practice/del/{id}")
+    @ApiOperation(value = "删除最近练习记录")
+    public HttpResponseResult<Boolean> delPracticeMusic(@PathVariable Long id) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null  || sysUser.getId() == null) {
+            return failed("用户信息获取失败");
+        }
+
+        musicSheetService.delPractice(id,sysUser.getId(),ClientEnum.STUDENT);
+        return succeed();
+    }
+
 
 
     /**
@@ -304,8 +330,17 @@ public class MusicSheetController extends BaseController {
         if (userId == null) {
             return failed("用户信息不存在");
         }
+        Student student = studentService.getById(userId);
+        if (student == null) {
+            return failed("用户信息不存在");
+        }
         StudentMusicSheetSearch search = new StudentMusicSheetSearch();
+
+        if (student.getTenantId() !=null && student.getTenantId()>0) {
+            search.setProviderType(SourceTypeEnum.TENANT);
+        }
         search.setStudentId(userId);
+        search.setClientType(ClientEnum.STUDENT);
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
         search.setRows(3);
@@ -451,6 +486,7 @@ public class MusicSheetController extends BaseController {
             throw new BizException("用户信息获取失败");
         }
         queryInfo.setSubjectId(Integer.parseInt(student.getSubjectId()));
+        queryInfo.setProviderType(SourceTypeEnum.TENANT);
         return succeed(musicSheetService.searchTenant(queryInfo));
     }
 

+ 15 - 10
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/MusicSheetController.java

@@ -1,17 +1,13 @@
 package com.yonge.cooleshow.teacher.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.dayaedu.cbs.common.enums.music.EMusicSourceType;
-import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
-import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.AppMusicSheetVo;
 import com.yonge.cooleshow.biz.dal.dto.MusicSheetRenderDto;
-import com.yonge.cooleshow.biz.dal.dto.ReasonDto;
 import com.yonge.cooleshow.biz.dal.dto.search.MusicSheetRelatedQueryInfo;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
 import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
-import com.yonge.cooleshow.biz.dal.entity.MusicSheetAuthRecord;
+import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
@@ -19,7 +15,6 @@ import com.yonge.cooleshow.biz.dal.enums.MusicSortType;
 import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.album.PurchaseRecordTypeEnum;
 import com.yonge.cooleshow.biz.dal.service.*;
-import com.yonge.cooleshow.biz.dal.service.cbs.CbsMusicScoreService;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetShareVo;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
@@ -35,19 +30,15 @@ import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
 import java.util.Optional;
-import java.util.stream.Collectors;
 
 /**
  * 曲谱表 web 控制层
@@ -70,6 +61,9 @@ public class MusicSheetController extends BaseController {
     @Resource
     private TeacherService teacherService;
 
+    @Autowired
+    private StudentService studentService;
+
     /**
      * 查询单条
      */
@@ -233,9 +227,14 @@ public class MusicSheetController extends BaseController {
     public HttpResponseResult<PageInfo<MusicSheetVo>> favoriteMusic(QueryInfo query) {
         SysUser sysUser = sysUserService.getUser();
         StudentMusicSheetSearch search = new StudentMusicSheetSearch();
+        Teacher teacher = teacherService.getById(sysUser.getId());
+        if (teacher.getTenantId() !=null && teacher.getTenantId() >0) {
+            search.setTenantId(teacher.getTenantId());
+        }
         search.setStudentId(sysUser.getId());
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
+        search.setProviderType(null);
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.favoriteMusic(PageUtil.getPage(query),search, ClientEnum.TEACHER);
         return succeed(PageUtil.pageInfo(sheetVoIPage));
     }
@@ -323,9 +322,15 @@ public class MusicSheetController extends BaseController {
         }
         StudentMusicSheetSearch search = new StudentMusicSheetSearch();
         search.setStudentId(userId);
+        search.setClientType(ClientEnum.STUDENT);
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
         search.setRows(3);
+        // 查询学生时机构还是平台
+        Student student = studentService.getById(search.getStudentId());
+        if (student != null && student.getTenantId() != null && student.getTenantId()>0) {
+            search.setProviderType(SourceTypeEnum.TENANT);
+        }
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.practiceMusic(PageUtil.getPage(search),search);
         return succeed(PageUtil.pageInfo(sheetVoIPage));
     }

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

@@ -455,4 +455,27 @@ public interface SysConfigConstant {
      * 默认曲目所属人
      */
     String DEFAULT_MUSIC_USER_ID = "default_music_user_id";
+
+    /**
+     * 内容平台机构应用ID
+     */
+    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";
+    String COURSE_SUBJECT_MAP = "course_subject_map";
 }

+ 15 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/MusicSheetDao.java

@@ -196,11 +196,11 @@ public interface MusicSheetDao extends BaseMapper<MusicSheet> {
 
     void updateBatchByCbsId(@Param("vos") List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> updateMusicScore);
 
-    void batchInsert(@Param("vos") List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> addMusicSheet);
+//    void batchInsert(@Param("vos") List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> addMusicSheet);
 
-    void batchEnable(@Param("ids") String cbsMusicSheetIds, @Param("status") Boolean status);
+    void batchEnable(@Param("ids") String cbsMusicSheetIds, @Param("status") Boolean status, @Param("tenantFlag") boolean tenantFlag);
 
-    void batchDel(@Param("ids") String cbsMusicSheetIds);
+    void batchDel(@Param("ids") String cbsMusicSheetIds, @Param("tenantFlag") boolean tenantFlag);
 
     IPage<CbsMusicSheetExtendWrapper.MusicSheetExtend> personOwnerList(@Param("page") IPage<CbsMusicSheetExtendWrapper.MusicSheetExtend> page,
                                                                  @Param("param") CbsMusicSheetExtendWrapper.MusicSheetExtendQuery query);
@@ -215,4 +215,16 @@ public interface MusicSheetDao extends BaseMapper<MusicSheet> {
     IPage<MusicSheet> selectSyncPage(Page<Object> objectPage);
 
     IPage<MusicSheetVo> queryTenantRelatedList(@Param("page") IPage<Object> page, @Param("queryInfo") MusicSheetRelatedQueryInfo queryInfo);
+
+    void updateTenantByCbsId(@Param("item") CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend);
+
+    void updatePlatformByCbsId(@Param("item") CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend);
+
+    void tenantInsert(@Param("item") CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend);
+
+    void platformInsert(@Param("item") CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend);
+
+    void updateState(@Param("ids") String ids);
+
+    void delPractice(@Param("musicSheetId") Long musicSheetId, @Param("userId") Long userId, @Param("clientEnum") ClientEnum clientEnum);
 }

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/TeacherMusicSheetAuditReq.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.biz.dal.dto.req;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.yonge.cooleshow.biz.dal.enums.AccompanimentTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.AudioTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
@@ -77,4 +78,7 @@ public class TeacherMusicSheetAuditReq {
 
     @ApiModelProperty(value = "音频文件存储路径")
     private String audioFileUrl;  //音频文件存储路径
+
+    @ApiModelProperty("谱面类型 默认谱面(STAVE: 五线谱; JIAN: 固定调; FIRST: 首调)")
+    private String scoreType;
 }

+ 21 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/MusicSheetSearch.java

@@ -1,12 +1,12 @@
 package com.yonge.cooleshow.biz.dal.dto.search;
 
-import com.dayaedu.cbs.common.enums.music.EDefaultScoreType;
 import com.yonge.cooleshow.biz.dal.enums.*;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
 import com.yonge.toolset.base.page.QueryInfo;
 import com.yonge.toolset.base.util.StringUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 
@@ -20,9 +20,19 @@ import java.util.stream.Collectors;
  * @author: liujunchi
  * @date: 2022-03-30
  */
+@Data
 @ApiModel(value = "MusicSheetSearch对象", description = "曲目表查询对象")
 public class MusicSheetSearch  extends QueryInfo{
 
+
+
+    @ApiModelProperty(value = "客户端状态曲目状态(0:停用,1:启用)")
+    private Boolean clientState;
+
+    @ApiModelProperty(value = "内容平台状态曲目状态(0:停用,1:启用)")
+    private Boolean  platformState;
+
+
     @ApiModelProperty(value = "曲目音频类型 MP3:mp3, MIDI:midi,")
     private AudioTypeEnum audioType;
 
@@ -46,7 +56,7 @@ public class MusicSheetSearch  extends QueryInfo{
 
 
     @ApiModelProperty(value = "提供方 TENANT 机构 PLATFORM 平台")
-    private SourceTypeEnum providerType;
+    private SourceTypeEnum providerType = SourceTypeEnum.PLATFORM;
 
 
     @ApiModelProperty("曲目状态(0:停用,1:启用))")
@@ -113,6 +123,15 @@ public class MusicSheetSearch  extends QueryInfo{
     @ApiModelProperty(value = "必须要匹配声部ID")
     private List<Long> mustMatchSubjectIds;
 
+    @ApiModelProperty("机构专辑分类")
+    private String subjectType;
+
+    @ApiModelProperty("机构分类id")
+    private Integer musicCategoryId;
+
+    @ApiModelProperty("机构专辑分类")
+    private List<Integer> tenantCategoryIds;
+
     public List<Long> getExcludeMusicIds() {
         return excludeMusicIds;
     }

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/StudentMusicSheetSearch.java

@@ -5,8 +5,6 @@ import com.yonge.cooleshow.biz.dal.enums.album.PurchaseRecordTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import java.util.List;
-
 /**
  * Description 学生查询乐谱
  *
@@ -45,6 +43,8 @@ public class StudentMusicSheetSearch  extends MusicSheetSearch{
     // 客户端类型
     private ClientEnum clientType;
 
+    private Long tenantId;
+
 
     public ClientEnum getUserType() {
         return userType;

+ 45 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/MusicSheet.java

@@ -69,7 +69,7 @@ public class MusicSheet implements Serializable {
 
     @TableField("provider_type_")
     @ApiModelProperty(value = "提供方 TENANT 机构 PLATFORM 平台")
-    private SourceTypeEnum providerType;
+    private String providerType;
 
     @NotBlank(message = "艺术家不能为空!")
     @Size(max = 32, message = "艺术家长度不能超过32位!")
@@ -138,6 +138,16 @@ public class MusicSheet implements Serializable {
 	@ApiModelProperty(value = "曲目状态(0:停用,1:启用)")
 	private YesOrNoEnum state;
 
+
+    @TableField("client_state_")
+    @ApiModelProperty(value = "客户端状态曲目状态(0:停用,1:启用)")
+    private Boolean clientState;
+
+
+    @TableField("platform_state_")
+    @ApiModelProperty(value = "内容平台状态曲目状态(0:停用,1:启用)")
+    private Boolean  platformState;
+
 	@TableField("reason_")
 	@ApiModelProperty(value = "曲目停用原因")
 	private String reason;
@@ -272,6 +282,40 @@ public class MusicSheet implements Serializable {
 	@TableField("is_all_subject_")
 	private Boolean isAllSubject;
 
+
+    @TableField("tenant_sort_number_")
+    @ApiModelProperty(value = "排序号")
+    private Integer tenantSortNumber;  //排序号
+
+
+    @TableField("tenant_state_")
+    @ApiModelProperty(value = "曲目状态(0:停用,1:启用)")
+    private Boolean tenantState;
+
+
+    @TableField("tenant_notation_")
+    @ApiModelProperty("是否可以转简谱(0:否,1:是)")
+    private Boolean tenantNotation;
+
+
+    @TableField("tenant_category_id_")
+    @ApiModelProperty("分类")
+    private String tenantCategoryId;
+
+
+    @ApiModelProperty("谱面类型")
+    @TableField("tenant_score_type_")
+    private String tenantScoreType;
+
+    @TableField("tenant_del_flag_")
+    @ApiModelProperty(value = "假删除标识 0:未删除 1:已删除")
+    private Boolean tenantDelFlag;
+
+
+    @TableField("upload_time_")
+    @ApiModelProperty(value = "机构曲目同步上传时间")
+    private Date uploadTime;  //上传时间
+
 	public ChargeTypeEnum getChargeType() {
 		if (Objects.isNull(this.chargeType) && StringUtils.isNotEmpty(getPaymentType())) {
 

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/SysMusicCompareRecord.java

@@ -90,6 +90,8 @@ public class SysMusicCompareRecord extends BaseEntity {
 
 	private Long tenantId = -1L;
 
+    private Boolean hiddenFlag;
+
 	public SysMusicCompareRecord(FeatureType feature) {
 		this.feature = feature;
 	}

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantAlbumMusicMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
@@ -39,4 +40,6 @@ public interface TenantAlbumMusicMapper extends BaseMapper<TenantAlbumMusic> {
     List<TenantAlbumMusic> getByAlbumAndEnable(@Param("tenantAlbumIds") List<Long> tenantAlbumIds);
 
     List<TenantAlbumMusic> getList(@Param("param") TenantAlbumMusicWrapper.TenantAlbumMusicSelect query, @Param("albumIds") List<Long> albumIds);
+
+    List<Long> getTenantAlbumMusicIdsByIds(@Param("tenantAlbumIds") List<Long> tenantAlbumIds, @Param("subjectTypes") List<SubjectTypeEnum> subjectTypes);
 }

+ 7 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/MusicSheetService.java

@@ -10,9 +10,9 @@ import com.yonge.cooleshow.biz.dal.dto.ReasonDto;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
 import com.yonge.cooleshow.biz.dal.dto.search.*;
 import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
-import com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.OrderTypeEnum;
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
 import com.yonge.cooleshow.biz.dal.vo.*;
 import com.yonge.cooleshow.biz.dal.vo.res.OrderCreateRes;
 import com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper;
@@ -413,9 +413,15 @@ public interface MusicSheetService extends IService<MusicSheet> {
 
     CbsMusicSheetWrapper.MusicSheetApplicationQuery getMusicSheetApplicationQuery();
 
+    CbsMusicSheetWrapper.MusicSheetApplicationQuery getMusicSheetApplicationQuery(SourceTypeEnum sourceType);
+
     PageInfo<CbsMusicSheetWrapper.MusicSheetAccApplication> queryCbsMusicSheetSoundApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
 
     List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
 
     IPage<MusicSheetVo> queryTenantRelatedList(IPage<Object> page, MusicSheetRelatedQueryInfo queryInfo);
+
+    com.microsvc.toolkit.common.response.paging.PageInfo<MusicSheetWrapper.MusicSheetApplication> tenantPage(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
+
+    void delPractice(Long musicSheetId,Long userId,ClientEnum clientEnum);
 }

+ 82 - 45
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CbsMusicSheetServiceImpl.java

@@ -17,7 +17,10 @@ import com.yonge.cooleshow.biz.dal.service.SubjectService;
 import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.toolset.base.exception.BizException;
+import com.yonge.toolset.payment.util.DistributedLock;
 import org.apache.commons.lang3.StringUtils;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @Service
@@ -45,54 +50,68 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
     @Resource
     private OpenFeignClientConfigProperties openFeignClientConfigProperties;
 
+    @Autowired
+    private RedissonClient redissonClient;
+
+
     @Override
-    @Transactional(rollbackFor = Exception.class)
+//    @Transactional(rollbackFor = Exception.class)
     public Boolean saveApplicationExtend(List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> addMusicSheet) {
         if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(addMusicSheet)) {
             throw new BizException("请选择曲目信息");
         }
-        String configValue = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_MUSIC_USER_ID);
+        String defaultMusicUserId = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_MUSIC_USER_ID);
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
         Long userId = 3L;
-        if (StringUtils.isNotBlank(configValue)) {
-            userId = Long.parseLong(configValue);
+        if (StringUtils.isNotBlank(defaultMusicUserId)) {
+            userId = Long.parseLong(defaultMusicUserId);
         }
 
-        List<Long> cbsMusicSheetIds = addMusicSheet.stream().map(e -> e.getMusicSheetId()).collect(Collectors.toList());
         for (CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend : addMusicSheet) {
+            //是否合奏曲目
             CbsMusicSheetApiWrapper.MusicSheetUpdate musicSheetUpdate = extend.getMusicSheetUpdate();
-            if(StringUtils.isNotBlank(musicSheetUpdate.getSubjectIds())) {
-                List<Subject> subjectIds = subjectService.getDao().getByCbsSubjectIds(musicSheetUpdate.getSubjectIds());
-                if (CollectionUtils.isNotEmpty(subjectIds)) {
-                    musicSheetUpdate.setSubjectIds(subjectIds.stream().map(e -> e.getId().toString()).collect(Collectors.joining(",")));
-                }
-            }
-            // 如果所属人存在,判断是否是当前应用的曲目 不是,设置默认所属用户
-            if (musicSheetUpdate.getUserId() != null && musicSheetUpdate.getUserApplicationId() !=null) {
-                if (musicSheetUpdate.getUserApplicationId().equals(Long.parseLong(openFeignClientConfigProperties.getAppId()))) {
-                    musicSheetUpdate.setUserId(extend.getMusicSheetUpdate().getUserId());
+
+            Long finalUserId = userId;
+            RLock lock = redissonClient.getLock("musicSheetUpdate:" + musicSheetUpdate.getId());
+            try {
+                if (lock.tryLock(10, 10, TimeUnit.SECONDS)) {
+                    updateMusicDataFormat(musicSheetUpdate, finalUserId);
+
+                    //需要修改的曲目
+                    List<MusicSheet> musicSheets = musicSheetService.lambdaQuery()
+                        .in(MusicSheet::getCbsMusicSheetId, extend.getMusicSheetId())
+                        .list();
+                    if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(musicSheets)) {
+                        // 判断是改机构数据,还是平台数据
+                        if (extend.getApplicationId() != null && cbsTenantAppId.equals(extend.getApplicationId().toString())) {
+
+                            musicSheetService.getDao().updateTenantByCbsId(extend);
+                        } else {
+                            musicSheetService.getDao().updatePlatformByCbsId(extend);
+                        }
+                    } else {
+                        if (extend.getApplicationId() != null && cbsTenantAppId.equals(extend.getApplicationId().toString())) {
+
+                            musicSheetService.getDao().tenantInsert(extend);
+                        } else {
+                            musicSheetService.getDao().platformInsert(extend);
+                        }
+                    }
                 } else {
-                    musicSheetUpdate.setUserId(userId);
+                    throw new BizException("获取锁失败");
+                }
+            } catch (BizException e) {
+                log.error("BizException error lockName : musicSheetUpdate:" + musicSheetUpdate.getId(), e);
+                throw e;
+            }  catch (Exception e) {
+                log.error("saveApplicationExtend error lockName : musicSheetUpdate:" + musicSheetUpdate.getId(), e);
+            } finally {
+                if (lock.getHoldCount() != 0 && lock.isHeldByCurrentThread()) {
+                    lock.unlock();
                 }
-            } else {
-                musicSheetUpdate.setUserId(userId);
             }
         }
-        //需要修改的曲目
-        List<MusicSheet> musicSheets = musicSheetService.lambdaQuery()
-                .in(MusicSheet::getCbsMusicSheetId, cbsMusicSheetIds)
-                .list();
-        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(musicSheets)){
-            List<Long> collect = musicSheets.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
-            //获取需要修改的曲目
-            List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> updateMusicScore =
-                    addMusicSheet.stream().filter(e -> collect.contains(e.getMusicSheetId())).collect(Collectors.toList());
-            musicSheetService.getDao().updateBatchByCbsId(updateMusicScore);
-            //排除已经存在的曲目
-            addMusicSheet = addMusicSheet.stream().filter(e -> !collect.contains(e.getMusicSheetId())).collect(Collectors.toList());
-        }
-        if(CollectionUtils.isNotEmpty(addMusicSheet)){
-            musicSheetService.getDao().batchInsert(addMusicSheet);
-        }
+
         return true;
     }
 
@@ -103,7 +122,14 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
         if (updateMusicSheet.getStatus() == null){
             throw new BizException("请选择状态");
         }
-        musicSheetService.getDao().batchEnable(updateMusicSheet.getIds(),updateMusicSheet.getStatus());
+
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+        if (updateMusicSheet.getApplicationId() != null && cbsTenantAppId.equals(updateMusicSheet.getApplicationId().toString())) {
+            musicSheetService.getDao().batchEnable(updateMusicSheet.getIds(),updateMusicSheet.getStatus(),true);
+        } else {
+            musicSheetService.getDao().batchEnable(updateMusicSheet.getIds(),updateMusicSheet.getStatus(),false);
+            musicSheetService.getDao().updateState(updateMusicSheet.getIds());
+        }
         return true;
     }
 
@@ -111,7 +137,13 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
         if (musicSheetApplicationExtendDel == null || StringUtils.isEmpty(musicSheetApplicationExtendDel.getIds())){
             throw new BizException("请选择曲目");
         }
-        musicSheetService.getDao().batchDel(musicSheetApplicationExtendDel.getIds());
+
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+        if (musicSheetApplicationExtendDel.getApplicationId() != null && cbsTenantAppId.equals(musicSheetApplicationExtendDel.getApplicationId().toString())) {
+            musicSheetService.getDao().batchDel(musicSheetApplicationExtendDel.getIds(),true);
+        } else {
+            musicSheetService.getDao().batchDel(musicSheetApplicationExtendDel.getIds(),false);
+        }
         return true;
     }
 
@@ -133,19 +165,26 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
     }
 
     public boolean updateMusicSheet(CbsMusicSheetApiWrapper.MusicSheetUpdate musicSheetUpdate) {
-        if(StringUtils.isNotBlank(musicSheetUpdate.getSubjectIds())) {
-            List<Subject> subjectIds = subjectService.getDao().getByCbsSubjectIds(musicSheetUpdate.getSubjectIds());
-            if (CollectionUtils.isNotEmpty(subjectIds)) {
-                musicSheetUpdate.setSubjectIds(subjectIds.stream().map(e -> e.getId().toString()).collect(Collectors.joining(",")));
-            }
-        }
         // 如果所属人存在,判断是否是当前应用的曲目 不是,设置默认所属用户
         String configValue = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_MUSIC_USER_ID);
         Long userId = 3L;
         if (StringUtils.isNotBlank(configValue)) {
             userId = Long.parseLong(configValue);
         }
-        if (musicSheetUpdate.getUserId() != null && musicSheetUpdate.getUserApplicationId() !=null) {
+        updateMusicDataFormat(musicSheetUpdate, userId);
+        musicSheetService.getDao().updateMusicSheet(musicSheetUpdate);
+        return true;
+    }
+
+    private void updateMusicDataFormat(CbsMusicSheetApiWrapper.MusicSheetUpdate musicSheetUpdate,Long userId) {
+        if(StringUtils.isNotBlank(musicSheetUpdate.getSubjectIds())) {
+            List<Subject> subjectIds = subjectService.getDao().getByCbsSubjectIds(musicSheetUpdate.getSubjectIds());
+            if (CollectionUtils.isNotEmpty(subjectIds)) {
+                musicSheetUpdate.setSubjectIds(subjectIds.stream().map(e -> e.getId().toString()).collect(Collectors.joining(",")));
+            }
+        }
+
+        if (musicSheetUpdate.getUserId() != null && musicSheetUpdate.getUserApplicationId() != null) {
             if (musicSheetUpdate.getUserApplicationId().equals(Long.parseLong(openFeignClientConfigProperties.getAppId()))) {
                 musicSheetUpdate.setUserId(musicSheetUpdate.getUserId());
             } else {
@@ -154,7 +193,5 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
         } else {
             musicSheetUpdate.setUserId(userId);
         }
-        musicSheetService.getDao().updateMusicSheet(musicSheetUpdate);
-        return true;
     }
 }

+ 7 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetAuthRecordServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayaedu.cbs.common.enums.music.EAudioType;
+import com.dayaedu.cbs.common.enums.music.EDefaultScoreType;
 import com.dayaedu.cbs.common.enums.music.EMusicAvailableType;
 import com.dayaedu.cbs.common.enums.school.EMusicSheetType;
 import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
@@ -98,6 +99,10 @@ public class MusicSheetAuthRecordServiceImpl extends ServiceImpl<MusicSheetAuthR
         addMusicSheet.setExtConfigJson(param.getExtConfigJson());
         addMusicSheet.setAudioType(EAudioType.valueOf(param.getAccompanimentType().getCode()));
         addMusicSheet.setMusicSheetType(EMusicSheetType.valueOf(param.getMusicSheetType()));
+        List<CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend> addMusicSheetApplicationExtend = addMusicSheet.getAddMusicSheetApplicationExtend();
+        for (CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend musicSheetApplicationExtend : addMusicSheetApplicationExtend) {
+            musicSheetApplicationExtend.setScoreType(EDefaultScoreType.valueOf(param.getScoreType()));
+        }
         musicSheetAuthRecord.setMusicSheetJson(JSON.toJSONString(addMusicSheet));
         MusicSheet musicSheet = musicSheetService.getById(musicSheetAuthRecord.getMusicSheetId());
         if (musicSheet == null) {
@@ -223,6 +228,7 @@ public class MusicSheetAuthRecordServiceImpl extends ServiceImpl<MusicSheetAuthR
         extend.setAvailableType(EMusicAvailableType.PLATFORM);
         extend.setMusicTagIds(addMusicSheet.getMusicTagIds());
         extend.setMusicPrice(addMusicSheet.getMusicPrice());
+        extend.setScoreType(EDefaultScoreType.STAVE);
         if(addMusicSheet.getIsConvertibleScore() == null){
             addMusicSheet.setIsConvertibleScore(true);
         }
@@ -247,6 +253,7 @@ public class MusicSheetAuthRecordServiceImpl extends ServiceImpl<MusicSheetAuthR
         musicSheet.setUserId(userId);
         musicSheet.setCreateBy(userId);
         musicSheet.setUpdateBy(userId);
+        musicSheet.setScoreType(EDefaultScoreType.STAVE.name());
         musicSheet.setCbsMusicSheetId(IdWorker.getId());
         musicSheetService.save(musicSheet);
         List<MusicSheetAccompaniment> musicSheetAccompaniments = musicSheetAccompanimentService.initMusicSheetAccompaniment(musicSheetAuthRecord.getMusicSheetJson(),musicSheet.getId());

+ 241 - 52
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java

@@ -199,7 +199,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
     @Override
     public IPage<MusicSheetVoResult> selectCbsPage(IPage<MusicSheetVo> page, MusicSheetSearch query) {
         List<MusicSheetVo> musicSheets = baseMapper.selectPage(page, query);
-        IPage<MusicSheetVo> info = page.setRecords(musicDataFormat(musicSheets));
+        IPage<MusicSheetVo> info = page.setRecords(musicDataFormat(musicSheets,query.getProviderType()));
         List<MusicSheetVo> rows = info.getRecords();
         List<MusicSheetVoResult> musicSheetVoResults = new ArrayList<>();
         for (MusicSheetVo row : rows) {
@@ -210,7 +210,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         return com.yonge.cooleshow.biz.dal.dto.PageUtil.transPageInfo(info, musicSheetVoResults);
     }
 
-    public List<MusicSheetVo> musicDataFormat(List<MusicSheetVo> musicSheets) {
+    public List<MusicSheetVo> musicDataFormat(List<MusicSheetVo> musicSheets,SourceTypeEnum sourceType) {
         if (CollectionUtils.isEmpty(musicSheets)) {
             return musicSheets;
         }
@@ -218,11 +218,15 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         if (CollectionUtils.isEmpty(cbsMusicSheetIds)) {
             return new ArrayList<>();
         }
+        Long appId = Long.parseLong(openFeignClientConfigProperties.getAppId());
+        if (sourceType!=null && sourceType==SourceTypeEnum.TENANT) {
+            appId = Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID));
+        }
         // 调用内容平台查询曲目信息
         R<PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> pageInfoR = musicFeignClientService
                 .musicSheetPageByApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery.builder()
                         .musicSheetIds(cbsMusicSheetIds).detailFlag(false).rows(-1).delFlag(true)
-                        .applicationId(Long.parseLong(openFeignClientConfigProperties.getAppId())).build());
+                        .applicationId(appId).build());
         List<CbsMusicSheetWrapper.MusicSheetApplication> rows;
         try {
             PageInfo<CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationPageInfo = pageInfoR.feignData();
@@ -310,7 +314,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = rows.get(0);
         CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus extendStatus = new CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus();
         extendStatus.setIds(musicSheetApplication.getApplicationExtendId().toString());
-        extendStatus.setStatus(musicSheet.getState()!=YesOrNoEnum.YES);
+        extendStatus.setStatus(!musicSheet.getClientState());
         R<JSONObject> jsonObjectR = musicFeignClientService.musicSheetApplicationExtendStatus(extendStatus);
         if (jsonObjectR.getCode() != 200) {
             throw new BizException("修改曲目状态失败,{}", jsonObjectR.getMessage());
@@ -388,7 +392,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         return musicSheetShareVo;
     }
 
-    public MusicSheetDetailVo getCbsDetail(Long id) {
+    public MusicSheetDetailVo getCbsDetail(Long id,SourceTypeEnum sourceTypeEnum) {
         MusicSheet musicSheet = this.baseMapper.get(id);
         if (musicSheet == null) {
             throw new BizException("未找到曲目信息");
@@ -397,7 +401,8 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             throw new BizException("曲目信息未同步");
         }
         MusicSheetDetailVo detailVo = JSON.parseObject(JSON.toJSONString(musicSheet), MusicSheetDetailVo.class);
-        this.initMusicSheetDetailVo(detailVo,musicSheet);
+        this.initMusicSheetDetailVo(detailVo,musicSheet,sourceTypeEnum);
+        detailVo.setProviderType(musicSheet.getProviderType());
         return detailVo;
     }
 
@@ -423,9 +428,11 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         return detailVo;
     }
 
-    public void initMusicSheetDetailVo(MusicSheetDetailVo detailVo,MusicSheet musicSheet) {
-        CbsMusicSheetWrapper.MusicSheetApplicationQuery query = this.getMusicSheetApplicationQuery();
+
+    public void initMusicSheetDetailVo(MusicSheetDetailVo detailVo,MusicSheet musicSheet,SourceTypeEnum sourceTypeEnum) {
+        CbsMusicSheetWrapper.MusicSheetApplicationQuery query = this.getMusicSheetApplicationQuery(sourceTypeEnum);
         query.setRows(1);
+        query.setDelFlag(true);
         query.setMusicSheetIds(Collections.singletonList(musicSheet.getCbsMusicSheetId()));
         List<CbsMusicSheetWrapper.MusicSheetApplication> rows = this.queryCbsMusicSheetApplication(query);
         if(CollectionUtils.isEmpty(rows)){
@@ -442,6 +449,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
                 detailVo.setUserAvatar(sysUser.getAvatar());
             }
         }
+        detailVo.setCategoryId(musicSheet1.getMusicCategoryId()!=null?musicSheet1.getMusicCategoryId().toString():"");
         detailVo.setMusicPrice(musicSheet1.getMusicPrice());
         detailVo.setSubjectNames(musicSheet1.getSubjectNames());
         detailVo.setCode(musicSheet1.getSubjectCodes());
@@ -549,6 +557,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         if (musicSheetApplication.getAudioType() != null) {
             sheet.setAccompanimentType(AccompanimentTypeEnum.valueOf(musicSheetApplication.getAudioType().getCode()));
         }
+        sheet.setCategoryName(musicSheetApplication.getMusicSheetCategoryName());
         sheet.setMusicTagNames(musicSheetApplication.getMusicTagNames());
         sheet.setSubjectNames(musicSheetApplication.getSubjectNames());
         sheet.setPaymentType(musicSheetApplication.getPaymentType());
@@ -610,7 +619,43 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
                 throw new BizException("未找到曲目信息");
             }
         }
-        MusicSheetDetailVo detail = this.getCbsDetail(Long.parseLong(id));
+        MusicSheetDetailVo detail ;
+        if (sysUser == null || userType == ClientEnum.SYSTEM) {
+
+            try {
+                detail = this.getCbsDetail(Long.parseLong(id),SourceTypeEnum.PLATFORM);
+            } catch (Exception e) {
+                detail = this.getCbsDetail(Long.parseLong(id),SourceTypeEnum.TENANT);
+            }
+        } else
+        if (StringUtil.isEmpty(tenantAlbumId)) {
+
+            // 如果是机构用户,判断机构专辑
+
+            // 机构学生,查询购买过的机构专辑,是否存在当前曲目
+            Long tenantId = userTenantId(sysUser.getId(), userType);
+
+            if (tenantId >0L) {
+                if (userType == ClientEnum.STUDENT) {
+                    detail = this.getCbsDetail(Long.parseLong(id),SourceTypeEnum.TENANT);
+                } else {
+                    if (detailVo.getProviderType().contains(SourceTypeEnum.PLATFORM.getCode())) {
+                        detail = this.getCbsDetail(Long.parseLong(id),SourceTypeEnum.PLATFORM);
+
+                    } else {
+                        detail = this.getCbsDetail(Long.parseLong(id),SourceTypeEnum.TENANT);
+                    }
+                }
+
+            } else {
+                detail = this.getCbsDetail(Long.parseLong(id),SourceTypeEnum.PLATFORM);
+            }
+        } else {
+
+            detail = this.getCbsDetail(Long.parseLong(id),SourceTypeEnum.TENANT);
+        }
+        detail.setPlay(YesOrNoEnum.NO);
+        detail.setTenantFlag(false);
         //兼容审批数据
         MusicSheetAuthRecord one = musicSheetAuthRecordService.lambdaQuery().eq(MusicSheetAuthRecord::getMusicSheetId, detail.getId()).last("limit 1").one();
         if (one != null) {
@@ -619,7 +664,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         // 设置收藏人数
         detail.setFavoriteCount(detail.getFavoriteCount() + detail.getVirtualNumber());
 
-        if (sysUser == null) {
+        if (sysUser == null || userType == ClientEnum.SYSTEM) {
             return detail;
         }
 
@@ -646,22 +691,60 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             detail.setReason(reason);
         }
         if (StringUtil.isEmpty(tenantAlbumId)) {
-            if (detail.getPaymentType().contains(ChargeTypeEnum.FREE.getCode())) {
-                detail.setPlay(YesOrNoEnum.YES);
-            } else if (ClientEnum.STUDENT.getCode().equals(userType.getCode())
-                || ClientEnum.TEACHER.getCode().equals(userType.getCode())) {
-                // 2022 7 20  老师也能购买曲目
-                if (ClientEnum.TEACHER.getCode().equals(userType.getCode()) && sysUser.getId().equals(detail.getUserId())) {
-                    detail.setPlay(YesOrNoEnum.YES);
-                } else {
-                    setMusicSheetPlay(sysUser.getId(), detail, userType);
+
+            // 如果是机构用户,判断机构专辑
+
+            // 机构学生,查询购买过的机构专辑,是否存在当前曲目
+            Long tenantId = userTenantId(sysUser.getId(), userType);
+
+            if (tenantId >0L) {
+
+                if (detail.getProviderType().contains(SourceTypeEnum.TENANT.getCode())) {
+                    if (userType == ClientEnum.STUDENT) {
+                        detail.setTenantFlag(true);
+                        // 机构学生
+                        List<Long> tenantAlbumIds = userTenantAlbumRecordMapper.selectTenantIds(sysUser.getId());
+                        if (CollectionUtils.isNotEmpty(tenantAlbumIds)) {
+                            List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByIds(tenantAlbumIds);
+                            if (musicSheetIds.contains(detail.getId())) {
+                                detail.setPlay(YesOrNoEnum.YES);
+                                detail.setBuyed(true);
+                            }
+                        }
+                    } else {
+                        // 老师所在机构启用的专辑
+                        Teacher teacher = teacherService.getById(sysUser.getId());
+                        if (teacher.getTenantId() >0) {
+                            List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByTenantIds(teacher.getTenantId());
+                            if (musicSheetIds.contains(detail.getId())) {
+                                detail.setPlay(YesOrNoEnum.YES);
+                                detail.setBuyed(true);
+                                detail.setTenantFlag(true);
+                            }
+                        }
+                        if (detail.getPlay() ==YesOrNoEnum.NO) {
+                            platformMusicUseCheck(sysUser, userType, detail);
+                        }
+                    }
+                }else {
+                    if (!detail.getProviderType().contains(SourceTypeEnum.PLATFORM.getCode())) {
+                        return detail;
+                    }
+                    platformMusicUseCheck(sysUser, userType, detail);
                 }
             } else {
-                detail.setPlay(YesOrNoEnum.YES);
+                if (!detail.getProviderType().contains(SourceTypeEnum.PLATFORM.getCode())) {
+                    return detail;
+                }
+                platformMusicUseCheck(sysUser, userType, detail);
             }
         } else {
+            detail.setTenantFlag(true);
+            if (!detail.getProviderType().contains(SourceTypeEnum.TENANT.getCode())) {
+                return detail;
+            }
             // 机构专辑购买
-            detail.setPlay(YesOrNoEnum.NO);
+//            detail.setPlay(YesOrNoEnum.NO);
             List<Long> collected = Arrays.stream(tenantAlbumId.split(",")).map(Long::parseLong).collect(Collectors.toList());
 
             // 学生生效中的机构专辑
@@ -688,9 +771,49 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
                 }
             }
         }
+        if (detail.getTenantFlag()) {
+            detail.setNotation(detail.getTenantNotation() !=null&& detail.getTenantNotation()?YesOrNoEnum.YES:YesOrNoEnum.NO);
+            detail.setScoreType(detail.getTenantScoreType());
+
+        }
         return detail;
     }
 
+    private void platformMusicUseCheck(SysUser sysUser, ClientEnum userType, MusicSheetDetailVo detail) {
+        if (!detail.getProviderType().contains(SourceTypeEnum.PLATFORM.getCode())) {
+            return;
+        }
+        if (detail.getPaymentType().contains(ChargeTypeEnum.FREE.getCode())) {
+            detail.setPlay(YesOrNoEnum.YES);
+        } else if (ClientEnum.STUDENT.getCode().equals(userType.getCode())
+            || ClientEnum.TEACHER.getCode().equals(userType.getCode())) {
+            // 2022 7 20  老师也能购买曲目
+            if (ClientEnum.TEACHER.getCode().equals(userType.getCode()) && sysUser.getId().equals(detail.getUserId())) {
+                detail.setPlay(YesOrNoEnum.YES);
+            } else {
+                setMusicSheetPlay(sysUser.getId(), detail, userType);
+            }
+        } else {
+            detail.setPlay(YesOrNoEnum.YES);
+        }
+    }
+
+    private Long userTenantId(Long userId, ClientEnum userType) {
+        if (ClientEnum.STUDENT == userType) {
+            Student student = studentService.getById(userId);
+            if (student != null&& student.getTenantId() !=null && student.getTenantId() >0) {
+                return student.getTenantId();
+            }
+        } else if (ClientEnum.TEACHER == userType) {
+            Teacher teacher = teacherService.getById(userId);
+            if (teacher != null && teacher.getTenantId() !=null && teacher.getTenantId() >0) {
+                return teacher.getTenantId();
+            }
+        }
+        return -1L;
+
+    }
+
     /**
      * 设置学生曲目信息
      * <p>
@@ -701,7 +824,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
      * @param userType  用户类型
      */
     private void setMusicSheetPlay(Long studentId, MusicSheetDetailVo detail, ClientEnum userType) {
-        detail.setPlay(YesOrNoEnum.NO);
+//        detail.setPlay(YesOrNoEnum.NO);
         // 单曲购买 判断购买记录,有记录课播放
         if (detail.getPaymentType().contains(ChargeTypeEnum.CHARGE.getCode())) {
             // 学生须判断是否能播放曲目
@@ -742,6 +865,10 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             return;
         }
 
+        if (detail.getDelFlag() ||detail.getState() == YesOrNoEnum.NO) {
+            return;
+        }
+
         // 判断专辑购买
 
         // 1 查询曲目所在的专辑
@@ -767,31 +894,6 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             if (count > 0) {
                 detail.setPlay(YesOrNoEnum.YES);
                 detail.setBuyed(true);
-                return;
-            }
-        }
-
-        // 机构专辑购买
-
-        // 学生生效中的机构专辑
-        if (ClientEnum.STUDENT == userType) {
-            List<Long> tenantAlbumIds = userTenantAlbumRecordMapper.selectTenantIds(studentId);
-            if (CollectionUtils.isNotEmpty(tenantAlbumIds)) {
-                List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByIds(tenantAlbumIds);
-                if (musicSheetIds.contains(detail.getId())) {
-                    detail.setPlay(YesOrNoEnum.YES);
-                    detail.setBuyed(true);
-                }
-            }
-        } else if (ClientEnum.TEACHER == userType) {
-            // 老师所在机构启用的专辑
-            Teacher teacher = teacherService.getById(studentId);
-            if (teacher.getTenantId() !=null) {
-                List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByTenantIds(teacher.getTenantId());
-                if (musicSheetIds.contains(detail.getId())) {
-                    detail.setPlay(YesOrNoEnum.YES);
-                    detail.setBuyed(true);
-                }
             }
         }
     }
@@ -925,6 +1027,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
     @Override
     public IPage<MusicSheetVo> myMusic(IPage<MusicSheetVo> page, StudentMusicSheetSearch query) {
         query.setDelFlag(null);
+        query.setProviderType(SourceTypeEnum.PLATFORM);
 
         List<MusicSheetVo> records = baseMapper.selectMyMusicPage(page, query);
         //设置内容平台曲目信息
@@ -968,6 +1071,8 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
 
         // 设置学生端收藏联系
         query.setClientType(ClientEnum.STUDENT);
+        query.setState(null);
+        query.setDelFlag(null);
         // 构建分页信息
         List<MusicSheetVo> musicSheetVos = baseMapper.selectPracticeMusicPage(query, practiceMusicIdList);
         //设置内容平台曲目信息
@@ -983,6 +1088,21 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             // 更新曲目专辑数量
             musicSheetService.updateMusicAlbumNumInfo(page.getRecords());
         }
+        for (MusicSheetVo record : page.getRecords()) {
+            // 1失效 0 有效
+            MusicSheetDetailVo detail = detail(record.getId(), sysUserFeignService.queryUserById(query.getStudentId()), ClientEnum.STUDENT);
+            record.setTitleImg(detail.getTitleImg());
+            record.setPlay(YesOrNoEnum.YES);
+            if (query.getProviderType() == SourceTypeEnum.PLATFORM) {
+                if (Boolean.TRUE.equals(detail.getBuyed())) {
+                    record.setPlay(YesOrNoEnum.NO);
+                } else if(detail.getProviderType().contains(SourceTypeEnum.PLATFORM.getCode())) {
+                    record.setPlay(detail.getState() ==YesOrNoEnum.YES && !detail.getDelFlag()?YesOrNoEnum.NO:YesOrNoEnum.YES);
+                }
+            }else {
+                record.setPlay(detail.getPlay()==YesOrNoEnum.YES?YesOrNoEnum.NO:YesOrNoEnum.YES);
+            }
+        }
         return page;
     }
 
@@ -1370,6 +1490,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         teacherMusicSheetListVo.setEntryFlag(teacherVo.getEntryFlag());
         teacherMusicSheetListVo.setMusicianFlag(teacherVo.getMusicianFlag());
         teacherMusicSheetListVo.setTag(teacherVo.getTag());
+        teacherMusicSheetListVo.setVipType(teacherVo.getVipType());
 
         TeacherTotal total = totalService.getTotalById(detail.getUserId());
         if (total != null) {
@@ -1478,7 +1599,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         addMusicSheetApplicationExtend.setMusicTagIds(musicSheet.getMusicTag());
         addMusicSheetApplicationExtend.setMusicPrice(musicSheet.getMusicPrice());
         addMusicSheetApplicationExtend.setPaymentType(musicSheet.getPaymentType());
-        addMusicSheetApplicationExtend.setAvailableType(musicSheet.getProviderType() !=null&& musicSheet.getProviderType()==SourceTypeEnum.TENANT
+        addMusicSheetApplicationExtend.setAvailableType(StringUtils.isNotBlank(musicSheet.getProviderType())&& musicSheet.getProviderType().equals("TENANT")
             ?EMusicAvailableType.ORG:EMusicAvailableType.PLATFORM);
         addMusicSheetApplicationExtend.setExquisiteFlag(musicSheet.getExquisiteFlag() == YesOrNoEnum.YES);
         addMusicSheetApplicationExtend.setSortNo(musicSheet.getSortNumber());
@@ -1859,6 +1980,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
 
             MusicSheetSearch musicSheetSearch = new MusicSheetSearch();
             musicSheetSearch.setMusicSheetIdlist(musicIds);
+            musicSheetSearch.setProviderType(SourceTypeEnum.TENANT);
             IPage<MusicSheetVo> musicSheetVoIPage = selectPage(PageUtil.getPage(queryInfo), musicSheetSearch);
             List<MusicSheetVo> records = musicSheetVoIPage.getRecords();
             if (CollectionUtils.isNotEmpty(records)) {
@@ -1977,7 +2099,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         musicSheetAudit.setCreateBy(userId);
         musicSheetAudit.setUpdateBy(userId);
         musicSheetAudit.setSubmitAuditTime(new Date());
-        musicSheetAudit.setProviderType(SourceTypeEnum.TEACHER);
+        musicSheetAudit.setProviderType(SourceTypeEnum.PLATFORM.getCode());
         musicSheetAudit.setSourceType(SourceTypeEnum.TEACHER);
         musicSheetAudit.setAuditStatus(AuthStatusEnum.DOING);
         musicSheetAudit.setState(YesOrNoEnum.NO);
@@ -2053,6 +2175,10 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         musicSheetAudit.setTitleImg(addMusicSheet.getMusicCover());
         musicSheetAudit.setExtConfigJson(addMusicSheet.getExtConfigJson());
         musicSheetAudit.setRemark(addMusicSheet.getRemark());
+        if (CollectionUtils.isNotEmpty(addMusicSheet.getAddMusicSheetApplicationExtend())) {
+            EDefaultScoreType scoreType = addMusicSheet.getAddMusicSheetApplicationExtend().get(0).getScoreType();
+            musicSheetAudit.setScoreType(scoreType!=null?scoreType.name():EDefaultScoreType.STAVE.getCode());
+        }
         if(addMusicSheet.getAudioType() != null){
             musicSheetAudit.setAccompanimentType(AccompanimentTypeEnum.valueOf(addMusicSheet.getAudioType().getCode()));
         }
@@ -2170,6 +2296,9 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
                 musicSheetAudit.setPaymentType(applicationExtend.getPaymentType());
                 musicSheetAudit.setChargeType(ChargeTypeEnum.valueOf(applicationExtend.getPaymentType()));
             }
+
+            EDefaultScoreType scoreType = addMusicSheet.getAddMusicSheetApplicationExtend().get(0).getScoreType();
+            musicSheetAudit.setScoreType(scoreType!=null?scoreType.name():EDefaultScoreType.STAVE.getCode());
             if(applicationExtend.getTopFlag() != null){
                 musicSheetAudit.setTopFlag(applicationExtend.getTopFlag()? YesOrNoEnum.YES: YesOrNoEnum.NO);
             }
@@ -2202,7 +2331,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
     }
     @Override
     public void initMusicSheetDetailVo(CbsMusicSheetWrapper.AddMusicSheet addMusicSheet, MusicSheetDetailVo musicSheetAudit) {
-        musicSheetAudit.setProviderType(SourceTypeEnum.TEACHER);
+        musicSheetAudit.setProviderType(SourceTypeEnum.PLATFORM.getCode());
         musicSheetAudit.setSourceType(SourceTypeEnum.TEACHER);
         musicSheetAudit.setMusicSheetName(addMusicSheet.getName());
         musicSheetAudit.setMusicSubject(addMusicSheet.getSubjectIds());
@@ -2265,6 +2394,9 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
                 musicSheetAudit.setPaymentType(applicationExtend.getPaymentType());
                 musicSheetAudit.setChargeType(ChargeTypeEnum.valueOf(applicationExtend.getPaymentType()));
             }
+
+            EDefaultScoreType scoreType = addMusicSheet.getAddMusicSheetApplicationExtend().get(0).getScoreType();
+            musicSheetAudit.setScoreType(scoreType!=null?scoreType.name():EDefaultScoreType.STAVE.getCode());
             if(applicationExtend.getTopFlag() != null){
                 musicSheetAudit.setTopFlag(applicationExtend.getTopFlag()? YesOrNoEnum.YES: YesOrNoEnum.NO);
             }
@@ -2328,12 +2460,20 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
 
     @Override
     public CbsMusicSheetWrapper.MusicSheetApplicationQuery getMusicSheetApplicationQuery() {
+        return getMusicSheetApplicationQuery(SourceTypeEnum.PLATFORM);
+    }
+    @Override
+    public CbsMusicSheetWrapper.MusicSheetApplicationQuery getMusicSheetApplicationQuery(SourceTypeEnum sourceType) {
         CbsMusicSheetWrapper.MusicSheetApplicationQuery query = new CbsMusicSheetWrapper.MusicSheetApplicationQuery();
         query.setDetailFlag(true);
         query.setDelFlag(true);
         query.setPage(1);
         query.setAudioPlayTypeFlag(false);
-        query.setApplicationId(applicationId);
+        if (sourceType == SourceTypeEnum.PLATFORM) {
+            query.setApplicationId(applicationId);
+        } else {
+            query.setApplicationId(Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID)));
+        }
         return query;
     }
 
@@ -2373,6 +2513,55 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         return musicSheetDao.queryTenantRelatedList(page,queryInfo);
     }
 
+    @Override
+    public PageInfo<MusicSheetWrapper.MusicSheetApplication> tenantPage(CbsMusicSheetWrapper.MusicSheetApplicationQuery query) {
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+        query.setApplicationId(Long.parseLong(cbsTenantAppId));
+        try {
+            PageInfo<CbsMusicSheetWrapper.MusicSheetApplication> feignedData = this.musicFeignClientService.musicSheetPageByApplication(query).feignData();
+            PageInfo<MusicSheetWrapper.MusicSheetApplication> convert = feignedData.convert(o -> JSON.parseObject(JSON.toJSONString(o),MusicSheetWrapper.MusicSheetApplication.class));
+
+            List<MusicSheetWrapper.MusicSheetApplication> rows = convert.getRows();
+            if (CollectionUtils.isEmpty(rows)) {
+                return convert;
+            }
+            // 查询曲目对应的业务ID
+            List<Long> cbsMusicSheetIds = rows.stream().map(CbsMusicSheetWrapper.MusicSheetApplication::getId).collect(Collectors.toList());
+            Map<Long, MusicSheet> mapByCbsIds = getMapByCbsIds(cbsMusicSheetIds);
+            rows = rows.stream().map(o->{
+                MusicSheet musicSheet = mapByCbsIds.get(o.getId());
+                if (musicSheet != null) {
+                    o.setBizId(musicSheet.getId());
+                    return o;
+                }
+                return null;
+            }).filter(Objects::nonNull).collect(Collectors.toList());
+
+
+            convert.setRows(rows);
+            return convert;
+        } catch (Exception e) {
+            log.error("查询曲目应用拓展表异常", e);
+            if(e instanceof com.microsvc.toolkit.common.webportal.exception.BizException) {
+                throw e;
+            }
+            throw com.microsvc.toolkit.common.webportal.exception.BizException.from("内容平台服务异常");
+        }
+    }
+
+    @Override
+    public void delPractice(Long musicSheetId,Long userId,ClientEnum clientEnum) {
+        baseMapper.delPractice(musicSheetId,userId,clientEnum);
+    }
+
+    private Map<Long,MusicSheet> getMapByCbsIds(List<Long> cbsMusicSheetIds) {
+        if (CollectionUtils.isEmpty(cbsMusicSheetIds)) {
+            return new HashMap<>();
+        }
+        List<MusicSheet> musicSheets = this.lambdaQuery().in(MusicSheet::getCbsMusicSheetId, cbsMusicSheetIds).list();
+        return musicSheets.stream().collect(Collectors.toMap(MusicSheet::getCbsMusicSheetId,o->o, (o1,o2)->o2));
+    }
+
 
     private void syncMusicSheet(MusicSheet record, Date date) {
         List<MusicSheetAccompaniment> list = musicSheetAccompanimentService.lambdaQuery().eq(MusicSheetAccompaniment::getMusicSheetId, record.getId()).list();
@@ -2528,7 +2717,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         addMusicSheetApplicationExtend.setPaymentType(from.getPaymentType());
         addMusicSheetApplicationExtend.setTopFlag(from.getTopFlag() !=null && from.getTopFlag() == YesOrNoEnum.YES);
         addMusicSheetApplicationExtend.setExquisiteFlag(from.getExquisiteFlag() !=null && from.getExquisiteFlag() == YesOrNoEnum.YES);
-        addMusicSheetApplicationExtend.setAvailableType(from.getProviderType() !=null && from.getProviderType() == SourceTypeEnum.TENANT?EMusicAvailableType.ORG:EMusicAvailableType.PLATFORM);
+        addMusicSheetApplicationExtend.setAvailableType(StringUtils.isNotBlank(from.getProviderType())&& from.getProviderType().equals(SourceTypeEnum.TENANT.getCode())?EMusicAvailableType.ORG:EMusicAvailableType.PLATFORM);
         addMusicSheetApplicationExtend.setMusicTagIds(from.getMusicTag());
         addMusicSheetApplicationExtend.setMusicPrice(from.getMusicPrice());
         addMusicSheet.setAddMusicSheetApplicationExtend(Lists.newArrayList(addMusicSheetApplicationExtend));

+ 12 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherTotalServiceImpl.java

@@ -186,7 +186,18 @@ public class TeacherTotalServiceImpl extends ServiceImpl<TeacherTotalDao, Teache
     public TeacherTotal getTotalById(Long id) {
         RBucket<Object> bucket = redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(id));
         if (bucket.isExists()) {
-            return (TeacherTotal) bucket.get();
+            try {
+
+                return (TeacherTotal) bucket.get();
+            }catch (Exception e) {
+                log.error("getTotalById error", e);
+            }
+            //去数据库查询
+            TeacherTotal total = totalTeacherTotalById(id);
+            if(null != total){
+                bucket.set(total);
+            }
+            return total;
         } else {
             //去数据库查询
             TeacherTotal total = totalTeacherTotalById(id);

+ 45 - 33
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumMusicServiceImpl.java

@@ -4,10 +4,12 @@ import cn.hutool.core.util.NumberUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.beust.jcommander.internal.Lists;
 import com.dayaedu.cbs.common.enums.school.ECourseType;
 import com.dayaedu.cbs.common.enums.school.EKnowledgeType;
 import com.dayaedu.cbs.common.enums.school.EMaterialType;
 import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsCourseTypeWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
@@ -15,12 +17,17 @@ import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
 import com.microsvc.toolkit.common.response.paging.PageInfo;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper;
+import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.wrapper.LessonCoursewareDetailWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.LessonCoursewareWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
+import com.yonge.cooleshow.common.enums.YesOrNoEnum;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.toolset.base.exception.BizException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
@@ -31,7 +38,6 @@ import org.springframework.stereotype.Service;
 
 import java.util.*;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * 机构专辑曲目
@@ -55,6 +61,12 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
     private MusicTagService musicTagService;
 
     @Autowired
+    private MusicFeignClientService musicFeignClientService;
+
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    @Autowired
     private TenantAlbumMusicMapper tenantAlbumMusicMapper;
 
     @Autowired
@@ -102,8 +114,8 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
             if (CollectionUtils.isEmpty(musicSheets)) {
                 return page.setRecords(musicSheets);
             }
-            CbsMusicSheetWrapper.MusicSheetApplicationQuery cbsQuery = musicSheetService.getMusicSheetApplicationQuery();
-            List<Long> cbsMusicSheetIds = musicSheets.stream().map(TenantAlbumMusicWrapper.StudentTenantAlbumMusic::getCbsMusicSheetId).collect(Collectors.toList());
+            CbsMusicSheetWrapper.MusicSheetApplicationQuery cbsQuery = musicSheetService.getMusicSheetApplicationQuery(SourceTypeEnum.TENANT);
+            List<Long> cbsMusicSheetIds = musicSheets.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
             cbsQuery.setMusicSheetIds(cbsMusicSheetIds);
             cbsQuery.setRows(cbsMusicSheetIds.size());
             List<CbsMusicSheetWrapper.MusicSheetApplication> rows = musicSheetService.queryCbsMusicSheetApplication(cbsQuery);
@@ -237,13 +249,13 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
         TenantAlbumMusicWrapper.TenantAlbumMusicSelectData data = new TenantAlbumMusicWrapper.TenantAlbumMusicSelectData();
 
         // 获取学生的专辑
-        List<Long> albumIds = userTenantAlbumRecordService.getUseAlbumIdsByUserId(query.getUserId(), ClientEnum.STUDENT);
-        if (CollectionUtils.isEmpty(albumIds)) {
-            return data;
-        }
+//        List<Long> albumIds = userTenantAlbumRecordService.getUseAlbumIdsByUserId(query.getUserId(), ClientEnum.STUDENT);
+//        if (CollectionUtils.isEmpty(albumIds)) {
+//            return data;
+//        }
 
         // 专辑曲目关联数据
-        List<TenantAlbumMusic> list = tenantAlbumMusicMapper.getList(query,albumIds);
+        List<TenantAlbumMusic> list = tenantAlbumMusicMapper.getList(query, Lists.newArrayList(query.getTenantAlbumId()));
         if (CollectionUtils.isEmpty(list)) {
             return data;
         }
@@ -311,19 +323,19 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
             data.setSubjects(subjects);
         }
 
-        // 标签
-        List<Long> musicTagIds = musicSheets.stream().flatMap(o -> {
-            if (StringUtils.isNotBlank(o.getMusicTag())) {
-                return Arrays.stream(o.getMusicTag().split(","));
-            }
-            return Stream.empty();
-
-        }).filter(StringUtils::isNotBlank).distinct().map(Long::parseLong).collect(Collectors.toList());
-        if (!CollectionUtils.isEmpty(musicTagIds)) {
-
-            List<MusicTag> tagList = musicTagService.listByIds(musicTagIds).parallelStream().collect(Collectors.toList());
-            data.setTags(tagList);
-        }
+//        // 标签
+//        List<Long> musicTagIds = musicSheets.stream().flatMap(o -> {
+//            if (StringUtils.isNotBlank(o.getMusicTag())) {
+//                return Arrays.stream(o.getMusicTag().split(","));
+//            }
+//            return Stream.empty();
+//
+//        }).filter(StringUtils::isNotBlank).distinct().map(Long::parseLong).collect(Collectors.toList());
+//        if (!CollectionUtils.isEmpty(musicTagIds)) {
+//
+//            List<MusicTag> tagList = musicTagService.listByIds(musicTagIds).parallelStream().collect(Collectors.toList());
+//            data.setTags(tagList);
+//        }
         data.setSubjects(new ArrayList<>());
 
         return data;
@@ -336,10 +348,16 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
         // 有声部, 根据声部查询对应的课件类型
         List<CbsCourseTypeWrapper.CourseType> courseTypes = coursewareFeignService.courseTypeList().feignData();
         if (subjectId != null) {
+            String configValue = sysConfigService.findConfigValue(SysConfigConstant.COURSE_SUBJECT_MAP);
+            Map<String, String> map= new HashMap<>();
+            if (StringUtils.isNotBlank(configValue)) {
+                map = JSON.parseObject(configValue, Map.class);
+            }
             Subject subject = subjectService.get(subjectId);
             for (CbsCourseTypeWrapper.CourseType courseType : courseTypes) {
                 if (StringUtils.isNotBlank(courseType.getSubjectIds()) ) {
                     if (subject !=null && subject.getCbsSubjectId() !=null) {
+                        subject.setCbsSubjectId(Long.parseLong(map.getOrDefault(subject.getCbsSubjectId().toString(),subject.getCbsSubjectId().toString())));
                         boolean contains = Arrays.asList(courseType.getSubjectIds().split(",")).contains(subject.getCbsSubjectId().toString());
                         if (contains) {
                             courseTypeList.add(ECourseType.valueOf(courseType.getTypeCode()));
@@ -363,14 +381,8 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
         if (CollectionUtils.isEmpty(tenantAlbumIds)) {
             return Collections.emptyList();
         }
-        List<TenantAlbumMusic> list = this.lambdaQuery()
-            .in(TenantAlbumMusic::getTenantAlbumId, tenantAlbumIds)
-            .in(CollectionUtils.isNotEmpty(subjectTypes),TenantAlbumMusic::getSubjectType,subjectTypes)
-            .list();
-        if (CollectionUtils.isEmpty(list)) {
-            return Collections.emptyList();
-        }
-        return list.stream().map(TenantAlbumMusic::getMusicSheetId).collect(Collectors.toList());
+
+        return baseMapper.getTenantAlbumMusicIdsByIds(tenantAlbumIds, subjectTypes);
     }
 
     @Override
@@ -441,8 +453,8 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
                 .filter(StringUtils::isNotBlank).map(Long::parseLong).collect(Collectors.toList());
             Map<Long, Long> idMap = musicSheetService.lambdaQuery()
                 .in(MusicSheet::getCbsMusicSheetId, cbsMaterialMusicIds)
-                .eq(MusicSheet::getDelFlag, false)
-                .eq(MusicSheet::getState, 1)
+                .eq(MusicSheet::getTenantDelFlag, false)
+                .eq(MusicSheet::getTenantState, 1)
                 .list()
                 .stream()
                 .collect(Collectors.toMap(MusicSheet::getCbsMusicSheetId, MusicSheet::getId,(o1,o2)->o1));
@@ -459,8 +471,8 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
         if (!org.springframework.util.CollectionUtils.isEmpty(cbsMusicSheetIdList)) {
             Map<Long, Long> idMap = musicSheetService.lambdaQuery()
                 .in(MusicSheet::getCbsMusicSheetId, cbsMusicSheetIdList)
-                .eq(MusicSheet::getDelFlag, false)
-                .eq(MusicSheet::getState, 1)
+                .eq(MusicSheet::getTenantDelFlag, false)
+                .eq(MusicSheet::getTenantState, 1)
                 .list()
                 .stream()
                 .collect(Collectors.toMap(MusicSheet::getCbsMusicSheetId, MusicSheet::getId,(o1,o2)->o1));

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetDetailVo.java

@@ -31,6 +31,9 @@ public class MusicSheetDetailVo extends MusicSheet {
     @ApiModelProperty("是否购买(0:否,1:是)")
     private Boolean buyed = false;
 
+
+    private Boolean tenantFlag = false;
+
     @ApiModelProperty("收藏0:否,1:是")
     private YesOrNoEnum favorite;
 
@@ -87,5 +90,8 @@ public class MusicSheetDetailVo extends MusicSheet {
 
     @ApiModelProperty("曲目json文件")
     private String musicSheetJson;
+
+    @ApiModelProperty("内容平台分类ID")
+    private String categoryId;
 }
 

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetVo.java

@@ -47,6 +47,9 @@ public class MusicSheetVo extends MusicSheet {
     @ApiModelProperty("机构专辑ID,逗号隔开")
     private String tenantAlbumId;
 
+    @ApiModelProperty("分类")
+    private String categoryName;
+
     @ApiModelProperty("所属人信息")
     private CbsMusicSheetWrapper.MusicSheetExtend musicSheetExtend;
 

+ 10 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetVoResult.java

@@ -246,6 +246,16 @@ public class MusicSheetVoResult implements Serializable {
     @ApiModelProperty("谱面类型")
     private EDefaultScoreType scoreType;
 
+
+    @ApiModelProperty(value = "客户端状态曲目状态(0:停用,1:启用)")
+    private Boolean clientState;
+
+    @ApiModelProperty(value = "内容平台状态曲目状态(0:停用,1:启用)")
+    private Boolean  platformState;
+
+    @ApiModelProperty("分类")
+    private String categoryName;
+
     public ChargeTypeEnum getChargeType() {
         if (Objects.isNull(this.chargeType) && StringUtils.isNotEmpty(getPaymentType())) {
 

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherMusicSheetListVo.java

@@ -1,8 +1,10 @@
 package com.yonge.cooleshow.biz.dal.vo;
 
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.util.List;
 
@@ -12,6 +14,7 @@ import java.util.List;
  * @author liujunchi
  * @date 2022-06-14
  */
+@Data
 @ApiModel("官网曲目详情老师和老师拥有的曲目信息")
 public class TeacherMusicSheetListVo {
 
@@ -46,6 +49,9 @@ public class TeacherMusicSheetListVo {
     private List<MusicSheetVo> musicSheetList;
 
 
+    @ApiModelProperty(value = "用户会员类型,普通用户:NORMAL,会员:VIP,SVIP:SVIP")
+    private EUserVipType vipType;
+
     public String getTag() {
         return tag;
     }

+ 72 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/MusicSheetWrapper.java

@@ -1,6 +1,8 @@
 package com.yonge.cooleshow.biz.dal.wrapper;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.ToStringSerializer;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -135,6 +137,11 @@ public class MusicSheetWrapper {
         @ApiModelProperty("添加人")
         private String addName;
 
+
+        @ApiModelProperty("谱面类型")
+        @TableField("score_type_")
+        private String scoreType;
+
         @ApiModelProperty("添加头像(老师头像)")
         private String addUserAvatar;
 
@@ -550,6 +557,9 @@ public class MusicSheetWrapper {
         @ApiModelProperty(value = "备注")
         private String remark;  //备注,填写未通过审核的原因
 
+        @ApiModelProperty("谱面类型")
+        @TableField("score_type_")
+        private String scoreType;
 
         @TableField("ext_config_json_")
         @ApiModelProperty("曲目配置信息")
@@ -862,4 +872,66 @@ public class MusicSheetWrapper {
         @ApiModelProperty("是否购买(0:否,1:是)")
         private Boolean buyed = false;
     }
+
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel(" MusicSheetTenantQuery-曲谱表")
+    public static class MusicSheetTenantQuery implements QueryInfo {
+
+        @ApiModelProperty("当前页")
+        private Integer page;
+
+        @ApiModelProperty("分页行数")
+        private Integer rows;
+
+        @ApiModelProperty("关键字匹配 曲目编号/名称")
+        private String keyword;
+
+        @ApiModelProperty(value = "曲目来源类型 TEACHER 老师 PLATFORM 平台")
+        private SourceTypeEnum sourceType;
+
+
+        @ApiModelProperty("伴奏类型  HOMEMODE:自制 COMMON:普通")
+        private String accompanimentType;
+
+
+        @ApiModelProperty("声部Id")
+        private String musicSubject;
+
+        @ApiModelProperty("曲谱分类编号")
+        private Integer musicSheetCategoriesId;
+
+        private List<Integer> musicSheetCategoriesIdList;
+
+        @ApiModelProperty(value = "启用停用标识,曲目状态(0:停用,1:启用)")
+        private Boolean platformStatus;
+
+        @ApiModelProperty(value = "启用停用标识,曲目状态(0:停用,1:启用)")
+        private Boolean clientStatus;
+
+        @ApiModelProperty("需要排查的曲谱ID")
+        private List<Long> excludeMusicIds;
+
+    }
+
+    @Data
+    public static class MusicSheetApplication extends CbsMusicSheetWrapper.MusicSheetApplication{
+        @ApiModelProperty("主键")
+        @JSONField(serializeUsing = ToStringSerializer.class)
+        private Long id;
+
+        @ApiModelProperty("分类ID")
+        @JSONField(serializeUsing = ToStringSerializer.class)
+        private Long musicSheetCategoryId;
+
+    }
+
+    @Data
+    public static class MusicSheetApplicationQuery extends CbsMusicSheetWrapper.MusicSheetApplicationQuery {
+        @ApiModelProperty("类型")
+        private String subjectType;
+    }
 }

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumMusicWrapper.java

@@ -3,6 +3,7 @@ package com.yonge.cooleshow.biz.dal.wrapper;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.dayaedu.cbs.common.enums.school.ECourseType;
+import com.dayaedu.cbs.openfeign.wrapper.music.MusicSheetCategoriesWrapper;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.biz.dal.entity.MusicTag;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
@@ -125,6 +126,9 @@ public class TenantAlbumMusicWrapper {
         @ApiModelProperty("课件教材分类集合")
         private List<String> courseTypeList = new ArrayList<>();
 
+        @ApiModelProperty("分类集合")
+        private List<MusicSheetCategoriesWrapper.MusicSheetCategories> categoyList = new ArrayList<>();
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -132,6 +136,7 @@ public class TenantAlbumMusicWrapper {
         public static TenantAlbumMusic from(String json) {
             return JSON.parseObject(json, TenantAlbumMusic.class);
         }
+
     }
 
 
@@ -161,6 +166,12 @@ public class TenantAlbumMusicWrapper {
         @ApiModelProperty("声部id")
         private Long subjectId;
 
+        @ApiModelProperty("分类id")
+        private Long categoryId;
+
+        @ApiModelProperty(value = "分类id",hidden = true)
+        private List<Long> categoryIds;
+
         @ApiModelProperty("级别")
         private String level;
 

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumWrapper.java

@@ -381,6 +381,12 @@ public class TenantAlbumWrapper {
 
         @ApiModelProperty(value = "上传人")
         private String userName;
+
+        @ApiModelProperty(value = "是否错误")
+        private Boolean errFlag;
+
+        @ApiModelProperty(value = "是否错误",hidden = true)
+        private Boolean loop;
     }
 
 

+ 4 - 4
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityEvaluationMapper.xml

@@ -25,7 +25,7 @@
         SELECT
         <include refid="baseColumns"/>
         FROM activity_evaluation t
-        left join music_sheet ms on t.music_sheet_id_ = ms.id_
+        left join music_sheet ms on t.music_sheet_id_ = ms.id_ and find_in_set('PLATFORM',ms.provider_type_)
         where t.id_ = #{id}
     </select>
 
@@ -41,7 +41,7 @@
             , ms.source_type_ as sourceType
             , ms.music_price_ as musicPrice
         FROM activity_evaluation t
-        left join music_sheet ms on t.music_sheet_id_ = ms.id_
+        left join music_sheet ms on t.music_sheet_id_ = ms.id_ and find_in_set('PLATFORM',ms.provider_type_)
         <where>
             <if test="param.activityId != null">
                 and t.activity_id_ = #{param.activityId}
@@ -77,7 +77,7 @@
         , ae.evaluation_difficulty_ AS evaluationDifficulty
         ,(select if(count(1)>0,1,0) as `join` from activity_evaluation_record aer where aer.evaluation_id_ = ae.id_ and aer.user_id_ = #{userId}) as `join`
         from activity_evaluation ae
-        left join music_sheet ms on ms.id_ = ae.music_sheet_id_
+        left join music_sheet ms on ms.id_ = ae.music_sheet_id_ and find_in_set('PLATFORM',ms.provider_type_)
         left join subject s on s.id_ = ms.music_subject_
         <where>
             ms.del_flag_ = 0
@@ -131,7 +131,7 @@
             left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
         </if>
         <where>
-            su.del_flag_ = 0
+            su.del_flag_ = 0 and find_in_set('PLATFORM',t.provider_type_)
             and not exists(
                 select 1 from activity_evaluation ae where ae.activity_id_ = ${param.activityId} and ae.music_sheet_id_ = t.id_
             )

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

@@ -58,7 +58,7 @@
                 from activity_registration ar
 		        left join activity_evaluation_record aer on ar.activity_id_ = aer.activity_id_ and ar.user_id_ = aer.user_id_
                 left join activity_evaluation ae on aer.evaluation_id_ = ae.id_
-                left join music_sheet ms on ae.music_sheet_id_ = ms.id_
+                left join music_sheet ms on ae.music_sheet_id_ = ms.id_ and find_in_set('PLATFORM',ms.provider_type_)
                 <where>
                     <if test="param.activityId != null">
                         and aer.activity_id_ = #{param.activityId}

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

@@ -34,7 +34,7 @@
 		FROM course_courseware t
         left join music_sheet ms on t.music_sheet_id_ = ms.id_
         <where>
-            t.del_flag_ = 0 AND ms.cbs_music_sheet_id_ IS NOT NULL
+            t.del_flag_ = 0 AND ms.cbs_music_sheet_id_ IS NOT NULL and find_in_set('PLATFORM',ms.provider_type_)
             <if test="param.userId != null">
                 and t.user_id_ = #{param.userId}
             </if>

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

@@ -53,7 +53,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
         ,t2.num as albumFavoriteCount
         <if test="query.userId != null">
@@ -189,7 +189,7 @@
         left join (select count(1) as num,amr.album_id_
             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_)
             group by amr.album_id_) t1 on t1.album_id_ = t.id_
         left join (select count(1) as num,af.album_id_ from album_favorite af
               group by af.album_id_
@@ -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
             ,(
@@ -241,7 +241,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
         ,if(t2.num >0,t2.num,0) as albumFavoriteCount
         from music_album t
@@ -308,6 +308,7 @@
             </if>
             <if test="paymentType != null">
                 AND t2.payment_type_ = #{paymentType}
+                and find_in_set('PLATFORM',t2.provider_type_)
             </if>
         </where>
         GROUP BY t1.album_id_

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

@@ -41,6 +41,12 @@
         <result column="provider_type_" jdbcType="VARCHAR" property="providerType"/>
         <result column="cbs_music_sheet_id_" property="cbsMusicSheetId"/>
         <result column="score_type_" property="scoreType"/>
+        <result column="tenant_sort_number_" property="tenantSortNumber"/>
+        <result column="tenant_state_" property="tenantState"/>
+        <result column="tenant_notation_" property="tenantNotation"/>
+        <result column="tenant_category_id_" property="tenantCategoryId"/>
+        <result column="tenant_score_type_" property="tenantScoreType"/>
+        <result column="tenant_del_flag_" property="tenantCategoryId"/>
     </resultMap>
 
     <sql id="Base_Column_List">
@@ -61,6 +67,8 @@
         t.payment_type_ as paymentType,
         t.provider_type_ as providerType,
         t.state_ as state,
+        t.client_state_ as clientState,
+        t.platform_state_ as platformState,
         t.sort_number_ as sortNumber,
         t.top_flag_ as topFlag,
         t.exquisite_flag_ as exquisiteFlag,
@@ -94,7 +102,13 @@
         t.audit_status_ as auditStatus,
         t.submit_audit_time_ as submitAuditTime,
         t.cbs_music_sheet_id_ as cbsMusicSheetId,
-        t.score_type_ as scoreType
+        t.score_type_ as scoreType,
+        t.tenant_sort_number_ as tenantSortNumber,
+        t.tenant_state_ as tenantState,
+        t.tenant_notation_ as tenantNotation,
+        t.tenant_category_id_ as tenantCategoryId,
+        t.tenant_score_type_ as tenantScoreType,
+        t.tenant_del_flag_ as tenantDelFlag
     </sql>
     <insert id="batchInsert">
         insert into music_sheet
@@ -143,6 +157,12 @@
         </if>
         <where>
             1=1
+            <if test="param.clientState != null">
+                and t.client_state_ = #{param.clientState}
+            </if>
+            <if test="param.platformState != null">
+                and t.platform_state_ = #{param.platformState}
+            </if>
             <if test="param.excludeMusicIds != null and param.excludeMusicIds.size() != 0">
                 and t.id_ not in
                 <foreach collection="param.excludeMusicIds" separator="," item="item" open="(" close=")">
@@ -159,6 +179,12 @@
             <if test="param.auditStatus == null">
                 AND t.cbs_music_sheet_id_ IS NOT NULL
             </if>
+            <if test="param.tenantCategoryIds != null and param.tenantCategoryIds.size() != 0">
+                and t.tenant_category_id_ in
+                <foreach collection="param.tenantCategoryIds" separator="," item="item" open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
             <if test="param.auditVersion != null ">
                 and #{param.auditVersion} = t.audit_version_
             </if>
@@ -204,7 +230,7 @@
             t.composer_ like concat ('%',#{param.search},'%'))
         </if>
         <if test="param.providerType != null">
-            and t.provider_type_ = #{param.providerType}
+            and find_in_set(#{param.providerType},t.provider_type_)
         </if>
         <if test="param.musicTagIds != null and param.musicTagIds != ''">
             and
@@ -231,7 +257,21 @@
             </foreach>
         </if>
         <if test="param.state != null">
-            and t.state_ = #{param.state}
+
+            <if test="param.providerType != null">
+                <if test="param.providerType.code == 'TENANT'">
+                    and t.tenant_state_ = #{param.state}
+                </if>
+
+                <if test="param.providerType.code == 'PLATFORM'">
+                    and t.state_ = #{param.state}
+                </if>
+            </if>
+
+            <if test="param.providerType == null">
+                and t.state_ = #{param.state}
+            </if>
+
         </if>
         <if test="param.auditStatus != null">
             and msar.last_audit_state_ = #{param.auditStatus}
@@ -243,7 +283,20 @@
             and t.create_by_ = #{param.createBy}
         </if>
         <if test="param.delFlag != null">
-            and t.del_flag_ = #{param.delFlag}
+            <if test="param.providerType != null">
+                <if test="param.providerType.code == 'TENANT'">
+                    and t.tenant_del_flag_ = #{param.delFlag}
+                </if>
+
+                <if test="param.providerType.code == 'PLATFORM'">
+                    and t.del_flag_ = #{param.delFlag}
+                </if>
+            </if>
+
+            <if test="param.providerType == null">
+                and t.del_flag_ = #{param.delFlag}
+            </if>
+
         </if>
         <if test="param.sourceType != null">
             and t.source_type_ = #{param.sourceType}
@@ -278,12 +331,12 @@
         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>
             <if test="param.providerType != null">
-                and t.provider_type_ = #{param.providerType}
+                and find_in_set(#{param.providerType},t.provider_type_)
             </if>
             <if test="param.idAndName != null and param.idAndName != ''">
                 and (t.id_ like concat('%',#{param.idAndName},'%') or
@@ -435,6 +488,13 @@
         <result column="musicFirstSvg" jdbcType="VARCHAR" property="musicFirstSvg"/>
         <result column="musicSheetType" jdbcType="VARCHAR" property="musicSheetType"/>
         <result column="musicSheetJson" jdbcType="VARCHAR" property="musicSheetJson"/>
+        <result column="tenantSortNumber" jdbcType="VARCHAR" property="tenantSortNumber"/>
+        <result column="tenantState" jdbcType="VARCHAR" property="tenantState"/>
+        <result column="tenantNotation" jdbcType="VARCHAR" property="tenantNotation"/>
+        <result column="tenantCategoryId" jdbcType="VARCHAR" property="tenantCategoryId"/>
+        <result column="tenantScoreType" jdbcType="VARCHAR" property="tenantScoreType"/>
+        <result column="tenantDelFlag" jdbcType="VARCHAR" property="tenantDelFlag"/>
+        <result column="scoreType" jdbcType="VARCHAR" property="scoreType"/>
         <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
             <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
             <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
@@ -543,11 +603,25 @@
             left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
         </if>
         <where>
-            1=1
-            <include refid="QueryInfo"/>
-            <if test="clientType != null">
-                AND mf.client_type_ = #{clientType}
+
+            mf.client_type_ = #{clientType}
+            <if test="clientType.code == 'STUDENT'">
+                and t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_)
+            </if>
+            <if test="clientType.code == 'TEACHER'">
+                and ((t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_))
+                    <if test="param.tenantId !=null">
+                        or (t.tenant_del_flag_=0 and t.tenant_state_ =1 and find_in_set('TENANT',t.provider_type_)
+                            and t.id_ in (select s.music_sheet_id_ from tenant_album_music s
+                                left join tenant_album s1 on s.tenant_album_id_ = s1.id_ where s.tenant_id_ = #{param.tenantId}
+                                        and s.del_flag_ = 0 and s.subject_type_ in ('ENSEMBLE','MUSIC','SUBJECT') and s1.del_flag_= 0 and s1.status_ = 1
+
+                            )
+                        )
+                    </if>
+                )
             </if>
+
             <if test="param.studentId != null">
                 and mf.user_id_ = #{param.studentId}
             </if>
@@ -746,7 +820,7 @@
             sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
             count(1) as musicSheetCount
         from music_sheet ms
-        where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_)
+        where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_) and find_in_set('PLATFORM',ms.provider_type_)
     </select>
 
     <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
@@ -941,18 +1015,36 @@
         </foreach>
     </update>
     <update id="batchEnable">
-        update music_sheet set state_ = #{status} where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
+        update music_sheet
+        <set>
+            <if test="tenantFlag == 1">
+                tenant_state_ = #{status},
+            </if>
+            <if test="tenantFlag == 0">
+                client_state_ = #{status}
+            </if>
+        </set>
+        where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
     </update>
     <update id="batchDel">
-        update music_sheet set del_flag_ = 1 where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
+        update music_sheet
+        <set>
+            <if test="tenantFlag == 1">
+                tenant_del_flag_ = 1,
+            </if>
+            <if test="tenantFlag == 0">
+                del_flag_ = 1
+            </if>
+        </set>
+         where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
     </update>
     <update id="updateMusicSheet">
         update music_sheet
         set music_sheet_name_ = #{param.name},music_subject_ = #{param.subjectIds},music_svg_ = #{param.musicSvg},
             composer_ = #{param.composer},title_img_ = #{param.musicCover},music_img_ = #{param.musicCover},accompaniment_type_ = #{param.audioType},
-            play_speed_ = #{param.playSpeed},is_all_subject_ = #{param.isAllSubject},
+            play_speed_ = #{param.playSpeed},is_all_subject_ = #{param.isAllSubject},platform_state_ = #{param.platformStatus},
             music_sheet_type_ = #{param.musicSheetType},source_type_ = CASE WHEN #{param.sourceType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TEACHER' END,
-            create_by_ = #{param.userId}
+            create_by_ = #{param.userId},tenant_category_id_ = #{param.musicCategoryId}
         where cbs_music_sheet_id_ = #{param.id}
     </update>
 
@@ -972,7 +1064,6 @@
             left join tenant_album_music tam on t.id_ = tam.music_sheet_id_
         </if>
             <where>
-                t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
                 <if test="param.subjectId != null">
                     and ( t.music_subject_ = #{param.subjectId} or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
                 </if>
@@ -988,7 +1079,16 @@
                     and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
                 </if>
                 <if test="param.providerType != null">
-                    and t.provider_type_ = #{param.providerType}
+                    and find_in_set(#{param.providerType},t.provider_type_)
+                    <if test="param.providerType != null">
+                        <if test="param.providerType.code == 'TENANT'">
+                            and t.tenant_state_ = true and t.tenant_del_flag_ = 0
+                        </if>
+
+                        <if test="param.providerType.code == 'PLATFORM'">
+                            and t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
+                        </if>
+                    </if>
                 </if>
             </where>
         order by t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc
@@ -1058,7 +1158,7 @@
         from music_sheet t
             left join tenant_album_music t1 on t1.music_sheet_id_ = t.id_
         <where>
-            t.del_flag_ = 0 and t.state_ =1  and t.audit_status_ = 'PASS' and t.cbs_music_sheet_id_ is not null
+            t.tenant_del_flag_ = 0 and t.tenant_state_ =1  and t.cbs_music_sheet_id_ is not null
             and t1.del_flag_=0 and t1.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
             <if test="queryInfo.albumId != null">
                 and t1.tenant_album_id_ = #{queryInfo.albumId}
@@ -1079,5 +1179,153 @@
         </where>
 
     </select>
+
+    <update id="updateTenantByCbsId">
+        update music_sheet ms set
+        ms.tenant_sort_number_ = #{item.sortNo},ms.tenant_del_flag_ = 0,
+        ms.tenant_score_type_ = #{item.scoreType},
+        ms.audit_status_ = 'PASS',
+        ms.tenant_state_ = #{item.status},
+        ms.tenant_notation_ = #{item.isConvertibleScore},
+        ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'TENANT'
+        when find_in_set('TENANT',ms.provider_type_) then ms.provider_type_
+        else concat(ms.provider_type_,',','TENANT') end
+        <if test="item.musicSheetUpdate != null">
+            ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
+            ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
+            ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
+            ms.composer_ = #{item.musicSheetUpdate.composer},
+            ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
+            ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
+            ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
+            ms.create_by_ = #{item.musicSheetUpdate.userId},
+            ms.audio_type_ = #{item.musicSheetUpdate.playMode},
+            ms.tenant_category_id_ = #{item.musicSheetUpdate.musicCategoryId},
+            ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
+            ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
+            ms.upload_time_ = #{item.musicSheetUpdate.createTime},
+            ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
+            WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
+        </if>
+        where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
+    </update>
+
+    <update id="updatePlatformByCbsId">
+        update music_sheet ms set
+        ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
+        ms.first_pass_audit_time_ = IF((#{item.musicSheetUpdate.sourceType} = 'PERSON' and ms.first_pass_audit_time_ is null) or !find_in_set('PLATFORM',ms.provider_type_),
+        now(), ms.first_pass_audit_time_),
+        ms.charge_type_ = #{item.paymentType},
+        ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
+        ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
+        ms.audit_status_ = 'PASS',
+        ms.score_type_ = #{item.scoreType},
+        ms.state_ = #{item.status},
+        ms.client_state_ = #{item.clientStatus},
+        ms.notation_ = #{item.isConvertibleScore},
+        ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'PLATFORM'
+                            when find_in_set('PLATFORM',ms.provider_type_) then ms.provider_type_
+                            else concat(ms.provider_type_,',','PLATFORM') end
+        <if test="item.musicSheetUpdate != null">
+            ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name}
+            ,ms.platform_state_ = #{item.musicSheetUpdate.platformStatus},
+            ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
+            ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
+            ms.composer_ = #{item.musicSheetUpdate.composer},
+            ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
+            ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
+            ms.notation_ = #{item.musicSheetUpdate.notation},
+            ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
+            ms.create_by_ = #{item.musicSheetUpdate.userId},
+            ms.audio_type_ = #{item.musicSheetUpdate.playMode},
+            ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
+            ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
+            ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
+            WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
+        </if>
+        where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
+    </update>
+
+    <insert id="tenantInsert">
+        insert into music_sheet
+        (cbs_music_sheet_id_,tenant_sort_number_,tenant_score_type_,tenant_state_,tenant_notation_,tenant_category_id_,tenant_del_flag_
+        ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
+        music_sheet_type_,provider_type_,audio_type_,show_fingering_,
+        can_evaluate_,create_by_,user_id_,audit_status_,upload_time_,source_type_
+        )
+        values
+            (#{item.musicSheetId},
+        #{item.sortNo},#{item.scoreType},#{item.status},#{item.isConvertibleScore}
+        ,#{item.musicSheetUpdate.musicCategoryId}
+            ,#{item.delFlag}
+            ,#{item.musicSheetUpdate.name},
+            #{item.musicSheetUpdate.subjectIds},
+            #{item.musicSheetUpdate.musicSvg},
+            #{item.musicSheetUpdate.composer},
+            #{item.musicSheetUpdate.audioType},
+            #{item.musicSheetUpdate.playSpeed},
+            #{item.musicSheetUpdate.musicSheetType},
+            'TENANT',
+            #{item.musicSheetUpdate.playMode},
+            #{item.musicSheetUpdate.showFingering},
+            #{item.musicSheetUpdate.canEvaluate},
+            #{item.musicSheetUpdate.userId},
+            #{item.musicSheetUpdate.userId},
+            'PASS',
+
+        #{item.musicSheetUpdate.createTime},
+        CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
+        WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
+        ELSE 'TENANT' END
+            )
+    </insert>
+
+    <insert id="platformInsert">
+        insert into music_sheet
+        (cbs_music_sheet_id_,music_tag_,payment_type_,charge_type_,top_flag_,exquisite_flag_,sort_number_,state_,audit_status_
+        ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
+        music_price_,notation_,music_sheet_type_,source_type_,provider_type_,audio_type_,show_fingering_,
+        can_evaluate_,create_by_,user_id_,score_type_,platform_state_,client_state_,first_pass_audit_time_
+        )
+        values
+        (#{item.musicSheetId},
+        #{item.musicTagIds},#{item.paymentType},#{item.paymentType},
+        #{item.topFlag},#{item.exquisiteFlag},#{item.sortNo},0
+        ,'PASS'
+        ,#{item.musicSheetUpdate.name},
+        #{item.musicSheetUpdate.subjectIds},
+        #{item.musicSheetUpdate.musicSvg},
+        #{item.musicSheetUpdate.composer},
+        #{item.musicSheetUpdate.audioType},
+        #{item.musicSheetUpdate.playSpeed},
+        #{item.musicSheetUpdate.musicPrice},
+        #{item.isConvertibleScore},
+        #{item.musicSheetUpdate.musicSheetType},
+        CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
+        WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
+        ELSE 'TENANT' END,
+        'PLATFORM',
+        #{item.musicSheetUpdate.playMode},
+        #{item.musicSheetUpdate.showFingering},
+        #{item.musicSheetUpdate.canEvaluate},
+        #{item.musicSheetUpdate.userId},#{item.musicSheetUpdate.userId},
+        #{item.scoreType},
+        #{item.musicSheetUpdate.platformStatus},
+        #{item.clientStatus},
+        now()
+        )
+    </insert>
+
+    <update id="updateState">
+        update music_sheet
+        set state_ = client_state_ and platform_state_
+        where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
+    </update>
+
+    <update id="delPractice">
+        update sys_music_compare_record
+        set hidden_flag_ = 1
+        where user_id_ = #{userId} and music_sheet_id_ = #{musicSheetId} and client_id_ = #{clientEnum}
+    </update>
     <!--单曲专辑数量统计-->
 </mapper>

+ 18 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetPracticeRecordMapper.xml

@@ -25,12 +25,28 @@
             left join music_sheet_auth_record msar ON msar.music_sheet_id_ = ms.id_
         </if>
         <where>
+            mspr.hidden_flag_ = 0
             <if test="param.auditStatus != null">
                 and msar.last_audit_state_ = #{param.auditStatus}
             </if>
-            <if test="param.state != null">
-                and ms.state_ = #{param.state}
+            <if test="param.clientType != null">
+                and mspr.client_id_ = #{param.clientType}
             </if>
+<!--            <if test="param.providerType.code == 'TENANT'">-->
+<!--                and find_in_set('TENANT',ms.provider_type_)-->
+
+<!--                <if test="param.state != null">-->
+<!--                    and ms.tenant_state_ = #{param.state}-->
+<!--                </if>-->
+<!--            </if>-->
+
+<!--            <if test="param.providerType.code == 'PLATFORM'">-->
+<!--                and find_in_set('PLATFORM',ms.provider_type_)-->
+
+<!--                <if test="param.state != null">-->
+<!--                    and ms.state_ = #{param.state}-->
+<!--                </if>-->
+<!--            </if>-->
             <if test="param.studentId != null">
                 and mspr.user_id_ = #{param.studentId}
             </if>

+ 5 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicTagMapper.xml

@@ -65,10 +65,10 @@
         SELECT
         <include refid="baseColumns" />,
         su.username_ as updateName,
-        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0 and  ms.state_ = 1 and ms.source_type_ = 'PLATFORM') as enablePlatformMusicSheetNum,
-        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0  and ms.source_type_ = 'PLATFORM') as musicPlatformSheetNum,
-        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0 and ms.source_type_ = 'TEACHER' and ms.audit_status_ = 'PASS') as musicTeacherSheetNum,
-        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0  and ms.source_type_ = 'TEACHER' and ms.state_ = 1 and ms.audit_status_ = 'PASS') as enableTeacherMusicSheetNum,
+        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0 and find_in_set('PLATFORM',ms.provider_type_) and  ms.state_ = 1 and ms.source_type_ = 'PLATFORM') as enablePlatformMusicSheetNum,
+        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0 and find_in_set('PLATFORM',ms.provider_type_)  and ms.source_type_ = 'PLATFORM') as musicPlatformSheetNum,
+        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0 and find_in_set('PLATFORM',ms.provider_type_) and ms.source_type_ = 'TEACHER' and ms.audit_status_ = 'PASS') as musicTeacherSheetNum,
+        (select count(1) from music_sheet ms where find_in_set(t.id_,ms.music_tag_) and ms.del_flag_ = 0 and find_in_set('PLATFORM',ms.provider_type_)  and ms.source_type_ = 'TEACHER' and ms.state_ = 1 and ms.audit_status_ = 'PASS') as enableTeacherMusicSheetNum,
         (select count(1) from music_album ma where find_in_set(t.id_,ma.album_tag_) and ma.del_flag_ = 0    and ma.album_status_ = 1) as enablePlatformAlbumNum,
         (select count(1) from music_album ma where find_in_set(t.id_,ma.album_tag_) and ma.del_flag_ = 0 ) as musicPlatformAlbumNum
         FROM music_tag t
@@ -91,7 +91,7 @@
 
         select count(1) from music_sheet ms
         <where>
-            ms.del_flag_ = 0
+            ms.del_flag_ = 0 and find_in_set('PLATFORM',ms.provider_type_)
             <if test="longs != null and longs.size() != 0">
                 and
                 <foreach collection="longs" item="item" open="(" close=")"  separator="or">

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

@@ -37,7 +37,7 @@
                 <if test="type == null or type =='MUSIC'">
                     union all
                     (select a.music_subject_ as subject_id_ from music_sheet a
-                    where a.del_flag_ = 0 and a.state_ = 1 AND a.cbs_music_sheet_id_ IS NOT NULL
+                    where ((a.del_flag_ = 0 and a.state_ = 1) or (a.tenant_del_flag_ =0 and a.tenant_state_ = 1)) AND a.cbs_music_sheet_id_ IS NOT NULL
                     GROUP BY a.music_subject_)
                 </if>
                 <if test="type == null or type =='ALBUM'">

+ 34 - 10
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMusicMapper.xml

@@ -32,10 +32,8 @@
 		FROM music_sheet m
         left join tenant_album_music t on t.music_sheet_id_ = m.id_
         <where>
-            m.state_ = true and m.del_flag_ = 0 and t.del_flag_ = 0 AND m.cbs_music_sheet_id_ IS NOT NULL
-            <if test="param.musicTagId != null ">
-                and (find_in_set(#{param.musicTagId},m.music_tag_))
-            </if>
+            find_in_set('TENANT',m.provider_type_) and
+            m.tenant_state_ = true and m.tenant_del_flag_ = 0 and t.del_flag_ = 0 AND m.cbs_music_sheet_id_ IS NOT NULL
             <if test="param.subjectId != null" >
                 and (find_in_set(#{param.subjectId},m.music_subject_) or m.music_subject_ is null or m.music_subject_ = '' OR m.is_all_subject_)
             </if>
@@ -51,6 +49,12 @@
             <if test="param.albumId != null">
                 and t.tenant_album_id_ = #{param.albumId}
             </if>
+            <if test="param.categoryIds != null and param.categoryIds.size() != 0">
+                and m.tenant_category_id_ in
+                <foreach collection="param.categoryIds" item="item" index="index" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
 
             <if test="param.keyword != null and param.keyword != ''">
                 and m.music_sheet_name_ LIKE CONCAT('%',#{param.keyword},'%')
@@ -86,17 +90,20 @@
         distinct t.music_sheet_id_
         FROM tenant_album_music t
         left join tenant_album_ref t1 on t1.tenant_album_id_ = t.tenant_album_id_
-        left join music_sheet t2 on t2.id_ = t.music_sheet_id_
-        where t2.state_ = 1 and t2.del_flag_ = 0 and t2.audit_version_ = 0 and t1.tenant_id_ = #{tenantId} and t.del_flag_ = 0
+        left join tenant_album t3 on t3.id_ = t1.tenant_album_id_
+        left join music_sheet t2 on t2.id_ = t.music_sheet_id_  and find_in_set('TENANT',t2.provider_type_)
+        where t2.tenant_state_ = 1 and t2.tenant_del_flag_ = 0 and t1.tenant_id_ = #{tenantId} and t.del_flag_ = 0
+         and t3.del_flag_=0 and t3.status_ = 1
     </select>
 
     <select id="getByAlbumAndEnable" resultType="com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic">
         select
         t.*
         from tenant_album_music t
-        left join music_sheet t1 on t.music_sheet_id_ = t1.id_
+        left join music_sheet t1 on t.music_sheet_id_ = t1.id_  and find_in_set('TENANT',t1.provider_type_)
         where
-        t.del_flag_ = 0 and ((t1.state_ = 1 and t1.del_flag_ = 0 and t.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')) or t.subject_type_ not in ('ENSEMBLE', 'MUSIC', 'SUBJECT'))
+        t.del_flag_ = 0 and ((t1.tenant_state_ = 1 and t1.tenant_del_flag_ = 0 and t.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT'))
+            or t.subject_type_ not in ('ENSEMBLE', 'MUSIC', 'SUBJECT'))
         and t.tenant_album_id_ in
         <foreach collection="tenantAlbumIds" item="item" index="index" open="(" close=")" separator=",">
             #{item}
@@ -107,9 +114,9 @@
         select
         t.*
         from tenant_album_music t
-        left join music_sheet m on t.music_sheet_id_ = m.id_
+        left join music_sheet m on t.music_sheet_id_ = m.id_ and find_in_set('TENANT',m.provider_type_)
         where
-        t.del_flag_ = 0
+        t.del_flag_ = 0 and m.tenant_del_flag_ =0 and m.tenant_state_ =1
         <if test="param.tenantAlbumId != null">
             and t.tenant_album_id_ = #{param.tenantAlbumId}
         </if>
@@ -127,4 +134,21 @@
             or t.subject_type_ not in  ('ENSEMBLE', 'MUSIC', 'SUBJECT') OR m.is_all_subject_)
         </if>
     </select>
+
+    <select id="getTenantAlbumMusicIdsByIds" resultType="java.lang.Long">
+        select
+        distinct t.music_sheet_id_
+        from tenant_album_music t
+        left join music_sheet t1 on t1.id_ = t.music_sheet_id_ and find_in_set('TENANT',t1.provider_type_)
+        where t.del_flag_ = 0
+        and t.tenant_album_id_ in
+        <foreach collection="tenantAlbumIds" item="item" index="index" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        and ( t.subject_type_ in  ('ENSEMBLE', 'MUSIC', 'SUBJECT') and t1.tenant_del_flag_ =0 and t1.tenant_state_ = 1)
+        and t.subject_type_ in
+        <foreach collection="subjectTypes" item="item" index="index" open="(" close=")" separator=",">
+            #{item.code}
+        </foreach>
+    </select>
 </mapper>

+ 1 - 1
pom.xml

@@ -23,7 +23,7 @@
 		<google.zxing.version>3.4.0</google.zxing.version>
 		<redisson.version>3.11.5</redisson.version>
 		<maven.test.skip>true</maven.test.skip>
-		<cbs.version>1.0.13</cbs.version>
+		<cbs.version>1.0.15</cbs.version>
 		<microsvc.version>1.0.8</microsvc.version>
 	</properties>