Browse Source

历史排班

28169 1 year ago
parent
commit
c218cc964f

+ 4 - 0
conf/app.conf View File

@@ -152,6 +152,10 @@ sso_domain = https://testsso.sgjyun.com
152 152
 call_domain = http://hf.szjkhd.com
153 153
 front_end_domain = "http://xt.test.sgjyun.com/#"
154 154
 
155
+sign_appid ="eac17a142dd046"
156
+serviceKye = "da8b09dce3684e6ebfbb7f70dba707a0"
157
+serviceCode ="msg0001"
158
+
155 159
 readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
156 160
 readmysqlport = 3306
157 161
 readmysqluser = root

+ 4 - 0
controllers/dialysis_api_controller.go View File

@@ -4168,6 +4168,8 @@ func (c *DialysisApiController) GetDialysisOrder() {
4168 4168
 	prescriptionInfo, _ := service.GetPrescriptionInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4169 4169
 
4170 4170
 	patientDiagnose, _ := service.FindPatientDianose(adminUserInfo.CurrentOrgId)
4171
+
4172
+	lastSchedule, _ := service.FindLastSchedule(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4171 4173
 	//if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
4172 4174
 	//	for _, item := range projects {
4173 4175
 	//		var advice *models.HisDoctorAdviceInfo
@@ -4225,6 +4227,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
4225 4227
 			"projects":                  projects,
4226 4228
 			"prescriptionInfo":          prescriptionInfo,
4227 4229
 			"patientDiagnose":           patientDiagnose,
4230
+			"lastSchedule":              lastSchedule,
4228 4231
 		})
4229 4232
 
4230 4233
 	}
@@ -4264,6 +4267,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
4264 4267
 			"projects":                  projects,
4265 4268
 			"prescriptionInfo":          prescriptionInfo,
4266 4269
 			"patientDiagnose":           patientDiagnose,
4270
+			"lastSchedule":              lastSchedule,
4267 4271
 		})
4268 4272
 	}
4269 4273
 

+ 1 - 0
controllers/inspection_api_controller.go View File

@@ -845,6 +845,7 @@ func (c *InspectionApiController) GetPatientInspections() {
845 845
 
846 846
 	adminUserInfo := c.GetAdminUserInfo()
847 847
 	inspections, total, dateTime, err := service.GetPatientInspections(adminUserInfo.CurrentOrgId, patient, projectId, page)
848
+	fmt.Println("inspections", inspections)
848 849
 	if err != nil {
849 850
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
850 851
 		return

+ 14 - 4
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -92,7 +92,7 @@ func (this *DialysisAPIController) Scheduals() {
92 92
 	patients, _ := service.GetAllPatientListSix(orgID)
93 93
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
94 94
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
95
-
95
+		fmt.Println("len2223o32o23o23owo", len(scheduals))
96 96
 		if err != nil {
97 97
 			this.ErrorLog("获取排班信息失败:%v", err)
98 98
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -106,6 +106,7 @@ func (this *DialysisAPIController) Scheduals() {
106 106
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
107 107
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
108 108
 				dobulecheck, _ := service.GetAllDobuleCheckList(orgID, date.Unix())
109
+				fmt.Println("dobulecheck", dobulecheck)
109 110
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
110 111
 				inforMation, _ := service.GetTodayInforMation(orgID, date.Unix())
111 112
 				for key, item := range scheduals {
@@ -973,10 +974,13 @@ func (c *DialysisAPIController) PostDoubleCheck() {
973 974
 
974 975
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
975 976
 		redis := service.RedisClient()
976
-
977
-		defer redis.Close()
978 977
 		//清空key 值
979 978
 		redis.Set(key, "", time.Second)
979
+		keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
980
+
981
+		redis.Set(keyOne, "", time.Second)
982
+		defer redis.Close()
983
+
980 984
 		if err == nil {
981 985
 			c.ServeSuccessJSON(map[string]interface{}{
982 986
 				"doubleCheck": &doubleCheck,
@@ -1054,9 +1058,15 @@ func (c *DialysisAPIController) PostDoubleCheck() {
1054 1058
 
1055 1059
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
1056 1060
 		redis := service.RedisClient()
1057
-		defer redis.Close()
1058 1061
 		//清空key 值
1059 1062
 		redis.Set(key, "", time.Second)
1063
+
1064
+		keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1065
+
1066
+		redis.Set(keyOne, "", time.Second)
1067
+
1068
+		defer redis.Close()
1069
+
1060 1070
 		if err == nil {
1061 1071
 			c.ServeSuccessJSON(map[string]interface{}{
1062 1072
 				"doubleCheck": &doubleCheck,

+ 10 - 6
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -3794,7 +3794,7 @@ func (c *PatientApiController) GetPatientMonitor() {
3794 3794
 	adminInfo := c.GetMobileAdminUserInfo()
3795 3795
 	orgID := adminInfo.Org.Id
3796 3796
 	monitor, err := service.GetMonitorRecord(orgID, theStartTime, partition, patient_id)
3797
-	fmt.Println("monitor-------------------", monitor)
3797
+
3798 3798
 	if err != nil {
3799 3799
 		c.ErrorLog("获取排班信息失败:%v", err)
3800 3800
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -3894,14 +3894,14 @@ func (c *PatientApiController) GetPatientMonitor() {
3894 3894
 	}
3895 3895
 
3896 3896
 	//获取患者的透析次数
3897
-	count, err := service.GetDialysisCount(orgID, partition)
3897
+	//count, err := service.GetDialysisCount(orgID, partition)
3898 3898
 
3899 3899
 	patients, err := service.GetAllpatientThirty(orgID)
3900 3900
 	if err == nil {
3901 3901
 		c.ServeSuccessJSON(map[string]interface{}{
3902
-			"monitor":      monitor,
3903
-			"patientCount": count,
3904
-			"patients":     patients,
3902
+			"monitor": monitor,
3903
+			//"patientCount": count,
3904
+			"patients": patients,
3905 3905
 		})
3906 3906
 	} else {
3907 3907
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -4072,11 +4072,13 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
4072 4072
 
4073 4073
 	//临时医嘱
4074 4074
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
4075
-	fmt.Println("DoctorAdvice3223323323232323223323323223332232332wode", DoctorAdvice)
4075
+
4076 4076
 	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
4077 4077
 	config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
4078 4078
 
4079 4079
 	project_config, _ := service.GetHisProjectConfig(adminUserInfo.Org.Id)
4080
+
4081
+	lastSchedule, _ := service.FindLastSchedule(adminUserInfo.Org.Id, patientInfo.ID, xttime)
4080 4082
 	projects, _ := service.FindAllHisProjectById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
4081 4083
 	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
4082 4084
 		for _, item := range projects {
@@ -4156,6 +4158,7 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
4156 4158
 			"projects":                projects,
4157 4159
 			"project_config":          project_config,
4158 4160
 			"lastWeight":              lastWeight,
4161
+			"lastSchedule":            lastSchedule,
4159 4162
 		})
4160 4163
 	}
4161 4164
 
@@ -4179,6 +4182,7 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
4179 4182
 			"projects":                projects,
4180 4183
 			"project_config":          project_config,
4181 4184
 			"lastWeight":              lastWeight,
4185
+			"lastSchedule":            lastSchedule,
4182 4186
 		})
4183 4187
 	}
4184 4188
 

+ 11 - 3
controllers/print_data_api_controller.go View File

@@ -93,10 +93,14 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
93 93
 				item.Count = list.Count
94 94
 			}
95 95
 
96
+			lastSchedule, _ := service.FindLastSchedule(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
97
+
98
+			item.Schedule = &lastSchedule
99
+
96 100
 			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10495 {
97 101
 
98 102
 				if item.ScheduleDate <= 1672416000 {
99
-					fmt.Print("进来1")
103
+
100 104
 					listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
101 105
 
102 106
 					item.Patient.TotalDialysis = listOne.Count
@@ -104,9 +108,9 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
104 108
 				}
105 109
 
106 110
 				if item.ScheduleDate >= 1672502400 {
107
-					fmt.Print("进来2")
111
+
108 112
 					listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
109
-					fmt.Println("listOne2322332", listOne.Count)
113
+
110 114
 					item.Patient.TotalDialysis = listOne.Count
111 115
 					item.Count = listOne.Count
112 116
 				}
@@ -155,6 +159,9 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
155 159
 				}
156 160
 
157 161
 			}
162
+			lastSchedule, _ := service.FindLastSchedule(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
163
+
164
+			item.Schedule = &lastSchedule
158 165
 			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 {
159 166
 				//listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
160 167
 
@@ -175,6 +182,7 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
175 182
 					item.Count = listOne.Count
176 183
 				}
177 184
 			}
185
+
178 186
 		}
179 187
 		if getScheduleErr != nil {
180 188
 			this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)

+ 61 - 0
controllers/sign_api_controller.go View File

@@ -19,11 +19,23 @@ func SignApiRegistRouters() {
19 19
 	//创建个人用户并实名
20 20
 	beego.Router("/api/sign/createrusername", &SignApiController{}, "Get:CreateUserName")
21 21
 
22
+	//创建企业用户并实名
23
+	beego.Router("/api/sign/createenterpriserealname", &SignApiController{}, "Get:CreateEnterPriseRealName")
24
+
25
+	//添加企业成员
26
+	beego.Router("/api/sign/createuserid", &SignApiController{}, "Get:CreateUserId")
27
+
22 28
 	//创建个人印章
23 29
 	beego.Router("/api/sign/createpersionseal", &SignApiController{}, "Get:CreatePersionSeal")
24 30
 
25 31
 	//上传文件创建创建合同
26 32
 	beego.Router("/api/sign/createuploadpact", &SignApiController{}, "Get:CreateUploadPact")
33
+
34
+	//添加合同签署人
35
+	beego.Router("/api/sign/addcontractsignatory", &SignApiController{}, "Get:AddContractSignatory")
36
+
37
+	//beego.Router("/api/sign/contractsignatory", &SignApiController{}, "Get:CreateSignTest")
38
+	beego.Router("/api/sign/contractsignatory", &SignApiController{}, "Get:CreateContractsignatory")
27 39
 }
28 40
 
29 41
 // 短信服务接口
@@ -150,3 +162,52 @@ func (this *SignApiController) CreateUploadPact() {
150 162
 	})
151 163
 	return
152 164
 }
165
+
166
+// 添加企业成员
167
+func (this *SignApiController) CreateUserId() {
168
+
169
+	userId := this.GetString("userId")
170
+	displayName := this.GetString("displayName")
171
+
172
+	sign := service.CreateUserId(userId, displayName)
173
+
174
+	this.ServeSuccessJSON(map[string]interface{}{
175
+		"sign": sign,
176
+	})
177
+	return
178
+
179
+}
180
+
181
+func (this *SignApiController) CreateEnterPriseRealName() {
182
+
183
+	enterprisename := this.GetString("enterprisename")
184
+
185
+	sign := service.CreateEnterPriseRealName(enterprisename)
186
+
187
+	this.ServeSuccessJSON(map[string]interface{}{
188
+		"sign": sign,
189
+	})
190
+	return
191
+}
192
+
193
+func (this *SignApiController) AddContractSignatory() {
194
+
195
+	contractId := this.GetString("contractId")
196
+
197
+	signers := this.GetString("signers")
198
+
199
+	service.AddContractSignatory(contractId, signers)
200
+}
201
+
202
+func (this *SignApiController) CreateContractsignatory() {
203
+
204
+	list, _ := service.GetHisDoctorAdviceInfoList(10215)
205
+
206
+	for _, item := range list {
207
+		service.UpdatePatietPrice(item.ID, item.RetailPrice)
208
+	}
209
+	this.ServeSuccessJSON(map[string]interface{}{
210
+		"sign": "msg",
211
+	})
212
+	return
213
+}

+ 63 - 0
models/sign.models.go View File

@@ -0,0 +1,63 @@
1
+package models
2
+
3
+type NewContract struct {
4
+	ContractId string `json:"contractId"`
5
+	signers    []struct {
6
+		UserId       string `json:"userId"`
7
+		SignerType   int64  `json:"signerType"`
8
+		EnterpriseId string `json:"enterpriseId"`
9
+		Sequence     string `json:"sequence"`
10
+		SendMsg      string `json:"sendMsg"`
11
+		SignFiles    []struct {
12
+			DocId          float64 `json:"343465645"`
13
+			XySignControls []struct {
14
+				Key       string `json:"key"`
15
+				Type      string `json:"type"`
16
+				PageNum   string `json:"pageNum"`
17
+				PositionX string `json:"positionX"`
18
+				positionY string `json:"positionY"`
19
+			} `json:"xySignControls"`
20
+			KeywordSignControls []struct {
21
+				Key       string `json:"key"`
22
+				Type      string `json:"type"`
23
+				PageNum   string `json:"pageNum"`
24
+				PositionX string `json:"positionX"`
25
+				positionY string `json:"positionY"`
26
+			} `json:"keywordSignControls"`
27
+		} `json:"signFiles"`
28
+	}
29
+}
30
+
31
+type XySignControls struct {
32
+	Key       string `json:"key"`
33
+	Type      string `json:"type"`
34
+	PageNum   string `json:"pageNum"`
35
+	PositionX string `json:"positionX"`
36
+	positionY string `json:"positionY"`
37
+}
38
+
39
+type KeywordSignControls struct {
40
+	Key       string `json:"key"`
41
+	Type      string `json:"type"`
42
+	PageNum   string `json:"pageNum"`
43
+	PositionX string `json:"positionX"`
44
+	positionY string `json:"positionY"`
45
+}
46
+
47
+type SignFiles []struct {
48
+	DocId          float64 `json:"343465645"`
49
+	XySignControls []struct {
50
+		Key       string `json:"key"`
51
+		Type      string `json:"type"`
52
+		PageNum   string `json:"pageNum"`
53
+		PositionX string `json:"positionX"`
54
+		positionY string `json:"positionY"`
55
+	} `json:"xySignControls"`
56
+	KeywordSignControls []struct {
57
+		Key       string `json:"key"`
58
+		Type      string `json:"type"`
59
+		PageNum   string `json:"pageNum"`
60
+		PositionX string `json:"positionX"`
61
+		positionY string `json:"positionY"`
62
+	} `json:"keywordSignControls"`
63
+}

+ 8 - 1
service/dialysis_service.go View File

@@ -2267,7 +2267,6 @@ func GetDialysisWatchByKeywordFlow(orgID int64, keyword string, schedulType int6
2267 2267
 func GetDialysisWatchFlow(orgID int64, schedulDate int64, schedulType int64, partitionType int64, page int64, limit int64, start int64, end int64) (schedule []*models.DialysisScheduleFlow, err error, total int64) {
2268 2268
 	db := readDb.Model(&models.DialysisScheduleFlow{})
2269 2269
 
2270
-	fmt.Println("schedule_date--------------------", schedulDate)
2271 2270
 	if schedulDate > 0 {
2272 2271
 		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
2273 2272
 			Preload("TreatmentMode", "status = 1").
@@ -2302,3 +2301,11 @@ func GetPrescriptionInfo(user_org_id int64, patient_id int64, record_date int64)
2302 2301
 	err := XTReadDB().Where("user_org_id = ? and patient_id =? and record_date = ? and status=1", user_org_id, patient_id, record_date).Find(&info).Error
2303 2302
 	return info, err
2304 2303
 }
2304
+
2305
+func FindLastSchedule(user_org_id int64, patient_id int64, schedule_date int64) (models.XtSchedules, error) {
2306
+
2307
+	schedules := models.XtSchedules{}
2308
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and schedule_date < ? and status =1", user_org_id, patient_id, schedule_date).Order("schedule_date desc").First(&schedules).Error
2309
+
2310
+	return schedules, err
2311
+}

+ 2 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

@@ -603,6 +603,7 @@ type ScheduleVM struct {
603 603
 	HisAdvices               []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
604 604
 	HisPrescriptionProject   []*models.HisPrescriptionProject `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_project"`
605 605
 	Count                    int64
606
+	Schedule                 *models.XtSchedule `gorm:"ForeignKey:PatientID" json:"lastSchedule"`
606 607
 }
607 608
 
608 609
 func (ScheduleVM) TableName() string {
@@ -861,6 +862,7 @@ type ScheduleVMSix struct {
861 862
 	HisAdvices               []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
862 863
 	HisPrescriptionProject   []*models.HisPrescriptionProject `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_project"`
863 864
 	Count                    int64
865
+	Schedule                 *models.XtSchedule `gorm:"ForeignKey:PatientID" json:"lastSchedule"`
864 866
 }
865 867
 
866 868
 func (ScheduleVMSix) TableName() string {

+ 8 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -487,3 +487,11 @@ func GetAdminUserEsTwo(orgid int64) (admin []*models.UserAdminRoles, err error)
487 487
 	err = db.Select("x.id,x.admin_user_id,x.user_name,x.org_id,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id").Where("x.org_id = ?", orgid).Scan(&admin).Error
488 488
 	return admin, err
489 489
 }
490
+
491
+func FindLastSchedule(user_org_id int64, patient_id int64, schedule_date int64) (models.XtSchedule, error) {
492
+
493
+	schedules := models.XtSchedule{}
494
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and schedule_date < ? and status =1", user_org_id, patient_id, schedule_date).Order("schedule_date desc").First(&schedules).Error
495
+
496
+	return schedules, err
497
+}

+ 207 - 3
service/sign_service.go View File

@@ -1,6 +1,7 @@
1 1
 package service
2 2
 
3 3
 import (
4
+	"XT_New/models"
4 5
 	"XT_New/utils"
5 6
 	"bytes"
6 7
 	"crypto/hmac"
@@ -272,7 +273,7 @@ func CreateUploadPact(contractcode string, contractname string, signcount int64,
272 273
 
273 274
 	maprequest := make(map[string]interface{})
274 275
 
275
-	maprequest["contractCode"] = "102020620701056856"
276
+	//maprequest["contractCode"] = "102020620701056856"
276 277
 
277 278
 	maprequest["contractName"] = "汽车购买交易合同"
278 279
 
@@ -287,9 +288,10 @@ func CreateUploadPact(contractcode string, contractname string, signcount int64,
287 288
 
288 289
 	maprequest["contractBase64"] = contractBase64
289 290
 
290
-	maprequest["creator"] = "1003"
291
+	//添加企业成员 里面的USERID
292
+	maprequest["creator"] = "DCBCD8QR2TU6B83XFF3FOHJL"
291 293
 
292
-	maprequest["enterpriseId"] = "1001"
294
+	maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
293 295
 
294 296
 	maprequest["signValidDays"] = 90
295 297
 
@@ -327,3 +329,205 @@ func CreateUploadPact(contractcode string, contractname string, signcount int64,
327 329
 
328 330
 	return str
329 331
 }
332
+
333
+func CreateEnterPriseRealName(enterprisename string) string {
334
+
335
+	var url string
336
+
337
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/enterprise/createEnterpriseRealName"
338
+	appId := beego.AppConfig.String("sign_appid")
339
+
340
+	serviceKye := beego.AppConfig.String("serviceKye")
341
+
342
+	serviceCode := beego.AppConfig.String("serviceCode")
343
+
344
+	maprequest := make(map[string]interface{})
345
+
346
+	customerReq := make(map[string]interface{})
347
+	customerReq["idCardType"] = "N"
348
+	customerReq["idCardNum"] = "430526199408156511"
349
+
350
+	maprequest["enterpriseName"] = "深圳益森科技有限公司"
351
+	maprequest["authentication"] = true
352
+	maprequest["customerAuthReq"] = customerReq
353
+
354
+	fmt.Println("maprequest", maprequest)
355
+	byterequest, _ := json.Marshal(maprequest)
356
+
357
+	reader := bytes.NewReader(byterequest)
358
+
359
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
360
+
361
+	request, err := http.NewRequest("POST", url, reader)
362
+	if err != nil {
363
+		fmt.Println(err.Error())
364
+	}
365
+
366
+	request.Header.Set("appId", appId)
367
+	request.Header.Set("serviceCode", serviceCode)
368
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
369
+	request.Header.Set("Content-Signature", signatureStr)
370
+	client := http.Client{}
371
+
372
+	resp, err := client.Do(request)
373
+	if err != nil {
374
+		fmt.Println(err.Error())
375
+
376
+	}
377
+	respBytes, err := ioutil.ReadAll(resp.Body)
378
+	if err != nil {
379
+		fmt.Println(err.Error())
380
+
381
+	}
382
+	str := string(respBytes)
383
+
384
+	return str
385
+}
386
+
387
+func CreateUserId(userId string, displayName string) string {
388
+
389
+	var url string
390
+
391
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/user/joinEnterprise"
392
+	appId := beego.AppConfig.String("sign_appid")
393
+
394
+	serviceKye := beego.AppConfig.String("serviceKye")
395
+
396
+	serviceCode := beego.AppConfig.String("serviceCode")
397
+
398
+	maprequest := make(map[string]interface{})
399
+
400
+	maprequest["enterpriseId"] = "BRWAABXW3RUD4PGCYEQWRRK8"
401
+	maprequest["userId"] = "DCBCD8QR2TU6B83XFF3FOHJL"
402
+
403
+	byterequest, _ := json.Marshal(maprequest)
404
+	reader := bytes.NewReader(byterequest)
405
+
406
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
407
+
408
+	request, err := http.NewRequest("POST", url, reader)
409
+	if err != nil {
410
+		fmt.Println(err.Error())
411
+	}
412
+
413
+	request.Header.Set("appId", appId)
414
+	request.Header.Set("serviceCode", serviceCode)
415
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
416
+	request.Header.Set("Content-Signature", signatureStr)
417
+	client := http.Client{}
418
+
419
+	resp, err := client.Do(request)
420
+	if err != nil {
421
+		fmt.Println(err.Error())
422
+
423
+	}
424
+	respBytes, err := ioutil.ReadAll(resp.Body)
425
+	if err != nil {
426
+		fmt.Println(err.Error())
427
+
428
+	}
429
+	str := string(respBytes)
430
+
431
+	return str
432
+}
433
+
434
+//type ResultTwo struct {
435
+//	ErrMsg      string `json:"err_msg"`
436
+//	InfRefmsgid string `json:"inf_refmsgid"`
437
+//	Infcode     int64  `json:"infcode"`
438
+//	Output      struct {
439
+//		Baseinfo struct {
440
+//			Age         float64 `json:"age"`
441
+//			Brdy        string  `json:"brdy"`
442
+//			Certno      string  `json:"certno"`
443
+//			Gend        string  `json:"gend"`
444
+//			Naty        string  `json:"naty"`
445
+//			PsnCertType string  `json:"psn_cert_type"`
446
+//			PsnName     string  `json:"psn_name"`
447
+//			PsnNo       string  `json:"psn_no"`
448
+//		} `json:"baseinfo"`
449
+//		Idetinfo []interface{} `json:"idetinfo"`
450
+//		Iinfo    []struct {
451
+//			Balc                   float64 `json:"balc"`
452
+//			CvlservFlag            string  `json:"cvlserv_flag"`
453
+//			EmpName                string  `json:"emp_name"`
454
+//			InsuplcAdmdvs          string  `json:"insuplc_admdvs"`
455
+//			Insutype               string  `json:"insutype"`
456
+//			PausInsuDansuplcAdmdvs string  `json:"paus_insu_dansuplc_admdvs"`
457
+//			PausInsuDate           string  `json:"paus_insu_date"`
458
+//			PsnInsuDate            string  `json:"psn_insu_date"`
459
+//			PsnInsuStas            string  `json:"psn_insu_stas"`
460
+//			PsnType                string  `json:"psn_type"`
461
+//		} `json:"insuinfo"`
462
+//	} `json:"output"`
463
+//	RefmsgTime  string      `json:"refmsg_time"`
464
+//	RespondTime string      `json:"respond_time"`
465
+//	Signtype    interface{} `json:"signtype"`
466
+//	WarnInfo    interface{} `json:"warn_info"`
467
+//}
468
+
469
+func AddContractSignatory(contractId string, signers string) string {
470
+
471
+	var url string
472
+
473
+	url = "http://demo.itruscloud.com/apigate/contractpaasapi/contract/addSignerByFile"
474
+	appId := beego.AppConfig.String("sign_appid")
475
+
476
+	serviceKye := beego.AppConfig.String("serviceKye")
477
+
478
+	serviceCode := beego.AppConfig.String("serviceCode")
479
+
480
+	maprequest := make(map[string]interface{})
481
+
482
+	maprequest["contractId"] = "153497878806048027"
483
+
484
+	maprequest["signers"] = ""
485
+
486
+	var customs models.NewContract
487
+
488
+	customs.ContractId = ""
489
+
490
+	byterequest, _ := json.Marshal(maprequest)
491
+	reader := bytes.NewReader(byterequest)
492
+
493
+	signatureStr, _ := generateHMACSHA1SignatureOne(maprequest, serviceKye, serviceCode)
494
+
495
+	request, err := http.NewRequest("POST", url, reader)
496
+	if err != nil {
497
+		fmt.Println(err.Error())
498
+	}
499
+
500
+	request.Header.Set("appId", appId)
501
+	request.Header.Set("serviceCode", serviceCode)
502
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
503
+	request.Header.Set("Content-Signature", signatureStr)
504
+	client := http.Client{}
505
+
506
+	resp, err := client.Do(request)
507
+	if err != nil {
508
+		fmt.Println(err.Error())
509
+
510
+	}
511
+	respBytes, err := ioutil.ReadAll(resp.Body)
512
+	if err != nil {
513
+		fmt.Println(err.Error())
514
+
515
+	}
516
+	str := string(respBytes)
517
+
518
+	return str
519
+}
520
+
521
+func GetHisDoctorAdviceInfoList(user_org_id int64) (advice []*models.XtDrugWarehouseInfo, err error) {
522
+
523
+	err = XTReadDB().Where("status= 1 and is_check= 1").Find(&advice).Error
524
+
525
+	return advice, err
526
+}
527
+
528
+func UpdatePatietPrice(id int64, retail_price float64) (models.DrugFlow, error) {
529
+
530
+	flow := models.DrugFlow{}
531
+	err := XTWriteDB().Model(&flow).Where("warehousing_detail_id = ? and status=1", id).Updates(map[string]interface{}{"price": retail_price}).Error
532
+	return flow, err
533
+}

+ 47 - 7
service/warhouse_service.go View File

@@ -161,6 +161,23 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
161 161
 
162 162
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
163 163
 
164
+	// 将该批次的剩余库存数量转换为拆零数量
165
+	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
166
+
167
+		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
168
+
169
+	}
170
+	if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
171
+
172
+		stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
173
+
174
+	}
175
+	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
176
+
177
+		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
178
+
179
+	}
180
+
164 181
 	//查找药品信息
165 182
 	//baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
166 183
 
@@ -186,7 +203,19 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
186 203
 			}
187 204
 		}
188 205
 
189
-		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
206
+		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
207
+			//fmt.Println("金1")
208
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
209
+		}
210
+
211
+		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
212
+			//fmt.Println("金2")
213
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
214
+		}
215
+		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
216
+			//fmt.Println("金3")
217
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
218
+		}
190 219
 
191 220
 		if warehouse.StockMaxNumber < 0 {
192 221
 			warehouse.StockMaxNumber = 0
@@ -198,25 +227,36 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
198 227
 		warehouse.Mtime = time.Now().Unix()
199 228
 
200 229
 		if warehouse.StockMinNumber < minNumber {
201
-
230
+			//fmt.Println("金4")
202 231
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
203
-			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
232
+			if warehouse.MaxUnit != warehouse.MinUnit {
233
+				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
234
+			}
204 235
 		} else {
236
+			//fmt.Println("金5")
205 237
 			if minNumber > 0 {
206
-				warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
238
+				if (warehouse.StockMinNumber - minNumber) >= 0 {
239
+					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
240
+				}
241
+
207 242
 			}
208 243
 
209 244
 			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
245
+				//fmt.Println("6")
210 246
 				if warehouse.StockMinNumber > 0 {
211
-					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
247
+					if warehouse.StockMinNumber-deliver_number >= 0 {
248
+						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
249
+					}
250
+
212 251
 				}
213 252
 
214 253
 			}
215 254
 
216 255
 		}
217 256
 
218
-		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
219
-			if (warehouse.StockMinNumber - deliver_number) > 0 {
257
+		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
258
+			if (warehouse.StockMinNumber - deliver_number) >= 0 {
259
+				//fmt.Println("金7")
220 260
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
221 261
 			}
222 262