Bladeren bron

管乐迷曲目来源内容平台

zouxuan 1 jaar geleden
bovenliggende
commit
89546a07d1

+ 9 - 7
mec-application/src/main/java/com/ym/mec/web/controller/SysMusicScoreController.java

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 @RequestMapping("${app-config.url.web:}/sysMusicScore")
@@ -23,16 +24,16 @@ import java.util.List;
 @RestController
 public class SysMusicScoreController extends BaseController {
 
-    @Autowired
+    @Resource
     private SysMusicScoreService sysMusicScoreService;
 
-    @ApiOperation(value = "修改")
+    /*@ApiOperation(value = "修改")
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('sysMusicScore/update')")
     public Object update(@RequestBody MusicScoreDto musicScoreDto) {
         sysMusicScoreService.updateMusicScore(musicScoreDto);
         return succeed();
-    }
+    }*/
 
     @ApiOperation(value = "修改样式")
     @PostMapping("/updateExtStyleConfigJson")
@@ -45,7 +46,7 @@ public class SysMusicScoreController extends BaseController {
     @ApiOperation(value = "启用/停用")
     @PostMapping("/show")
     @PreAuthorize("@pcs.hasPermissions('sysMusicScore/show')")
-    public Object update(Integer sysMusicScoreId,Integer showFlag) {
+    public HttpResponseResult<Object> update(Integer sysMusicScoreId, Integer showFlag) {
         SysMusicScore sysMusicScore = sysMusicScoreService.get(sysMusicScoreId);
         if(sysMusicScore == null){
             throw new BizException("曲目信息不存在");
@@ -55,13 +56,13 @@ public class SysMusicScoreController extends BaseController {
         return succeed();
     }
 
-    @ApiOperation(value = "新增")
+    /*@ApiOperation(value = "新增")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('sysMusicScore/add')")
     public Object add(@RequestBody MusicScoreDto musicScoreDto) {
         sysMusicScoreService.add(musicScoreDto);
         return succeed();
-    }
+    }*/
 
     @ApiOperation(value = "删除")
     @PostMapping("/del")
@@ -84,7 +85,8 @@ public class SysMusicScoreController extends BaseController {
         queryInfo.setType("COMMON");
         queryInfo.setShowFlag(1);
         queryInfo.setClientType(ClientTypeEnum.SMART_PRACTICE);
-        return succeed(sysMusicScoreService.queryMusicScorePageInfo(queryInfo));
+//        return succeed(sysMusicScoreService.queryMusicScorePageInfo(queryInfo));
+        return succeed(sysMusicScoreService.queryMusicScorePage(queryInfo));
     }
     
     private void getAllCategoryIdList(List<Integer> categoryIdList, List<SysMusicScoreCategories> sysMusicScoreCategoriesList){

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

@@ -174,4 +174,6 @@ public interface SubjectDao extends BaseDAO<Integer, Subject> {
     List<StudentSubjectDto> getSubjectByStudentId(@Param("studentIds") Set studentIds);
 
     List<Subject> findByNames();
+
+    List<Subject> queryCbsList(@Param("cbsSubjectIds") List<Long> cbsSubjectIds);
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysMusicScoreDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 
+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;
@@ -24,4 +25,8 @@ public interface SysMusicScoreDao extends BaseDAO<Integer, SysMusicScore> {
     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(List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> updateMusicScore);
 }

+ 5 - 98
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Subject.java

@@ -1,9 +1,8 @@
 package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
-
 import io.swagger.annotations.ApiModelProperty;
-
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.math.BigDecimal;
@@ -12,10 +11,14 @@ import java.util.List;
 /**
  * 对应数据库表(subject):
  */
+@Data
 public class Subject {
 
 	/**  */
 	private Integer id;
+
+	/**  */
+	private Long cbsSubjectId;
 	
 	/**  */
 	@ApiModelProperty(value = "科目名称",required = false)
@@ -57,104 +60,8 @@ public class Subject {
 	@ApiModelProperty(value = "子节点列表",required = false)
 	private List<Subject> subjects;
 
-	public Integer getTenantId() {
-		return tenantId;
-	}
-
-	public void setTenantId(Integer tenantId) {
-		this.tenantId = tenantId;
-	}
-
-	public List<Subject> getSubjects() {
-		return subjects;
-	}
-
-	public BigDecimal getFee() {
-		return fee;
-	}
-
-	public void setFee(BigDecimal fee) {
-		this.fee = fee;
-	}
-
-	public void setSubjects(List<Subject> subjects) {
-		this.subjects = subjects;
-	}
-
-	public void setId(Integer id){
-		this.id = id;
-	}
-	
-	public Integer getId(){
-		return this.id;
-	}
-			
-	public void setName(String name){
-		this.name = name;
-	}
-	
-	public String getName(){
-		return this.name;
-	}
-			
-	public void setCode(String code){
-		this.code = code;
-	}
-	
-	public String getCode(){
-		return this.code;
-	}
-			
-	public void setParentSubjectId(Integer parentSubjectId){
-		this.parentSubjectId = parentSubjectId;
-	}
-	
-	public Integer getParentSubjectId(){
-		return this.parentSubjectId;
-	}
-			
-	public void setCreateTime(java.util.Date createTime){
-		this.createTime = createTime;
-	}
-	
-	public java.util.Date getCreateTime(){
-		return this.createTime;
-	}
-			
-	public void setUpdateTime(java.util.Date updateTime){
-		this.updateTime = updateTime;
-	}
-	
-	public java.util.Date getUpdateTime(){
-		return this.updateTime;
-	}
-
-	public YesOrNoEnum getDelFlag() {
-		return delFlag;
-	}
-
-	public void setDelFlag(YesOrNoEnum delFlag) {
-		this.delFlag = delFlag;
-	}
-
-	public String getImg() {
-		return img;
-	}
-
-	public void setImg(String img) {
-		this.img = img;
-	}
-
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
-
-	public String getParentSubjectName() {
-		return parentSubjectName;
-	}
-
-	public void setParentSubjectName(String parentSubjectName) {
-		this.parentSubjectName = parentSubjectName;
-	}
 }

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

@@ -3,11 +3,14 @@ package com.ym.mec.biz.dal.entity;
 import com.ym.mec.biz.dal.enums.ClientTypeEnum;
 import com.ym.mec.biz.dal.enums.ExamSongTypeEnum;
 import com.ym.mec.common.enums.BaseEnum;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * 对应数据库表(sys_music_score):
  */
+@Data
 public class SysMusicScore {
 	
 	public enum PlayMode  implements BaseEnum<String, PlayMode> {
@@ -37,6 +40,9 @@ public class SysMusicScore {
 
 	/**  */
 	private Integer id;
+
+	@ApiModelProperty(value = "内容平台曲目ID")
+	private Long cbsMusicSheetId;  //主键ID
 	
 	/**  */
 	private Integer musicScoreCategoriesId;
@@ -63,7 +69,7 @@ public class SysMusicScore {
 	private String subjectName;
 	
 	/** 速度 */
-	private Integer speed;
+	private String speed;
 	
 	/** 原音MP3 */
 	private String url;
@@ -107,8 +113,8 @@ public class SysMusicScore {
 	/**  */
 	private java.util.Date createTime;
 
-	//是否显示
 	private Integer showFlag = 0;
+
 	private String showName;
 
 	private Boolean isOpenMetronome;
@@ -122,303 +128,6 @@ public class SysMusicScore {
 	private PlayMode playMode;
 
 	private String organName;
-
-	public String getExtConfigJson() {
-		return extConfigJson;
-	}
-
-	public void setExtConfigJson(String extConfigJson) {
-		this.extConfigJson = extConfigJson;
-	}
-
-	public String getExtStyleConfigJson() {
-		return extStyleConfigJson;
-	}
-
-	public void setExtStyleConfigJson(String extStyleConfigJson) {
-		this.extStyleConfigJson = extStyleConfigJson;
-	}
-
-	public String getTypeName() {
-		return typeName;
-	}
-
-	public void setTypeName(String typeName) {
-		this.typeName = typeName;
-	}
-
-	public String getOpenMetronomeName() {
-		return openMetronomeName;
-	}
-
-	public String getShowName() {
-		return showName;
-	}
-
-	public void setShowName(String showName) {
-		this.showName = showName;
-	}
-
-	public void setOpenMetronomeName(String openMetronomeName) {
-		this.openMetronomeName = openMetronomeName;
-	}
-
-	public Integer getSubjectId() {
-		return subjectId;
-	}
-
-	public void setSubjectId(Integer subjectId) {
-		this.subjectId = subjectId;
-	}
-
-	public String getSubjectName() {
-		return subjectName;
-	}
-
-	public void setSubjectName(String subjectName) {
-		this.subjectName = subjectName;
-	}
-
-	public String getOrganName() {
-		return organName;
-	}
-
-	public void setOrganName(String organName) {
-		this.organName = organName;
-	}
-
-	public Boolean getIsOpenMetronome() {
-		return isOpenMetronome;
-	}
-
-	public void setIsOpenMetronome(Boolean isOpenMetronome) {
-		this.isOpenMetronome = isOpenMetronome;
-	}
-
-	public PlayMode getPlayMode() {
-		return playMode;
-	}
-
-	public void setPlayMode(PlayMode playMode) {
-		this.playMode = playMode;
-	}
-
-	public String getAccompanimentUrl() {
-		return accompanimentUrl;
-	}
-
-	public void setAccompanimentUrl(String accompanimentUrl) {
-		this.accompanimentUrl = accompanimentUrl;
-	}
-
-	public String getAccompanimentMetronomeUrl() {
-		return accompanimentMetronomeUrl;
-	}
-
-	public void setAccompanimentMetronomeUrl(String accompanimentMetronomeUrl) {
-		this.accompanimentMetronomeUrl = accompanimentMetronomeUrl;
-	}
-
-	public String getXmlUrl() {
-		return xmlUrl;
-	}
-
-	public void setXmlUrl(String xmlUrl) {
-		this.xmlUrl = xmlUrl;
-	}
-
-	public String getMetronomeUrl() {
-		return metronomeUrl;
-	}
-
-	public void setMetronomeUrl(String metronomeUrl) {
-		this.metronomeUrl = metronomeUrl;
-	}
-
-	public String getMidiUrl() {
-		return midiUrl;
-	}
-
-	public void setMidiUrl(String midiUrl) {
-		this.midiUrl = midiUrl;
-	}
-
-	public Integer getShowFlag() {
-		return showFlag;
-	}
-
-	public void setShowFlag(Integer showFlag) {
-		this.showFlag = showFlag;
-	}
-
-	public String getRankIds() {
-		return rankIds;
-	}
-
-	public void setRankIds(String rankIds) {
-		this.rankIds = rankIds;
-	}
-
-	public String getRenderFrom() {
-		return renderFrom;
-	}
-
-	public void setRenderFrom(String renderFrom) {
-		this.renderFrom = renderFrom;
-	}
-
-	public boolean isEnableEvaluation() {
-		return enableEvaluation;
-	}
-
-	public void setEnableEvaluation(boolean enableEvaluation) {
-		this.enableEvaluation = enableEvaluation;
-	}
-
-	public ClientTypeEnum getClientType() {
-		return clientType;
-	}
-
-	public void setClientType(ClientTypeEnum clientType) {
-		this.clientType = clientType;
-	}
-
-	public Integer getOrder() {
-		return order;
-	}
-
-	public void setOrder(Integer order) {
-		this.order = order;
-	}
-
-	public Integer getCategoriesId() {
-		return categoriesId;
-	}
-
-	public void setCategoriesId(Integer categoriesId) {
-		this.categoriesId = categoriesId;
-	}
-
-	public String getCategoriesName() {
-		return categoriesName;
-	}
-
-	public void setCategoriesName(String categoriesName) {
-		this.categoriesName = categoriesName;
-	}
-
-	public String getCreateUserName() {
-		return createUserName;
-	}
-
-	public void setCreateUserName(String createUserName) {
-		this.createUserName = createUserName;
-	}
-
-	public void setId(Integer id){
-		this.id = id;
-	}
-	
-	public Integer getId(){
-		return this.id;
-	}
-			
-	public void setMusicScoreCategoriesId(Integer musicScoreCategoriesId){
-		this.musicScoreCategoriesId = musicScoreCategoriesId;
-	}
-	
-	public Integer getMusicScoreCategoriesId(){
-		return this.musicScoreCategoriesId;
-	}
-			
-	public void setName(String name){
-		this.name = name;
-	}
-	
-	public String getName(){
-		return this.name;
-	}
-
-	public ExamSongTypeEnum getType() {
-		return type;
-	}
-
-	public void setType(ExamSongTypeEnum type) {
-		this.type = type;
-	}
-
-	public void setSubjectIds(String subjectIds){
-		this.subjectIds = subjectIds;
-	}
-	
-	public String getSubjectIds(){
-		return this.subjectIds;
-	}
-			
-	public void setSpeed(Integer speed){
-		this.speed = speed;
-	}
-	
-	public Integer getSpeed(){
-		return this.speed;
-	}
-			
-	public void setUrl(String url){
-		this.url = url;
-	}
-	
-	public String getUrl(){
-		return this.url;
-	}
-			
-	public void setCreateUserId(Integer createUserId){
-		this.createUserId = createUserId;
-	}
-	
-	public Integer getCreateUserId(){
-		return this.createUserId;
-	}
-			
-	public void setDelFlag(Integer delFlag){
-		this.delFlag = delFlag;
-	}
-	
-	public Integer getDelFlag(){
-		return this.delFlag;
-	}
-			
-	public void setUpdateTime(java.util.Date updateTime){
-		this.updateTime = updateTime;
-	}
-	
-	public java.util.Date getUpdateTime(){
-		return this.updateTime;
-	}
-			
-	public void setCreateTime(java.util.Date createTime){
-		this.createTime = createTime;
-	}
-	
-	public java.util.Date getCreateTime(){
-		return this.createTime;
-	}
-
-	public String getMuseScoreUrl() {
-		return museScoreUrl;
-	}
-
-	public void setMuseScoreUrl(String museScoreUrl) {
-		this.museScoreUrl = museScoreUrl;
-	}
-
-	public String getMuseScoreMemo() {
-		return museScoreMemo;
-	}
-
-	public void setMuseScoreMemo(String museScoreMemo) {
-		this.museScoreMemo = museScoreMemo;
-	}
-
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysMusicScoreService.java

@@ -4,6 +4,7 @@ package com.ym.mec.biz.service;
 import java.util.List;
 import java.util.Map;
 
+import com.ym.mec.biz.dal.dao.SysMusicScoreDao;
 import com.ym.mec.biz.dal.dto.MusicScoreDto;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
@@ -12,6 +13,8 @@ import com.ym.mec.common.service.BaseService;
 
 public interface SysMusicScoreService extends BaseService<Integer, SysMusicScore> {
 
+    SysMusicScoreDao getDao();
+
     void updateMusicScore(MusicScoreDto musicScoreDto);
 
     void add(MusicScoreDto musicScoreDto);

+ 117 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CbsMusicSheetServiceImpl.java

@@ -0,0 +1,117 @@
+package com.ym.mec.biz.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.dayaedu.cbs.common.enums.music.EMusicSourceType;
+import com.dayaedu.cbs.openfeign.service.CbsMusicSheetService;
+import com.dayaedu.cbs.openfeign.wrapper.music.*;
+import com.microsvc.toolkit.common.response.paging.PageInfo;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.SysMusicScore;
+import com.ym.mec.biz.service.SubjectService;
+import com.ym.mec.biz.service.SysMusicScoreService;
+import com.ym.mec.common.exception.BizException;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class CbsMusicSheetServiceImpl implements CbsMusicSheetService {
+
+    private static final Logger log = LoggerFactory.getLogger(CbsMusicSheetServiceImpl.class);
+
+    @Resource
+    private SysMusicScoreService sysMusicScoreService;
+    @Resource
+    private MusicTagService musicTagService;
+    @Resource
+    private SubjectService subjectService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean saveApplicationExtend(List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> addMusicSheet) {
+        if (CollectionUtils.isEmpty(addMusicSheet)) {
+            throw new BizException("请选择曲目信息");
+        }
+        List<Long> cbsMusicSheetIds = addMusicSheet.stream().map(e -> e.getMusicSheetId()).collect(Collectors.toList());
+        for (CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend : addMusicSheet) {
+            CbsMusicSheetApiWrapper.MusicSheetUpdate musicSheetUpdate = extend.getMusicSheetUpdate();
+            if(StringUtils.isNotBlank(musicSheetUpdate.getSubjectIds())) {
+                List<Long> cbsSubjectIds = Arrays.stream(musicSheetUpdate.getSubjectIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
+                List<Subject> subjectIds = subjectService.getDao().queryCbsList(cbsSubjectIds);
+                if (CollectionUtils.isNotEmpty(subjectIds)) {
+                    musicSheetUpdate.setSubjectIds(subjectIds.stream().map(e -> e.getId().toString()).collect(Collectors.joining(",")));
+                }
+            }
+        }
+        //需要修改的曲目
+        List<SysMusicScore> musicSheets = sysMusicScoreService.getDao().findByCbsId(cbsMusicSheetIds);
+        if (CollectionUtils.isNotEmpty(musicSheets)){
+            List<Long> collect = musicSheets.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
+            //获取需要修改的曲目
+            List<CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend> updateMusicScore =
+                    addMusicSheet.stream().filter(e -> collect.contains(e.getMusicSheetId())).collect(Collectors.toList());
+            sysMusicScoreService.getDao().updateBatchByCbsId(updateMusicScore);
+            //排除已经存在的曲目
+            addMusicSheet = addMusicSheet.stream().filter(e -> !collect.contains(e.getMusicSheetId())).collect(Collectors.toList());
+        }
+        if(CollectionUtils.isNotEmpty(addMusicSheet)){
+            sysMusicScoreService.getDao().batchInsert(addMusicSheet);
+        }
+        return true;
+    }
+
+    public Boolean updateApplicationExtendStatus(CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtendStatus updateMusicSheet){
+        if (updateMusicSheet == null || StringUtils.isEmpty(updateMusicSheet.getIds())){
+            throw new BizException("请选择曲目");
+        }
+        if (updateMusicSheet.getStatus() == null){
+            throw new BizException("请选择状态");
+        }
+        if (!updateMusicSheet.getStatus()){
+            musicSheetService.getDao().batchEnable(updateMusicSheet.getIds(),updateMusicSheet.getStatus());
+        }
+        return true;
+    }
+
+    public Boolean delApplicationExtend(CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtendDel musicSheetApplicationExtendDel){
+        if (musicSheetApplicationExtendDel == null || StringUtils.isEmpty(musicSheetApplicationExtendDel.getIds())){
+            throw new BizException("请选择曲目");
+        }
+        musicSheetService.getDao().batchDel(musicSheetApplicationExtendDel.getIds());
+        return true;
+    }
+
+    public List<CbsMusicSheetTagWrapper.MusicSheetTag> tagList(CbsMusicSheetTagWrapper.MusicSheetTagQuery queryInfo){
+        return musicTagService.getBaseMapper().tagList(queryInfo);
+    }
+
+    public List<CbsMusicSheetCategoryWrapper.MusicSheetCategory> categoryList(CbsMusicSheetCategoryWrapper.MusicSheetCategoryQuery queryInfo){
+        return musicTagService.getBaseMapper().categoryList(queryInfo);
+    }
+
+    public PageInfo<CbsMusicSheetExtendWrapper.MusicSheetExtend> ownerList(CbsMusicSheetExtendWrapper.MusicSheetExtendQuery queryInfo){
+        IPage<CbsMusicSheetExtendWrapper.MusicSheetExtend> page = QueryInfo.getPage(queryInfo);
+        if (queryInfo.getSourceType() == null){
+            throw new BizException("请选择来源类型");
+        }
+        if(queryInfo.getSourceType() == EMusicSourceType.PERSON){
+            return QueryInfo.pageInfo(musicSheetService.getDao().personOwnerList(page, queryInfo));
+        }else {
+            return QueryInfo.pageInfo(musicSheetService.getDao().orgOwnerList(page, queryInfo));
+        }
+    }
+
+    public boolean updateMusicSheet(CbsMusicSheetApiWrapper.MusicSheetUpdate musicSheetUpdate) {
+        musicSheetService.getDao().updateMusicSheet(musicSheetUpdate);
+        return true;
+    }
+}

+ 86 - 24
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicScoreServiceImpl.java

@@ -2,18 +2,17 @@ package com.ym.mec.biz.service.impl;
 
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper;
+import com.microsvc.toolkit.common.response.template.R;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 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.SysMusicScore;
-import com.ym.mec.biz.dal.entity.SysMusicScoreAccompaniment;
-import com.ym.mec.biz.dal.entity.SysMusicScoreCategories;
-import com.ym.mec.biz.dal.entity.SysMusicScoreChangeLog;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.biz.service.OrganizationService;
 import com.ym.mec.biz.service.SysMusicScoreCategoriesService;
@@ -28,7 +27,9 @@ 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 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;
 
@@ -38,6 +39,7 @@ import java.io.FileInputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.ClientTypeEnum.SMART_PRACTICE;
@@ -68,12 +70,20 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
     @Resource
     private MusicFeignClientService musicFeignClientService;
 
+    @Value("${openfeign-client.app-id:1745637981387108354}")
+    public Long applicationId;
+
     @Override
     public BaseDAO<Integer, SysMusicScore> getDAO() {
         return sysMusicScoreDao;
     }
 
     @Override
+    public SysMusicScoreDao getDao() {
+        return sysMusicScoreDao;
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public void updateMusicScore(MusicScoreDto musicScoreDto) {
         SysMusicScore sysMusicScore = musicScoreDto.getSysMusicScore();
@@ -204,13 +214,36 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         }
     }
 
-    private void dealMusicScoreData(List<SysMusicScore> rows){
-        if (rows != null && rows.size() > 0) {
-            Set<Integer> categoriesIds = rows.stream().map(e -> e.getMusicScoreCategoriesId()).collect(Collectors.toSet());
+    private void dealMusicScoreData(List<SysMusicScore> records){
+        if (CollectionUtils.isNotEmpty(records)) {
+            List<Long> cbsMusicSheetIds = records.stream().map(e -> e.getCbsMusicSheetId()).collect(Collectors.toList());
+            CbsMusicSheetWrapper.MusicSheetApplicationQuery query = new CbsMusicSheetWrapper.MusicSheetApplicationQuery();
+            query.setMusicSheetIds(cbsMusicSheetIds);
+            query.setDetailFlag(true);
+            R<com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> pageInfoR =
+                    musicFeignClientService.musicSheetPageByApplication(query);
+            if(pageInfoR.getCode() != 200){
+                throw new BizException("获取曲目信息失败");
+            }
+            com.microsvc.toolkit.common.response.paging.PageInfo<CbsMusicSheetWrapper.MusicSheetApplication> pageInfo = pageInfoR.getData();
+            if(pageInfo != null && CollectionUtils.isNotEmpty(pageInfo.getRows())){
+                Map<Long, CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationMap = pageInfo.getRows()
+                        .stream().collect(Collectors.toMap(CbsMusicSheetWrapper.MusicSheetApplication::getId, Function.identity()));
+                List<Subject> subjects = subjectDao.queryCbsList(records.stream().map(SysMusicScore::getSubjectIds)
+                        .filter(StringUtils::isNotEmpty).map(Long::parseLong).distinct().collect(Collectors.toList()));
+                Map<Integer, Subject> subjectMap = subjects.stream().collect(Collectors.toMap(Subject::getId, Function.identity()));
+                for (SysMusicScore record : records) {
+                    CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication = musicSheetApplicationMap.get(record.getCbsMusicSheetId());
+                    if(musicSheetApplication != null){
+                        this.initMusicSheetVo(record,musicSheetApplication,subjectMap);
+                    }
+                }
+            }
+            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());
+            /*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) {
@@ -222,15 +255,55 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
                 if(null != categoriesId){
                     map.put(categoriesId, getParentTreeName(categoriesId));
                 }
-            }
-            for (SysMusicScore row : rows) {
-                row.setCategoriesName(map.get(row.getMusicScoreCategoriesId()));
+            }*/
+            for (SysMusicScore row : records) {
+//                row.setCategoriesName(map.get(row.getMusicScoreCategoriesId()));
                 row.setOrganName(organMap.get(row.getMusicScoreCategoriesId()));
-                row.setSubjectName(subjectMap.get(row.getSubjectId()));
+//                row.setSubjectName(subjectMap.get(row.getSubjectId()));
             }
         }
     }
 
+    public void initMusicSheetVo(SysMusicScore record,CbsMusicSheetWrapper.MusicSheetApplication musicSheetApplication,Map<Integer, Subject> subjectMap){
+        if(StringUtils.isNotEmpty(musicSheetApplication.getSubjectIds())){
+            StringBuffer sb = new StringBuffer();
+            for (String s : musicSheetApplication.getSubjectIds().split(",")) {
+                Subject subject = subjectMap.get(Integer.parseInt(s));
+                if(subject != null){
+                    if (sb.length() > 0) {
+                        sb.append(",");
+                    }
+                    sb.append(subject.getName());
+                }
+            }
+            record.setSubjectName(sb.toString());
+        }
+        record.setCbsMusicSheetId(musicSheetApplication.getId());
+        record.setPlayMode(SysMusicScore.PlayMode.valueOf(musicSheetApplication.getPlayMode().getCode()));
+        record.setExtConfigJson(musicSheetApplication.getExtConfigJson());
+        record.setExtStyleConfigJson(musicSheetApplication.getExtStyleConfigJson());
+        if(musicSheetApplication.getMusicSheetCategoryId() != null){
+            record.setMusicScoreCategoriesId(musicSheetApplication.getMusicSheetCategoryId().intValue());
+            record.setCategoriesId(musicSheetApplication.getMusicSheetCategoryId().intValue());
+        }
+        record.setName(musicSheetApplication.getName());
+        record.setCategoriesName(musicSheetApplication.getMusicSheetCategoryName());
+        record.setSpeed(musicSheetApplication.getPlaySpeed());
+        List<CbsMusicSheetWrapper.MusicSheetAccompaniment> accompanimentList = musicSheetApplication.getMusicSheetAccompanimentList();
+        if (CollectionUtils.isNotEmpty(accompanimentList)) {
+            record.setMetronomeUrl(accompanimentList.get(0).getAudioFileUrl());
+        }
+        List<CbsMusicSheetWrapper.MusicSheetSound> soundList = musicSheetApplication.getMusicSheetSoundList();
+        if (CollectionUtils.isNotEmpty(soundList)) {
+            record.setAccompanimentMetronomeUrl(soundList.get(0).getAudioFileUrl());
+        }
+        record.setXmlUrl(musicSheetApplication.getXmlFileUrl());
+        record.setMidiUrl(musicSheetApplication.getMidiFileUrl());
+        record.setOrder(musicSheetApplication.getSortNo());
+        record.setEnableEvaluation(musicSheetApplication.getIsEvaluated());
+        record.setIsOpenMetronome(musicSheetApplication.getIsUseSystemBeat() && musicSheetApplication.getIsPlayBeat());
+    }
+
     @Override
     public List<SysMusicScore> queryMusicScoreAll(SysExamSongQueryInfo queryInfo) {
         //封装查询参数
@@ -256,17 +329,6 @@ public class SysMusicScoreServiceImpl extends BaseServiceImpl<Integer, SysMusicS
         return sysMusicScorePageInfo;
     }
 
-    @Override
-    public PageInfo<SysMusicScore> queryCbsPage(SysExamSongQueryInfo queryInfo) {
-        //封装查询参数
-        dealMusicScoreParam(queryInfo);
-
-        PageInfo<SysMusicScore> sysMusicScorePageInfo = queryPage(queryInfo);
-        List<SysMusicScore> rows = sysMusicScorePageInfo.getRows();
-        //处理查询结果
-        dealMusicScoreData(rows);
-        return sysMusicScorePageInfo;
-    }
 
     @Override
     public PageInfo<SysMusicScore> queryMusicScorePageInfo(SysExamSongQueryInfo queryInfo) {

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

@@ -8,6 +8,7 @@
 
     <resultMap type="com.ym.mec.biz.dal.entity.Subject" id="Subject">
         <result column="id_" property="id"/>
+        <result column="cbs_subject_id_" property="cbsSubjectId"/>
         <result column="name_" property="name"/>
         <result column="code_" property="code"/>
         <result column="parent_subject_id_" property="parentSubjectId"/>
@@ -30,8 +31,8 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Subject" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
-        INSERT INTO subject (id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_)
-        VALUES(#{id},#{name},#{code},#{parentSubjectId},#{img},now(),now())
+        INSERT INTO subject (id_,cbs_subject_id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_)
+        VALUES(#{id},#{cbsSubjectId},#{name},#{code},#{parentSubjectId},#{img},now(),now())
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -41,8 +42,11 @@
             <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">
-                parent_subject_id_ = #{parentSubjectId},
+                cbs_subject_id_ = #{parentSubjectId},
             </if>
             <if test="code != null">
                 code_ = #{code},
@@ -305,4 +309,13 @@
     <select id="findByNames" resultMap="Subject">
         SELECT * FROM `subject` where name_ IN ('长笛','单簧管','萨克斯','小号','长号','圆号','上低音号','大号','打击乐') and del_flag_ = 0
     </select>
+    <select id="queryCbsList" resultType="com.ym.mec.biz.dal.entity.Subject">
+        SELECT * FROM `subject` WHERE del_flag_ = 0 AND parent_subject_id_ != 0
+        <if test="cbsSubjectIds != null and cbsSubjectIds.size > 0">
+            AND cbs_subject_id_ IN
+            <foreach collection="query.cbsSubjectIds" item="cbsSubjectId" open="(" close=")" separator=",">
+                #{cbsSubjectId}
+            </foreach>
+        </if>
+    </select>
 </mapper>

+ 47 - 7
mec-biz/src/main/resources/config/mybatis/SysMusicScoreMapper.xml

@@ -184,6 +184,15 @@
 		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">
+			AND cbs_music_sheet_id_ IN
+			<foreach collection="cbsMusicSheetIds" separator="," item="item" open="(" close=")">
+				#{item}
+			</foreach>
+		</if>
+	</select>
 
 	<update id="updateAccompanimentBySongId">
 		update sys_music_score_accompaniment t
@@ -202,16 +211,47 @@
 		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=";">
+			music_score_categories_id_,name_,type_,speed_,url_,metronome_url_,midi_url_,create_user_id_,order_,
+			update_time_,create_time_,client_type_,rank_ids_,render_from_,enable_evaluation_,show_flag_,
+			                          play_mode_,muse_score_url_,muse_score_memo_,ext_config_json_,ext_style_config_json_
+
+			update music_sheet ms set ms.provider_type_ = CASE WHEN #{item.availableType} = 'PLATFORM' THEN 'PLATFORM'
+			WHEN #{item.availableType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END,
+			ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
+			ms.charge_type_ = #{item.paymentType},
+			ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
+			ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
+			ms.audit_status_ = CASE WHEN #{item.delFlag} THEN 'PASS' ELSE 'DOING' END
+			<if test="item.musicSheetUpdate != null">
+				,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
+				ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
+				ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
+				ms.composer_ = #{item.musicSheetUpdate.composer},
+				ms.title_img_ = #{item.musicSheetUpdate.musicCover},
+				ms.music_img_ = #{item.musicSheetUpdate.musicCover},
+				ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
+				ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
+				ms.music_price_ = #{item.musicSheetUpdate.musicPrice},
+				ms.notation_ = #{item.musicSheetUpdate.notation},
+				ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
+				ms.create_by_ = #{item.musicSheetUpdate.userId},
+				ms.audio_type_ = #{item.musicSheetUpdate.playMode},
+				ms.notation_ = #{item.musicSheetUpdate.notation},
+				ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
+				ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
+				ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
+				WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
+				ELSE 'TENANT' END
+			</if>
+			where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
+		</foreach>
+	</update>
 
 	<sql id="queryPageSql">
 		<where>
-			ses.del_flag_ = 0
-			<!-- <if test="organId != null and organId != null">
-				AND INTE_ARRAY(smsc.organ_id_,#{organId})
-			</if> -->
-			<!-- <if test="categoriesId != null">
-				AND FIND_IN_SET(ses.music_score_categories_id_,#{categoriesId})
-			</if> -->
+			ses.del_flag_ = 0 AND ses.cbs_music_sheet_id_ IS NOT NULL
 			<if test="categoriesIdList != null">
 				AND smsc.id_ IN
 				<foreach collection="categoriesIdList" separator="," item="item" open="(" close=")">