|
@ -1,29 +1,24 @@
|
|
|
package com.yihu.wlyy.service.app.health;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticle;
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticleOpHistory;
|
|
|
import com.yihu.wlyy.entity.patient.PatientHealthRecordMedication;
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
|
|
|
import com.yihu.wlyy.repository.education.HealthEduArticleDao;
|
|
|
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import com.yihu.wlyy.util.XMLUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springside.modules.persistence.DynamicSpecifications;
|
|
|
import org.springside.modules.persistence.SearchFilter;
|
|
|
import org.springside.modules.persistence.SearchFilter.Operator;
|
|
|
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticle;
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
|
|
|
import com.yihu.wlyy.repository.education.HealthEduArticleDao;
|
|
|
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 健康教育业务控制类
|
|
@ -45,6 +40,60 @@ public class HealthEduArticleService extends BaseService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
/**
|
|
|
* 保存福州健康教育文章
|
|
|
* @param result xml格式
|
|
|
* @return
|
|
|
* @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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 由请求参数获取福州健康教育文章
|
|
|
* @param params
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String getHealthEduArticles(Map<String, String> params) throws Exception {
|
|
|
|
|
|
SystemConf systemConf = SystemConf.getInstance();
|
|
|
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
|
|
XMLUtil xmlUtil = new XMLUtil();
|
|
|
|
|
|
// 获取远程地址url 、App Key 和 App secret
|
|
|
String prixUrl = SystemConf.getInstance().getYihuOpenPlatformUrl();
|
|
|
// String prixUrl ="http://apitest.yihu.com.cn/OpenPlatform/cgiBin/1.0/";
|
|
|
String appId =SystemConf.getInstance().getYihuOpenPlatformAppId();
|
|
|
// String appId = "9000276";
|
|
|
String secret = SystemConf.getInstance().getYihuOpenPlatformSecret();
|
|
|
// String secret = "OKC8BS1KGXTDE9GPP1EO4VYLUXF8DJ7QUP72H613ZXA";
|
|
|
// 请求参数(i健康接口说明文档)正式接口 由prixUrl获取apixUrl
|
|
|
String apiUrl = prixUrl+"jkjy/JkjyImpl/queryHealtheducationForIHealth";
|
|
|
|
|
|
|
|
|
// 获取加密后参数集合
|
|
|
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)
|
|
|
// 获取返回数据( HTTP post请求,参数需要utf-8编码)
|
|
|
// String results = httpClientUtil.httpPost(apiUrl,strXML);
|
|
|
// String results = HttpUtil.sendPost(apiUrl, strXML);
|
|
|
String results = httpClientUtil.httpPost(apiUrl,param);
|
|
|
|
|
|
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询文章信息
|
|
|
*
|