admin
2018-12-25 4cb15e222cd7d099d533ccbeb7f9a8cd99bf180c
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
@@ -6,8 +6,6 @@
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -21,14 +19,14 @@
import com.yeshi.fanli.entity.xinge.MessageInfo;
import com.yeshi.fanli.entity.xinge.PushRecord;
import com.yeshi.fanli.exception.PushException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.PushLogHelper;
import com.yeshi.fanli.service.inter.push.IOSPushService;
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.push.IOSPushUtil;
import net.sf.json.JSONObject;
@Service
public class IOSPushServiceImpl implements IOSPushService {
@@ -150,11 +148,6 @@
   }
   @Override
   public void pushWEEXUrl(Long uid, String weexUrl, String title, String content) throws PushException {
   }
   @Override
   public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX) throws PushException {
      MessageInfo info = new MessageInfo();
      info.setPackageName(Constant.systemCommonConfig.getAndroidPackageName());
@@ -256,6 +249,14 @@
         deviceTokenIos.setUid(uid);
         deviceTokenIos.setVersion(version);
         deviceTokenIOSMapper.insertSelective(deviceTokenIos);
      } else {// 更新devicetoken
         DeviceTokenIOS updateDeviceTokenIOS = new DeviceTokenIOS();
         updateDeviceTokenIOS.setId(deviceTokenIos.getId());
         updateDeviceTokenIOS.setDeviceToken(deviceToken);
         updateDeviceTokenIOS.setDeviceTokenMd5(StringUtil.Md5(deviceToken));
         updateDeviceTokenIOS.setUid(uid);
         updateDeviceTokenIOS.setUpdateTime(new Date());
         deviceTokenIOSMapper.updateByPrimaryKeySelective(updateDeviceTokenIOS);
      }
   }
@@ -469,4 +470,64 @@
      pushQueueRecordMapper.updateByPrimaryKeySelective(pushQueueRecord);
   }
   @Override
   public void unBindUidAndDevice(String device) {
      if (StringUtil.isNullOrEmpty(device))
         return;
      DeviceTokenIOS deviceTokenIOS = deviceTokenIOSMapper.selectByDevice(device);
      if (device != null) {
         deviceTokenIOS.setUpdateTime(new Date());
         deviceTokenIOS.setUid(null);
         deviceTokenIOSMapper.updateByPrimaryKey(deviceTokenIOS);
      }
   }
   @Override
   public void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException {
      MessageInfo info = new MessageInfo();
      info.setTitle(title);
      info.setContent(content);
      info.setDescription(content);
      // IOS 全推
      if (uid == null || uid == 0) {
         addPushIOSQueue(info, weexUrl, PushController.WEEX);
      } else {
         List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
         List<String> deviceTokenList = new ArrayList<>();
         if (deviceTokenIosList != null)
            for (DeviceTokenIOS ios : deviceTokenIosList) {
               deviceTokenList.add(ios.getDeviceToken());
            }
         try {
            IOSPushUtil.allPushIOS(deviceTokenList, info, weexUrl, PushController.WEEX);
         } catch (Exception e) {
            PushLogHelper.iosError(e);
         }
      }
   }
   @Override
   public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
      MessageInfo info = new MessageInfo();
      info.setTitle(title);
      info.setContent(content);
      info.setDescription(content);
      // IOS 全推
      if (uid == null || uid == 0) {
         addPushIOSQueue(info, url, PushController.BAICHUAN);
      } else {
         List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
         List<String> deviceTokenList = new ArrayList<>();
         if (deviceTokenIosList != null)
            for (DeviceTokenIOS ios : deviceTokenIosList) {
               deviceTokenList.add(ios.getDeviceToken());
            }
         try {
            IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.BAICHUAN);
         } catch (Exception e) {
            PushLogHelper.iosError(e);
         }
      }
   }
}