Browse Source

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 3 years ago
parent
commit
5964c14eab
1 changed files with 25 additions and 11 deletions
  1. 25 11
      controllers/sg/his_api_controller.go

+ 25 - 11
controllers/sg/his_api_controller.go View File

@@ -218,25 +218,39 @@ func (c *HisApiController) ReadCard() {
218 218
 	id_card_type, _ := c.GetInt64("id_card_type")
219 219
 	admin_user_id, _ := c.GetInt64("admin_user_id")
220 220
 	certificates, _ := c.GetInt64("certificates")
221
-
222 221
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
223 222
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
224 223
 
225 224
 	switch id_card_type {
226 225
 	case 1:
227 226
 		if miConfig.MdtrtareaAdmvs == "421300" {
228
-			result, request_log := service.Gdyb1101C("", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates)
229
-			fmt.Println(request_log)
230
-			var dat map[string]interface{}
231
-			if err := json.Unmarshal([]byte(result), &dat); err == nil {
232
-				fmt.Println(dat)
233
-			} else {
234
-				fmt.Println(err)
227
+			var res ResultTwo
228
+			api := "http://127.0.0.1:9533/" + "hbyb/1101?cert_no=" + "" +
229
+				"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
230
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
231
+			resp, requestErr := http.Get(api)
232
+			if requestErr != nil {
233
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
234
+				return
235 235
 			}
236 236
 
237
-			userJSONBytes, _ := json.Marshal(dat)
238
-			var res ResultTwo
239
-			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
237
+			body, ioErr := ioutil.ReadAll(resp.Body)
238
+			if ioErr != nil {
239
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
240
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
241
+				return
242
+			}
243
+			var respJSON map[string]interface{}
244
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
245
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
246
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
247
+				return
248
+			}
249
+
250
+			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
251
+			result, _ := json.Marshal(respJSON)
252
+
253
+			if err := json.Unmarshal([]byte(result), &res); err != nil {
240 254
 				utils.ErrorLog("解析失败:%v", err)
241 255
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
242 256
 				return