浏览代码

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida 8 年之前
父节点
当前提交
9f03973d89

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -102,7 +102,8 @@ public class SwaggerConfig {
                        regex("/qrcode/.*"),
                        regex("/onepay/.*"),
                        regex("/wlyy_service/.*"),
                        regex("/express/.*")
                        regex("/wlyy_service/.*"),
                        regex("/wechat/.*")
                ))
                .build()
                .apiInfo(otherApiInfo());

+ 51 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/wechat/WechatTag.java

@ -0,0 +1,51 @@
package com.yihu.wlyy.entity.wechat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/4.
 */
@Entity
@Table(name = "wx_tag")
public class WechatTag extends IdEntity {
    private Integer tagId;
    private String tagName;
    private Date createTime;
    private Integer del;
    public Integer getTagId() {
        return tagId;
    }
    public void setTagId(Integer tagId) {
        this.tagId = tagId;
    }
    public String getTagName() {
        return tagName;
    }
    public void setTagName(String tagName) {
        this.tagName = tagName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/SystemDictDao.java

@ -16,7 +16,10 @@ public interface SystemDictDao extends PagingAndSortingRepository<SystemDict, Lo
    List<SystemDict> findByDictName(String name);
    @Query("select s.value from SystemDict s where s.dictName=?1 and s.code =?2")
    String findByDictNameAndCode(String dictName,String code);
    String findByDictNameAndCode(String dictName, String code);
    @Query(" from SystemDict s where s.dictName=?1 and s.value =?2")
    SystemDict findByDictNameAndValue(String dictName, String value);
    @Query("select s from SystemDict s where s.value like ?1 ")
    List<SystemDict> findByLikeName(String name);

+ 24 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/wechat/WechatTagDao.java

@ -0,0 +1,24 @@
package com.yihu.wlyy.repository.wechat;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.url.CudUrl;
import com.yihu.wlyy.entity.wechat.WechatTag;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/4.
 */
public interface WechatTagDao extends PagingAndSortingRepository<WechatTag, Long>, JpaSpecificationExecutor<WechatTag> {
    @Query(" from WechatTag where tagName=? and del=1")
    WechatTag findByName(String name);
    @Query(" from WechatTag where tagId=? and del=1")
    WechatTag findByTagId(Integer tagId);
    @Query(" update WechatTag set del=0 where tagId=?1 ")
    @Modifying
    void deleteTag(Integer tagId);
}

+ 21 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -9,11 +9,14 @@ import com.yihu.wlyy.service.common.util.SignTeamAndGroupRunnable;
import com.yihu.wlyy.util.SpringUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
@ -48,7 +51,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/disease/to_redis")
    @RequestMapping(value = "/disease/to_redis", method = RequestMethod.POST)
    public String updateToRedid() {
        try {
            diseaseService.updateToRedis();
@ -63,7 +66,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/disease/to_disease")
    @RequestMapping(value = "/disease/to_disease", method = RequestMethod.POST)
    public String updateToDisease() {
        try {
            diseaseService.updateToDisease();
@ -79,7 +82,7 @@ public class ManagerUtilController extends BaseController {
     * @param patient
     * @return
     */
    @RequestMapping(value = "/disease/patient")
    @RequestMapping(value = "/disease/patient", method = RequestMethod.POST)
    public String getDiseaseFromRedis(String patient) {
        try {
            return write(200, "查询成功", "data", redisTemplate.opsForValue().get("disease:" + patient));
@ -96,7 +99,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/famous_doctor/times_update")
    @RequestMapping(value = "/famous_doctor/times_update", method = RequestMethod.POST)
    public String famousConsultTimeUpdate() {
        try {
            workTimeService.consultTimesRemain(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
@ -112,7 +115,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/people_num_to_redis")
    @RequestMapping(value = "/people_num_to_redis", method = RequestMethod.POST)
    public String peopleNumToRedis(String year) {
        try {
            statisticsService.peopleNumToRedis(year);
@ -127,7 +130,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_set_group_team")
    @RequestMapping(value = "/sign_set_group_team", method = RequestMethod.POST)
    public String signSetGroupAndTeam() {
        try {
            manageUtilService.signPatientSetGroup();
@ -142,7 +145,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_set_group_team_page")
    @RequestMapping(value = "/sign_set_group_team_page", method = RequestMethod.POST)
    public String signSetGroupAndTeamPage(int page) {
        try {
            manageUtilService.setSignTeamAndGroupByPage(page);
@ -157,7 +160,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_set_group_team_id")
    @RequestMapping(value = "/sign_set_group_team_id", method = RequestMethod.POST)
    public String signSetGroupAndTeamId(Long id) {
        try {
            manageUtilService.setSignTeamAndGroupById(id);
@ -172,7 +175,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_error_page_id")
    @RequestMapping(value = "/sign_error_page_id", method = RequestMethod.POST)
    public String getErrorPage(int type) {
        try {
            if (type == 1) {
@ -192,7 +195,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_team_group_thread")
    @RequestMapping(value = "/sign_team_group_thread", method = RequestMethod.POST)
    public String getErrorPage(long start, long end) {
        try {
            new Thread(SpringUtil.getBean(SignTeamAndGroupRunnable.class)
@ -209,7 +212,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/tranform_edu_article")
    @RequestMapping(value = "/tranform_edu_article", method = RequestMethod.POST)
    public String tranformEduArticle() {
        try {
            manageUtilService.transformEduArticle();
@ -220,12 +223,10 @@ public class ManagerUtilController extends BaseController {
    }
    /**
     * 产检提醒
     *  每天早上六点
     * 每天早上六点
     *
     * @return
     */
//    @RequestMapping(value = "/start_prenatal_inspector_job")
@ -242,4 +243,9 @@ public class ManagerUtilController extends BaseController {
//            return error(-1, "启动失败");
//        }
//    }
    //---------------------------微信标签相关 start---------------------------------
    //---------------------------微信标签相关 end---------------------------------
}

+ 1 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.service.weixin.WeiXinCoreService;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -161,7 +160,7 @@ public class WechatCoreController extends WeixinBaseController {
    public String createMenuTest() {
        try {
            String filePath = WechatCoreController.class.getResource("/").getPath() +
                    File.separator + "weixin_menu.txt";
                    File.separator + "wechat"+ File.separator+"weixin_menu.txt";
            String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + getAccessToken();
            // 读取微信菜单配置文件
            InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "utf-8");

+ 119 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatMenuController.java

@ -0,0 +1,119 @@
package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
/**
 * Created by chenweida on 2017/8/4.
 */
@RestController
@RequestMapping(value = "/wechat/menu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "微信菜单相关管理")
public class WechatMenuController extends BaseController {
    @Autowired
    private WeiXinTagUtil weiXinTagUtil;
    @Value("${wechat.wechat_token}")
    private String wechat_token;
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Value("${wechat.appId}")
    private String appId;
    @Autowired
    private com.yihu.wlyy.util.HttpUtil HttpUtil;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    /**
     * 微信菜单创建
     *
     * @return
     */
    @ApiOperation(value = "微信菜单创建")
    @RequestMapping(value = "/menu/create", method = RequestMethod.POST)
    public String createMenuTest() {
        try {
            String filePath = WechatCoreController.class.getResource("/").getPath() +
                    File.separator + "wechat" + File.separator + "weixin_menu.txt";
            String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + weiXinAccessTokenUtils.getAccessToken();
            // 读取微信菜单配置文件
            InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "utf-8");
            BufferedReader bufferedReader = new BufferedReader(reader);
            String params = "";
            String readTxt = "";
            // 读取微信菜单
            while ((readTxt = bufferedReader.readLine()) != null) {
                System.out.println(readTxt);
                params += readTxt;
            }
            bufferedReader.close();
            reader.close();
            // 替换服务器地址、APPID
            params = params.replaceAll("server_url", wechat_base_url);
            params = params.replaceAll("appId", appId);
            // 请求微信接口创建菜单
            String jsonStr = HttpUtil.sendPost(url, params);
            JSONObject result = new JSONObject(jsonStr);
            if (result != null && result.get("errcode").toString().equals("0") && result.getString("errmsg").equals("ok")) {
                return write(200, "创建成功!", "data", jsonStr);
            } else {
                return write(-1, "创建失败!", "data", jsonStr);
            }
        } catch (Exception e) {
            return error(-1, "创建失败");
        }
    }
    /**
     * 集美区微信特色菜单菜单创建
     *
     * @return
     */
    @ApiOperation(value = "集美区微信特色菜单菜单创建")
    @RequestMapping(value = "/menu/create/jimei", method = RequestMethod.POST)
    public String createMenuTestJimei() {
        try {
            String filePath = WechatCoreController.class.getResource("/").getPath() +
                    File.separator + "wechat" + File.separator + "weixin_menu_jimei.txt";
            String url = " https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=" + weiXinAccessTokenUtils.getAccessToken();
            // 读取微信菜单配置文件
            InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "utf-8");
            BufferedReader bufferedReader = new BufferedReader(reader);
            String params = "";
            String readTxt = "";
            // 读取微信菜单
            while ((readTxt = bufferedReader.readLine()) != null) {
                System.out.println(readTxt);
                params += readTxt;
            }
            bufferedReader.close();
            reader.close();
            // 替换服务器地址、APPID
            params = params.replaceAll("server_url", wechat_base_url);
            params = params.replaceAll("appId", appId);
            // 请求微信接口创建菜单
            String jsonStr = HttpUtil.sendPost(url, params);
            return write(200, "创建成功!", "data", jsonStr);
        } catch (Exception e) {
            return error(-1, "创建失败");
        }
    }
}

+ 105 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatTagController.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
/**
 * Created by chenweida on 2017/8/4.
 */
@RestController
@RequestMapping(value = "/wechat/tag", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "微信标签相关管理")
public class WechatTagController extends BaseController {
    @Autowired
    private WeiXinTagUtil weiXinTagUtil;
    @ApiOperation(value = "创建微信标签")
    @RequestMapping(value = "/createTag", method = RequestMethod.POST)
    public String createTage(
            @ApiParam(name = "tagName", value = "标签名称", required = true) @RequestParam(value = "tagName", required = true) String tagName) {
        try {
            String string = weiXinTagUtil.createTag(tagName);
            return write(200, "创建成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "删除微信标签")
    @RequestMapping(value = "/deleteTag", method = RequestMethod.POST)
    public String deleteTag(
            @ApiParam(name = "tageId", value = "微信标签Id", required = true) @RequestParam(value = "tageId", required = true) Integer tageId) {
        try {
           String string= weiXinTagUtil.deleteTag(tageId);
            return write(200, "删除成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "获取已经创建的微信标签")
    @RequestMapping(value = "/queryTags", method = RequestMethod.GET)
    public String queryTags() {
        try {
            String string = weiXinTagUtil.queryTags();
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "根据openId获取该用户下的标签")
    @RequestMapping(value = "/queryByOpenId", method = RequestMethod.POST)
    public String queryByOpenId(
            @ApiParam(name = "openid", value = "openid", required = true) @RequestParam(value = "openid", required = true) String openid) {
        try {
            String string = weiXinTagUtil.queryTagWithOpenid(openid);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "批量给openID添加标签")
    @RequestMapping(value = "/addTagsWithOpenId", method = RequestMethod.POST)
    public String addTagsWithOpenId(
            @ApiParam(name = "openids", value = "openids,多个逗号分割", required = true) @RequestParam(value = "openids", required = true) String openids,
            @ApiParam(name = "tageId", value = "微信标签Id", required = true) @RequestParam(value = "tageId", required = true) Integer tageId) {
        try {
            String[] openis = openids.split(",");
            String string = weiXinTagUtil.addTagWithOpenid(java.util.Arrays.asList(openis),tageId);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "批量给openID取消标签")
    @RequestMapping(value = "deleteTagsWithOpenId", method = RequestMethod.POST)
    public String deleteTagsWithOpenId(
            @ApiParam(name = "openids", value = "openids,多个逗号分割", required = true) @RequestParam(value = "openids", required = true) String openids,
            @ApiParam(name = "tageId", value = "微信标签Id", required = true) @RequestParam(value = "tageId", required = true) Integer tageId) {
        try {
            String[] openis = openids.split(",");
            String string = weiXinTagUtil.deleteTagWithOpenid(java.util.Arrays.asList(openis),tageId);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
}

+ 200 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinTagUtil.java

@ -0,0 +1,200 @@
package com.yihu.wlyy.wechat.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.wechat.WechatTag;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.wechat.WechatTagDao;
import com.yihu.wlyy.util.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/8/4.
 * 微信标签功能
 */
@Component
public class WeiXinTagUtil {
    @Autowired
    private WechatTagDao wechatTagDao;
    private Logger logger = LoggerFactory.getLogger(WeiXinTagUtil.class);
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private HttpUtil httpUtil;
    @Value("${wechat.appSecret}")
    private String appSecret;
    // 创建标签
    private static String create_tag = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=";
    //删除标签
    private static String delete_tag = "https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=";
    //查询标签
    private static String query_tag = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token=";
    //给用户打标签
    private static String add_user_tag = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=";
    //给用户删除标签
    private static String delete_user_tag = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=";
    //获取用户标签
    private static String query_user_tag = "https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=";
    /**
     * 根据openID给用户打标签,并且同步更新用户表
     *
     * @param openIds
     * @param tagId
     * @return
     */
    public String addTagWithOpenid(List<String> openIds, Integer tagId) {
        try {
            net.sf.json.JSONObject params = new net.sf.json.JSONObject();
            params.put("openid_list", net.sf.json.JSONArray.fromObject(openIds));
            params.put("tagid", tagId);
            String result = httpUtil.sendPost(add_user_tag + weiXinAccessTokenUtils.getAccessToken(), params.toString());
            net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
            if (resultJson.containsKey("errcode")) {
                Integer status = resultJson.getInt("errcode");
                if (status != 0) {
                    throw new Exception("创建失败," + result);
                }
            }
            return result;
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * 根据openID给用户取消标签,并且同步更新用户表
     *
     * @param openIds
     * @param tagId
     * @return
     */
    public String deleteTagWithOpenid(List<String> openIds, Integer tagId) {
        try {
            net.sf.json.JSONObject params = new net.sf.json.JSONObject();
            params.put("openid_list", net.sf.json.JSONArray.fromObject(openIds));
            params.put("tagid", tagId);
            String result = httpUtil.sendPost(delete_user_tag + weiXinAccessTokenUtils.getAccessToken(), params.toString());
            net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
            if (resultJson.containsKey("errcode")) {
                Integer status = resultJson.getInt("errcode");
                if (status != 0) {
                    throw new Exception("创建失败," + result);
                }
            }
            return result;
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * 获取用户身上的标签列表
     *
     * @param openId
     * @return
     */
    public String queryTagWithOpenid(String openId) {
        try {
            net.sf.json.JSONObject params = new net.sf.json.JSONObject();
            params.put("openid", openId);
            String result = httpUtil.sendGet(query_user_tag + weiXinAccessTokenUtils.getAccessToken(), params.toString());
            net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
            return result;
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * 新增标签
     *
     * @param name
     * @return
     */
    public String createTag(String name) throws Exception {
        JSONObject params = new JSONObject();
        JSONObject tagName = new JSONObject();
        tagName.put("name", name);
        params.put("tag", tagName);
        // 发送模板消息
        String result = httpUtil.sendPost(create_tag + weiXinAccessTokenUtils.getAccessToken(), params.toJSONString());
        logger.info("create tag resutl:" + result);
        net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
        if (resultJson.containsKey("errcode")) {
            Integer status = resultJson.getInt("errcode");
            if (status != 0) {
                throw new Exception("创建失败," + result);
            }
        }
        Integer tag = resultJson.getJSONObject("tag").getInt("id");
        WechatTag newWechatTag = new WechatTag();
        newWechatTag.setCreateTime(new Date());
        newWechatTag.setTagName(name);
        newWechatTag.setDel(1);
        newWechatTag.setTagId(tag);
        wechatTagDao.save(newWechatTag);
        return result;
    }
    /**
     * 删除标签
     *
     * @param tagId
     * @return
     */
    public String deleteTag(Integer tagId) throws Exception {
        JSONObject params = new JSONObject();
        JSONObject tagName = new JSONObject();
        tagName.put("id", tagId);
        params.put("tag", tagName);
        // 发送模板消息
        String result = httpUtil.sendPost(delete_tag + weiXinAccessTokenUtils.getAccessToken(), params.toJSONString());
        logger.info("delete tag resutl:" + result);
        net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
        if (resultJson.containsKey("errcode")) {
            Integer status = resultJson.getInt("errcode");
            if (status != 0) {
                throw new Exception("创建失败," + result);
            }
        }
        //删除我们自己表的标签表数据
        wechatTagDao.deleteTag(tagId);
        return result;
    }
    public String queryTags() {
        String result = httpUtil.sendGet(query_tag + weiXinAccessTokenUtils.getAccessToken() + "&secret=" + appSecret, "");
        return result;
    }
}

patient-co/patient-co-wlyy/src/main/resources/weixin_menu.txt → patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt


+ 92 - 0
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

@ -0,0 +1,92 @@
{
"button":[
   {
	  "name":"家庭医生",
	  "sub_button":[
		  {
			"type":"view",
			"name":"签约管理",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fqygl%2fhtml%2fsigning_management.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生咨询",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszx%2fhtml%2fdoctor-consultation.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生指导",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszd%2fhtml%2fdoctor-guidance.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
            "type":"view",
            "name":"健康文章",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjy%2fhtml%2farticle_list.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          }
	  ]
   },
   {
	  "name":"健康管理",
	  "sub_button":[
		 {
			  "type":"view",
			  "name":"预约挂号",
			  "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdyy%2fhtml%2fappointment-register.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		 },
		 {
               "type":"view",
               "name":"健康记录",
               "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjl%2fhtml%2fhealth-record.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		{
			"type":"click",
			"name":"健康档案",
			"key":"jiankangdangan"
		},
         {
            "type":"view",
            "name":"疾病社区",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjbsq%2fhtml%2fdisease-community.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
        {
            "type":"view",
            "name":"热量查询",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2frlcx%2fhtml%2fserach-index.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	  ]
   },
   {
	  "name":"我的",
	  "sub_button":[
		{
		   "type":"view",
		   "name":"我的资料",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-detail.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
           "type":"view",
           "name":"我的家庭",
           "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjtgx%2fhtml%2ffamily.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
		{
		   "type":"view",
		   "name":"我的设备",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdsb%2fhtml%2fmy-equipments.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
         	"type":"click",
         	"name":"操作说明",
         	"key":"caozuoshuoming"
        },
        {
        	 "type":"view",
        	 "name":"集美反馈",
        	 "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyjfk%2fhtml%2ffeedback.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	 ]
  }],
    "matchrule":{
      "tag_id":"105"
      }
}