| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import com.fgkj.actions.ActionUtil;
|
| | | import com.fgkj.actions.CustompageAction;
|
| | | import com.fgkj.dto.Custompage;
|
| | | import com.fgkj.dto.User_inf;
|
| | | import com.fgkj.dto.User_permitgroup;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | /**
|
| | | * 防止用户非法盗链
|
| | |
| | | flag=true;
|
| | | }
|
| | | }else{
|
| | | List<User_permitgroup> permits=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(ActionUtil.getSession().getAttribute("permits").toString(), new TypeToken<List<User_permitgroup>>(){}.getType());
|
| | | /*List<User_permitgroup> permits=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(ActionUtil.getSession().getAttribute("permits").toString(), new TypeToken<List<User_permitgroup>>(){}.getType());
|
| | | //System.out.println(permitName);
|
| | | //System.out.println(permits);
|
| | | User_permitgroup permit=getPermitByName(permitName, permits);
|
| | | //System.out.println(cust);
|
| | | if(permit!=null && permit.getPermit_item_value()==1 && cust.getSubflag()==1){
|
| | | flag=true;
|
| | | } |
| | | } */ |
| | | }
|
| | | Custompage t=getMainMenu(cust, custompages);
|
| | | if(t!=null && t.getSubflag()==0){
|
| | |
| | |
|
| | | }
|
| | |
|
| | | //判断当前用户是否有(permit)该权限
|
| | | /*//判断当前用户是否有(permit)该权限
|
| | | public static boolean getAlow(List<User_permitgroup> permits,User_permitgroup permit){
|
| | | boolean flag=false;
|
| | | for (int i = 0; i < permits.size(); i++) {
|
| | |
| | | }
|
| | | return flag;
|
| | | }
|
| | | |
| | | //根据权限的名字获取权限对象
|
| | | */
|
| | | /*//根据权限的名字获取权限对象
|
| | | public static User_permitgroup getPermitByName(String name,List<User_permitgroup> permits){
|
| | | for(int i=0;i<permits.size();i++){
|
| | | if(name.equalsIgnoreCase(permits.get(i).getPermit_item_name())){
|
| | |
| | | }
|
| | | //System.out.println("没有该权限");
|
| | | return null;
|
| | | }
|
| | | }*/
|
| | |
|
| | | //根据访问的页面获取导航对象
|
| | | public static Custompage getCustompage(String target,List<Custompage> Custs){
|
| | |
| | |
|
| | | import com.fgkj.actions.ActionUtil;
|
| | | import com.fgkj.dao.CheckMobile;
|
| | | import com.fgkj.dto.User;
|
| | | import com.fgkj.dto.User_inf;
|
| | | import com.fgkj.dto.Vip_user;
|
| | |
|
| | |
| | | import com.fgkj.db.DBUtil;
|
| | | import com.fgkj.db.IDatabaseName;
|
| | | import com.fgkj.dto.ServiceModel;
|
| | | import com.fgkj.dto.User;
|
| | | import com.fgkj.dto.UserClient;
|
| | | import com.fgkj.dto.User_Chart;
|
| | | import com.fgkj.dto.User_inf;
|
| | | import com.fgkj.dto.User_log;
|
| | | import com.fgkj.services.UserService;
|
| | | import com.fgkj.services.User_ChartService;
|
| | | import com.fgkj.services.User_battgroup_baojigroup_battgroupService;
|
| | | import com.fgkj.services.User_infService;
|
| | | import com.fgkj.services.User_logService;
|
| | | import com.fgkj.services.Vip_userService;
|
| | |
| | | * 存储当前用户的包机组信息
|
| | | * @param u
|
| | | */
|
| | | public void setUserBaoji(User_inf u){
|
| | | /*public void setUserBaoji(User_inf u){
|
| | | User_battgroup_baojigroup_battgroupService se = new User_battgroup_baojigroup_battgroupService();
|
| | | try {
|
| | | Object batts = se.serchByCondition(u).getData();
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }*/
|
| | |
|
| | | /**
|
| | | * 记录用户的登录记录
|
| | |
| | |
|
| | | import com.fgkj.dao.DAOHelper;
|
| | | import com.fgkj.dao.UinfDaoFactory;
|
| | | import com.fgkj.dto.BattInf;
|
| | | import com.fgkj.dto.BattMap_information;
|
| | | import com.fgkj.dto.ImageSize;
|
| | | import com.fgkj.dto.MyFile;
|
| | | import com.fgkj.dto.ServiceModel;
|
| | |
| | | }
|
| | |
|
| | | //上传机房视频接口
|
| | | public String uploadStationFile(){
|
| | | /*public String uploadStationFile(){
|
| | | BattInf binf = getGson().fromJson(json, BattInf.class);
|
| | | String fileRoot = "stationsrc";
|
| | | ServiceModel model = new ServiceModel();
|
| | |
| | | result = tojson(model);
|
| | | return SUCCESS;
|
| | | }
|
| | | |
| | | */
|
| | | /**
|
| | | *
|
| | | * 获取指定机房得资源
|
| | | */
|
| | | public String searchStationSource(){
|
| | | /*public String searchStationSource(){
|
| | | String fileRoot = "stationsrc"; //存放机房资源文件的文件夹
|
| | | BattInf binf = getGson().fromJson(json, BattInf.class);
|
| | | ServiceModel model = new ServiceModel();
|
| | |
| | | }
|
| | | result = tojson(model);
|
| | | return SUCCESS;
|
| | | }
|
| | | }*/
|
| | |
|
| | | //将文件复制到指定的目录
|
| | | public static void copyFile(File oldFile, String newPath){
|
| | |
| | | }
|
| | |
|
| | | //上传机房视频接口(手机端)
|
| | | public String uploadStationFile_mobile(){
|
| | | /*public String uploadStationFile_mobile(){
|
| | | BattInf binf = getGson().fromJson(json, BattInf.class);
|
| | | String fileRoot = "stationsrc";
|
| | | ServiceModel model = new ServiceModel();
|
| | |
| | | }
|
| | | result = tojson(model);
|
| | | return SUCCESS;
|
| | | }
|
| | | }*/
|
| | | //将获取到得图片加水印
|
| | | public static void GraphicsFile(Object obj, File file,String newImagePath) {
|
| | | /*public static void GraphicsFile(Object obj, File file,String newImagePath) {
|
| | | //InputStream is = null;
|
| | | OutputStream os = null;
|
| | | BattMap_information binfmation=(BattMap_information) obj;
|
| | |
| | | g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
| | | g.drawImage(srcImg.getScaledInstance(srcImg.getWidth(null), srcImg.getHeight(null), java.awt.Image.SCALE_SMOOTH), 0, 0, null);
|
| | | // 4、设置水印旋转
|
| | | /*if (null != degree) {
|
| | | if (null != degree) {
|
| | | //System.out.println("buffImg.getWidth():"+buffImg.getWidth()+" buffImg.getHeight():"+buffImg.getHeight());
|
| | | g.rotate(Math.toRadians(degree), buffImg.getWidth()/10,buffImg.getHeight() /10);
|
| | | }*/
|
| | | }
|
| | | // 5、设置水印文字颜色
|
| | | g.setColor(new Color(255,0,0));//默认红色
|
| | | int font_size= buffImg.getHeight() /35;
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | /* try {
|
| | | try {
|
| | | if (null != is)
|
| | | is.close();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }*/
|
| | | }
|
| | | try {
|
| | | if (null != os)
|
| | | os.close();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }*/
|
| | | //计算水印文本长度
|
| | | //1、中文长度即文本长度 2、英文长度为文本长度二分之一
|
| | | public static int getTextLength(String text){
|
| | |
| | | File file = new File(filePath);
|
| | | System.out.println(ActionUtil.tojson(file));*/
|
| | | //GraphicsFile("我是鲁星伟","D:\\1.jpg","D:\\2.jpg",0,new Color(255,0,0),"JPG");
|
| | | BattMap_information binfmation=new BattMap_information();
|
| | | /*BattMap_information binfmation=new BattMap_information();
|
| | | binfmation.setStationId("42000001");
|
| | | binfmation.setStationName("广西省-百色-GX百色乐业县立新小区WF-BTS设备");
|
| | | binfmation.setAddress("百色市乐业县立新小区附近居民楼上");
|
| | |
| | | File file=new File("D:\\1.jpg");
|
| | | String filePath = "D:\\2.jpg";
|
| | | //String filename="2.jpg";
|
| | | GraphicsFile(binfmation,file,filePath);
|
| | | GraphicsFile(binfmation,file,filePath);*/
|
| | | }
|
| | | }
|
| | |
| | | package com.fgkj.actions;
|
| | |
|
| | | import com.fgkj.dao.UinfDaoFactory;
|
| | | import com.fgkj.dto.Batt_attention;
|
| | | import com.fgkj.dto.Process_survey;
|
| | | import com.fgkj.dto.ServiceModel;
|
| | | import com.fgkj.dto.User_log;
|
| | |
| | | import java.util.Map;
|
| | |
|
| | | import com.fgkj.dao.UinfDaoFactory;
|
| | | import com.fgkj.dto.BattDischarge_plan;
|
| | | import com.fgkj.dto.ServiceModel;
|
| | | import com.fgkj.dto.User_Chart;
|
| | | import com.fgkj.dto.User_inf;
|
| | | import com.fgkj.dto.User_log;
|
| | | import com.fgkj.services.BattDischarge_planService;
|
| | | import com.fgkj.services.User_ChartService;
|
| | | import com.fgkj.services.User_logService;
|
| | |
|
| | |
| | |
|
| | | public static final int SENSOR_INF=2;
|
| | |
|
| | | public static final int SENSOR_STATE=3;
|
| | | |
| | | public static final int USER_CHART=4;
|
| | | |
| | | public static final int CUSTOMPAGE=5;
|
| | | |
| | | public static final int ECHARTS_USR=6;
|
| | | |
| | | public static final int PROCESS_SURVEY=7;
|
| | | |
| | | public static final int STATIONTRAFFIC=8;
|
| | | |
| | | public static final int USER_INF=9;
|
| | | |
| | | public static final int USER_LOG=10;
|
| | | |
| | | public static final int VIP_USER=11;
|
| | | |
| | | public static final int HARD_DEV_SMS_STATE=12;
|
| | | |
| | | public static final int SERVER_STATE=13;
|
| | | |
| | | |
| | | public boolean add(Object obj); // 添加
|
| | |
|
| | | public boolean update(Object obj); // 更新
|
| | |
| | | package com.fgkj.dao;
|
| | |
|
| | | import com.fgkj.dao.impl.CustompageImpl;
|
| | | import com.fgkj.dao.impl.Echarts_usrImpl;
|
| | | import com.fgkj.dao.impl.Process_surveyImpl;
|
| | | import com.fgkj.dao.impl.Sensor_infImpl;
|
| | | import com.fgkj.dao.impl.Sensor_mapinfoImpl;
|
| | | import com.fgkj.dao.impl.Sensor_stateImpl;
|
| | | import com.fgkj.dao.impl.StationtrafficImpl;
|
| | | import com.fgkj.dao.impl.User_ChartImpl;
|
| | | import com.fgkj.dao.impl.User_infImpl;
|
| | | import com.fgkj.dao.impl.User_logImpl;
|
| | | import com.fgkj.dao.impl.Vip_userImpl;
|
| | | import com.fgkj.dao.impl.ram.Hard_dev_sms_stateImpl;
|
| | | import com.fgkj.dao.impl.ram.Server_stateImpl;
|
| | | import com.fgkj.dto.Sensor_mapinfo;
|
| | |
|
| | | public class BaseDAOFactory {
|
| | |
| | | switch(DAOcode){
|
| | | case 1:return new Sensor_mapinfoImpl();
|
| | | case 2:return new Sensor_infImpl();
|
| | | case 3:return new Sensor_stateImpl();
|
| | | case 4:return new User_ChartImpl();
|
| | | case 5:return new CustompageImpl();
|
| | | case 6:return new Echarts_usrImpl();
|
| | | case 7:return new Process_surveyImpl();
|
| | | case 8:return new StationtrafficImpl();
|
| | | case 9:return new User_infImpl();
|
| | | case 10:return new User_logImpl();
|
| | | case 11:return new Vip_userImpl();
|
| | | case 12:return new Hard_dev_sms_stateImpl();
|
| | | case 13:return new Server_stateImpl();
|
| | | default :return null;
|
| | | }
|
| | | }
|
| | |
| | | import org.apache.poi.ss.formula.functions.T;
|
| | | import org.apache.struts2.ServletActionContext;
|
| | |
|
| | | import com.fgkj.dto.User;
|
| | |
|
| | | public class FileUtil {
|
| | | private static String filename="用户表.xls";
|
| | |
| | | return is;
|
| | | }
|
| | |
|
| | | public static void WriterFile(List<User> list){
|
| | | /*public static void WriterFile(List<User> list){
|
| | | HSSFWorkbook workbook = new HSSFWorkbook();
|
| | | HSSFSheet sheet = workbook.createSheet("sheet1");
|
| | |
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | |
| | | */
|
| | |
|
| | | public void exportExcel(String title, String[] headers, Collection dataset, String fileName, String pattern, String type)
|
| | | throws FileNotFoundException, IOException {
|
| | |
| | |
|
| | | import com.fgkj.dao.BaseDAO;
|
| | | import com.fgkj.dao.BaseDAOFactory;
|
| | | import com.fgkj.dao.impl.Sensor_infImpl;
|
| | | import com.fgkj.dto.ServiceModel;
|
| | |
|
| | | public class Sensor_infService {
|
| | |
| | | }
|
| | | //查询所有的省份(一级)
|
| | | public ServiceModel serchProvice(){
|
| | | |
| | | List list=((Sensor_infImpl)dao).serchProvice();
|
| | | if(list!=null&&list.size()>0){
|
| | | model.setCode(1);
|
| | | model.setData(list);
|
| | | model.setMsg("查询成功!");
|
| | | }else{
|
| | | model.setCode(0);
|
| | | model.setMsg("查询失败!");
|
| | | }
|
| | | |
| | | return model;
|
| | | }
|
| | | //查询所有的城市(二级)
|
| | | public ServiceModel serchCity(Object obj){
|
| | | List list=((Sensor_infImpl)dao).serchCity(obj);
|
| | | if(list!=null&&list.size()>0){
|
| | | model.setCode(1);
|
| | | model.setData(list);
|
| | | model.setMsg("查询成功!");
|
| | | }else{
|
| | | model.setCode(0);
|
| | | model.setMsg("查询失败!");
|
| | | }
|
| | | return model;
|
| | | }
|
| | | //查询所有的城市(三级)
|
| | | public ServiceModel serchCounty(Object obj){
|
| | | List list=((Sensor_infImpl)dao).serchCounty(obj);
|
| | | if(list!=null&&list.size()>0){
|
| | | model.setCode(1);
|
| | | model.setData(list);
|
| | | model.setMsg("查询成功!");
|
| | | }else{
|
| | | model.setCode(0);
|
| | | model.setMsg("查询失败!");
|
| | | }
|
| | | return model;
|
| | | }
|
| | | //根据设备id查询信息
|
| | | public ServiceModel serchByCondition(Object obj){
|
| | | List list=dao.serchByCondition(obj);
|
| | | if(list!=null&&list.size()>0){
|
| | | model.setCode(1);
|
| | | model.setData(list);
|
| | | model.setMsg("查询成功!");
|
| | | }else{
|
| | | model.setCode(0);
|
| | | model.setMsg("查询失败!");
|
| | | }
|
| | | return model;
|
| | | }
|
| | | }
|
| | |
| | | package com.fgkj.services;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.fgkj.dao.BaseDAO;
|
| | | import com.fgkj.dao.BaseDAOFactory;
|
| | | import com.fgkj.dto.ServiceModel;
|
| | |
|
| | | public class Sensor_stateService {
|
| | | private BaseDAO dao;
|
| | | private ServiceModel model;
|
| | | |
| | | |
| | | public Sensor_stateService() {
|
| | | super();
|
| | | dao=BaseDAOFactory.getBaseDAO(BaseDAO.SENSOR_STATE);
|
| | | model=new ServiceModel();
|
| | | }
|
| | | |
| | | //根据设备id查询状态
|
| | | public ServiceModel serchByCondition(Object obj) {
|
| | | List list=dao.serchByCondition(obj);
|
| | | if(list!=null&&list.size()>0){
|
| | | model.setCode(1);
|
| | | model.setData(list);
|
| | | model.setMsg("查询成功!");
|
| | | }else{
|
| | | model.setCode(0);
|
| | | model.setMsg("查询失败!");
|
| | | }
|
| | | return model;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| | |
|
| | | import com.fgkj.actions.ActionUtil;
|
| | | import com.fgkj.dao.BattTestData;
|
| | | import com.fgkj.dto.BattInf;
|
| | | import com.fgkj.dto.Batt_Maint_Dealarm;
|
| | | import com.fgkj.dto.Battalarm_data;
|
| | | import com.fgkj.dto.Batttestdata;
|
| | | import com.fgkj.dto.Ld9testdata;
|
| | | import com.fgkj.dto.Ld9testdata_inf;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | |
|
| | | import sun.misc.BASE64Decoder;
|
| | |
| | | }else if("control".equalsIgnoreCase(pageName)){
|
| | | controlExcelExprot(req,resp); //实时监测导出图表
|
| | | }else if("exportTbal".equalsIgnoreCase(pageName)){
|
| | | ExprotReport(req,resp); //导出报表
|
| | | //ExprotReport(req,resp); //导出报表
|
| | | }else if("charge-test-monData".equalsIgnoreCase(pageName)){
|
| | | ExprotLD9MonTestData(req,resp);
|
| | | //ExprotLD9MonTestData(req,resp);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | * @param req
|
| | | * @param resp
|
| | | */
|
| | | private void ExprotLD9MonTestData(HttpServletRequest req,
|
| | | /*private void ExprotLD9MonTestData(HttpServletRequest req,
|
| | | HttpServletResponse resp) {
|
| | | String mon_vol_line = req.getParameter("mon_vol_line"); //单体电压折线图
|
| | | String group_vol_line = req.getParameter("group_vol_line"); //组端/在线电压折线图
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | }*/
|
| | |
|
| | | //生成历史数据中LD9单体数据的报表
|
| | | /*//生成历史数据中LD9单体数据的报表
|
| | | private void createMonTestDataExcel(List<byte[]> bytes,BattInf binf,List<Ld9testdata> montestdata,Ld9testdata_inf mondatainfo,HttpServletResponse resp,HttpServletRequest req) {
|
| | | try {
|
| | | // 创建一个工作薄
|
| | |
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }*/
|
| | |
|
| | |
|
| | | public void createNewLD9DataSheet(HSSFWorkbook wb,final List<Ld9testdata> montestdata){
|
| | | /*public void createNewLD9DataSheet(HSSFWorkbook wb,final List<Ld9testdata> montestdata){
|
| | | HSSFSheet sheet = wb.createSheet("单体数据表");
|
| | | if(montestdata != null && montestdata.size()>0){
|
| | |
|
| | |
| | | //System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
|
| | | }
|
| | | }
|
| | | |
| | | */
|
| | |
|
| | | /**
|
| | | * 导出报表
|
| | | * @param req
|
| | | * @param resp
|
| | | */
|
| | | private void ExprotReport(HttpServletRequest req, HttpServletResponse resp) { |
| | | /*private void ExprotReport(HttpServletRequest req, HttpServletResponse resp) { |
| | | String ltop_echart = req.getParameter("ltop_echart"); //组端电压折线图
|
| | | String rtop_echart = req.getParameter("rtop_echart"); //电池电流折线图
|
| | | String lbottom_echart = req.getParameter("lbottom_echart"); //单体电压折线图
|
| | |
| | | createExcel(bytes, echarttitle, datas, bmd,mon_vol_list,mon_tmp_list,groupinfo, resp, req);
|
| | | }
|
| | |
|
| | | }
|
| | | }*/
|
| | |
|
| | |
|
| | | private void controlExcelExprot(HttpServletRequest req,
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | //生成历史数据中的报表
|
| | | /*//生成历史数据中的报表
|
| | | private void createExcel(List<byte[]> bytes,Title title,String[][] datas,Batt_Maint_Dealarm bmd,String[][] mon_vol_list ,String[][] mon_tmp_list,List<Batttestdata> groupinfo, HttpServletResponse resp,
|
| | | HttpServletRequest req) {
|
| | | String[] arrTh = new String[]{
|
| | |
| | | picnum ++;rownum+=25;
|
| | | }
|
| | |
|
| | | /*sheet1.createRow(rownum);
|
| | | sheet1.createRow(rownum);
|
| | | sheet1.getRow(rownum).createCell(1).setCellValue("单体实际容量");
|
| | | rownum++;
|
| | | anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
|
| | |
| | | anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
|
| | | anchor.setAnchorType(3);
|
| | | patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
|
| | | picnum ++;rownum+=25;*/
|
| | | picnum ++;rownum+=25;
|
| | |
|
| | | sheet1.createRow(rownum);
|
| | | sheet1.getRow(rownum).createCell(1).setCellValue("最高单体电压");
|
| | |
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }*/
|
| | |
|
| | | public void createMonInfoSheet(HSSFWorkbook wb,String[][] mon_vol_list ,String[][] mon_tmp_list,List<Batttestdata> groupinfo){
|
| | | /*public void createMonInfoSheet(HSSFWorkbook wb,String[][] mon_vol_list ,String[][] mon_tmp_list,List<Batttestdata> groupinfo){
|
| | | HSSFSheet sheet = wb.createSheet("单体数据表");
|
| | | if(mon_vol_list != null && mon_tmp_list != null && groupinfo != null){
|
| | | int mon_count = mon_tmp_list.length; //总单体数量
|
| | |
| | |
|
| | | //System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
|
| | | }
|
| | | }
|
| | | }*/
|
| | |
|
| | | /**
|
| | | * 将日期格式转换成指定的字符串格式
|
| | |
| | | import com.fgkj.actions.ActionUtil;
|
| | | import com.fgkj.dto.ServiceModel;
|
| | | import com.fgkj.dto.User_inf;
|
| | | import com.fgkj.dto.ram.Fbs9100_state;
|
| | | import com.fgkj.services.ram.Fbs9100_stateService;
|
| | |
|
| | | @ServerEndpoint("/ws/Fbs9100_stateSocket")
|
| | | public class Fbs9100_stateSocket extends ActionUtil{
|
| | | private Fbs9100_stateService service = new Fbs9100_stateService();
|
| | | /*private Fbs9100_stateService service = new Fbs9100_stateService();
|
| | |
|
| | | //静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
|
| | | static int onlineCount = 0;
|
| | |
| | |
|
| | | private HttpSession httpSession;
|
| | |
|
| | | /**
|
| | | *//**
|
| | | * 连接建立成功调用的方法
|
| | | * @param session 可选的参数。session为与某个客户端的连接会话,需要通过它来给客户端发送数据
|
| | | */
|
| | | *//*
|
| | | @OnOpen
|
| | | public void onOpen(Session session, EndpointConfig config){
|
| | | this.session = session;
|
| | |
| | | //System.out.println("有新连接加入!当前在线人数为" + getOnlineCount());
|
| | | }
|
| | |
|
| | | /**
|
| | | *//**
|
| | | * 连接关闭调用的方法
|
| | | */
|
| | | *//*
|
| | | @OnClose
|
| | | public void onClose(){
|
| | | timer.cancel();
|
| | |
| | | ServiceModel model = service.serchByCondition(state);
|
| | | return model;
|
| | | }
|
| | | /**
|
| | | *//**
|
| | | * 收到客户端消息后调用的方法
|
| | | * @param message 客户端发送过来的消息
|
| | | * @param session 可选的参数
|
| | | */
|
| | | *//*
|
| | | @OnMessage
|
| | | public void onMessage(String message,Session session) {
|
| | | task.setMessage(message);
|
| | | task.run();
|
| | | }
|
| | | /**
|
| | | *//**
|
| | | * 发生错误时调用
|
| | | * @param session
|
| | | * @param error
|
| | | */
|
| | | *//*
|
| | | @OnError
|
| | | public void onError(Session session, Throwable error){
|
| | | System.out.println("发生错误");
|
| | | error.printStackTrace();
|
| | | }
|
| | |
|
| | | /**
|
| | | *//**
|
| | | * 这个方法与上面几个方法不一样。没有用注解,是根据自己需要添加的方法。
|
| | | * @param message
|
| | | * @throws IOException
|
| | | */
|
| | | *//*
|
| | | public void sendMessage(String message) throws IOException{
|
| | | this.session.getBasicRemote().sendText(message);
|
| | | //this.session.getAsyncRemote().sendText(message);
|
| | |
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | */
|
| | | }
|