yujian
2019-02-25 8b37d2f16d4aa7c7ce19829b74307ae0072b127f
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
@@ -8,9 +8,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
import com.yeshi.fanli.exception.PushException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SystemService;
import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
import com.yeshi.fanli.service.inter.push.PushRecordService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.user.AccountMessageService;
@@ -31,6 +34,8 @@
   public final static int URL = 2; // 网页推送
   public final static int DETAIL = 3; // 详情推送
   public final static int ZNX = 4; // 站内推送
   public final static int WEEX = 5; // 站内推送
   public final static int BAICHUAN = 6; // 站内推送
   @Resource
   private PushRecordService pushRecordService;
@@ -49,6 +54,9 @@
   @Resource
   private PushService pushService;
   @Resource
   private UserSystemMsgService userSystemMsgService;
   /**
    * 商品推送
@@ -138,17 +146,26 @@
    * @param out
    * @throws Exception
    */
   @RequestMapping(value = "convertLink", method = RequestMethod.POST)
   public void convertLink(String url, PrintWriter out) throws Exception {
   @RequestMapping(value = "convertLink")
   public void convertLink(String callback, String url, PrintWriter out) {
      String shortLink = org.yeshi.utils.HttpUtil.getShortLink(url);
      if (StringUtil.isNullOrEmpty(url)) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("转链数据不能为空"));
         return;
      }
      try {
         String shortLink = org.yeshi.utils.HttpUtil.getShortLink(url);
      JSONObject jsonData = new JSONObject();
      jsonData.put("url", url);
      jsonData.put("shortLink", shortLink);
      out.print(JsonUtil.loadTrueResult(jsonData));
         JSONObject jsonData = new JSONObject();
         jsonData.put("url", url);
         jsonData.put("shortLink", shortLink);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonData));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("转换失败"));
         e.printStackTrace();
      }
   }
   
@@ -241,7 +258,7 @@
    * @throws Exception
    */
   @RequestMapping(value = "newPushFanZNX")
   public void newPushFanZNX(String callback, Long uid, String title, String content, PrintWriter out) {
   public void newPushFanZNX(String callback, String uids, String title, String content, PrintWriter out) {
      
      if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写标题与内容"));
@@ -249,13 +266,79 @@
      }
      
      try {
         pushService.pushZNX(uid, title, content);
         String[] uidArray = null;
         if (uids != null) {
            uidArray = uids.split(",");
         }
         if (uidArray == null) {
            pushService.pushZNX(null, title, content);
         } else {
            for (int i = 0; i < uidArray.length; i++) {
               String str_uid = uidArray[i];
               if (str_uid != null && str_uid.trim().length() > 0) {
                  pushService.pushZNX(Long.parseLong(str_uid), title, content);
                  userSystemMsgService.addUserSystemMsg(Long.parseLong(str_uid),
                        UserSystemMsgTypeEnum.question, title, content,
                        UserSystemMsg.TIME_TAG_EMERGENT, null);
               }
            }
         }
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
      } catch (PushException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("推送失败"));
         e.printStackTrace();
      }
   }
   
   /**
    *
    * 方法说明: 百川推送 -(新后台)
    *
    * @param uId
    * @param title
    * @param content
    * @throws Exception
    */
   @RequestMapping(value = "pushBaiChuan")
   public void pushBaiChuan(String callback, String uids, String title, String content, String url,
         PrintWriter out) {
      if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写标题与内容"));
         return;
      }
      try {
         String[] uidArray = null;
         if (uids != null) {
            uidArray = uids.split(",");
         }
         if (uidArray == null) {
            pushService.pushBaiChuanUrl(null, title, content, url);
         } else {
            for (int i = 0; i < uidArray.length; i++) {
               String str_uid = uidArray[i];
               if (str_uid != null && str_uid.trim().length() > 0) {
                  pushService.pushBaiChuanUrl(Long.parseLong(str_uid), title, content, url);
               }
            }
         }
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
      } catch (PushException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("推送失败"));
         e.printStackTrace();
      }
   }
}