package com.ag.web.websocket;

import cn.hutool.core.date.DateUtil;
import com.ag.entity.topic.RemqMsgCustom;
import com.ag.topic.IRedisTopicCtl;
import com.wb.util.SysUtil;
import com.wb.util.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
public class NoticeTestService {

    @Autowired
    JdbcTemplate jdbcTemplatebusiness;
    @Autowired
    private IRedisTopicCtl redisTopicCtl;


    @Transactional
    public void test(org.json.JSONObject jsonObject, HttpServletResponse response, HttpServletRequest request) {


        String busType = "订舱";
        String busUrl = "bookingManagement/onlineBookingConfirm.xwl";
        String chatName = "测试频道";
        String msg = "已提交订舱数据";

        RemqMsgCustom remqMsgCustom = new RemqMsgCustom();
        remqMsgCustom.setId(SysUtil.getId());
        remqMsgCustom.setBusinessKey(SysUtil.getId());//明细MSG_ID
        remqMsgCustom.setBusinessType(busType);//业务类型 名称
        remqMsgCustom.setBusinessUrl(busUrl);//业务页面URL
        remqMsgCustom.setMsgInfo(msg);//消息内容
        remqMsgCustom.setCreatedBy("system");
        remqMsgCustom.setAssignReceiveMan("admin,13fd2c40-9938-47a0-a2a5-327f675c1109");//指定消息接收人
        remqMsgCustom.setCreatedOn(DateUtil.date());
        remqMsgCustom.setUpdatedBy("system");
        remqMsgCustom.setUpdatedOn(DateUtil.date());
        remqMsgCustom.setChatName(chatName);

        redisTopicCtl.send(remqMsgCustom, chatName);

        try {
            WebUtil.send(response, 1);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



}

