Bläddra i källkod

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

8 år sedan
förälder
incheckning
899571f923

+ 60 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java

@ -8,7 +8,7 @@ import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.XMLUtil;
import com.yihu.wlyy.util.Xml2ListMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
@ -47,13 +47,65 @@ public class HealthEduArticleService extends BaseService {
     * @throws Exception
     * @throws Exception
     */
     */
    public int saveHealthEduArticles(String result) throws Exception {
    public int saveHealthEduArticles(String result) throws Exception {
        XMLUtil xmlUtil = new XMLUtil();
        Map mapList = xmlUtil.xmltoMap(result);
        String code = mapList.get("").toString();
        String sql = "INSERT INTO wlyy_health_edu_article  " +
                "VALUES(NULL,?,?,?,?,NULL,?,?)";
        int rows = jdbcTemplate.update(sql,code);
        return  rows;
        List<Map<String,String>> listmap= Xml2ListMap.xml2List(result);
        String code = null;
        String title = null;
        String imgUrl = null;
        String content = null;
        String keyWord = null;
        String type = null;
        int rows = 0;
        for(Map<String,String> temp : listmap){
            code = temp.get("xml.Result.MessageId");
            title = temp.get("xml.Result.MessageTitle");
            imgUrl = temp.get("xml.Result.ImageUrlSmall");
            content = temp.get("xml.Result.MessageContent");
            keyWord = temp.get("xml.Result.MessageType");
            switch (keyWord){
                case "1":
                    keyWord = "高血压";
                    type = "2";
                    break;
                case "2":
                    keyWord = "糖尿病";
                    type = "1";
                    break;
                case "3":
                    keyWord = "儿保";
                    type = "3";
                    break;
                case "4":
                    keyWord = "妇保";
                    type = "3";
                    break;
                case "5":
                    keyWord = "孕产";
                    type = "3";
                    break;
                case "6":
                    keyWord = "医药";
                    type = "4";
                    break;
                case "7":
                    keyWord = "急救";
                    type = "4";
                    break;
                case "8":
                    keyWord = "生活";
                    type = "0";
                    break;
                case "9":
                    keyWord = "更多";
                    type = "0";
                    break;
            }
            String sql = "INSERT INTO wlyy_health_edu_article  " +
                    "VALUES(NULL,?,?,?,?,NULL,?,?)";
            rows = jdbcTemplate.update(sql,code,title,imgUrl,content,keyWord,type);
            rows+=rows;
        }
        return rows;
    }
    }
    /**
    /**
@ -63,10 +115,7 @@ public class HealthEduArticleService extends BaseService {
     * @throws Exception
     * @throws Exception
     */
     */
    public String getHealthEduArticles(Map<String, String> params) throws Exception {
    public String getHealthEduArticles(Map<String, String> params) throws Exception {
        SystemConf systemConf = SystemConf.getInstance();
        HttpClientUtil httpClientUtil = new HttpClientUtil();
        HttpClientUtil httpClientUtil = new HttpClientUtil();
        XMLUtil xmlUtil = new XMLUtil();
//      获取远程地址url 、App Key 和 App secret  
//      获取远程地址url 、App Key 和 App secret  
        String prixUrl = SystemConf.getInstance().getYihuOpenPlatformUrl();
        String prixUrl = SystemConf.getInstance().getYihuOpenPlatformUrl();
@ -81,13 +130,8 @@ public class HealthEduArticleService extends BaseService {
//      获取加密后参数集合
//      获取加密后参数集合
        Map<String,String> param = httpClientUtil.getSecretParams(params,appId,secret);
        Map<String,String> param = httpClientUtil.getSecretParams(params,appId,secret);
//      以xml格式入参param
        String strXml = xmlUtil.map2xml(param);
        String strXML = strXml.replace("QUERY_FORM","xml");
//      拼接请求URL (加密签名+apiUrl)
//      拼接请求URL (加密签名+apiUrl)
//      获取返回数据( HTTP post请求,参数需要utf-8编码)
//      获取返回数据( HTTP post请求,参数需要utf-8编码)
//        String  results = httpClientUtil.httpPost(apiUrl,strXML);
//        String  results = HttpUtil.sendPost(apiUrl, strXML);
        String  results = httpClientUtil.httpPost(apiUrl,param);
        String  results = httpClientUtil.httpPost(apiUrl,param);

+ 15 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.CommonUtil;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
@ -56,10 +57,6 @@ public class DoctorGuidanceTempService extends BaseService {
        String [] imagesArray = null;
        String [] imagesArray = null;
        if(imagesUrl != null){
        if(imagesUrl != null){
            imagesArray = imagesUrl.split(",");
            imagesArray = imagesUrl.split(",");
            String head = "htttp://";
            for (int i=0;i<imagesArray.length;i++) {
                imagesArray[i]=head +imagesArray[i];
            }
        }
        }
        String createTime = (String)temp.get("create_time").toString();
        String createTime = (String)temp.get("create_time").toString();
@ -82,6 +79,7 @@ public class DoctorGuidanceTempService extends BaseService {
     */
     */
    public DoctorGuidanceTemp add(String doctor, String content,String modelName,String imagesUrl) {
    public DoctorGuidanceTemp add(String doctor, String content,String modelName,String imagesUrl) {
        DoctorGuidanceTemp guidanceTemp = new DoctorGuidanceTemp();
        DoctorGuidanceTemp guidanceTemp = new DoctorGuidanceTemp();
        String imgsUrl = null;
        guidanceTemp.setCode(getCode());
        guidanceTemp.setCode(getCode());
        guidanceTemp.setOwner(doctor);
        guidanceTemp.setOwner(doctor);
@ -90,7 +88,13 @@ public class DoctorGuidanceTempService extends BaseService {
        guidanceTemp.setCreateTime(new Date());
        guidanceTemp.setCreateTime(new Date());
        guidanceTemp.setModelName(modelName);
        guidanceTemp.setModelName(modelName);
        guidanceTemp.setImagesUrl(imagesUrl);
        try {
            imgsUrl = CommonUtil.copyTempImage(imagesUrl);
        } catch (Exception e) {
            e.printStackTrace();
        }
        guidanceTemp.setImagesUrl(imgsUrl);
        return guidanceTempDao.save(guidanceTemp);
        return guidanceTempDao.save(guidanceTemp);
    }
    }
@ -155,8 +159,8 @@ public class DoctorGuidanceTempService extends BaseService {
            temps = guidanceTempDao.findByOwner("system");
            temps = guidanceTempDao.findByOwner("system");
            for(DoctorGuidanceTemp temp : temps){
            for(DoctorGuidanceTemp temp : temps){
                Map<String,Object> tem = new HashMap<>();
                Map<String,Object> tem = new HashMap<>();
                tem.put("code:",temp.getCode());
                tem.put("owner:",temp.getOwner());
                tem.put("code",temp.getCode());
                tem.put("owner",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                tem.put("modelName",temp.getModelName());
@ -166,8 +170,8 @@ public class DoctorGuidanceTempService extends BaseService {
            temps = guidanceTempDao.findByOwner(doctor);
            temps = guidanceTempDao.findByOwner(doctor);
            for(DoctorGuidanceTemp temp : temps){
            for(DoctorGuidanceTemp temp : temps){
                Map<String,Object> tem = new HashMap<>();
                Map<String,Object> tem = new HashMap<>();
                tem.put("code:",temp.getCode());
                tem.put("owner:",temp.getOwner());
                tem.put("code",temp.getCode());
                tem.put("owner",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                tem.put("modelName",temp.getModelName());
@ -177,8 +181,8 @@ public class DoctorGuidanceTempService extends BaseService {
            temps = guidanceTempDao.findByOwnerAndSystem(doctor);
            temps = guidanceTempDao.findByOwnerAndSystem(doctor);
            for(DoctorGuidanceTemp temp : temps){
            for(DoctorGuidanceTemp temp : temps){
                Map<String,Object> tem = new HashMap<>();
                Map<String,Object> tem = new HashMap<>();
                tem.put("code:",temp.getCode());
                tem.put("owner:",temp.getOwner());
                tem.put("code",temp.getCode());
                tem.put("owner",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                tem.put("modelName",temp.getModelName());

+ 2 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -1,16 +1,12 @@
package com.yihu.wlyy.util;
package com.yihu.wlyy.util;
import java.io.*;
import java.util.Date;
import java.util.Random;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.config.FastDFSConfig;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import it.sauronsoftware.jave.*;
import it.sauronsoftware.jave.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
public class CommonUtil {
public class CommonUtil {
    /**
    /**

+ 1 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -365,9 +365,7 @@ public class SystemConf {
	 * 健康之路开放平台渠道号
	 * 健康之路开放平台渠道号
	 */
	 */
	public String getYihuOpenPlatformAppId() {
	public String getYihuOpenPlatformAppId() {
		String str = getSystemProperties().getProperty("yihu_OpenPlatform_appId");
		String str1 = getSystemProperties().getProperty("fastdfs_file_url");
		return str;
		return getSystemProperties().getProperty("yihu_OpenPlatform_appId");
	}
	}
	/**
	/**

+ 43 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/XMLUtil.java

@ -20,10 +20,14 @@ import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Field;
import java.util.*;
import java.util.*;
public class XMLUtil {
public class XMLUtil {
    private static Logger logger = LoggerFactory.getLogger(XMLUtil.class);
    private static Logger logger = LoggerFactory.getLogger(XMLUtil.class);
    /**
    /**
     * 把xml字符串转换成 Document对象。
     * 把xml字符串转换成 Document对象。
     *
     *
@ -521,7 +525,46 @@ public class XMLUtil {
        }
        }
    }
    }
//============================================
    public static Object xml2map(Element element) {
        System.out.println(element);
        Map<String, Object> map = new HashMap<String, Object>();
        List<Element> elements = element.elements();
        if (elements.size() == 0) {
            map.put(element.getName(), element.getText());
            if (!element.isRootElement()) {
                return element.getText();
            }
        } else if (elements.size() == 1) {
            map.put(elements.get(0).getName(), xml2map(elements.get(0)));
        } else if (elements.size() > 1) {
            // 多个子节点的话就得考虑list的情况了,比如多个子节点有节点名称相同的
            // 构造一个map用来去重
            Map<String, Element> tempMap = new HashMap<String, Element>();
            for (Element ele : elements) {
                tempMap.put(ele.getName(), ele);
            }
            Set<String> keySet = tempMap.keySet();
            for (String string : keySet) {
                Namespace namespace = tempMap.get(string).getNamespace();
                List<Element> elements2 = element.elements(new QName(string, namespace));
                // 如果同名的数目大于1则表示要构建list
                if (elements2.size() > 1) {
                    List<Object> list = new ArrayList<Object>();
                    for (Element ele : elements2) {
                        list.add(xml2map(ele));
                    }
                    map.put(string, list);
                } else {
                    // 同名的数量不大于1则直接递归去
                    map.put(string, xml2map(elements2.get(0)));
                }
            }
        }
        return map;
    }
//    ============================================
    public static Map xmltoMap(String xml) {
    public static Map xmltoMap(String xml) {

+ 135 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/Xml2ListMap.java

@ -0,0 +1,135 @@
package com.yihu.wlyy.util;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import java.io.IOException;
import java.io.StringReader;
import java.util.*;
public class Xml2ListMap {
    /**
     * 取得xml文件的根节点名称,即消息名称。
     * @param xmlStr xml内容
     * @return String 返回名称
     */
    public static String getRootName(String xmlStr) throws Exception {
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(new StringReader(xmlStr));
        Element root = doc.getRootElement();
        return root.getName();
    }
    /**
     * 递归函数,找出最下层的节点并加入到map中,由xml2Map方法调用。
     * @param e xml节点,包括根节点
     * @param map 目标map
     * @param lastname 从根节点到上一级节点名称连接的字串
     */
    public static void convert(Element e, Map<String , String> map, String lastname) {
        if (e.getAttributes().size() > 0) {
            Iterator it_attr = e.getAttributes().iterator();
            while (it_attr.hasNext()) {
                Attribute attribute = (Attribute)it_attr.next();
                String attrname = attribute.getName();
                String attrvalue = e.getAttributeValue(attrname);
                map.put(lastname + "." + attrname, attrvalue);
            }
        }
        List children = e.getChildren();
        Iterator it = children.iterator();
        while (it.hasNext()) {
            Element child = (Element) it.next();
            String name = lastname + "." + child.getName();
            // 如果有子节点,则递归调用
            if (child.getChildren().size() > 0) {
                convert(child, map, name);
            } else {
                // 如果没有子节点,则把值加入map
                map.put(name, child.getText());
                // 如果该节点有属性,则把所有的属性值也加入map
                if (child.getAttributes().size() > 0) {
                    Iterator attr = child.getAttributes().iterator();
                    while (attr.hasNext()) {
                        Attribute attribute = (Attribute)attr.next();
                        String attrname = attribute.getName();
                        String attrvalue = child.getAttributeValue(attrname);
                        map.put(name + "." + attrname, attrvalue);
                    }
                }
            }
        }
    }
    /**
     * 把xml文件转换为list形式,其中每个元素是一个map,map中的key为有值的节点名称,并以其所有的祖先节点为前缀,用
     * "."相连接。如:SubscribeServiceReq.Send_Address.Address_Info.DeviceType
     * @param xmlStr xml内容
     * @return Map 转换为map返回
     */
    public static List<Map<String,String>> xml2List(String xmlStr) throws JDOMException, IOException {
        List<Map<String,String>> rtnList = new ArrayList<Map<String,String>>();
        Map<String , String> rtnMap = new HashMap<String , String>();
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(new StringReader(xmlStr));
        // 得到根节点
        Element root = doc.getRootElement();
        String rootName = root.getName();
        rtnMap.put("root.name", rootName);
        // 调用递归函数,得到所有最底层元素的名称和值,加入map中
        convert2List(root, rtnMap, rootName, rtnList);
        if(rtnList.size()==0)
            rtnList.add(rtnMap);
        return rtnList;
    }
    /**
     * 递归函数,找出最下层的节点并加入到map中,如果有相同的节点,则加入list中,
     * 由xml2List方法调用。
     * @param e xml节点,包括根节点
     * @param map 目标map
     * @param lastname 从根节点到上一级节点名称连接的字串
     * @param list 相同节点生成map放入list中
     */
    public static void convert2List(Element e, Map<String , String> map, String lastname, List<Map<String,String>> list) {
        if (e.getAttributes().size() > 0) {
            Iterator it_attr = e.getAttributes().iterator();
            while (it_attr.hasNext()) {
                Attribute attribute = (Attribute)it_attr.next();
                String attrname = attribute.getName();
                String attrvalue = e.getAttributeValue(attrname);
                map.put(lastname + "." + attrname, attrvalue);
            }
        }
        List children = e.getChildren();
        Iterator it = children.iterator();
        while (it.hasNext()) {
            Element child = (Element)it.next();
            String name = lastname + "." + child.getName();
            // 如果有子节点,则递归调用
            if (child.getChildren().size() > 0) {
                convert(child, map, name);
            } else {
                // 如果没有子节点,则把值加入map
                map.put(name, child.getText());
                // 如果该节点有属性,则把所有的属性值也加入map
                if (child.getAttributes().size() > 0) {
                    Iterator attr = child.getAttributes().iterator();
                    while (attr.hasNext()) {
                        Attribute attribute = (Attribute)attr.next();
                        String attrname = attribute.getName();
                        String attrvalue = child.getAttributeValue(attrname);
                        map.put(name + "." + attrname, attrvalue);
                    }
                }
            }
            //如果有相同节点,则加入list中,不考虑子节点中又有相同节点的情况
            if(e.getChildren(child.getName()).size()>1){
                Map<String,String> aMap = new HashMap<String,String>();
                aMap.putAll(map);
                list.add(aMap);
                map= new HashMap<String,String>();
                map.put("root.name", aMap.get("root.name"));
            }
        }
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/health/HealthEduArticlesController.java

@ -51,7 +51,7 @@ public class HealthEduArticlesController extends BaseController{
//          保存福州健康教育文章
//          保存福州健康教育文章
            int rows = healthEduArticleService.saveHealthEduArticles(result);
            int rows = healthEduArticleService.saveHealthEduArticles(result);
            if(rows>0){
            if(rows>0){
                return write(200, "数据导入成功!","data",result);
                return write(200, "数据导入成功");
            }
            }
            return write(-1, "数据导入失败!");
            return write(-1, "数据导入失败!");
        }catch (Exception e){
        }catch (Exception e){

+ 0 - 21
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -142,11 +142,6 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
				}
				}
				guidance.setImages(images);
				guidance.setImages(images);
				if (StringUtils.isNotEmpty(voice)) {
					images = CommonUtil.copyTempVoice(voice);
				}
				guidance.setVoice(voice);
				// 保存
				// 保存
				if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
				if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
					Patient p = patientService.findByCode(patient);
					Patient p = patientService.findByCode(patient);
@ -162,30 +157,14 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
				return error(-1, "保存失败!");
				return error(-1, "保存失败!");
			}
			}
		}else{
		}else{
//			使用模板发送指导
			try{
			try{
/*//			1.查询单个模板详情
				JSONObject modelDetail = doctorGuidanceTempService.listDetail(modelCode);
				String name = modelDetail.get("modelName").toString();
				String contain = modelDetail.get("content").toString();
				String image = modelDetail.get("imagesUrl").toString();
				content+=contain;
				images+=image;*/
				PatientHealthGuidance guidance = new PatientHealthGuidance();
				PatientHealthGuidance guidance = new PatientHealthGuidance();
				guidance.setContent(content);
				guidance.setContent(content);
				guidance.setDoctor(getUID());
				guidance.setDoctor(getUID());
				guidance.setPatient(patient);
				guidance.setPatient(patient);
				Doctor doctor = doctorService.findDoctorByCode(getUID());
				Doctor doctor = doctorService.findDoctorByCode(getUID());
				if (StringUtils.isNotEmpty(images)) {
					images = CommonUtil.copyTempImage(images);
				}
				guidance.setImages(images);
				guidance.setImages(images);
				if (StringUtils.isNotEmpty(voice)) {
					images = CommonUtil.copyTempVoice(voice);
				}
				guidance.setVoice(voice);
				// 保存
				// 保存
				if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
				if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
					Patient p = patientService.findByCode(patient);
					Patient p = patientService.findByCode(patient);

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempController.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.web.doctor.template;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;