派生自 projectDept/qhighschool

胡仁荣
2022-11-24 06d6372b451b964738cbfe2adb37e1da85d856ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package com.qxueyou.scc.exercise.service.impl;
 
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.qxueyou.scc.base.dao.CommonDAO;
import com.qxueyou.scc.base.service.IONSExceptionLogService;
 
@Service("ExerciseSysMsgDealService")
public class ExerciseSysMsgDealService {
 
    @Autowired
    CommonDAO dao;
/*
    @Autowired
    IMsgVenderService  easemobService;*/
    
    @Autowired
    IONSExceptionLogService onsExceptionLogService;
    
    /*@Autowired
    protected IConfigService cfg;*/
    
    //private static Logger log = LogManager.getLogger("ONSExceptionLogService");
    
//    @PostConstruct
//    void init() {
//        CommonONSConsumer.registerHandler("SYS_EXER_SAVE", "ExerciseSysMsgDealService");
//    }
//
//    @Override
//    public void doHandle(Message msg, ConsumeContext context) {
        
        /*try {
 
//            String groupId = msg.getUserProperties("groupId");
//            String classId = msg.getUserProperties("classId");
//            String actionType = msg.getUserProperties("actionType");
            // Á·Ï°²»ÔÙ·¢ÏµÍ³Í¨Öª by cyq 20160823
            //sendSysNotice(groupId, classId, actionType);
 
        } catch (Exception e) {
 
            String businessId = cfg.getConfigByEnv("ons-common-topic") + "-" + UUIDUtils.generateUUID();
            String desp = "classId:" + msg.getUserProperties("classId") +
                    ";groupId:" + msg.getUserProperties("groupId") + 
                    ";actionType:" + msg.getUserProperties("actionType") ;
 
            log.error( businessId + " :¸üÐÂÁ·Ï°ÏµÍ³ÏûÏ¢·¢ËÍʧ°Ü:" + e , e);
            onsExceptionLogService.doSaveExceptionLog(cfg.getConfigByEnv("ons-common-topic"), "SYS_EXER_SAVE", businessId , desp );
 
        }*/
    }
    
    /**
     * ·¢ËÍÏûÏ¢
     * @param groupId
     * @param classId
     * @param actionType
     *//*
    private void sendSysNotice(String groupId, String classId, String actionType) {
        ExerciseGroup group = dao.read(ExerciseGroup.class, groupId);
        String hql = "from UserRegistration u where u.classId = ? and deleteFlag is false";
        
        List<UserRegistration> userList = dao.find(hql, CollectionUtils.newList(classId), UserRegistration.class);
        List<String> userIdList = new ArrayList<>();
        for (UserRegistration ur : userList) {
            userIdList.add(ur.getUserId());
        }
        OrgClass cls = dao.read(OrgClass.class, classId);
        String content = null;
            
        Map<String,String> extra = new HashMap<String,String>();
        extra.put("classId", classId);
        extra.put("className", cls.getName());
        if ("new".equalsIgnoreCase(actionType)) {
            extra.put("title", "ÓÐеÄϰÌâÀ²");
            content = cls.getName() + "°àÓÐеÄϰÌâŶ£¬¸Ï¿ìÈ¥ÃéÃé°É£¡";
        } else if ("update".equalsIgnoreCase(actionType)) {
            extra.put("title", "ϰÌâÓиüÐÂÀ²");
            content = cls.getName() + "°àϰÌâÓиüÐÂŶ£¬¸Ï¿ìÈ¥ÃéÃé°É£¡";
        }
        // add cyq 
        JSONObject androidParam = new JSONObject();
        JSONObject iOSParam = new JSONObject();
        if (group.getType() == ExerciseGroup.TYPE_HOMEWORK) {
            
            extra.put("type", SysNoticeConfigMetadata.TYPE_EXERCISE_HOMEWORK);
            androidParam.put("key_exercise_type_name", "¼ÒÍ¥×÷Òµ");
            androidParam.put("key_exercise_list_url", "http://www.qxueyou.com/qxueyou/exercise/Exercise/homeWorkListNew");
            androidParam.put("key_exercise_type", "1");
            iOSParam.put("Titlename", "¼ÒÍ¥×÷Òµ");
            
        } else if (group.getType() == ExerciseGroup.TYPE_MOCK_EXAM) {
            
            extra.put("type", SysNoticeConfigMetadata.TYPE_EXERCISE_ANALOGY);
            androidParam.put("key_exercise_type_name", "Ä£Ä⿼ÊÔ");
            androidParam.put("key_exercise_list_url", "http://www.qxueyou.com/qxueyou/exercise/Exercise/examsListNew");
            androidParam.put("key_exercise_type", "4");
            iOSParam.put("Titlename", "Ä£Ä⿼ÊÔ");
            
        } else if (group.getType() == ExerciseGroup.TYPE_CHAPTER_ITEM) {
            
            extra.put("type", SysNoticeConfigMetadata.TYPE_EXERCISE_CHAPTER);
            androidParam.put("key_exercise_type_name", "Õ½ÚÁ·Ï°");
            androidParam.put("key_exercise_list_url", "http://www.qxueyou.com/qxueyou/exercise/Exercise/chapterListNew");
            androidParam.put("key_exercise_type", "6");
            iOSParam.put("Titlename", "Õ½ÚÁ·Ï°");
            
        } else if (group.getType() == ExerciseGroup.TYPE_EXERCISE_TOPIC) {
            
            extra.put("type", SysNoticeConfigMetadata.TYPE_EXERCISE_CHAPTER);
            androidParam.put("key_exercise_type_name", "רÏîÁ·Ï°");
            androidParam.put("key_exercise_list_url", "http://www.qxueyou.com/qxueyou/exercise/Exercise/topicListNew");
            androidParam.put("key_exercise_type", "9");
            iOSParam.put("Titlename", "רÏîÁ·Ï°");
            
        } else if (group.getType() == ExerciseGroup.TYPE_EXERCISE_FREE) {
            
            extra.put("type", SysNoticeConfigMetadata.TYPE_EXERCISE_FREEDOM);
            androidParam.put("key_exercise_type_name", "×ÔÓÉÁ·Ï°");
            androidParam.put("key_exercise_list_url", "http://www.qxueyou.com/qxueyou/exercise/Exercise/freeListNew");
            androidParam.put("key_exercise_type", "10");
            iOSParam.put("Titlename", "×ÔÓÉÁ·Ï°");
            
        }
        
        extra.put("androidParams", androidParam.toString());
        extra.put("iosParams", iOSParam.toString());
        if (StringUtils.isNotEmpty(content)) {
            // ¶ÔÏûÏ¢½ÓÊÕÈ˰´Ã¿Åú×î¶à20ÈË·ÖÅú·¢ËÍ
            String[] receivers;
            int loop = (userIdList.size() + 19) / 20;
            for (int i = 0; i < loop; i ++) {
                int len = (i == (loop - 1)) ? userIdList.size() - 20 * i : 20;
                receivers = new String[len];
                userIdList.subList(i * 20,  i * 20 + len).toArray(receivers);
                easemobService.doSendTextMsgToUsers("notice-sys", receivers, content, extra);
            }
        }
    }*/
//}