提交 | 用户 | age
|
739bf5
|
1 |
package com.hx.phip.his.service.impl; |
C |
2 |
|
|
3 |
import com.hx.phip.common.HisUrl; |
|
4 |
import com.hx.phip.his.config.SystemConfig; |
|
5 |
import com.hx.phiappt.dao.mapper.SystemParameterMapper; |
|
6 |
import com.hx.phip.his.service.GetTokenService; |
|
7 |
import com.hx.phip.his.service.SyncSalesFinancialDataService; |
|
8 |
import com.hx.phip.uti.ApiUtil; |
|
9 |
import com.hx.phip.uti.HisHttpUtil; |
|
10 |
import com.hx.resultTool.Result; |
|
11 |
import com.hx.util.StringUtils; |
|
12 |
import com.hz.util.http.HttpHzUtil; |
|
13 |
import com.hz.util.http.dto.HttpHzResponse; |
|
14 |
import net.sf.json.JSONObject; |
|
15 |
import org.springframework.stereotype.Service; |
|
16 |
import org.springframework.transaction.annotation.Transactional; |
|
17 |
|
|
18 |
import javax.annotation.Resource; |
|
19 |
import java.util.HashMap; |
|
20 |
import java.util.List; |
|
21 |
import java.util.Map; |
|
22 |
|
|
23 |
/** |
|
24 |
* @Author |
|
25 |
*/ |
|
26 |
@Transactional |
|
27 |
@Service |
|
28 |
public class SyncSalesFinancialDataServiceImpl implements SyncSalesFinancialDataService { |
|
29 |
|
|
30 |
@Resource |
|
31 |
private SystemParameterMapper systemParameterMapper; |
|
32 |
@Resource |
|
33 |
private SystemConfig systemConfig; |
|
34 |
@Resource |
|
35 |
private GetTokenService getTokenService; |
|
36 |
/** |
|
37 |
* 获取HIS token |
|
38 |
* @return |
|
39 |
*/ |
|
40 |
public String getToken(){ |
|
41 |
//获取 领健 token |
|
42 |
String at = getTokenService.getHisToken(systemParameterMapper, systemConfig.getApiAppId(), systemConfig.getApiCode(), |
|
43 |
systemConfig.getApiSecret(), systemConfig.getApiUrl()); |
|
44 |
return at; |
|
45 |
} |
|
46 |
@Override |
|
47 |
public Result payment(JSONObject jsonObject) { |
|
48 |
String at = getToken(); |
|
49 |
Map<String,String> header=new HashMap<>(); |
|
50 |
header.put("x-access-token",at); |
|
51 |
StringBuffer url=new StringBuffer(systemConfig.getApiUrl()+ HisUrl.API_V1_BILLING_PAYMENT); |
|
52 |
if(StringUtils.isEmpty(jsonObject.optString("page"))){ |
|
53 |
url.append("?page="+0); |
|
54 |
}else { |
|
55 |
url.append("?page="+jsonObject.optString("page")); |
|
56 |
} |
|
57 |
if(StringUtils.isEmpty(jsonObject.optString("size"))){ |
|
58 |
url.append("&size="+50); |
|
59 |
}else { |
|
60 |
url.append("&size="+jsonObject.optString("size")); |
|
61 |
} |
|
62 |
|
|
63 |
if (!StringUtils.isEmpty(jsonObject.optString("clinicId"))) url.append("&clinicId="+jsonObject.optString("size")); |
|
64 |
if (!StringUtils.isEmpty(jsonObject.optString("customerId"))) url.append("&customerId="+jsonObject.optString("customerId")); |
|
65 |
if (!StringUtils.isEmpty(jsonObject.optString("start"))) url.append("&start="+jsonObject.optString("start")); |
|
66 |
if (!StringUtils.isEmpty(jsonObject.optString("end"))) url.append("&start="+jsonObject.optString("end")); |
|
67 |
if(!StringUtils.isEmpty(jsonObject.optString("orderIds"))){ |
|
68 |
List<String> list = com.alibaba.fastjson.JSONArray.parseArray(jsonObject.optString("orderIds"), String.class); |
|
69 |
for (String id : list) { |
|
70 |
url.append("&orderIds="+id); |
|
71 |
} |
|
72 |
} |
|
73 |
HttpHzResponse httpHzResponse = HttpHzUtil.HttpURLUtilJson(url.toString(),null,null,header,"GET",null); |
|
74 |
|
|
75 |
return Result.success(httpHzResponse.getData()); |
|
76 |
} |
|
77 |
} |