Browse Source

Merge branch 'zx_saas_cbs' of http://git.dayaedu.com/yonge/mec into dev

# Conflicts:
#	pom.xml
zouxuan 1 year ago
parent
commit
9a65e385f4
33 changed files with 1699 additions and 613 deletions
  1. 3 43
      mec-application/src/main/java/com/ym/mec/teacher/controller/SysMusicScoreController.java
  2. 185 0
      mec-application/src/main/java/com/ym/mec/web/controller/MusicSheetApplicationExtendController.java
  3. 117 13
      mec-application/src/main/java/com/ym/mec/web/controller/SubjectController.java
  4. 42 57
      mec-application/src/main/java/com/ym/mec/web/controller/SysMusicScoreController.java
  5. 25 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/InstrumentDao.java
  6. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SubjectDao.java
  7. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysMusicScoreAccompanimentDao.java
  8. 2 10
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysMusicScoreDao.java
  9. 48 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReasonDto.java
  10. 0 44
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SysMusicScoreMetronomeTranscod.java
  11. 0 47
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SysMusicScoreTranscod.java
  12. 55 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Instrument.java
  13. 7 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Subject.java
  14. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicScore.java
  15. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicScoreAccompaniment.java
  16. 123 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/InstrumentWrapper.java
  17. 25 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/MusicSheetWrapper.java
  18. 268 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/SubjectWrapper.java
  19. 59 0
      mec-biz/src/main/java/com/ym/mec/biz/service/InstrumentService.java
  20. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SubjectService.java
  21. 9 11
      mec-biz/src/main/java/com/ym/mec/biz/service/SysMusicScoreService.java
  22. 6 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CbsMusicSheetServiceImpl.java
  23. 219 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/InstrumentServiceImpl.java
  24. 116 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectServiceImpl.java
  25. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java
  26. 11 15
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreAccompanimentServiceImpl.java
  27. 218 321
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreServiceImpl.java
  28. 39 0
      mec-biz/src/main/resources/config/mybatis/InstrumentMapper.xml
  29. 97 3
      mec-biz/src/main/resources/config/mybatis/SubjectMapper.xml
  30. 4 1
      mec-biz/src/main/resources/config/mybatis/SysMusicScoreAccompanimentMapper.xml
  31. 3 35
      mec-biz/src/main/resources/config/mybatis/SysMusicScoreMapper.xml
  32. 1 1
      mec-common/audit-log/src/main/java/com/yonge/log/interceptor/AuditLogInterceptor.java
  33. 1 1
      pom.xml

+ 3 - 43
mec-application/src/main/java/com/ym/mec/teacher/controller/SysMusicScoreController.java

@@ -1,17 +1,14 @@
 package com.ym.mec.teacher.controller;
 
-import com.ym.mec.biz.dal.dto.MusicScoreDto;
-import com.ym.mec.biz.dal.entity.SysMusicScore;
 import com.ym.mec.biz.dal.enums.ClientTypeEnum;
-import com.ym.mec.biz.dal.enums.ExamSongTypeEnum;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.biz.service.SysMusicScoreService;
-import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 
@@ -22,43 +19,6 @@ public class SysMusicScoreController extends BaseController {
 
     @Resource
     private SysMusicScoreService sysMusicScoreService;
-    @Resource
-    private SysUserService sysUserService;
-
-    @ApiOperation(value = "新增")
-    @PostMapping("/add")
-    public Object add(@RequestBody MusicScoreDto musicScoreDto) {
-        SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
-        sysMusicScore.setType(ExamSongTypeEnum.PERSON);
-        if(sysMusicScore.getClientType() == null){
-            sysMusicScore.setClientType(ClientTypeEnum.NETWORK_ROOM);
-        }
-        sysMusicScore.setShowFlag(1);
-        sysMusicScoreService.add(musicScoreDto);
-        return succeed();
-    }
-
-    @ApiOperation(value = "删除")
-    @PostMapping("/del")
-    public Object del(Integer id) {
-        sysMusicScoreService.del(id);
-        return succeed();
-    }
-
-    @ApiOperation(value = "分页查询")
-    @GetMapping("/queryPage")
-    public Object queryPage(SysExamSongQueryInfo queryInfo) {
-        String type = queryInfo.getType();
-        if(StringUtils.isEmpty(type)){
-            queryInfo.setType("ALL");
-        }
-        if(queryInfo.getClientType() == null){
-            queryInfo.setClientType(ClientTypeEnum.NETWORK_ROOM);
-        }
-        queryInfo.setCreateUserId(sysUserService.getUserId());
-        queryInfo.setShowFlag(1);
-        return succeed(sysMusicScoreService.queryPage(queryInfo));
-    }
 
     @ApiOperation(value = "分页查询")
     @GetMapping("/queryPage2")

+ 185 - 0
mec-application/src/main/java/com/ym/mec/web/controller/MusicSheetApplicationExtendController.java

@@ -0,0 +1,185 @@
+package com.ym.mec.web.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.ym.mec.biz.dal.entity.SysMusicScore;
+import com.ym.mec.biz.service.SysMusicScoreService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+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:}/musicSheetApplicationExtend")
+@Api(tags = "曲目应用拓展表")
+public class MusicSheetApplicationExtendController {
+
+    @Resource
+    private MusicFeignClientService musicFeignClientService;
+
+
+    @Resource
+    private CbsMusicSheetService cbsMusicSheetService;
+
+    @Resource
+    private OpenFeignClientConfigProperties openFeignClientConfigProperties;
+
+    @Resource
+    private SysMusicScoreService sysMusicScoreService;
+
+    @PreAuthorize("@pcs.hasPermissions('musicSheetApplicationExtend/pageByApplication')")
+    @PostMapping({"/pageByApplication"})
+    public R<PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> musicSheetPageByApplication(@RequestBody CbsMusicSheetWrapper.MusicSheetApplicationQuery var1) {
+        var1.setApplicationId(Long.parseLong(openFeignClientConfigProperties.getAppId()));
+        try {
+            PageInfo<CbsMusicSheetWrapper.MusicSheetApplication> feignedData = this.musicFeignClientService.musicSheetPageByApplication(var1).feignData();
+            List<CbsMusicSheetWrapper.MusicSheetApplication> rows = feignedData.getRows();
+            if (CollectionUtils.isEmpty(rows)) {
+                return R.from(feignedData);
+            }
+            List<Long> cbsMusicIds = rows.stream().map(CbsMusicSheetWrapper.MusicSheetApplication::getId).collect(Collectors.toList());
+            List<SysMusicScore> musicSheetList = sysMusicScoreService.getDao().findByCbsId(cbsMusicIds);
+            Map<String, SysMusicScore> map = musicSheetList.stream().collect(Collectors.toMap(SysMusicScore::getCbsMusicSheetId, o -> o, (o1, o2) -> o1));
+
+            for (CbsMusicSheetWrapper.MusicSheetApplication row : rows) {
+                SysMusicScore musicSheet = map.get(row.getId().toString());
+                if (Objects.nonNull(musicSheet)) {
+                    row.setBizId(musicSheet.getId().longValue());
+                }
+            }
+            feignedData.setRows(rows);
+            return R.from(feignedData);
+        } catch (Exception e) {
+            log.error("查询曲目应用拓展表异常", e);
+            if (e instanceof BizException) {
+                throw e;
+            }
+            throw BizException.from("内容平台服务异常");
+        }
+    }
+
+
+    @ApiOperation(value = "修改应用扩展信息", notes = "曲目应用拓展表- 传入 MusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend")
+    @PreAuthorize("@pcs.hasPermissions('musicSheetApplicationExtend/update')")
+    @PostMapping("/update")
+    public R<JSONObject> update(@RequestBody CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend addMusicSheetApplicationExtend) {
+
+        // 更新数据
+        addMusicSheetApplicationExtend.setApplicationId(Long.parseLong(openFeignClientConfigProperties.getAppId()));
+        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('musicSheetApplicationExtend/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('musicSheetApplicationExtend/saveBatch')")
+    @PostMapping("/saveBatch")
+    public R<JSONObject> saveBatch(@RequestBody List<CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend> list) {
+
+        if (CollectionUtils.isEmpty(list)) {
+            throw BizException.from("参数错误");
+        }
+        for (CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend addMusicSheetApplicationExtend : list) {
+            addMusicSheetApplicationExtend.setApplicationId(Long.parseLong(openFeignClientConfigProperties.getAppId()));
+        }
+        // 更新数据
+        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<CbsMusicSheetCategoryWrapper.MusicSheetCategory>> categoryList() {
+
+        return R.from(cbsMusicSheetService.categoryList(new CbsMusicSheetCategoryWrapper.MusicSheetCategoryQuery()));
+
+    }
+
+    @ApiOperation(value = "所属人信息查询")
+    @PostMapping("/ownerList")
+    public R<PageInfo<CbsMusicSheetExtendWrapper.MusicSheetExtend>> ownerList(@RequestBody CbsMusicSheetExtendWrapper.MusicSheetExtendQuery queryInfo) {
+
+        return R.from(cbsMusicSheetService.ownerList(queryInfo));
+    }
+
+    @ApiOperation(value = "查询曲目适用项目的扩展信息")
+    @PostMapping("/applicationExtendInfo")
+    public R<CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtend> applicationExtendInfo(@RequestBody @Validated CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendQuery query) {
+        if (query == null || query.getMusicSheetId() == null) {
+            throw BizException.from("参数错误");
+        }
+        query.setApplicationId(Long.parseLong(openFeignClientConfigProperties.getAppId()));
+        R<List<CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtend>> listR = musicFeignClientService.musicSheetApplicationExtendApplicationExtendInfo(query);
+        List<CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtend> data = listR.feignData();
+        if (CollectionUtils.isNotEmpty(data)) {
+            return R.from(data.get(0));
+        } else {
+            throw new BizException("扩展信息不存在");
+        }
+    }
+
+}

+ 117 - 13
mec-application/src/main/java/com/ym/mec/web/controller/SubjectController.java

@@ -1,29 +1,48 @@
 package com.ym.mec.web.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.musicInstrument.CbsMusicalInstrumentWrapper;
+import com.microsvc.toolkit.common.webportal.exception.BizException;
+import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
+import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
 import com.ym.mec.biz.dal.page.SubjectQueryInfo;
+import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
+import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
 import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.*;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.web:}/subject")
 @Api(tags = "科目服务")
 @RestController
+@Slf4j
 public class SubjectController extends BaseController {
 
-    @Autowired
+    @Resource
     private SubjectService subjectService;
+    @Resource
+    private MusicFeignClientService musicFeignClientService;
 
     @ApiOperation(value = "修改、新增科目")
     @PostMapping("/upset")
     @PreAuthorize("@pcs.hasPermissions('subject/upset')")
-    public Object update(@RequestBody Subject subject){
+    public HttpResponseResult<Object> update(@RequestBody Subject subject){
         subjectService.upSetSubject(subject);
         return succeed();
     }
@@ -31,21 +50,21 @@ public class SubjectController extends BaseController {
     @ApiOperation(value = "根据科目编号查询科目")
     @GetMapping("/get/{id}")
     @PreAuthorize("@pcs.hasPermissions('subject/get')")
-    public Object get(@ApiParam(value = "科目编号", required = true) @PathVariable("id") Integer id){
+    public HttpResponseResult<Subject> get(@ApiParam(value = "科目编号", required = true) @PathVariable("id") Integer id){
         return succeed(subjectService.get(id));
     }
 
     @ApiOperation(value = "分页查询科目列表")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('subject/queryPage')")
-    public Object queryPage(SubjectQueryInfo queryInfo){
+    public HttpResponseResult<PageInfo<Subject>> queryPage(SubjectQueryInfo queryInfo){
         return succeed(subjectService.queryPage(queryInfo));
     }
 
     @ApiOperation(value = "分页查询科目树状列表")
     @GetMapping("/queryPageTree")
     @PreAuthorize("@pcs.hasPermissions('subject/queryPageTree')")
-    public Object queryPageTree(SubjectQueryInfo queryInfo){
+    public HttpResponseResult<PageInfo<Subject>> queryPageTree(SubjectQueryInfo queryInfo){
         return succeed(subjectService.queryPageTree(queryInfo));
     }
 
@@ -53,7 +72,7 @@ public class SubjectController extends BaseController {
     @GetMapping("/querySubByMusicGroupId")
     @PreAuthorize("@pcs.hasPermissions('subject/querySubByMusicGroupId')")
     @ApiImplicitParams({ @ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "String")})
-    public Object findSubByMusicGroupId(String musicGroupId){
+    public HttpResponseResult<List<Subject>> findSubByMusicGroupId(String musicGroupId){
         return succeed(subjectService.findSubByMusicGroupId(musicGroupId));
     }
 
@@ -61,14 +80,14 @@ public class SubjectController extends BaseController {
     @GetMapping("/setSubjectInfo")
     @PreAuthorize("@pcs.hasPermissions('subject/setSubjectInfo')")
     @ApiImplicitParams({ @ApiImplicitParam(name = "chargeTypeId", value = "收费类型编号", required = true, dataType = "Integer")})
-    public Object setSubjectInfo(Integer chargeTypeId){
+    public HttpResponseResult<SubFeeSettingDto> setSubjectInfo(Integer chargeTypeId){
         return succeed(subjectService.setSubjectInfo(chargeTypeId));
     }
 
     @ApiOperation(value = "修改、新增声部关联的商品列表")
     @PostMapping("/markGoods")
     @PreAuthorize("@pcs.hasPermissions('subject/markGoods')")
-    public Object markGoods(@RequestBody List<SubjectGoodsMapper> subjectGoodsMappers){
+    public HttpResponseResult<Object> markGoods(@RequestBody List<SubjectGoodsMapper> subjectGoodsMappers){
         subjectService.markGoods(subjectGoodsMappers);
         return succeed();
     }
@@ -77,28 +96,113 @@ public class SubjectController extends BaseController {
     @GetMapping("/findSubApplyDetail")
     @PreAuthorize("@pcs.hasPermissions('subject/findSubApplyDetail')")
     @ApiImplicitParams({ @ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "String")})
-    public Object findSubApplyDetail(String musicGroupId){
+    public HttpResponseResult<List<SubjectApplyDetailDto>> findSubApplyDetail(String musicGroupId){
         return succeed(subjectService.findSubApplyDetail(musicGroupId));
     }
 
     @ApiOperation(value = "获取子集科目列表按父Id")
     @GetMapping("/findSubSubjects")
     @PreAuthorize("@pcs.hasPermissions('subject/findSubSubjects')")
-    public Object findSubSubjects(Integer parentSubjectId){
+    public HttpResponseResult<List<Subject>> findSubSubjects(Integer parentSubjectId){
         return succeed(subjectService.findSubSubjects(parentSubjectId));
     }
 
     @ApiOperation(value = "搜索按Id和名称")
     @PostMapping("/queryPageByIdOrName")
     @PreAuthorize("@pcs.hasPermissions('subject/queryPageByIdOrName')")
-    public Object queryPageByIdOrName(SubjectQueryInfo queryInfo){
+    public HttpResponseResult<PageInfo<Subject>> queryPageByIdOrName(SubjectQueryInfo queryInfo){
         return succeed(subjectService.queryPageByIdOrName(queryInfo));
     }
 
     @ApiOperation(value = "列出所有分部")
     @PostMapping("/list")
     // @PreAuthorize("@pcs.hasPermissions('subject/list')")
-    public Object list(){
+    public HttpResponseResult<List<Subject>> list(){
         return succeed(subjectService.list());
     }
+
+
+    /**
+     * 声部分页
+     */
+    @ApiOperation(value = "内容平台对应的声部数据")
+    @PostMapping("/cbsSubject/page")
+    public HttpResponseResult<List<SubjectWrapper.CbsSubject>> subjectPage(@RequestBody SubjectWrapper.CbsSubjectQuery query){
+        // 移除已被使用的声部ID
+        if (Boolean.TRUE.equals(query.getRemoveUsed())) {
+            List<Subject> list = subjectService.getDao().notInSubjectIds(query.getSubjectId());
+            if (CollectionUtils.isNotEmpty(list)) {
+                List<Long> cbsSubjectIds = list.stream().map(Subject::getCbsSubjectId).filter(Objects::nonNull).map(Integer::longValue).distinct().collect(Collectors.toList());
+                if (CollectionUtils.isNotEmpty(cbsSubjectIds)) {
+                    query.setRemoveIds(cbsSubjectIds);
+                }
+            }
+        }
+
+        try {
+            query.setPage(1);
+            query.setRows(-1);
+            Subject sb = subjectService.getDao().get(query.getSubjectId());
+            if (sb == null || sb.getCbsSubjectId() == null) {
+                throw new com.ym.mec.common.exception.BizException("声部数据不存在");
+            }
+            query.setIds(Collections.singletonList(sb.getCbsSubjectId().longValue()));
+            List<CbsSubjectWrapper.Subject> subjectPageInfo = musicFeignClientService.subjectPage(query).feignData().getRows();
+            if (CollectionUtils.isEmpty(subjectPageInfo)) {
+                return succeed(new ArrayList<>());
+            }
+            List<Integer> subjectIds = subjectPageInfo.stream().map(CbsSubjectWrapper.Subject::getId).map(Long::intValue).collect(Collectors.toList());
+
+            // 查询乐器信息
+            CbsMusicalInstrumentWrapper.MusicalInstrumentQuery musicalInstrumentQuery = new CbsMusicalInstrumentWrapper.MusicalInstrumentQuery();
+            musicalInstrumentQuery.setSubjectIds(subjectIds);
+            musicalInstrumentQuery.setPage(1);
+            musicalInstrumentQuery.setRows(9999);
+            List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> rows = musicFeignClientService
+                    .musicalInstrumentPage(musicalInstrumentQuery).feignData().getRows();
+            Map<Long, List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto>> subjectIdMap = rows.stream()
+                    .collect(Collectors.groupingBy(o -> o.getSubjectId().longValue(), LinkedHashMap::new, Collectors.toList()));
+
+            // 查询本地已经添加过的曲目数据
+            SubjectWrapper.SubjectQuery query1 = new SubjectWrapper.SubjectQuery();
+            query1.setHasInstrument(true);
+            List<SubjectWrapper.Subject> list = subjectService.queryList(query1);
+            // 转map
+            Map<Long, SubjectWrapper.Subject> subjectMap = list.stream().collect(Collectors.groupingBy(SubjectWrapper.Subject::getCbsSubjectId, Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
+
+            List<SubjectWrapper.CbsSubject> cbsSubjects = new ArrayList<>();
+            for (CbsSubjectWrapper.Subject subject : subjectPageInfo) {
+                SubjectWrapper.CbsSubject cbsSubject = new SubjectWrapper.CbsSubject();
+                BeanUtils.copyProperties(subject, cbsSubject);
+
+                List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> musicalInstrumentQueryDtos = subjectIdMap.get(cbsSubject.getId());
+                if (CollectionUtils.isEmpty(musicalInstrumentQueryDtos)) {
+                    continue;
+                }
+                cbsSubject.setInstruments(JSON.parseArray(JSON.toJSONString(musicalInstrumentQueryDtos), SubjectWrapper.Instrument.class));
+
+                cbsSubjects.add(cbsSubject);
+                // 本地已经添加过的曲目数据
+                SubjectWrapper.Subject subject1 = subjectMap.get(subject.getId());
+                if (subject1 == null) {
+                    continue;
+                }
+                List<InstrumentWrapper.Instrument> instruments = subject1.getInstruments();
+                if (CollectionUtils.isEmpty(instruments)) {
+                    continue;
+                }
+                // instruments 转map
+                Map<Integer, InstrumentWrapper.Instrument> instrumentMap = instruments.stream().collect(Collectors.toMap(InstrumentWrapper.Instrument::getId, o -> o));
+                for (SubjectWrapper.Instrument instrument : cbsSubject.getInstruments()) {
+                    instrument.setAdded(instrumentMap.containsKey(instrument.getId()));
+                }
+
+            }
+
+            return succeed(cbsSubjects);
+        } catch (Exception e) {
+            log.error("内容平台对应的声部数据查询失败", e);
+            throw BizException.from("内容平台服务异常");
+        }
+    }
 }

+ 42 - 57
mec-application/src/main/java/com/ym/mec/web/controller/SysMusicScoreController.java

@@ -1,8 +1,10 @@
 package com.ym.mec.web.controller;
 
+import com.dayaedu.cbs.domain.wrapper.MusicSheetWrapper;
+import com.ym.mec.biz.dal.dto.ReasonDto;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
-import com.ym.mec.biz.dal.entity.SysMusicScoreCategories;
 import com.ym.mec.biz.dal.enums.ClientTypeEnum;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.biz.service.SysMusicScoreService;
 import com.ym.mec.common.controller.BaseController;
@@ -10,14 +12,13 @@ import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 @RequestMapping("${app-config.url.web:}/sysMusicScore")
 @Api(tags = "曲库")
@@ -27,46 +28,14 @@ public class SysMusicScoreController extends BaseController {
     @Resource
     private SysMusicScoreService sysMusicScoreService;
 
-    /*@ApiOperation(value = "修改")
+    @ApiOperation(value = "修改应用扩展信息")
+    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/update', {'BACKEND'})")
     @PostMapping("/update")
-    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/update')")
-    public Object update(@RequestBody MusicScoreDto musicScoreDto) {
-        sysMusicScoreService.updateMusicScore(musicScoreDto);
-        return succeed();
-    }*/
-
-    @ApiOperation(value = "修改样式")
-    @PostMapping("/updateExtStyleConfigJson")
-    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/updateExtStyleConfigJson')")
-    public Object updateExtStyleConfigJson(Integer sysMusicScoreId,String extStyleConfigJson) {
-        sysMusicScoreService.updateExtStyleConfigJson(sysMusicScoreId, extStyleConfigJson);
-        return succeed();
-    }
-
-    @ApiOperation(value = "启用/停用")
-    @PostMapping("/show")
-    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/show')")
-    public HttpResponseResult<Object> update(Integer sysMusicScoreId, Integer showFlag) {
-        sysMusicScoreService.enable(sysMusicScoreId, showFlag);
+    public HttpResponseResult<Object> update(@RequestBody MusicSheetWrapper.MusicSheetApplicationExtendWrapper addMusicSheetApplicationExtend) {
+        sysMusicScoreService.updateCbs(addMusicSheetApplicationExtend);
         return succeed();
     }
 
-    /*@ApiOperation(value = "新增")
-    @PostMapping("/add")
-    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/add')")
-    public Object add(@RequestBody MusicScoreDto musicScoreDto) {
-        sysMusicScoreService.add(musicScoreDto);
-        return succeed();
-    }*/
-
-/*    @ApiOperation(value = "删除")
-    @PostMapping("/del")
-    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/del')")
-    public Object del(Integer id) {
-        sysMusicScoreService.del(id);
-        return succeed();
-    }*/
-
     @ApiOperation(value = "分页查询")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('sysMusicScore/queryPage')")
@@ -80,25 +49,41 @@ public class SysMusicScoreController extends BaseController {
         queryInfo.setType("COMMON");
         queryInfo.setShowFlag(1);
         queryInfo.setClientType(ClientTypeEnum.SMART_PRACTICE);
-//        return succeed(sysMusicScoreService.queryMusicScorePageInfo(queryInfo));
         return succeed(sysMusicScoreService.queryMusicScorePage(queryInfo));
     }
-    
-    private void getAllCategoryIdList(List<Integer> categoryIdList, List<SysMusicScoreCategories> sysMusicScoreCategoriesList){
-    	
-    	if(sysMusicScoreCategoriesList != null && sysMusicScoreCategoriesList.size() > 0){
-    		for(SysMusicScoreCategories sysMusicScoreCategories : sysMusicScoreCategoriesList){
-    			categoryIdList.add(sysMusicScoreCategories.getId());
-    			getAllCategoryIdList(categoryIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());
-    		}
-    	}
+
+    @PostMapping("/state/{id}")
+    @ApiOperation(value = "启用/停用", notes = "传入id")
+    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/state')")
+    public HttpResponseResult<Boolean> state(@ApiParam(value = "曲目编号", required = true)  @PathVariable Integer id) {
+        if (id == null) {
+            return failed("参数不能为空");
+        }
+        return succeed(sysMusicScoreService.state(id));
+    }
+
+    @PostMapping("/stateList")
+    @ApiOperation(value = "批量启用/停用")
+    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/stateList')")
+    public HttpResponseResult<Boolean> stateList(@RequestBody ReasonDto reasonDto) {
+        if (StringUtils.isEmpty(reasonDto.getMusicSheetIds())) {
+            return failed("参数不能为空");
+        }
+        if (reasonDto.getState() == null) {
+            return failed("启用/禁用状态不能为空");
+        }
+        if (reasonDto.getState().equals(YesOrNoEnum.NO) && StringUtils.isEmpty(reasonDto.getReason())) {
+            return failed("停用原因不能为空");
+        }
+        return succeed(sysMusicScoreService.stateList(reasonDto));
     }
 
-    @ApiOperation(value = "转码")
-    @PostMapping("/transcod")
-    @PreAuthorize("@pcs.hasPermissions('sysMusicScore/transcod')")
-    public Object transcod(Integer sysMusicScoreId) {
-        sysMusicScoreService.transcod(sysMusicScoreId);
+    @ApiOperation(value = "数据同步", notes = "曲谱表- 修改曲目缓存 MusicSheetVo.MusicSheet")
+    @PostMapping("/sync")
+    public HttpResponseResult<Object> sync() {
+        CompletableFuture.runAsync(() -> {
+            sysMusicScoreService.sync();
+        });
         return succeed();
     }
 }

+ 25 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/InstrumentDao.java

@@ -0,0 +1,25 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ym.mec.biz.dal.entity.Instrument;
+import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 乐器设置
+ * 2024-04-22 16:55:18
+ */
+public interface InstrumentDao extends BaseMapper<Instrument> {
+
+	/**
+	 * 分页查询
+	 * @param page IPage<InstrumentWrapper.Instrument>
+	 * @param param InstrumentWrapper.InstrumentQuery
+	 * @return List<InstrumentWrapper.Instrument>
+	 */
+	List<InstrumentWrapper.Instrument> selectPage(@Param("page") IPage<InstrumentWrapper.Instrument> page, @Param("param") InstrumentWrapper.InstrumentQuery param);
+
+}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SubjectDao.java

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
 import com.ym.mec.common.dal.BaseDAO;
 
 import org.apache.ibatis.annotations.Param;
@@ -176,4 +177,10 @@ public interface SubjectDao extends BaseDAO<Integer, Subject> {
     List<Subject> findByNames();
 
     List<Subject> queryCbsList(@Param("cbsSubjectIds") List<Long> cbsSubjectIds);
+
+    List<Subject> notInSubjectIds(@Param("subjectId") Integer subjectId);
+
+    int findCount(Map<String, Object> params);
+
+    List<SubjectWrapper.Subject> findPage(Map<String, Object> params);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysMusicScoreAccompanimentDao.java

@@ -34,4 +34,6 @@ public interface SysMusicScoreAccompanimentDao extends BaseDAO<Integer, SysMusic
      * @return
      */
     List<Subject> querySubjectIds(@Param("categoriesIdList") List<Integer> categoriesIdList);
+
+    List<SysMusicScoreAccompaniment> findByMusicScoreId(@Param("recordId") Integer recordId);
 }

+ 2 - 10
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysMusicScoreDao.java

@@ -3,8 +3,6 @@ package com.ym.mec.biz.dal.dao;
 
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetApiWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetApplicationExtendWrapper;
-import com.ym.mec.biz.dal.dto.SysMusicScoreMetronomeTranscod;
-import com.ym.mec.biz.dal.dto.SysMusicScoreTranscod;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
 import com.ym.mec.biz.dal.entity.SysMusicScoreAccompaniment;
 import com.ym.mec.common.dal.BaseDAO;
@@ -18,14 +16,6 @@ public interface SysMusicScoreDao extends BaseDAO<Integer, SysMusicScore> {
 
     int countBuyCategoriesIds(@Param("categoriesIds") String delCategoriesIds);
 
-    SysMusicScoreTranscod getTranscod(@Param("sysMusicScoreId") Integer sysMusicScoreId);
-
-    List<SysMusicScoreMetronomeTranscod> getMetronomeTranscod(@Param("sysMusicScoreId") Integer sysMusicScoreId);
-
-    int updateAccompanimentBySongId(@Param("param") SysMusicScoreAccompaniment param);
-
-    int updateExtStyleConfigJson(@Param("id") Integer id, @Param("extStyleConfigJson") String extStyleConfigJson);
-
     List<SysMusicScore> findByCbsId(@Param("cbsMusicSheetIds") List<Long> cbsMusicSheetIds);
 
     void updateBatchByCbsId(@Param("vos") List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> updateMusicScore);
@@ -39,4 +29,6 @@ public interface SysMusicScoreDao extends BaseDAO<Integer, SysMusicScore> {
     void updateMusicSheet(@Param("param") CbsMusicSheetApiWrapper.MusicSheetUpdate musicSheetUpdate);
 
     void batchInsertAccompaniment(@Param("vos") List<Integer> musicSheetIds);
+
+    List<SysMusicScore> selectSyncPage();
 }

+ 48 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReasonDto.java

@@ -0,0 +1,48 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Description
+ *
+ * @author liujunchi
+ * @date 2022-08-08
+ */
+@ApiModel("曲目下架原因")
+public class ReasonDto {
+
+    @ApiModelProperty("曲目下架原因")
+    private String  reason;
+
+    @ApiModelProperty("曲目id集合 逗号隔开")
+    private String musicSheetIds;
+
+    @ApiModelProperty("启用: 1 ,停用 : 0")
+    private YesOrNoEnum state;
+
+    public YesOrNoEnum getState() {
+        return state;
+    }
+
+    public void setState(YesOrNoEnum state) {
+        this.state = state;
+    }
+
+    public String getMusicSheetIds() {
+        return musicSheetIds;
+    }
+
+    public void setMusicSheetIds(String musicSheetIds) {
+        this.musicSheetIds = musicSheetIds;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+}

+ 0 - 44
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SysMusicScoreMetronomeTranscod.java

@@ -1,44 +0,0 @@
-package com.ym.mec.biz.dal.dto;
-
-public class SysMusicScoreMetronomeTranscod {
-    //sys_music_score_accompaniment.id_
-    private Integer id;
-    //sys_music_score_accompaniment.exam_song_id_
-    private Integer examSongId;
-    //原音MP3
-    private String mp3Url;
-    //原音MP3(含节拍器)
-    private String  metronomeMp3Url;
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public Integer getExamSongId() {
-        return examSongId;
-    }
-
-    public void setExamSongId(Integer examSongId) {
-        this.examSongId = examSongId;
-    }
-
-    public String getMp3Url() {
-        return mp3Url;
-    }
-
-    public void setMp3Url(String mp3Url) {
-        this.mp3Url = mp3Url;
-    }
-
-    public String getMetronomeMp3Url() {
-        return metronomeMp3Url;
-    }
-
-    public void setMetronomeMp3Url(String metronomeMp3Url) {
-        this.metronomeMp3Url = metronomeMp3Url;
-    }
-}

+ 0 - 47
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SysMusicScoreTranscod.java

@@ -1,47 +0,0 @@
-package com.ym.mec.biz.dal.dto;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SysMusicScoreTranscod {
-    //sys_music_score.id_
-    private Integer id;
-    //伴奏MP3
-    private String url;
-    //伴奏MP3(含节拍器)
-    private String  metronomeUrl;
-
-    private List<SysMusicScoreMetronomeTranscod> accompanimentList = new ArrayList<>();
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getMetronomeUrl() {
-        return metronomeUrl;
-    }
-
-    public void setMetronomeUrl(String metronomeUrl) {
-        this.metronomeUrl = metronomeUrl;
-    }
-
-    public List<SysMusicScoreMetronomeTranscod> getAccompanimentList() {
-        return accompanimentList;
-    }
-
-    public void setAccompanimentList(List<SysMusicScoreMetronomeTranscod> accompanimentList) {
-        this.accompanimentList = accompanimentList;
-    }
-}

+ 55 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Instrument.java

@@ -0,0 +1,55 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 乐器设置
+ * 2024-04-22 16:55:18
+ */
+@Data
+@ApiModel(" Instrument-乐器设置")
+@TableName("instrument")
+public class Instrument implements Serializable {
+
+    @ApiModelProperty("主键ID,内容平台乐器ID")
+    @TableId(value = "id_")
+    private Integer id;
+
+    @ApiModelProperty("声部ID")
+	@TableField(value = "subject_id_")
+    private Integer subjectId;
+
+    @ApiModelProperty("横竖屏:1:竖 0:横")
+	@TableField(value = "orientation_")
+    private Boolean orientation;
+
+    @ApiModelProperty("启用/停用")
+    @TableField(value = "enable_flag_")
+    private Boolean enableFlag;
+
+    @ApiModelProperty("删除标记")
+	@TableField(value = "del_flag_")
+    private Boolean delFlag;
+
+    @ApiModelProperty("创建时间")
+	@TableField(value = "create_time_")
+    private Date createTime;
+
+    @ApiModelProperty("更新时间")
+	@TableField(value = "update_time_")
+    private Date updateTime;
+
+    @ApiModelProperty("操作人")
+	@TableField(value = "operator_")
+    private Long operator;
+
+}

+ 7 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Subject.java

@@ -18,7 +18,7 @@ public class Subject {
 	private Integer id;
 
 	/**  */
-	private Long cbsSubjectId;
+	private Integer cbsSubjectId;
 	
 	/**  */
 	@ApiModelProperty(value = "科目名称",required = false)
@@ -60,6 +60,12 @@ public class Subject {
 	@ApiModelProperty(value = "子节点列表",required = false)
 	private List<Subject> subjects;
 
+	@ApiModelProperty(value = "乐器编号(逗号分隔)",required = false)
+	private String instrumentIds;
+
+	@ApiModelProperty(value = "乐器名称",required = false)
+	private String instrumentName;
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicScore.java

@@ -42,7 +42,7 @@ public class SysMusicScore {
 	private Integer id;
 
 	@ApiModelProperty(value = "内容平台曲目ID")
-	private Long cbsMusicSheetId;  //主键ID
+	private String cbsMusicSheetId;  //主键ID
 	
 	/**  */
 	private Integer musicScoreCategoriesId;

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicScoreAccompaniment.java

@@ -17,7 +17,7 @@ public class SysMusicScoreAccompaniment {
 	/**  */
 	private Integer examSongId;
 	/**  */
-	private Long cbsMusicSheetId;
+	private String cbsMusicSheetId;
 	
 	/**  */
 	private Integer subjectId;

+ 123 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/InstrumentWrapper.java

@@ -0,0 +1,123 @@
+package com.ym.mec.biz.dal.wrapper;
+
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 乐器设置
+ * 2024-04-22 16:55:18
+ */
+@ApiModel(value = "InstrumentWrapper对象", description = "乐器设置查询对象")
+public class InstrumentWrapper {
+
+    @Data
+	@Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel(" InstrumentQuery-乐器设置")
+    public static class InstrumentQuery implements QueryInfo {
+    	@ApiModelProperty("当前页")
+        private Integer page;
+        @ApiModelProperty("分页行数")
+        private Integer rows;
+        @ApiModelProperty("声部")
+        private Integer subjectId;
+        @ApiModelProperty("声部")
+        private List<Integer> subjectIds;
+        @ApiModelProperty("是否启用")
+        private Boolean enableFlag;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static InstrumentQuery from(String json) {
+            return JSON.parseObject(json, InstrumentQuery.class);
+        }
+    }
+
+    @Data
+	@ApiModel(" Instrument-乐器设置")
+    public static class Instrument {
+
+        @ApiModelProperty("乐器ID")
+        private Integer id;
+
+        @ApiModelProperty("乐器名称")
+        private String name;
+
+        @ApiModelProperty("声部ID")
+        private Integer subjectId;
+
+        @ApiModelProperty("声部名称")
+        private String subjectName;
+
+        @ApiModelProperty("横竖屏:1:竖 0:横")
+        private Boolean orientation;
+
+        @ApiModelProperty("启用/停用")
+        private Boolean enableFlag;
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+        @ApiModelProperty("操作人")
+        private Long operator;
+
+        @ApiModelProperty("编码")
+        private String code;
+
+
+        @ApiModelProperty("是否可转普")
+        private Boolean transferFlag;
+
+        @ApiModelProperty("图片")
+        private String img;
+
+        @ApiModelProperty("音频")
+        private String media;
+
+        @ApiModelProperty("频率")
+        private Integer hz;
+
+        @ApiModelProperty("默认谱面(STAVE: 五线谱; JIAN: 固定调; FIRST: 首调)")
+        private String defaultScore;
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static Instrument from(String json) {
+            return JSON.parseObject(json, Instrument.class);
+        }
+	}
+
+    @Data
+    public static class Update {
+
+        @ApiModelProperty("乐器ID")
+        @NotNull(message = "乐器ID不能为空")
+        private Long id;
+
+        @ApiModelProperty("操作人")
+        private Long operator;
+
+        @ApiModelProperty("横竖屏:1:竖 0:横")
+        private Boolean orientation;
+
+        @ApiModelProperty("启用/停用")
+        private Boolean enableFlag;
+    }
+}

+ 25 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/MusicSheetWrapper.java

@@ -8,6 +8,7 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Optional;
 
@@ -199,6 +200,30 @@ public class MusicSheetWrapper {
     @NoArgsConstructor
     @AllArgsConstructor
     @ApiModel(" MusicSheet-管乐迷曲谱表")
+    public static class MusicSheetApplicationExtendWrapper {
+        @ApiModelProperty("曲目ID")
+        private @NotNull(
+                message = "曲目ID不能为空"
+        ) Long musicSheetId;
+
+        @ApiModelProperty("分类ID")
+        private Long musicSheetCategoryId;
+
+        @ApiModelProperty("启用状态")
+        private Boolean status;
+
+        @ApiModelProperty("排序")
+        private Integer sortNo;
+
+        @ApiModelProperty("收费类型(FREE:免费;VIP:会员;CHARGE:单曲收费)")
+        private String paymentType;
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel(" MusicSheet-管乐迷曲谱表")
     public static class MecMusicSheet extends MusicSheet {
 
         @ApiModelProperty("曲目分类")

+ 268 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/SubjectWrapper.java

@@ -0,0 +1,268 @@
+package com.ym.mec.biz.dal.wrapper;
+
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectWrapper;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.List;
+
+public class SubjectWrapper {
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class SubjectQuery implements QueryInfo {
+
+        @ApiModelProperty("当前页")
+        private Integer page;
+
+        @ApiModelProperty("分页行数")
+        private Integer rows;
+
+        @ApiModelProperty("关键字匹配")
+        private String keyword;
+
+        @ApiModelProperty("删除标识")
+        private Integer delFlag;
+
+        @ApiModelProperty("启用标识")
+        private Boolean enableFlag;
+
+        @ApiModelProperty("声部ID")
+        private Integer subjectId;
+
+        @ApiModelProperty("父级声部ID")
+        private Integer parentSubjectId;
+
+        @ApiModelProperty("多个声部ID")
+        private String subjectIds;
+
+        @ApiModelProperty("多个乐器ID")
+        private String instrumentIds;
+
+        @ApiModelProperty("有乐器")
+        private Boolean hasInstrument;
+
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class Subject {
+
+        @ApiModelProperty("主键")
+        private Integer id;
+
+        @ApiModelProperty("内容平台声部ID")
+        private Long cbsSubjectId;
+
+        @ApiModelProperty("内容平台声部名称")
+        private String cbsSubjectName;
+
+        @ApiModelProperty("名称")
+        private String name;
+
+        @ApiModelProperty("编码")
+        private String code;
+
+        @ApiModelProperty(value = "父级编号",required = false)
+        private Integer parentSubjectId;
+
+        private String parentSubjectName;
+
+        @ApiModelProperty("封面")
+        private String img;
+
+        @ApiModelProperty("orientation:1:竖 0:横")
+        private Boolean orientation;
+
+        @ApiModelProperty("删除标识")
+        private Boolean delFlag;
+
+        @ApiModelProperty("描述信息")
+        private String desc;
+
+        @ApiModelProperty("logo")
+        private String logo;
+
+        @ApiModelProperty("音频")
+        private String media;
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+        @ApiModelProperty("启用标识")
+        private Boolean enableFlag;
+
+        @ApiModelProperty("声部列表")
+        private List<Subject> subjects;
+
+        @ApiModelProperty("乐器列表")
+        private List<InstrumentWrapper.Instrument> instruments;
+
+    }
+
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class SmallInstrument {
+
+        @ApiModelProperty("乐器ID")
+        private Integer id;
+
+        @ApiModelProperty("乐器名称")
+        private String name;
+
+        @ApiModelProperty("编码")
+        private String code;
+
+        @ApiModelProperty("横竖屏:1:竖 0:横")
+        private Boolean orientation;
+
+        @ApiModelProperty("是否可转普")
+        private Boolean transferFlag;
+
+        @ApiModelProperty("图片")
+        private String img;
+
+        @ApiModelProperty("音频")
+        private String media;
+
+        @ApiModelProperty("频率")
+        private Integer hz;
+
+        @ApiModelProperty("是否启用")
+        private Boolean enableFlag = false;
+
+        @ApiModelProperty("操作人")
+        private Long operator;
+    }
+
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class SmallSubject {
+
+        @ApiModelProperty("声部ID")
+        private Integer id;
+
+        @ApiModelProperty("声部名称")
+        private String name;
+    }
+
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class SmallMusicSheet {
+
+        @ApiModelProperty("id")
+        private Long id;
+
+        @ApiModelProperty("声部ID")
+        private String musicSubject;
+
+        @ApiModelProperty("内容平台声部ID")
+        private String cbsSubjectId;
+    }
+
+    @Data
+    @ApiModel("声部启用")
+    public static class SubjectEnable {
+
+        @ApiModelProperty("声部ID")
+        @NotNull(message = "声部ID不能为空")
+        private Long id;
+
+        @ApiModelProperty("启用标识")
+        @NotNull(message = "启用标识不能为空")
+        private Boolean enableFlag;
+    }
+
+
+    @Data
+    public static class AddSubject {
+
+        @ApiModelProperty("内容平台声部")
+        private List<AddSubjectInstrument> subjects;
+
+        @ApiModelProperty("操作人")
+        private Long operator;
+    }
+
+    @Data
+    public static class AddSubjectInstrument {
+
+        @ApiModelProperty("内容平台声部ID")
+        @NotNull(message = "内容平台声部ID不能为空")
+        private Long cbsSubjectId;
+
+        @ApiModelProperty("分类编号")
+        @NotNull(message = "分类编号不能为空")
+        private Long parentSubjectId;
+
+        @ApiModelProperty("乐器ID")
+        private List<Long> instrumentIds;
+    }
+
+    @Data
+    public static class CbsSubject{
+        @ApiModelProperty("声部ID")
+        private Long id;
+
+        @ApiModelProperty("名称")
+        private String name;
+
+        @ApiModelProperty("编码")
+        private String code;
+
+        @ApiModelProperty("是否启用")
+        private Boolean enableFlag;
+
+        @ApiModelProperty("乐器列表")
+        private List<Instrument> instruments;
+    }
+
+
+    @Data
+    @ApiModel(" Instrument-乐器设置")
+    public static class Instrument {
+
+        @ApiModelProperty("乐器ID")
+        private Integer id;
+
+        @ApiModelProperty("乐器名称")
+        private String name;
+
+        @ApiModelProperty("是否已被添加过")
+        private Boolean added = false;
+    }
+
+    @Data
+    @ApiModel(" SubjectList-声部表")
+    public static class CbsSubjectQuery extends CbsSubjectWrapper.SubjectQuery {
+
+        @ApiModelProperty("当前声部ID")
+        private Integer subjectId;
+
+        @ApiModelProperty("是否移除被使用过的声部")
+        private Boolean removeUsed = false;
+    }
+}

+ 59 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/InstrumentService.java

@@ -0,0 +1,59 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.Instrument;
+import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 乐器设置
+ * 2024-04-22 16:55:18
+ */
+public interface InstrumentService extends IService<Instrument>  {
+
+	/**
+     * 查询详情
+     * @param id 详情ID
+     * @return Instrument
+     */
+	Instrument detail(Integer id);
+
+    /**
+     * 分页查询
+     * @param page IPage<Instrument>
+     * @param query InstrumentWrapper.InstrumentQuery
+     * @return IPage<Instrument>
+     */
+    IPage<InstrumentWrapper.Instrument> selectPage(IPage<InstrumentWrapper.Instrument> page, InstrumentWrapper.InstrumentQuery query);
+
+    /**
+     * 添加
+     * @param instrument InstrumentWrapper.Instrument
+     * @return Boolean
+     */
+     Boolean add(InstrumentWrapper.Instrument instrument);
+
+    /**
+     * 更新
+     * @param instrument InstrumentWrapper.Instrument
+     * @return Boolean
+     */
+     Boolean update(InstrumentWrapper.Instrument instrument);
+
+    List<Instrument> queryBySubjectId(Integer subject);
+
+    Map<Integer,InstrumentWrapper.Instrument> getMapByIds(List<Integer> instrumentIdList);
+
+    List<InstrumentWrapper.Instrument> getInstruments(List<Integer> instrumentIdList);
+
+    Map<Integer,List<InstrumentWrapper.Instrument>> getGroupBySubjectId(List<Integer> subjectIds, Boolean enableFlag);
+
+    List<InstrumentWrapper.Instrument> getList(InstrumentWrapper.InstrumentQuery query);
+
+    List<Integer> getInstrumentIdsBySubjectId(Integer subjectId);
+
+    void modify(InstrumentWrapper.Update update);
+}

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SubjectService.java

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
 import com.ym.mec.biz.dal.page.SubjectQueryInfo;
+import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
@@ -116,4 +117,7 @@ public interface SubjectService extends BaseService<Integer, Subject> {
 
     Map<Integer, StudentSubjectDto> getSubjectByStudentId(Set studentIds);
 
+    List<SubjectWrapper.Subject> queryList(SubjectWrapper.SubjectQuery query);
+
+    PageInfo<SubjectWrapper.Subject> selectPage(SubjectWrapper.SubjectQuery query);
 }

+ 9 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/SysMusicScoreService.java

@@ -4,9 +4,11 @@ package com.ym.mec.biz.service;
 import java.util.List;
 import java.util.Map;
 
+import com.dayaedu.cbs.domain.wrapper.MusicSheetWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
 import com.ym.mec.biz.dal.dao.SysMusicScoreDao;
 import com.ym.mec.biz.dal.dto.MusicScoreDto;
+import com.ym.mec.biz.dal.dto.ReasonDto;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.common.page.PageInfo;
@@ -16,13 +18,7 @@ public interface SysMusicScoreService extends BaseService<Integer, SysMusicScore
 
     SysMusicScoreDao getDao();
 
-    void updateMusicScore(MusicScoreDto musicScoreDto);
-
-    void add(MusicScoreDto musicScoreDto);
-
-    void del(Integer id);
-
-    List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<Long> cbsMusicSheetIds);
+    List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<String> cbsMusicSheetIds);
 
     List<SysMusicScore> queryMusicScoreAll(SysExamSongQueryInfo queryInfo);
 
@@ -30,11 +26,13 @@ public interface SysMusicScoreService extends BaseService<Integer, SysMusicScore
     
     PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo);
 
-    void transcod(Integer sysMusicScoreId);
+    Map<Long, SysMusicScore> getMapByIds(List<Long> musicSheetIds);
 
-    int updateExtStyleConfigJson(Integer id, String extStyleConfigJson);
+    Boolean stateList(ReasonDto reasonDto);
 
-    Map<Long, SysMusicScore> getMapByIds(List<Long> musicSheetIds);
+    Boolean state(Integer id);
+
+    void updateCbs(MusicSheetWrapper.MusicSheetApplicationExtendWrapper addMusicSheetApplicationExtend);
 
-    void enable(Integer sysMusicScoreId, Integer showFlag);
+    void sync();
 }

+ 6 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CbsMusicSheetServiceImpl.java

@@ -10,7 +10,6 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.ym.mec.biz.dal.dao.SysUserTenantDao;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
-import com.ym.mec.biz.dal.entity.SysMusicScoreCategories;
 import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.biz.service.SysMusicScoreCategoriesService;
 import com.ym.mec.biz.service.SysMusicScoreService;
@@ -46,7 +45,7 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
         if (CollectionUtils.isEmpty(addMusicSheet)) {
             throw new BizException("请选择曲目信息");
         }
-        List<Long> cbsMusicSheetIds = addMusicSheet.stream().map(e -> e.getMusicSheetId()).collect(Collectors.toList());
+        List<Long> cbsMusicSheetIds = addMusicSheet.stream().map(CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend::getMusicSheetId).collect(Collectors.toList());
         for (CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend : addMusicSheet) {
             CbsMusicSheetApiWrapper.MusicSheetUpdate musicSheetUpdate = extend.getMusicSheetUpdate();
             if(StringUtils.isNotBlank(musicSheetUpdate.getSubjectIds())) {
@@ -60,19 +59,19 @@ public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
         //需要修改的曲目
         List<SysMusicScore> musicSheets = sysMusicScoreService.getDao().findByCbsId(cbsMusicSheetIds);
         if (CollectionUtils.isNotEmpty(musicSheets)){
-            List<Long> collect = musicSheets.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
+            List<String> collect = musicSheets.stream().map(SysMusicScore::getCbsMusicSheetId).collect(Collectors.toList());
             //获取需要修改的曲目
             List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> updateMusicScore =
-                    addMusicSheet.stream().filter(e -> collect.contains(e.getMusicSheetId())).collect(Collectors.toList());
+                    addMusicSheet.stream().filter(e -> collect.contains(e.getMusicSheetId().toString())).collect(Collectors.toList());
             sysMusicScoreService.getDao().updateBatchByCbsId(updateMusicScore);
             //排除已经存在的曲目
-            addMusicSheet = addMusicSheet.stream().filter(e -> !collect.contains(e.getMusicSheetId())).collect(Collectors.toList());
+            addMusicSheet = addMusicSheet.stream().filter(e -> !collect.contains(e.getMusicSheetId().toString())).collect(Collectors.toList());
         }
         if(CollectionUtils.isNotEmpty(addMusicSheet)){
             sysMusicScoreService.getDao().batchInsert(addMusicSheet);
-            List<Long> cbsIds = addMusicSheet.stream().map(e -> e.getMusicSheetId()).collect(Collectors.toList());
+            List<Long> cbsIds = addMusicSheet.stream().map(CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend::getMusicSheetId).collect(Collectors.toList());
             List<SysMusicScore> sysMusicScores = sysMusicScoreService.getDao().findByCbsId(cbsIds);
-            List<Integer> collect = sysMusicScores.stream().map(e -> e.getId()).collect(Collectors.toList());
+            List<Integer> collect = sysMusicScores.stream().map(SysMusicScore::getId).collect(Collectors.toList());
             sysMusicScoreService.getDao().batchInsertAccompaniment(collect);
         }
         return true;

+ 219 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/InstrumentServiceImpl.java

@@ -0,0 +1,219 @@
+package com.ym.mec.biz.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
+import com.dayaedu.cbs.openfeign.wrapper.musicInstrument.CbsMusicalInstrumentWrapper;
+import com.microsvc.toolkit.common.webportal.exception.BizException;
+import com.ym.mec.biz.dal.dao.InstrumentDao;
+import com.ym.mec.biz.dal.entity.Instrument;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
+import com.ym.mec.biz.service.InstrumentService;
+import com.ym.mec.biz.service.SubjectService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * 乐器设置
+ * 2024-04-22 16:55:18
+ */
+@Slf4j
+@Service
+public class InstrumentServiceImpl extends ServiceImpl<InstrumentDao, Instrument> implements InstrumentService {
+
+    @Resource
+    private MusicFeignClientService musicFeignClientService;
+    @Resource
+    private SubjectService subjectService;
+
+    /**
+     * 查询详情
+     *
+     * @param id 详情ID
+     * @return Instrument
+     */
+    @Override
+    public Instrument detail(Integer id) {
+
+        return baseMapper.selectById(id);
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param page  IPage<Instrument>
+     * @param query InstrumentWrapper.InstrumentQuery
+     * @return IPage<Instrument>
+     */
+    @Override
+    public IPage<InstrumentWrapper.Instrument> selectPage(IPage<InstrumentWrapper.Instrument> page, InstrumentWrapper.InstrumentQuery query) {
+
+        IPage<InstrumentWrapper.Instrument> instrumentIPage = page.setRecords(baseMapper.selectPage(page, query));
+        List<InstrumentWrapper.Instrument> records = instrumentIPage.getRecords();
+        if (CollectionUtils.isEmpty(records)) {
+            return instrumentIPage;
+        }
+        List<InstrumentWrapper.Instrument> instruments = getInstruments(records.stream().map(InstrumentWrapper.Instrument::getId).distinct().collect(Collectors.toList()));
+        return instrumentIPage.setRecords(instruments);
+    }
+
+    /**
+     * 添加
+     *
+     * @param instrument InstrumentWrapper.Instrument
+     * @return Boolean
+     */
+    @Override
+    public Boolean add(InstrumentWrapper.Instrument instrument) {
+
+        return this.save(JSON.parseObject(instrument.jsonString(), Instrument.class));
+    }
+
+    /**
+     * 更新
+     *
+     * @param instrument InstrumentWrapper.Instrument
+     * @return Boolean
+     */
+    @Override
+    public Boolean update(InstrumentWrapper.Instrument instrument) {
+
+        return this.updateById(JSON.parseObject(instrument.jsonString(), Instrument.class));
+    }
+
+    @Override
+    public List<Instrument> queryBySubjectId(Integer subject) {
+        if (subject == null) {
+            return new ArrayList<>();
+        }
+        return this.lambdaQuery()
+            .eq(Instrument::getSubjectId, subject)
+            .list();
+    }
+
+    @Override
+    public Map<Integer, InstrumentWrapper.Instrument> getMapByIds(List<Integer> instrumentIdList) {
+        if (CollectionUtils.isEmpty(instrumentIdList)) {
+            return new HashMap<>();
+        }
+        instrumentIdList = instrumentIdList.stream().distinct().collect(Collectors.toList());
+        List<InstrumentWrapper.Instrument> instrumentList = getInstruments(instrumentIdList);
+        return instrumentList.stream().collect(Collectors.toMap(InstrumentWrapper.Instrument::getId, Function.identity()));
+    }
+
+    @Override
+    public List<InstrumentWrapper.Instrument> getInstruments(List<Integer> instrumentIdList) {
+        instrumentIdList = instrumentIdList.stream().filter(Objects::nonNull).collect(Collectors.toList());
+        Map<Integer, Instrument> idImstrumentMap = this.lambdaQuery().in(Instrument::getId, instrumentIdList).list()
+            .stream().collect(Collectors.toMap(Instrument::getId, Function.identity()));
+        // 去内容平台查询乐器名称
+        CbsMusicalInstrumentWrapper.MusicalInstrumentQuery build = CbsMusicalInstrumentWrapper.MusicalInstrumentQuery.builder()
+            .rows(-1)
+            .ids(instrumentIdList)
+            .build();
+        List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> rows;
+        try {
+            rows = musicFeignClientService
+                .musicalInstrumentPage(build).feignData().getRows();
+        } catch (Exception e) {
+            throw new BizException("内容平台服务异常");
+        }
+        Map<Integer, CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> idMap = rows.stream().collect(Collectors.toMap(CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto::getId,
+            Function.identity()));
+
+        List<InstrumentWrapper.Instrument> instrumentList = new ArrayList<>();
+        instrumentIdList.forEach(next -> {
+            CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto dto = idMap.get(next.intValue());
+            if (dto == null) {
+                return;
+            }
+            InstrumentWrapper.Instrument instrument = JSON.parseObject(JSON.toJSONString(dto), InstrumentWrapper.Instrument.class);
+            if (dto.getDefaultScore() != null) {
+                instrument.setDefaultScore(dto.getDefaultScore().name());
+            }
+            instrument.setId(next);
+
+            Instrument instrument1 = idImstrumentMap.getOrDefault(next, new Instrument());
+            instrument.setOrientation(instrument1.getOrientation());
+            instrument.setEnableFlag(instrument1.getEnableFlag());
+            instrument.setOperator(instrument1.getOperator());
+            instrument.setSubjectId(instrument1.getSubjectId());
+            instrumentList.add(instrument);
+        });
+        return instrumentList;
+    }
+
+    @Override
+    public Map<Integer, List<InstrumentWrapper.Instrument>> getGroupBySubjectId(List<Integer> subjectIds, Boolean enableFlag) {
+        if (CollectionUtils.isEmpty(subjectIds)) {
+            return new HashMap<>();
+        }
+        List<Instrument> list = this.lambdaQuery()
+            .in(Instrument::getSubjectId, subjectIds)
+            .eq(enableFlag != null, Instrument::getEnableFlag, enableFlag)
+            .list();
+        if (CollectionUtils.isEmpty(list)) {
+            return new HashMap<>();
+        }
+        // group
+        Map<Integer, List<Integer>> idResult = list.stream()
+            .collect(Collectors.groupingBy(Instrument::getSubjectId, LinkedHashMap::new,Collectors.mapping(Instrument::getId, Collectors.toList())));
+
+        // id 集合
+        List<Integer> instrumentIds = list.stream().map(Instrument::getId).collect(Collectors.toList());
+        Map<Integer, InstrumentWrapper.Instrument> instrumentMap = getMapByIds(instrumentIds);
+        Map<Integer, List<InstrumentWrapper.Instrument>> result = new HashMap<>();
+        idResult.forEach((k,v)->{
+            List<InstrumentWrapper.Instrument> instruments = v.stream().map(instrumentMap::get).collect(Collectors.toList());
+            result.put(k, instruments);
+        });
+        return result;
+
+    }
+
+    @Override
+    public List<InstrumentWrapper.Instrument> getList(InstrumentWrapper.InstrumentQuery query) {
+
+        IPage<InstrumentWrapper.Instrument> instrumentIPage = this.selectPage(new Page<>(1, -1), query);
+        return instrumentIPage.getRecords();
+    }
+
+    @Override
+    public List<Integer> getInstrumentIdsBySubjectId(Integer subjectId) {
+        List<Instrument> list = this.lambdaQuery()
+            .eq(Instrument::getSubjectId, subjectId)
+            .list();
+        if (CollectionUtils.isEmpty(list)) {
+            return new ArrayList<>();
+        }
+        return list.stream().map(Instrument::getId).collect(Collectors.toList());
+    }
+
+    @Override
+    @Transactional
+    public void modify(InstrumentWrapper.Update update) {
+        Instrument instrument = JSON.parseObject(JSON.toJSONString(update), Instrument.class);
+
+        this.updateById(instrument);
+
+        if (update.getEnableFlag() != null && update.getEnableFlag()) {
+            // 启用声部
+            Instrument entity = this.getById(update.getId());
+            if (entity == null) {
+                return;
+            }
+            Subject subject = subjectService.get(entity.getSubjectId());
+            subjectService.getDao().update(subject);
+        }
+    }
+}

+ 116 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectServiceImpl.java

@@ -1,5 +1,9 @@
 package com.ym.mec.biz.service.impl;
 
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
+import com.dayaedu.cbs.openfeign.client.SubjectFeignClientService;
+import com.dayaedu.cbs.openfeign.wrapper.musicInstrument.CbsMusicalInstrumentWrapper;
+import com.microsvc.toolkit.common.response.template.R;
 import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
 import com.ym.mec.biz.dal.dao.SubjectDao;
 import com.ym.mec.biz.dal.dao.SubjectGoodsMapperDao;
@@ -7,17 +11,23 @@ import com.ym.mec.biz.dal.dto.ConditionDto;
 import com.ym.mec.biz.dal.dto.StudentSubjectDto;
 import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
 import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
+import com.ym.mec.biz.dal.entity.Instrument;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.SubjectQueryInfo;
+import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
+import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
+import com.ym.mec.biz.service.InstrumentService;
 import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
@@ -35,6 +45,10 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
     private StudentRegistrationDao studentRegistrationDao;
     @Resource
     private SubjectGoodsMapperDao subjectGoodsMapperDao;
+    @Resource
+    private InstrumentService instrumentService;
+    @Resource
+    private MusicFeignClientService musicFeignClientService;
 
     @Override
     public BaseDAO<Integer, Subject> getDAO() {
@@ -87,9 +101,11 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void upSetSubject(Subject subject) {
         if (subject.getDelFlag() == YesOrNoEnum.YES) {
             subjectDao.delete(subject.getId());
+            instrumentService.lambdaUpdate().eq(Instrument::getSubjectId, subject.getId()).remove();
             return;
         }
         Integer parentId = upset(subject, null);
@@ -111,9 +127,28 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
         } else {
             subjectDao.insert(subject);
         }
+        //保存乐器关联
+        this.saveInstrument(subject);
         return subject.getId();
     }
 
+    private void saveInstrument(Subject subject) {
+        if (StringUtils.isNotEmpty(subject.getInstrumentIds())) {
+            instrumentService.lambdaUpdate().eq(Instrument::getSubjectId, subject.getId()).remove();
+            List<Instrument> instruments = new ArrayList<>();
+            String[] split = subject.getInstrumentIds().split(",");
+            for (String s : split) {
+                Instrument instrument = new Instrument();
+                instrument.setSubjectId(subject.getId());
+                instrument.setId(Integer.valueOf(s));
+                instrument.setEnableFlag(true);
+                instrument.setDelFlag(false);
+                instruments.add(instrument);
+            }
+            instrumentService.saveBatch(instruments);
+        }
+    }
+
     @Override
     public void markGoods(List<SubjectGoodsMapper> subjectGoodsMappers) {
         subjectGoodsMappers.forEach(e -> {
@@ -212,6 +247,26 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
             dataList = subjectDao.queryPageByIdOrName(params);
+            List<Integer> subjectIds = dataList.stream().map(Subject::getId).collect(Collectors.toList());
+            List<Instrument> list = instrumentService.lambdaQuery().in(Instrument::getSubjectId, subjectIds).list();
+            List<Integer> instrumentIds = list.stream().map(Instrument::getId).collect(Collectors.toList());
+            CbsMusicalInstrumentWrapper.MusicalInstrumentQuery query = new CbsMusicalInstrumentWrapper.MusicalInstrumentQuery();
+            query.setIds(instrumentIds);
+            query.setPage(1);
+            query.setRows(instrumentIds.size());
+            R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto>> infoR = musicFeignClientService.musicalInstrumentPage(query);
+            if (infoR.getCode() != 200){
+                throw new BizException("调用内容平台失败 : {}",infoR.getMessage());
+            }
+            List<CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> rows = infoR.getData().getRows();
+            Map<Integer,CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto> map = rows.stream()
+                    .collect(Collectors.toMap(CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto::getSubjectId, Function.identity()));
+            for (Subject subject : dataList) {
+                CbsMusicalInstrumentWrapper.MusicalInstrumentQueryDto dto = map.get(subject.getCbsSubjectId());
+                if (dto != null) {
+                    subject.setInstrumentName(dto.getName());
+                }
+            }
         }
         if (count == 0) {
             dataList = new ArrayList<>();
@@ -252,4 +307,65 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
         }
         return map;
     }
+
+    @Override
+    public List<SubjectWrapper.Subject> queryList(SubjectWrapper.SubjectQuery query) {
+        query.setPage(1);
+        query.setRows(9999);
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, query);
+
+        PageInfo<SubjectWrapper.Subject> subjectIPage = this.selectPage(query);
+        List<SubjectWrapper.Subject> records = subjectIPage.getRows();
+        if (CollectionUtils.isEmpty(records)) {
+            return records;
+        }
+        String instrumentIds = query.getInstrumentIds();
+        List<Integer> instrumentIdList = new ArrayList<>();
+        if (StringUtils.isNotEmpty(instrumentIds)) {
+            List<Integer> collect = Arrays.stream(instrumentIds.split(",")).map(Integer::valueOf).distinct().collect(Collectors.toList());
+            instrumentIdList.addAll(collect);
+        }
+        if (!instrumentIdList.isEmpty()) {
+            records.forEach(record -> {
+                List<InstrumentWrapper.Instrument> instruments = record.getInstruments();
+                instruments.removeIf(next -> !instrumentIdList.contains(next.getId()));
+            });
+        }
+        return records;
+    }
+
+    @Override
+    public PageInfo<SubjectWrapper.Subject> selectPage(SubjectWrapper.SubjectQuery query) {
+        PageInfo<SubjectWrapper.Subject> pageInfo = new PageInfo<>(query.getPage(), query.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, query);
+
+        List<SubjectWrapper.Subject> dataList = null;
+        int count = subjectDao.findCount(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = subjectDao.findPage(params);
+            // 设置声部下的乐器信息
+            List<Integer> subjectIds = dataList.stream().map(SubjectWrapper.Subject::getId).distinct().collect(Collectors.toList());
+            Map<Integer, List<InstrumentWrapper.Instrument>> groupBySubjectId = instrumentService.getGroupBySubjectId(subjectIds, query.getEnableFlag());
+            Map<Integer, Subject> map = this.findBySubjectByIdList(dataList.stream().map(SubjectWrapper.Subject::getParentSubjectId).collect(Collectors.toList())).stream()
+                    .collect(Collectors.toMap(Subject::getId, t -> t));
+            dataList.forEach(e -> {
+                if(e.getParentSubjectId() != null && e.getParentSubjectId() > 0) {
+                    e.setParentSubjectName(map.get(e.getParentSubjectId()).getName());
+                }
+                List<InstrumentWrapper.Instrument> instruments = groupBySubjectId.get(e.getId());
+                if (org.apache.commons.collections.CollectionUtils.isNotEmpty(instruments)) {
+                    e.setInstruments(instruments);
+                }
+            });
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java

@@ -524,7 +524,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 			LOGGER.error("接收地址不能为空");
 			return;
 		}
-		if("STUDENT".equals(jpushType) && type != STUDENT_PUSH_VIP_BUY){
+		if(messageSender == MessageSender.JIGUANG && "STUDENT".equals(jpushType) && type != STUDENT_PUSH_VIP_BUY){
 			//如果不是缴费信息
 			int hour = DateUtil.getHour(new Date());
 			//如果当前时间在22点之后

+ 11 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreAccompanimentServiceImpl.java

@@ -3,7 +3,6 @@ package com.ym.mec.biz.service.impl;
 
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
 import com.ym.mec.auth.api.dto.MusicScoreQueryInfo;
-import com.ym.mec.biz.dal.dao.SubjectDao;
 import com.ym.mec.biz.dal.dao.SysMusicScoreAccompanimentDao;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
@@ -36,8 +35,6 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
 	@Resource
 	private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
 	@Resource
-	private SubjectDao subjectDao;
-	@Resource
 	private SysMusicScoreCategoriesService sysMusicScoreCategoriesService;
 	@Resource
 	private SysMusicScoreService sysMusicScoreService;
@@ -55,7 +52,7 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
 		List<Integer> idList = new ArrayList<>();
 		idList.add(accompaniment.getId());
 		List<Integer> subjectIds = sysMusicScoreAccompanimentDao.findSubjectByMusicScoreId(accompaniment.getExamSongId(),idList);
-		if(subjectIds.size() > 0 && subjectIds.contains(accompaniment.getId())){
+		if(CollectionUtils.isNotEmpty(subjectIds) && subjectIds.contains(accompaniment.getId())){
 			throw new BizException("操作失败:请勿提交重复的伴奏声部");
 		}
 		sysMusicScoreAccompanimentDao.update(sysMusicScoreAccompaniment);
@@ -77,13 +74,13 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
 		if(count == 0){
 			return result;
 		}
-		List<Long> cbsMusicSheetIds = accompaniments.stream().filter(e->e.getCbsMusicSheetId() != null)
-				.map(SysMusicScoreAccompaniment::getCbsMusicSheetId).collect(Collectors.toList());
+		List<String> cbsMusicSheetIds = accompaniments.stream().map(SysMusicScoreAccompaniment::getCbsMusicSheetId)
+				.filter(StringUtils::isNotEmpty).collect(Collectors.toList());
 		List<CbsMusicSheetWrapper.MusicSheetApplication> applications = sysMusicScoreService.queryCbsMusicSheetApplication(cbsMusicSheetIds);
 		if (CollectionUtils.isEmpty(applications)) {
 			throw new BizException("获取曲目信息失败");
 		}
-		Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> applicationMap = applications.stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
+		Map<String, CbsMusicSheetWrapper.MusicSheetApplication> applicationMap = applications.stream().collect(Collectors.toMap(e->e.getId().toString(), Function.identity()));
 		for (SysMusicScoreAccompaniment accompaniment : accompaniments) {
 			if(accompaniment.getCbsMusicSheetId() == null){
 				result.add(accompaniment);
@@ -104,7 +101,7 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
 				record.setRankIds("FREE".equals(musicSheetApplication.getPaymentType()) ? "1" : null);
 				record.setClientType(accompaniment.getClientType());
 				record.setExamSongId(accompaniment.getExamSongId());
-				record.setCbsMusicSheetId(musicSheetApplication.getId());
+				record.setCbsMusicSheetId(musicSheetApplication.getId().toString());
 				record.setPlayMode(SysMusicScore.PlayMode.valueOf(musicSheetApplication.getPlayMode().getCode()));
 				record.setExtConfigJson(musicSheetApplication.getExtConfigJson());
 				record.setSubjectId(accompaniment.getSubjectId());
@@ -149,8 +146,8 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
 			musicScoreQueryInfo.setEnable(queryInfo.getEnable());
 			musicScoreQueryInfo.setOrganId(queryInfo.getOrganId());
 			List<SysMusicScoreCategories> scoreCategories = sysMusicScoreCategoriesService.queryTree(musicScoreQueryInfo);
-			if(scoreCategories.size() > 0){
-				categoriesIdList = scoreCategories.stream().map(e->e.getId()).collect(Collectors.toList());
+			if(CollectionUtils.isNotEmpty(scoreCategories)){
+				categoriesIdList = scoreCategories.stream().map(SysMusicScoreCategories::getId).collect(Collectors.toList());
 			}else {
 				categoriesIdList.add(categoriesId);
 			}
@@ -176,15 +173,14 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
 			MusicScoreQueryInfo musicScoreQueryInfo = new MusicScoreQueryInfo();
 			musicScoreQueryInfo.setParentId(categoriesId);
 			List<SysMusicScoreCategories> scoreCategories = sysMusicScoreCategoriesService.queryTree(musicScoreQueryInfo);
-			if(scoreCategories.size() > 0){
-				List<SysMusicScoreCategories> allScoreCategories = new ArrayList<>();
-				allScoreCategories.addAll(scoreCategories);
+			if(CollectionUtils.isNotEmpty(scoreCategories)){
+                List<SysMusicScoreCategories> allScoreCategories = new ArrayList<>(scoreCategories);
 				for (SysMusicScoreCategories scoreCategory : scoreCategories) {
 					if(scoreCategory.getSysMusicScoreCategoriesList() != null){
 						allScoreCategories.addAll(scoreCategory.getSysMusicScoreCategoriesList());
 					}
 				}
-				categoriesIdList = allScoreCategories.stream().map(e->e.getId()).collect(Collectors.toList());
+				categoriesIdList = allScoreCategories.stream().map(SysMusicScoreCategories::getId).collect(Collectors.toList());
 			}else {
 				categoriesIdList.add(categoriesId);
 			}
@@ -232,7 +228,7 @@ public class SysMusicScoreAccompanimentServiceImpl extends BaseServiceImpl<Integ
     
     private void getAllCategoryIdList(List<Integer> categoryIdList, List<SysMusicScoreCategories> sysMusicScoreCategoriesList){
     	
-    	if(sysMusicScoreCategoriesList != null && sysMusicScoreCategoriesList.size() > 0){
+    	if(CollectionUtils.isNotEmpty(sysMusicScoreCategoriesList)){
     		for(SysMusicScoreCategories sysMusicScoreCategories : sysMusicScoreCategoriesList){
     			categoryIdList.add(sysMusicScoreCategories.getId());
     			getAllCategoryIdList(categoryIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());

+ 218 - 321
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreServiceImpl.java

@@ -2,66 +2,66 @@ package com.ym.mec.biz.service.impl;
 
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.beust.jcommander.internal.Lists;
+import com.dayaedu.cbs.common.enums.EClientType;
+import com.dayaedu.cbs.common.enums.music.EAudioType;
+import com.dayaedu.cbs.common.enums.music.EMusicAvailableType;
+import com.dayaedu.cbs.common.enums.music.EMusicPlayMode;
+import com.dayaedu.cbs.common.enums.music.EMusicSourceType;
+import com.dayaedu.cbs.common.enums.school.EMusicSheetType;
+import com.dayaedu.cbs.domain.wrapper.MusicSheetWrapper;
 import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetApplicationExtendClientWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
 import com.microsvc.toolkit.common.response.template.R;
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.MusicScoreDto;
-import com.ym.mec.biz.dal.dto.SysMusicScoreMetronomeTranscod;
-import com.ym.mec.biz.dal.dto.SysMusicScoreTranscod;
-import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.dao.SysMusicScoreAccompanimentDao;
+import com.ym.mec.biz.dal.dao.SysMusicScoreCategoriesDao;
+import com.ym.mec.biz.dal.dao.SysMusicScoreDao;
+import com.ym.mec.biz.dal.dto.ReasonDto;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.SysMusicScore;
+import com.ym.mec.biz.dal.entity.SysMusicScoreAccompaniment;
+import com.ym.mec.biz.dal.entity.SysMusicScoreCategories;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.entity.UploadReturnBean;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
-import com.ym.mec.util.file.FileUtil;
-import com.ym.mec.util.shell.ScriptUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
 import java.util.*;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
-import static com.ym.mec.biz.dal.enums.ClientTypeEnum.SMART_PRACTICE;
-
 @Service
+@Slf4j
 public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicScore> implements SysMusicScoreService {
 
     @Resource
     private SysMusicScoreDao sysMusicScoreDao;
     @Resource
-    private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
-    @Resource
-    private SysUserService sysUserService;
-    @Resource
     private SysMusicScoreCategoriesDao sysMusicScoreCategoriesDao;
     @Resource
-    private SubjectDao subjectDao;
-    @Resource
     private SysMusicScoreCategoriesService sysMusicScoreCategoriesService;
     @Resource
-    private SysMusicScoreChangeLogDao sysMusicScoreChangeLogDao;
-    @Resource
-    private IdGeneratorService idGeneratorService;
+    private OrganizationService organizationService;
     @Resource
-    private UploadFileService uploadFileService;
+    private SubjectService subjectService;
     @Resource
-    private OrganizationService organizationService;
+    private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
     @Resource
     private MusicFeignClientService musicFeignClientService;
 
@@ -78,101 +78,6 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         return sysMusicScoreDao;
     }
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateMusicScore(MusicScoreDto musicScoreDto) {
-        SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
-        sysMusicScoreDao.update(sysMusicScore);
-        List<Integer> delExamSongAccompanimentIds = musicScoreDto.getDelExamSongAccompanimentIds();
-        if (delExamSongAccompanimentIds != null && delExamSongAccompanimentIds.size() > 0) {
-            sysMusicScoreAccompanimentDao.batchDel(delExamSongAccompanimentIds);
-        }
-        List<SysMusicScoreAccompaniment> sysMusicScoreAccompaniments = musicScoreDto.getSysMusicScoreAccompaniments();
-        if (sysMusicScoreAccompaniments != null && sysMusicScoreAccompaniments.size() > 0) {
-            List<Integer> subjectIdList = sysMusicScoreAccompaniments.stream().map(e -> e.getSubjectId()).collect(Collectors.toList());
-            subjectIdList.removeAll(Collections.singleton(null));
-
-            if (subjectIdList.size() > 0) {
-                List<Integer> idList = sysMusicScoreAccompaniments.stream().map(e -> e.getId()).collect(Collectors.toList());
-                List<Integer> subjectIds = sysMusicScoreAccompanimentDao.findSubjectByMusicScoreId(sysMusicScore.getId(), idList);
-                int subjectSize = subjectIds.size() + subjectIdList.size();
-                subjectIdList.addAll(subjectIds);
-                int size = new HashSet<>(subjectIdList).size();
-                if (size < subjectSize && !musicScoreDto.getMultitrack()) {
-                    throw new BizException("操作失败:请勿提交重复的伴奏声部");
-                }
-            }
-            //获取需要修改的伴奏
-            List<SysMusicScoreAccompaniment> updateCollect = sysMusicScoreAccompaniments.stream().filter(e -> e.getId() != null).collect(Collectors.toList());
-            if (updateCollect.size() > 0) {
-                sysMusicScoreAccompanimentDao.batchUpdate(updateCollect, sysMusicScore.getIsOpenMetronome());
-            }
-            //获取需要新增的伴奏
-            List<SysMusicScoreAccompaniment> addCollect = sysMusicScoreAccompaniments.stream().filter(e -> e.getId() == null).collect(Collectors.toList());
-            if (addCollect.size() > 0) {
-                sysMusicScoreAccompanimentDao.batchInsert(addCollect, sysMusicScore.getId(), sysMusicScore.getIsOpenMetronome());
-            }
-        }
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void add(MusicScoreDto musicScoreDto) {
-        SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
-        sysMusicScore.setCreateUserId(sysUserService.getUserId());
-        sysMusicScoreDao.insert(sysMusicScore);
-        List<SysMusicScoreAccompaniment> sysMusicScoreAccompaniments = musicScoreDto.getSysMusicScoreAccompaniments();
-        if (sysMusicScoreAccompaniments != null && sysMusicScoreAccompaniments.size() > 0) {
-            sysMusicScoreAccompaniments.forEach(e -> {
-                e.setIsOpenMetronome(sysMusicScore.getIsOpenMetronome());
-            });
-            sysMusicScoreAccompanimentDao.batchInsert(sysMusicScoreAccompaniments, sysMusicScore.getId(), sysMusicScore.getIsOpenMetronome());
-        }
-        Integer categoriesId = sysMusicScore.getMusicScoreCategoriesId();
-        if (categoriesId != null && sysMusicScore.getClientType() == SMART_PRACTICE) {
-            while (true) {
-                SysMusicScoreCategories categories = sysMusicScoreCategoriesDao.get(categoriesId);
-                if (categories.getParentId() == 0) {
-                    categories.setMusicScoreNum(categories.getMusicScoreNum() + 1);
-                    sysMusicScoreCategoriesDao.update(categories);
-                    return;
-                }
-                categoriesId = categories.getParentId();
-            }
-        }
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void del(Integer id) {
-        SysMusicScore sysMusicScore = sysMusicScoreDao.get(id);
-        if (sysMusicScore == null) {
-            throw new BizException("曲目不存在");
-        }
-        Integer userId = sysUserService.getUserId();
-        if (!Objects.equals(sysMusicScore.getCreateUserId(), userId)) {
-            throw new BizException("无权限删除");
-        }
-        sysMusicScoreDao.delete(id);
-        sysMusicScoreAccompanimentDao.deleteBySongId(id);
-        Integer categoriesId = sysMusicScore.getMusicScoreCategoriesId();
-        if (categoriesId != null && sysMusicScore.getClientType() == SMART_PRACTICE) {
-            while (true) {
-                SysMusicScoreCategories categories = sysMusicScoreCategoriesDao.get(categoriesId);
-                if (categories.getParentId() == 0) {
-                    Integer musicScoreNum = categories.getMusicScoreNum() - 1;
-                    if (musicScoreNum < 0) {
-                        musicScoreNum = 0;
-                    }
-                    categories.setMusicScoreNum(musicScoreNum);
-                    sysMusicScoreCategoriesDao.update(categories);
-                    return;
-                }
-                categoriesId = categories.getParentId();
-            }
-        }
-    }
-
     private String getParentTreeName(Integer categoriesId) {
         StringBuffer sb = new StringBuffer();
         while (true) {
@@ -191,9 +96,9 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
     }
 
     @Override
-    public List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<Long> cbsMusicSheetIds){
+    public List<CbsMusicSheetWrapper.MusicSheetApplication> queryCbsMusicSheetApplication(List<String> cbsMusicSheetIds){
         CbsMusicSheetWrapper.MusicSheetApplicationQuery query = new CbsMusicSheetWrapper.MusicSheetApplicationQuery();
-        query.setMusicSheetIds(cbsMusicSheetIds);
+        query.setMusicSheetIds(cbsMusicSheetIds.stream().map(Long::parseLong).collect(Collectors.toList()));
         query.setDetailFlag(true);
         query.setDelFlag(true);
         query.setPage(1);
@@ -213,60 +118,36 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
 
     private void dealMusicScoreData(List<SysMusicScore> records){
         if (CollectionUtils.isNotEmpty(records)) {
-            List<Long> cbsMusicSheetIds = records.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
+            List<String> cbsMusicSheetIds = records.stream().map(SysMusicScore::getCbsMusicSheetId).collect(Collectors.toList());
             List<CbsMusicSheetWrapper.MusicSheetApplication> applications = this.queryCbsMusicSheetApplication(cbsMusicSheetIds);
             if(CollectionUtils.isNotEmpty(applications)){
+                Set<Integer> categoriesIds = records.stream().map(SysMusicScore::getMusicScoreCategoriesId).collect(Collectors.toSet());
+                //获取分部列表
+                Map<Integer, String> organMap = MapUtil.convertMybatisMap(sysMusicScoreCategoriesDao.queryOrganByIds(categoriesIds));
+                Map<Integer, String> map = new HashMap<>(categoriesIds.size());
+                for (Integer categoriesId : categoriesIds) {
+                    if(null != categoriesId){
+                        map.put(categoriesId, getParentTreeName(categoriesId));
+                    }
+                }
                 Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = applications
                         .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
-                List<Subject> subjects = subjectDao.queryCbsList(null);
-                Map<Long, Subject> subjectMap = subjects.stream().collect(Collectors.toMap(Subject::getCbsSubjectId, Function.identity()));
                 for (SysMusicScore record : records) {
-                    CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMap.get(record.getCbsMusicSheetId());
+                    record.setCategoriesName(map.get(record.getMusicScoreCategoriesId()));
+                    record.setOrganName(organMap.get(record.getMusicScoreCategoriesId()));
+                    CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMap.get(Long.parseLong(record.getCbsMusicSheetId()));
                     if(musicSheetApplication != null){
-                        this.initMusicSheetVo(record,musicSheetApplication,subjectMap);
+                        this.initMusicSheetVo(record,musicSheetApplication);
                     }
                 }
             }
-            Set<Integer> categoriesIds = records.stream().map(e -> e.getMusicScoreCategoriesId()).collect(Collectors.toSet());
-            //获取分部列表
-            Map<Integer, String> organMap = MapUtil.convertMybatisMap(sysMusicScoreCategoriesDao.queryOrganByIds(categoriesIds));
-            //获取声部列表
-            /*Set<Integer> subjectIds = rows.stream().map(e -> e.getSubjectId()).collect(Collectors.toSet());
-            subjectIds.removeAll(Collections.singleton(null));
-            Map<Long, String> subjectMap = new HashMap();
-            if (subjectIds.size() > 0) {
-                String ids = StringUtils.join(subjectIds, ",");
-                subjectMap = MapUtil.convertMybatisMap(subjectDao.findBySubjecIds(ids));
-            }*/
-            Map<Integer, String> map = new HashMap<>(categoriesIds.size());
-            for (Integer categoriesId : categoriesIds) {
-                if(null != categoriesId){
-                    map.put(categoriesId, getParentTreeName(categoriesId));
-                }
-            }
-            for (SysMusicScore row : records) {
-                row.setCategoriesName(map.get(row.getMusicScoreCategoriesId()));
-                row.setOrganName(organMap.get(row.getMusicScoreCategoriesId()));
-//                row.setSubjectName(subjectMap.get(row.getSubjectId()));
-            }
         }
     }
 
-    public void initMusicSheetVo(SysMusicScore record,CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication,Map<Long, Subject> subjectMap){
-        if(StringUtils.isNotEmpty(musicSheetApplication.getSubjectIds())){
-            StringBuffer sb = new StringBuffer();
-            for (String s : musicSheetApplication.getSubjectIds().split(",")) {
-                Subject subject = subjectMap.get(Long.parseLong(s));
-                if(subject != null){
-                    if (sb.length() > 0) {
-                        sb.append(",");
-                    }
-                    sb.append(subject.getName());
-                }
-            }
-            record.setSubjectName(sb.toString());
-        }
-        record.setCbsMusicSheetId(musicSheetApplication.getId());
+    public void initMusicSheetVo(SysMusicScore record,CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication){
+        record.setSubjectName(musicSheetApplication.getSubjectNames());
+        record.setRankIds(StringUtils.equals("FREE",musicSheetApplication.getPaymentType()) ? "" : "1");
+        record.setCbsMusicSheetId(musicSheetApplication.getId().toString());
         record.setPlayMode(SysMusicScore.PlayMode.valueOf(musicSheetApplication.getPlayMode().getCode()));
         record.setExtConfigJson(musicSheetApplication.getExtConfigJson());
         record.setExtStyleConfigJson(musicSheetApplication.getExtStyleConfigJson());
@@ -362,77 +243,6 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
     }
 
     @Override
-    public void transcod(Integer sysMusicScoreId) {
-        SysMusicScoreTranscod obj = sysMusicScoreDao.getTranscod(sysMusicScoreId);
-        if (obj == null) {
-            throw new BizException("曲目信息不存在");
-        }
-        List<SysMusicScoreMetronomeTranscod> metronomeTranscod = sysMusicScoreDao.getMetronomeTranscod(sysMusicScoreId);
-        obj.setAccompanimentList(metronomeTranscod);
-        //
-        String old = JSONObject.toJSONString(obj);
-        boolean flag = false;
-        String url = doTranscod(obj.getUrl());
-        if (StringUtils.isNotEmpty(url)) {
-            obj.setUrl(url);
-            flag = true;
-        }
-        String metronomeUrl = doTranscod(obj.getMetronomeUrl());
-        if (StringUtils.isNotEmpty(metronomeUrl)) {
-            obj.setMetronomeUrl(metronomeUrl);
-            flag = true;
-        }
-        if (flag) {
-            //更新obj
-            SysMusicScore sysMusicScore = new SysMusicScore();
-            sysMusicScore.setId(obj.getId());
-            sysMusicScore.setUrl(obj.getUrl());
-            sysMusicScore.setMetronomeUrl(obj.getMetronomeUrl());
-            sysMusicScoreDao.update(sysMusicScore);
-        }
-
-        for (SysMusicScoreMetronomeTranscod o : metronomeTranscod) {
-            Boolean subFlag = false;
-            String mp3Url = doTranscod(o.getMp3Url());
-            if (StringUtils.isNotEmpty(mp3Url)) {
-                o.setMp3Url(mp3Url);
-                flag = true;
-                subFlag = true;
-            }
-            String metronomeMp3Url = doTranscod(o.getMetronomeMp3Url());
-            if (StringUtils.isNotEmpty(metronomeMp3Url)) {
-                o.setMetronomeMp3Url(metronomeMp3Url);
-                flag = true;
-                subFlag = true;
-            }
-            if (subFlag) {
-                SysMusicScoreAccompaniment accompaniment = new SysMusicScoreAccompaniment();
-                accompaniment.setExamSongId(o.getId());
-                accompaniment.setMp3Url(o.getMp3Url());
-                accompaniment.setMetronomeMp3Url(o.getMetronomeMp3Url());
-                sysMusicScoreDao.updateAccompanimentBySongId(accompaniment);
-            }
-        }
-        if (!flag) {
-            return;
-        }
-        obj.setAccompanimentList(metronomeTranscod);
-        String now = JSONObject.toJSONString(obj);
-
-        //记录日志
-        SysMusicScoreChangeLog log = new SysMusicScoreChangeLog();
-        log.setSysMusicScoreId(obj.getId());
-        log.setChangeBefore(old);
-        log.setChangeAfter(now);
-        sysMusicScoreChangeLogDao.insert(log);
-    }
-
-    @Override
-	public int updateExtStyleConfigJson(Integer id, String extStyleConfigJson) {
-		return sysMusicScoreDao.updateExtStyleConfigJson(id, extStyleConfigJson);
-	}
-
-    @Override
     public Map<Long, SysMusicScore> getMapByIds(List<Long> musicSheetIds) {
         if (CollectionUtils.isEmpty(musicSheetIds)) {
             return new HashMap<>();
@@ -446,108 +256,195 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
     }
 
     @Override
-    public void enable(Integer sysMusicScoreId, Integer showFlag) {
-        SysMusicScore sysMusicScore = this.get(sysMusicScoreId);
-        if(sysMusicScore == null){
+    public Boolean stateList(ReasonDto reasonDto) {
+        List<Integer> musicSheets = Arrays.stream(reasonDto.getMusicSheetIds().split(",")).map(Integer::parseInt).collect(Collectors.toList());
+        List<SysMusicScore> musicSheetList = sysMusicScoreDao.findByIds(musicSheets.stream().map(String::valueOf).collect(Collectors.joining(",")));
+
+        List<CbsMusicSheetWrapper.MusicSheetApplication> rows =
+                this.queryCbsMusicSheetApplication(musicSheetList.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList()));
+        String applicationExtendIds = rows.stream().map(e -> e.getApplicationExtendId().toString()).collect(Collectors.joining(","));
+        CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus extendStatus = new CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus();
+        extendStatus.setIds(applicationExtendIds);
+        extendStatus.setStatus(reasonDto.getState()== YesOrNoEnum.YES);
+        R<JSONObject> jsonObjectR = musicFeignClientService.musicSheetApplicationExtendStatus(extendStatus);
+        if (jsonObjectR.getCode() != 200) {
+            throw new BizException("修改曲目状态失败,{}", jsonObjectR.getMessage());
+        }
+        return true;
+    }
+
+    @Override
+    public Boolean state(Integer id) {
+        SysMusicScore musicScore = sysMusicScoreDao.get(id);
+        if (musicScore == null) {
             throw new BizException("曲目信息不存在");
         }
-        CbsMusicSheetWrapper.MusicSheetApplicationQuery query = new CbsMusicSheetWrapper.MusicSheetApplicationQuery();
-        query.setApplicationId(applicationId);
-        query.setMusicSheetIds(Collections.singletonList(sysMusicScore.getCbsMusicSheetId()));
-        query.setDelFlag(true);
-        query.setPage(1);
-        query.setRows(1);
-        R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> pageInfoR = musicFeignClientService.musicSheetPageByApplication(query);
-        if (pageInfoR.getCode() != 200) {
-            throw new BizException("获取曲目信息异常,{}", pageInfoR.getMessage());
+        List<CbsMusicSheetWrapper.MusicSheetApplication> rows =
+                this.queryCbsMusicSheetApplication(Collections.singletonList(musicScore.getCbsMusicSheetId()));
+        String applicationExtendIds = rows.stream().map(e -> e.getApplicationExtendId().toString()).collect(Collectors.joining(","));
+        CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus extendStatus = new CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus();
+        extendStatus.setIds(applicationExtendIds);
+        extendStatus.setStatus(musicScore.getShowFlag() != 1);
+        R<JSONObject> jsonObjectR = musicFeignClientService.musicSheetApplicationExtendStatus(extendStatus);
+        if (jsonObjectR.getCode() != 200) {
+            throw new BizException("修改曲目状态失败,{}", jsonObjectR.getMessage());
         }
-        List<CbsMusicSheetWrapper.MusicSheetApplication> rows = pageInfoR.feignData().getRows();
-        if (CollectionUtils.isEmpty(rows)) {
-            throw new BizException("获取曲目信息失败");
+        return true;
+    }
+
+    @Override
+    public void updateCbs(MusicSheetWrapper.MusicSheetApplicationExtendWrapper addMusicSheetApplicationExtend) {
+        CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend extend =
+                JSONObject.parseObject(JSONObject.toJSONString(addMusicSheetApplicationExtend), CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend.class);
+        extend.setApplicationId(applicationId);
+        R<JSONObject> jsonObjectR = musicFeignClientService.musicSheetApplicationExtendUpdate(extend);
+        if (jsonObjectR.getCode() != 200) {
+            throw new BizException("修改失败,{}",jsonObjectR.getMessage());
         }
-        CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = rows.get(0);
-        CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus extendStatus = new CbsMusicSheetApplicationExtendClientWrapper.MusicSheetApplicationExtendStatus();
-        extendStatus.setIds(musicSheetApplication.getApplicationExtendId().toString());
-        extendStatus.setStatus(showFlag == 1);
-        musicFeignClientService.musicSheetApplicationExtendStatus(extendStatus);
     }
 
-    /**
-     * 进行转码
-     *
-     * @param fileUrl
-     * @return
-     */
-    private String doTranscod(String fileUrl) {
-        String transcodUrl = "";
-        if (StringUtils.isEmpty(fileUrl)) {
-            return transcodUrl;
+    @Override
+    public void sync() {
+        ThreadPoolExecutor executorService =  new ThreadPoolExecutor(50, 50,
+                0L, TimeUnit.MILLISECONDS,
+                new LinkedBlockingQueue<>());
+        List<SysMusicScore> records = sysMusicScoreDao.selectSyncPage();
+        if (CollectionUtils.isEmpty(records)) {
+            return;
         }
-        //文件扩展名
-        String expand = FileUtil.getFileExpandByPath(fileUrl);
-        //将远程文件写入本地临时文件路径
-        String tempFileName = getTempFileName(expand);
-        File tempFile = new File(tempFileName);
-        //转码后文件路径
-        String tempTranscodFileName = getTempFileName(expand);
-        try {
-            URL url = new URL(fileUrl);
-            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-            //设置超时间为3秒
-            conn.setConnectTimeout(3 * 1000);
-            //防止屏蔽程序抓取而返回403错误
-            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
-
-            FileUtil.inputStreamToFile(conn.getInputStream(), tempFile);
-
-            String script = "ffmpeg -i " + tempFileName + " -vn -c:a libmp3lame -b:a 320k -ac 2 " + tempTranscodFileName;
-            int i = ScriptUtil.callScript(script);
-            if (i == 0) {
-                //转码成功
-                FileInputStream inputStream = new FileInputStream(tempTranscodFileName);
-                UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(inputStream, expand);
-                transcodUrl = uploadReturnBean.getUrl();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            //删除服务器中的文件
-            if (tempFile.exists()) {
-                tempFile.delete();
+        for (SysMusicScore record : records) {
+            executorService.submit(() ->
+                    {
+                        try {
+                            syncMusicSheet(record);
+                        }catch (Exception e) {
+                            log.error("曲目同步异常,曲目ID:{}", record.getId(), e);
+                        }
+                    }
+            );
+        }
+        while (!executorService.getQueue().isEmpty()) {
+            try {
+                log.info("线程池中正在执行的任务数量:{},等待数量:{}", executorService.getActiveCount(),executorService.getQueue().size());
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                log.error("线程等待异常", e);
             }
-            File tempTranscodFile = new File(tempTranscodFileName);
-            if (tempTranscodFile.exists()) {
-                tempTranscodFile.delete();
+        }
+        log.info("-------------------- 曲目数据同步成功! -------------------------------");
+        executorService.shutdown();
+    }
+
+    private void syncMusicSheet(SysMusicScore record) {
+        List<SysMusicScoreAccompaniment> list = sysMusicScoreAccompanimentDao.findByMusicScoreId(record.getId());
+
+        CbsMusicSheetWrapper.AddMusicSheet addMusicSheet = this.musicToAddMusicSheet(record,list);
+
+        R<CbsMusicSheetWrapper.MusicSheet> musicSheetR = musicFeignClientService.musicCbsSync(addMusicSheet);
+        try {
+            CbsMusicSheetWrapper.MusicSheet musicSheet = musicSheetR.feignData();
+            if (musicSheet == null) {
+                log.error("曲目同步失败,曲目ID:{}", record.getId());
             }
+        } catch (Exception e){
+            log.error("曲目同步失败,曲目ID:{}", record.getId(),e);
         }
-        return transcodUrl;
+
     }
 
-    /**
-     * 通过网络文件路径获取临时文件路径
-     *
-     * @param fileUrl
-     * @return
-     */
-    String tempPath = "/usr/temp";
-
-    private String getTempFileName(String expand) {
-        //没有目录则创建
-        File file = new File(tempPath);
-        if (!file.exists()) {
-            file.mkdirs();
+    //测试环境合奏分类
+    private static String categoryIds = "42,43,44,45,46,91,92,93,94,95,7,11,15,180";
+    private static String prodCategoryIds = "42,43,44,45,46,91,92,93,94,95,185,186,7,11,15,180";
+
+    private CbsMusicSheetWrapper.AddMusicSheet musicToAddMusicSheet(SysMusicScore from, List<SysMusicScoreAccompaniment> accList) {
+        CbsMusicSheetWrapper.AddMusicSheet addMusicSheet = new CbsMusicSheetWrapper.AddMusicSheet();
+        addMusicSheet.setId(Long.parseLong(from.getCbsMusicSheetId()));
+        addMusicSheet.setName(from.getName());
+        if (StringUtils.isNotBlank(from.getSubjectIds())) {
+            List<Integer> subjectIds = Arrays.stream(from.getSubjectIds().split(","))
+                    .map(Integer::parseInt).distinct().collect(Collectors.toList());
+            List<Subject> list = subjectService.findBySubjectByIdList(subjectIds);
+            if (CollectionUtils.isNotEmpty(list)) {
+                addMusicSheet.setSubjectIds(list.stream().map(o->o.getCbsSubjectId().toString()).collect(Collectors.joining(",")));
+            }
         }
-        //.mp3
-        String fileName = tempPath + File.separator + idGeneratorService.generatorId("tempFile");
-        if (StringUtils.isNotEmpty(expand)) {
-            fileName += "." + expand;
+        addMusicSheet.setSendAppFlag(false);
+        addMusicSheet.setAppAuditFlag(false);
+        addMusicSheet.setRemark(from.getMuseScoreMemo());
+        addMusicSheet.setIsUseSystemBeat(true);
+        if(categoryIds.contains(from.getCategoriesId().toString())){
+            addMusicSheet.setMusicSheetType(EMusicSheetType.CONCERT);
+        }else {
+            addMusicSheet.setMusicSheetType(EMusicSheetType.SINGLE);
+        }
+        addMusicSheet.setIsEvaluated(from.isEnableEvaluation());
+        addMusicSheet.setIsConvertibleScore(true);
+        addMusicSheet.setPlaySpeed(from.getSpeed());
+        addMusicSheet.setPlayMode(from.getPlayMode() == SysMusicScore.PlayMode.MP3 ? EMusicPlayMode.MP3 : EMusicPlayMode.MIDI);
+        addMusicSheet.setMidiFileUrl(from.getMidiUrl());
+        addMusicSheet.setExtConfigJson(from.getExtConfigJson());
+        addMusicSheet.setCreateTime(from.getCreateTime());
+        addMusicSheet.setAudioType(EAudioType.HOMEMODE);
+        addMusicSheet.setAvailableType(EMusicAvailableType.ORG);
+        addMusicSheet.setSourceType(EMusicSourceType.PLATFORM);
+        addMusicSheet.setStatus(true);
+
+        String tracks = "";
+        // 伴奏,原音 扩展信息
+        if (addMusicSheet.getPlayMode() == EMusicPlayMode.MP3) {
+            CbsMusicSheetWrapper.MusicSheetAccompaniment musicSheetAccompaniment = new CbsMusicSheetWrapper.MusicSheetAccompaniment();
+            if (StringUtils.isNotBlank(musicSheetAccompaniment.getAudioFileUrl())) {
+                addMusicSheet.setMusicSheetAccompanimentList(Lists.newArrayList(musicSheetAccompaniment));
+            }
+            if (CollectionUtils.isNotEmpty(accList)) {
+                List<CbsMusicSheetWrapper.MusicSheetSound> musicSheetSounds = new ArrayList<>();
+                int i = 0;
+                for (SysMusicScoreAccompaniment sheetAccompaniment : accList) {
+                    CbsMusicSheetWrapper.MusicSheetSound musicSheetSound = new CbsMusicSheetWrapper.MusicSheetSound();
+                    if (StringUtils.isNotBlank(sheetAccompaniment.getMetronomeMp3Url())){
+                        musicSheetSound.setAudioFileUrl(sheetAccompaniment.getMetronomeMp3Url());
+                    } else {
+                        musicSheetSound.setAudioFileUrl(sheetAccompaniment.getMp3Url());
+                    }
+                    musicSheetSound.setTrack(sheetAccompaniment.getTrack());
+                    musicSheetSound.setSortNumber(i++);
+                    if (StringUtils.isNotBlank(musicSheetSound.getAudioFileUrl())) {
+                        //xml
+                        addMusicSheet.setXmlFileUrl(sheetAccompaniment.getXmlUrl());
+                        //是否显示指法
+                        addMusicSheet.setIsShowFingering(sheetAccompaniment.getIsShowFingering());
+                        //是否播放节拍器
+                        addMusicSheet.setIsPlayBeat(sheetAccompaniment.getIsOpenMetronome());
+                        musicSheetSounds.add(musicSheetSound);
+                    }
+                }
+                tracks = musicSheetSounds.stream().map(CbsMusicSheetWrapper.MusicSheetSound::getTrack).collect(Collectors.joining(","));
+                addMusicSheet.setMusicSheetSoundList(musicSheetSounds);
+            }
         }
-        return fileName;
+        addMusicSheet.setMultiTracksSelection(tracks);
+
+        CbsMusicSheetWrapper.MusicSheetExtend musicSheetExtend = new CbsMusicSheetWrapper.MusicSheetExtend();
+        musicSheetExtend.setApplicationId(applicationId);
+        musicSheetExtend.setClientType(EClientType.BACKEND.name());
+        addMusicSheet.setMusicSheetExtend(musicSheetExtend);
+
+        // 应用扩展信息
+        CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend addMusicSheetApplicationExtend = new CbsMusicSheetApplicationExtendClientWrapper.AddMusicSheetApplicationExtend();
+        addMusicSheetApplicationExtend.setApplicationId(applicationId);
+        addMusicSheetApplicationExtend.setStatus(addMusicSheet.getStatus());
+        addMusicSheetApplicationExtend.setSortNo(from.getOrder());
+        addMusicSheetApplicationExtend.setPaymentType(StringUtils.isNotEmpty(from.getRankIds()) ? "PAY" : "FREE");
+        addMusicSheetApplicationExtend.setAvailableType(EMusicAvailableType.ORG);
+        addMusicSheetApplicationExtend.setMusicSheetCategoryId(from.getCategoriesId().longValue());
+        addMusicSheet.setAddMusicSheetApplicationExtend(Lists.newArrayList(addMusicSheetApplicationExtend));
+        addMusicSheet.setIsConvertibleScore(true);
+        return addMusicSheet;
     }
 
     private void getAllCategoryIdList(List<Integer> categoryIdList, List<SysMusicScoreCategories> sysMusicScoreCategoriesList) {
 
-        if (sysMusicScoreCategoriesList != null && sysMusicScoreCategoriesList.size() > 0) {
+        if (CollectionUtils.isNotEmpty(sysMusicScoreCategoriesList)) {
             for (SysMusicScoreCategories sysMusicScoreCategories : sysMusicScoreCategoriesList) {
                 categoryIdList.add(sysMusicScoreCategories.getId());
                 getAllCategoryIdList(categoryIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());

+ 39 - 0
mec-biz/src/main/resources/config/mybatis/InstrumentMapper.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE  mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ym.mec.biz.dal.dao.InstrumentDao">
+
+
+
+    <!-- 表字段 -->
+    <sql id="baseColumns">
+         t.id_ AS id
+        , t.subject_id_ AS subjectId
+        , t.orientation_ AS orientation
+        , t.del_flag_ AS delFlag
+        , t.enable_flag_ AS enableFlag
+        , t.create_time_ AS createTime
+        , t.update_time_ AS updateTime
+        , t.operator_ AS operator
+        </sql>
+
+    <select id="selectPage" resultType="com.ym.mec.biz.dal.wrapper.InstrumentWrapper$Instrument">
+		SELECT
+        	<include refid="baseColumns" />
+		FROM instrument t
+        <where>
+            <if test="param.subjectId != null">
+                AND t.subject_id_ = #{param.subjectId}
+            </if>
+            <if test="param.subjectIds != null and param.subjectIds.size() != 0">
+                AND t.subject_id_ in
+                <foreach collection="param.subjectIds" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="param.enableFlag != null">
+                AND t.enable_flag_ = #{param.enableFlag}
+            </if>
+        </where>
+	</select>
+
+</mapper>

+ 97 - 3
mec-biz/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -42,9 +42,6 @@
             <if test="delFlag != null">
                 del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
-            <if test="cbsSubjectId != null">
-                parent_subject_id_ = #{cbsSubjectId},
-            </if>
             <if test="parentSubjectId != null">
                 cbs_subject_id_ = #{parentSubjectId},
             </if>
@@ -318,4 +315,101 @@
             </foreach>
         </if>
     </select>
+    <select id="notInSubjectIds" resultMap="Subject">
+        SELECT * FROM subject WHERE del_flag_ = 0 and id_ != #{subjectId}
+    </select>
+    <select id="findCount" resultType="java.lang.Integer">
+        select count(DISTINCT t.id_) from
+        (SELECT t.id_
+        FROM subject t
+        LEFT JOIN instrument i on t.id_ = i.subject_id_
+        <where>
+            <if test="parentSubjectId != null">
+                AND t.parent_subject_id_ = #{parentSubjectId}
+            </if>
+            <if test="parentSubjectId == null">
+                AND t.parent_subject_id_ != 0 AND t.cbs_subject_id_ is not null
+            </if>
+            <if test="keyword != null and keyword != ''">
+                AND (t.name_ LIKE CONCAT('%',#{keyword},'%') OR t.code_ LIKE CONCAT('%',#{keyword},'%'))
+            </if>
+            <if test="delFlag != null">
+                AND t.del_flag_ = #{delFlag}
+            </if>
+            <if test="subjectId != null">
+                AND t.id_ = #{subjectId}
+            </if>
+            <if test="subjectIds != null">
+                AND find_in_set(t.id_,#{subjectIds})
+            </if>
+            <if test="instrumentIds != null">
+                AND find_in_set(i.id_, #{instrumentIds})
+            </if>
+            <if test="enableFlag != null">
+                AND t.enable_flag_ = #{enableFlag} and i.enable_flag_ = #{enableFlag}
+            </if>
+        </where>
+        group by t.id_
+        <if test="hasInstrument != null">
+            <if test="hasInstrument == true">
+                having count(i.id_) > 0
+            </if>
+            <if test="hasInstrument == false">
+                having count(i.id_) = 0
+            </if>
+        </if>) t
+    </select>
+    <sql id="baseColumns">
+        t.id_ as id
+        , t.name_ as name
+        , t.code_ as code
+        , t.parent_subject_id_ as parentSubjectId
+        , t.img_ as img
+        , t.del_flag_ as delFlag
+        , t.update_time_ as updateTime
+        , t.create_time_ as createTime
+        ,t.cbs_subject_id_ as cbsSubjectId
+    </sql>
+    <select id="findPage" resultType="com.ym.mec.biz.dal.wrapper.SubjectWrapper$Subject">
+        SELECT
+        <include refid="baseColumns" />
+        FROM subject t
+        LEFT JOIN instrument i on t.id_ = i.subject_id_
+        <where>
+            <if test="parentSubjectId != null">
+                AND t.parent_subject_id_ = #{parentSubjectId}
+            </if>
+            <if test="parentSubjectId == null">
+                AND t.parent_subject_id_ != 0 AND t.cbs_subject_id_ is not null
+            </if>
+            <if test="keyword != null and keyword != ''">
+                AND (t.name_ LIKE CONCAT('%',#{keyword},'%') OR t.code_ LIKE CONCAT('%',#{keyword},'%'))
+            </if>
+            <if test="delFlag != null">
+                AND t.del_flag_ = #{delFlag}
+            </if>
+            <if test="subjectId != null">
+                AND t.id_ = #{subjectId}
+            </if>
+            <if test="subjectIds != null">
+                AND find_in_set(t.id_,#{subjectIds})
+            </if>
+            <if test="instrumentIds != null">
+                AND find_in_set(i.id_, #{instrumentIds})
+            </if>
+            <if test="enableFlag != null">
+                AND t.enable_flag_ = #{enableFlag} and i.enable_flag_ = #{enableFlag}
+            </if>
+        </where>
+        group by t.id_
+        <if test="hasInstrument != null">
+            <if test="hasInstrument == true">
+                having count(i.id_) > 0
+            </if>
+            <if test="hasInstrument == false">
+                having count(i.id_) = 0
+            </if>
+        </if>
+        <include refid="global.limit"/>
+    </select>
 </mapper>

+ 4 - 1
mec-biz/src/main/resources/config/mybatis/SysMusicScoreAccompanimentMapper.xml

@@ -215,8 +215,11 @@
 		</if>
 		GROUP BY sesa.subject_id_
 	</select>
+    <select id="findByMusicScoreId" resultMap="SysMusicScoreAccompaniment">
+		SELECT * FROM sys_music_score_accompaniment WHERE exam_song_id_ = #{recordId} AND del_flag_ = 0
+	</select>
 
-	<sql id="queryPageSql">
+    <sql id="queryPageSql">
 		<where>
 			sesa.del_flag_ = 0 AND ses.del_flag_ = 0
 			<if test="enable != null">

+ 3 - 35
mec-biz/src/main/resources/config/mybatis/SysMusicScoreMapper.xml

@@ -167,24 +167,6 @@
     <select id="countBuyCategoriesIds" resultType="java.lang.Integer">
 		SELECT COUNT(0) FROM sys_music_score WHERE FIND_IN_SET(music_score_categories_id_,#{categoriesIds}) AND del_flag_ = 0
 	</select>
-    <select id="getTranscod" resultType="com.ym.mec.biz.dal.dto.SysMusicScoreTranscod">
-		select
-			t.id_ as id,
-		   	t.url_ as url,
-		   	t.metronome_url_ as metronomeUrl
-		from sys_music_score t
-		where t.del_flag_ = 0 and t.id_ = #{sysMusicScoreId}
-	</select>
-
-	<select id="getMetronomeTranscod" resultType="com.ym.mec.biz.dal.dto.SysMusicScoreMetronomeTranscod">
-		select
-			smsa.id_ as id,
-			smsa.exam_song_id_ as examSongId,
-			smsa.mp3_url_ as mp3Url,
-			smsa.metronome_mp3_url_ as metronomeMp3Url
-		from sys_music_score_accompaniment smsa
-		where smsa.del_flag_ = 0 and smsa.exam_song_id_ = #{sysMusicScoreId}
-	</select>
 	<select id="findByCbsId" resultMap="SysMusicScore">
 		SELECT * FROM sys_music_score WHERE del_flag_ = 0
 		<if test="cbsMusicSheetIds != null">
@@ -194,24 +176,10 @@
 			</foreach>
 		</if>
 	</select>
+	<select id="selectSyncPage" resultMap="SysMusicScore">
+		select * from sys_music_score where cbs_music_sheet_id_ iS NOT NULL and del_flag_ = 0 and show_flag_ = 1
+	</select>
 
-	<update id="updateAccompanimentBySongId">
-		update sys_music_score_accompaniment t
-		<set>
-			<if test="param.mp3Url != null and param.mp3Url != ''">
-				t.mp3_url_ = #{param.mp3Url},
-			</if>
-			<if test="param.metronomeMp3Url != null and param.metronomeMp3Url != ''">
-				t.metronome_mp3_url_ = #{param.metronomeMp3Url},
-			</if>
-		</set>
-		where t.exam_song_id_ = #{param.examSongId} and t.del_flag_ = 0
-	</update>
-
-	<update id="updateExtStyleConfigJson">
-		update sys_music_score ms set ms.ext_style_config_json_ = #{extStyleConfigJson}
-		where ms.id_ = #{id}
-	</update>
 	<update id="updateBatchByCbsId">
 		<foreach collection="vos" item="item" index="index" separator=";">
 			update sys_music_score set music_score_categories_id_ = #{item.musicSheetCategoryId},

+ 1 - 1
mec-common/audit-log/src/main/java/com/yonge/log/interceptor/AuditLogInterceptor.java

@@ -41,7 +41,7 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
 
     @Override
     public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
-        syncSaveLog(request, handler);
+//        syncSaveLog(request, handler);
     }
 
     public void syncSaveLog(HttpServletRequest request, Object handler) {

+ 1 - 1
pom.xml

@@ -25,8 +25,8 @@
 		<docker.host>http://127.0.0.1:2375</docker.host>
 		<docker.registry.repository>127.0.0.1:5000</docker.registry.repository>
 		<docker.maven.plugin.version>1.2.2</docker.maven.plugin.version>
+		<com.microsvc.toolkit.version>1.0.4</com.microsvc.toolkit.version>
 		<cbs.version>1.0.10</cbs.version>
-		<com.microsvc.toolkit.version>1.0.7</com.microsvc.toolkit.version>
 	</properties>
 
 	<dependencyManagement>