Browse Source

曲目同步

liujc 7 months ago
parent
commit
107ab5ef5b
18 changed files with 603 additions and 96 deletions
  1. 148 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantMusicSheetApplicationExtendController.java
  2. 8 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/MusicSheetController.java
  3. 6 0
      cooleshow-common/src/main/java/com/yonge/cooleshow/common/constant/SysConfigConstant.java
  4. 11 3
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/MusicSheetDao.java
  5. 3 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/MusicSheetSearch.java
  6. 35 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/MusicSheet.java
  7. 2 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/MusicSheetService.java
  8. 67 46
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CbsMusicSheetServiceImpl.java
  9. 46 3
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java
  10. 44 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/MusicSheetWrapper.java
  11. 4 4
      cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityEvaluationMapper.xml
  12. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityRegistrationMapper.xml
  13. 198 10
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml
  14. 14 2
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetPracticeRecordMapper.xml
  15. 5 5
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicTagMapper.xml
  16. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/SubjectMapper.xml
  17. 9 16
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMusicMapper.xml
  18. 1 1
      pom.xml

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

@@ -0,0 +1,148 @@
+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.CbsMusicSheetApplicationExtendClientWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetCategoryWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
+import com.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.service.MusicSheetService;
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
+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("/tenantMusicSheetApplicationExtend")
+@Api(tags = "曲目应用拓展表")
+public class TenantMusicSheetApplicationExtendController {
+
+    @Autowired
+    private MusicFeignClientService musicFeignClientService;
+
+
+    @Autowired
+    private CbsMusicSheetService cbsMusicSheetService;
+
+    @Autowired
+    private OpenFeignClientConfigProperties openFeignClientConfigProperties;
+
+    @Autowired
+    private MusicSheetService musicSheetService;
+
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/pageByApplication')")
+    @PostMapping({"/pageByApplication"})
+    public R<PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> musicSheetPageByApplication(@RequestBody CbsMusicSheetWrapper.MusicSheetApplicationQuery var1){
+
+        return R.from(musicSheetService.tenantPage(var1));
+    }
+
+
+    @PreAuthorize("@pcs.hasPermissions('tenantMusicSheetApplicationExtend/page')")
+    @PostMapping({"/page"})
+    public R<PageInfo<CbsMusicSheetWrapper.MusicSheet>> musicSheetPage(@RequestBody CbsMusicSheetWrapper.MusicSheetQuery var1){
+
+        String cbsTenantAppId = sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID);
+        // 更新数据
+        var1.setAddAppId(Long.parseLong(cbsTenantAppId));
+        try {
+
+            return R.from(this.musicFeignClientService.musicSheetPage(var1).feignData());
+        }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 = "应用分类列表")
+    @PostMapping("/categoryList")
+    public R<List<CbsMusicSheetCategoryWrapper.MusicSheetCategory>> categoryList() {
+
+        return R.from(cbsMusicSheetService.categoryList(new CbsMusicSheetCategoryWrapper.MusicSheetCategoryQuery()));
+
+    }
+
+    @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());
+
+    }
+
+}

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

@@ -304,7 +304,15 @@ 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.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);

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

@@ -455,4 +455,10 @@ public interface SysConfigConstant {
      * 默认曲目所属人
      */
     String DEFAULT_MUSIC_USER_ID = "default_music_user_id";
+
+    /**
+     * 内容平台机构应用ID
+     */
+    String CBS_TENANT_APP_ID = "cbs_tenant_app_id";
+
 }

+ 11 - 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,12 @@ 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);
 }

+ 3 - 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,6 +20,7 @@ import java.util.stream.Collectors;
  * @author: liujunchi
  * @date: 2022-03-30
  */
+@Data
 @ApiModel(value = "MusicSheetSearch对象", description = "曲目表查询对象")
 public class MusicSheetSearch  extends QueryInfo{
 
@@ -46,7 +47,7 @@ public class MusicSheetSearch  extends QueryInfo{
 
 
     @ApiModelProperty(value = "提供方 TENANT 机构 PLATFORM 平台")
-    private SourceTypeEnum providerType;
+    private SourceTypeEnum providerType = SourceTypeEnum.PLATFORM;
 
 
     @ApiModelProperty("曲目状态(0:停用,1:启用))")

+ 35 - 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位!")
@@ -272,6 +272,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 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/MusicSheetService.java

@@ -10,7 +10,6 @@ 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.vo.*;
@@ -418,4 +417,6 @@ public interface MusicSheetService extends IService<MusicSheet> {
     List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
 
     IPage<MusicSheetVo> queryTenantRelatedList(IPage<Object> page, MusicSheetRelatedQueryInfo queryInfo);
+
+    com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplication> tenantPage(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
 }

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

@@ -17,7 +17,9 @@ 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.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @Service
@@ -45,54 +48,55 @@ 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;
+            DistributedLock.of(redissonClient).runIfLockCanGet("musicSheetUpdate:" + musicSheetUpdate.getId(), () -> {
+                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 {
-                    musicSheetUpdate.setUserId(userId);
+                    if (extend.getApplicationId() !=null && cbsTenantAppId.equals(extend.getApplicationId().toString())) {
+
+                        musicSheetService.getDao().tenantInsert(extend);
+                    } else {
+                        musicSheetService.getDao().platformInsert(extend);
+                    }
                 }
-            } 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);
+            },5L, TimeUnit.MINUTES);
+
         }
+
         return true;
     }
 
@@ -103,7 +107,13 @@ 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);
+        }
         return true;
     }
 
@@ -111,7 +121,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 +149,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 +177,5 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
         } else {
             musicSheetUpdate.setUserId(userId);
         }
-        musicSheetService.getDao().updateMusicSheet(musicSheetUpdate);
-        return true;
     }
 }

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

@@ -1859,6 +1859,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 +1978,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);
@@ -2202,7 +2203,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());
@@ -2373,6 +2374,48 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         return musicSheetDao.queryTenantRelatedList(page,queryInfo);
     }
 
+    @Override
+    public PageInfo<CbsMusicSheetWrapper.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();
+            List<CbsMusicSheetWrapper.MusicSheetApplication> rows = feignedData.getRows();
+            if (CollectionUtils.isEmpty(rows)) {
+                return feignedData;
+            }
+            // 查询曲目对应的业务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());
+
+
+            feignedData.setRows(rows);
+            return feignedData;
+        } 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("内容平台服务异常");
+        }
+    }
+
+    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 +2571,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));

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

@@ -862,4 +862,48 @@ 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;
+
+    }
 }

+ 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}

+ 198 - 10
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">
@@ -94,7 +100,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
@@ -204,7 +216,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 +243,21 @@
             </foreach>
         </if>
         <if test="param.state != null">
-            and t.state_ = #{param.state}
+
+            <if test="param.providerType != null">
+                <if test="param.providerType == 'TENANT'">
+                    and t.tenant_state_ = #{param.state}
+                </if>
+
+                <if test="param.providerType == '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 +269,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 == 'TENANT'">
+                    and t.tenant_del_flag_ = #{param.delFlag}
+                </if>
+
+                <if test="param.providerType == '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}
@@ -283,7 +322,7 @@
                 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 +474,12 @@
         <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"/>
         <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"/>
@@ -940,10 +985,28 @@
         </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">
+                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
@@ -951,7 +1014,7 @@
             composer_ = #{param.composer},title_img_ = #{param.musicCover},music_img_ = #{param.musicCover},accompaniment_type_ = #{param.audioType},
             play_speed_ = #{param.playSpeed},is_all_subject_ = #{param.isAllSubject},
             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>
 
@@ -987,7 +1050,7 @@
                     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>
             </where>
         order by t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc
@@ -1057,7 +1120,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}
@@ -1078,5 +1141,130 @@
         </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 'PLATFORM'
+        when find_in_set(#{item.availableType},ms.provider_type_) then ms.provider_type_
+        else concat(ms.provider_type_,',',#{item.availableType}) 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.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.notation_ = #{item.isConvertibleScore},
+        ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'PLATFORM'
+                            when find_in_set(#{item.availableType},ms.provider_type_) then ms.provider_type_
+                            else concat(ms.provider_type_,',',#{item.availableType}) 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.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_
+        ,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_
+        )
+        values
+            (#{item.musicSheetId},
+        #{item.sortNo},#{item.scoreType},#{item.status},#{item.isConvertibleScore}
+        ,#{item.musicSheetUpdate.musicCategoryId}
+            ,#{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}
+            )
+    </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_
+        )
+        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}
+        )
+    </insert>
     <!--单曲专辑数量统计-->
 </mapper>

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

@@ -28,8 +28,20 @@
             <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.providerType == '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 == '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}

+ 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'">

+ 9 - 16
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMusicMapper.xml

@@ -32,22 +32,14 @@
 		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>
             <if test="param.subjectType != null">
                 and t.subject_type_ = #{param.subjectType}
             </if>
-            <if test="param.level != null and param.level != ''">
-                and t.level_ = #{param.level}
-            </if>
-            <if test="param.type != null and param.type != ''">
-                and t.type_ = #{param.type}
-            </if>
             <if test="param.albumId != null">
                 and t.tenant_album_id_ = #{param.albumId}
             </if>
@@ -86,17 +78,18 @@
         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 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 t2.audit_version_ = 0 and t1.tenant_id_ = #{tenantId} and t.del_flag_ = 0
     </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 +100,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>

+ 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>