Пример #1
0
  @Override
  public Map<DATA_TYPE, Object> unpackObject(Map<DATA_TYPE, Object> message)
      throws PacketOperationException {
    logger.info("开始进行FIXSTRING解包....");
    offset = 0;

    cm = PacketUtils.getControlMessage(message);
    bm = PacketUtils.getBusinessMessage(message);
    bm.setSystemChanelCode(GlobalConst.bmwebChanelCode);
    buffer = (String) PacketUtils.getOrigReqPacket(message);

    logger.info("需要解包的报文内容:[{}]", buffer);

    fieldValues.clear();
    String[] fields = headerHelper.hasFields();
    unpackFIXSTRING(fields, buffer);
    headerHelper.unpack(fieldValues, cm, bm);
    String tranCode = cm.getTranCode();
    logger.info("交易{}解包包头完成.", tranCode);
    offset = 192;

    // pack body
    IPacketWEBSTRING packetHelper;
    try {
      packetHelper =
          (IPacketWEBSTRING) SpringContextHolder.getBean(getPacketBeanName(cm.getTranCode()));

      fields = packetHelper.hasFields();
      fieldValues.clear();
      unpackFIXSTRING(fields, buffer);

      System.out.println(buffer.toString());
      packetHelper.unpack(fieldValues, cm, bm);

      /*String shopCode = null;
      WEBMessageHead  fixMsgHeadData = (WEBMessageHead)bm.getFixMsgHeadData();
      if(bm.getTranCode().equals("000010")&& fixMsgHeadData.getHandleType().equals("7")) {
      	bm.setMacFlag(false);
      	//如果是web端交易同步调取的末笔交易查询则执行
      	TbBiTrade tbBiTrade =  tradeDao.getTradeById(fixMsgHeadData.getTranDate(), bm.getOldPbSeqno());
      	if(tbBiTrade != null) {
      		shopCode = tbBiTrade.getCompanyCode();
      	}
      }else {
      	shopCode = psamCompanyDao.findPsamCompanyRef(bm.getPSAMCardNo());
      }


      if(shopCode == null){
      	logger.error("psam卡对应商户号不存在!");
      	throw new PacketOperationException("psam卡对应商户号不存在!");
      }
      bm.setShopCode(shopCode);*/

      if (!checkMac(bm)) {
        throw new PacketOperationException("报文解包失败!报文格式错误");
      }

    } catch (Exception e) {
      logger.error("get packet helper class error!", e);
      throw new PacketOperationException();
    }
    logger.info("交易{}解包包体完成.", tranCode);
    logger.info("交易{}FIXSTRING报文解包完成....", tranCode);
    return message;
  }
Пример #2
0
 // 仅当报文解包处理出错时调用该函数
 @Override
 public Map<DATA_TYPE, Object> packErrorBuffer(Map<DATA_TYPE, Object> message) {
   // 如果解包未完成,直接将请求包返回
   PacketUtils.setOrigAnsPacket(message, PacketUtils.getOrigReqPacket(message));
   return null;
 }