Sfoglia il codice sorgente

Merge branch '20211122' of http://git.shengws.com/csx/XT_New into 20211122

csx 2 anni fa
parent
commit
15cba56dc6

+ 34 - 5
controllers/dialysis_api_controller.go Vedi File

@@ -62,6 +62,8 @@ func DialysisApiRegistRouters() {
62 62
 	beego.Router("/api/goodstatistics/get", &DialysisApiController{}, "Get:GetDialysisGoodsStatistics")
63 63
 	beego.Router("/api/queue/get", &DialysisApiController{}, "Get:GetQueueCall")
64 64
 	beego.Router("/api/queue/update", &DialysisApiController{}, "Get:UpdateQueueCall")
65
+
66
+	beego.Router("/api/get/getrolelist", &DialysisApiController{}, "Get:GetRoleList")
65 67
 }
66 68
 
67 69
 func (c *DialysisApiController) GetQueueCall() {
@@ -909,7 +911,7 @@ func (c *DialysisApiController) PostDouleCheck() {
909 911
 	vascular_access_desc := c.GetString("vascular_access_desc")
910 912
 	pipeline_connection_desc := c.GetString("pipeline_connection_desc")
911 913
 	collator, _ := c.GetInt64("collator", 0)
912
-
914
+	employee_number := c.GetString("employee_number")
913 915
 	if id <= 0 {
914 916
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
915 917
 		return
@@ -934,6 +936,15 @@ func (c *DialysisApiController) PostDouleCheck() {
934 936
 
935 937
 	var checkDate int64
936 938
 
939
+	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
940
+		list, _ := service.GetRoleList(adminUserInfo.CurrentOrgId, modifier)
941
+
942
+		if employee_number != list.JobNumber {
943
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorEmployeeNumber)
944
+			return
945
+		}
946
+	}
947
+
937 948
 	if len(checkTimeStr) == 0 {
938 949
 		//checkTimeStr = time.Now().Format("2006-01-02 15:04")
939 950
 		checkDate = 0
@@ -970,6 +981,7 @@ func (c *DialysisApiController) PostDouleCheck() {
970 981
 		CreatedTime:                time.Now().Unix(),
971 982
 		UpdatedTime:                time.Now().Unix(),
972 983
 		CheckDate:                  recordDate.Unix(),
984
+		EmployeeNumber:             employee_number,
973 985
 	}
974 986
 
975 987
 	_, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
@@ -982,11 +994,11 @@ func (c *DialysisApiController) PostDouleCheck() {
982 994
 		err := service.AddSigleDoubleCheck(&doubleCheck)
983 995
 		redis := service.RedisClient()
984 996
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
985
-		fmt.Println("key2333223233223232323", key)
997
+
986 998
 		//清空key 值
987 999
 		redis.Set(key, "", time.Second)
988 1000
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
989
-		fmt.Println("keyTwo23332323223233223323232", keyTwo)
1001
+
990 1002
 		redis.Set(keyTwo, "", time.Second)
991 1003
 		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
992 1004
 		redis.Set(keyThree, "", time.Second)
@@ -1010,10 +1022,10 @@ func (c *DialysisApiController) PostDouleCheck() {
1010 1022
 		redis := service.RedisClient()
1011 1023
 		err := service.UpdateDoubleCheck(&doubleCheck)
1012 1024
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
1013
-		fmt.Println("key2333223233223232323", key)
1025
+
1014 1026
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1015 1027
 		redis.Set(keyTwo, "", time.Second)
1016
-		fmt.Println("keyTwo23332323223233223323232", keyTwo)
1028
+
1017 1029
 		//清空key 值
1018 1030
 		redis.Set(key, "", time.Second)
1019 1031
 		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
@@ -3844,3 +3856,20 @@ func (c *DialysisApiController) GetDialysisGoodsStatistics() {
3844 3856
 	}
3845 3857
 
3846 3858
 }
3859
+
3860
+func (c *DialysisApiController) GetRoleList() {
3861
+
3862
+	orgId := c.GetAdminUserInfo().CurrentOrgId
3863
+	admin_user_id, _ := c.GetInt64("admin_user_id")
3864
+	list, err := service.GetRoleList(orgId, admin_user_id)
3865
+	if err == nil {
3866
+		c.ServeSuccessJSON(map[string]interface{}{
3867
+			"adminRole": list,
3868
+		})
3869
+		return
3870
+
3871
+	} else {
3872
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3873
+		return
3874
+	}
3875
+}

+ 89 - 10
controllers/dialysis_record_api_controller.go Vedi File

@@ -1015,7 +1015,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1015 1015
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
1016 1016
 
1017 1017
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
1018
-				fmt.Println("total23232323232322332", totalMin)
1018
+				//fmt.Println("total23232323232322332", totalMin)
1019 1019
 				if (template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 36) && adminUserInfo.CurrentOrgId != 9671 {
1020 1020
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
1021 1021
 				}
@@ -1046,7 +1046,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1046 1046
 
1047 1047
 					if evaluation.ID > 0 {
1048 1048
 						ultrafiltration_rate = math.Ceil(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
1049
-						fmt.Println("ultrafiltration_rate", ultrafiltration_rate)
1049
+
1050 1050
 					}
1051 1051
 				}
1052 1052
 
@@ -1055,7 +1055,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1055 1055
 
1056 1056
 					if evaluation.ID > 0 {
1057 1057
 						ultrafiltration_rate = math.Ceil(prescription.TargetUltrafiltration / float64(totalMin) * 60)
1058
-						fmt.Println("hhhh2323323223322323323232", ultrafiltration_rate)
1058
+
1059 1059
 					}
1060 1060
 				}
1061 1061
 			}
@@ -1138,6 +1138,10 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1138 1138
 	nurseID, _ := this.GetInt64("nurse")
1139 1139
 	end_time := this.GetString("end_time")
1140 1140
 
1141
+	puncture_point_haematoma, _ := this.GetInt64("puncture_point_haematoma")
1142
+	internal_fistula := this.GetString("internal_fistula")
1143
+	catheter := this.GetString("catheter")
1144
+	cruor := this.GetString("cruor")
1141 1145
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 {
1142 1146
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1143 1147
 		return
@@ -1343,6 +1347,72 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1343 1347
 
1344 1348
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1345 1349
 
1350
+	//evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1351
+	//if evaluation.SystolicBloodPressure == 0 {
1352
+	//	evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1353
+	//
1354
+	//	pre := models.PredialysisEvaluation{
1355
+	//		SystolicBloodPressure: evaluation.SystolicBloodPressure,
1356
+	//	}
1357
+	//	fmt.Println("prew", pre)
1358
+	//	getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1359
+	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1360
+	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1361
+	//
1362
+	//	redis := service.RedisClient()
1363
+	//	redis.Set(key, "", time.Second)
1364
+	//	redis.Set(keyOne, "", time.Second)
1365
+	//	defer redis.Close()
1366
+	//	fmt.Println(getNurseErr)
1367
+	//}
1368
+	//if evaluation.DiastolicBloodPressure == 0 {
1369
+	//	evaluation.DiastolicBloodPressure = fmonitorRecords.DiastolicBloodPressure
1370
+	//	pres := models.PredialysisEvaluation{
1371
+	//		DiastolicBloodPressure: evaluation.DiastolicBloodPressure,
1372
+	//	}
1373
+	//	getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1374
+	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1375
+	//
1376
+	//	redis := service.RedisClient()
1377
+	//	redis.Set(key, "", time.Second)
1378
+	//
1379
+	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1380
+	//	redis.Set(keyOne, "", time.Second)
1381
+	//	defer redis.Close()
1382
+	//	fmt.Println(getNurseErr)
1383
+	//}
1384
+	//if evaluation.PulseFrequency == 0 {
1385
+	//	evaluation.PulseFrequency = fmonitorRecords.PulseFrequency
1386
+	//	press := models.PredialysisEvaluation{
1387
+	//		PulseFrequency: evaluation.PulseFrequency,
1388
+	//	}
1389
+	//	getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1390
+	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1391
+	//
1392
+	//	redis := service.RedisClient()
1393
+	//	redis.Set(key, "", time.Second)
1394
+	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1395
+	//	redis.Set(keyOne, "", time.Second)
1396
+	//	defer redis.Close()
1397
+	//	fmt.Println(getNurseErr)
1398
+	//}
1399
+	//
1400
+	//if evaluation.Temperature == 0 {
1401
+	//	evaluation.Temperature = fmonitorRecords.Temperature
1402
+	//	press := models.PredialysisEvaluation{
1403
+	//		Temperature: evaluation.Temperature,
1404
+	//	}
1405
+	//	getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1406
+	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1407
+	//
1408
+	//	redis := service.RedisClient()
1409
+	//	redis.Set(key, "", time.Second)
1410
+	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1411
+	//	redis.Set(keyOne, "", time.Second)
1412
+	//	defer redis.Close()
1413
+	//	fmt.Println(getNurseErr)
1414
+	//}
1415
+	//
1346 1416
 	if err != nil {
1347 1417
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1348 1418
 		return
@@ -1358,7 +1428,8 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1358 1428
 		http.PostForm(api, values)
1359 1429
 	}()
1360 1430
 
1361
-	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
1431
+	//执行下机
1432
+	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor)
1362 1433
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1363 1434
 	redis := service.RedisClient()
1364 1435
 	defer redis.Close()
@@ -1386,6 +1457,7 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1386 1457
 			"assessmentAfterDislysis": tempassessmentAfterDislysis,
1387 1458
 		})
1388 1459
 	}
1460
+
1389 1461
 }
1390 1462
 
1391 1463
 func (this *DialysisRecordAPIController) ModifyStartDialysis() {
@@ -1619,7 +1691,10 @@ func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
1619 1691
 	record_id, _ := c.GetInt64("id")
1620 1692
 	nurseID, _ := c.GetInt64("nurse")
1621 1693
 	end_time := c.GetString("end_time")
1622
-
1694
+	puncture_point_haematoma, _ := c.GetInt64("puncture_point_haematoma")
1695
+	internal_fistula := c.GetString("internal_fistula")
1696
+	catheter := c.GetString("catheter")
1697
+	cruor := c.GetString("cruor")
1623 1698
 	if record_id <= 0 || nurseID <= 0 {
1624 1699
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1625 1700
 		return
@@ -1657,11 +1732,15 @@ func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
1657 1732
 	//}
1658 1733
 
1659 1734
 	dialysisRecord := &models.DialysisOrder{
1660
-		ID:             record_id,
1661
-		UserOrgId:      adminUserInfo.CurrentOrgId,
1662
-		EndTime:        endDate.Unix(),
1663
-		FinishNurse:    nurseID,
1664
-		FinishModifier: adminUserInfo.AdminUser.Id,
1735
+		ID:                         record_id,
1736
+		UserOrgId:                  adminUserInfo.CurrentOrgId,
1737
+		EndTime:                    endDate.Unix(),
1738
+		FinishNurse:                nurseID,
1739
+		FinishModifier:             adminUserInfo.AdminUser.Id,
1740
+		PuncturePointHaematoma:     puncture_point_haematoma,
1741
+		BloodAccessInternalFistula: internal_fistula,
1742
+		Catheter:                   catheter,
1743
+		Cruor:                      cruor,
1665 1744
 	}
1666 1745
 
1667 1746
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)

+ 393 - 123
controllers/drug_pharmacy_management_controller.go Vedi File

@@ -2,10 +2,14 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
6 7
 	"XT_New/utils"
7 8
 	"fmt"
8 9
 	"github.com/astaxie/beego"
10
+	"github.com/jinzhu/gorm"
11
+	"math"
12
+	"strconv"
9 13
 	"strings"
10 14
 	"time"
11 15
 )
@@ -16,9 +20,23 @@ type PharmacyApiController struct {
16 20
 
17 21
 func PharmacyApiControllersRegisterRouters() {
18 22
 
23
+	//获取设置为药房发药的药品数据
19 24
 	beego.Router("/api/advice/gettodayadvicelist", &PharmacyApiController{}, "Get:GetTodayAdviceList")
25
+	//获取今日未发药的数据
20 26
 	beego.Router("api/advice/getpharmacybasedrug", &PharmacyApiController{}, "Get:GetPharyMacyBaseDrug")
27
+	//发药
21 28
 	beego.Router("/api/advice/updatepharmacybasedrug", &PharmacyApiController{}, "Get:UpdatePharmacyBaseDrug")
29
+
30
+	//获取今日已发药的数据
31
+	beego.Router("/api/advice/getpharmacybasedruglist", &PharmacyApiController{}, "Get:GetPharmacyBaseDrugList")
32
+	//退药流程
33
+	beego.Router("/api/advice/getreturnpharmacybasedrug", &PharmacyApiController{}, "Get:GetReturnPharmacyBaseDrug")
34
+
35
+	//设置
36
+	beego.Router("/api/advice/savesetting", &PharmacyApiController{}, "Get:SaveSetting")
37
+
38
+	beego.Router("/api/advice/getpharmacyconfig", &PharmacyApiController{}, "Get:GetPharmacyConfig")
39
+
22 40
 }
23 41
 
24 42
 func (this *PharmacyApiController) GetTodayAdviceList() {
@@ -30,9 +48,12 @@ func (this *PharmacyApiController) GetTodayAdviceList() {
30 48
 	//获取药房发药药品库数据
31 49
 	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
32 50
 	list, err := service.GetPharmacyDrugList(houseConfig.DrugStorehouseOut, orgId, keywords)
51
+	appId := this.GetAdminUserInfo().CurrentAppId
52
+	doctorlist, _ := service.GetAllDoctorSix(orgId, appId)
33 53
 	if err == nil {
34 54
 		this.ServeSuccessJSON(map[string]interface{}{
35
-			"list": list,
55
+			"list":       list,
56
+			"doctorlist": doctorlist,
36 57
 		})
37 58
 	} else {
38 59
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -80,6 +101,7 @@ func (this *PharmacyApiController) UpdatePharmacyBaseDrug() {
80 101
 
81 102
 	hisStr := this.GetString("hisStr")
82 103
 
104
+	admin_user_id, _ := this.GetInt64("admin_user_id")
83 105
 	if len(bloodStr) == 0 {
84 106
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
85 107
 		return
@@ -105,139 +127,387 @@ func (this *PharmacyApiController) UpdatePharmacyBaseDrug() {
105 127
 	adviceList, _ := service.GetPharmacyAdviceList(idArray, orgId)
106 128
 
107 129
 	hisAdviceList, _ := service.GetPharmacyHisAdviceList(idArray, orgId)
108
-	fmt.Print(hisAdviceList)
130
+
109 131
 	//查询是否通过药房出库
110 132
 	pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
111
-
112
-	medical, _ := service.GetBaseDrugMedical(orgId)
113
-	fmt.Print(medical)
114 133
 	if pharmacyConfig.IsOpen == 1 {
134
+		var total int64
135
+		var prescribing_number_total int64
136
+		//创建流水
137
+		timeStr := time.Now().Format("2006-01-02")
138
+		timeArr := strings.Split(timeStr, "-")
139
+		totals, _ := service.FindAllPharmacyDrugWarehouseOut(orgId)
140
+		totals = totals + 1
141
+		warehousing_out_order := strconv.FormatInt(orgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
142
+		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
143
+		number = number + totals
144
+		warehousing_out_order = "FY" + strconv.FormatInt(number, 10)
115 145
 
146
+		//血透
116 147
 		for _, item := range adviceList {
117
-			fmt.Print(item)
118
-			//houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
148
+
149
+			pharmacy := models.Pharmacy{
150
+				UserOrgId:      item.UserOrgId,
151
+				PatientId:      item.PatientId,
152
+				PrescriptionId: 0,
153
+				XtAdviceId:     item.ID,
154
+				HisOrXt:        1,
155
+				Ctime:          time.Now().Unix(),
156
+				Mtime:          0,
157
+				Status:         1,
158
+				HisAdviceId:    0,
159
+				DrugId:         item.DrugId,
160
+				RecordDate:     item.AdviceDate,
161
+				OrdreNumber:    warehousing_out_order,
162
+				Creater:        admin_user_id,
163
+			}
164
+
165
+			service.CreatePharmacy(pharmacy)
166
+
167
+			lastPharmacy, _ := service.GetLastPharmary(item.UserOrgId, item.ID, item.AdviceDate)
168
+
169
+			houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
119 170
 			////查询该药品是否有库存
120
-			//list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
171
+			list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
121 172
 			//
122 173
 			////查询改药品信息
123
-			//medical, _ := service.GetBaseDrugMedical(item.DrugId)
174
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
124 175
 			////判断单位是否相等
125
-			//if medical.MaxUnit == item.PrescribingNumberUnit {
126
-			//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
127
-			//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
128
-			//  //转化为最小单位
129
-			//  total = list.Count*medical.MinNumber + list.StockMinNumber
130
-			//  prescribing_number_total = count * medical.MinNumber
131
-			//}
132
-			//if medical.MinUnit == item.PrescribingNumberUnit {
133
-			//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
134
-			//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
135
-			//  total = list.Count*medical.MinNumber + list.StockMinNumber
136
-			//  prescribing_number_total = count
137
-			//}
138
-			//
139
-			//if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
140
-			//  c.ServeSuccessJSON(map[string]interface{}{
141
-			//    "msg":    "3",
142
-			//    "advice": advice,
143
-			//  })
144
-			//  return
145
-			//}
146
-			//if prescribing_number_total > total {
147
-			//  c.ServeSuccessJSON(map[string]interface{}{
148
-			//    "msg":    "2",
149
-			//    "advice": advice,
150
-			//  })
151
-			//  return
152
-			//}
153
-			//if prescribing_number_total <= total {
154
-			//
155
-			//  //查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
156
-			//
157
-			//  adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
158
-			//  if adviceSetting.IsAdviceOpen == 1 {
159
-			//
160
-			//    //查询是否出库按钮开启
161
-			//    prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
162
-			//    if prescriptionConfig.IsOpen == 1 {
163
-			//      if medical.IsUse == 2 {
164
-			//        service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
165
-			//        //查询默认仓库
166
-			//        houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
167
-			//        //查询默认仓库剩余多少库存
168
-			//        list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
169
-			//        var sum_count int64
170
-			//        var sum_in_count int64
171
-			//        for _, it := range list {
172
-			//          baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
173
-			//          if it.MaxUnit == baseDrug.MaxUnit {
174
-			//            it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
175
-			//            it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
176
-			//          }
177
-			//          sum_count += it.StockMaxNumber + it.StockMinNumber
178
-			//          sum_in_count += it.WarehousingCount
179
-			//        }
180
-			//        service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
181
-			//        break
182
-			//        c.ServeSuccessJSON(map[string]interface{}{
183
-			//          "msg":    "1",
184
-			//          "advice": advice,
185
-			//        })
186
-			//        return
187
-			//      }
188
-			//      if medical.IsUse == 1 {
189
-			//        c.ServeSuccessJSON(map[string]interface{}{
190
-			//          "msg":    "1",
191
-			//          "advice": advice,
192
-			//        })
193
-			//        return
194
-			//      }
195
-			//    } else {
196
-			//      if medical.IsUse == 1 {
197
-			//        c.ServeSuccessJSON(map[string]interface{}{
198
-			//          "msg":    "1",
199
-			//          "advice": advice,
200
-			//        })
201
-			//        return
202
-			//      }
203
-			//    }
176
+			if medical.MaxUnit == item.PrescribingNumberUnit {
177
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
178
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
179
+				//转化为最小单位
180
+				total = list.Count*medical.MinNumber + list.StockMinNumber
181
+				prescribing_number_total = count * medical.MinNumber
182
+			}
183
+			if medical.MinUnit == item.PrescribingNumberUnit {
184
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
185
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
186
+				total = list.Count*medical.MinNumber + list.StockMinNumber
187
+				prescribing_number_total = count
188
+			}
189
+
190
+			if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
191
+				this.ServeSuccessJSON(map[string]interface{}{
192
+					"msg":     "3",
193
+					"medical": medical,
194
+				})
195
+				return
196
+			}
197
+			if prescribing_number_total > total {
198
+				this.ServeSuccessJSON(map[string]interface{}{
199
+					"msg":     "2",
200
+					"medical": medical,
201
+				})
202
+				return
203
+			}
204
+
205
+			if prescribing_number_total <= total {
206
+
207
+				//查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
208
+				adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
209
+				if adviceSetting.IsAdviceOpen == 1 {
210
+					if medical.IsUse == 2 {
211
+						service.PharmacyDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmacy.ID)
212
+						//查询默认仓库
213
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
214
+						//查询默认仓库剩余多少库存
215
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
216
+						var sum_count int64
217
+						var sum_in_count int64
218
+						for _, it := range list {
219
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
220
+							if it.MaxUnit == baseDrug.MaxUnit {
221
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
222
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
223
+							}
224
+							sum_count += it.StockMaxNumber + it.StockMinNumber
225
+							sum_in_count += it.WarehousingCount
226
+						}
227
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
228
+						break
229
+						this.ServeSuccessJSON(map[string]interface{}{
230
+							"msg":     "1",
231
+							"medical": medical,
232
+						})
233
+						return
234
+					}
235
+					if medical.IsUse == 1 {
236
+						this.ServeSuccessJSON(map[string]interface{}{
237
+							"msg": "1",
238
+						})
239
+						return
240
+					}
241
+
242
+				} else {
243
+					if medical.IsUse == 2 {
244
+						service.PharmacyDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmacy.ID)
245
+						//查询默认仓库
246
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
247
+						//查询默认仓库剩余多少库存
248
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
249
+						var sum_count int64
250
+						var sum_in_count int64
251
+						for _, it := range list {
252
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
253
+							if it.MaxUnit == baseDrug.MaxUnit {
254
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
255
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
256
+							}
257
+							sum_count += it.StockMaxNumber + it.StockMinNumber
258
+							sum_in_count += it.WarehousingCount
259
+						}
260
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
261
+						this.ServeSuccessJSON(map[string]interface{}{
262
+							"msg":     "1",
263
+							"medical": medical,
264
+						})
265
+						return
266
+					}
267
+					if medical.IsUse == 1 {
268
+						this.ServeSuccessJSON(map[string]interface{}{
269
+							"msg":     "1",
270
+							"medical": medical,
271
+						})
272
+						return
273
+					}
274
+				}
275
+			}
276
+		}
277
+
278
+		//血透
279
+		for _, item := range hisAdviceList {
280
+
281
+			pharmacy := models.Pharmacy{
282
+				UserOrgId:      item.UserOrgId,
283
+				PatientId:      item.PatientId,
284
+				PrescriptionId: 0,
285
+				XtAdviceId:     0,
286
+				HisOrXt:        2,
287
+				Ctime:          time.Now().Unix(),
288
+				Mtime:          0,
289
+				Status:         1,
290
+				HisAdviceId:    item.ID,
291
+				DrugId:         item.DrugId,
292
+				RecordDate:     item.AdviceDate,
293
+				OrdreNumber:    warehousing_out_order,
294
+				Creater:        admin_user_id,
295
+			}
296
+
297
+			service.CreatePharmacy(pharmacy)
298
+
299
+			lastPharmary, _ := service.GetLastHisPharmary(item.UserOrgId, item.ID, item.AdviceDate)
300
+
301
+			houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
302
+			////查询该药品是否有库存
303
+			list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
204 304
 			//
205
-			//  } else {
206
-			//    if medical.IsUse == 2 {
207
-			//      service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
208
-			//      //查询默认仓库
209
-			//      houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
210
-			//      //查询默认仓库剩余多少库存
211
-			//      list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
212
-			//      var sum_count int64
213
-			//      var sum_in_count int64
214
-			//      for _, it := range list {
215
-			//        baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
216
-			//        if it.MaxUnit == baseDrug.MaxUnit {
217
-			//          it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
218
-			//          it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
219
-			//        }
220
-			//        sum_count += it.StockMaxNumber + it.StockMinNumber
221
-			//        sum_in_count += it.WarehousingCount
222
-			//      }
223
-			//      service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
224
-			//      break
225
-			//      c.ServeSuccessJSON(map[string]interface{}{
226
-			//        "msg":    "1",
227
-			//        "advice": advice,
228
-			//      })
229
-			//      return
230
-			//    }
231
-			//    if medical.IsUse == 1 {
232
-			//      c.ServeSuccessJSON(map[string]interface{}{
233
-			//        "msg":    "1",
234
-			//        "advice": advice,
235
-			//      })
236
-			//      return
237
-			//    }
238
-			//  }
239
-			//}
305
+			////查询改药品信息
306
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
307
+			////判断单位是否相等
308
+			if medical.MaxUnit == item.PrescribingNumberUnit {
309
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
310
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
311
+				//转化为最小单位
312
+				total = list.Count*medical.MinNumber + list.StockMinNumber
313
+				prescribing_number_total = count * medical.MinNumber
314
+			}
315
+			if medical.MinUnit == item.PrescribingNumberUnit {
316
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
317
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
318
+				total = list.Count*medical.MinNumber + list.StockMinNumber
319
+				prescribing_number_total = count
320
+			}
321
+
322
+			if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
323
+				this.ServeSuccessJSON(map[string]interface{}{
324
+					"msg":     "3",
325
+					"medical": medical,
326
+				})
327
+				return
328
+			}
329
+			if prescribing_number_total > total {
330
+				this.ServeSuccessJSON(map[string]interface{}{
331
+					"msg":     "2",
332
+					"medical": medical,
333
+				})
334
+				return
335
+			}
336
+
337
+			if prescribing_number_total <= total {
338
+
339
+				//查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
340
+				adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
341
+				if adviceSetting.IsAdviceOpen == 1 {
342
+					if medical.IsUse == 2 {
343
+						service.PharmacyHisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmary.ID)
344
+						//查询默认仓库
345
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
346
+						//查询默认仓库剩余多少库存
347
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
348
+						var sum_count int64
349
+						var sum_in_count int64
350
+						for _, it := range list {
351
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
352
+							if it.MaxUnit == baseDrug.MaxUnit {
353
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
354
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
355
+							}
356
+							sum_count += it.StockMaxNumber + it.StockMinNumber
357
+							sum_in_count += it.WarehousingCount
358
+						}
359
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
360
+						break
361
+						this.ServeSuccessJSON(map[string]interface{}{
362
+							"msg":     "1",
363
+							"medical": medical,
364
+						})
365
+						return
366
+					}
367
+					if medical.IsUse == 1 {
368
+						this.ServeSuccessJSON(map[string]interface{}{
369
+							"msg": "1",
370
+						})
371
+						return
372
+					}
373
+
374
+				} else {
375
+					if medical.IsUse == 2 {
376
+						service.PharmacyHisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmary.ID)
377
+						//查询默认仓库
378
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
379
+						//查询默认仓库剩余多少库存
380
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
381
+						var sum_count int64
382
+						var sum_in_count int64
383
+						for _, it := range list {
384
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
385
+							if it.MaxUnit == baseDrug.MaxUnit {
386
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
387
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
388
+							}
389
+							sum_count += it.StockMaxNumber + it.StockMinNumber
390
+							sum_in_count += it.WarehousingCount
391
+						}
392
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
393
+						this.ServeSuccessJSON(map[string]interface{}{
394
+							"msg":     "1",
395
+							"medical": medical,
396
+						})
397
+						return
398
+					}
399
+					if medical.IsUse == 1 {
400
+						this.ServeSuccessJSON(map[string]interface{}{
401
+							"msg":     "1",
402
+							"medical": medical,
403
+						})
404
+						return
405
+					}
406
+				}
407
+			}
240 408
 		}
241 409
 	}
410
+}
411
+
412
+func (this *PharmacyApiController) GetPharmacyBaseDrugList() {
413
+
414
+	start_time := this.GetString("start_time")
415
+	timeLayout := "2006-01-02"
416
+	loc, _ := time.LoadLocation("Local")
417
+	var theStartTime int64
418
+	if len(start_time) > 0 {
419
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
420
+		if err != nil {
421
+			utils.ErrorLog(err.Error())
422
+		}
423
+		theStartTime = theTime.Unix()
424
+	}
425
+
426
+	drug_id, _ := this.GetInt64("drug_id")
427
+
428
+	orgId := this.GetAdminUserInfo().CurrentOrgId
429
+	//获取血透医嘱
430
+	advicelist, _ := service.GetUseredBloodAdviceList(theStartTime, drug_id, orgId)
431
+
432
+	//获取医保医嘱
433
+	hisAdviceList, err := service.GetUseredHisAdviceList(theStartTime, drug_id, orgId)
434
+
435
+	patient, _ := service.GetAllPatientListSix(orgId)
436
+	if err == nil {
437
+		this.ServeSuccessJSON(map[string]interface{}{
438
+			"advicelist":    advicelist,
439
+			"hisAdviceList": hisAdviceList,
440
+			"patient":       patient,
441
+		})
442
+	} else {
443
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
444
+	}
445
+}
446
+
447
+func (this *PharmacyApiController) GetReturnPharmacyBaseDrug() {
448
+
449
+	bloodStr := this.GetString("bloodStr")
450
+
451
+	hisStr := this.GetString("hisStr")
452
+
453
+	if len(bloodStr) == 0 {
454
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
455
+		return
456
+	}
457
+
458
+	idArray := strings.Split(bloodStr, ",")
459
+
460
+	if len(hisStr) == 0 {
461
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
462
+		return
463
+	}
242 464
 
465
+	idArrayOne := strings.Split(hisStr, ",")
466
+
467
+	fmt.Println("idArray23332233223", idArray)
468
+	fmt.Println("idArrayOne23332233223", idArrayOne)
469
+
470
+	orgId := this.GetAdminUserInfo().CurrentOrgId
471
+	service.UpdateReturnPharmacyAdviceBaseDrug(idArray, orgId)
472
+	service.UpdateReturnPharmacyHisAdviceBaseDrug(idArray, orgId)
473
+}
474
+
475
+func (this *PharmacyApiController) SaveSetting() {
476
+
477
+	is_open, _ := this.GetInt64("is_open")
478
+
479
+	orgId := this.GetAdminUserInfo().CurrentOrgId
480
+	config := models.PharmacyConfig{
481
+		UserOrgId: orgId,
482
+		IsOpen:    is_open,
483
+		Status:    1,
484
+		Ctime:     time.Now().Unix(),
485
+	}
486
+
487
+	//查找是否存在
488
+	_, errcode := service.GetConfigSettingIsExsit(orgId)
489
+	if errcode == gorm.ErrRecordNotFound {
490
+		service.CreatePharmacyConfig(&config)
491
+	} else if errcode == nil {
492
+		service.UpdatePharmacyConfig(orgId, &config)
493
+	}
494
+
495
+	this.ServeSuccessJSON(map[string]interface{}{
496
+		"config": config,
497
+	})
498
+}
499
+
500
+func (this *PharmacyApiController) GetPharmacyConfig() {
501
+
502
+	orgId := this.GetAdminUserInfo().CurrentOrgId
503
+
504
+	config, err := service.GetPharmacyConfig(orgId)
505
+
506
+	if err == nil {
507
+		this.ServeSuccessJSON(map[string]interface{}{
508
+			"config": config,
509
+		})
510
+	} else {
511
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
512
+	}
243 513
 }

+ 106 - 67
controllers/drug_stock_api_contorller.go Vedi File

@@ -71,6 +71,8 @@ func DrugStockManagerApiRegistRouters() {
71 71
 	beego.Router("/api/drug/getdrugwarehouseinfoprint", &StockDrugApiController{}, "get:GetDrugWarehouseInfoPrint")
72 72
 	beego.Router("/api/drug/getdrugoutorderprint", &StockDrugApiController{}, "get:GetDrugOutOrderPrint")
73 73
 
74
+	beego.Router("/api/drugstock/config/list", &StockDrugApiController{}, "get:GetConfigList")
75
+
74 76
 }
75 77
 
76 78
 func (c *StockDrugApiController) CreateDrugWarehouse() {
@@ -986,7 +988,10 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
986 988
 						fmt.Println(parseDateErr)
987 989
 					}
988 990
 				}
989
-				errs = service.UpDateDrugWarehousingInfoSix(item.ID, warehouseinfo)
991
+				if item.MaxUnit == warehouseInfo.MaxUnit {
992
+					errs = service.UpDateDrugWarehousingInfoSix(item.ID, warehouseinfo)
993
+				}
994
+
990 995
 				//查询默认仓库
991 996
 				houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
992 997
 				//查询默认仓库剩余多少库存
@@ -2281,7 +2286,8 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2281 2286
 
2282 2287
 				if item.CountUnit == medical.MaxUnit {
2283 2288
 					maxNumber = cha_number / medical.MinNumber
2284
-					parseDateErr := service.UpdateWarehouseInfo(maxNumber, item.DrugId, item.OrgId)
2289
+
2290
+					parseDateErr := service.UpdateWarehouseInfo(maxNumber, item.DrugId, item.OrgId, outInfo.WarehouseInfoId)
2285 2291
 
2286 2292
 					if parseDateErr != nil {
2287 2293
 						utils.ErrorLog(errs.Error())
@@ -2302,7 +2308,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2302 2308
 					if minNumber < 0 {
2303 2309
 						minNumber = 0
2304 2310
 					}
2305
-					parseDateErr = service.UpdateWarehouseInfoOne(minNumber, item.DrugId, item.OrgId)
2311
+					parseDateErr = service.UpdateWarehouseInfoOne(minNumber, item.DrugId, item.OrgId, outInfo.WarehouseInfoId)
2306 2312
 
2307 2313
 					if parseDateErr != nil {
2308 2314
 						utils.ErrorLog(errs.Error())
@@ -2321,7 +2327,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2321 2327
 					})
2322 2328
 				}
2323 2329
 				if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
2324
-					parseDateErr := service.UpdateWarehouseInfoOne(cha_number, item.DrugId, item.OrgId)
2330
+					parseDateErr := service.UpdateWarehouseInfoOne(cha_number, item.DrugId, item.OrgId, outInfo.WarehouseInfoId)
2325 2331
 
2326 2332
 					if parseDateErr != nil {
2327 2333
 						utils.ErrorLog(errs.Error())
@@ -2361,68 +2367,83 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2361 2367
 						AdminUserId:  item.AdminUserId,
2362 2368
 					}
2363 2369
 					service.UpdateDrugFlowSix(item.WarehouseOutId, item.DrugId, item.WarehouseOutOrderNumber, flow)
2364
-					if item.CountUnit == medical.MaxUnit {
2365
-						maxNumber = cha_number / medical.MinNumber
2366
-
2367
-						parseDateErr := service.UpdateWarehouseInfoTwo(maxNumber, item.DrugId, item.OrgId)
2368
-
2369
-						fmt.Println("parseDateErr", parseDateErr)
2370
-						if parseDateErr != nil {
2371
-							utils.ErrorLog(errs.Error())
2372
-							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2373
-							return
2374
-						}
2375
-
2376
-						c.ServeSuccessJSON(map[string]interface{}{
2377
-							"msg":        "2",
2378
-							"drug_name":  "",
2379
-							"dose":       "",
2380
-							"dose_unit":  "",
2381
-							"min_number": "",
2382
-							"min_unit":   "",
2383
-							"max_unit":   "",
2384
-						})
2385
-						minNumber = cha_number % medical.MinNumber
2386
-						if minNumber < 0 {
2387
-							minNumber = 0
2388
-						}
2389
-						parseDateErr = service.UpdateWarehouseInfoFour(minNumber, item.DrugId, item.OrgId)
2390 2370
 
2391
-						if parseDateErr != nil {
2392
-							utils.ErrorLog(errs.Error())
2393
-							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2394
-							return
2395
-						}
2396
-
2397
-						c.ServeSuccessJSON(map[string]interface{}{
2398
-							"msg":        "2",
2399
-							"drug_name":  "",
2400
-							"dose":       "",
2401
-							"dose_unit":  "",
2402
-							"min_number": "",
2403
-							"min_unit":   "",
2404
-							"max_unit":   "",
2405
-						})
2406
-					}
2407
-					if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
2408
-						parseDateErr := service.UpdateWarehouseInfoFour(cha_number, item.DrugId, item.OrgId)
2409
-
2410
-						if parseDateErr != nil {
2411
-							utils.ErrorLog(errs.Error())
2412
-							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2413
-							return
2414
-						}
2415
-
2416
-						c.ServeSuccessJSON(map[string]interface{}{
2417
-							"msg":        "2",
2418
-							"drug_name":  "",
2419
-							"dose":       "",
2420
-							"dose_unit":  "",
2421
-							"min_number": "",
2422
-							"min_unit":   "",
2423
-							"max_unit":   "",
2424
-						})
2425
-					}
2371
+					service.UpdateWarehouseInfoTwentyFive(cha_number, item.DrugId, item.OrgId, storehouse_id, &medical)
2372
+
2373
+					//if item.CountUnit == medical.MaxUnit {
2374
+					//	maxNumber = cha_number / medical.MinNumber
2375
+					//
2376
+					//  service.UpdateWarehouseInfoTwentyFive(maxNumber,item.DrugId,item.OrgId,storehouse_id)
2377
+					//
2378
+					//  ////如果库存大于差
2379
+					//  //if(warehouse.StockMaxNumber > maxNumber){
2380
+					//  // service.UpdateWarehouseInfoTwenty(maxNumber,warehouse.ID)
2381
+					//  //}
2382
+					//  ////如果库存小于差
2383
+					//  //if(warehouse.StockMaxNumber < maxNumber){
2384
+					//  //
2385
+					//  //   //先出库完上一个批次的
2386
+					//  //  service.UpdateWarehouseInfoTwentyOne(warehouse.ID)
2387
+					//  //}
2388
+					//
2389
+					//	parseDateErr := service.UpdateWarehouseInfoTwo(maxNumber, item.DrugId, item.OrgId)
2390
+					//	fmt.Println("parseDateErr", parseDateErr)
2391
+					//	if parseDateErr != nil {
2392
+					//		utils.ErrorLog(errs.Error())
2393
+					//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2394
+					//		return
2395
+					//	}
2396
+					//
2397
+					//	c.ServeSuccessJSON(map[string]interface{}{
2398
+					//		"msg":        "2",
2399
+					//		"drug_name":  "",
2400
+					//		"dose":       "",
2401
+					//		"dose_unit":  "",
2402
+					//		"min_number": "",
2403
+					//		"min_unit":   "",
2404
+					//		"max_unit":   "",
2405
+					//	})
2406
+					//	minNumber = cha_number % medical.MinNumber
2407
+					//	if minNumber < 0 {
2408
+					//		minNumber = 0
2409
+					//	}
2410
+					//	parseDateErr = service.UpdateWarehouseInfoFour(minNumber, item.DrugId, item.OrgId)
2411
+					//
2412
+					//	if parseDateErr != nil {
2413
+					//		utils.ErrorLog(errs.Error())
2414
+					//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2415
+					//		return
2416
+					//	}
2417
+					//
2418
+					//	c.ServeSuccessJSON(map[string]interface{}{
2419
+					//		"msg":        "2",
2420
+					//		"drug_name":  "",
2421
+					//		"dose":       "",
2422
+					//		"dose_unit":  "",
2423
+					//		"min_number": "",
2424
+					//		"min_unit":   "",
2425
+					//		"max_unit":   "",
2426
+					//	})
2427
+					//}
2428
+					//if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
2429
+					//	parseDateErr := service.UpdateWarehouseInfoFour(cha_number, item.DrugId, item.OrgId)
2430
+					//
2431
+					//	if parseDateErr != nil {
2432
+					//		utils.ErrorLog(errs.Error())
2433
+					//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2434
+					//		return
2435
+					//	}
2436
+					//
2437
+					//	c.ServeSuccessJSON(map[string]interface{}{
2438
+					//		"msg":        "2",
2439
+					//		"drug_name":  "",
2440
+					//		"dose":       "",
2441
+					//		"dose_unit":  "",
2442
+					//		"min_number": "",
2443
+					//		"min_unit":   "",
2444
+					//		"max_unit":   "",
2445
+					//	})
2446
+					//}
2426 2447
 				}
2427 2448
 
2428 2449
 				if all_number == cha_number {
@@ -3854,8 +3875,7 @@ func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3854 3875
 	adminUserInfo := c.GetAdminUserInfo()
3855 3876
 	orgId := adminUserInfo.CurrentOrgId
3856 3877
 	if order_type == 2 {
3857
-		//list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId)
3858
-		list, err := service.GetDrugOutOrderPrintList(startTime, endTime, orgId)
3878
+		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId)
3859 3879
 		if err == nil {
3860 3880
 			c.ServeSuccessJSON(map[string]interface{}{
3861 3881
 				"list": list,
@@ -3865,3 +3885,22 @@ func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3865 3885
 	}
3866 3886
 
3867 3887
 }
3888
+
3889
+func (c *StockDrugApiController) GetConfigList() {
3890
+	adminUserInfo := c.GetAdminUserInfo()
3891
+	manufacturer, _ := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
3892
+	dealer, _ := service.FindAllDealer(adminUserInfo.CurrentOrgId)
3893
+	stockIns, _ := service.FindStockInNumber(adminUserInfo.CurrentOrgId)
3894
+	list, _ := service.GetAllStoreHouseListThree(adminUserInfo.CurrentOrgId)
3895
+	configlist, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
3896
+	appId := c.GetAdminUserInfo().CurrentAppId
3897
+	doctorList, _ := service.GetAllDoctorListSix(adminUserInfo.CurrentOrgId, appId)
3898
+	c.ServeSuccessJSON(map[string]interface{}{
3899
+		"manufacturer": manufacturer,
3900
+		"dealer":       dealer,
3901
+		"numbers":      stockIns,
3902
+		"list":         list,
3903
+		"configlist":   configlist,
3904
+		"doctorList":   doctorList,
3905
+	})
3906
+}

+ 35 - 4
controllers/gobal_config_api_controller.go Vedi File

@@ -118,6 +118,8 @@ func GobalConfigRegistRouters() {
118 118
 	beego.Router("/api/changeadviceconfig", &GobalConfigApiController{}, "Get:ChangeAdviceConfig")
119 119
 
120 120
 	beego.Router("/api/changeprescriptionconfig", &GobalConfigApiController{}, "Get:ChangePrescriptionConfig")
121
+
122
+	beego.Router("/api/changedrugopenconfig", &GobalConfigApiController{}, "Get:ChangeDrugOpenConfig")
121 123
 }
122 124
 
123 125
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1567,12 +1569,15 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1567 1569
 	adviceSetting, _ := service.FindAdviceSettingById(adminUserInfo.CurrentOrgId)
1568 1570
 
1569 1571
 	prescriptionConfig, _ := service.FindPrescriptionConfigById(adminUserInfo.CurrentOrgId)
1572
+
1573
+	drugOutConfig, _ := service.FindDrugOutConfigById(adminUserInfo.CurrentOrgId)
1570 1574
 	c.ServeSuccessJSON(map[string]interface{}{
1571 1575
 		"is_open_xt_his":         config.IsOpen,
1572 1576
 		"is_open_xt_his_project": project_config.IsOpen,
1573 1577
 		"is_open_stock":          stockSetting.IsType,
1574 1578
 		"is_open_advice":         adviceSetting.IsAdviceOpen,
1575 1579
 		"is_prescription_advice": prescriptionConfig.IsOpen,
1580
+		"is_open":                drugOutConfig.IsOpen,
1576 1581
 	})
1577 1582
 
1578 1583
 }
@@ -2239,11 +2244,13 @@ func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
2239 2244
 
2240 2245
 	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2241 2246
 
2242
-	//drug_warhouse_out, _ := service.GetDrugWarehouseOut(ids)
2247
+	drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids, admin.CurrentOrgId)
2248
+
2243 2249
 	c.ServeSuccessJSON(map[string]interface{}{
2244
-		"info":             info,
2245
-		"warehousing":      warehousing,
2246
-		"manufacturerList": manufacturerList,
2250
+		"info":              info,
2251
+		"warehousing":       warehousing,
2252
+		"manufacturerList":  manufacturerList,
2253
+		"drug_warhouse_out": drug_warhouse_out,
2247 2254
 	})
2248 2255
 }
2249 2256
 
@@ -2435,3 +2442,27 @@ func (c *GobalConfigApiController) ChangePrescriptionConfig() {
2435 2442
 	}
2436 2443
 
2437 2444
 }
2445
+
2446
+func (c *GobalConfigApiController) ChangeDrugOpenConfig() {
2447
+
2448
+	drug_out_open, _ := c.GetInt64("drug_out_open")
2449
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2450
+	_, errcode := service.GetDrugOpenConfig(orgId)
2451
+	if errcode == gorm.ErrRecordNotFound {
2452
+		config := models.DrugOutConfig{
2453
+			UserOrgId: orgId,
2454
+			IsOpen:    drug_out_open,
2455
+			Status:    1,
2456
+			Ctime:     time.Now().Unix(),
2457
+		}
2458
+		service.CreateDrugOutConfig(config)
2459
+		c.ServeSuccessJSON(map[string]interface{}{
2460
+			"msg": 1,
2461
+		})
2462
+	} else if errcode == nil {
2463
+		service.UpdateDrugOutConfig(orgId, drug_out_open)
2464
+		c.ServeSuccessJSON(map[string]interface{}{
2465
+			"msg": 1,
2466
+		})
2467
+	}
2468
+}

+ 78 - 34
controllers/his_api_controller.go Vedi File

@@ -832,46 +832,90 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
832 832
 	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
833 833
 
834 834
 	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
835
-	//获取所有基础药
836
-	drugs, _ := service.GetAllDrugLibListSix(adminInfo.CurrentOrgId, houseConfig.DrugStorehouseOut)
837
-
838
-	_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
839
-	if config.ID > 0 && config.IsOpen == 1 {
840
-		for _, item := range drugs {
841
-			var index = 0
842
-			for _, subItem := range item.OtherDrugWarehouseInfo {
843
-				if index == 0 {
844
-					index = index + 1
845
-					if subItem.RetailPrice > 0 {
846
-						item.MinPrice = subItem.RetailPrice
835
+	if adminInfo.CurrentOrgId == 9675 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10215 {
836
+		//获取所有基础药
837
+		drugs, _ := service.GetAllDrugLibListSeven(adminInfo.CurrentOrgId, houseConfig.DrugStorehouseOut)
838
+		_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
839
+		if config.ID > 0 && config.IsOpen == 1 {
840
+			for _, item := range drugs {
841
+				var index = 0
842
+				for _, subItem := range item.OtherDrugWarehouseInfo {
843
+					if index == 0 {
844
+						index = index + 1
845
+						if subItem.RetailPrice > 0 {
846
+							item.MinPrice = subItem.RetailPrice
847
+						}
847 848
 					}
848 849
 				}
849 850
 			}
850 851
 		}
852
+
853
+		manufacturers, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
854
+		drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
855
+		efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
856
+		doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
857
+		//获取所有科室信息
858
+		department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
859
+		//获取诊断信息
860
+		sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
861
+		diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
862
+		additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
863
+
864
+		c.ServeSuccessJSON(map[string]interface{}{
865
+			"drugs":            drugs,
866
+			"advices_template": advices,
867
+			"drugways":         drugways,
868
+			"efs":              efs,
869
+			"doctors":          doctors,
870
+			"department":       department,
871
+			"sick":             sick,
872
+			"additions":        additions,
873
+			"diagnose":         diagnose,
874
+			"manufacturers":    manufacturers,
875
+		})
851 876
 	}
852
-	manufacturers, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
853
-	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
854
-	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
855
-	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
856
-	//获取所有科室信息
857
-	department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
858
-	//获取诊断信息
859
-	sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
860
-	diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
861
-	additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
877
+	if adminInfo.CurrentOrgId != 9675 && adminInfo.CurrentOrgId != 9671 && adminInfo.CurrentOrgId != 10215 {
878
+		//获取所有基础药
879
+		drugs, _ := service.GetAllDrugLibListSix(adminInfo.CurrentOrgId, houseConfig.DrugStorehouseOut)
880
+		_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
881
+		if config.ID > 0 && config.IsOpen == 1 {
882
+			for _, item := range drugs {
883
+				var index = 0
884
+				for _, subItem := range item.OtherDrugWarehouseInfo {
885
+					if index == 0 {
886
+						index = index + 1
887
+						if subItem.RetailPrice > 0 {
888
+							item.MinPrice = subItem.RetailPrice
889
+						}
890
+					}
891
+				}
892
+			}
893
+		}
862 894
 
863
-	c.ServeSuccessJSON(map[string]interface{}{
864
-		"drugs":            drugs,
865
-		"advices_template": advices,
866
-		"drugways":         drugways,
867
-		"efs":              efs,
868
-		"doctors":          doctors,
869
-		"department":       department,
870
-		"sick":             sick,
871
-		"additions":        additions,
872
-		"diagnose":         diagnose,
873
-		"manufacturers":    manufacturers,
874
-	})
895
+		manufacturers, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
896
+		drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
897
+		efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
898
+		doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
899
+		//获取所有科室信息
900
+		department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
901
+		//获取诊断信息
902
+		sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
903
+		diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
904
+		additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
905
+
906
+		c.ServeSuccessJSON(map[string]interface{}{
907
+			"drugs":            drugs,
908
+			"advices_template": advices,
909
+			"drugways":         drugways,
910
+			"efs":              efs,
911
+			"doctors":          doctors,
912
+			"department":       department,
913
+			"sick":             sick,
914
+			"additions":        additions,
915
+			"diagnose":         diagnose,
916
+			"manufacturers":    manufacturers,
917
+		})
918
+	}
875 919
 }
876 920
 
877 921
 func (c *HisApiController) CreateHisPrescription() {

+ 43 - 16
controllers/his_project_api_controller.go Vedi File

@@ -827,28 +827,55 @@ func (this *HisProjectApiController) DeleteProject() {
827 827
 func (this *HisProjectApiController) GetHisProject() {
828 828
 	adminUserInfo := this.GetAdminUserInfo()
829 829
 	orgId := adminUserInfo.CurrentOrgId
830
-	project, err := service.GetHisProject(orgId)
830
+
831 831
 	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
832
-	good_info, err := service.GetGoodInfoMationSix(orgId, houseConfig.StorehouseOutInfo)
833
-	_, config := service.FindHisStockPriceRecordByOrgId(orgId)
834
-	if config.ID > 0 && config.IsOpen == 1 {
835
-		//处理耗材不同批号价格问题
836
-		for _, item := range good_info {
837
-			if len(item.GoodSotckInfo) > 0 {
838
-				if item.GoodSotckInfo[0].Price > 0 {
839
-					item.PackingPrice = item.GoodSotckInfo[0].Price
832
+	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10215 {
833
+		project, err := service.GetHisProject(orgId)
834
+		good_info, err := service.GetGoodInfoMationSeven(orgId, houseConfig.StorehouseOutInfo)
835
+		_, config := service.FindHisStockPriceRecordByOrgId(orgId)
836
+		if config.ID > 0 && config.IsOpen == 1 {
837
+			//处理耗材不同批号价格问题
838
+			for _, item := range good_info {
839
+				if len(item.GoodSotckInfo) > 0 {
840
+					if item.GoodSotckInfo[0].Price > 0 {
841
+						item.PackingPrice = item.GoodSotckInfo[0].Price
842
+					}
840 843
 				}
841 844
 			}
842 845
 		}
846
+		if err != nil {
847
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
848
+			return
849
+		}
850
+		this.ServeSuccessJSON(map[string]interface{}{
851
+			"project":   project,
852
+			"good_info": good_info,
853
+		})
843 854
 	}
844
-	if err != nil {
845
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
846
-		return
855
+
856
+	if adminUserInfo.CurrentOrgId != 9671 && adminUserInfo.CurrentOrgId != 9675 && adminUserInfo.CurrentOrgId != 10215 {
857
+		project, err := service.GetHisProject(orgId)
858
+		good_info, err := service.GetGoodInfoMationSix(orgId, houseConfig.StorehouseOutInfo)
859
+		_, config := service.FindHisStockPriceRecordByOrgId(orgId)
860
+		if config.ID > 0 && config.IsOpen == 1 {
861
+			//处理耗材不同批号价格问题
862
+			for _, item := range good_info {
863
+				if len(item.GoodSotckInfo) > 0 {
864
+					if item.GoodSotckInfo[0].Price > 0 {
865
+						item.PackingPrice = item.GoodSotckInfo[0].Price
866
+					}
867
+				}
868
+			}
869
+		}
870
+		if err != nil {
871
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
872
+			return
873
+		}
874
+		this.ServeSuccessJSON(map[string]interface{}{
875
+			"project":   project,
876
+			"good_info": good_info,
877
+		})
847 878
 	}
848
-	this.ServeSuccessJSON(map[string]interface{}{
849
-		"project":   project,
850
-		"good_info": good_info,
851
-	})
852 879
 }
853 880
 
854 881
 func (this *HisProjectApiController) GetProjectTeam() {

+ 3 - 2
controllers/manager_center_api_controller.go Vedi File

@@ -2285,8 +2285,9 @@ func (c *ManagerCenterApiController) GetAllDrugList() {
2285 2285
 func (c *ManagerCenterApiController) GetSearchDrugList() {
2286 2286
 	keyword := c.GetString("keyword")
2287 2287
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2288
-	config, _ := service.GetAllStoreHouseConfig(orgId)
2289
-	list, err := service.GetSearchDrugListSix(keyword, orgId, config.DrugStorehouseOut)
2288
+	storehouse_id, _ := c.GetInt64("storehouse_id")
2289
+	list, err := service.GetSearchDrugListSix(keyword, orgId, storehouse_id)
2290
+
2290 2291
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2291 2292
 	dealerList, _ := service.GetAllDealerList(orgId)
2292 2293
 	if err == nil {

+ 60 - 9
controllers/mobile_api_controllers/dialysis_api_controller.go Vedi File

@@ -738,6 +738,7 @@ func (c *DialysisAPIController) PostDoubleCheck() {
738 738
 	vascular_access_desc := c.GetString("vascular_access_desc")
739 739
 	pipeline_connection_desc := c.GetString("pipeline_connection_desc")
740 740
 	collator, _ := c.GetInt64("collator", 0)
741
+	employee_number := c.GetString("employee_number")
741 742
 
742 743
 	if id <= 0 {
743 744
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -751,6 +752,15 @@ func (c *DialysisAPIController) PostDoubleCheck() {
751 752
 		return
752 753
 	}
753 754
 
755
+	if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10340 {
756
+
757
+		list, _ := service.GetRoleList(adminUserInfo.Org.Id, modifier)
758
+		if employee_number != list.JobNumber {
759
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorEmployeeNumber)
760
+			return
761
+		}
762
+	}
763
+
754 764
 	if len(recordDateStr) == 0 {
755 765
 		recordDateStr = time.Now().Format("2006-01-02")
756 766
 	}
@@ -800,6 +810,7 @@ func (c *DialysisAPIController) PostDoubleCheck() {
800 810
 		CreatedTime:                time.Now().Unix(),
801 811
 		CheckDate:                  recordDate.Unix(),
802 812
 		UpdatedTime:                time.Now().Unix(),
813
+		EmployeeNumber:             employee_number,
803 814
 	}
804 815
 
805 816
 	_, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -829,9 +840,9 @@ func (c *DialysisAPIController) PostDoubleCheck() {
829 840
 		doubleCheck.Modifier = modifier
830 841
 		doubleCheck.CreatedTime = check.CreatedTime
831 842
 		doubleCheck.ID = check.ID
843
+		doubleCheck.EmployeeNumber = employee_number
832 844
 		err := service.UpdateDoubleCheck(&doubleCheck)
833 845
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
834
-		fmt.Println("key233232232323232323", key)
835 846
 		redis := service.RedisClient()
836 847
 		defer redis.Close()
837 848
 		//清空key 值
@@ -1646,7 +1657,10 @@ func (c *DialysisAPIController) Finish() {
1646 1657
 	recordDateStr := c.GetString("record_date")
1647 1658
 	nurseID, _ := c.GetInt64("nurse")
1648 1659
 	end_time := c.GetString("end_time")
1649
-
1660
+	puncture_point_haematoma, _ := c.GetInt64("puncture_point_haematoma")
1661
+	internal_fistula := c.GetString("blood_access_internal_fistula")
1662
+	catheter := c.GetString("catheter")
1663
+	cruor := c.GetString("cruor")
1650 1664
 	if id <= 0 || nurseID <= 0 {
1651 1665
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1652 1666
 		return
@@ -1766,7 +1780,7 @@ func (c *DialysisAPIController) Finish() {
1766 1780
 
1767 1781
 	}
1768 1782
 
1769
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 {
1783
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 {
1770 1784
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1771 1785
 		if evaluation.SystolicBloodPressure == 0 {
1772 1786
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
@@ -1784,6 +1798,7 @@ func (c *DialysisAPIController) Finish() {
1784 1798
 			defer redis.Close()
1785 1799
 			fmt.Println(getNurseErr)
1786 1800
 		}
1801
+
1787 1802
 		if evaluation.DiastolicBloodPressure == 0 {
1788 1803
 			evaluation.DiastolicBloodPressure = fmonitorRecords.DiastolicBloodPressure
1789 1804
 			pres := models.PredialysisEvaluation{
@@ -1815,6 +1830,22 @@ func (c *DialysisAPIController) Finish() {
1815 1830
 			defer redis.Close()
1816 1831
 			fmt.Println(getNurseErr)
1817 1832
 		}
1833
+
1834
+		if evaluation.Temperature == 0 {
1835
+			evaluation.Temperature = fmonitorRecords.Temperature
1836
+			press := models.PredialysisEvaluation{
1837
+				Temperature: evaluation.Temperature,
1838
+			}
1839
+			getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1840
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1841
+
1842
+			redis := service.RedisClient()
1843
+			redis.Set(key, "", time.Second)
1844
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1845
+			redis.Set(keyOne, "", time.Second)
1846
+			defer redis.Close()
1847
+			fmt.Println(getNurseErr)
1848
+		}
1818 1849
 	}
1819 1850
 
1820 1851
 	if adminUserInfo.Org.Id == 9583 {
@@ -1933,7 +1964,7 @@ func (c *DialysisAPIController) Finish() {
1933 1964
 		return
1934 1965
 	}
1935 1966
 	if dialysisOrder.Stage == 1 {
1936
-		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
1967
+		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor)
1937 1968
 
1938 1969
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1939 1970
 		redis := service.RedisClient()
@@ -3153,6 +3184,10 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
3153 3184
 	nurseID, _ := c.GetInt64("nurse")
3154 3185
 	end_time := c.GetString("end_time")
3155 3186
 
3187
+	puncture_point_haematoma, _ := c.GetInt64("puncture_point_haematoma")
3188
+	blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
3189
+	catheter := c.GetString("catheter")
3190
+	cruor := c.GetString("cruor")
3156 3191
 	if record_id <= 0 || nurseID <= 0 {
3157 3192
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3158 3193
 		return
@@ -3190,11 +3225,15 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
3190 3225
 	//}
3191 3226
 
3192 3227
 	dialysisRecord := &models.DialysisOrder{
3193
-		ID:             record_id,
3194
-		UserOrgId:      adminUserInfo.Org.Id,
3195
-		EndTime:        endDate.Unix(),
3196
-		FinishNurse:    nurseID,
3197
-		FinishModifier: adminUserInfo.AdminUser.Id,
3228
+		ID:                         record_id,
3229
+		UserOrgId:                  adminUserInfo.Org.Id,
3230
+		EndTime:                    endDate.Unix(),
3231
+		FinishNurse:                nurseID,
3232
+		FinishModifier:             adminUserInfo.AdminUser.Id,
3233
+		PuncturePointHaematoma:     puncture_point_haematoma,
3234
+		BloodAccessInternalFistula: blood_access_internal_fistula,
3235
+		Catheter:                   catheter,
3236
+		Cruor:                      cruor,
3198 3237
 	}
3199 3238
 
3200 3239
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
@@ -5672,3 +5711,15 @@ func RemoveRepeatedCheckRecod(arr []*models.HisPrescriptionProject) (newArr []*m
5672 5711
 	}
5673 5712
 	return
5674 5713
 }
5714
+
5715
+func (this *DialysisAPIController) GetRoleList() {
5716
+
5717
+	admin_user_id, _ := this.GetInt64("admin_user_id")
5718
+	orgid := this.GetMobileAdminUserInfo().Org.Id
5719
+	list, err := service.GetRoleList(orgid, admin_user_id)
5720
+	fmt.Println(err)
5721
+	this.ServeSuccessJSON(map[string]interface{}{
5722
+		"list": list,
5723
+	})
5724
+	return
5725
+}

+ 2 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go Vedi File

@@ -165,4 +165,6 @@ func MobileAPIControllersRegisterRouters() {
165 165
 
166 166
 	beego.Router("/m/api/getmobileschedulelist", &DialysisAPIController{}, "Get:GetMobileScheduleList")
167 167
 
168
+	beego.Router("/m/api/getrolelist", &DialysisAPIController{}, "Get:GetRoleList")
169
+
168 170
 }

+ 19 - 15
controllers/mobile_api_controllers/patient_api_controller.go Vedi File

@@ -1160,23 +1160,27 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1160 1160
 					}
1161 1161
 					if prescribing_number_total <= total {
1162 1162
 						if medical.IsUse == 2 {
1163
-							service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1164
-							//查询默认仓库
1165
-							houseConfig, _ := service.GetAllStoreHouseConfig(medical.OrgId)
1166
-							//查询默认仓库剩余多少库存
1167
-							list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, medical.OrgId, medical.ID)
1168
-							var sum_count int64
1169
-							var sum_in_count int64
1170
-							for _, it := range list {
1171
-								baseDrug, _ := service.GetBaseDrugMedical(medical.ID)
1172
-								if it.MaxUnit == baseDrug.MaxUnit {
1173
-									it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1174
-									it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1163
+							config, _ := service.GetDrugOpenConfig(adminInfo.Org.Id)
1164
+							if config.IsOpen != 1 {
1165
+								service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1166
+								//查询默认仓库
1167
+								houseConfig, _ := service.GetAllStoreHouseConfig(medical.OrgId)
1168
+								//查询默认仓库剩余多少库存
1169
+								list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, medical.OrgId, medical.ID)
1170
+								var sum_count int64
1171
+								var sum_in_count int64
1172
+								for _, it := range list {
1173
+									baseDrug, _ := service.GetBaseDrugMedical(medical.ID)
1174
+									if it.MaxUnit == baseDrug.MaxUnit {
1175
+										it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1176
+										it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1177
+									}
1178
+									sum_count += it.StockMaxNumber + it.StockMinNumber
1179
+									sum_in_count += it.WarehousingCount
1175 1180
 								}
1176
-								sum_count += it.StockMaxNumber + it.StockMinNumber
1177
-								sum_in_count += it.WarehousingCount
1181
+								service.UpdateMedicalSumCount(medical.ID, sum_count, sum_in_count, medical.OrgId)
1178 1182
 							}
1179
-							service.UpdateMedicalSumCount(medical.ID, sum_count, sum_in_count, medical.OrgId)
1183
+
1180 1184
 						}
1181 1185
 					}
1182 1186
 				}

+ 25 - 22
controllers/patient_api_controller.go Vedi File

@@ -2124,30 +2124,33 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2124 2124
 				}
2125 2125
 				if prescribing_number_total <= total {
2126 2126
 					if medical.IsUse == 2 {
2127
-						service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
2128
-
2129
-						//查询默认仓库
2130
-						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2131
-						//查询默认仓库剩余多少库存
2132
-						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2133
-						var sum_count int64
2134
-						var sum_in_count int64
2135
-						for _, it := range list {
2136
-							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2137
-							if it.MaxUnit == baseDrug.MaxUnit {
2138
-								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2139
-								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2127
+						config, _ := service.GetDrugOpenConfig(adminUserInfo.CurrentOrgId)
2128
+						if config.IsOpen != 1 {
2129
+							service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
2130
+
2131
+							//查询默认仓库
2132
+							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2133
+							//查询默认仓库剩余多少库存
2134
+							list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2135
+							var sum_count int64
2136
+							var sum_in_count int64
2137
+							for _, it := range list {
2138
+								baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2139
+								if it.MaxUnit == baseDrug.MaxUnit {
2140
+									it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2141
+									it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2142
+								}
2143
+								sum_count += it.StockMaxNumber + it.StockMinNumber
2144
+								sum_in_count += it.WarehousingCount
2140 2145
 							}
2141
-							sum_count += it.StockMaxNumber + it.StockMinNumber
2142
-							sum_in_count += it.WarehousingCount
2146
+							service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
2147
+							break
2148
+							c.ServeSuccessJSON(map[string]interface{}{
2149
+								"msg":    "1",
2150
+								"advice": advice,
2151
+							})
2152
+							return
2143 2153
 						}
2144
-						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
2145
-						break
2146
-						c.ServeSuccessJSON(map[string]interface{}{
2147
-							"msg":    "1",
2148
-							"advice": advice,
2149
-						})
2150
-						return
2151 2154
 					}
2152 2155
 
2153 2156
 					if medical.IsUse == 1 {

+ 55 - 122
controllers/stock_in_api_controller.go Vedi File

@@ -4382,36 +4382,36 @@ func (this *StockManagerApiController) AddDrugInformation() {
4382 4382
 		drug.Dealer = dealer_id
4383 4383
 
4384 4384
 		delivery_way := goodNameM["delivery_way"].(string)
4385
-		if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
4386
-			err_log := models.ExportErrLog{
4387
-				LogType:    4,
4388
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4389
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
4390
-				Status:     1,
4391
-				CreateTime: time.Now().Unix(),
4392
-				UpdateTime: time.Now().Unix(),
4393
-				ExportTime: time.Now().Unix(),
4394
-			}
4395
-			service.CreateExportErrLog(&err_log)
4396
-			continue
4397
-		}
4385
+		//if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
4386
+		//	err_log := models.ExportErrLog{
4387
+		//		LogType:    4,
4388
+		//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4389
+		//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
4390
+		//		Status:     1,
4391
+		//		CreateTime: time.Now().Unix(),
4392
+		//		UpdateTime: time.Now().Unix(),
4393
+		//		ExportTime: time.Now().Unix(),
4394
+		//	}
4395
+		//	service.CreateExportErrLog(&err_log)
4396
+		//	continue
4397
+		//}
4398 4398
 
4399 4399
 		drug.DeliveryWay = delivery_way
4400 4400
 
4401 4401
 		execution_frequency := goodNameM["execution_frequency"].(string)
4402
-		if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
4403
-			err_log := models.ExportErrLog{
4404
-				LogType:    4,
4405
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4406
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
4407
-				Status:     1,
4408
-				CreateTime: time.Now().Unix(),
4409
-				UpdateTime: time.Now().Unix(),
4410
-				ExportTime: time.Now().Unix(),
4411
-			}
4412
-			service.CreateExportErrLog(&err_log)
4413
-			continue
4414
-		}
4402
+		//if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
4403
+		//	err_log := models.ExportErrLog{
4404
+		//		LogType:    4,
4405
+		//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4406
+		//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
4407
+		//		Status:     1,
4408
+		//		CreateTime: time.Now().Unix(),
4409
+		//		UpdateTime: time.Now().Unix(),
4410
+		//		ExportTime: time.Now().Unix(),
4411
+		//	}
4412
+		//	service.CreateExportErrLog(&err_log)
4413
+		//	continue
4414
+		//}
4415 4415
 
4416 4416
 		drug.ExecutionFrequency = execution_frequency
4417 4417
 
@@ -4419,74 +4419,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
4419 4419
 
4420 4420
 		drug.LmtUsedFlag = lmt_used_flags
4421 4421
 
4422
-		//medical_insurance_level := goodNameM["medical_insurance_level"].(string)
4423
-		//var medical_insurance_level_id int64
4424
-		//if len(medical_insurance_level) == 0 { //名字为空则生成一条导入错误日志
4425
-		//  err_log := models.ExportErrLog{
4426
-		//    LogType:    4,
4427
-		//    UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4428
-		//    ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的医保等级不能为空",
4429
-		//    Status:     1,
4430
-		//    CreateTime: time.Now().Unix(),
4431
-		//    UpdateTime: time.Now().Unix(),
4432
-		//    ExportTime: time.Now().Unix(),
4433
-		//  }
4434
-		//  service.CreateExportErrLog(&err_log)
4435
-		//  continue
4436
-		//}
4437
-		//var medicalInsuranceName = "医保等级"
4438
-		//medicalInsuranceConfig, _ := service.GetDrugDataConfig(0, medicalInsuranceName)
4439
-		//if len(medical_insurance_level) != 0 {
4440
-		//  _, errcodemedical := service.IsExistDicConfig(medicalInsuranceConfig.ID, medical_insurance_level, orgId)
4441
-		//  if errcodemedical == gorm.ErrRecordNotFound {
4442
-		//    medConfig, _ := service.GetLastDicConfig(medicalInsuranceConfig.ID, orgId)
4443
-		//    dataconfig := models.DictDataconfig{
4444
-		//      ParentId:       medicalInsuranceConfig.ID,
4445
-		//      Module:         "system",
4446
-		//      OrgId:          orgId,
4447
-		//      Name:           medical_insurance_level,
4448
-		//      FieldName:      "",
4449
-		//      Value:          medConfig.Value + 1,
4450
-		//      CreatedTime:    "",
4451
-		//      UpdatedTime:    "",
4452
-		//      CreateUserId:   adminUser.AdminUser.Id,
4453
-		//      Status:         1,
4454
-		//      Remark:         "",
4455
-		//      DeleteIdSystem: 0,
4456
-		//      Title:          "",
4457
-		//      Content:        "",
4458
-		//      Order:          0,
4459
-		//      Code:           "",
4460
-		//    }
4461
-		//    service.CreatedDicConfig(&dataconfig)
4462
-		//  }
4463
-		//}
4464
-
4465
-		//medicalInsuranceList, _ := service.GetParentDataConfig(medicalInsuranceConfig.ID, orgId)
4466
-		//for _, it := range medicalInsuranceList {
4467
-		//  if medical_insurance_level == it.Name {
4468
-		//    medical_insurance_level_id = int64(it.Value)
4469
-		//  }
4470
-		//}
4471
-		//drug.MedicalInsuranceLevel = medical_insurance_level_id
4472
-
4473
-		//unit_matrixing := goodNameM["unit_matrixing"].(string)
4474
-		//if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
4475
-		//  err_log := models.ExportErrLog{
4476
-		//    LogType:    4,
4477
-		//    UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4478
-		//    ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
4479
-		//    Status:     1,
4480
-		//    CreateTime: time.Now().Unix(),
4481
-		//    UpdateTime: time.Now().Unix(),
4482
-		//    ExportTime: time.Now().Unix(),
4483
-		//  }
4484
-		//  service.CreateExportErrLog(&err_log)
4485
-		//  continue
4486
-		//}
4487
-		//
4488
-		//drug.UnitMatrixing = unit_matrixing
4489
-
4490 4422
 		dataConfig, _ := service.GetDataConfigIsExist(0, units)
4491 4423
 		if len(drugDoseUnit) != 0 {
4492 4424
 			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
@@ -5045,36 +4977,36 @@ func (this *StockManagerApiController) AddDrugInformation() {
5045 4977
 			drug.Dealer = dealer_id
5046 4978
 
5047 4979
 			delivery_way := goodNameM["delivery_way"].(string)
5048
-			if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
5049
-				err_log := models.ExportErrLog{
5050
-					LogType:    4,
5051
-					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
5052
-					ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
5053
-					Status:     1,
5054
-					CreateTime: time.Now().Unix(),
5055
-					UpdateTime: time.Now().Unix(),
5056
-					ExportTime: time.Now().Unix(),
5057
-				}
5058
-				service.CreateExportErrLog(&err_log)
5059
-				continue
5060
-			}
4980
+			//if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
4981
+			//	err_log := models.ExportErrLog{
4982
+			//		LogType:    4,
4983
+			//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4984
+			//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
4985
+			//		Status:     1,
4986
+			//		CreateTime: time.Now().Unix(),
4987
+			//		UpdateTime: time.Now().Unix(),
4988
+			//		ExportTime: time.Now().Unix(),
4989
+			//	}
4990
+			//	service.CreateExportErrLog(&err_log)
4991
+			//	continue
4992
+			//}
5061 4993
 
5062 4994
 			drug.DeliveryWay = delivery_way
5063 4995
 
5064 4996
 			execution_frequency := goodNameM["execution_frequency"].(string)
5065
-			if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
5066
-				err_log := models.ExportErrLog{
5067
-					LogType:    4,
5068
-					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
5069
-					ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
5070
-					Status:     1,
5071
-					CreateTime: time.Now().Unix(),
5072
-					UpdateTime: time.Now().Unix(),
5073
-					ExportTime: time.Now().Unix(),
5074
-				}
5075
-				service.CreateExportErrLog(&err_log)
5076
-				continue
5077
-			}
4997
+			//if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
4998
+			//	err_log := models.ExportErrLog{
4999
+			//		LogType:    4,
5000
+			//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
5001
+			//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
5002
+			//		Status:     1,
5003
+			//		CreateTime: time.Now().Unix(),
5004
+			//		UpdateTime: time.Now().Unix(),
5005
+			//		ExportTime: time.Now().Unix(),
5006
+			//	}
5007
+			//	service.CreateExportErrLog(&err_log)
5008
+			//	continue
5009
+			//}
5078 5010
 
5079 5011
 			drug.ExecutionFrequency = execution_frequency
5080 5012
 
@@ -5379,6 +5311,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
5379 5311
 					DoseUnit:                    item.DoseUnit,
5380 5312
 					Dose:                        item.Dose,
5381 5313
 					MinNumber:                   item.MinNumber,
5314
+					IsUse:                       2,
5382 5315
 				}
5383 5316
 
5384 5317
 				//查询同种药品同种规格是否存在
@@ -5510,8 +5443,8 @@ func (this *StockManagerApiController) PostSearchGoodList() {
5510 5443
 	adminUserInfo := this.GetAdminUserInfo()
5511 5444
 	orgId := adminUserInfo.CurrentOrgId
5512 5445
 
5513
-	config, _ := service.GetAllStoreHouseConfig(orgId)
5514
-	list, _ := service.GetSearchGoodListSix(keyword, orgId, config.StorehouseOutInfo)
5446
+	storehouse_id, _ := this.GetInt64("storehouse_id")
5447
+	list, _ := service.GetSearchGoodListSix(keyword, orgId, storehouse_id)
5515 5448
 
5516 5449
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
5517 5450
 	dealerList, _ := service.GetAllDealerList(orgId)

+ 4 - 1
enums/error_code.go Vedi File

@@ -247,6 +247,8 @@ const ( // ErrorCode
247 247
 	ErrorCodeRecordFailedException = 300011
248 248
 
249 249
 	ErrorPsnNoEmpty = 310000
250
+
251
+	ErrorEmployeeNumber = 320000
250 252
 )
251 253
 
252 254
 var ErrCodeMsgs = map[int]string{
@@ -483,7 +485,8 @@ var ErrCodeMsgs = map[int]string{
483 485
 
484 486
 	ErrorCodeStockExced: "请先出库,执行失败",
485 487
 
486
-	ErrorPsnNoEmpty: "人员编码不能为空",
488
+	ErrorPsnNoEmpty:     "人员编码不能为空",
489
+	ErrorEmployeeNumber: "请输入正确的工号",
487 490
 }
488 491
 
489 492
 type SGJError struct {

+ 34 - 28
models/dialysis.go Vedi File

@@ -538,6 +538,7 @@ type DoubleCheck struct {
538 538
 	Modifier                   int64  `gorm:"column:modifier" json:"modifier"`
539 539
 	CheckTime                  int64  `gorm:"column:check_time" json:"check_time"`
540 540
 	FirstCheckTime             int64  `gorm:"column:first_check_time" json:"first_check_time"`
541
+	EmployeeNumber             string `gorm:"column:employee_number" json:"employee_number" form:"employee_number"`
541 542
 }
542 543
 
543 544
 func (DoubleCheck) TableName() string {
@@ -794,34 +795,38 @@ func (VmDialysisOrder) TableName() string {
794 795
 }
795 796
 
796 797
 type DialysisOrder struct {
797
-	ID                     int64         `gorm:"column:id" json:"id"`
798
-	DialysisDate           int64         `gorm:"column:dialysis_date" json:"dialysis_date"`
799
-	UserOrgId              int64         `gorm:"column:user_org_id" json:"user_org_id"`
800
-	PatientId              int64         `gorm:"column:patient_id" json:"patient_id"`
801
-	PrescriptionId         int64         `gorm:"column:prescription_id" json:"prescription_id"`
802
-	Stage                  int64         `gorm:"column:stage" json:"stage"`
803
-	Remark                 string        `gorm:"column:remark" json:"remark"`
804
-	BedID                  int64         `gorm:"column:bed_id" json:"bed_id"`
805
-	StartNurse             int64         `gorm:"column:start_nurse" json:"start_nurse"`
806
-	FinishNurse            int64         `gorm:"column:finish_nurse" json:"finish_nurse"`
807
-	Status                 int64         `gorm:"column:status" json:"status"`
808
-	CreatedTime            int64         `gorm:"column:created_time" json:"created_time"`
809
-	UpdatedTime            int64         `gorm:"column:updated_time" json:"updated_time"`
810
-	DeviceNumber           DeviceNumber  `gorm:"ForeignKey:BedID"`
811
-	StartTime              int64         `gorm:"column:start_time" json:"start_time"`
812
-	EndTime                int64         `gorm:"column:end_time" json:"end_time"`
813
-	PunctureNurse          int64         `gorm:"column:puncture_nurse" json:"puncture_nurse"`
814
-	Creator                int64         `gorm:"column:creator" json:"creator"`
815
-	Modifier               int64         `gorm:"column:modifier" json:"modifier"`
816
-	FinishCreator          int64         `gorm:"column:finish_creator" json:"finish_creator"`
817
-	FinishModifier         int64         `gorm:"column:finish_modifier" json:"finish_modifier"`
818
-	SchedualType           int64         `gorm:"column:schedual_type" json:"schedual_type"`
819
-	UserAdminRole          UserAdminRole `json:"role" gorm:"foreignkey:AdminUserId;AssociationForeignKey:StartNurse;"`
820
-	WashpipeNurse          int64         `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
821
-	ChangeNurse            int64         `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
822
-	DifficultPunctureNurse int64         `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
823
-	NewFistulaNurse        int64         `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
824
-	ZoneId                 int64         `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
798
+	ID                         int64         `gorm:"column:id" json:"id"`
799
+	DialysisDate               int64         `gorm:"column:dialysis_date" json:"dialysis_date"`
800
+	UserOrgId                  int64         `gorm:"column:user_org_id" json:"user_org_id"`
801
+	PatientId                  int64         `gorm:"column:patient_id" json:"patient_id"`
802
+	PrescriptionId             int64         `gorm:"column:prescription_id" json:"prescription_id"`
803
+	Stage                      int64         `gorm:"column:stage" json:"stage"`
804
+	Remark                     string        `gorm:"column:remark" json:"remark"`
805
+	BedID                      int64         `gorm:"column:bed_id" json:"bed_id"`
806
+	StartNurse                 int64         `gorm:"column:start_nurse" json:"start_nurse"`
807
+	FinishNurse                int64         `gorm:"column:finish_nurse" json:"finish_nurse"`
808
+	Status                     int64         `gorm:"column:status" json:"status"`
809
+	CreatedTime                int64         `gorm:"column:created_time" json:"created_time"`
810
+	UpdatedTime                int64         `gorm:"column:updated_time" json:"updated_time"`
811
+	DeviceNumber               DeviceNumber  `gorm:"ForeignKey:BedID"`
812
+	StartTime                  int64         `gorm:"column:start_time" json:"start_time"`
813
+	EndTime                    int64         `gorm:"column:end_time" json:"end_time"`
814
+	PunctureNurse              int64         `gorm:"column:puncture_nurse" json:"puncture_nurse"`
815
+	Creator                    int64         `gorm:"column:creator" json:"creator"`
816
+	Modifier                   int64         `gorm:"column:modifier" json:"modifier"`
817
+	FinishCreator              int64         `gorm:"column:finish_creator" json:"finish_creator"`
818
+	FinishModifier             int64         `gorm:"column:finish_modifier" json:"finish_modifier"`
819
+	SchedualType               int64         `gorm:"column:schedual_type" json:"schedual_type"`
820
+	UserAdminRole              UserAdminRole `json:"role" gorm:"foreignkey:AdminUserId;AssociationForeignKey:StartNurse;"`
821
+	WashpipeNurse              int64         `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
822
+	ChangeNurse                int64         `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
823
+	DifficultPunctureNurse     int64         `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
824
+	NewFistulaNurse            int64         `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
825
+	ZoneId                     int64         `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
826
+	PuncturePointHaematoma     int64         `gorm:"column:puncture_point_haematoma" json:"puncture_point_haematoma" form:"puncture_point_haematoma"`
827
+	BloodAccessInternalFistula string        `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula" form:"blood_access_internal_fistula"`
828
+	Catheter                   string        `gorm:"column:catheter" json:"catheter" form:"catheter"`
829
+	Cruor                      string        `gorm:"column:cruor" json:"cruor" form:"cruor"`
825 830
 }
826 831
 
827 832
 func (DialysisOrder) TableName() string {
@@ -982,6 +987,7 @@ type SgjUserAdminRole struct {
982 987
 	OrgName       string `gorm:"column:org_name" json:"org_name" form:"org_name"`
983 988
 	OrgLogo       string `gorm:"column:org_logo" json:"org_logo" form:"org_logo"`
984 989
 	Creator       int64  `gorm:"column:creator" json:"creator" form:"creator"`
990
+	JobNumber     string `gorm:"column:job_number" json:"job_number" form:"job_number"`
985 991
 }
986 992
 
987 993
 func (SgjUserAdminRole) TableName() string {

+ 22 - 0
models/drug_pharmacy_management_models.go Vedi File

@@ -213,3 +213,25 @@ type PharmacyConfig struct {
213 213
 func (PharmacyConfig) TableName() string {
214 214
 	return "xt_pharmacy_config"
215 215
 }
216
+
217
+type Pharmacy struct {
218
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
219
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
220
+	PatientId       int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
221
+	HisAdviceInfoId int64  `gorm:"column:his_advice_info_id" json:"his_advice_info_id" form:"his_advice_info_id"`
222
+	XtAdviceId      int64  `gorm:"column:xt_advice_id" json:"xt_advice_id" form:"xt_advice_id"`
223
+	HisOrXt         int64  `gorm:"column:his_or_xt" json:"his_or_xt" form:"his_or_xt"`
224
+	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
225
+	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
226
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
227
+	HisAdviceId     int64  `gorm:"column:his_advice_id" json:"his_advice_id" form:"his_advice_id"`
228
+	DrugId          int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
229
+	RecordDate      int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
230
+	OrdreNumber     string `gorm:"column:ordre_number" json:"ordre_number" form:"ordre_number"`
231
+	Creater         int64  `gorm:"column:creater" json:"creater" form:"creater"`
232
+	PrescriptionId  int64  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
233
+}
234
+
235
+func (Pharmacy) TableName() string {
236
+	return "xt_pharmacy"
237
+}

+ 75 - 0
models/drug_stock.go Vedi File

@@ -167,6 +167,7 @@ type DrugWarehouseOutInfo struct {
167 167
 	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
168 168
 	LastPrice               float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
169 169
 	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
170
+	PharmacyId              int64   `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
170 171
 }
171 172
 
172 173
 func (DrugWarehouseOutInfo) TableName() string {
@@ -414,8 +415,82 @@ type DrugFlow struct {
414 415
 	AdminUserId               int64                `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
415 416
 	LastPrice                 float64              `gorm:"column:last_price" json:"last_price" form:"last_price"`
416 417
 	StockCount                string               `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
418
+	PharmacyId                int64                `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
417 419
 }
418 420
 
419 421
 func (DrugFlow) TableName() string {
420 422
 	return "xt_drug_flow"
421 423
 }
424
+
425
+type DrugWarehouseOutInfoTenty struct {
426
+	ID                      int64       `gorm:"column:id" json:"id" form:"id"`
427
+	WarehouseOutId          int64       `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
428
+	DrugId                  int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
429
+	WarehousingOutTarget    int64       `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
430
+	Count                   int64       `gorm:"column:count" json:"count" form:"count"`
431
+	CountUnit               string      `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
432
+	Price                   float64     `gorm:"column:price" json:"price" form:"price"`
433
+	TotalPrice              float64     `gorm:"column:total_price" json:"total_price" form:"total_price"`
434
+	ProductDate             int64       `gorm:"column:product_date" json:"product_date" form:"product_date"`
435
+	ExpiryDate              int64       `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
436
+	Mtime                   int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
437
+	Ctime                   int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
438
+	Status                  int64       `gorm:"column:status" json:"status" form:"status"`
439
+	OrgId                   int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
440
+	Remark                  string      `gorm:"column:remark" json:"remark" form:"remark"`
441
+	IsCancel                int64       `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
442
+	WarehouseOutOrderNumber string      `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
443
+	Type                    int64       `gorm:"column:type" json:"type" form:"type"`
444
+	Dealer                  int64       `gorm:"column:dealer" json:"dealer" form:"dealer"`
445
+	Manufacturer            int64       `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
446
+	IsSys                   int64       `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
447
+	SysRecordTime           int64       `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
448
+	RetailPrice             float64     `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
449
+	RetailTotalPrice        float64     `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
450
+	Number                  string      `gorm:"column:number" json:"number" form:"number"`
451
+	BatchNumber             string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
452
+	PatientId               int64       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
453
+	WarehouseInfoId         int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
454
+	AdviceId                int64       `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
455
+	SupplyCancelOutId       int64       `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
456
+	SupplyWarehouseId       int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
457
+	IsSource                int64       `gorm:"column:is_source" json:"is_source" form:"is_source"`
458
+	StorehouseId            int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
459
+	SecondWarehouseInfoId   int64       `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
460
+	AdminUserId             int64       `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
461
+	LastPrice               float64     `gorm:"column:last_price" json:"last_price" form:"last_price"`
462
+	StockCount              string      `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
463
+	PharmacyId              int64       `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
464
+	BaseDrugLib             BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
465
+}
466
+
467
+func (DrugWarehouseOutInfoTenty) TableName() string {
468
+	return "xt_drug_warehouse_out_info"
469
+}
470
+
471
+type DrugWarehouseOutTwenty struct {
472
+	ID                        int64                     `gorm:"column:id" json:"id" form:"id"`
473
+	WarehouseOutOrderNumber   string                    `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
474
+	OperationTime             int64                     `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
475
+	Creater                   int64                     `gorm:"column:creater" json:"creater" form:"creater"`
476
+	OrgId                     int64                     `gorm:"column:org_id" json:"org_id" form:"org_id"`
477
+	Modifier                  int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
478
+	Remark                    string                    `gorm:"column:remark" json:"remark" form:"remark"`
479
+	Ctime                     int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
480
+	Mtime                     int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
481
+	Status                    int64                     `gorm:"column:status" json:"status" form:"status"`
482
+	WarehouseOutTime          int64                     `gorm:"column:warehouse_out_time" json:"warehouse_out_time" form:"warehouse_out_time"`
483
+	Dealer                    int64                     `gorm:"column:dealer" json:"dealer" form:"dealer"`
484
+	Manufacturer              int64                     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
485
+	Type                      int64                     `gorm:"column:type" json:"type" form:"type"`
486
+	IsSys                     int64                     `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
487
+	SupplyCancelOutId         int64                     `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
488
+	SupplyWarehouseId         int64                     `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
489
+	StorehouseId              int64                     `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
490
+	SecondWarehouseId         int64                     `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
491
+	DrugWarehouseOutInfoTenty DrugWarehouseOutInfoTenty `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutId"json:"xt_drug_warehouse_out_info" `
492
+}
493
+
494
+func (DrugWarehouseOutTwenty) TableName() string {
495
+	return "xt_drug_warehouse_out"
496
+}

+ 1 - 0
models/self_drug_models.go Vedi File

@@ -645,6 +645,7 @@ type StDrugWarehouseInfo struct {
645 645
 	LastPrice        string  `json:"last_price"`
646 646
 	PackingUnit      string  `json:"packing_unit"`
647 647
 	Dosage           int64   `json:"dosage"`
648
+	LimaxUnit        string  `json:"limax_unit"`
648 649
 }
649 650
 
650 651
 type VmDrugWarehouseOutInfo struct {

+ 14 - 0
models/stock_models.go Vedi File

@@ -1007,6 +1007,7 @@ type VmStockAdjustPrice struct {
1007 1007
 	UserName          string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
1008 1008
 	Number            string  `gorm:"column:number" json:"number" form:"number"`
1009 1009
 	Total             int64   `gorm:"column:total" json:"total" form:"total"`
1010
+	StorehouseId      int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1010 1011
 }
1011 1012
 
1012 1013
 type XtStockReportPrice struct {
@@ -1377,3 +1378,16 @@ type XtPrescriptionConfig struct {
1377 1378
 func (XtPrescriptionConfig) TableName() string {
1378 1379
 	return "xt_prescription_config"
1379 1380
 }
1381
+
1382
+type DrugOutConfig struct {
1383
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1384
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1385
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
1386
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1387
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1388
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1389
+}
1390
+
1391
+func (DrugOutConfig) TableName() string {
1392
+	return "xt_drug_out_config"
1393
+}

+ 1 - 1
service/device_service.go Vedi File

@@ -254,7 +254,7 @@ func GetDeviceCountForDeviceNumberID(orgID int64, deviceNumberID int64) (int, er
254 254
 
255 255
 func GetAllValidDeviceZones(orgID int64) ([]*models.DeviceZone, error) {
256 256
 	var zones []*models.DeviceZone
257
-	err := readDb.Model(&models.DeviceZone{}).Where("org_id = ? AND status = 1", orgID).Find(&zones).Error
257
+	err := readDb.Model(&models.DeviceZone{}).Where("org_id = ?", orgID).Find(&zones).Error
258 258
 	if err != nil {
259 259
 		return nil, err
260 260
 	}

+ 29 - 10
service/dialysis_service.go Vedi File

@@ -264,7 +264,7 @@ func AddSigleAssessmentBeforeDislysisRecord(assessmentBeforeDislysis *models.Pre
264 264
 
265 265
 func AddSigleDoubleCheck(check *models.DoubleCheck) (err error) {
266 266
 	tx := writeDb.Begin()
267
-	errors := tx.Model(&models.PredialysisEvaluation{}).Create(&check).Error
267
+	errors := tx.Model(&models.DoubleCheck{}).Create(&check).Error
268 268
 	if err != nil {
269 269
 		tx.Rollback()
270 270
 	}
@@ -324,6 +324,12 @@ func UpdatePredialysisEvaluationThree(predialysisevaluation *models.PredialysisE
324 324
 	return err
325 325
 }
326 326
 
327
+func UpdatePredialysisEvaluationFour(predialysisevaluation *models.PredialysisEvaluation, id int64) error {
328
+
329
+	err := writeDb.Model(&predialysisevaluation).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"temperature": predialysisevaluation.Temperature}).Error
330
+	return err
331
+}
332
+
327 333
 //修改
328 334
 func UpdateSummeRecord(treatmentSummary *models.TreatmentSummary) error {
329 335
 	err := writeDb.Save(&treatmentSummary).Error
@@ -525,12 +531,18 @@ func CreateDialysisRecord(id int64, orgId int64, record *models.DialysisOrder) e
525 531
 	return nil
526 532
 }
527 533
 
528
-func ModifyDialysisRecord(id int64, finishNurse int64, end_time int64, admin_user_id int64) error {
529
-	err := writeDb.Model(&models.DialysisOrder{}).Where("id = ? AND status = 1 ", id).Updates(map[string]interface{}{"updated_time": time.Now().Unix(), "stage": 2, "finish_nurse": finishNurse, "end_time": end_time, "finish_creator": admin_user_id, "finish_modifier": admin_user_id}).Error
534
+func ModifyDialysisRecord(id int64, finishNurse int64, end_time int64, admin_user_id int64, puncture_point_haematoma int64, internal_fistula string, catheter string, cruor string) error {
535
+	err := writeDb.Model(&models.DialysisOrder{}).Where("id = ? AND status = 1 ", id).Updates(map[string]interface{}{"updated_time": time.Now().Unix(), "stage": 2, "finish_nurse": finishNurse, "end_time": end_time, "finish_creator": admin_user_id, "finish_modifier": admin_user_id, "puncture_point_haematoma": puncture_point_haematoma, "blood_access_internal_fistula": internal_fistula, "catheter": catheter, "cruor": cruor}).Error
530 536
 	return err
531 537
 
532 538
 }
533 539
 
540
+//func ModifyDialysisRecord(id int64, finishNurse int64, end_time int64, admin_user_id int64) error {
541
+//  err := writeDb.Model(&models.DialysisOrder{}).Where("id = ? AND status = 1 ", id).Updates(map[string]interface{}{"updated_time": time.Now().Unix(), "stage": 2, "finish_nurse": finishNurse, "end_time": end_time, "finish_creator": admin_user_id, "finish_modifier": admin_user_id}).Error
542
+//  return err
543
+//
544
+//}
545
+
534 546
 func UpdateSolutionByPatientId(id int64) error {
535 547
 	err := writeDb.Model(&models.Patients{}).Where("id = ? AND status = 1 ", id).UpdateColumn("total_dialysis", gorm.Expr("total_dialysis + ?", 1)).Error
536 548
 	return err
@@ -673,8 +685,8 @@ func GetDialysisSchedualsOne(orgID int64, scheduleDate int64) ([]*MDialysisSched
673 685
 	var vms []*MDialysisScheduleVM
674 686
 	db := readDb.
675 687
 		Table("xt_schedule").
676
-		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
677
-		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
688
+		Preload("DeviceNumber", "org_id = ?", orgID).
689
+		Preload("DeviceNumber.Zone", "org_id = ?", orgID).
678 690
 		//Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).
679 691
 		//Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND  assessment_date = ?", orgID, scheduleDate).
680 692
 		//Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
@@ -699,7 +711,7 @@ func GetLastAcceptsAssessment(patient int64, orgId int64) (error, models.Receive
699 711
 func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partitionType int64, page int64, limit int64, start int64, end int64) (schedule []*models.DialysisSchedule, err error, total int64) {
700 712
 	db := readDb.Model(&models.MonitorDialysisSchedule{})
701 713
 	if start > 0 && end > 0 {
702
-		db = db.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
714
+		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
703 715
 			Preload("TreatmentMode", "status = 1").
704 716
 			Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date <=?", orgID, start, end).
705 717
 			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, start, end).
@@ -712,7 +724,7 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
712 724
 		db = db.Where("xt_schedule.status = 1 AND user_org_id = ?", orgID)
713 725
 	}
714 726
 	if schedulDate > 0 {
715
-		db = db.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
727
+		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
716 728
 			Preload("TreatmentMode", "status = 1").
717 729
 			Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date <=?", orgID, schedulDate, schedulDate).
718 730
 			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, schedulDate, schedulDate).
@@ -735,7 +747,7 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
735 747
 		db = db.Where("schedule_date <= ?", end)
736 748
 	}
737 749
 	if partitionType > 0 {
738
-		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ? and xt_device_number.status = 1", partitionType)
750
+		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ?", partitionType)
739 751
 		// db = db.Where("partition_id = ?", partitionType)
740 752
 	}
741 753
 	offset := (page - 1) * limit
@@ -803,7 +815,7 @@ func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, p
803 815
 		db = db.Where("schedule_date<=?", end)
804 816
 	}
805 817
 	if partitionType > 0 {
806
-		db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ? and d_n.status = 1", partitionType)
818
+		db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ?", partitionType)
807 819
 		// db = db.Where("partition_id = ?", partitionType)
808 820
 	}
809 821
 	var schedules []*models.DialysisSchedule
@@ -1385,7 +1397,14 @@ func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1385 1397
 func GetGoodInfoMationSix(orgid int64, storehouse_id int64) (goodinfo []*models.GoodInfo, err error) {
1386 1398
 
1387 1399
 	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count > 0 and status = 1 and storehouse_id = ?", storehouse_id).Find(&goodinfo).Error
1388
-	//err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodinfo).Error
1400
+
1401
+	return goodinfo, err
1402
+}
1403
+
1404
+func GetGoodInfoMationSeven(orgid int64, storehouse_id int64) (goodinfo []*models.GoodInfo, err error) {
1405
+
1406
+	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "status = 1 and storehouse_id = ?", storehouse_id).Find(&goodinfo).Error
1407
+
1389 1408
 	return goodinfo, err
1390 1409
 }
1391 1410
 

File diff suppressed because it is too large
+ 1564 - 0
service/drug_pharmacy_management_service.go


+ 8 - 1
service/his_service.go Vedi File

@@ -802,7 +802,14 @@ func GetAllDrugLibListSix(org_id int64, storehouse_id int64) (list []*BaseDrugLi
802 802
 		return db.Where("(status = 1 and stock_max_number > 0 and  storehouse_id = ? )  or  (status = 1  AND stock_min_number >0 and  storehouse_id = ?)", storehouse_id, storehouse_id)
803 803
 	}).Find(&list).Error
804 804
 
805
-	//err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Find(&list).Error
805
+	return
806
+}
807
+
808
+func GetAllDrugLibListSeven(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
809
+	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
810
+		return db.Where("(status = 1  and  storehouse_id = ? )  or  (status = 1 and  storehouse_id = ?)", storehouse_id, storehouse_id)
811
+	}).Find(&list).Error
812
+
806 813
 	return
807 814
 }
808 815
 

+ 7 - 1
service/mobile_dialysis_service.go Vedi File

@@ -2018,7 +2018,7 @@ func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2018 2018
 func ModifyFinishDialysisOrder(order *models.DialysisOrder) error {
2019 2019
 	tx := writeDb.Begin()
2020 2020
 	updateTime := time.Now().Unix()
2021
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"finish_nurse": order.FinishNurse, "updated_time": updateTime, "end_time": order.EndTime, "finish_modifier": order.FinishModifier}).Error
2021
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"finish_nurse": order.FinishNurse, "updated_time": updateTime, "end_time": order.EndTime, "finish_modifier": order.FinishModifier, "puncture_point_haematoma": order.PuncturePointHaematoma, "blood_access_internal_fistula": order.BloodAccessInternalFistula, "catheter": order.Catheter, "cruor": order.Cruor}).Error
2022 2022
 	if err != nil {
2023 2023
 		tx.Rollback()
2024 2024
 		return err
@@ -3619,3 +3619,9 @@ func GetMobileAutoReduce(orgID int64, scheduleDate int64) (auto []*models.Automa
3619 3619
 	err = readDb.Where("org_id = ? and status = 1 and record_time = ?", orgID, scheduleDate).Find(&auto).Error
3620 3620
 	return auto, err
3621 3621
 }
3622
+
3623
+func GetRoleList(orgid int64, admin_user_id int64) (models.SgjUserAdminRole, error) {
3624
+	role := models.SgjUserAdminRole{}
3625
+	err = readUserDb.Where("org_id = ? and admin_user_id = ? and status =1 ", orgid, admin_user_id).Find(&role).Error
3626
+	return role, err
3627
+}

+ 0 - 1
service/self_drug_service.go Vedi File

@@ -1116,7 +1116,6 @@ func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid i
1116 1116
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
1117 1117
 	}
1118 1118
 	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,x.storehouse_id,t.dose,t.dose_unit,t.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.last_stock_max_number,x.last_stock_min_number,x.inventory_type").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1119
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,t.dose,t.dose_unit,t.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.last_stock_max_number,x.last_stock_min_number,x.inventory_type").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Order("x.ctime desc").Offset(offset).Limit(limit).Scan(&list).Error
1120 1119
 	return list, total, err
1121 1120
 }
1122 1121
 

+ 297 - 8
service/stock_service.go Vedi File

@@ -2,6 +2,7 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"errors"
5 6
 	"fmt"
6 7
 	"github.com/jinzhu/gorm"
7 8
 	"strconv"
@@ -727,6 +728,11 @@ func CreateDrugFlowOne(flow models.DrugFlow) error {
727 728
 	return err
728 729
 }
729 730
 
731
+//func CreateDrugFlowOneTX(flow models.DrugFlow,tx *gorm.DB) error {
732
+//	err := tx.Create(&flow).Error
733
+//	return err
734
+//}
735
+
730 736
 func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice_id int64) (models.DrugAutomaticReduceDetail, error) {
731 737
 
732 738
 	detail := models.DrugAutomaticReduceDetail{}
@@ -1149,7 +1155,7 @@ func FindDrugWarehousingInfoByIdOne(id []string, org_id int64) (list []*models.S
1149 1155
 	if org_id > 0 {
1150 1156
 		db = db.Where("x.org_id = ?", org_id)
1151 1157
 	}
1152
-	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.price,x.remark,x.batch_number,x.batch_number,x.manufacturer,x.dealer,t.drug_name,t.last_price,t.dose_unit,t.dose,t.min_number,t.min_unit,t.max_unit,t.drug_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&list).Error
1158
+	err = db.Select("x.id,x.max_unit as limax_unit,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.price,x.remark,x.batch_number,x.batch_number,x.manufacturer,x.dealer,t.drug_name,t.last_price,t.dose_unit,t.dose,t.min_number,t.min_unit,t.max_unit,t.drug_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&list).Error
1153 1159
 	return list, err
1154 1160
 }
1155 1161
 
@@ -1291,9 +1297,13 @@ func FindAllCancelStockTotal(org_id int64) (total int64, err error) {
1291 1297
 func FindAllDrugCancelStockTotal(org_id int64) (total int64, err error) {
1292 1298
 	err = readDb.Model(&models.DrugCancelStock{}).Where("org_id = ?", org_id).Count(&total).Error
1293 1299
 	return total, err
1294
-
1295 1300
 }
1296 1301
 
1302
+//func FindAllDrugCancelStockTotalTX(org_id int64,tx *gorm.DB) (total int64, err error) {
1303
+//	err = tx.Model(&models.DrugCancelStock{}).Where("org_id = ?", org_id).Count(&total).Error
1304
+//	return total, err
1305
+//}
1306
+
1297 1307
 func FindAllReturnList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.SalesReturn, total int64, err error) {
1298 1308
 	db := readDb.Model(&models.SalesReturn{})
1299 1309
 	db = db.Where("xt_sales_return.org_id = ? AND xt_sales_return.status = 1 AND xt_sales_return.type = ?", orgId, types)
@@ -1805,6 +1815,12 @@ func GetLastDrugCancelStockById(orgid int64) (models.DrugCancelStock, error) {
1805 1815
 	return stock, err
1806 1816
 }
1807 1817
 
1818
+//func GetLastDrugCancelStockByIdTX(orgid int64,tx *gorm.DB) (models.DrugCancelStock, error) {
1819
+//	stock := models.DrugCancelStock{}
1820
+//	err := tx.Where("org_id = ? and status = 1", orgid).Last(&stock).Error
1821
+//	return stock, err
1822
+//}
1823
+
1808 1824
 func GetManufactureById(id int64) (models.Manufacturer, error) {
1809 1825
 	manufacturer := models.Manufacturer{}
1810 1826
 	err := XTReadDB().Model(&manufacturer).Where("id = ? and status = 1", id).Find(&manufacturer).Error
@@ -1820,9 +1836,13 @@ func GetDealerById(id int64) (models.Dealer, error) {
1820 1836
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1821 1837
 	err := writeDb.Create(&cancelStock).Error
1822 1838
 	return err
1823
-
1824 1839
 }
1825 1840
 
1841
+//func AddSigleDrugCancelStockTX(cancelStock *models.DrugCancelStock,tx *gorm.DB) error {
1842
+//	err := tx.Create(&cancelStock).Error
1843
+//	return err
1844
+//}
1845
+
1826 1846
 func CreateCancelStockInfo(cancelStockInfo []*models.CancelStockInfo) (err error) {
1827 1847
 	if len(cancelStockInfo) > 0 {
1828 1848
 		utx := writeDb.Begin()
@@ -1872,6 +1892,11 @@ func CreateCancelStockInfoTwo(info *models.DrugCancelStockInfo) error {
1872 1892
 	return err
1873 1893
 }
1874 1894
 
1895
+//func CreateCancelStockInfoTwoTX(info *models.DrugCancelStockInfo,tx *gorm.DB) error {
1896
+//	err := tx.Create(&info).Error
1897
+//	return err
1898
+//}
1899
+
1875 1900
 func GetLastStockInfoThree(drugid int64) (models.DrugCancelStockInfo, error) {
1876 1901
 
1877 1902
 	info := models.DrugCancelStockInfo{}
@@ -1880,6 +1905,12 @@ func GetLastStockInfoThree(drugid int64) (models.DrugCancelStockInfo, error) {
1880 1905
 	return info, err
1881 1906
 }
1882 1907
 
1908
+//func GetLastStockInfoThreeTX(drugid int64,tx *gorm.DB) (models.DrugCancelStockInfo, error) {
1909
+//	info := models.DrugCancelStockInfo{}
1910
+//	err := tx.Model(&info).Where("drug_id = ? and status = 1", drugid).Find(&info).Error
1911
+//	return info, err
1912
+//}
1913
+
1883 1914
 func CreateCancelStockInfoOne(info *models.CancelStockInfo) error {
1884 1915
 
1885 1916
 	err := XTWriteDB().Create(&info).Error
@@ -3488,11 +3519,22 @@ func GetAllManufacturerList(orgid int64) (list []*models.Manufacturer, err error
3488 3519
 	return list, err
3489 3520
 }
3490 3521
 
3522
+//func GetAllManufacturerListTX(orgid int64,tx *gorm.DB) (list []*models.Manufacturer, err error) {
3523
+//
3524
+//	err = tx.Where("org_id = ? and status = 1", orgid).Find(&list).Error
3525
+//	return list, err
3526
+//}
3527
+
3491 3528
 func GetAllDealerList(orgid int64) (list []*models.Dealer, err error) {
3492 3529
 
3493 3530
 	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&list).Error
3494 3531
 	return list, err
3495 3532
 }
3533
+
3534
+//func GetAllDealerListTX(orgid int64,tx *gorm.DB) (list []*models.Dealer, err error) {
3535
+//	err = tx.Where("org_id = ? and status = 1", orgid).Find(&list).Error
3536
+//	return list, err
3537
+//}
3496 3538
 func GetDealerByName(orgid int64, name string) (*models.Dealer, error) {
3497 3539
 	var dealer models.Dealer
3498 3540
 	var err error
@@ -4687,6 +4729,16 @@ func GetDrugWarehouseOut(warehouse_out_id []string) (out []*models.StDrugWarehou
4687 4729
 	return out, err
4688 4730
 }
4689 4731
 
4732
+func GetDrugWarehouseOutTenty(warehouse_out_id []string, orgid int64) (out []*models.DrugWarehouseOutTwenty, err error) {
4733
+
4734
+	err = XTReadDB().Where("id in(?)", warehouse_out_id).
4735
+		Preload("DrugWarehouseOutInfoTenty", func(db *gorm.DB) *gorm.DB {
4736
+			return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid)
4737
+		}).Find(&out).Error
4738
+
4739
+	return out, err
4740
+}
4741
+
4690 4742
 func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid_id int64) (models.WarehouseOutInfo, error) {
4691 4743
 
4692 4744
 	info := models.WarehouseOutInfo{}
@@ -5090,6 +5142,16 @@ func GetDrugWarehouseInfo(id int64) (models.XtDrugWarehouseInfo, error) {
5090 5142
 	return info, err
5091 5143
 }
5092 5144
 
5145
+//func GetDrugWarehouseInfoTX(id int64,tx *gorm.DB) (models.XtDrugWarehouseInfo, error) {
5146
+//	info := models.XtDrugWarehouseInfo{}
5147
+//	db := tx.Model(&info).Where("status = 1")
5148
+//	if id > 0 {
5149
+//		db = db.Where("id = ?", id)
5150
+//	}
5151
+//	err := db.Select("drug_id,warehousing_count,stock_max_number,stock_min_number").Find(&info).Error
5152
+//	return info, err
5153
+//}
5154
+
5093 5155
 func GetDrugWarehouseInfoPrescription(drugid int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
5094 5156
 
5095 5157
 	err = XTReadDB().Where("drug_id = ? and org_id =? and status = 1", drugid, orgid).Find(&info).Error
@@ -5170,6 +5232,11 @@ func UpdateDrugWarehouseInfo(info *models.XtDrugWarehouseInfo, id int64) error {
5170 5232
 	return err
5171 5233
 }
5172 5234
 
5235
+//func UpdateDrugWarehouseInfoTX(info *models.XtDrugWarehouseInfo, id int64,tx *gorm.DB) error {
5236
+//	err = tx.Model(&models.XtDrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", info.StockMaxNumber)).Error
5237
+//	return err
5238
+//}
5239
+
5173 5240
 func UpdateDrugWarehouseInfoOne(info *models.XtDrugWarehouseInfo, id int64) error {
5174 5241
 
5175 5242
 	//err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_min_number": info.StockMaxNumber}).Error
@@ -5179,6 +5246,11 @@ func UpdateDrugWarehouseInfoOne(info *models.XtDrugWarehouseInfo, id int64) erro
5179 5246
 	return err
5180 5247
 }
5181 5248
 
5249
+//func UpdateDrugWarehouseInfoOneTX(info *models.XtDrugWarehouseInfo, id int64,tx *gorm.DB) error {
5250
+//	err = tx.Model(&models.XtDrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", info.StockMinNumber)).Error
5251
+//	return err
5252
+//}
5253
+
5182 5254
 func GetLastCancelStockInfo(id int64) (models.DrugCancelStockInfo, error) {
5183 5255
 
5184 5256
 	info := models.DrugCancelStockInfo{}
@@ -5213,9 +5285,9 @@ func UpdatedDrugInfoOne(id int64, count int64) (err error) {
5213 5285
 	return err
5214 5286
 }
5215 5287
 
5216
-func UpdateWarehouseInfo(count int64, drugid int64, orgid int64) error {
5288
+func UpdateWarehouseInfo(count int64, drugid int64, orgid int64, warehouse_info_id int64) error {
5217 5289
 
5218
-	err := writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ?  and org_id = ? and status = 1", drugid, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
5290
+	err := writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ?  and org_id = ? and status = 1 and id = ?", drugid, orgid, warehouse_info_id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
5219 5291
 
5220 5292
 	return err
5221 5293
 }
@@ -5227,9 +5299,9 @@ func UpdateWarehouseInfoTwo(count int64, drugid int64, orgid int64) error {
5227 5299
 	return err
5228 5300
 }
5229 5301
 
5230
-func UpdateWarehouseInfoOne(count int64, drugid int64, orgid int64) error {
5302
+func UpdateWarehouseInfoOne(count int64, drugid int64, orgid int64, warehouse_info_id int64) error {
5231 5303
 
5232
-	err := writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ?  and org_id = ? and status = 1", drugid, orgid).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
5304
+	err := writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ?  and org_id = ? and status = 1 and id = ?", drugid, orgid, warehouse_info_id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
5233 5305
 	return err
5234 5306
 }
5235 5307
 
@@ -5347,6 +5419,12 @@ func UpdateDrugCancel(id int64) (models.DrugCancelStock, error) {
5347 5419
 	return stock, err
5348 5420
 }
5349 5421
 
5422
+//func UpdateDrugCancelTX(id int64,tx *gorm.DB) (models.DrugCancelStock, error) {
5423
+//	stock := models.DrugCancelStock{}
5424
+//	err := tx.Model(&stock).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
5425
+//	return stock, err
5426
+//}
5427
+
5350 5428
 func GetDrugWarehouseOutInfo(warehouse_info_id int64, drug_id int64) (info []*models.DrugWarehouseOutInfo, err error) {
5351 5429
 
5352 5430
 	db := XTReadDB().Model(&info)
@@ -5361,12 +5439,29 @@ func GetDrugWarehouseOutInfo(warehouse_info_id int64, drug_id int64) (info []*mo
5361 5439
 	return info, err
5362 5440
 }
5363 5441
 
5442
+//func GetDrugWarehouseOutInfoTX(warehouse_info_id int64, drug_id int64,tx *gorm.DB) (info []*models.DrugWarehouseOutInfo, err error) {
5443
+//	db := tx.Model(&info)
5444
+//	if warehouse_info_id > 0 {
5445
+//		db = db.Where("warehouse_info_id = ?", warehouse_info_id)
5446
+//	}
5447
+//	if drug_id > 0 {
5448
+//		db = db.Where("drug_id = ? and status =1", drug_id)
5449
+//	}
5450
+//	err = db.Find(&info).Error
5451
+//	return info, err
5452
+//}
5453
+
5364 5454
 func GetCancelDrugStockOutInfo(warehouse_info_id int64, drug_id int64) (info []*models.DrugCancelStockInfo, err error) {
5365 5455
 
5366 5456
 	err = XTReadDB().Model(&info).Where("batch_number_id =? and drug_id = ? and status = 1", warehouse_info_id, drug_id).Find(&info).Error
5367 5457
 	return info, err
5368 5458
 }
5369 5459
 
5460
+//func GetCancelDrugStockOutInfoTX(warehouse_info_id int64, drug_id int64,tx *gorm.DB) (info []*models.DrugCancelStockInfo, err error) {
5461
+//	err = tx.Model(&info).Where("batch_number_id =? and drug_id = ? and status = 1", warehouse_info_id, drug_id).Find(&info).Error
5462
+//	return info, err
5463
+//}
5464
+
5370 5465
 func GetTemplateSummary(orgid int64) (config []*models.Dataconfig, err error) {
5371 5466
 
5372 5467
 	err = XTReadDB().Model(&config).Where("module='template_summary' and parent_id=? and org_id in (?)", 0, orgid).Find(&config).Error
@@ -5712,7 +5807,6 @@ func GetInventoryDetailList(keyword string, limit int64, page int64, orgid int64
5712 5807
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
5713 5808
 	}
5714 5809
 	err = db.Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,x.expire_date,x.product_date,t.packing_unit,x.last_stock_count,x.type,x.inventory_type,x.stock_count,x.storehouse_id").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
5715
-	err = db.Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,x.expire_date,x.product_date,t.packing_unit,x.last_stock_count,x.type,x.inventory_type,x.stock_count,x.ctime").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Order("x.ctime desc").Offset(offset).Limit(limit).Scan(&list).Error
5716 5810
 	return list, total, err
5717 5811
 }
5718 5812
 
@@ -6408,6 +6502,11 @@ func UpdateMedicalSumCount(drug_id int64, sum_count int64, sum_in_count int64, o
6408 6502
 	return err
6409 6503
 }
6410 6504
 
6505
+//func UpdateMedicalSumCountTX(drug_id int64, sum_count int64, sum_in_count int64, orgid int64,tx *gorm.DB) error {
6506
+//	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
6507
+//	return err
6508
+//}
6509
+
6411 6510
 func UpdateGoodByGoodId(good_id int64, sum_count int64, sum_in_count int64, orgid int64) error {
6412 6511
 	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
6413 6512
 	return err
@@ -6630,3 +6729,193 @@ func FindPrescriptionConfigById(orgid int64) (models.XtPrescriptionConfig, error
6630 6729
 
6631 6730
 	return config, err
6632 6731
 }
6732
+
6733
+func UpdateWarehouseInfoTwentyFive(maxNumber int64, drugid int64, orgID int64, storehouse_id int64, drup *models.XtBaseDrug) (err error) {
6734
+
6735
+	var deliver_number int64 = 0
6736
+	var stock_number int64 = 0
6737
+
6738
+	deliver_number = maxNumber
6739
+	// 根据先进先出原则,查询最先入库的批次,进行出库
6740
+	// 如果没有对应的库存,则报错
6741
+	//开启事物
6742
+
6743
+	warehouse, err := FindLastDrugWarehousingInfoByID(drugid, storehouse_id)
6744
+
6745
+	if err != nil {
6746
+		return err
6747
+	}
6748
+
6749
+	// 将该批次的剩余库存数量转换为拆零数量
6750
+	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
6751
+
6752
+	// 当库存数量大于或等于出库数量的话,则正常出库该批次
6753
+	if stock_number >= deliver_number {
6754
+
6755
+		var maxNumber int64 = 0
6756
+		var minNumber int64 = 0
6757
+		var stock_max_number int64 = 0
6758
+		stock_max_number = warehouse.StockMaxNumber
6759
+
6760
+		maxNumber = deliver_number / drup.MinNumber
6761
+		minNumber = deliver_number % drup.MinNumber
6762
+
6763
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
6764
+			minNumber = maxNumber
6765
+		}
6766
+
6767
+		if drup.MaxUnit != drup.MinUnit {
6768
+			if warehouse.StockMaxNumber < maxNumber && warehouse.StockMinNumber < minNumber {
6769
+				return errors.New("库存数量不足")
6770
+			}
6771
+		}
6772
+
6773
+		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
6774
+
6775
+		if warehouse.StockMaxNumber < 0 {
6776
+			warehouse.StockMaxNumber = 0
6777
+		}
6778
+		if warehouse.StockMinNumber < 0 {
6779
+			warehouse.StockMinNumber = 0
6780
+		}
6781
+
6782
+		warehouse.Mtime = time.Now().Unix()
6783
+
6784
+		if warehouse.StockMinNumber < minNumber {
6785
+
6786
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
6787
+			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
6788
+		} else {
6789
+			if minNumber > 0 {
6790
+				if minNumber == 1 && maxNumber == 1 && drup.MaxUnit != drup.MinUnit {
6791
+					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
6792
+				} else {
6793
+					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
6794
+				}
6795
+			}
6796
+
6797
+			if minNumber == 0 && maxNumber != 1 {
6798
+				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
6799
+			}
6800
+
6801
+		}
6802
+
6803
+		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
6804
+			warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
6805
+			if warehouse.StockMinNumber == 0 {
6806
+				warehouse.StockMaxNumber = stock_max_number
6807
+			}
6808
+		}
6809
+
6810
+		if drup.MaxUnit != drup.MinUnit {
6811
+			if warehouse.StockMaxNumber < 0 && warehouse.StockMinNumber < 0 {
6812
+				return errors.New("库存数量不足")
6813
+			}
6814
+		}
6815
+		if warehouse.StockMinNumber <= 0 {
6816
+			warehouse.StockMinNumber = 0
6817
+		}
6818
+
6819
+		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
6820
+		fmt.Println(errThree)
6821
+
6822
+		//查询默认仓库
6823
+		houseConfig, _ := GetAllStoreHouseConfig(orgID)
6824
+		//查询默认仓库剩余多少库存
6825
+		list, _ := GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgID, warehouse.DrugId)
6826
+		var sum_count int64
6827
+		var sum_in_count int64
6828
+		for _, it := range list {
6829
+			baseDrug, _ := GetBaseDrugMedical(it.DrugId)
6830
+			if it.MaxUnit == baseDrug.MaxUnit {
6831
+				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
6832
+				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
6833
+				sum_count += it.StockMaxNumber + it.StockMinNumber
6834
+				sum_in_count += it.WarehousingCount
6835
+			}
6836
+		}
6837
+		UpdateMedicalSumCount(warehouse.DrugId, sum_count, sum_in_count, orgID)
6838
+
6839
+		return nil
6840
+
6841
+	} else {
6842
+
6843
+		warehouse.StockMaxNumber = 0
6844
+		warehouse.StockMinNumber = 0
6845
+		warehouse.Mtime = time.Now().Unix()
6846
+
6847
+		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
6848
+		fmt.Println(errThree)
6849
+
6850
+		//查询默认仓库
6851
+		houseConfig, _ := GetAllStoreHouseConfig(orgID)
6852
+		//查询默认仓库剩余多少库存
6853
+		list, _ := GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgID, warehouse.DrugId)
6854
+		var sum_count int64
6855
+		var sum_in_count int64
6856
+		for _, it := range list {
6857
+			baseDrug, _ := GetBaseDrugMedical(it.DrugId)
6858
+			if it.MaxUnit == baseDrug.MaxUnit {
6859
+				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
6860
+				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
6861
+				sum_count += it.StockMaxNumber + it.StockMinNumber
6862
+				sum_in_count += it.WarehousingCount
6863
+			}
6864
+		}
6865
+		UpdateMedicalSumCount(warehouse.DrugId, sum_count, sum_in_count, orgID)
6866
+		if errThree != nil {
6867
+			return errThree
6868
+		}
6869
+		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
6870
+		prescribingNumber_two_temp := deliver_number - stock_number
6871
+
6872
+		UpdateWarehouseInfoTwentyFive(prescribingNumber_two_temp, drugid, orgID, storehouse_id, drup)
6873
+	}
6874
+	return
6875
+}
6876
+
6877
+func UpdateWarehouseInfoTentyFour(count int64, id int64) error {
6878
+
6879
+	err := writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("id = ? status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
6880
+
6881
+	return err
6882
+}
6883
+
6884
+func UpdateWarehouseInfoTentyThree(count int64, id int64) error {
6885
+
6886
+	err := writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("id = ? status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
6887
+
6888
+	return err
6889
+}
6890
+
6891
+func GetDrugOpenConfig(orgid int64) (*models.DrugOutConfig, error) {
6892
+
6893
+	config := models.DrugOutConfig{}
6894
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6895
+	if err == gorm.ErrRecordNotFound {
6896
+		return nil, err
6897
+	}
6898
+	if err != nil {
6899
+		return nil, err
6900
+	}
6901
+	return &config, nil
6902
+}
6903
+
6904
+func CreateDrugOutConfig(config models.DrugOutConfig) error {
6905
+
6906
+	err := XTWriteDB().Create(&config).Error
6907
+	return err
6908
+}
6909
+
6910
+func UpdateDrugOutConfig(orgid int64, drug_out_open int64) error {
6911
+
6912
+	err := XTWriteDB().Model(&models.DrugOutConfig{}).Where("user_org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_open": drug_out_open}).Error
6913
+	return err
6914
+}
6915
+
6916
+func FindDrugOutConfigById(orgid int64) (models.DrugOutConfig, error) {
6917
+
6918
+	config := models.DrugOutConfig{}
6919
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6920
+	return config, err
6921
+}