Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
aed0706f32

+ 75 - 151
controllers/base_api_controller.go View File

@@ -2,15 +2,10 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
-	"XT_New/models"
6 5
 	"XT_New/service"
7
-	"encoding/json"
8
-	"os"
9
-	"path"
10
-	"runtime"
6
+	"fmt"
11 7
 	"strconv"
12 8
 	"strings"
13
-	"time"
14 9
 )
15 10
 
16 11
 type BaseAPIController struct {
@@ -74,72 +69,56 @@ type BaseAuthAPIController struct {
74 69
 func (this *BaseAuthAPIController) Prepare() {
75 70
 	this.BaseAPIController.Prepare()
76 71
 	if this.GetAdminUserInfo() == nil {
77
-		var userAdmin models.AdminUser
78
-		userAdmin.Id = 1448
79
-		userAdmin.Mobile = "13318599895"
80
-
81
-		userAdmin.Id = 597
82
-		userAdmin.Mobile = "19874122664"
83
-		userAdmin.IsSuperAdmin = false
84
-		userAdmin.Status = 1
85
-		userAdmin.CreateTime = 1530786071
86
-		userAdmin.ModifyTime = 1530786071
87
-		var subscibe models.ServeSubscibe
88
-		subscibe.ID = 1
89
-		subscibe.OrgId = 10215
90
-		subscibe.PeriodStart = 1538035409
91
-		subscibe.PeriodEnd = 1569571409
92
-		subscibe.State = 1
93
-		subscibe.Status = 1
94
-		subscibe.CreatedTime = 1538035409
95
-		subscibe.UpdatedTime = 1538035409
96
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
97
-		subscibes[4] = &subscibe
98
-		var adminUserInfo service.AdminUserInfo
99
-		adminUserInfo.CurrentOrgId = 10215
100
-		adminUserInfo.CurrentAppId = 4
101
-		adminUserInfo.AdminUser = &userAdmin
102
-		adminUserInfo.Subscibes = subscibes
103
-		this.SetSession("admin_user_info", &adminUserInfo)
104
-
105
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
106
-		//this.StopRun()
72
+		//var userAdmin models.AdminUser
73
+		//userAdmin.Id = 1448
74
+		//userAdmin.Mobile = "13318599895"
75
+		//
76
+		//userAdmin.Id = 597
77
+		//userAdmin.Mobile = "19874122664"
78
+		//userAdmin.IsSuperAdmin = false
79
+		//userAdmin.Status = 1
80
+		//userAdmin.CreateTime = 1530786071
81
+		//userAdmin.ModifyTime = 1530786071
82
+		//var subscibe models.ServeSubscibe
83
+		//subscibe.ID = 1
84
+		//subscibe.OrgId = 3877
85
+		//subscibe.PeriodStart = 1538035409
86
+		//subscibe.PeriodEnd = 1569571409
87
+		//subscibe.State = 1
88
+		//subscibe.Status = 1
89
+		//subscibe.CreatedTime = 1538035409
90
+		//subscibe.UpdatedTime = 1538035409
91
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
+		//subscibes[4] = &subscibe
93
+		//var adminUserInfo service.AdminUserInfo
94
+		//adminUserInfo.CurrentOrgId = 3877
95
+		//adminUserInfo.CurrentAppId = 4
96
+		//adminUserInfo.AdminUser = &userAdmin
97
+		//adminUserInfo.Subscibes = subscibes
98
+		//this.SetSession("admin_user_info", &adminUserInfo)
99
+
100
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
+		this.StopRun()
107 102
 
108 103
 	}
109 104
 
110 105
 	adminUserInfo := this.GetAdminUserInfo()
111 106
 
112 107
 	if this.Ctx.Request.Header.Get("Permission") == "2" {
113
-		err_msgs := LoadErrMsgConfig("./err_msg.json").Msgs
114
-
115 108
 		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
116 109
 		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
117 110
 
118 111
 			isPermission := false
119 112
 			adminUserInfo := this.GetAdminUserInfo()
120
-
121
-			redisClient := service.RedisClient()
122
-			defer redisClient.Close()
123
-			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 64) + "_" + strconv.FormatInt(adminUserInfo.AdminUser.Id, 64) + "_role_ids"
124
-			result, _ := redisClient.Get(key).Result()
125
-			var role models.App_Role
113
+			//该机构下该用户有多少个
114
+			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
126 115
 			var roles []string
127
-			if len(result) == 0 {
128
-				//该机构下该用户有多少个
129
-				role, _ = service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
130
-				redisClient.Set(key, role, time.Second*60*60*18)
131
-				if len(role.RoleIds) > 0 { //该用户没有设置角色
132
-					roles = strings.Split(role.RoleIds, ",")
133
-				}
116
+			if len(role.RoleIds) <= 0 { //该用户没有设置角色
117
+
134 118
 			} else {
135
-				json.Unmarshal([]byte(result), &role)
136
-				if len(role.RoleIds) > 0 { //该用户没有设置角色
137
-					roles = strings.Split(role.RoleIds, ",")
138
-				}
119
+				roles = strings.Split(role.RoleIds, ",")
139 120
 			}
140
-
141
-			//key := strconv.FormatInt(role_id, 64) + "_" + strconv.FormatInt(adminUserInfo.AdminUser.Id, 64) + "_role_ids"
142
-			//result, _ := redisClient.Get(key).Result()
121
+			fmt.Println(roles)
143 122
 
144 123
 			//获取该用户下所有角色的权限总集
145 124
 			var userRolePurviews string
@@ -155,7 +134,7 @@ func (this *BaseAuthAPIController) Prepare() {
155 134
 			}
156 135
 			//该用户所拥有角色的权限的总集
157 136
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
158
-
137
+			fmt.Println(userRolePurviewsArr)
159 138
 			//系统所记录的权限列表
160 139
 			allPermission, _ := service.GetAllFunctionPurview()
161 140
 
@@ -176,13 +155,7 @@ func (this *BaseAuthAPIController) Prepare() {
176 155
 						}
177 156
 					}
178 157
 					if !isPermission {
179
-						var msg string
180
-						for _, item := range err_msgs {
181
-							if strings.Index(item.Url, strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode")) != -1 {
182
-								msg = item.ErrMsg
183
-							}
184
-						}
185
-						//msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
158
+						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
186 159
 						json := make(map[string]interface{})
187 160
 						json["msg"] = msg
188 161
 						json["code"] = 0
@@ -192,39 +165,25 @@ func (this *BaseAuthAPIController) Prepare() {
192 165
 						this.StopRun()
193 166
 					}
194 167
 				}
195
-
196 168
 			}
197 169
 		}
198 170
 	}
199 171
 
200 172
 	if this.Ctx.Request.Header.Get("Permission") == "3" {
201
-		err_msgs := LoadErrMsgConfig("./err_msg.json").Msgs
202
-
203 173
 		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
204 174
 		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
205 175
 
206 176
 			isPermission := false
207 177
 			adminUserInfo := this.GetAdminUserInfo()
208 178
 			//该机构下该用户有多少个
209
-			redisClient := service.RedisClient()
210
-			defer redisClient.Close()
211
-			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 64) + "_" + strconv.FormatInt(adminUserInfo.AdminUser.Id, 64) + "_role_ids"
212
-			result, _ := redisClient.Get(key).Result()
213
-			var role models.App_Role
179
+			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
214 180
 			var roles []string
215
-			if len(result) == 0 {
216
-				//该机构下该用户有多少个
217
-				role, _ = service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
218
-				redisClient.Set(key, role, time.Second*60*60*18)
219
-				if len(role.RoleIds) > 0 { //该用户没有设置角色
220
-					roles = strings.Split(role.RoleIds, ",")
221
-				}
181
+			if len(role.RoleIds) <= 0 { //该用户没有设置角色
182
+
222 183
 			} else {
223
-				json.Unmarshal([]byte(result), &role)
224
-				if len(role.RoleIds) > 0 { //该用户没有设置角色
225
-					roles = strings.Split(role.RoleIds, ",")
226
-				}
184
+				roles = strings.Split(role.RoleIds, ",")
227 185
 			}
186
+			fmt.Println(roles)
228 187
 
229 188
 			//获取该用户下所有角色的权限总集
230 189
 			var userRolePurviews string
@@ -240,6 +199,7 @@ func (this *BaseAuthAPIController) Prepare() {
240 199
 			}
241 200
 			//该用户所拥有角色的权限的总集
242 201
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
202
+			fmt.Println(userRolePurviewsArr)
243 203
 			//系统所记录的权限列表
244 204
 			allPermission, _ := service.GetAllFunctionPurview()
245 205
 
@@ -258,13 +218,7 @@ func (this *BaseAuthAPIController) Prepare() {
258 218
 						}
259 219
 					}
260 220
 					if !isPermission {
261
-						var msg string
262
-						for _, item := range err_msgs {
263
-							if strings.Index(item.Url, strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode")) != -1 {
264
-								msg = item.ErrMsg
265
-							}
266
-						}
267
-						//msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
221
+						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
268 222
 						json := make(map[string]interface{})
269 223
 						json["msg"] = msg
270 224
 						json["code"] = 0
@@ -361,35 +315,35 @@ type BaseServeAPIController struct {
361 315
 func (this *BaseServeAPIController) Prepare() {
362 316
 	this.BaseAPIController.Prepare()
363 317
 	if this.GetAdminUserInfo() == nil {
364
-		var userAdmin models.AdminUser
365
-		userAdmin.Id = 1448
366
-		userAdmin.Mobile = "13318599895"
367
-
368
-		userAdmin.Id = 597
369
-		userAdmin.Mobile = "19874122664"
370
-		userAdmin.IsSuperAdmin = false
371
-		userAdmin.Status = 1
372
-		userAdmin.CreateTime = 1530786071
373
-		userAdmin.ModifyTime = 1530786071
374
-		var subscibe models.ServeSubscibe
375
-		subscibe.ID = 1
376
-		subscibe.OrgId = 10215
377
-		subscibe.PeriodStart = 1538035409
378
-		subscibe.PeriodEnd = 1569571409
379
-		subscibe.State = 1
380
-		subscibe.Status = 1
381
-		subscibe.CreatedTime = 1538035409
382
-		subscibe.UpdatedTime = 1538035409
383
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
384
-		subscibes[4] = &subscibe
385
-		var adminUserInfo service.AdminUserInfo
386
-		adminUserInfo.CurrentOrgId = 10215
387
-		adminUserInfo.CurrentAppId = 4
388
-		adminUserInfo.AdminUser = &userAdmin
389
-		adminUserInfo.Subscibes = subscibes
390
-		this.SetSession("admin_user_info", &adminUserInfo)
391
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
392
-		//this.StopRun()
318
+		//var userAdmin models.AdminUser
319
+		//userAdmin.Id = 1448
320
+		//userAdmin.Mobile = "13318599895"
321
+		//
322
+		//userAdmin.Id = 597
323
+		//userAdmin.Mobile = "19874122664"
324
+		//userAdmin.IsSuperAdmin = false
325
+		//userAdmin.Status = 1
326
+		//userAdmin.CreateTime = 1530786071
327
+		//userAdmin.ModifyTime = 1530786071
328
+		//var subscibe models.ServeSubscibe
329
+		//subscibe.ID = 1
330
+		//subscibe.OrgId = 3877
331
+		//subscibe.PeriodStart = 1538035409
332
+		//subscibe.PeriodEnd = 1569571409
333
+		//subscibe.State = 1
334
+		//subscibe.Status = 1
335
+		//subscibe.CreatedTime = 1538035409
336
+		//subscibe.UpdatedTime = 1538035409
337
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
+		//subscibes[4] = &subscibe
339
+		//var adminUserInfo service.AdminUserInfo
340
+		//adminUserInfo.CurrentOrgId = 3877
341
+		//adminUserInfo.CurrentAppId = 4
342
+		//adminUserInfo.AdminUser = &userAdmin
343
+		//adminUserInfo.Subscibes = subscibes
344
+		//this.SetSession("admin_user_info", &adminUserInfo)
345
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
+		this.StopRun()
393 347
 	}
394 348
 
395 349
 	//if adminUserInfo.AppRole != nil {
@@ -426,33 +380,3 @@ func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
426 380
 	}
427 381
 	return
428 382
 }
429
-
430
-type ErrMsgConfig struct {
431
-	Msgs []*models.ErrMsg "json:msg"
432
-}
433
-
434
-func LoadErrMsgConfig(dataFile string) *ErrMsgConfig {
435
-	var config ErrMsgConfig
436
-	_, filename, _, _ := runtime.Caller(1)
437
-	datapath := path.Join(path.Dir(filename), dataFile)
438
-	config_file, err := os.Open(datapath)
439
-	if err != nil {
440
-		emit("Failed to open config file '%s': %s\n", datapath, err)
441
-		return &config
442
-	}
443
-	fi, _ := config_file.Stat()
444
-	buffer := make([]byte, fi.Size())
445
-	_, err = config_file.Read(buffer)
446
-	buffer, err = StripComments(buffer) //去掉注释
447
-	if err != nil {
448
-		emit("Failed to strip comments from json: %s\n", err)
449
-		return &config
450
-	}
451
-	buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
452
-	err = json.Unmarshal(buffer, &config)         //解析json格式数据
453
-	if err != nil {
454
-		emit("Failed unmarshalling json: %s\n", err)
455
-		return &config
456
-	}
457
-	return &config
458
-}

+ 11 - 6
controllers/device_api_controller.go View File

@@ -883,6 +883,17 @@ func (this *DeviceAPIController) ModifyNumber() {
883 883
 		return
884 884
 	}
885 885
 	updateErr := service.UpdateDeviceNumber(number)
886
+
887
+	//查询该床位是否绑定设备
888
+	_, errcode := service.GetAddMacherByBedId(id, adminInfo.CurrentOrgId)
889
+	if errcode == nil {
890
+		//修改设备管理机器分区
891
+		addmacher := models.DeviceAddmacher{
892
+			ZoneId: zoneID,
893
+		}
894
+		service.UpdateAddmacherByBedId(id, addmacher)
895
+	}
896
+
886 897
 	if updateErr != nil {
887 898
 		this.ErrorLog("修改机号失败:%v", updateErr)
888 899
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
@@ -1135,17 +1146,11 @@ func (this *DeviceAPIController) GetAllSubregion() {
1135 1146
 func (this *DeviceAPIController) GetAllMachineInfo() {
1136 1147
 
1137 1148
 	page, _ := this.GetInt64("page")
1138
-	fmt.Println("page是什么", page)
1139 1149
 	limit, _ := this.GetInt64("limit")
1140
-	fmt.Println("limit是什么", limit)
1141 1150
 	searchKey := this.GetString("searchKey")
1142
-	fmt.Println("searcheKey", searchKey)
1143 1151
 	zoneid, _ := this.GetInt64("zoneid")
1144
-	fmt.Println("区号id", zoneid)
1145 1152
 	equipmentid, _ := this.GetInt64("equipmentid")
1146
-	fmt.Println("equipmentid", equipmentid)
1147 1153
 	statusid, _ := this.GetInt64("statusid")
1148
-	fmt.Println("statusid", statusid)
1149 1154
 	adminUserInfo := this.GetAdminUserInfo()
1150 1155
 	orgid := adminUserInfo.CurrentOrgId
1151 1156
 	addmahcer, total, err := service.GetAllMachineInfo(page, limit, searchKey, zoneid, equipmentid, statusid, orgid)

+ 6 - 1
controllers/dialysis_api_controller.go View File

@@ -1845,10 +1845,15 @@ func (c *DialysisApiController) PostTreatmentSummary() {
1845 1845
 		treatmentSummary.Modifier = adminUserInfo.AdminUser.Id
1846 1846
 		treatmentSummary.ID = tempTreatmentSummary.ID
1847 1847
 		err := service.UpdateSummeRecord(&treatmentSummary)
1848
+
1848 1849
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
1850
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
1851
+		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1849 1852
 		//清空key 值
1850 1853
 		redis := service.RedisClient()
1851 1854
 		redis.Set(key, "", time.Second)
1855
+		redis.Set(keyOne, "", time.Second)
1856
+		redis.Set(keyThree, "", time.Second)
1852 1857
 		defer redis.Close()
1853 1858
 		if err == nil {
1854 1859
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -2725,7 +2730,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
2725 2730
 	patientInfo, _ := service.FindPatientWithDeviceByNo(adminUserInfo.CurrentOrgId, xtno, xttime)
2726 2731
 
2727 2732
 	//透析单
2728
-	dialysisOrder, _ := service.MobileGetSchedualDialysisRecord(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2733
+	dialysisOrder, _ := service.MobileGetSchedualDialysisRecordTen(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2729 2734
 	if dialysisOrder != nil {
2730 2735
 		if dialysisOrder.FinishNurse > 0 {
2731 2736
 			operatorIDs = append(operatorIDs, dialysisOrder.FinishNurse)

+ 146 - 92
controllers/drug_stock_api_contorller.go View File

@@ -52,7 +52,6 @@ func DrugStockManagerApiRegistRouters() {
52 52
 	beego.Router("/api/drugcancelstock/delete", &StockDrugApiController{}, "post:DeleteDrugCancelStock")
53 53
 	beego.Router("/api/drugcancelstockinfo/delete", &StockDrugApiController{}, "post:DeleteDrugCancelStockInfo")
54 54
 	beego.Router("/api/drugcancelstockinfo/edit", &StockDrugApiController{}, "post:EditDrugCancelStock")
55
-	//beego.Router("/api/drugcancelstockinfo/config", &StockDrugApiController{}, "get:GetDrugCancelStockConfig")
56 55
 
57 56
 	////库存相关全局配置
58 57
 	beego.Router("/api/drugstock/config", &StockDrugApiController{}, "get:GetAllConfig")
@@ -93,9 +92,9 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
93 92
 	timeArr := strings.Split(timeStr, "-")
94 93
 	total, _ := service.FindAllWarehouseTotalOne(adminUserInfo.CurrentOrgId)
95 94
 	total = total + 1
96
-	fmt.Println("total2323232323232", total)
95
+
97 96
 	warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
98
-	fmt.Println("r入库单据好  2323232322223", warehousing_order)
97
+
99 98
 	operation_time := time.Now().Unix()
100 99
 	creater := adminUserInfo.AdminUser.Id
101 100
 	warehousing := models.DrugWarehouse{
@@ -285,6 +284,10 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
285 284
 			service.UpdateBaseDrug(&lib, item.DrugId)
286 285
 		}
287 286
 	}
287
+	for _, items := range drugFlow {
288
+		drugWarehouseInfo, _ := service.GetLastDrugWarehouseInfo(items.DrugId)
289
+		items.WarehousingDetailId = drugWarehouseInfo.ID
290
+	}
288 291
 	//创建流水单
289 292
 	service.CreateDrugFlow(drugFlow)
290 293
 
@@ -633,26 +636,27 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
633 636
 			for _, it := range warehousingInfo {
634 637
 				info, _ := service.GetLastDrugWarehouseInfSix(it.DrugId)
635 638
 				flows := models.DrugFlow{
636
-					WarehousingOrder: info.WarehousingOrder,
637
-					WarehousingId:    info.WarehousingId,
638
-					DrugId:           info.DrugId,
639
-					Number:           info.Number,
640
-					ProductDate:      info.ProductDate,
641
-					ExpireDate:       info.ExpiryDate,
642
-					Count:            info.WarehousingCount,
643
-					Price:            info.Price,
644
-					Status:           1,
645
-					Ctime:            ctime,
646
-					UserOrgId:        adminUserInfo.CurrentOrgId,
647
-					Manufacturer:     info.Manufacturer,
648
-					Dealer:           info.Dealer,
649
-					BatchNumber:      info.BatchNumber,
650
-					MaxUnit:          info.MaxUnit,
651
-					MinUnit:          "",
652
-					ConsumableType:   1,
653
-					IsEdit:           1,
654
-					Creator:          adminUserInfo.AdminUser.Id,
655
-					IsSys:            0,
639
+					WarehousingOrder:    info.WarehousingOrder,
640
+					WarehousingId:       info.WarehousingId,
641
+					DrugId:              info.DrugId,
642
+					Number:              info.Number,
643
+					ProductDate:         info.ProductDate,
644
+					ExpireDate:          info.ExpiryDate,
645
+					Count:               info.WarehousingCount,
646
+					Price:               info.Price,
647
+					Status:              1,
648
+					Ctime:               ctime,
649
+					UserOrgId:           adminUserInfo.CurrentOrgId,
650
+					Manufacturer:        info.Manufacturer,
651
+					Dealer:              info.Dealer,
652
+					BatchNumber:         info.BatchNumber,
653
+					MaxUnit:             info.MaxUnit,
654
+					MinUnit:             "",
655
+					ConsumableType:      1,
656
+					IsEdit:              1,
657
+					Creator:             adminUserInfo.AdminUser.Id,
658
+					IsSys:               0,
659
+					WarehousingDetailId: info.ID,
656 660
 				}
657 661
 				_, existerrcodes := service.GetDrugFlowIsExist(info.ID, info.DrugId)
658 662
 
@@ -673,8 +677,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
673 677
 			//查询修改的记录
674 678
 			orderInfo, _ := service.GetDrugWarehouseOrderOne(id, item.DrugId)
675 679
 
676
-			fmt.Println("hh23323232323232332233232", orderInfo)
677
-
678 680
 			info, _ := service.FindeDrugInfo(item.DrugId)
679 681
 
680 682
 			//历史入库总数
@@ -711,7 +713,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
711 713
 			}
712 714
 
713 715
 			warehouseInfo, _ := service.FindeLastWarehouseInfo(item.ID)
714
-			fmt.Println("hhhhh23hh32h232332323223", warehouseInfo)
716
+
715 717
 			var total int64
716 718
 
717 719
 			//比较大小(加)
@@ -722,11 +724,15 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
722 724
 				errs = service.UpDateDrugWarehousingInfo(item)
723 725
 				if len(drugFlow) > 0 {
724 726
 					for _, it := range drugFlow {
725
-						fmt.Println(it)
726 727
 						flow := models.DrugFlow{
727
-							Count: item.StockMaxNumber,
728
+							Count:        item.StockMaxNumber,
729
+							Manufacturer: it.Manufacturer,
730
+							Dealer:       it.Dealer,
731
+							Number:       it.Number,
732
+							BatchNumber:  it.BatchNumber,
733
+							Price:        it.Price,
728 734
 						}
729
-						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
735
+						parseDateErr := service.UpdateDrugFlowTen(flow, item.DrugId, warehouseInfo.WarehousingId)
730 736
 						fmt.Println(parseDateErr)
731 737
 
732 738
 					}
@@ -808,6 +814,7 @@ func (c *StockDrugApiController) DeleteDrugWarehouseInfo() {
808 814
 	}
809 815
 
810 816
 	err := service.UpDateDrugWarehouseStatus(id)
817
+	service.UpdateDrugFlowById(id)
811 818
 	if err != nil {
812 819
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
813 820
 	} else {
@@ -1336,28 +1343,6 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1336 1343
 				}
1337 1344
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1338 1345
 
1339
-				//drugflow := &models.DrugFlow{
1340
-				//	WarehouseOutId:          warehouseOut.ID,
1341
-				//	WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1342
-				//	DrugId:                  drug_id,
1343
-				//	Number:                  number,
1344
-				//	ProductDate:             productDates,
1345
-				//	ExpireDate:              expiryDates,
1346
-				//	Count:                   count,
1347
-				//	Price:                   price,
1348
-				//	Status:                  1,
1349
-				//	Ctime:                   ctime,
1350
-				//	UserOrgId:               adminUserInfo.CurrentOrgId,
1351
-				//	Manufacturer:            manufacturer,
1352
-				//	Dealer:                  dealer,
1353
-				//	BatchNumber:             batch_number,
1354
-				//	MaxUnit:                 max_unit,
1355
-				//	ConsumableType:          2,
1356
-				//	IsEdit:                  1,
1357
-				//	Creator:                 adminUserInfo.AdminUser.Id,
1358
-				//	IsSys:                   0,
1359
-				//}
1360
-				//drugFlow = append(drugFlow, drugflow)
1361 1346
 			}
1362 1347
 		}
1363 1348
 	}
@@ -1384,10 +1369,6 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1384 1369
 			prescribing_number_total = item.Count
1385 1370
 		}
1386 1371
 
1387
-		fmt.Println("药品ID", item.DrugId)
1388
-		fmt.Println("数量一", prescribing_number_total)
1389
-		fmt.Println("数量二", total_count)
1390
-
1391 1372
 		//判断单位
1392 1373
 		if total_count == 0 {
1393 1374
 			goodObj, _ := service.GetDrugByGoodId(item.DrugId)
@@ -1535,6 +1516,7 @@ func (this *StockDrugApiController) DeleteDrugWarehouseOutInfo() {
1535 1516
 	}
1536 1517
 
1537 1518
 	err := service.UpDateDrugWarehouseOutStatus(id)
1519
+	service.DeleteDrugWarehouseOutInfoById(id)
1538 1520
 	if err != nil {
1539 1521
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1540 1522
 	} else {
@@ -1675,6 +1657,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1675 1657
 					}
1676 1658
 
1677 1659
 				}
1660
+
1678 1661
 				if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
1679 1662
 					productDates = 0
1680 1663
 				} else {
@@ -1838,8 +1821,6 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1838 1821
 				prescribing_number_total = item.Count
1839 1822
 			}
1840 1823
 
1841
-			fmt.Println("数量一", prescribing_number_total)
1842
-			fmt.Println("数量二", total_count)
1843 1824
 			//判断单位
1844 1825
 			if total_count == 0 {
1845 1826
 				goodObj, _ := service.GetDrugByGoodId(item.DrugId)
@@ -1868,8 +1849,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1868 1849
 				})
1869 1850
 				return
1870 1851
 			} else {
1871
-				//errs = service.CreateDrugWarehousingOutInfo(warehousingOutInfo)
1872
-				//service.CreateDrugFlow(drugFlow)
1852
+
1873 1853
 				// 出库流程
1874 1854
 				// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
1875 1855
 				drup, _ := service.FindBaseDrugLibRecord(item.OrgId, item.DrugId)
@@ -1906,8 +1886,6 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1906 1886
 				min_number = outInfo.Count
1907 1887
 			}
1908 1888
 
1909
-			fmt.Println("单位1", medical.MaxUnit)
1910
-			fmt.Println("单位2", item.CountUnit)
1911 1889
 			if medical.MaxUnit == item.CountUnit {
1912 1890
 				max_number = item.Count * medical.MinNumber
1913 1891
 			}
@@ -1918,11 +1896,18 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1918 1896
 
1919 1897
 			all_number = info.Count*medical.MinNumber + info.StockMinNumber
1920 1898
 
1921
-			////比较当前出库数量 和 最后一次出库数量,正常
1899
+			////比较当前出库数量 和 最后一次出库数量,正常退
1922 1900
 			if max_number <= min_number {
1923 1901
 				errs = service.UpDateDrugWarehouseOutInfo(item)
1924 1902
 				flow := models.DrugFlow{
1925
-					Count: item.Count,
1903
+					Count:          max_number,
1904
+					ExpireDate:     item.ExpiryDate,
1905
+					ProductDate:    item.ProductDate,
1906
+					Price:          item.Price,
1907
+					Manufacturer:   item.Manufacturer,
1908
+					Dealer:         item.Dealer,
1909
+					Number:         item.Number,
1910
+					WarehouseOutId: item.WarehouseOutId,
1926 1911
 				}
1927 1912
 				service.UpdateDrugFlowSix(item.WarehouseOutId, item.DrugId, item.WarehouseOutOrderNumber, flow)
1928 1913
 				cha_number = min_number - max_number
@@ -1986,19 +1971,25 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1986 1971
 			//退库操作
1987 1972
 			if max_number > min_number {
1988 1973
 
1989
-				cha_number = min_number - max_number
1974
+				cha_number = max_number - min_number
1990 1975
 				//如果总库存大于差,正常出库
1991 1976
 				if all_number > cha_number {
1992 1977
 
1993 1978
 					errs = service.UpDateDrugWarehouseOutInfo(item)
1994 1979
 					flow := models.DrugFlow{
1995
-						Count: item.Count,
1980
+						Count:        max_number,
1981
+						ExpireDate:   item.ExpiryDate,
1982
+						ProductDate:  item.ProductDate,
1983
+						Price:        item.Price,
1984
+						Manufacturer: item.Manufacturer,
1985
+						Dealer:       item.Dealer,
1986
+						Number:       item.Number,
1996 1987
 					}
1997 1988
 					service.UpdateDrugFlowSix(item.WarehouseOutId, item.DrugId, item.WarehouseOutOrderNumber, flow)
1998 1989
 					if item.CountUnit == medical.MaxUnit {
1999 1990
 						maxNumber = cha_number / medical.MinNumber
2000 1991
 
2001
-						parseDateErr := service.UpdateWarehouseInfo(maxNumber, item.DrugId, item.OrgId)
1992
+						parseDateErr := service.UpdateWarehouseInfoTwo(maxNumber, item.DrugId, item.OrgId)
2002 1993
 						fmt.Println("parseDateErr", parseDateErr)
2003 1994
 						if parseDateErr != nil {
2004 1995
 							utils.ErrorLog(errs.Error())
@@ -2016,7 +2007,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2016 2007
 							"max_unit":   "",
2017 2008
 						})
2018 2009
 						minNumber = cha_number % medical.MinNumber
2019
-						parseDateErr = service.UpdateWarehouseInfoOne(minNumber, item.DrugId, item.OrgId)
2010
+						parseDateErr = service.UpdateWarehouseInfoFour(minNumber, item.DrugId, item.OrgId)
2020 2011
 						if parseDateErr != nil {
2021 2012
 							utils.ErrorLog(errs.Error())
2022 2013
 							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
@@ -2034,7 +2025,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2034 2025
 						})
2035 2026
 					}
2036 2027
 					if item.CountUnit == medical.MinUnit {
2037
-						parseDateErr := service.UpdateWarehouseInfoOne(cha_number, item.DrugId, item.OrgId)
2028
+						parseDateErr := service.UpdateWarehouseInfoFour(cha_number, item.DrugId, item.OrgId)
2038 2029
 						if parseDateErr != nil {
2039 2030
 							utils.ErrorLog(errs.Error())
2040 2031
 							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
@@ -2052,6 +2043,8 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2052 2043
 						})
2053 2044
 					}
2054 2045
 				}
2046
+				fmt.Println("cha_number233232323222332323232232", cha_number)
2047
+				fmt.Println("all_number43444444444444444", all_number)
2055 2048
 				if all_number == cha_number {
2056 2049
 					warehouseInfo := models.XtDrugWarehouseInfo{
2057 2050
 						Number:       item.Number,
@@ -2066,21 +2059,83 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
2066 2059
 						MaxUnit:      item.CountUnit,
2067 2060
 					}
2068 2061
 					parseDateErr := service.UpdateDrugWarehouseingInfoSix(item.ID, warehouseInfo)
2062
+
2069 2063
 					if parseDateErr != nil {
2070 2064
 						utils.ErrorLog(errs.Error())
2071 2065
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2072 2066
 						return
2073 2067
 					}
2068
+					fmt.Println("单位123223232323", item.CountUnit)
2069
+					fmt.Println("单位232232323323232", medical.MaxUnit)
2070
+
2071
+					errs = service.UpDateDrugWarehouseOutInfo(item)
2072
+					flow := models.DrugFlow{
2073
+						Count:        item.Count,
2074
+						ExpireDate:   item.ExpiryDate,
2075
+						ProductDate:  item.ProductDate,
2076
+						Price:        item.Price,
2077
+						Manufacturer: item.Manufacturer,
2078
+						Dealer:       item.Dealer,
2079
+						Number:       item.Number,
2080
+					}
2081
+					service.UpdateDrugFlowSix(item.WarehouseOutId, item.DrugId, item.WarehouseOutOrderNumber, flow)
2082
+					if item.CountUnit == medical.MaxUnit {
2083
+						maxNumber = cha_number / medical.MinNumber
2084
+
2085
+						parseDateErr := service.UpdateWarehouseInfoTwo(maxNumber, item.DrugId, item.OrgId)
2086
+						fmt.Println("parseDateErr", parseDateErr)
2087
+						if parseDateErr != nil {
2088
+							utils.ErrorLog(errs.Error())
2089
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2090
+							return
2091
+						}
2092
+
2093
+						c.ServeSuccessJSON(map[string]interface{}{
2094
+							"msg":        "2",
2095
+							"drug_name":  "",
2096
+							"dose":       "",
2097
+							"dose_unit":  "",
2098
+							"min_number": "",
2099
+							"min_unit":   "",
2100
+							"max_unit":   "",
2101
+						})
2102
+						minNumber = cha_number % medical.MinNumber
2103
+						parseDateErr = service.UpdateWarehouseInfoFour(minNumber, item.DrugId, item.OrgId)
2104
+						if parseDateErr != nil {
2105
+							utils.ErrorLog(errs.Error())
2106
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2107
+							return
2108
+						}
2109
+
2110
+						c.ServeSuccessJSON(map[string]interface{}{
2111
+							"msg":        "2",
2112
+							"drug_name":  "",
2113
+							"dose":       "",
2114
+							"dose_unit":  "",
2115
+							"min_number": "",
2116
+							"min_unit":   "",
2117
+							"max_unit":   "",
2118
+						})
2119
+					}
2120
+					if item.CountUnit == medical.MinUnit {
2121
+						parseDateErr := service.UpdateWarehouseInfoFour(cha_number, item.DrugId, item.OrgId)
2122
+						if parseDateErr != nil {
2123
+							utils.ErrorLog(errs.Error())
2124
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
2125
+							return
2126
+						}
2127
+
2128
+						c.ServeSuccessJSON(map[string]interface{}{
2129
+							"msg":        "2",
2130
+							"drug_name":  "",
2131
+							"dose":       "",
2132
+							"dose_unit":  "",
2133
+							"min_number": "",
2134
+							"min_unit":   "",
2135
+							"max_unit":   "",
2136
+						})
2137
+					}
2074 2138
 
2075
-					c.ServeSuccessJSON(map[string]interface{}{
2076
-						"msg":        "2",
2077
-						"drug_name":  "",
2078
-						"dose":       "",
2079
-						"dose_unit":  "",
2080
-						"min_number": "",
2081
-						"min_unit":   "",
2082
-						"max_unit":   "",
2083
-					})
2084 2139
 				}
2085 2140
 				if all_number < cha_number {
2086 2141
 					goodObj, _ := service.GetDrugByGoodId(item.DrugId)
@@ -2383,8 +2438,6 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2383 2438
 			return
2384 2439
 		}
2385 2440
 
2386
-		fmt.Println("时间任命323332233232", total_number, total_count)
2387
-
2388 2441
 		//判断退库数量是否大于总入库数量
2389 2442
 		if total_number > total_count {
2390 2443
 			service.UpdateDrugCancel(item.CancelStockId)
@@ -2395,9 +2448,7 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2395 2448
 		}
2396 2449
 
2397 2450
 		//判断总退库数量是否大于出库数量
2398
-		fmt.Println("该批次总退库数量", can_number+total_number)
2399
-		fmt.Println("总出库数量", out_number)
2400
-		fmt.Println("当前退库数量", total_number)
2451
+
2401 2452
 		if can_number+total_number > out_number {
2402 2453
 			//清空退库单
2403 2454
 			service.UpdateDrugCancel(item.CancelStockId)
@@ -2406,12 +2457,12 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2406 2457
 			})
2407 2458
 			return
2408 2459
 		}
2409
-		fmt.Println("当前退库数量", total_number)
2410
-		fmt.Println("总出口数量", out_number)
2460
+
2411 2461
 		//正常退库
2412 2462
 		if total_number <= out_number {
2413 2463
 			//创建退库详情
2414 2464
 			errs := service.CreateCancelStockInfoTwo(item)
2465
+			lastInfo, _ := service.GetLastStockInfoThree(item.DrugId)
2415 2466
 			//创建库存明细
2416 2467
 			flows := models.DrugFlow{
2417 2468
 				WarehousingId:           0,
@@ -2440,7 +2491,7 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2440 2491
 				Price:                   item.Price,
2441 2492
 				WarehousingDetailId:     0,
2442 2493
 				WarehouseOutDetailId:    0,
2443
-				CancelOutDetailId:       0,
2494
+				CancelOutDetailId:       lastInfo.ID,
2444 2495
 				ExpireDate:              item.ExpiryDate,
2445 2496
 				ProductDate:             item.ProductDate,
2446 2497
 				MaxUnit:                 item.MaxUnit,
@@ -2570,6 +2621,8 @@ func (this *StockDrugApiController) DeleteDrugCancelStockInfo() {
2570 2621
 	}
2571 2622
 
2572 2623
 	err := service.UpDateDrugCancleStockStatus(id)
2624
+
2625
+	service.UpDateDrugCancelStockById(id)
2573 2626
 	if err != nil {
2574 2627
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
2575 2628
 	} else {
@@ -2882,8 +2935,11 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2882 2935
 				//创建库存明细
2883 2936
 				//查询这个药品这个订单是否已存在流水
2884 2937
 				for _, items := range drugFlow {
2938
+					drugwarehouseinfo, _ := service.GetLastDrugCancelStockInfoById(items.DrugId)
2939
+					items.CancelOutDetailId = drugwarehouseinfo.ID
2885 2940
 					_, errsId := service.GetCancelStockId(items.CancelStockId, items.DrugId)
2886 2941
 					if errsId == gorm.ErrRecordNotFound {
2942
+
2887 2943
 						errs = service.CreateDrugFlowTwo(items)
2888 2944
 					}
2889 2945
 				}
@@ -2898,7 +2954,7 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2898 2954
 				if lastCancel.MaxUnit == medical.MinUnit {
2899 2955
 					cancel_number = lastCancel.Count
2900 2956
 				}
2901
-				fmt.Println("999999232323232232232323232323", item.Count, cancel_number)
2957
+
2902 2958
 				var total int64
2903 2959
 
2904 2960
 				if medical.MaxUnit == item.MaxUnit {
@@ -2966,8 +3022,9 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2966 3022
 
2967 3023
 			//查询最后一条退库记录
2968 3024
 			info, _ := service.GetLastCancelStockInfoOne(id, item.DrugId)
3025
+			fmt.Println("hh23232oooooooo2o3o2o32o23oo23o23o23", item.ExpiryDate, item.ProductDate)
2969 3026
 			errs = service.UpDateDrugCancelStockInfo(item)
2970
-			fmt.Println("hh23232oooooooo2o3o2o32o23oo23o23o23", info)
3027
+
2971 3028
 			//查询该药品的信息
2972 3029
 			medical, _ := service.GetBaseDrugMedical(item.DrugId)
2973 3030
 			//统计该批次的总出库数
@@ -3030,8 +3087,6 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
3030 3087
 					Count: item.Count,
3031 3088
 				}
3032 3089
 				service.UpdatedDrugFlow(info.CancelStockId, item.DrugId, flow)
3033
-				break
3034
-
3035 3090
 			}
3036 3091
 
3037 3092
 			if item.MaxUnit == medical.MinUnit {
@@ -3042,12 +3097,11 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
3042 3097
 					Count: item.Count,
3043 3098
 				}
3044 3099
 				service.UpdatedDrugFlow(info.CancelStockId, item.DrugId, flow)
3045
-				break
3046 3100
 			}
3047 3101
 
3048 3102
 			//if(item.MaxUnit == info.MaxUnit && item.Count == info.Count){
3049
-			//
3050
-			//  service.UpdateDrugCancelStockInfo(item)
3103
+			// fmt.Println("hhh23232323232进来23232323232")
3104
+			// service.UpdateDrugCancelStockInfo(item)
3051 3105
 			//}
3052 3106
 		}
3053 3107
 	}

+ 4 - 2
controllers/gobal_config_api_controller.go View File

@@ -2191,10 +2191,12 @@ func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
2191 2191
 	ids := strings.Split(id, ",")
2192 2192
 	admin := c.GetAdminUserInfo()
2193 2193
 	info, _ := service.FindeDrugWarehouseOutOrder(ids, admin.CurrentOrgId)
2194
-	//info, _ := service.GetExportOutOrderDrugListOne(ids)
2194
+
2195 2195
 	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
2196
-	//warehousing, _ := service.FindeDrugWarehouseOutDetail(ids, admin.CurrentOrgId)
2196
+
2197 2197
 	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2198
+
2199
+	//drug_warhouse_out, _ := service.GetDrugWarehouseOut(ids)
2198 2200
 	c.ServeSuccessJSON(map[string]interface{}{
2199 2201
 		"info":             info,
2200 2202
 		"warehousing":      warehousing,

+ 33 - 102
controllers/manage_api_controller.go View File

@@ -129,36 +129,34 @@ func ManageRouters() {
129 129
 func (this *MachineApiController) SaveManageInfo() {
130 130
 	adminUserInfo := this.GetAdminUserInfo()
131 131
 	orgid := adminUserInfo.CurrentOrgId
132
-	//fmt.Println("机构id", orgid)
132
+
133 133
 	dataBody := make(map[string]interface{}, 0)
134 134
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
135
-	//fmt.Println("err", err)
136
-	//serial_numbe := int64(dataBody["serial_number"].(float64))
135
+
137 136
 	serial_numbe := dataBody["serial_number"].(string)
138
-	//fmt.Println("序列号", serial_numbe)
137
+
139 138
 	device_type := int64(dataBody["device_type"].(float64))
140
-	//fmt.Println("设备类型", device_type)
139
+
141 140
 	bed_number := int64(dataBody["bed_number"].(float64))
142
-	//	fmt.Println("床位号", bed_number)
141
+
143 142
 	//通过床位id获取区号id
144 143
 	number, err := service.GetZoneId(bed_number, orgid)
145
-	//fmt.Println("number", number)
146
-	//	fmt.Println("获取分区id错误", err)
144
+
147 145
 	device_name := dataBody["device_name"].(string)
148
-	//	fmt.Println("设备名称", device_name)
146
+
149 147
 	manufacture_factory := dataBody["manufacture_factory"].(string)
150
-	//fmt.Println("生产厂家", manufacture_factory)
148
+
151 149
 	service_manufacturer := dataBody["service_manufacturer"].(string)
152
-	//	fmt.Println("维修厂家", service_manufacturer)
150
+
153 151
 	unittype := int64(dataBody["unit_type"].(float64))
154 152
 	unit_type := strconv.FormatInt(unittype, 10)
155
-	//	fmt.Println("设备型号", unit_type)
153
+
156 154
 	use_section := dataBody["use_section"].(string)
157
-	//fmt.Println("使用科室", use_section)
155
+
158 156
 	section_number := dataBody["section_number"].(string)
159
-	//	fmt.Println("科室编号", section_number)
157
+
160 158
 	buy_date := dataBody["buy_date"].(string)
161
-	//	fmt.Println("buy_date", buy_date)
159
+
162 160
 	timeLayout := "2006-01-02 15:04:05"
163 161
 	theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
164 162
 	buydate := theTime.Unix()
@@ -166,7 +164,6 @@ func (this *MachineApiController) SaveManageInfo() {
166 164
 	if int_num < 0 {
167 165
 		buydate = 0
168 166
 	}
169
-	//	fmt.Println("购买日期", buydate)
170 167
 
171 168
 	install_date := dataBody["install_date"].(string)
172 169
 	toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
@@ -175,7 +172,6 @@ func (this *MachineApiController) SaveManageInfo() {
175 172
 	if buy_num < 0 {
176 173
 		installdate = 0
177 174
 	}
178
-	//fmt.Println("安装日期", installdate)
179 175
 
180 176
 	start_date := dataBody["start_date"].(string)
181 177
 	stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
@@ -184,22 +180,13 @@ func (this *MachineApiController) SaveManageInfo() {
184 180
 	if start_num < 0 {
185 181
 		startdate = 0
186 182
 	}
187
-	//	fmt.Println("启用日期", startdate)
188
-
189 183
 	maintenance_engineer := dataBody["maintenance_engineer"].(string)
190
-	//fmt.Println("维修工程", maintenance_engineer)
191 184
 	telephone := dataBody["telephone"].(string)
192
-	//fmt.Println("telephone", telephone)
193 185
 	guarantee_date := dataBody["guarantee_date"].(string)
194
-	//	fmt.Println("保修期限", guarantee_date)
195 186
 	machine_status := int64(dataBody["machine_status"].(float64))
196
-	//fmt.Println("机器状态", machine_status)
197 187
 	user_total := dataBody["user_total"].(string)
198
-	//fmt.Println("初次使用次数", user_total)
199 188
 	disinfection_mode := int64(dataBody["Disinfection_mode"].(float64))
200
-	//fmt.Println("消毒方式", disinfection_mode)
201 189
 	remarks := dataBody["remarks"].(string)
202
-	//fmt.Println("备注", remarks)
203 190
 	rubbish_date := dataBody["rubbish_date"].(string)
204 191
 	timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
205 192
 	rubbishdate := timeStringToTime.Unix()
@@ -207,16 +194,11 @@ func (this *MachineApiController) SaveManageInfo() {
207 194
 	if rubb_num < 0 {
208 195
 		rubbishdate = 0
209 196
 	}
210
-	//fmt.Println("报废日期", rubbishdate)
211 197
 	rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
212
-	//fmt.Println("报废原因", rubbish_reason)
213 198
 	user_year := dataBody["user_year"].(string)
214
-	//	fmt.Println("使用年限", user_year)
215 199
 	work_time := dataBody["work_time"].(string)
216
-	//fmt.Println("工作时长", work_time)
217 200
 	treat_types := dataBody["treat_type"].([]interface{})
218 201
 	revers := int64(dataBody["revers_mode"].(float64))
219
-	//fmt.Println("反渗模式", revers)
220 202
 	ids := make([]int64, 0)
221 203
 	for _, treat := range treat_types {
222 204
 		id := int64(treat.(float64))
@@ -231,11 +213,11 @@ func (this *MachineApiController) SaveManageInfo() {
231 213
 	}
232 214
 
233 215
 	addmacher := &models.DeviceAddmacher{
234
-		SerialNumber: serial_numbe,
235
-		DeviceType:   device_type,
236
-		BedNumber:    number.Number,
237
-		BedId:        bed_number,
238
-		//ZoneId:              number.ZoneID,
216
+		SerialNumber:        serial_numbe,
217
+		DeviceType:          device_type,
218
+		BedNumber:           number.Number,
219
+		BedId:               bed_number,
220
+		ZoneId:              number.ZoneID,
239 221
 		DeviceName:          device_name,
240 222
 		ManufactureFactory:  manufacture_factory,
241 223
 		ServiceManufacturer: service_manufacturer,
@@ -262,7 +244,6 @@ func (this *MachineApiController) SaveManageInfo() {
262 244
 		UserOrgId:           orgid,
263 245
 	}
264 246
 	err = service.CreateMacher(addmacher)
265
-	//fmt.Println("什么原因啊", err)
266 247
 	if err != nil {
267 248
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
268 249
 		return
@@ -277,20 +258,9 @@ func (this *MachineApiController) SaveManageInfo() {
277 258
 		EquitmentId:   deviceAddmacher.ID,
278 259
 		BedId:         bed_number,
279 260
 	}
280
-
281 261
 	error := service.AddTreatMode(deviceAddmacher.ID, orgid, ids)
282 262
 	fmt.Println("error:", error)
283
-	name, errcode := service.GetEquitmentName(unit_type, orgid)
284
-	fmt.Print("错误", errcode)
285
-	fmt.Print("name", name)
286 263
 	err = service.CreateEquimentName(equimentname)
287
-	//if errcode == gorm.ErrRecordNotFound {
288
-	//	err = service.CreateEquimentName(equimentname)
289
-	//} else if errcode == nil {
290
-	//	fmt.Print("设备类型已经存在")
291
-	//} else {
292
-	//	fmt.Print("设备类型已经存在")
293
-	//}
294 264
 	fmt.Println("添加设备型号失败", err)
295 265
 	this.ServeSuccessJSON(map[string]interface{}{
296 266
 		"addmacher": addmacher,
@@ -300,39 +270,20 @@ func (this *MachineApiController) SaveManageInfo() {
300 270
 func (this *MachineApiController) UpdateMachineInfo() {
301 271
 	adminUserInfo := this.GetAdminUserInfo()
302 272
 	orgid := adminUserInfo.CurrentOrgId
303
-	//fmt.Println("机构id", orgid)
304 273
 	dataBody := make(map[string]interface{}, 0)
305 274
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
306
-	//fmt.Println("错误是", err)
307 275
 	id := int64(dataBody["id"].(float64))
308
-	fmt.Println("id是什么", id)
309
-	//serial_number := int64(dataBody["serial_number"].(float64))
310 276
 	serial_number := dataBody["serial_number"].(string)
311
-	fmt.Println("序列号", serial_number)
312 277
 	device_type := int64(dataBody["devicetype"].(float64))
313
-	fmt.Println("设备类型", device_type)
314
-
315 278
 	bed_number := int64(dataBody["bed_number"].(float64))
316
-	fmt.Println("机位号", bed_number)
317
-
318 279
 	number, err := service.GetZoneId(bed_number, orgid)
319
-	//fmt.Println("number是多少", number)
320 280
 	device_name := dataBody["device_name"].(string)
321
-	//fmt.Println("设备名称", device_name)
322 281
 	manufacture_factory := dataBody["manufacture_factory"].(string)
323
-	//fmt.Println("生产厂家", manufacture_factory)
324 282
 	service_manufacturer := dataBody["service_manufacturer"].(string)
325
-	//fmt.Println("维修厂家", service_manufacturer)
326 283
 	unit_type := int64(dataBody["unit_type"].(float64))
327
-	//unit_type := strconv.FormatInt(unittype, 10)
328
-	fmt.Println("设备型号", unit_type)
329
-
330 284
 	use_section := dataBody["use_section"].(string)
331
-	//fmt.Println("使用科室", use_section)
332 285
 	section_number := dataBody["section_number"].(string)
333
-	//fmt.Println("科室编号", section_number)
334 286
 	buy_date := dataBody["buy_date"].(string)
335
-	//	fmt.Println("buy_date", buy_date)
336 287
 	timeLayout := "2006-01-02 15:04:05"
337 288
 	theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
338 289
 	buydate := theTime.Unix()
@@ -340,7 +291,6 @@ func (this *MachineApiController) UpdateMachineInfo() {
340 291
 	if int_num < 0 {
341 292
 		buydate = 0
342 293
 	}
343
-	fmt.Println("购买日期", buydate)
344 294
 	install_date := dataBody["install_date"].(string)
345 295
 	toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
346 296
 	installdate := toTime.Unix()
@@ -348,8 +298,6 @@ func (this *MachineApiController) UpdateMachineInfo() {
348 298
 	if buy_num < 0 {
349 299
 		installdate = 0
350 300
 	}
351
-	//fmt.Println("安装日期", installdate)
352
-
353 301
 	start_date := dataBody["start_date"].(string)
354 302
 	stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
355 303
 	startdate := stringToTime.Unix()
@@ -357,19 +305,12 @@ func (this *MachineApiController) UpdateMachineInfo() {
357 305
 	if start_num < 0 {
358 306
 		startdate = 0
359 307
 	}
360
-	//fmt.Println("启用日期", startdate)
361 308
 	maintenance_engineer := dataBody["maintenance_engineer"].(string)
362
-	//fmt.Println("维修工程", maintenance_engineer)
363 309
 	telephone := dataBody["telephone"].(string)
364
-	//fmt.Println("telephone", telephone)
365 310
 	guarantee_date := dataBody["guarantee_date"].(string)
366
-	//fmt.Println("保修期限", guarantee_date)
367 311
 	machine_status := int64(dataBody["machine_status"].(float64))
368
-	//fmt.Println("机器状态", machine_status)
369 312
 	user_total := dataBody["user_total"].(string)
370
-	//fmt.Println("初次使用次数", user_total)
371 313
 	remarks := dataBody["remarks"].(string)
372
-	//fmt.Println("备注", remarks)
373 314
 	rubbish_date := dataBody["rubbish_date"].(string)
374 315
 	timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
375 316
 	rubbishdate := timeStringToTime.Unix()
@@ -377,21 +318,15 @@ func (this *MachineApiController) UpdateMachineInfo() {
377 318
 	if rubb_num < 0 {
378 319
 		rubbishdate = 0
379 320
 	}
380
-	//fmt.Println("报废日期", rubbishdate)
381 321
 	rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
382
-	//fmt.Println("报废原因", rubbish_reason)
383 322
 	user_year := dataBody["user_year"].(string)
384
-	//fmt.Println("使用年限", user_year)
385 323
 	work_time := dataBody["work_time"].(string)
386
-	//fmt.Println("工作时长", work_time)
387 324
 	treat_types := dataBody["treat_type"].([]interface{})
388 325
 	ids := make([]int64, 0)
389 326
 	for _, treat := range treat_types {
390 327
 		id := int64(treat.(float64))
391 328
 		ids = append(ids, id)
392 329
 	}
393
-	fmt.Println("ids", ids)
394
-	//service.GetModeName(unit_type)
395 330
 	thisAddmacher, err := service.GetEquitmentByBedID(bed_number, orgid)
396 331
 	if thisAddmacher.ID > 0 && thisAddmacher.ID != id {
397 332
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisNoExist)
@@ -423,11 +358,7 @@ func (this *MachineApiController) UpdateMachineInfo() {
423 358
 		UserYear:            user_year,
424 359
 		WorkTime:            work_time,
425 360
 	}
426
-	//fmt.Println("addmacher", addmacher)
427 361
 	err = service.UpdateMachine(id, orgid, &addmacher)
428
-	//mt.Println("报错", err)
429
-	//zone, err := service.GetZoneName(number.ZoneID, orgid)
430
-	//fmt.Println("zoneerr",err)
431 362
 	errors := service.UpdateTreatMode(id, orgid, ids)
432 363
 	fmt.Println("更新透析模式失败", errors)
433 364
 	if err != nil {
@@ -697,12 +628,15 @@ func (this *MachineApiController) GetAllEquimentName() {
697 628
 	adminUser := this.GetAdminUserInfo()
698 629
 	orgid := adminUser.CurrentOrgId
699 630
 	equit, err := service.GetAllEquimentName(orgid)
631
+	list, _ := service.GetAllDeviceMode(orgid)
632
+
700 633
 	if err != nil {
701 634
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
702 635
 		return
703 636
 	}
704 637
 	this.ServeSuccessJSON(map[string]interface{}{
705 638
 		"equit": equit,
639
+		"list":  list,
706 640
 	})
707 641
 }
708 642
 
@@ -919,29 +853,30 @@ func (this *MachineApiController) UpdatePlanInfo() {
919 853
 
920 854
 func (this *MachineApiController) GetComprehensive() {
921 855
 	zone, _ := this.GetInt64("zone")
922
-	//fmt.Println("分区", zone)
856
+
923 857
 	number, _ := this.GetInt64("number")
924
-	//fmt.Println("机号", number)
858
+
925 859
 	devicetype, _ := this.GetInt64("devicetype")
926
-	//fmt.Println("type", devicetype)
860
+
927 861
 	year, _ := this.GetInt64("year")
928
-	//fmt.Println("year", year)
929 862
 
930 863
 	startTime := this.GetString("starttime")
931
-	//fmt.Println("开始时间", startTime)
864
+
865
+	device_mode, _ := this.GetInt64("device_mode")
866
+
867
+	fmt.Println("hh232323233232232233223232323", device_mode)
932 868
 	timeLayout := "2006-01-02"
933 869
 	loc, _ := time.LoadLocation("Local")
934 870
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
935 871
 	starts := theTime.Unix()
936
-	//fmt.Println("开始日期", starts)
937 872
 
938 873
 	endtime := this.GetString("endtime")
939 874
 	location, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
940 875
 	end := location.Unix()
941
-	//fmt.Println("endtime", end)
876
+
942 877
 	adminUserInfo := this.GetAdminUserInfo()
943 878
 	orgid := adminUserInfo.CurrentOrgId
944
-	macher, err := service.GetComprehensive(zone, number, devicetype, year, starts, end, orgid)
879
+	macher, err := service.GetComprehensive(zone, number, devicetype, year, starts, end, orgid, device_mode)
945 880
 	if err != nil {
946 881
 		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
947 882
 		return
@@ -954,21 +889,17 @@ func (this *MachineApiController) GetComprehensive() {
954 889
 func (this *MachineApiController) GetPatientInfo() {
955 890
 	adminUser := this.GetAdminUserInfo()
956 891
 	orgid := adminUser.CurrentOrgId
957
-	//fmt.Println("机构id", orgid)
958 892
 	id, _ := this.GetInt64("id")
959
-	//fmt.Println("设备id", id)
960 893
 	addmacher, _ := service.GetBedId(id)
961
-	//fmt.Println("addmacher", addmacher.BedId)
894
+
962 895
 	timeStr := time.Now().Format("2006-01-02")
963 896
 	timeLayout := "2006-01-02 15:04:05"
964
-	//fmt.Println("timeStr:", timeStr)
965 897
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
966 898
 	timenow := timeStringToTime.Unix()
967
-	//fmt.Println("timenow是什么", timenow)
968
-	//fmt.Println("时间搓", timeStringToTime.Unix())
899
+
969 900
 	//获取当天床位号排班的所有病人
970 901
 	schedules, err := service.GetPatientInfo(addmacher.BedId, timenow, orgid)
971
-	//fmt.Println("错误", err)
902
+
972 903
 	if err != nil {
973 904
 		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
974 905
 		return

+ 8 - 4
controllers/schedule_api_controller.go View File

@@ -2031,16 +2031,20 @@ func (this *ScheduleApiController) GetNextWeekDaySchedule() {
2031 2031
 
2032 2032
 	week_type, _ := this.GetInt64("week_type", -1)
2033 2033
 	week_time, _ := this.GetInt64("week_time")
2034
-	start_time, _ := this.GetInt64("start_time")
2035
-	end_time, _ := this.GetInt64("end_time")
2034
+	//start_time, _ := this.GetInt64("start_time")
2035
+	//end_time, _ := this.GetInt64("end_time")
2036 2036
 	record_date := this.GetString("record_date")
2037 2037
 
2038 2038
 	zons := this.GetString("zone")
2039 2039
 	zone := strings.Split(zons, ",")
2040
-	adminUserInfo := this.GetAdminUserInfo()
2040
+	start_time := this.GetString("start_time")
2041
+	end_time := this.GetString("end_time")
2041 2042
 	timeLayout := "2006-01-02"
2042 2043
 	loc, _ := time.LoadLocation("Local")
2044
+	theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2045
+	theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
2043 2046
 
2047
+	adminUserInfo := this.GetAdminUserInfo()
2044 2048
 	var theStartTIme int64
2045 2049
 	if len(record_date) > 0 {
2046 2050
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
@@ -2050,7 +2054,7 @@ func (this *ScheduleApiController) GetNextWeekDaySchedule() {
2050 2054
 		theStartTIme = theTime.Unix()
2051 2055
 	}
2052 2056
 
2053
-	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone, theStartTIme)
2057
+	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, theTimeStart.Unix(), theTimeEnd.Unix(), adminUserInfo.CurrentOrgId, zone, theStartTIme)
2054 2058
 	if err != nil {
2055 2059
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2056 2060
 		return

+ 157 - 50
controllers/stock_in_api_controller.go View File

@@ -305,7 +305,10 @@ func (c *StockManagerApiController) CreateWarehouse() {
305 305
 
306 306
 	//入库单创建成功
307 307
 	errs := service.CreateWarehousingInfo(warehousingInfo)
308
-
308
+	for _, its := range stockFlow {
309
+		warehousinginfo, _ := service.GetLastWarehousingInfo(its.GoodId)
310
+		its.WarehousingDetailId = warehousinginfo.ID
311
+	}
309 312
 	//创建入库单流水
310 313
 	service.CreateStockFlow(stockFlow)
311 314
 
@@ -691,10 +694,18 @@ func (c *StockManagerApiController) EditWarehouse() {
691 694
 				}
692 695
 
693 696
 				service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
697
+
694 698
 				flowStock := models.VmStockFlow{
695
-					Count: item.WarehousingCount,
696
-				}
697
-				service.UpdatedStockFlowByGoodId(item.WarehousingId, item.GoodId, flowStock)
699
+					Count:         item.WarehousingCount,
700
+					Number:        item.Number,
701
+					ProductDate:   item.ProductDate,
702
+					ExpireDate:    item.ExpiryDate,
703
+					Price:         item.Price,
704
+					Manufacturer:  item.Manufacturer,
705
+					Dealer:        item.Dealer,
706
+					LicenseNumber: info.LicenseNumber,
707
+				}
708
+				service.UpdatedStockFlowByGoodIdOne(item.WarehousingId, item.GoodId, flowStock)
698 709
 				//改变库存
699 710
 				good, _ := service.GetLastInfoMationById(info.GoodId)
700 711
 				warhouseCount := strconv.FormatInt(total, 10)
@@ -775,6 +786,8 @@ func (c *StockManagerApiController) DeleteWarehouse() {
775 786
 
776 787
 	idArray := strings.Split(ids, ",")
777 788
 	err := service.DeleteWarehouse(idArray)
789
+	//删除流水
790
+	service.DeleteStockFlow(idArray)
778 791
 	if err != nil {
779 792
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
780 793
 	} else {
@@ -792,6 +805,7 @@ func (c *StockManagerApiController) DeleteWarehouseInfo() {
792 805
 	}
793 806
 
794 807
 	err := service.UpDateWarehouseStatus(id)
808
+	service.UpdatedStockFlowById(id)
795 809
 	if err != nil {
796 810
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
797 811
 	} else {
@@ -1312,7 +1326,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1312 1326
 
1313 1327
 		// 查询该耗材是否有库存
1314 1328
 		warehouseOne, _ := service.FindWarehousingInfoTen(item.GoodId)
1315
-		fmt.Println("hhh2333223223", item.GoodId, item.Count, warehouseOne.StockCount)
1329
+
1316 1330
 		// 如果出库数量大于该批次剩余库存数量
1317 1331
 		if item.Count > warehouseOne.StockCount {
1318 1332
 
@@ -1436,6 +1450,7 @@ func (this *StockManagerApiController) DeleteWarehouseOutInfo() {
1436 1450
 	}
1437 1451
 
1438 1452
 	err := service.UpDateWarehouseOutStatus(id)
1453
+	service.UpdateStockFlowWarehouseOutById(id)
1439 1454
 	if err != nil {
1440 1455
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1441 1456
 	} else {
@@ -1697,13 +1712,11 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1697 1712
 
1698 1713
 	if len(upDateWarehouseOutInfos) > 0 {
1699 1714
 		for _, item := range upDateWarehouseOutInfos {
1700
-			fmt.Println("item2332323232323", item.ProductDate, item.ExpiryDate)
1701 1715
 
1702 1716
 			//1.查询该耗材该批次的最后一次出库记录
1703 1717
 			lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId, item.OrgId)
1704 1718
 
1705
-			// 退库的库存和该耗材该批次最后一次出库数量进行比较
1706
-			//如果退库数量大于 最后一次批次的数量(要么要进行出库)
1719
+			//如果出库数量大于 最后一次批次的数量(那么要进行出库)
1707 1720
 
1708 1721
 			if item.Count > lastGood.Count {
1709 1722
 
@@ -1726,13 +1739,19 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1726 1739
 					//计算和最后一次出库数据的差
1727 1740
 					total = item.Count - lastGood.Count
1728 1741
 
1742
+					if total > warehouseinfo.StockCount {
1743
+						c.ServeSuccessJSON(map[string]interface{}{
1744
+							"msg": "6",
1745
+						})
1746
+						return
1747
+					}
1729 1748
 					//获取该耗材该批次的剩余库存量
1730 1749
 					info, _ := service.GetLastGoodCountById(item.GoodId, item.WarehouseInfotId)
1731 1750
 
1732 1751
 					//判断该批次的剩余库存 和出库的库存进行比较
1733 1752
 					//如果出库的库存大于该批次的剩余库存,那么需要出库下一批次的库存
1734 1753
 
1735
-					if item.Count > info.StockCount {
1754
+					if total > info.StockCount {
1736 1755
 						//计算出库和该批次相差的库存
1737 1756
 						total_count = item.Count - info.StockCount
1738 1757
 						//清空本批次次库存
@@ -1748,8 +1767,8 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1748 1767
 							"msg": "1",
1749 1768
 						})
1750 1769
 					}
1751
-					//如果出库的库存小于或等于于该批次的剩余库存,那么需要该批次出库
1752
-					if item.Count <= info.StockCount {
1770
+					//如果与上次比的库存小于或等于于该批次的剩余库存,那么需要该批次出库
1771
+					if total <= info.StockCount {
1753 1772
 						stock_cout = lastGood.Count + total
1754 1773
 						fmt.Println(stock_cout)
1755 1774
 						//扣减库存
@@ -1785,6 +1804,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1785 1804
 						//查询是否存在
1786 1805
 						_, errcode := service.GetWarehouseOutInfoIsExist(item.ID)
1787 1806
 						if errcode == gorm.ErrRecordNotFound {
1807
+
1788 1808
 							errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1789 1809
 							if errOne != nil {
1790 1810
 								utils.ErrorLog(errs.Error())
@@ -1797,12 +1817,29 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1797 1817
 							return
1798 1818
 						} else if errcode == nil {
1799 1819
 							service.UpDateWarehouseOutInfo(item)
1820
+							//更新流水
1821
+							flow := models.VmStockFlow{
1822
+								Number:        item.Number,
1823
+								LicenseNumber: item.LicenseNumber,
1824
+								Count:         item.Count,
1825
+								Manufacturer:  item.Manufacturer,
1826
+								Dealer:        item.Dealer,
1827
+								ProductDate:   item.ProductDate,
1828
+								ExpireDate:    item.ExpiryDate,
1829
+								Price:         item.Price,
1830
+							}
1831
+							service.UpdateStockFlowByDetailId(flow, item.ID)
1832
+
1833
+							goodInfo := models.GoodInfo{
1834
+								Manufacturer: item.Manufacturer,
1835
+								Dealer:       item.Dealer,
1836
+							}
1837
+							service.UpdatedGoodInfo(goodInfo, item.GoodId)
1800 1838
 							c.ServeSuccessJSON(map[string]interface{}{
1801 1839
 								"msg": "1",
1802 1840
 							})
1803 1841
 							return
1804 1842
 						}
1805
-
1806 1843
 					}
1807 1844
 				}
1808 1845
 			}
@@ -1874,6 +1911,22 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1874 1911
 						return
1875 1912
 					} else if errcode == nil {
1876 1913
 						service.UpDateWarehouseOutInfo(item)
1914
+						flow := models.VmStockFlow{
1915
+							Number:        item.Number,
1916
+							LicenseNumber: item.LicenseNumber,
1917
+							Count:         item.Count,
1918
+							Manufacturer:  item.Manufacturer,
1919
+							Dealer:        item.Dealer,
1920
+							ProductDate:   item.ProductDate,
1921
+							ExpireDate:    item.ExpiryDate,
1922
+							Price:         item.Price,
1923
+						}
1924
+						service.UpdateStockFlowByDetailId(flow, item.ID)
1925
+						goodInfo := models.GoodInfo{
1926
+							Manufacturer: item.Manufacturer,
1927
+							Dealer:       item.Dealer,
1928
+						}
1929
+						service.UpdatedGoodInfo(goodInfo, item.GoodId)
1877 1930
 						return
1878 1931
 					}
1879 1932
 				}
@@ -1890,6 +1943,22 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1890 1943
 			if item.Count == lastGood.Count {
1891 1944
 
1892 1945
 				errs = service.UpDateWarehouseOutInfo(item)
1946
+				flow := models.VmStockFlow{
1947
+					Number:        item.Number,
1948
+					LicenseNumber: item.LicenseNumber,
1949
+					Count:         item.Count,
1950
+					Manufacturer:  item.Manufacturer,
1951
+					Dealer:        item.Dealer,
1952
+					ProductDate:   item.ProductDate,
1953
+					ExpireDate:    item.ExpiryDate,
1954
+					Price:         item.Price,
1955
+				}
1956
+				service.UpdateStockFlowByDetailId(flow, item.ID)
1957
+				goodInfo := models.GoodInfo{
1958
+					Manufacturer: item.Manufacturer,
1959
+					Dealer:       item.Dealer,
1960
+				}
1961
+				service.UpdatedGoodInfo(goodInfo, item.GoodId)
1893 1962
 				if errs != nil {
1894 1963
 					utils.ErrorLog(errs.Error())
1895 1964
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
@@ -2056,6 +2125,16 @@ func (c *StockManagerApiController) CreateCancelStock() {
2056 2125
 				}
2057 2126
 				cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
2058 2127
 
2128
+				list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2129
+
2130
+				var manufacturer_id int64
2131
+
2132
+				for _, items := range list {
2133
+					if manufacturer == items.ManufacturerName {
2134
+						manufacturer_id = items.ID
2135
+					}
2136
+				}
2137
+
2059 2138
 				flow := &models.VmStockFlow{
2060 2139
 					WarehousingId:           0,
2061 2140
 					GoodId:                  good_id,
@@ -2073,7 +2152,7 @@ func (c *StockManagerApiController) CreateCancelStock() {
2073 2152
 					IsEdit:                  0,
2074 2153
 					CancelStockId:           cancelStock.ID,
2075 2154
 					CancelOrderNumber:       cancelStock.OrderNumber,
2076
-					Manufacturer:            0,
2155
+					Manufacturer:            manufacturer_id,
2077 2156
 					Dealer:                  0,
2078 2157
 					Creator:                 adminUserInfo.AdminUser.Id,
2079 2158
 					UpdateCreator:           0,
@@ -2094,11 +2173,8 @@ func (c *StockManagerApiController) CreateCancelStock() {
2094 2173
 
2095 2174
 	for _, item := range cancelStockInfos {
2096 2175
 
2097
-		//统计该批次耗材的出库数量
2098
-		//info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId, item.WarehouseInfoId)
2099
-
2100 2176
 		info, _ := service.GetWarehoureOrderStockOutFlow(item.GoodId, item.OrgId, item.WarehouseInfoId)
2101
-		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
2177
+
2102 2178
 		if item.Count > info.Count {
2103 2179
 			service.UpdateCancelInfo(item.CancelStockId)
2104 2180
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -2124,11 +2200,17 @@ func (c *StockManagerApiController) CreateCancelStock() {
2124 2200
 			}
2125 2201
 			listcancel, _ := service.GetLastCancelStockById(adminUserInfo.CurrentOrgId)
2126 2202
 
2127
-			fmt.Println("2332323232323232323", cancelStockInfos)
2128 2203
 			item.CancelStockId = listcancel.ID
2129 2204
 			errs := service.CreateCancelStockInfoOne(item)
2130 2205
 
2131 2206
 			if len(stockFLow) > 0 {
2207
+
2208
+				for _, items := range stockFLow {
2209
+					cancelStockInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
2210
+					items.CancelStockId = listcancel.ID
2211
+					items.CancelOutDetailId = cancelStockInfo.ID
2212
+
2213
+				}
2132 2214
 				service.CreateStockFlow(stockFLow)
2133 2215
 			}
2134 2216
 			if errs != nil {
@@ -2245,6 +2327,7 @@ func (this *StockManagerApiController) DeleteCancelStockInfo() {
2245 2327
 	}
2246 2328
 
2247 2329
 	err := service.UpDateCancleStockStatus(id)
2330
+	service.UpdatedStockFlowByCancelId(id)
2248 2331
 	if err != nil {
2249 2332
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
2250 2333
 	} else {
@@ -2376,6 +2459,8 @@ func (c *StockManagerApiController) EditCancelStock() {
2376 2459
 					return
2377 2460
 				}
2378 2461
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
2462
+
2463
+				warehouse_info_id := int64(items["warehouse_info_id"].(float64))
2379 2464
 				if id == 0 {
2380 2465
 					cancelStockInfo := &models.CancelStockInfo{
2381 2466
 						GoodId:          good_id,
@@ -2395,6 +2480,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2395 2480
 						ExpiryDate:      expiryDates,
2396 2481
 						Remark:          remark,
2397 2482
 						Price:           price,
2483
+						WarehouseInfoId: warehouse_info_id,
2398 2484
 					}
2399 2485
 					cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
2400 2486
 
@@ -2423,7 +2509,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2423 2509
 						Ctime:                   time.Now().Unix(),
2424 2510
 						Mtime:                   0,
2425 2511
 						Price:                   price,
2426
-						WarehousingDetailId:     0,
2512
+						WarehousingDetailId:     warehouse_info_id,
2427 2513
 						WarehouseOutDetailId:    0,
2428 2514
 						CancelOutDetailId:       0,
2429 2515
 						ProductDate:             productDates,
@@ -2452,9 +2538,19 @@ func (c *StockManagerApiController) EditCancelStock() {
2452 2538
 						ExpiryDate:      expiryDates,
2453 2539
 						Remark:          remark,
2454 2540
 						Price:           price,
2541
+						WarehouseInfoId: warehouse_info_id,
2455 2542
 					}
2456 2543
 					upDateCancelStockInfos = append(upDateCancelStockInfos, cancelStockInfo)
2457 2544
 
2545
+					list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2546
+
2547
+					var manufacuture_id int64
2548
+					for _, it := range list {
2549
+						if it.ManufacturerName == manufacturer {
2550
+							manufacuture_id = it.ID
2551
+						}
2552
+					}
2553
+
2458 2554
 					flow := &models.VmStockFlow{
2459 2555
 						WarehousingId:           0,
2460 2556
 						GoodId:                  good_id,
@@ -2472,7 +2568,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2472 2568
 						IsEdit:                  2,
2473 2569
 						CancelStockId:           cancelStock.ID,
2474 2570
 						CancelOrderNumber:       cancelStock.OrderNumber,
2475
-						Manufacturer:            0,
2571
+						Manufacturer:            manufacuture_id,
2476 2572
 						Dealer:                  0,
2477 2573
 						Creator:                 adminUserInfo.AdminUser.Id,
2478 2574
 						UpdateCreator:           0,
@@ -2480,7 +2576,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2480 2576
 						Ctime:                   time.Now().Unix(),
2481 2577
 						Mtime:                   0,
2482 2578
 						Price:                   price,
2483
-						WarehousingDetailId:     0,
2579
+						WarehousingDetailId:     warehouse_info_id,
2484 2580
 						WarehouseOutDetailId:    0,
2485 2581
 						CancelOutDetailId:       0,
2486 2582
 						ProductDate:             productDates,
@@ -2535,36 +2631,50 @@ func (c *StockManagerApiController) EditCancelStock() {
2535 2631
 
2536 2632
 		if len(stockFlow) > 0 {
2537 2633
 			for _, itemcancel := range stockFlow {
2538
-
2634
+				fmt.Println("hhh233232323323233223323232我的时间")
2539 2635
 				//查询是否存在
2540 2636
 				stockInfo, errcode := service.IsExsitStockFlow(itemcancel.GoodId, itemcancel.CancelOrderNumber)
2541 2637
 				if errcode == gorm.ErrRecordNotFound {
2542
-
2638
+					service.CreateStockFlowSix(itemcancel)
2543 2639
 				} else {
2544 2640
 					flow := models.VmStockFlow{
2545
-						Count: itemcancel.Count,
2641
+						Count:        itemcancel.Count,
2642
+						Manufacturer: itemcancel.Manufacturer,
2643
+						Dealer:       itemcancel.Dealer,
2644
+						Price:        itemcancel.Price,
2645
+						ProductDate:  itemcancel.ProductDate,
2646
+						ExpireDate:   itemcancel.ExpireDate,
2546 2647
 					}
2547
-					service.UpdateStockFlowTwo(stockInfo.ID, flow)
2648
+					service.UpdateStockFlowThree(stockInfo.ID, flow)
2548 2649
 				}
2549 2650
 			}
2550
-			//service.CreateStockFlow(stockFlow)
2551 2651
 		}
2552 2652
 	}
2553 2653
 
2554 2654
 	if len(upDateCancelStockInfos) > 0 {
2555 2655
 		for _, item := range upDateCancelStockInfos {
2556 2656
 
2557
-			//获取该批次最后一套出库记录
2657
+			var all_total int64
2658
+			//获取该批次最后一套退库记录
2558 2659
 			info, _ := service.GetLastCancelInfo(item.WarehouseInfoId, item.GoodId)
2660
+			//查询该批次总的退库数量
2661
+			list, _ := service.GetAllCancelInfoById(item.WarehouseInfoId, item.GoodId)
2662
+			for _, it := range list {
2663
+				all_total += it.Count
2664
+			}
2665
+			fmt.Println("最后一次出库233223323233223", info.Count)
2666
+			fmt.Println("当前出库23323223232323323", item.Count)
2559 2667
 
2560
-			//比较出库数量和最后一次出库数据大小
2668
+			//比较退库库数量和最后一次退库库数据大小
2561 2669
 			//退库(加)
2562
-			if item.Count < info.Count {
2563
-				var total = info.Count - item.Count
2670
+			if item.Count > info.Count {
2671
+				var total = item.Count - info.Count
2564 2672
 				errs = service.UpDateCancelStockInfo(item)
2565 2673
 
2566 2674
 				warehouseinfo, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
2567
-				if (warehouseinfo.StockCount + total) > warehouseinfo.StockCount {
2675
+
2676
+				// 总退库数量大于入库数据
2677
+				if all_total > warehouseinfo.StockCount {
2568 2678
 					c.ServeSuccessJSON(map[string]interface{}{
2569 2679
 						"msg": "5",
2570 2680
 					})
@@ -2578,26 +2688,18 @@ func (c *StockManagerApiController) EditCancelStock() {
2578 2688
 				}
2579 2689
 			}
2580 2690
 			//(减)
2581
-			if item.Count > info.Count {
2691
+			if item.Count < info.Count {
2582 2692
 				errs = service.UpDateCancelStockInfo(item)
2583
-				//查询该批次入库的值
2584
-				infolist, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
2585
-				if item.Count > infolist.WarehousingCount {
2586
-					c.ServeSuccessJSON(map[string]interface{}{
2587
-						"msg": "4",
2588
-					})
2693
+
2694
+				var total_count = info.Count - item.Count
2695
+
2696
+				parseDateErr := service.UpdateWareInfoByIdSix(item.WarehouseInfoId, total_count)
2697
+				if parseDateErr != nil {
2698
+					utils.ErrorLog(errs.Error())
2699
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
2589 2700
 					return
2590 2701
 				}
2591
-				if item.Count <= infolist.WarehousingCount {
2592
-					var total_count = info.Count - item.Count
2593 2702
 
2594
-					parseDateErr := service.UpdateWareInfoById(item.WarehouseInfoId, total_count)
2595
-					if parseDateErr != nil {
2596
-						utils.ErrorLog(errs.Error())
2597
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
2598
-						return
2599
-					}
2600
-				}
2601 2703
 			}
2602 2704
 			if item.Count == info.Count {
2603 2705
 				errs = service.UpDateCancelStockInfo(item)
@@ -2613,9 +2715,14 @@ func (c *StockManagerApiController) EditCancelStock() {
2613 2715
 
2614 2716
 			} else {
2615 2717
 				flow := models.VmStockFlow{
2616
-					Count: itemcancel.Count,
2617
-				}
2618
-				service.UpdateStockFlowTwo(stockInfo.ID, flow)
2718
+					Count:         itemcancel.Count,
2719
+					Manufacturer:  itemcancel.Manufacturer,
2720
+					Dealer:        itemcancel.Dealer,
2721
+					Price:         itemcancel.Price,
2722
+					LicenseNumber: itemcancel.LicenseNumber,
2723
+					Number:        itemcancel.Number,
2724
+				}
2725
+				service.UpdateStockFlowThree(stockInfo.ID, flow)
2619 2726
 			}
2620 2727
 		}
2621 2728
 	}

+ 2 - 0
models/dialysis_parameter_models.go View File

@@ -132,6 +132,8 @@ type DialysisPrescriptionParameter struct {
132 132
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
133 133
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
134 134
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
135
+	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
136
+	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
135 137
 }
136 138
 
137 139
 func (DialysisPrescriptionParameter) TableName() string {

+ 1 - 1
service/data.go View File

@@ -318,7 +318,7 @@ func BatchInspectionConfiguration(orgid int64) (err error) {
318 318
 }
319 319
 
320 320
 func ShowFiledConfig(org_id int64, isShow int, id int64) (err error) {
321
-	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"ctime": time.Now().Unix(), "mtime": time.Now().Unix(), "is_show": isShow}).Error
321
+	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"create_time": time.Now().Unix(), "update_time": time.Now().Unix(), "is_show": isShow}).Error
322 322
 	return
323 323
 }
324 324
 

+ 24 - 27
service/device_service.go View File

@@ -504,6 +504,30 @@ func UpdateDeviceNumber(number *models.DeviceNumber) error {
504 504
 	return nil
505 505
 }
506 506
 
507
+func GetAddMacherByBedId(bedid int64, user_org_id int64) (*models.DeviceAddmacher, error) {
508
+	addmacher := models.DeviceAddmacher{}
509
+	err := UserReadDB().Where("bed_id = ? and status = 1 and user_org_id = ?", bedid, user_org_id).Find(&addmacher).Error
510
+	if err != nil {
511
+		if err == gorm.ErrRecordNotFound {
512
+			return nil, nil
513
+		} else {
514
+			return nil, err
515
+		}
516
+	}
517
+	return &addmacher, nil
518
+}
519
+
520
+func UpdateAddmacherByBedId(bedId int64, addmacher models.DeviceAddmacher) error {
521
+	tx := UserWriteDB().Begin()
522
+	err := tx.Model(&addmacher).Where("bed_id = ? and status = 1", bedId).Updates(map[string]interface{}{"zone_id": addmacher.ZoneId}).Error
523
+	if err != nil {
524
+		tx.Rollback()
525
+		return err
526
+	}
527
+	tx.Commit()
528
+	return nil
529
+}
530
+
507 531
 func GetDeviceNumberCountForZoneID(orgID int64, zoneID int64) (int, error) {
508 532
 	var count int
509 533
 	err := readDb.Model(&models.DeviceNumber{}).Where("zone_id = ? AND org_id = ? AND status = 1", zoneID, orgID).Count(&count).Error
@@ -547,32 +571,6 @@ func GetZoneId(bednumber int64, orgid int64) (models.DeviceNumber, error) {
547 571
 	return number, err
548 572
 }
549 573
 
550
-//func AddMacher(deviceaddmacher *models.DeviceAddmacher) error{
551
-//	fmt.Println("进来了没哟")
552
-//	tx := writeDb.Begin()
553
-//	err := tx.Model(&models.DeviceAddmachers{}).Create(&deviceaddmacher).Error
554
-//	fmt.Println("错误是什么",err)
555
-//	if err !=nil{
556
-//		tx.Rollback()
557
-//	}
558
-//	tx.Commit()
559
-//	return err
560
-//}
561
-
562
-// func CreateMacher(machers *models.DeviceAddmacher) error {
563
-//      fmt.Println("进来了米有")
564
-// 	begin := writeDb.Begin()
565
-// 	fmt.Println("hhhhhhhh",begin)
566
-// 	err := begin.Model(&models.DeviceAddmacher{}).Create(machers).Error
567
-// 	fmt.Println("err",err)
568
-// 	if err !=nil{
569
-// 		begin.Rollback()
570
-// 	}
571
-// 	begin.Commit()
572
-// 	fmt.Println("执行了没有")
573
-// 	return err
574
-// }
575
-
576 574
 func GetLastMacherData(orgid int64) (models.DeviceAddmacher, error) {
577 575
 	addmacher := models.DeviceAddmacher{}
578 576
 	err := UserReadDB().Model(&addmacher).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addmacher).Error
@@ -621,7 +619,6 @@ func AddTreatMode(machineid int64, orgid int64, treatmodes []int64) (err error)
621 619
 
622 620
 func GetAllMachineInfo(page int64, limit int64, keyword string, zoneid int64, equimentid int64, statusid int64, orgid int64) (addmahcer []*models.DeviceAddmachers, total int64, err error) {
623 621
 
624
-	//db := readUserDb().Table("xt_device_addmacher as a").Where("a.status = 1")
625 622
 	db := readUserDb.Table("xt_device_addmacher as a").Where("a.status = 1")
626 623
 	table := XTReadDB().Table("xt_device_zone as x")
627 624
 	d := readUserDb.Table("xt_device_mode as m")

+ 10 - 1
service/manage_service.go View File

@@ -103,6 +103,12 @@ func GetAllEquimentName(orgid int64) (equit []*models.DeviceEquimentname, err er
103 103
 	return equit, err
104 104
 }
105 105
 
106
+func GetAllDeviceMode(orgid int64) (device []*models.DeviceMode, err error) {
107
+
108
+	err = readUserDb.Model(&device).Where("user_org_id = ? and status = 1", orgid).Find(&device).Error
109
+	return device, err
110
+}
111
+
106 112
 func GetBed(equitid int64) (models.DeviceAddmacher, error) {
107 113
 	addmacher := models.DeviceAddmacher{}
108 114
 	err := UserReadDB().Where("id=? AND status = ?", equitid, 1).Find(&addmacher).Error
@@ -257,7 +263,7 @@ func UpdatePlanInfo(id int64, orgid int64, plan models.DevicePlan) error {
257 263
 	return err
258 264
 }
259 265
 
260
-func GetComprehensive(zone int64, number int64, devicetype int64, year int64, starttime int64, endtime int64, orgid int64) (macher []*models.DeviceAddmachers, err error) {
266
+func GetComprehensive(zone int64, number int64, devicetype int64, year int64, starttime int64, endtime int64, orgid int64, device_mode int64) (macher []*models.DeviceAddmachers, err error) {
261 267
 	db := readUserDb.Table("xt_device_addmacher as a").Where("a.status = 1")
262 268
 	table := XTReadDB().Table("xt_device_zone as x")
263 269
 	fmt.Println(table)
@@ -273,6 +279,9 @@ func GetComprehensive(zone int64, number int64, devicetype int64, year int64, st
273 279
 	if devicetype > 0 {
274 280
 		db = db.Where("a.device_type = ?", devicetype)
275 281
 	}
282
+	if device_mode > 0 {
283
+		db = db.Where("a.unit_type = ?", device_mode)
284
+	}
276 285
 	if year == 1 {
277 286
 		db = db.Where("a.user_year >= 0 AND a.user_year <= 1")
278 287
 	}

+ 14 - 0
service/mobile_dialysis_service.go View File

@@ -791,6 +791,20 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
791 791
 	}
792 792
 }
793 793
 
794
+// 透析记录
795
+func MobileGetSchedualDialysisRecordTen(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
796
+	var record models.DialysisOrder
797
+	err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
798
+	if err != nil {
799
+		if err == gorm.ErrRecordNotFound {
800
+			return nil, nil
801
+		} else {
802
+			return nil, err
803
+		}
804
+	}
805
+	return &record, nil
806
+}
807
+
794 808
 // 透析记录
795 809
 func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
796 810
 	var record models.DialysisOrder

+ 0 - 1
service/patient_service.go View File

@@ -283,7 +283,6 @@ func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentB
283 283
 		}
284 284
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
285 285
 		if assessment_befores_list_all == "null" {
286
-			fmt.Println("尽力2323232", assessment_befores_list_all)
287 286
 			return nil, nil
288 287
 		} else {
289 288
 			json.Unmarshal([]byte(assessment_befores_list_all), &assessmentBefores)

+ 5 - 4
service/schedule_service.go View File

@@ -838,10 +838,11 @@ func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endt
838 838
 	err = db.
839 839
 		Preload("DeviceZone", "status = 1 ").
840 840
 		Preload("DeviceNumber", "status = 1 ").
841
-		Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date = ?", record_date).
842
-		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
843
-			return db.Where("status = 1").Order("id asc")
844
-		}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
841
+		Preload("XtAssessmentBeforeDislysis", func(db *gorm.DB) *gorm.DB {
842
+			return db.Where("status = 1 and assessment_date = ?", record_date)
843
+		}).Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
844
+		return db.Where("status = 1").Order("id asc")
845
+	}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
845 846
 		return db.Where("status = 1").Order("id asc")
846 847
 	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
847 848
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", record_date).Preload("ChildDoctorAdvice", "status = 1 and advice_date = ?", record_date)

+ 0 - 6
service/self_drug_service.go View File

@@ -1043,12 +1043,6 @@ func GetLastDrugWarehouseInfSix(drugid int64) (models.XtDrugWarehouseInfo, error
1043 1043
 	err := XTReadDB().Model(&info).Where("drug_id=? and status = 1", drugid).Last(&info).Error
1044 1044
 	return info, err
1045 1045
 }
1046
-//func GetLastDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1047
-//
1048
-//	info := models.XtDrugWarehouseInfo{}
1049
-//	err := XTReadDB().Model(&info).Where("id=? and status = 1", drugid).Last(&info).Error
1050
-//	return info, err
1051
-//}
1052 1046
 
1053 1047
 func GetFirstDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1054 1048
 

+ 232 - 16
service/stock_service.go View File

@@ -267,6 +267,30 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
267 267
 	if len(keyword) > 0 {
268 268
 		likeKey := "%" + keyword + "%"
269 269
 		db = db.Where("good_code LIKE ? OR good_name LIKE ?", likeKey, likeKey)
270
+		if is_use > 0 {
271
+			if is_use == 1 {
272
+				db = db.Where("find_in_set('停用',good_status) = 0")
273
+			} else {
274
+				db = db.Where("find_in_set('停用',good_status) > 0")
275
+			}
276
+		}
277
+		if is_charge > 0 {
278
+			if is_charge == 1 {
279
+				db = db.Where("find_in_set('收费',good_status) > 0")
280
+			} else {
281
+				db = db.Where("find_in_set('收费',good_status) = 0")
282
+			}
283
+		}
284
+		if good_kind > 0 {
285
+			db = db.Where(" good_kind = ?", good_kind)
286
+		}
287
+
288
+		if is_mark > 0 {
289
+			db = db.Where("is_mark = ?", is_mark)
290
+		}
291
+		if manufacturer > 0 {
292
+			db = db.Where("manufacturer = ?", manufacturer)
293
+		}
270 294
 	} else {
271 295
 		if is_use > 0 {
272 296
 			if is_use == 1 {
@@ -626,6 +650,12 @@ func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err err
626 650
 
627 651
 }
628 652
 
653
+func GetLastWarehousingInfo(goodid int64) (models.WarehousingInfo, error) {
654
+	info := models.WarehousingInfo{}
655
+	err := XTReadDB().Model(&info).Where("good_id = ? and status = 1", goodid).Last(&info).Error
656
+	return info, err
657
+}
658
+
629 659
 func FindFirstWarehousingInfoByStock(good_id int64, good_type_id int64) (info models.WarehousingInfo, err error) {
630 660
 	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND good_type_id = ? AND status = 1 and stock_count > 0", good_id, good_type_id).Order("ctime").First(&info).Error
631 661
 	return info, err
@@ -1549,6 +1579,19 @@ func GetCancelStockDetailByOrderNumber(ordernumber string, orgid int64) (*models
1549 1579
 	return &stock, nil
1550 1580
 }
1551 1581
 
1582
+func GetCancelStockDetailByOrderNumberOne(return_time int64, orgid int64) (*models.CancelStock, error) {
1583
+
1584
+	stock := models.CancelStock{}
1585
+	err := XTReadDB().Where("return_time = ? and org_id = ? and status = 1", return_time, orgid).Find(&stock).Error
1586
+	if err == gorm.ErrRecordNotFound {
1587
+		return nil, err
1588
+	}
1589
+	if err != nil {
1590
+		return nil, err
1591
+	}
1592
+	return &stock, nil
1593
+}
1594
+
1552 1595
 func AddSigleCancelStock(cancelStock *models.CancelStock) error {
1553 1596
 	err := writeDb.Create(&cancelStock).Error
1554 1597
 	return err
@@ -1633,12 +1676,32 @@ func CreateCancelStockInfoTwo(info *models.DrugCancelStockInfo) error {
1633 1676
 	return err
1634 1677
 }
1635 1678
 
1679
+func GetLastStockInfoThree(drugid int64) (models.DrugCancelStockInfo, error) {
1680
+
1681
+	info := models.DrugCancelStockInfo{}
1682
+
1683
+	err := XTReadDB().Model(&info).Where("drug_id = ? and status = 1", drugid).Find(&info).Error
1684
+	return info, err
1685
+}
1686
+
1636 1687
 func CreateCancelStockInfoOne(info *models.CancelStockInfo) error {
1637 1688
 
1638 1689
 	err := XTWriteDB().Create(&info).Error
1639 1690
 	return err
1640 1691
 }
1641 1692
 
1693
+func GetLastCancelStockInfoByGoodId(goodId int64) (models.CancelStockInfo, error) {
1694
+	info := models.CancelStockInfo{}
1695
+	err := XTReadDB().Model(&info).Where("good_id = ? and status = 1", goodId).Last(&info).Error
1696
+	return info, err
1697
+}
1698
+
1699
+func GetLastDrugCancelStockInfoById(drugid int64) (models.DrugCancelStockInfo, error) {
1700
+	info := models.DrugCancelStockInfo{}
1701
+	err := XTReadDB().Model(&info).Where("drug_id = ? and status = 1", drugid).Last(&info).Error
1702
+	return info, err
1703
+}
1704
+
1642 1705
 func CreateDrugCancelStockInfo(cancelStockInfo []*models.DrugCancelStockInfo) (err error) {
1643 1706
 	if len(cancelStockInfo) > 0 {
1644 1707
 		utx := writeDb.Begin()
@@ -1819,6 +1882,12 @@ func UpDateWarehouseInfo(warehouseInfo *models.WarehousingInfo) (err error) {
1819 1882
 
1820 1883
 func UpDateWarehouseStatus(id int64) (err error) {
1821 1884
 	err = readDb.Model(&models.WarehousingInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1885
+
1886
+	return
1887
+}
1888
+
1889
+func UpdatedStockFlowById(id int64) (err error) {
1890
+	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("warehousing_detail_id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
1822 1891
 	return
1823 1892
 }
1824 1893
 
@@ -1827,6 +1896,11 @@ func UpDateDrugWarehouseStatus(id int64) (err error) {
1827 1896
 	return
1828 1897
 }
1829 1898
 
1899
+func UpdateDrugFlowById(id int64) (err error) {
1900
+	err = XTWriteDB().Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1901
+	return
1902
+}
1903
+
1830 1904
 func DeleteWarehouse(ids []string) (err error) {
1831 1905
 	ut := writeDb.Begin()
1832 1906
 	err = ut.Model(&models.Warehousing{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -1839,6 +1913,18 @@ func DeleteWarehouse(ids []string) (err error) {
1839 1913
 		ut.Rollback()
1840 1914
 		return
1841 1915
 	}
1916
+
1917
+	ut.Commit()
1918
+	return
1919
+}
1920
+
1921
+func DeleteStockFlow(ids []string) (err error) {
1922
+	ut := writeDb.Begin()
1923
+	err = ut.Model(&models.VmStockFlow{}).Where("warehousing_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1924
+	if err != nil {
1925
+		ut.Rollback()
1926
+		return
1927
+	}
1842 1928
 	ut.Commit()
1843 1929
 	return
1844 1930
 }
@@ -1855,6 +1941,12 @@ func DeleteDrugWarehouse(ids []string) (err error) {
1855 1941
 		ut.Rollback()
1856 1942
 		return
1857 1943
 	}
1944
+
1945
+	err = ut.Model(&models.DrugFlow{}).Where("warehousing_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1946
+	if err != nil {
1947
+		ut.Rollback()
1948
+		return
1949
+	}
1858 1950
 	ut.Commit()
1859 1951
 	return
1860 1952
 }
@@ -2118,6 +2210,12 @@ func DeleteWarehouseOut(ids []string) (err error) {
2118 2210
 		ut.Rollback()
2119 2211
 		return
2120 2212
 	}
2213
+
2214
+	err = ut.Model(&models.VmStockFlow{}).Where("warehouse_out_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2215
+	if err != nil {
2216
+		ut.Rollback()
2217
+		return
2218
+	}
2121 2219
 	ut.Commit()
2122 2220
 	return
2123 2221
 }
@@ -2134,6 +2232,12 @@ func DeleteDrugWarehouseOut(ids []string) (err error) {
2134 2232
 		ut.Rollback()
2135 2233
 		return
2136 2234
 	}
2235
+
2236
+	err = ut.Model(&models.DrugFlow{}).Where("warehouse_out_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2237
+	if err != nil {
2238
+		ut.Rollback()
2239
+		return
2240
+	}
2137 2241
 	ut.Commit()
2138 2242
 	return
2139 2243
 }
@@ -2143,6 +2247,11 @@ func UpDateWarehouseOutStatus(id int64) (err error) {
2143 2247
 	return
2144 2248
 }
2145 2249
 
2250
+func UpdateStockFlowWarehouseOutById(id int64) (err error) {
2251
+	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("warehouse_out_detail_id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
2252
+	return err
2253
+}
2254
+
2146 2255
 func UpDateDrugWarehouseInfoByStock(info *models.XtDrugWarehouseInfo) (err error) {
2147 2256
 	ut := writeDb.Begin()
2148 2257
 	err = ut.Save(&info).Error
@@ -2175,6 +2284,11 @@ func UpDateDrugWarehouseOutStatus(id int64) (err error) {
2175 2284
 	return
2176 2285
 }
2177 2286
 
2287
+func DeleteDrugWarehouseOutInfoById(id int64) (err error) {
2288
+	err = XTWriteDB().Model(&models.DrugFlow{}).Where("warehouse_out_detail_id = ? and satus = 1", id).Updates(map[string]interface{}{"status": 0}).Error
2289
+	return
2290
+}
2291
+
2178 2292
 func EditWarehouseOut(warehouseOut models.WarehouseOut) {
2179 2293
 	err = readDb.Model(&models.WarehouseOut{}).Where("id = ? AND status = 1", warehouseOut.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehouse_out_time": warehouseOut.WarehouseOutTime, "dealer": warehouseOut.Dealer, "manufacturer": warehouseOut.Manufacturer}).Error
2180 2294
 }
@@ -2195,7 +2309,7 @@ func UpDateDrugWarehouseOutInfo(info *models.DrugWarehouseOutInfo) (err error) {
2195 2309
 
2196 2310
 func UpdateDrugFlowSix(warehousoutid int64, drugid int64, warehouse_out_order_number string, flow models.DrugFlow) error {
2197 2311
 
2198
-	err := XTWriteDB().Model(&flow).Where("warehouse_out_id = ? and drug_id = ? and warehouse_out_order_number = ?", warehousoutid, drugid, warehouse_out_order_number).Updates(map[string]interface{}{"count": flow.Count}).Error
2312
+	err := XTWriteDB().Model(&flow).Where("warehouse_out_id = ? and drug_id = ? and warehouse_out_order_number = ?", warehousoutid, drugid, warehouse_out_order_number).Updates(map[string]interface{}{"count": flow.Count, "expire_date": flow.ExpireDate, "product_date": flow.ProductDate, "price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "number": flow.Number}).Error
2199 2313
 	return err
2200 2314
 }
2201 2315
 
@@ -2255,6 +2369,11 @@ func DeleteCancelStock(ids []string) (err error) {
2255 2369
 		ut.Rollback()
2256 2370
 		return
2257 2371
 	}
2372
+	err = ut.Model(&models.VmStockFlow{}).Where("cancel_stock_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2373
+	if err != nil {
2374
+		ut.Rollback()
2375
+		return
2376
+	}
2258 2377
 	ut.Commit()
2259 2378
 	return
2260 2379
 }
@@ -2271,6 +2390,11 @@ func DeleteDrugCancelStock(ids []string) (err error) {
2271 2390
 		ut.Rollback()
2272 2391
 		return
2273 2392
 	}
2393
+	err = ut.Model(&models.DrugFlow{}).Where("cancel_stock_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2394
+	if err != nil {
2395
+		ut.Rollback()
2396
+		return
2397
+	}
2274 2398
 	ut.Commit()
2275 2399
 	return
2276 2400
 }
@@ -2280,11 +2404,23 @@ func UpDateCancleStockStatus(id int64) (err error) {
2280 2404
 	return
2281 2405
 }
2282 2406
 
2407
+func UpdatedStockFlowByCancelId(id int64) (err error) {
2408
+
2409
+	err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_out_detail_id = ? and status = 0", id).Updates(map[string]interface{}{"status": 0}).Error
2410
+	return
2411
+}
2412
+
2283 2413
 func UpDateDrugCancleStockStatus(id int64) (err error) {
2284 2414
 	err = readDb.Model(&models.DrugCancelStockInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2285 2415
 	return
2286 2416
 }
2287 2417
 
2418
+func UpDateDrugCancelStockById(id int64) (err error) {
2419
+
2420
+	err = XTWriteDB().Model(&models.DrugFlow{}).Where("cancel_out_detail_id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
2421
+	return
2422
+}
2423
+
2288 2424
 func EditCancelStock(sales models.CancelStock) {
2289 2425
 	err = readDb.Model(&models.CancelStock{}).Where("id = ? AND status = 1", sales.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "return_time": sales.ReturnTime, "dealer": sales.Dealer, "manufacturer": sales.Manufacturer}).Error
2290 2426
 
@@ -3300,6 +3436,18 @@ func DeleteAutoRedeceDetailTwo(orgid int64, patient_id int64, recordtime int64,
3300 3436
 	return err
3301 3437
 }
3302 3438
 
3439
+func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64, goodid int64) error {
3440
+
3441
+	detail := models.BloodAutomaticReduceDetail{}
3442
+	err := XTWriteDB().Model(&detail).Where("org_id = ? and patient_id = ? and record_time = ? and status =1 and good_id = ? ", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3443
+	info := models.WarehouseOutInfo{}
3444
+	err = XTWriteDB().Model(&info).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3445
+	prepare := models.DialysisBeforePrepare{}
3446
+	err = XTWriteDB().Model(&prepare).Where("user_org_id = ? and patient_id = ? and record_date = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3447
+	return err
3448
+
3449
+}
3450
+
3303 3451
 func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
3304 3452
 	err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
3305 3453
 	return err
@@ -4050,6 +4198,12 @@ func GetExportOutOrderDrugListOne(warehouse_out_id []string) (out []*models.StDr
4050 4198
 	return out, err
4051 4199
 }
4052 4200
 
4201
+func GetDrugWarehouseOut(warehouse_out_id []string) (out []*models.StDrugWarehouseOutInfo, err error) {
4202
+
4203
+	err = XTReadDB().Where("warehouse_out_id in(?)", warehouse_out_id).Find(&out).Error
4204
+	return out, err
4205
+}
4206
+
4053 4207
 func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid_id int64) (models.WarehouseOutInfo, error) {
4054 4208
 
4055 4209
 	info := models.WarehouseOutInfo{}
@@ -4085,7 +4239,7 @@ func UpdateWarehousingInfo(info models.WarehousingInfo, id int64) error {
4085 4239
 }
4086 4240
 
4087 4241
 func FindFirstWarehousingInfoByGoodId(good_id int64, id int64) (info models.WarehousingInfo, err error) {
4088
-	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND status = 1 and stock_count > 0", good_id).Order("ctime asc").First(&info).Error
4242
+	err = readDb.Where("good_id = ? AND status = 1 and stock_count > 0", good_id).Order("ctime asc").First(&info).Error
4089 4243
 	return info, err
4090 4244
 }
4091 4245
 
@@ -4147,6 +4301,12 @@ func CreateStockFlowOne(flow models.VmStockFlow) error {
4147 4301
 	return err
4148 4302
 }
4149 4303
 
4304
+func CreateStockFlowSix(flow *models.VmStockFlow) error {
4305
+
4306
+	err := XTWriteDB().Create(&flow).Error
4307
+	return err
4308
+}
4309
+
4150 4310
 func UpdatedStockFlow(flow models.VmStockFlow) error {
4151 4311
 	err := XTWriteDB().Save(&flow).Error
4152 4312
 	return err
@@ -4203,7 +4363,7 @@ func GetWarehouseOutInfoIsExistOne(good_id int64, patient_id int64, record_time
4203 4363
 func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int64, startTime int64, endTime int64, good_id int64) (flow []*models.VmStockFlow, total int64, err error) {
4204 4364
 
4205 4365
 	offset := (page - 1) * limit
4206
-	db := XTReadDB().Model(&flow)
4366
+	db := XTReadDB().Model(&flow).Where("status = 1 and count > 0")
4207 4367
 	if consumable_type > 0 {
4208 4368
 		//入库
4209 4369
 		if consumable_type == 1 {
@@ -4485,12 +4645,25 @@ func UpdateWarehouseInfo(count int64, drugid int64, orgid int64) error {
4485 4645
 	return err
4486 4646
 }
4487 4647
 
4648
+func UpdateWarehouseInfoTwo(count int64, drugid int64, orgid int64) error {
4649
+
4650
+	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
4651
+
4652
+	return err
4653
+}
4654
+
4488 4655
 func UpdateWarehouseInfoOne(count int64, drugid int64, orgid int64) error {
4489 4656
 
4490 4657
 	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
4491 4658
 	return err
4492 4659
 }
4493 4660
 
4661
+func UpdateWarehouseInfoFour(count int64, drugid int64, orgid int64) error {
4662
+
4663
+	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
4664
+	return err
4665
+}
4666
+
4494 4667
 func GetWarehouseInfoByIdSeven(id int64) (models.WarehousingInfo, error) {
4495 4668
 
4496 4669
 	info := models.WarehousingInfo{}
@@ -4541,12 +4714,24 @@ func UpdateWareInfoById(id int64, count int64) error {
4541 4714
 	return err
4542 4715
 }
4543 4716
 
4717
+func UpdateWareInfoByIdSix(id int64, count int64) error {
4718
+
4719
+	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
4720
+	return err
4721
+}
4722
+
4544 4723
 func GetLastCancelInfo(id int64, goodid int64) (models.CancelStockInfo, error) {
4545 4724
 	info := models.CancelStockInfo{}
4546 4725
 	err := XTReadDB().Model(&info).Where("warehouse_info_id  = ? and good_id = ? and status = 1", id, goodid).Find(&info).Error
4547 4726
 	return info, err
4548 4727
 }
4549 4728
 
4729
+func GetAllCancelInfoById(id int64, goodid int64) (info []*models.CancelStockInfo, err error) {
4730
+
4731
+	err = XTReadDB().Model(&info).Where("warehouse_info_id  in(?) and good_id = ? and status = 1", id, goodid).Find(&info).Error
4732
+	return info, err
4733
+}
4734
+
4550 4735
 func UpdateStockFlow(flow models.VmStockFlow, goodid int64, warehousing_id int64) error {
4551 4736
 
4552 4737
 	err := XTWriteDB().Model(&flow).Where("good_id = ? and warehousing_id= ? and status = 1", goodid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count}).Error
@@ -4560,6 +4745,13 @@ func UpdateDrugFlow(flow models.DrugFlow, drugid int64, warehousing_id int64) er
4560 4745
 	return err
4561 4746
 }
4562 4747
 
4748
+func UpdateDrugFlowTen(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4749
+
4750
+	drugFlow := models.DrugFlow{}
4751
+	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "number": flow.Number, "batch_number": flow.BatchNumber, "price": flow.Price}).Error
4752
+	return err
4753
+}
4754
+
4563 4755
 func UpdateDrugCancel(id int64) (models.DrugCancelStock, error) {
4564 4756
 
4565 4757
 	stock := models.DrugCancelStock{}
@@ -5091,6 +5283,22 @@ func UpdatedStockFlowByGoodId(warehousing_id int64, good_id int64, flow models.V
5091 5283
 	return err
5092 5284
 }
5093 5285
 
5286
+func UpdatedStockFlowByGoodIdOne(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5287
+
5288
+	err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count, "number": flow.Number, "product_date": flow.ProductDate, "expire_date": flow.ExpireDate, "Price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "license_number": flow.LicenseNumber}).Error
5289
+	return err
5290
+}
5291
+
5292
+func UpdateStockFlowByDetailId(flow models.VmStockFlow, wareoutdetailid int64) error {
5293
+	err := XTWriteDB().Model(&flow).Where("warehouse_out_detail_id = ? and status = 1", wareoutdetailid).Updates(map[string]interface{}{"count": flow.Count, "number": flow.Number, "product_date": flow.ProductDate, "expire_date": flow.ExpireDate, "Price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "license_number": flow.LicenseNumber, "price": flow.Price}).Error
5294
+	return err
5295
+}
5296
+
5297
+func UpdatedGoodInfo(info models.GoodInfo, goodid int64) error {
5298
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", goodid).Updates(map[string]interface{}{"manufacturer": info.Manufacturer, "dealer": info.Dealer}).Error
5299
+	return err
5300
+}
5301
+
5094 5302
 func GetInventoryExportList(orgid int64) (info []*models.PatientWarehouseInfo, err error) {
5095 5303
 
5096 5304
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
@@ -5103,13 +5311,6 @@ func GetInventoryExportList(orgid int64) (info []*models.PatientWarehouseInfo, e
5103 5311
 	return info, err
5104 5312
 }
5105 5313
 
5106
-func GetDrugWarehouseingInfo(id int64) (models.XtDrugWarehouseInfo, error) {
5107
-
5108
-	info := models.XtDrugWarehouseInfo{}
5109
-	err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
5110
-	return info, err
5111
-}
5112
-
5113 5314
 func UpdateDrugWarehouseingInfoSix(id int64, info models.XtDrugWarehouseInfo) error {
5114 5315
 
5115 5316
 	warehouseInfo := models.XtDrugWarehouseInfo{}
@@ -5123,12 +5324,6 @@ func CreatedCancelStock(info models.DrugCancelStockInfo) error {
5123 5324
 	return err
5124 5325
 }
5125 5326
 
5126
-func UpdateDrugCancelStockInfo(info *models.DrugCancelStockInfo) error {
5127
-
5128
-	err := XTWriteDB().Save(&info).Error
5129
-	return err
5130
-}
5131
-
5132 5327
 func IsExsitStockFlow(goodid int64, cancel_order_number string) (*models.VmStockFlow, error) {
5133 5328
 	flow := models.VmStockFlow{}
5134 5329
 	err := XTReadDB().Where("good_id = ? and cancel_order_number = ? and status = 1", goodid, cancel_order_number).Find(&flow).Error
@@ -5146,3 +5341,24 @@ func UpdateStockFlowTwo(id int64, flow models.VmStockFlow) error {
5146 5341
 	err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count}).Error
5147 5342
 	return err
5148 5343
 }
5344
+
5345
+func UpdateStockFlowThree(id int64, flow models.VmStockFlow) error {
5346
+
5347
+	err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count, "manufacturer": flow.Count, "dealer": flow.Dealer, "number": flow.Number, "license_number": flow.LicenseNumber, "price": flow.Price}).Error
5348
+	return err
5349
+}
5350
+
5351
+func GetLastWarehouseOutInfoById(drugid int64) (models.DrugWarehouseOutInfo, error) {
5352
+
5353
+	flow := models.DrugWarehouseOutInfo{}
5354
+	err := XTReadDB().Where("drug_id = ? and status = 1", drugid).Last(&flow).Error
5355
+	return flow, err
5356
+}
5357
+
5358
+func GetLastWarehoseByGoodId(goodid int64, patient_id int64, record_date int64) (models.WarehouseOutInfo, error) {
5359
+
5360
+	info := models.WarehouseOutInfo{}
5361
+	err := XTReadDB().Model(&info).Where("good_id = ? and patient_id = ? and sys_record_time = ? and status = 1", goodid, patient_id, record_date).First(&info).Error
5362
+
5363
+	return info, err
5364
+}

+ 26 - 77
service/warhouse_service.go View File

@@ -89,9 +89,6 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
89 89
 	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
90 90
 	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
91 91
 
92
-	fmt.Println("c出库数量", advice.PrescribingNumber)
93
-	fmt.Println("单位1", advice.PrescribingNumberUnit)
94
-	fmt.Println("单位2", drup.MaxUnit)
95 92
 	var drug_price float64
96 93
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
97 94
 		deliver_number = count * drup.MinNumber
@@ -124,10 +121,8 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
124 121
 	}
125 122
 
126 123
 	// 将该批次的剩余库存数量转换为拆零数量
127
-	fmt.Println("hhh2322333232333232322332323232323232", warehouse.StockMaxNumber, drup.MinNumber, warehouse.StockMinNumber)
124
+
128 125
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
129
-	fmt.Println("剩余库存🇨🇳2222222222222222222", stock_number)
130
-	fmt.Println("deliver_number88888888888", deliver_number)
131 126
 
132 127
 	//查找药品信息
133 128
 	//baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
@@ -160,8 +155,6 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
160 155
 			WarehouseInfoId:         warehouse.ID,
161 156
 		}
162 157
 
163
-		fmt.Println("单据号2232322323232323232323232323232323", warehouseout.WarehouseOutOrderNumber)
164
-
165 158
 		drugflow := models.DrugFlow{
166 159
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
167 160
 			WarehouseOutId:          warehouseout.ID,
@@ -225,7 +218,6 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
225 218
 		var maxNumber int64 = 0
226 219
 		var minNumber int64 = 0
227 220
 
228
-		fmt.Println("2332233232232323232323", advice.PrescribingNumberUnit, drup.MaxUnit)
229 221
 		//if advice.PrescribingNumberUnit == drup.MaxUnit {
230 222
 		//	maxNumber = deliver_number / drup.MinNumber
231 223
 		//	minNumber = deliver_number % drup.MinNumber
@@ -238,15 +230,13 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
238 230
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
239 231
 			minNumber = maxNumber
240 232
 		}
241
-		fmt.Println("maxNumber0000000000000", maxNumber)
242
-		fmt.Println("minNumber999999999999999", minNumber)
233
+
243 234
 		if warehouse.StockMaxNumber < maxNumber {
244 235
 
245 236
 			return errors.New("库存数量不足")
246 237
 		}
247 238
 
248 239
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
249
-		fmt.Println("扣减库存2322223232332233223232323233233223", warehouse.StockMaxNumber)
250 240
 
251 241
 		warehouse.Mtime = time.Now().Unix()
252 242
 
@@ -326,8 +316,6 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
326 316
 			return errTwo
327 317
 		}
328 318
 
329
-		fmt.Println("hh23232323232323232233232", warehouse.ID)
330
-
331 319
 		info := models.XtDrugWarehouseInfo{
332 320
 			ID:                warehouse.ID,
333 321
 			WarehousingId:     warehouse.WarehousingId,
@@ -388,12 +376,10 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
388 376
 		}
389 377
 
390 378
 		CreateDrugFlowOne(drugflow)
391
-		fmt.Println("deliver_number4444444444444", deliver_number)
392
-		fmt.Println("剩余库存hhh2332323232233223232323", stock_number)
379
+
393 380
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
394 381
 		prescribingNumber_two_temp := deliver_number - stock_number
395 382
 
396
-		fmt.Println("下哥批次要出的库存数控数量23333322222222222232323233322332", prescribingNumber_two_temp)
397 383
 		overPlusNumber := float64(prescribingNumber_two_temp)
398 384
 
399 385
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
@@ -501,7 +487,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
501 487
 	// 如果没有对应的库存,则报错
502 488
 
503 489
 	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId)
504
-	fmt.Println("warehouse233223232323", warehouse.ID)
490
+
505 491
 	//查找药品信息
506 492
 	//baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
507 493
 	if err != nil {
@@ -513,9 +499,6 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
513 499
 
514 500
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
515 501
 
516
-	fmt.Println("剩余库存", stock_number)
517
-	fmt.Println("出库数量233322323", deliver_number)
518
-
519 502
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
520 503
 	if stock_number >= deliver_number {
521 504
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
@@ -605,15 +588,12 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
605 588
 		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
606 589
 		var maxNumber int64 = 0
607 590
 		var minNumber int64 = 0
608
-		fmt.Println("单位1111111", advice.PrescribingNumberUnit)
609
-		fmt.Println("单位232323233223", drup.MinUnit)
610
-		fmt.Println("出库数量", deliver_number)
591
+
611 592
 		maxNumber = deliver_number / drup.MinNumber
612 593
 		minNumber = deliver_number % drup.MinNumber
613 594
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
614 595
 			minNumber = maxNumber
615 596
 		}
616
-		fmt.Println("剩余库存233233232323323232")
617 597
 
618 598
 		if drup.MaxUnit != drup.MinUnit {
619 599
 			if warehouse.StockMaxNumber < maxNumber {
@@ -621,18 +601,11 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
621 601
 			}
622 602
 		}
623 603
 
624
-		fmt.Println("库存数量2332232323", stock_number)
625
-		fmt.Println("c出库数量", maxNumber)
626
-		fmt.Println("c出库数量", minNumber)
627
-
628 604
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
629 605
 		if warehouse.StockMaxNumber < 0 {
630 606
 			warehouse.StockMaxNumber = 0
631 607
 		}
632
-		fmt.Println("剩余库存", warehouse.StockMaxNumber)
633 608
 
634
-		fmt.Println("ha1", warehouse.StockMinNumber)
635
-		fmt.Println("ha2", minNumber)
636 609
 		warehouse.Mtime = time.Now().Unix()
637 610
 
638 611
 		if warehouse.StockMinNumber < minNumber {
@@ -652,7 +625,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
652 625
 
653 626
 		//扣减库存232332332332
654 627
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
655
-		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
628
+
656 629
 		if errThree != nil {
657 630
 			return errThree
658 631
 		}
@@ -768,8 +741,6 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
768 741
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
769 742
 		prescribingNumber_two_temp := deliver_number - stock_number
770 743
 
771
-		fmt.Println("剩余出库数量4444444444444444", prescribingNumber_two_temp)
772
-
773 744
 		overPlusNumber := float64(prescribingNumber_two_temp)
774 745
 
775 746
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
@@ -789,9 +760,6 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
789 760
 	var deliver_number int64 = 0
790 761
 	var stock_number int64 = 0
791 762
 
792
-	fmt.Println("单位1", advice.CountUnit)
793
-	fmt.Println("单位2", drup.MaxUnit)
794
-
795 763
 	if advice.CountUnit == drup.MaxUnit {
796 764
 		deliver_number = prescribingNumber * drup.MinNumber
797 765
 	} else {
@@ -847,8 +815,8 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
847 815
 		if errOne != nil {
848 816
 			return errOne
849 817
 		}
850
-		fmt.Println("hh233223323223232323233223232323233223232323", warehouseout.ID, warehouseout.WarehouseOutOrderNumber)
851
-		//list, _ := GetLastWarehouseOut(drup.OrgId)
818
+
819
+		drugWareInfo, _ := GetLastWarehouseOutInfoById(advice.DrugId)
852 820
 		drugflow := models.DrugFlow{
853 821
 			WarehouseOutId:          warehouseout.ID,
854 822
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -869,6 +837,7 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
869 837
 			IsEdit:                  1,
870 838
 			Creator:                 0,
871 839
 			IsSys:                   0,
840
+			WarehouseOutDetailId:    drugWareInfo.ID,
872 841
 		}
873 842
 
874 843
 		CreateDrugFlowOne(drugflow)
@@ -941,7 +910,7 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
941 910
 		if errOne != nil {
942 911
 			return errOne
943 912
 		}
944
-		//list, _ := GetLastWarehouseOut(drup.OrgId)
913
+		drugWareInfo, _ := GetLastWarehouseOutInfoById(advice.DrugId)
945 914
 		drugflow := models.DrugFlow{
946 915
 			WarehouseOutId:          warehouseout.ID,
947 916
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -962,6 +931,7 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
962 931
 			IsEdit:                  1,
963 932
 			Creator:                 0,
964 933
 			IsSys:                   0,
934
+			WarehouseOutDetailId:    drugWareInfo.ID,
965 935
 		}
966 936
 		CreateDrugFlowOne(drugflow)
967 937
 		// 出库完成后,要将该批次库存清零
@@ -1024,8 +994,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
1024 994
 
1025 995
 	// goods_yc 这个数据就是需要已经出库了,但是现在需要删除出库的耗材数据
1026 996
 	// goods 这个数据就是需要出库的耗材的数据(新增的数据)
1027
-	fmt.Println("goods222222222222", goods)
1028
-	fmt.Println("goodsy999999999999", goods_yc)
997
+
1029 998
 	if len(goods) > 0 {
1030 999
 		out, err := FindStockOutByIsSys(orgID, 1, record_time)
1031 1000
 		if err == gorm.ErrRecordNotFound {
@@ -1195,7 +1164,6 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1195 1164
 			//查询流水是否存在
1196 1165
 			exsit, errflow := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1197 1166
 
1198
-			fmt.Println("什么数据233232323", errflow)
1199 1167
 			if errflow == gorm.ErrRecordNotFound {
1200 1168
 				errThre := CreateStockFlowOne(flow)
1201 1169
 				if errThre != nil {
@@ -1322,7 +1290,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1322 1290
 
1323 1291
 		return nil
1324 1292
 	} else {
1325
-		fmt.Println("不进来22323232323232323232233223323223322323")
1293
+
1326 1294
 		// 当刚批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1327 1295
 		warehouseOutInfo := &models.WarehouseOutInfo{
1328 1296
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -1349,7 +1317,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1349 1317
 		warehouseOutInfo.Count = stock_number
1350 1318
 
1351 1319
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, goods.PatientId, record_time)
1352
-		fmt.Println("hhhhh2h323233223232323", errcodes)
1320
+
1353 1321
 		if errcodes == gorm.ErrRecordNotFound {
1354 1322
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1355 1323
 
@@ -1418,7 +1386,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1418 1386
 			}
1419 1387
 
1420 1388
 		} else if errcodes == nil {
1421
-			fmt.Println("尽力3323232322323232323232323232323")
1389
+
1422 1390
 			goods.Count = deliver_number - stock_number
1423 1391
 			//更新数量为  该批次剩余数量  + 还有未出的数量
1424 1392
 			warehouseOutInfo.Count = stock_number
@@ -1453,7 +1421,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1453 1421
 			if errflows == gorm.ErrRecordNotFound {
1454 1422
 				CreateStockFlowOne(flow)
1455 1423
 			} else if errflows == nil {
1456
-				fmt.Println("尽力3323232322323232323232323232323", exsit.Count+goods.Count)
1424
+
1457 1425
 				flow := models.VmStockFlow{
1458 1426
 					ID:                      exsit.ID,
1459 1427
 					WarehouseOutId:          warehouseOut.ID,
@@ -1623,21 +1591,17 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1623 1591
 	var maxNumber int64 = 0
1624 1592
 
1625 1593
 	deliver_number = goods.Count
1626
-	fmt.Println("出库数量", deliver_number)
1627 1594
 
1628 1595
 	// 根据先进先出原则,查询最先入库的批次,进行出库
1629 1596
 
1630 1597
 	// 如果没有对应的库存,则报错
1631 1598
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
1632
-
1633 1599
 	if err != nil {
1634 1600
 
1635 1601
 		return err
1636 1602
 	}
1637 1603
 
1638 1604
 	stock_number = warehouse.StockCount
1639
-	fmt.Println("库存数量", stock_number)
1640
-	fmt.Println("出库数量", deliver_number)
1641 1605
 
1642 1606
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1643 1607
 	if stock_number >= deliver_number {
@@ -1707,8 +1671,6 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1707 1671
 
1708 1672
 		maxNumber = goods.Count
1709 1673
 
1710
-		fmt.Println("数据1111111111111", warehouse.StockCount)
1711
-		fmt.Println("s数据233232323232323232233232", maxNumber)
1712 1674
 		if warehouse.StockCount < maxNumber {
1713 1675
 			return errors.New("库存数量不足")
1714 1676
 		}
@@ -1718,7 +1680,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1718 1680
 
1719 1681
 		//扣减库存
1720 1682
 		errThree := UpDateWarehouseInfoByStock(&warehouse)
1721
-		fmt.Println("几年里2323323232323232323232")
1683
+
1722 1684
 		if errThree != nil {
1723 1685
 			return errThree
1724 1686
 		}
@@ -1768,7 +1730,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1768 1730
 			GoodId:                  goods.GoodId,
1769 1731
 			Number:                  warehouse.Number,
1770 1732
 			LicenseNumber:           goods.LicenseNumber,
1771
-			Count:                   goods.Count,
1733
+			Count:                   stock_number,
1772 1734
 			UserOrgId:               goods.OrgId,
1773 1735
 			PatientId:               0,
1774 1736
 			SystemTime:              record_time,
@@ -1823,15 +1785,15 @@ func ConsumablesDeliveryTwo(orgID int64, goods *models.WarehouseOutInfo, count i
1823 1785
 	var maxNumber int64 = 0
1824 1786
 
1825 1787
 	deliver_number = goods.Count
1826
-	fmt.Println("添加数量", deliver_number)
1827 1788
 
1828 1789
 	// 根据先进先出原则,查询最先入库的批次,进行出库
1829 1790
 	warehouse, err := FindFirstWarehousingInfoByGoodId(goods.GoodId, goods.ID)
1791
+
1830 1792
 	if err != nil {
1831 1793
 		return err
1832 1794
 	}
1795
+
1833 1796
 	stock_number = warehouse.StockCount
1834
-	fmt.Println("hh233232232323323232322323233", stock_number, deliver_number)
1835 1797
 
1836 1798
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1837 1799
 	if stock_number >= deliver_number {
@@ -1919,10 +1881,10 @@ func ConsumablesDeliveryTwo(orgID int64, goods *models.WarehouseOutInfo, count i
1919 1881
 		if errThree != nil {
1920 1882
 			return errThree
1921 1883
 		}
1922
-		fmt.Println("我的时间h232323332323223232323322332322323323223233223232323232332232332232323", errThree)
1884
+
1923 1885
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1924 1886
 		goods.Count = deliver_number - stock_number
1925
-		fmt.Println("hh23323232232332232323233232323223223", goods.Count)
1887
+
1926 1888
 		ConsumablesDeliveryTwo(orgID, goods, count)
1927 1889
 
1928 1890
 	}
@@ -1972,10 +1934,8 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
1972 1934
 	}
1973 1935
 
1974 1936
 	// 将该批次的剩余库存数量转换为拆零数量
1975
-	fmt.Println("hhh2322333232333232322332323232323232", warehouse.StockMaxNumber, drup.MinNumber, warehouse.StockMinNumber)
1937
+
1976 1938
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1977
-	fmt.Println("剩余库存🇨🇳2222222222222222222", stock_number)
1978
-	fmt.Println("deliver_number88888888888", deliver_number)
1979 1939
 
1980 1940
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1981 1941
 	if stock_number >= deliver_number {
@@ -2004,8 +1964,6 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
2004 1964
 			WarehouseInfoId:         warehouse.ID,
2005 1965
 		}
2006 1966
 
2007
-		fmt.Println("单据号2232322323232323232323232323232323", warehouseout.WarehouseOutOrderNumber)
2008
-
2009 1967
 		drugflow := models.DrugFlow{
2010 1968
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
2011 1969
 			WarehouseOutId:          warehouseout.ID,
@@ -2067,23 +2025,19 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
2067 2025
 		var maxNumber int64 = 0
2068 2026
 		var minNumber int64 = 0
2069 2027
 
2070
-		fmt.Println("2332233232232323232323", advice.PrescribingNumberUnit, drup.MaxUnit)
2071
-
2072 2028
 		//将拆零数量转为 最大包装单位  和 最小单位
2073 2029
 		maxNumber = deliver_number / drup.MinNumber
2074 2030
 		minNumber = deliver_number % drup.MinNumber
2075 2031
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
2076 2032
 			minNumber = maxNumber
2077 2033
 		}
2078
-		fmt.Println("maxNumber0000000000000", maxNumber)
2079
-		fmt.Println("minNumber999999999999999", minNumber)
2034
+
2080 2035
 		if warehouse.StockMaxNumber < maxNumber {
2081 2036
 
2082 2037
 			return errors.New("库存数量不足")
2083 2038
 		}
2084 2039
 
2085 2040
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
2086
-		fmt.Println("扣减库存2322223232332233223232323233233223", warehouse.StockMaxNumber)
2087 2041
 
2088 2042
 		warehouse.Mtime = time.Now().Unix()
2089 2043
 
@@ -2167,7 +2121,6 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
2167 2121
 		//warehouse.StockMaxNumber = 0
2168 2122
 		//warehouse.StockMinNumber = 0
2169 2123
 		//warehouse.Mtime = time.Now().Unix()
2170
-		fmt.Println("hh23232323232323232233232", warehouse.ID)
2171 2124
 
2172 2125
 		info := models.XtDrugWarehouseInfo{
2173 2126
 			ID:                warehouse.ID,
@@ -2228,12 +2181,10 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
2228 2181
 		}
2229 2182
 
2230 2183
 		CreateDrugFlowOne(drugflow)
2231
-		fmt.Println("deliver_number4444444444444", deliver_number)
2232
-		fmt.Println("剩余库存hhh2332323232233223232323", stock_number)
2184
+
2233 2185
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
2234 2186
 		prescribingNumber_two_temp := deliver_number - stock_number
2235 2187
 
2236
-		fmt.Println("下哥批次要出的库存数控数量23333322222222222232323233322332", prescribingNumber_two_temp)
2237 2188
 		overPlusNumber := float64(prescribingNumber_two_temp)
2238 2189
 
2239 2190
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
@@ -2285,8 +2236,6 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2285 2236
 	// 将该批次的剩余库存数量转换为拆零数量
2286 2237
 
2287 2238
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
2288
-	fmt.Println("第二次拆零数量2222222222222222222", stock_number)
2289
-	fmt.Println("第二次出库数量55555555555555555555", deliver_number)
2290 2239
 
2291 2240
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
2292 2241
 	if stock_number >= deliver_number {
@@ -2403,7 +2352,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2403 2352
 		}
2404 2353
 
2405 2354
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
2406
-		fmt.Println("我你233232323232323332323232232332322323233232232323")
2355
+
2407 2356
 		if errThree != nil {
2408 2357
 			return errThree
2409 2358
 		}