ssm配置socket_SSM配置Socket多线程编程(RFID签到实例)

packagecn.xydata.pharmacy.api.app.test;importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStream;importjava.io.InputStreamReader;importjava.io.PrintWriter;importjava.net.Socket;importjava.net.SocketTimeoutException;importjava.text.SimpleDateFormat;importjava.util.ArrayList;importjava.util.Date;importjava.util.LinkedHashSet;importjava.util.List;importjava.util.Map;importjava.util.TreeMap;importjavax.servlet.ServletContext;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.stereotype.Component;importcn.xydata.pharmacy.api.app.wx.Test1;importcn.xydata.pharmacy.api.app.wx.WxAPI;importcn.xydata.pharmacy.dao.meetings.MeetingDao;importcn.xydata.pharmacy.dto.meetings.MeetingEquipmentDto;importcn.xydata.pharmacy.dto.meetings.MeetingInfoDto;importcn.xydata.pharmacy.dto.meetings.MeetingParticipantDto;importcn.xydata.pharmacy.dto.meetings.ParticipantInfoDto;importcn.xydata.pharmacy.dto.wechat.AccessTokenDto;importcn.xydata.pharmacy.service.WechatMsgService;importcn.xydata.pharmacy.util.CommonUtil;importcn.xydata.pharmacy.util.DateUtil;importcn.xydata.pharmacy.util.WsPool;importcn.xydata.pharmacy.wechat.AccessToken;importcn.xydata.pharmacy.wechat.HttpReqUtil;importcn.xydata.pharmacy.wechat.JsonUtil;importcn.xydata.pharmacy.wechat.SystemConstant;importcn.xydata.pharmacy.wechat.TemplateMsgResult;importcn.xydata.pharmacy.wechat.WechatConfig;importcn.xydata.pharmacy.wechat.WechatTemplateMsg;importcn.xydata.pharmacy.wechat.enterprise.EwConfig;importcn.xydata.pharmacy.wechat.enterprise.MessageModel;/*** 多线程处理socket接收的数据

*

*@authorhuajian

**/@Componentpublic class SocketOperate extendsThread {

@AutowiredprivateWechatMsgService wechatMsgService;

@AutowiredprivateMeetingDao meetingDao;privateSocket socket;publicSocketOperate() {super();

}public staticSocketOperate socketOperate;public void init() throwsException {

socketOperate= this;

}publicSocketOperate(Socket socket) {this.socket =socket;

}

@SuppressWarnings("unused")public voidrun() {try{

InputStream in=socket.getInputStream();

PrintWriter out= newPrintWriter(socket.getOutputStream());//BufferedReader wt = new BufferedReader(new//InputStreamReader(System.in));

byte b[]=new byte[10];

String string= "";//while(in.read(b) != -1) {//in.read(readBytesFromInputStream(in, 10));

while(in.read(b) != -1) {

System.out.println("原始数据changdu:"+in.read(b));

string=Test1.bytesToHexFun2(b);

System.out.println("客户端发来:" +string.toString());//List listData = getSocketDatas(string);//for(String s : listData){//string = string.substring(string.indexOf("00008"), string.indexOf("00008")+8);//获取access_token

if("09".equals(string.substring(0, 2)) && string.indexOf("00008") != -1){

String czsbNo= "";for(MeetingEquipmentDto me : queryEquipment("czsb")){ //车载识别推送

czsbNo += me.geteNo() + "|";

}if(queryEquipment("hyqd").get(0).geteNo().equals(string.substring(2, 4))){ //签到消息推送

signTemplatePush(string);

}else if(queryEquipment("cjldts").get(0).geteNo().equals

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值