Browse Source

新增医生助手功能

trick9191 7 years ago
parent
commit
97f3c28c23

+ 1 - 1
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -2574,7 +2574,7 @@ public class SignWebService extends BaseService {
    }
    public List<String> findOpenidsByTown(String town) {
        String sql = "select w.openid from wlyy_sign_family w ,dm_hospital d where w.hospital=d.`code` and d.town='" + town + "' and w.openid is not null and w.openid !=''";
        String sql = "select  w.openid from wlyy_sign_family w ,dm_hospital d where w.hospital=d.`code` and d.town='" + town + "' and w.openid is not null and w.openid !=''";
        return jdbcTemplate.queryForList(sql, String.class);
    }

+ 8 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -1295,6 +1295,13 @@ public class PrescriptionInfoService extends BaseService {
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor, " +
                " pr.dispensary_type AS dispensaryType," +
                " e.address, " +
                " e.province_name AS provinceName, " +
                " e.city_name AS cityName," +
                " e.town_name AS townName," +
                " e.street_name AS streetName," +
                " e.hospital_name AS hospitalName," +
                " e.hospital_address AS hospitalAddress," +
                " e.expressage_code AS expressageCode, " +
                " e.expressage_name AS expressageName, " +
                " e.expressage_hospital_address AS expressageHospitalAddress, " +
@ -1708,7 +1715,7 @@ public class PrescriptionInfoService extends BaseService {
                    sql +=" AND d.`name` LIKE '%"+name+"%' ";
                }
                if(page!=null&&size!=null){
                    sql += " LIMIT "+(page-1)+","+size;
                    sql += " LIMIT "+(page-1)*size+","+size;
                }
        String totalSql = "SELECT " +
                " count(1) AS total" +

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -2582,7 +2582,8 @@ public class SignWebService extends BaseService {
    }
    public List<String> findOpenidsByTown(String town) {
        String sql = "select w.openid from wlyy_sign_family w ,dm_hospital d where w.hospital=d.`code` and d.town='" + town + "' and w.openid is not null and w.openid !=''";
        String sql = "select distinct w.openid from wlyy_sign_family w ,dm_hospital d where w.hospital=d.`code` and d.town='" + town + "' and w.openid is not null and w.openid !='' and w.`status`>0 " +
                " and w.expenses_status ='1' ";
        return jdbcTemplate.queryForList(sql, String.class);
    }

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

@ -37,6 +37,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.createTag(tagName);
            return write(200, "创建成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
@ -49,6 +50,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.deleteTag(tageId);
            return write(200, "删除成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
@ -60,6 +62,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.queryTags();
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
@ -73,6 +76,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.queryTagWithOpenid(openid);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
@ -88,6 +92,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.addTagWithOpenid(java.util.Arrays.asList(openis), tageId,null,null);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
@ -103,6 +108,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.deleteTagWithOpenid(java.util.Arrays.asList(openis), tageId);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
@ -117,6 +123,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.addTagWithOpenid(openids, tageId,null,null);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
@ -130,6 +137,7 @@ public class WechatTagController extends BaseController {
            String string = weiXinTagUtil.deleteTagWithOpenid(openids, tageId);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }

+ 40 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinTagUtil.java

@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -74,26 +75,55 @@ public class WeiXinTagUtil {
        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());
            //为openID分组
            List<List<String>> list = getSplitList(openIds,40);
            net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
            if(list!=null&&list.size()>0){
            if (resultJson.containsKey("errcode")) {
                Integer status = resultJson.getInt("errcode");
                if (status != 0) {
                    throw new Exception("创建失败," + result);
                for(List<String> ops : list){
                    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);
                }
            }
            return result;
//            if (resultJson.containsKey("errcode")) {
//                Integer status = resultJson.getInt("errcode");
//                if (status != 0) {
//                    throw new Exception("创建失败," + result);
//                }
//            }
            return "1";
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     *
     * @param list 要拆分的集合
     * @param size 指定的大小
     * @return
     */
    public static List<List<String>> getSplitList(List<String> list , int size)
    {
        List<List<String>> returnList = new ArrayList<List<String>>();
        int listSize = list.size();
        int num = listSize%size==0?listSize/size:(listSize/size+1);
        int start = 0;
        int end = 0;
        for(int i=1;i<=num;i++)
        {
            start = (i-1)*size;
            end = i*size>listSize?listSize:i*size;
            System.out.println(start+":"+end);
            returnList.add(list.subList(start, end));
        }
        return returnList;
    }
    /**
     * 根据openID给用户打标签,
     *