Browse Source

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

csx 3 years ago
parent
commit
22d9f58bbb
1 changed files with 68 additions and 3 deletions
  1. 68 3
      controllers/js/jsyb_controller.go

+ 68 - 3
controllers/js/jsyb_controller.go View File

@@ -11,10 +11,12 @@ import (
11 11
 	"github.com/astaxie/beego"
12 12
 	"github.com/axgle/mahonia"
13 13
 	"io/ioutil"
14
+	"os"
14 15
 	"regexp"
15 16
 	"strconv"
16 17
 	"strings"
17 18
 	"syscall"
19
+	"time"
18 20
 	"unsafe"
19 21
 )
20 22
 
@@ -52,8 +54,10 @@ func (c *JSybController) Get5301() {
52 54
 	ak := c.GetString("ak")
53 55
 
54 56
 	result, inputLog := service.Jsyb5301(psn_no, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak)
55
-	fmt.Println(result)
56
-	fmt.Println(inputLog)
57
+	//saveJsLog()
58
+	saveJsLog("", inputLog, "5301", "查询备案", org_name)
59
+	saveJsLog(result, inputLog, "5301", "查询备案", org_name)
60
+
57 61
 	var dat map[string]interface{}
58 62
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
59 63
 
@@ -91,6 +95,8 @@ func (c *JSybController) PostOne() {
91 95
 	result, inputLog := service.Jsyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates, url, ak)
92 96
 	fmt.Println(result)
93 97
 	fmt.Println(inputLog)
98
+	saveJsLog("", inputLog, "1101", "查询个人信息", org_name)
99
+	saveJsLog(result, "", "1101", "查询个人信息", org_name)
94 100
 	var dat map[string]interface{}
95 101
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
96 102
 
@@ -138,6 +144,8 @@ func (c *JSybController) PostTwo() {
138 144
 	result, request_log := service.Jsyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, url, ak, verify_number)
139 145
 	fmt.Println(result)
140 146
 	fmt.Println(request_log)
147
+	saveJsLog("", request_log, "2201", "挂号", org_name)
148
+	saveJsLog(result, "", "2201", "挂号", org_name)
141 149
 	var dat map[string]interface{}
142 150
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
143 151
 
@@ -170,6 +178,8 @@ func (c *JSybController) PostThree() {
170 178
 	url := c.GetString("url")
171 179
 	ak := c.GetString("ak")
172 180
 	result, request_log := service.Jsyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak)
181
+	saveJsLog("", request_log, "2202", "退号", org_name)
182
+	saveJsLog(result, "", "2202", "退号", org_name)
173 183
 	var dat map[string]interface{}
174 184
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
175 185
 	} else {
@@ -224,6 +234,8 @@ func (c *JSybController) PostFour() {
224 234
 	ak := respJSON["ak"].(string)
225 235
 	begin_time := respJSON["begin_time"].(string)
226 236
 	result, request_log, timeStamp := service.Jsyb2203(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config, url, ak, begin_time)
237
+	saveJsLog("", request_log, "2203", "上传就诊信息", org_name)
238
+	saveJsLog(result, "", "2203", "上传就诊信息", org_name)
227 239
 	var dat2 map[string]interface{}
228 240
 	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
229 241
 
@@ -291,6 +303,8 @@ func (c *JSybController) PostFive() {
291 303
 	result, request_log := service.Jsyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
292 304
 		respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string), respJSON["dept_code"].(string), respJSON["doctor_id"].(string), respJSON["insuplc_admdvs"].(string), respJSON["mdtrtarea_admvs"].(string), respJSON["secret_key"].(string), respJSON["balance_accounts_type"].(string), respJSON["diag_code"].(string), respJSON["url"].(string), respJSON["ak"].(string), respJSON["new_doctor_name"].(string), "")
293 305
 
306
+	saveJsLog("", request_log, "2204", "上传明细", respJSON["org_name"].(string))
307
+	saveJsLog(result, "", "2204", "上传明细", respJSON["org_name"].(string))
294 308
 	var dat map[string]interface{}
295 309
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
296 310
 		fmt.Println(dat)
@@ -327,6 +341,8 @@ func (c *JSybController) PostSix() {
327 341
 
328 342
 	result, request_log := service.Jsyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak)
329 343
 	fmt.Println(request_log)
344
+	saveJsLog("", request_log, "2205", "撤销明细", org_name)
345
+	saveJsLog(result, "", "2205", "撤销明细", org_name)
330 346
 	var dat map[string]interface{}
331 347
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
332 348
 		fmt.Println(dat)
@@ -367,7 +383,8 @@ func (c *JSybController) PostSeven() {
367 383
 	ak := c.GetString("ak")
368 384
 
369 385
 	result, request_log := service.Jsyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, 0, 0, 0, 0, certificates, url, ak, verify_number)
370
-
386
+	saveJsLog("", request_log, "2206", "预结算", org_name)
387
+	saveJsLog(result, "", "2206", "预结算", org_name)
371 388
 	var dat map[string]interface{}
372 389
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
373 390
 		fmt.Println(dat)
@@ -415,6 +432,8 @@ func (c *JSybController) PostEight() {
415 432
 	verify_number := c.GetString("verify_number")
416 433
 
417 434
 	result, request_log := service.Jsyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt, certificates, acct_used_flag, url, ak, verify_number)
435
+	saveJsLog("", request_log, "2207", "结算", org_name)
436
+	saveJsLog(result, "", "2207", "结算", org_name)
418 437
 	var dat map[string]interface{}
419 438
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
420 439
 		fmt.Println(dat)
@@ -447,6 +466,8 @@ func (c *JSybController) PostNine() {
447 466
 	url := c.GetString("url")
448 467
 	ak := c.GetString("ak")
449 468
 	result, request_log := service.Jsyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak)
469
+	saveJsLog("", request_log, "2208", "退费", org_name)
470
+	saveJsLog(result, "", "2208", "退费", org_name)
450 471
 	fmt.Println(request_log)
451 472
 	var dat map[string]interface{}
452 473
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -497,6 +518,8 @@ func (c *JSybController) PostTen() {
497 518
 	}
498 519
 
499 520
 	result, request_log := service.Jsyb5203(baseParams, businessParams)
521
+	saveJsLog("", request_log, "5203", "结算单", org_name)
522
+	saveJsLog(result, "", "5203", "结算单", org_name)
500 523
 	var dat map[string]interface{}
501 524
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
502 525
 		fmt.Println(dat)
@@ -688,3 +711,45 @@ func Remove0000(s string) string {
688 711
 	}
689 712
 	return string(str)
690 713
 }
714
+
715
+func saveJsLog(result string, request string, infno string, desc string, org_name string) {
716
+
717
+	//org_id, _ := beego.AppConfig.Int64("org_id")
718
+	//miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
719
+	dir := org_name + "日志"
720
+	utils.Mkdir(dir)
721
+	month := time.Unix(1557042972, 0).Format("1")
722
+	year := time.Now().Format("2006")
723
+	month = time.Now().Format("01")
724
+	day := time.Now().Format("02")
725
+	hour := time.Now().Format("15")
726
+	min := time.Now().Format("04")
727
+	sec := time.Now().Format("05")
728
+
729
+	result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
730
+
731
+	file := org_name + "_" + year + month + day + "_log"
732
+	file_name := file + ".txt"
733
+	file_path := org_name + "日志" + "/" + file_name
734
+	exist, _ := utils.PathExists(file_path)
735
+	if exist { //存在
736
+		fmt.Println("存在")
737
+		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
738
+		if err != nil {
739
+			fmt.Println("read fail")
740
+		}
741
+		content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
742
+		n, _ := f.Seek(0, 2)
743
+		_, err = f.WriteAt([]byte(content), n)
744
+
745
+	} else { //不存在
746
+		fmt.Println("文件不存在,创建文件")
747
+		f, err := os.Create(org_name + "日志" + "/" + file_name)
748
+		defer f.Close()
749
+		if err != nil {
750
+		} else {
751
+			_, err = f.Write([]byte("记录日志"))
752
+		}
753
+	}
754
+
755
+}