Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

周箭河 4 vuotta sitten
vanhempi
commit
1f83037abc

+ 16 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CooperationOrganServiceImpl.java

@@ -7,15 +7,13 @@ import java.util.Map;
 
 import com.ym.mec.biz.dal.dao.ClassGroupDao;
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.entity.ClassGroup;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.ImGroupMemberService;
+import com.ym.mec.biz.service.ImGroupService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.ym.mec.biz.dal.dao.CooperationOrganDao;
-import com.ym.mec.biz.dal.entity.CooperationOrgan;
 import com.ym.mec.biz.service.CooperationOrganService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -32,6 +30,8 @@ public class CooperationOrganServiceImpl extends BaseServiceImpl<Integer, Cooper
 	private ClassGroupDao classGroupDao;
 	@Autowired
 	private ImGroupMemberService imGroupMemberService;
+	@Autowired
+	private ImGroupService imGroupService;
 
 	@Override
 	public BaseDAO<Integer, CooperationOrgan> getDAO() {
@@ -58,6 +58,18 @@ public class CooperationOrganServiceImpl extends BaseServiceImpl<Integer, Cooper
 			List<MusicGroup> musicGroups = musicGroupDao.findByCooperationId(cooperationOrgan.getId());
 			if(musicGroups.size() > 0){
 				for (MusicGroup musicGroup : musicGroups) {
+					//乐团主管有变更
+					if(!cooperationOrgan.getEducationUserId().equals(musicGroup.getEducationalTeacherId())){
+						//不是导入的乐团
+						if(musicGroup.getId().length() > 10){
+							//是否有预报名的群聊
+							ImGroup imGroup = imGroupService.get(Long.parseLong(musicGroup.getId()));
+							if(imGroup != null){
+								imGroupMemberService.quit(Long.parseLong(musicGroup.getId()),musicGroup.getEducationalTeacherId());
+								imGroupMemberService.join(Long.parseLong(musicGroup.getId()),cooperationOrgan.getEducationUserId(),"乐团主管",false);
+							}
+						}
+					}
 					//获取当前乐团所有班级
 					List<ClassGroup> classGroups = classGroupDao.findClassGroups(musicGroup.getId());
 					if (classGroups == null || classGroups.size() == 0) {

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

@@ -241,6 +241,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             throw new BizException("乐团初始状态错误");
         }
         musicGroup.setDelFlag(false);
+        CooperationOrgan cooperationOrgan = cooperationOrganDao.get(musicGroup.getCooperationOrganId());
+        if(cooperationOrgan.getEducationUserId() == null){
+            throw new BizException("操作失败:请先配置合作单位: {} 关联的乐团主管",cooperationOrgan.getName());
+        }
+        musicGroup.setEducationalTeacherId(cooperationOrgan.getEducationUserId());
         // 保存乐团基本信息
         musicGroupDao.insert(musicGroup);
 
@@ -2559,7 +2564,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     private void updateTeamTeacher(MusicGroup oldMusicGroup, MusicGroup newMusicGroup) {
         //获取当前乐团所有班级
         List<ClassGroup> classGroups = classGroupDao.findClassGroups(newMusicGroup.getId());
-        if (classGroups == null || classGroups.size() == 0) {
+        if (classGroups != null || classGroups.size() == 0) {
             return;
         }
         Integer teamTeacherId = newMusicGroup.getTeamTeacherId();
@@ -2622,6 +2627,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (group.getStatus() == MusicGroupStatusEnum.PROGRESS) {
             updateTeamTeacher(group, musicGroup);
         }
+        //乐团主管有变更
+        if(!cooperationOrgan.getEducationUserId().equals(group.getEducationalTeacherId())){
+            //不是导入的乐团
+            if(musicGroupId.length() > 10){
+                //是否有预报名的群聊
+                ImGroup imGroup = imGroupService.get(Long.parseLong(musicGroupId));
+                if(imGroup != null){
+                    imGroupMemberService.quit(Long.parseLong(musicGroupId),group.getEducationalTeacherId());
+                    imGroupMemberService.join(Long.parseLong(musicGroupId),cooperationOrgan.getEducationUserId(),"乐团主管",false);
+                }
+            }
+        }
 
         Date date = new Date();
         //缴费方式不同

+ 14 - 35
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundServiceImpl.java

@@ -50,8 +50,6 @@ public class SoundServiceImpl implements SoundService {
     @Autowired
     private SysMusicScoreDao sysMusicScoreDao;
     @Autowired
-    private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
-    @Autowired
     private IdGeneratorService idGeneratorService;
 
     /**
@@ -74,27 +72,6 @@ public class SoundServiceImpl implements SoundService {
         return times;
     }
 
-    private List<Double> rootMeanSquareExtractor(byte[] bytes, String url) throws UnsupportedAudioFileException {
-        List<Double> rootMeans = new ArrayList<>();
-        int size = 2048;
-        int overlap = 0;
-        AudioDispatcher dispatcher = StringUtils.isBlank(url)?getFromByteArray(bytes, size, overlap):getFromFile(url, size, overlap);
-
-        dispatcher.addAudioProcessor(new AudioProcessor() {
-            @Override
-            public void processingFinished() {
-            }
-
-            @Override
-            public boolean process(AudioEvent audioEvent) {
-                rootMeans.add(audioEvent.getRMS());
-                return true;
-            }
-        });
-        dispatcher.run();
-        return rootMeans;
-    }
-
     /**
      * @describe 音频分贝信息提取
      * @author Joburgess
@@ -144,6 +121,9 @@ public class SoundServiceImpl implements SoundService {
 
     @Override
     public HttpResponseResult compare(MultipartFile record, Integer musicScoreId) {
+        if(record.getSize()<1024){
+            throw new BizException("录音时间太短");
+        }
         SysMusicScore sysMusicScore = sysMusicScoreDao.get(musicScoreId);
         if(Objects.isNull(sysMusicScore)|| StringUtils.isBlank(sysMusicScore.getUrl())){
             throw new BizException("伴奏信息错误");
@@ -162,7 +142,7 @@ public class SoundServiceImpl implements SoundService {
             f = new File(filePath);
             FileUtils.copyURLToFile(url, f);
 
-            LOGGER.info("文件名:{},伴奏编号:{},源文件:{}", record.getOriginalFilename(), musicScoreId, filePath);
+            LOGGER.info("录音文件大小:{}MB,伴奏编号:{},源文件:{}", record.getSize()/1048576f, musicScoreId, filePath);
 
             BigDecimal oneHandred = new BigDecimal(100);
 
@@ -218,7 +198,7 @@ public class SoundServiceImpl implements SoundService {
             float sameTimes = 0;
             for (Double time1 : times_s) {
                 for (Double time2 : times_r) {
-                    if(Math.abs(time2-time1)<1.5){
+                    if(Math.abs(time2-time1)<1.3){
                         sameTimes++;
                         break;
                     }
@@ -232,14 +212,13 @@ public class SoundServiceImpl implements SoundService {
             }
             cadence = new BigDecimal(cadence_d).multiply(oneHandred).setScale(0, BigDecimal.ROUND_HALF_UP);
 
-            integrity = new BigDecimal(0);
-            if(l_r.compareTo(BigDecimal.ZERO)<=0||l_s.compareTo(BigDecimal.ZERO)<=0){
-
-            }else if(l_r.compareTo(l_s)<0){
-                integrity = l_r.divide(l_s, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHandred).setScale(0, BigDecimal.ROUND_HALF_UP);
-            }else{
-                integrity = new BigDecimal(100);
+            //完整度
+            BigDecimal time_s = new BigDecimal(times_s.size());
+            BigDecimal time_r = new BigDecimal(times_r.size());
+            if(time_s.compareTo(time_r)<0){
+                time_r = time_s;
             }
+            integrity = time_r.divide(time_s, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHandred).setScale(0, BigDecimal.ROUND_HALF_UP);
 
             score = intonation.add(cadence).add(integrity).divide(new BigDecimal(3), 0, BigDecimal.ROUND_HALF_UP);
 
@@ -252,9 +231,9 @@ public class SoundServiceImpl implements SoundService {
             if(f!=null){
                 f.delete();
             }
-//            if(f_r!=null){
-//                f_r.delete();
-//            }
+            if(f_r!=null){
+                f_r.deleteOnExit();
+            }
         }
 
         result.put("score", score);