Search in sources :

Example 1 with TestAlertVo

use of com.ngtesting.platform.vo.TestAlertVo in project ngtesting-platform by aaronchen2k.

the class OptFacade method opt.

public void opt(JSONObject json, String userId) {
    Map<String, Object> ret = new HashMap<>();
    String type = json.getString("type");
    try {
        if (WsConstant.WS_OPEN.equals(type) || WsConstant.WS_TODO.equals(type)) {
            List<TestMsgVo> msgs = msgService.list(Long.valueOf(userId), false);
            List<TestAlertVo> alerts = alertService.list(Long.valueOf(userId), false);
            ret.put("msgs", msgs);
            ret.put("alerts", alerts);
            ret.put("type", WsConstant.WS_MSG_AND_ALERT_LASTEST);
        } else if (WsConstant.WS_OPT_ENTER_CHAT_ROOM.equals(type)) {
            ret = optChat.enter(json);
        } else if (WsConstant.WS_OPT_CHAT.equals(type)) {
            ret = optChat.chat(json);
        }
    } catch (Exception e) {
        logger.error(ExceptionUtil.GetExceptionInfo(e));
        if (e.getCause() instanceof TimeoutException) {
            ret.put("code", RespCode.BIZ_FAIL.getCode());
            ret.put("msg", "操作超时!");
        } else {
            ret.put("msg", "操作出错,请稍后重试");
        }
    }
    ret.put("code", 1);
    if (ret.get("type") != null) {
        scopeBean.sendMessageToClient(userId, new TextMessage(JSON.toJSONString(ret)));
    }
}
Also used : TestMsgVo(com.ngtesting.platform.vo.TestMsgVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestAlertVo(com.ngtesting.platform.vo.TestAlertVo) TimeoutException(java.util.concurrent.TimeoutException) TextMessage(org.springframework.web.socket.TextMessage) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with TestAlertVo

use of com.ngtesting.platform.vo.TestAlertVo in project ngtesting-platform by aaronchen2k.

the class AlertServiceImpl method genVos.

@Override
public List<TestAlertVo> genVos(List<TestAlert> pos) {
    List<TestAlertVo> vos = new LinkedList<>();
    for (TestAlert run : pos) {
        TestAlertVo vo = genVo(run);
        vos.add(vo);
    }
    return vos;
}
Also used : TestAlert(com.ngtesting.platform.entity.TestAlert) TestAlertVo(com.ngtesting.platform.vo.TestAlertVo) LinkedList(java.util.LinkedList)

Example 3 with TestAlertVo

use of com.ngtesting.platform.vo.TestAlertVo in project ngtesting-platform by aaronchen2k.

the class AlertServiceImpl method genVo.

@Override
public TestAlertVo genVo(TestAlert po) {
    TestAlertVo vo = new TestAlertVo();
    BeanUtilEx.copyProperties(vo, po);
    vo.setName(po.getEntityName());
    TestUser user = (TestUser) get(TestUser.class, po.getUserId());
    TestUser assignee = (TestUser) get(TestUser.class, po.getAssigneeId());
    vo.setUserName(user.getName());
    vo.setUserAvatar(user.getAvatar());
    vo.setAssigneeName(assignee.getName());
    vo.setAssigneeAvatar(assignee.getAvatar());
    Date now = new Date();
    Long startTimeOfToday = DateUtils.GetStartTimeOfDay(now).getTime();
    Long endTimeOfToday = DateUtils.GetEndTimeOfDay(now).getTime();
    Date startTime = po.getStartTime();
    Date endTime = po.getEndTime();
    if (endTime != null && endTime.getTime() >= startTimeOfToday && endTime.getTime() <= endTimeOfToday) {
        vo.setTitle("测试集" + StringUtil.highlightDict(vo.getName()) + "完成");
    } else {
        vo.setTitle("测试集" + StringUtil.highlightDict(vo.getName()) + "开始");
    }
    return vo;
}
Also used : TestAlertVo(com.ngtesting.platform.vo.TestAlertVo) TestUser(com.ngtesting.platform.entity.TestUser) Date(java.util.Date)

Aggregations

TestAlertVo (com.ngtesting.platform.vo.TestAlertVo)3 JSONObject (com.alibaba.fastjson.JSONObject)1 TestAlert (com.ngtesting.platform.entity.TestAlert)1 TestUser (com.ngtesting.platform.entity.TestUser)1 TestMsgVo (com.ngtesting.platform.vo.TestMsgVo)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 TimeoutException (java.util.concurrent.TimeoutException)1 TextMessage (org.springframework.web.socket.TextMessage)1