|
@ -12,7 +12,9 @@ import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
|
import com.yihu.jw.rm.patient.PatientRequestMapping;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.wechat.service.WechatInfoService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
@ -20,9 +22,8 @@ import org.apache.axis.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
import java.security.MessageDigest;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author huangwenjie
|
|
@ -41,6 +42,10 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
|
|
|
@Autowired
|
|
|
private BasePatientService basePatientService;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private WechatInfoService wechatInfoService;
|
|
|
|
|
|
@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
|
|
|
@ApiOperation(value = "患者咨询记录查询")
|
|
|
public ListEnvelop records(
|
|
@ -308,16 +313,53 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
|
|
|
return success("请求成功");
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getEvaluationByConsultCode)
|
|
|
@ApiOperation(value = "评价咨询", notes = "评价咨询")
|
|
|
public ListEnvelop getEvaluationByConsultCode(
|
|
|
@ApiParam(name = "consult", value = "咨询CODE")
|
|
|
@RequestParam(value = "consult",required = true) String consult)throws Exception{
|
|
|
// if(StringUtils.isEmpty(scoreContent)){
|
|
|
// scoreContent= "[{\"scoreType\":\"1\",\"score\":100,\"content\":\"\"},{\"scoreType\":\"2\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"3\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"4\",\"score\":0,\"content\":\"测试评语。。。。123123\"}]";
|
|
|
// }
|
|
|
@PostMapping(value = BaseHospitalRequestMapping.PatientIM.getSign)
|
|
|
@ApiOperation(value = "获取微信签名", notes = "获取微信签名")
|
|
|
public Envelop getSign(@ApiParam(name = "pageUrl", value = "授权页面")
|
|
|
@RequestParam(value = "pageUrl", required = true)String pageUrl,
|
|
|
@ApiParam(name = "wxId", value = "微信id")
|
|
|
@RequestParam(value = "wxId", required = true)String wxId) throws Exception {
|
|
|
|
|
|
return success("请求成功",imService.getEvaluationByConsultCode(consult));
|
|
|
String ticket = wechatInfoService.getJsapi_ticketByToken(wxId);
|
|
|
Map<Object, Object> map = new HashMap<Object, Object>();
|
|
|
if (ticket != null) {
|
|
|
String noncestr = UUID.randomUUID().toString();
|
|
|
long timestamp = System.currentTimeMillis() / 1000;
|
|
|
String url = pageUrl;
|
|
|
String str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "×tamp=" + timestamp + "&url=" + url;
|
|
|
// sha1加密
|
|
|
String signature = SHA1(str);
|
|
|
map.put("noncestr", noncestr);
|
|
|
map.put("timestamp", timestamp);
|
|
|
map.put("signature", signature);
|
|
|
return success(PatientRequestMapping.Wechat.api_success,map);
|
|
|
}
|
|
|
return failed(PatientRequestMapping.Wechat.api_error);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @description: SHA、SHA1加密 @parameter: str:待加密字符串 @return: 加密串
|
|
|
**/
|
|
|
public String SHA1(String str) throws Exception {
|
|
|
try {
|
|
|
MessageDigest digest = java.security.MessageDigest.getInstance("SHA-1"); // 如果是SHA加密只需要将"SHA-1"改成"SHA"即可
|
|
|
digest.update(str.getBytes());
|
|
|
byte messageDigest[] = digest.digest();
|
|
|
// Create Hex String
|
|
|
StringBuffer hexStr = new StringBuffer();
|
|
|
// 字节数组转换为 十六进制 数
|
|
|
for (int i = 0; i < messageDigest.length; i++) {
|
|
|
String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
|
|
|
if (shaHex.length() < 2) {
|
|
|
hexStr.append(0);
|
|
|
}
|
|
|
hexStr.append(shaHex);
|
|
|
}
|
|
|
return hexStr.toString();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|