Browse Source

Merge branch 'reg_6_21'

river 4 years ago
parent
commit
071f9e4aff
22 changed files with 591 additions and 42 deletions
  1. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java
  2. 29 5
      mec-biz/src/main/java/com/ym/mec/biz/service/UploadFileService.java
  3. 0 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java
  4. 14 9
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  5. 38 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  6. 9 0
      mec-client-api/src/main/java/com/ym/mec/im/ImFeignService.java
  7. 3 3
      mec-client-api/src/main/java/com/ym/mec/im/fallback/ImFeignServiceFallback.java
  8. 4 0
      mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java
  9. 5 0
      mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java
  10. 16 0
      mec-common/audit-log/src/main/java/com/yonge/log/dal/dao/HistoryMessageDao.java
  11. 164 0
      mec-common/audit-log/src/main/java/com/yonge/log/dal/model/HistoryMessage.java
  12. 16 0
      mec-common/audit-log/src/main/java/com/yonge/log/service/HistoryMessageService.java
  13. 159 0
      mec-common/audit-log/src/main/java/com/yonge/log/service/impl/HistoryMessageServiceImpl.java
  14. 10 0
      mec-common/mongo-db/src/main/java/com/yonge/mongodb/dao/BaseDaoWithMongo.java
  15. 2 1
      mec-im/src/main/java/com/ym/config/ResourceServerConfig.java
  16. 2 6
      mec-im/src/main/java/com/ym/controller/HistoryController.java
  17. 4 1
      mec-im/src/main/java/com/ym/service/Impl/MessageServiceImpl.java
  18. 19 0
      mec-task/src/main/java/com/ym/mec/task/jobs/SyncImHistoryMessageTask.java
  19. 3 1
      mec-util/src/main/java/com/ym/mec/util/date/DateUtil.java
  20. 34 0
      mec-web/src/main/java/com/ym/mec/web/controller/ImHistoryMessageController.java
  21. 10 3
      mec-web/src/main/java/com/ym/mec/web/controller/StudentRegistrationController.java
  22. 43 0
      mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -413,4 +413,11 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      */
     Boolean setNoneCloudTeacher(Long id);
 
+    /**
+     * 已付费解除审核增加缴费人数和0元缴费人数
+     * @param id
+     * @return
+     */
+    Boolean addPaidNum(Long id);
+
 }

+ 29 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/UploadFileService.java

@@ -1,15 +1,13 @@
 package com.ym.mec.biz.service;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import com.ym.mec.common.entity.UploadReturnBean;
@@ -17,6 +15,7 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.thirdparty.storage.StoragePluginContext;
 import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
 import com.ym.mec.util.upload.UploadUtil;
+import org.springframework.web.multipart.MultipartFile;
 
 /** 
  * 上传工具服务层实现类
@@ -40,7 +39,6 @@ public class UploadFileService {
 	private String fileRoot;
 
 	public UploadReturnBean uploadFile(InputStream in, String ext) {
-
 		UploadReturnBean uploadReturn = new UploadReturnBean("", false, "");
 		String fileName = UploadUtil.getFileName(ext);
 
@@ -77,6 +75,32 @@ public class UploadFileService {
 		return uploadReturn;
 	}
 
+
+	@Async
+	public UploadReturnBean uploadImHistoryMsgFile(File msgFile) throws FileNotFoundException {
+		InputStream in = new FileInputStream(msgFile);
+		UploadReturnBean uploadReturn = new UploadReturnBean("", false, "");
+		String fileName = UploadUtil.getFileName(msgFile.getName());
+
+		String root = fileRoot + "im_history_msg/";
+		if (StringUtils.isBlank(root)) {
+			uploadReturn.setMessage("上传临时目录没有配置");
+			return uploadReturn;
+		}
+
+		String staticFloder = "";
+		String folder = UploadUtil.getFileFloder();
+		String filePath = UploadUtil.getFilePath(root, staticFloder, folder);
+		File file = uploadFile(in, filePath, fileName);
+		String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME,staticFloder + folder, file);
+
+		FileUtils.deleteQuietly(file);
+
+		uploadReturn.setStatus(true);
+		uploadReturn.setUrl(url);
+		return uploadReturn;
+	}
+
 	public void setMaxSize(int maxSize) {
 		this.maxSize = maxSize;
 	}

+ 0 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -956,12 +956,6 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 
 		resultMap.put("studentInfo",flag2);
 		boolean flag3 = false;
-		if(!flag3){
-			int teacherLeave = indexBaseMonthDataDao.queryTeacherLeave(organIdsStr,startTime);
-			if(teacherLeave > 0){
-				flag3 = true;
-			}
-		}
 
 		Integer userId = null;
 		if (!userRole.contains(SysUserRole.SECTION_MANAGER) && !sysUser.getIsSuperAdmin()) {

+ 14 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -709,6 +709,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus());
         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
+        boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206);
 
         Date date = new Date();
         BigDecimal balance = BigDecimal.ZERO;
@@ -751,10 +752,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.NO_BUY_CLOUD_TEACHER_MSG,
                     userPhoneMap, null, 0, null, null, musicGroup.getName(), studentRegistration.getName());
 
-            Map<String, String> notifyMap = new HashMap<>();
-            notifyMap.put("hasPaidZero", "205");
-            notifyMap.put("orderNo", studentPaymentOrder.getOrderNo());
-            return notifyMap;
+            if(!canPay){
+                Map<String, String> notifyMap = new HashMap<>();
+                notifyMap.put("hasPaidZero", "205");
+                notifyMap.put("orderNo", studentPaymentOrder.getOrderNo());
+                return notifyMap;
+            }
         }
 
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
@@ -898,6 +901,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus());
         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
+        boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206);
         Date date = new Date();
 
         BigDecimal balance = BigDecimal.ZERO;
@@ -939,11 +943,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.NO_BUY_CLOUD_TEACHER_MSG,
                     userPhoneMap, null, 0, null, null, musicGroup.getName(), studentRegistration.getName());
 
-
-            Map<String, String> notifyMap = new HashMap<>();
-            notifyMap.put("hasPaidZero", "205");
-            notifyMap.put("orderNo", studentPaymentOrder.getOrderNo());
-            return notifyMap;
+            if(!canPay) {
+                Map<String, String> notifyMap = new HashMap<>();
+                notifyMap.put("hasPaidZero", "205");
+                notifyMap.put("orderNo", studentPaymentOrder.getOrderNo());
+                return notifyMap;
+            }
         }
 
         if (amount.compareTo(BigDecimal.ZERO) == 0) {

+ 38 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -527,6 +527,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             studentPaymentOrder.setVersion(0);
             String code = studentRegistration.getNoneNeedCloudTeacher().equals(1) ? "200" : "205";
             studentPaymentOrder.setPaymentAccountNo(code);
+            if (code.equals("205") && !"".equals(maintenanceGoodsId)) {
+                studentPaymentOrder.setClassGroupId(206);
+            }
             studentPaymentOrderService.update(studentPaymentOrder);
         }
         return studentPaymentOrder;
@@ -1087,7 +1090,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             }
             studentRegistration.setPaymentStatus(YES);
             studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
-            studentRegistration.setPayingStatus(0);
+
+            if (studentPaymentOrder.getClassGroupId() == null || !studentPaymentOrder.getClassGroupId().equals(206)) {
+                studentRegistration.setPayingStatus(0);
+            }
 
             List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.getOrderDetail(studentPaymentOrder.getId());
 
@@ -1838,21 +1844,21 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         int registerNum = studentRegistrationDao.getRegisterNum(queryInfo.getMusicGroupId());
         pageInfo.setRegNum(registerNum);
         RegisterDto registerOrPreMinTime = studentRegistrationDao.getRegisterOrPreMinTime(queryInfo.getMusicGroupId());
-        if(registerOrPreMinTime != null && registerOrPreMinTime.getMinPayTime() != null){
+        if (registerOrPreMinTime != null && registerOrPreMinTime.getMinPayTime() != null) {
             Date startTime = DateUtil.trunc(registerOrPreMinTime.getMinPayTime());
             Date endTime = DateUtil.getLastTimeWithDay(startTime);
             int firstPayNum = studentRegistrationDao.getFirstPayNum(queryInfo.getMusicGroupId(), startTime, endTime);
-            int totalPayNum = studentRegistrationDao.getFirstPayNum(queryInfo.getMusicGroupId(), startTime,null);
+            int totalPayNum = studentRegistrationDao.getFirstPayNum(queryInfo.getMusicGroupId(), startTime, null);
             pageInfo.setFirstDayPayNum(firstPayNum);
             pageInfo.setPayNum(totalPayNum);
-            pageInfo.setPayScale(new BigDecimal(firstPayNum).multiply(new BigDecimal(100)).divide(new BigDecimal(totalPayNum),2,BigDecimal.ROUND_HALF_UP));
+            pageInfo.setPayScale(new BigDecimal(firstPayNum).multiply(new BigDecimal(100)).divide(new BigDecimal(totalPayNum), 2, BigDecimal.ROUND_HALF_UP));
         }
 
         pageInfo.setTotal(count);
         params.put("offset", pageInfo.getOffset());
         if (queryInfo.getPage() <= pageInfo.getTotalPage()) {
-            Date firstPreTime = registerOrPreMinTime != null ?registerOrPreMinTime.getMinPerRegisterTime():null;
-            Date firstPayTime = registerOrPreMinTime != null ?registerOrPreMinTime.getMinPayTime():null;
+            Date firstPreTime = registerOrPreMinTime != null ? registerOrPreMinTime.getMinPerRegisterTime() : null;
+            Date firstPayTime = registerOrPreMinTime != null ? registerOrPreMinTime.getMinPayTime() : null;
             dataList = studentRegistrationDao.getRegisterOrPreList(params);
             for (RegisterDto registerDto : dataList) {
                 if (DateUtil.dateToString(registerDto.getPerRegisterTime()).equals("2099-12-31") ||
@@ -1887,7 +1893,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     public Boolean setNoneCloudTeacher(Long id) {
         StudentRegistration studentRegistration = studentRegistrationDao.get(id);
         if (!studentRegistration.getPayingStatus().equals(2)) {
-            throw new BizException("该学生不在预约中");
+            throw new BizException("该学生不在审核中");
         }
         if (studentRegistration.getNoneNeedCloudTeacher().equals(1)) {
             throw new BizException("该学生已设置");
@@ -1898,4 +1904,29 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }
         return true;
     }
+
+    @Override
+    public Boolean addPaidNum(Long id) {
+        StudentRegistration studentRegistration = studentRegistrationDao.get(id);
+        if (!studentRegistration.getPayingStatus().equals(2)) {
+            throw new BizException("该学生不在审核");
+        }
+        if (!studentRegistration.getPaymentStatus().equals(YES)) {
+            throw new BizException("该学生状态已更新,请刷新查看");
+        }
+        studentRegistration.setPayingStatus(0);
+        studentRegistrationDao.update(studentRegistration);
+
+
+        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
+        int paidNum = musicOneSubjectClassPlan.getPaidStudentNum() == null ? 0 : musicOneSubjectClassPlan.getPaidStudentNum();
+        int paidZeroNum = musicOneSubjectClassPlan.getPaidZeroNum() == null ? 0 : musicOneSubjectClassPlan.getPaidZeroNum();
+        musicOneSubjectClassPlan.setPaidZeroNum(paidZeroNum + 1);
+        musicOneSubjectClassPlan.setPaidStudentNum(paidNum + 1);
+        int count = musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
+        if (count <= 0) {
+            throw new BizException("缴费人数更新失败,请重试");
+        }
+        return true;
+    }
 }

+ 9 - 0
mec-client-api/src/main/java/com/ym/mec/im/ImFeignService.java

@@ -15,6 +15,7 @@ import com.ym.mec.common.entity.ImResult;
 import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.im.entity.GroupModel;
 import com.ym.mec.im.fallback.ImFeignServiceFallback;
+import org.springframework.web.bind.annotation.RequestParam;
 
 @FeignClient(name = "im-server", configuration = FeignConfiguration.class, fallback = ImFeignServiceFallback.class)
 public interface ImFeignService {
@@ -109,4 +110,12 @@ public interface ImFeignService {
 
 	@PostMapping(value = "group/send")
 	Object groupSend(@RequestBody ImGroupMessage imGroupMessage);
+
+	/**
+	 * 获取历史消息记录
+	 * @param date
+	 * @return
+	 */
+	@PostMapping(value = "history/get")
+	Object historyGet(@RequestParam("date") String date);
 }

+ 3 - 3
mec-client-api/src/main/java/com/ym/mec/im/fallback/ImFeignServiceFallback.java

@@ -75,9 +75,9 @@ public class ImFeignServiceFallback implements ImFeignService {
     public Object groupSend(ImGroupMessage imGroupMessage) {
         return null;
     }
-/*
+
     @Override
-    public Object privateSendCustom(ImGroupMessage groupMessage) {
+    public Object historyGet(String date) {
         return null;
-    }*/
+    }
 }

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -192,6 +192,10 @@ public interface TaskRemoteService {
 	@GetMapping("task/checkCloudOrderStart")
 	void checkCloudOrderStart();
 
+	//同步即时通讯聊天记录
+	@GetMapping("task/syncImHistoryMessageTask")
+    void syncImHistoryMessageTask();
+
 	//历史异常数据记录
 	@GetMapping("task/indexErrDataRecordTask")
 	void indexErrDataRecord();

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -238,6 +238,11 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
 		logger.error("乐团云教练订单生效处理失败");
 	}
 
+    @Override
+    public void syncImHistoryMessageTask() {
+		logger.error("同步即时通讯聊天记录失败");
+    }
+
 	@Override
 	public void indexErrDataRecord() {
 		logger.error("历史异常数据记录失败");

+ 16 - 0
mec-common/audit-log/src/main/java/com/yonge/log/dal/dao/HistoryMessageDao.java

@@ -0,0 +1,16 @@
+package com.yonge.log.dal.dao;
+
+import com.yonge.log.dal.model.AuditLog;
+import com.yonge.log.dal.model.HistoryMessage;
+import com.yonge.mongodb.dao.BaseDaoWithMongo;
+import org.springframework.stereotype.Component;
+
+@Component
+public class HistoryMessageDao extends BaseDaoWithMongo<String, HistoryMessage> {
+
+	@Override
+	public Class<HistoryMessage> getClassEntity() {
+		return HistoryMessage.class;
+	}
+
+}

+ 164 - 0
mec-common/audit-log/src/main/java/com/yonge/log/dal/model/HistoryMessage.java

@@ -0,0 +1,164 @@
+package com.yonge.log.dal.model;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+@Document(collection = "im_history_message")
+public class HistoryMessage implements Serializable {
+    @Id
+    private String msgUID;
+
+    private String fromUserId;
+
+    private String targetId;
+
+    private Integer targetType;
+
+    private String GroupId;
+
+    private String classname;
+
+    private String dateTime;
+
+    private String source;
+
+    private String isDiscard;
+
+    private String isSensitiveWord;
+
+    private String isForbidden;
+
+    private String isNotForward;
+
+    private String groupUserIds;
+
+    private String content;
+
+    public String getFromUserId() {
+        return fromUserId;
+    }
+
+    public void setFromUserId(String fromUserId) {
+        this.fromUserId = fromUserId;
+    }
+
+    public String getTargetId() {
+        return targetId;
+    }
+
+    public void setTargetId(String targetId) {
+        this.targetId = targetId;
+    }
+
+    public Integer getTargetType() {
+        return targetType;
+    }
+
+    public void setTargetType(Integer targetType) {
+        this.targetType = targetType;
+    }
+
+    public String getGroupId() {
+        return GroupId;
+    }
+
+    public void setGroupId(String groupId) {
+        GroupId = groupId;
+    }
+
+    public String getClassname() {
+        return classname;
+    }
+
+    public void setClassname(String classname) {
+        this.classname = classname;
+    }
+
+    public String getDateTime() {
+        return dateTime;
+    }
+
+    public void setDateTime(String dateTime) {
+        this.dateTime = dateTime;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public String getIsDiscard() {
+        return isDiscard;
+    }
+
+    public void setIsDiscard(String isDiscard) {
+        this.isDiscard = isDiscard;
+    }
+
+    public String getIsSensitiveWord() {
+        return isSensitiveWord;
+    }
+
+    public void setIsSensitiveWord(String isSensitiveWord) {
+        this.isSensitiveWord = isSensitiveWord;
+    }
+
+    public String getIsForbidden() {
+        return isForbidden;
+    }
+
+    public void setIsForbidden(String isForbidden) {
+        this.isForbidden = isForbidden;
+    }
+
+    public String getIsNotForward() {
+        return isNotForward;
+    }
+
+    public void setIsNotForward(String isNotForward) {
+        this.isNotForward = isNotForward;
+    }
+
+    public String getMsgUID() {
+        return msgUID;
+    }
+
+    public void setMsgUID(String msgUID) {
+        this.msgUID = msgUID;
+    }
+
+    public String getGroupUserIds() {
+        return groupUserIds;
+    }
+
+    public void setGroupUserIds(String groupUserIds) {
+        this.groupUserIds = groupUserIds;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        HistoryMessage that = (HistoryMessage) o;
+        return msgUID.equals(that.msgUID);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(msgUID);
+    }
+}

+ 16 - 0
mec-common/audit-log/src/main/java/com/yonge/log/service/HistoryMessageService.java

@@ -0,0 +1,16 @@
+package com.yonge.log.service;
+
+import com.yonge.log.dal.model.HistoryMessage;
+import com.yonge.mongodb.service.BaseServiceWithMongo;
+
+import java.io.File;
+
+public interface HistoryMessageService extends BaseServiceWithMongo<String, HistoryMessage> {
+
+    /**
+     * 保存融云历史聊天记录
+     * @param file
+     * @throws Exception
+     */
+    void saveImHistoryMessage(File file) throws Exception;
+}

+ 159 - 0
mec-common/audit-log/src/main/java/com/yonge/log/service/impl/HistoryMessageServiceImpl.java

@@ -0,0 +1,159 @@
+package com.yonge.log.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.yonge.log.dal.dao.HistoryMessageDao;
+import com.yonge.log.dal.model.HistoryMessage;
+import com.yonge.log.service.HistoryMessageService;
+import com.yonge.mongodb.dao.BaseDaoWithMongo;
+import com.yonge.mongodb.service.impl.BaseServiceImplWithMongo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
+
+@Service
+public class HistoryMessageServiceImpl extends BaseServiceImplWithMongo<String, HistoryMessage> implements HistoryMessageService {
+
+	@Autowired
+	private HistoryMessageDao historyMessageDao;
+
+	@Override
+	public BaseDaoWithMongo<String, HistoryMessage> getDAO() {
+		return historyMessageDao;
+	}
+
+	@Override
+	public void saveImHistoryMessage(File file) throws Exception {
+//		long length = file.length();
+//		if(length > 1048576){
+			doNioReadFile(file);
+//		}else {
+//			doBufferReadFile(file);
+//		}
+	}
+
+//	public static void main(String[] args) throws Exception {
+//		doNioReadFile1(new File("/Users/chenxiaoyu/Documents/77fe9ce6-7d91-4568-afe3-9e8ac351e87f.zip"));
+//	}
+
+	public void doNioReadFile(File file) {
+		ZipInputStream zin = null;
+		try {
+			zin = new ZipInputStream(new FileInputStream(file), StandardCharsets.UTF_8);
+			ZipFile zf = new ZipFile(file);
+			ZipEntry ze;
+			Set<HistoryMessage> historyMessages = new HashSet<>();
+			while ((ze = zin.getNextEntry()) != null) {
+				BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze)));
+				String line;
+				while ((line = br.readLine()) != null) {
+					try {
+						historyMessages.add(JSONObject.parseObject(line.substring(line.indexOf("{")), HistoryMessage.class));
+//						if(historyMessages.size() >= 2000){
+//							historyMessageDao.batchInsert(new ArrayList<>(historyMessages),HistoryMessage.class);
+//							historyMessages.clear();
+//						}
+					}catch (Exception e){
+						e.printStackTrace();
+					}
+				}
+				br.close();
+				break;
+			}
+			if(historyMessages.size() > 0){
+				historyMessageDao.batchInsert(historyMessages.stream().sorted(Comparator.comparing(HistoryMessage::getDateTime)).collect(Collectors.toList()),HistoryMessage.class);
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			if (zin != null) {
+				try {
+					zin.closeEntry();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+//	public void doBufferReadFile(File file) throws Exception
+//	{
+//		BufferedReader reader = null;
+//		try {
+//
+////			InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "GBK");
+//			reader = new BufferedReader(new FileReader(file));
+//			String line = null;
+//			int num = 0;
+//			List<HistoryMessage> historyMessages = new ArrayList<>();
+//			while ((line = reader.readLine()) != null){
+//				try {
+//					historyMessages.add(JSONObject.parseObject(line.substring(line.indexOf("{")), HistoryMessage.class));
+//					if(historyMessages.size() >= 2000){
+//						historyMessageDao.batchInsert(historyMessages,HistoryMessage.class);
+//						historyMessages.clear();
+//					}
+//				}catch (Exception e){
+//					e.printStackTrace();
+//				}
+//				num++;
+//			}
+//			if(historyMessages.size() > 0){
+//				historyMessageDao.batchInsert(historyMessages,HistoryMessage.class);
+//			}
+//		} finally {
+//			reader.close();
+//		}
+//	}
+
+
+//	public static void doNioReadFile(File file) throws Exception
+//	{
+//		String enterStr = "\n";
+//
+//		FileChannel inChannel = new FileInputStream(file).getChannel();
+//		ByteBuffer buffer = ByteBuffer.allocate(1048576);
+//
+//		StringBuilder newlinesBui = new StringBuilder();
+//		while (inChannel.read(buffer) != -1)
+//		{
+//			buffer.flip();
+//			//数据组合.
+//			String content = new String(buffer.array());
+//			newlinesBui.append(content).toString();
+//
+//			int fromIndex = 0;
+//			int endIndex = -1;
+//			//循环找到 \n
+//			List<HistoryMessage> historyMessages = new ArrayList<>();
+//			while ((endIndex = newlinesBui.indexOf(enterStr, fromIndex)) > -1)
+//			{
+//				//得到一行
+//				String line = newlinesBui.substring(fromIndex, endIndex);
+//				try {
+//					historyMessages.add(JSONObject.parseObject(line.substring(line.indexOf("{")), HistoryMessage.class));
+//					if(historyMessages.size() >= 2000){
+////						historyMessageDao.batchInsert(historyMessages,HistoryMessage.class);
+//						historyMessages.clear();
+//					}
+//				}catch (Exception e){
+//					e.printStackTrace();
+//				}
+//				fromIndex = endIndex + 1;
+//			}
+//			if(historyMessages.size() > 0){
+////				historyMessageDao.batchInsert(historyMessages,HistoryMessage.class);
+//			}
+//			newlinesBui.delete(0, fromIndex);
+//			buffer.clear();
+//		}
+//	}
+}

+ 10 - 0
mec-common/mongo-db/src/main/java/com/yonge/mongodb/dao/BaseDaoWithMongo.java

@@ -3,6 +3,7 @@ package com.yonge.mongodb.dao;
 import java.io.Serializable;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -75,6 +76,15 @@ public abstract class BaseDaoWithMongo<PK, T extends Serializable> {
 	}
 
 	/**
+	 * 写入实体对象
+	 * @param batchBean
+	 * @param clazz
+	 */
+	public void batchInsert(List<T> batchBean, Class clazz) {
+		mongoTemplate.insert(batchBean,clazz);
+	}
+
+	/**
 	 * 通过参数查找所有结果集
 	 * @param params
 	 * @return

+ 2 - 1
mec-im/src/main/java/com/ym/config/ResourceServerConfig.java

@@ -12,6 +12,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
     public void configure(HttpSecurity http) throws Exception {
         http.authorizeRequests().antMatchers("/v2/api-docs","/user/register",
                 "/group/join","/group/create","/group/quit","/room/leave","/room/statusSync",
-                "/room/statusImMsg","/group/batchDismiss","/private/send","/group/send","/group/dismiss","/room/statusImMsg").permitAll().anyRequest().authenticated().and().csrf().disable();
+                "/room/statusImMsg","/group/batchDismiss","/private/send","/group/send",
+                "/group/dismiss","/room/statusImMsg","/history/get").permitAll().anyRequest().authenticated().and().csrf().disable();
     }
 }

+ 2 - 6
mec-im/src/main/java/com/ym/controller/HistoryController.java

@@ -2,14 +2,10 @@ package com.ym.controller;
 
 import com.ym.service.MessageService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
-/**
- * Created by weiqinxiao on 2019/2/25.
- */
 @RestController
 @RequestMapping("/history")
 public class HistoryController{
@@ -18,12 +14,12 @@ public class HistoryController{
     MessageService messageService;
 
     @RequestMapping(value = "/get", method = RequestMethod.POST)
-    public Object get(@RequestBody String date) throws Exception {
+    public Object get(String date) throws Exception {
         return messageService.historyGet(date);
     }
 
     @RequestMapping(value = "/remove", method = RequestMethod.POST)
-    public Object remove(@RequestBody String date) throws Exception {
+    public Object remove(String date) throws Exception {
         return messageService.historyRemove(date);
     }
 }

+ 4 - 1
mec-im/src/main/java/com/ym/service/Impl/MessageServiceImpl.java

@@ -47,7 +47,10 @@ public class MessageServiceImpl implements MessageService {
         return msgSystem;
     }
     private History getHistory(){
-        return new History(appKey,appSecret);
+        RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret);
+        History history = new History(appKey, appSecret);
+        history.setRongCloud(rongCloud);
+        return history;
     }
     private Push getPush(){
         return new Push(appKey,appSecret);

+ 19 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/SyncImHistoryMessageTask.java

@@ -0,0 +1,19 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SyncImHistoryMessageTask extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.syncImHistoryMessageTask();
+	}
+}

+ 3 - 1
mec-util/src/main/java/com/ym/mec/util/date/DateUtil.java

@@ -19,7 +19,9 @@ import java.util.*;
  */
 public class DateUtil {
 
-	private static final String CHINESE_DATA_FORMAT = "yyyy年MM月dd日 HH:mm:ss";
+	public static final String CHINESE_DATA_FORMAT = "yyyy年MM月dd日 HH:mm:ss";
+
+	public static final String YEAR_MONTH_DAY_HOUR = "yyyyMMddHH";
 
 	public static final String DEFAULT_PATTERN = "yyyy-MM-dd";
 

+ 34 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ImHistoryMessageController.java

@@ -0,0 +1,34 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.service.UploadFileService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.UploadReturnBean;
+import com.yonge.log.service.HistoryMessageService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.File;
+
+@RequestMapping("imHistoryMessage")
+@Api(tags = "系统操作日志")
+@RestController
+public class ImHistoryMessageController extends BaseController {
+
+	@Autowired
+	private HistoryMessageService historyMessageService;
+	@Autowired
+	private UploadFileService uploadFileService;
+
+
+	@GetMapping("/save")
+	public Object saveImHistoryMessage(String fileDir) throws Exception {
+		File file = new File(fileDir);
+		UploadReturnBean uploadReturnBean = uploadFileService.uploadImHistoryMsgFile(file);
+		historyMessageService.saveImHistoryMessage(file);
+		return succeed();
+	}
+
+}

+ 10 - 3
mec-web/src/main/java/com/ym/mec/web/controller/StudentRegistrationController.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.EmployeeService;
 
@@ -396,8 +397,8 @@ public class StudentRegistrationController extends BaseController {
         OutputStream outputStream = response.getOutputStream();
         HSSFWorkbook workbook = null;
         try {
-            String[] header = {"学员编号", "学员姓名", "声部", "预报名时间", "预报名时间差","预报名排名", "缴费时间", "缴费时间差","缴费排名"};
-            String[] body = {"userId", "studentName", "actualSubjectName", "perRegisterTime", "perRegIntervalStr","perRegSort", "payTime", "payIntervalStr","paySort"};
+            String[] header = {"学员编号", "学员姓名", "声部", "预报名时间", "预报名时间差", "预报名排名", "缴费时间", "缴费时间差", "缴费排名"};
+            String[] body = {"userId", "studentName", "actualSubjectName", "perRegisterTime", "perRegIntervalStr", "perRegSort", "payTime", "payIntervalStr", "paySort"};
             workbook = POIUtil.exportExcel(header, body, registerOrPreList.getRows());
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=registerOrPer-" + DateUtil.getDate(new Date()) + ".xls");
@@ -425,6 +426,12 @@ public class StudentRegistrationController extends BaseController {
     @GetMapping("/setNoneCloudTeacher")
     @PreAuthorize("@pcs.hasPermissions('studentRegistration/setNoneCloudTeacher')")
     public HttpResponseResult<Boolean> setNoneCloudTeacher(Long id) {
-        return succeed(studentRegistrationService.setNoneCloudTeacher(id));
+        StudentRegistration studentRegistration = studentRegistrationService.get(id);
+        //已付费的增加,已缴费人数、和0元付费人数
+        if (studentRegistration.getPaymentStatus().equals(PaymentStatusEnum.YES)) {
+            return succeed(studentRegistrationService.addPaidNum(id));
+        } else {
+            return succeed(studentRegistrationService.setNoneCloudTeacher(id));
+        }
     }
 }

+ 43 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -1,17 +1,27 @@
 package com.ym.mec.web.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.enums.IndexDataType;
 import com.ym.mec.biz.event.source.CourseEventSource;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.UploadReturnBean;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.redis.service.RedisCache;
+import com.ym.mec.im.ImFeignService;
+import com.ym.mec.util.date.DateUtil;
+import com.yonge.log.service.HistoryMessageService;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.File;
+import java.net.URL;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @RequestMapping("task")
@@ -100,6 +110,39 @@ public class TaskController extends BaseController {
 
 	@Autowired
 	private CloudTeacherOrderService cloudTeacherOrderService;
+	@Autowired
+	private HistoryMessageService historyMessageService;
+	@Autowired
+	private UploadFileService uploadFileService;
+	@Autowired
+	private ImFeignService imFeignService;
+
+	@GetMapping(value = "/syncImHistoryMessageTask")
+	// 同步即时通讯聊天记录
+	public void syncImHistoryMessageTask(String date) throws Exception {
+//		date = "2021060710";
+		if(date == null){
+			date = DateUtil.format(DateUtil.addHours(new Date(),-2), DateUtil.YEAR_MONTH_DAY_HOUR);
+		}
+		Object o = imFeignService.historyGet(date);
+		JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(o));
+		if(jsonObject.get("code").equals(200)){
+			Boolean success = redisCache.getRedisTemplate().opsForValue().setIfAbsent("syncImHistoryMessage" + date,date);
+			if(!success){
+				return;
+			}
+			String url = jsonObject.getString("url");
+			if(StringUtils.isEmpty(url)){
+				return;
+			}
+			File file = new File(FileUtils.getTempDirectoryPath() + url.substring(url.lastIndexOf("/")));
+//			File file = new File("/Users/chenxiaoyu/Documents/" + url.substring(url.lastIndexOf("/")));
+			URL url1 = new URL(url);
+			FileUtils.copyURLToFile(url1,file);
+			UploadReturnBean uploadReturnBean = uploadFileService.uploadImHistoryMsgFile(file);
+			historyMessageService.saveImHistoryMessage(new File(file.getAbsolutePath()));
+		}
+	}
 
 	@Autowired
 	private IndexErrDataRecordService indexErrDataRecordService;