|  | @@ -2,8 +2,10 @@ package com.yonge.cooleshow.admin.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.tencentyun.TLSSigAPIv2;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dto.ImGroupSearchDto;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.ImGroup;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.entity.ImHistoryMessage;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.SysUserService;
 | 
	
	
		
			
				|  | @@ -11,6 +13,7 @@ import com.yonge.cooleshow.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.redis.service.RedisCache;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.utils.date.DateUtil;
 | 
	
		
			
				|  |  | +import com.yonge.toolset.utils.http.HttpUtil;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.utils.validator.ValidationKit;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
	
		
			
				|  | @@ -26,7 +29,11 @@ import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  |  import javax.validation.Valid;
 | 
	
		
			
				|  |  |  import java.io.File;
 | 
	
		
			
				|  |  | +import java.net.HttpURLConnection;
 | 
	
		
			
				|  |  | +import java.net.MalformedURLException;
 | 
	
		
			
				|  |  |  import java.net.URL;
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | +import java.util.Calendar;
 | 
	
		
			
				|  |  |  import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -83,30 +90,68 @@ public class ImGroupController extends BaseController {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @GetMapping(value = "/syncImHistoryMessageTask")
 | 
	
		
			
				|  |  | -    // 同步即时通讯聊天记录
 | 
	
		
			
				|  |  | +    // 融云同步即时通讯聊天记录
 | 
	
		
			
				|  |  |      public void syncImHistoryMessageTask(String date) throws Exception {
 | 
	
		
			
				|  |  |          if(date == null){
 | 
	
		
			
				|  |  |              date = DateUtil.format(DateUtil.addHours(new Date(),-2), DateUtil.YEAR_MONTH_DAY_HOUR);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        Object o = imGroupService.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;
 | 
	
		
			
				|  |  | +        // 获取输入日期
 | 
	
		
			
				|  |  | +        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
 | 
	
		
			
				|  |  | +        Date currentDate = format.parse(date);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 创建Calendar对象 设置为输入时间
 | 
	
		
			
				|  |  | +        Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  | +        calendar.setTime(currentDate);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 将日期减少一个月
 | 
	
		
			
				|  |  | +        calendar.add(Calendar.MONTH, -1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 获取减少一个月后的日期
 | 
	
		
			
				|  |  | +        Date lastMonthDate = calendar.getTime();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        calendar.setTime(currentDate);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //按照小时递减
 | 
	
		
			
				|  |  | +        while (currentDate.after(lastMonthDate))
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            String d = DateUtil.format(DateUtil.addHours(currentDate,0), DateUtil.YEAR_MONTH_DAY_HOUR);
 | 
	
		
			
				|  |  | +            Object o = imGroupService.historyGet(d);
 | 
	
		
			
				|  |  | +            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(o));
 | 
	
		
			
				|  |  | +            if(jsonObject.get("code").equals(200)){
 | 
	
		
			
				|  |  | +                Boolean success = redisCache.getRedisTemplate().opsForValue().setIfAbsent("syncImHistoryMessage" + d,d);
 | 
	
		
			
				|  |  | +                if(!success){
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                String url = jsonObject.getString("url");
 | 
	
		
			
				|  |  | +                if(StringUtils.isEmpty(url)){
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                File file = new File(FileUtils.getTempDirectoryPath() + url.substring(url.lastIndexOf("/")));
 | 
	
		
			
				|  |  | +                URL url1 = new URL(url);
 | 
	
		
			
				|  |  | +                FileUtils.copyURLToFile(url1,file);
 | 
	
		
			
				|  |  | +                imGroupService.saveImHistoryMessage(new File(file.getAbsolutePath()));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            String url = jsonObject.getString("url");
 | 
	
		
			
				|  |  | -            if(StringUtils.isEmpty(url)){
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            File file = new File(FileUtils.getTempDirectoryPath() + url.substring(url.lastIndexOf("/")));
 | 
	
		
			
				|  |  | -            URL url1 = new URL(url);
 | 
	
		
			
				|  |  | -            FileUtils.copyURLToFile(url1,file);
 | 
	
		
			
				|  |  | -            imGroupService.saveImHistoryMessage(new File(file.getAbsolutePath()));
 | 
	
		
			
				|  |  | +            calendar.add(Calendar.HOUR,-1);
 | 
	
		
			
				|  |  | +            currentDate = calendar.getTime();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ApiOperation("IM导入消息")
 | 
	
		
			
				|  |  | +    @PostMapping(value = "/ImportIM")
 | 
	
		
			
				|  |  | +    public void ImportIM() throws Exception {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //获取融云消息
 | 
	
		
			
				|  |  | +        List<ImHistoryMessage> info = imGroupService.getRongYunInfo();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        imGroupService.importInfo(info);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |