Explorar el Código

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

test_user hace 4 semanas
padre
commit
91480273da
Se han modificado 1 ficheros con 208 adiciones y 2 borrados
  1. 208 2
      controllers/sg/his_api_controller.go

+ 208 - 2
controllers/sg/his_api_controller.go Ver fichero

@@ -34,8 +34,6 @@ import (
34 34
 	"syscall"
35 35
 	"time"
36 36
 	"unsafe"
37
-	"github.com/go-ole/go-ole"
38
-
39 37
 )
40 38
 
41 39
 type HisApiController struct {
@@ -2939,6 +2937,214 @@ func (c *HisApiController) DeleteXSandBGTwo() {
2939 2937
 
2940 2938
 }
2941 2939
 
2940
+// 删除
2941
+func (c *HisApiController) DeleteXSandBGThree() {
2942
+	id, _ := c.GetInt64("id")
2943
+	admin_user_id, _ := c.GetInt64("admin_user_id")
2944
+
2945
+	advicelist, _ := service.FindHisAdviceDocAdvice(id)
2946
+	var flows []*models.DrugFlow
2947
+	for _, item := range advicelist {
2948
+		flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
2949
+		flows = append(flows, flow...)
2950
+	}
2951
+
2952
+	//flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
2953
+	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2954
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2955
+
2956
+	var err []string
2957
+	for _, item := range flows {
2958
+		if item.IsSale == 1 {
2959
+			var res FJ3507Result
2960
+
2961
+			var struct3507 models.Struct3507
2962
+			struct3507.FixmedinsBchno = item.Bchno
2963
+			struct3507.InvDataType = "4"
2964
+			struct3507.Opter = roles.UserName
2965
+			struct3507.OrgName = miConfig.OrgName
2966
+			struct3507.AccessKey = miConfig.AccessKey
2967
+			struct3507.RequestUrl = miConfig.Url
2968
+			struct3507.FixmedinsCode = miConfig.Code
2969
+			struct3507.SecretKey = miConfig.SecretKey
2970
+			struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
2971
+			struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
2972
+			struct3507.Url = miConfig.Url
2973
+			struct3507.AppId = miConfig.Cainfo
2974
+			struct3507.AppSecret = miConfig.AppSecret
2975
+			struct3507.Enckey = miConfig.EncKey
2976
+			struct3507.SignKey = miConfig.SignKey
2977
+			struct3507.SecretKey = miConfig.SecretKey
2978
+
2979
+			if miConfig.MdtrtareaAdmvs == "350500" {
2980
+				result, result1, _ := service.FJyb3507(struct3507)
2981
+				saveLog(result, result1, "3507", "3507")
2982
+				var respJSON2 map[string]interface{}
2983
+				if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
2984
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2985
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2986
+					return
2987
+				}
2988
+				userJSONBytes2, _ := json.Marshal(respJSON2)
2989
+				if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
2990
+					utils.ErrorLog("解析失败:%v", err)
2991
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2992
+					return
2993
+				}
2994
+			} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
2995
+				data := make(map[string]interface{})
2996
+				data["struct_3507s"] = struct3507
2997
+				client := &http.Client{}
2998
+				bytesData, _ := json.Marshal(data)
2999
+				var req *http.Request
3000
+				if miConfig.MdtrtareaAdmvs == "320921" {
3001
+					req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
3002
+				} else {
3003
+					req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
3004
+				}
3005
+
3006
+				resp, _ := client.Do(req)
3007
+				defer resp.Body.Close()
3008
+				body, ioErr := ioutil.ReadAll(resp.Body)
3009
+				if ioErr != nil {
3010
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3011
+				}
3012
+				var respJSON map[string]interface{}
3013
+				if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
3014
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3015
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3016
+					return
3017
+				}
3018
+				var resSix10265 ResultSix10265 //1101结果
3019
+				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
3020
+				result, _ := json.Marshal(respJSON)
3021
+				if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
3022
+					utils.ErrorLog("解析失败:%v", err)
3023
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3024
+					return
3025
+				}
3026
+				res.InfRefmsgid = resSix10265.InfRefmsgid
3027
+				//res.Output = resSix10265.Output
3028
+				res.ErrMsg = resSix10265.ErrMsg
3029
+				res.Cainfo = resSix10265.Cainfo
3030
+				res.WarnMsg = resSix10265.WarnMsg
3031
+				infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
3032
+				res.Infcode = infocode
3033
+			} else if miConfig.MdtrtareaAdmvs == "440100" {
3034
+				result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
3035
+				saveLog(result2, result1, "3507", "3507")
3036
+				var respJSON2 map[string]interface{}
3037
+				if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
3038
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3039
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3040
+					return
3041
+				}
3042
+				userJSONBytes2, _ := json.Marshal(respJSON2)
3043
+				if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
3044
+					utils.ErrorLog("解析失败:%v", err)
3045
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3046
+					return
3047
+				}
3048
+			} else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
3049
+				result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
3050
+				saveLog(result2, result1, "3507", "3507")
3051
+				var respJSON2 map[string]interface{}
3052
+				if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
3053
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3054
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3055
+					return
3056
+				}
3057
+				userJSONBytes2, _ := json.Marshal(respJSON2)
3058
+				if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
3059
+					utils.ErrorLog("解析失败:%v", err)
3060
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3061
+					return
3062
+				}
3063
+			} else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
3064
+				result1, result2 := service.Jxyb3507(struct3507)
3065
+				saveLog(result2, result1, "3507", "3507")
3066
+				var respJSON2 map[string]interface{}
3067
+				if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
3068
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3069
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3070
+					return
3071
+				}
3072
+				userJSONBytes2, _ := json.Marshal(respJSON2)
3073
+				if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
3074
+					utils.ErrorLog("解析失败:%v", err)
3075
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3076
+					return
3077
+				}
3078
+			} else if miConfig.MdtrtareaAdmvs == "340699" {
3079
+				result1, result2 := service.AHyb3507(struct3507)
3080
+				saveLog(result2, result1, "3507", "3507")
3081
+				var respJSON2 map[string]interface{}
3082
+				if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
3083
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3084
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3085
+					return
3086
+				}
3087
+				userJSONBytes2, _ := json.Marshal(respJSON2)
3088
+				if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
3089
+					utils.ErrorLog("解析失败:%v", err)
3090
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3091
+					return
3092
+				}
3093
+			} else if miConfig.MdtrtareaAdmvs == "150499" {
3094
+
3095
+				data := make(map[string]interface{})
3096
+				data["struct_3507s"] = struct3507
3097
+				client := &http.Client{}
3098
+				bytesData, _ := json.Marshal(data)
3099
+				var req *http.Request
3100
+
3101
+				req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
3102
+
3103
+				resp, _ := client.Do(req)
3104
+				defer resp.Body.Close()
3105
+				body, ioErr := ioutil.ReadAll(resp.Body)
3106
+				if ioErr != nil {
3107
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3108
+				}
3109
+				var respJSON map[string]interface{}
3110
+				if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
3111
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3112
+				}
3113
+
3114
+				var resSix10265 ResultSix10265 //1101结果
3115
+				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
3116
+				result, _ := json.Marshal(respJSON)
3117
+				if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
3118
+					utils.ErrorLog("解析失败:%v", err)
3119
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3120
+					return
3121
+				}
3122
+				res.InfRefmsgid = resSix10265.InfRefmsgid
3123
+				res.ErrMsg = resSix10265.ErrMsg
3124
+				res.Cainfo = resSix10265.Cainfo
3125
+				res.WarnMsg = resSix10265.WarnMsg
3126
+				infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
3127
+				res.Infcode = infocode
3128
+			}
3129
+
3130
+			if res.Infcode == 0 {
3131
+				service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
3132
+				item.IsSale = 0
3133
+				item.SaleDate = ""
3134
+				item.Bchno = ""
3135
+				service.SaveDF(item)
3136
+			} else {
3137
+				err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
3138
+			}
3139
+		}
3140
+	}
3141
+
3142
+	c.ServeSuccessJSON(map[string]interface{}{
3143
+		"msg": "删除销售数据成功",
3144
+	})
3145
+
3146
+}
3147
+
2942 3148
 // 获取当天起止时间戳
2943 3149
 func GetNowTime() (int64, int64) {
2944 3150
 	t := time.Now()