Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
d44c8af394

+ 28 - 0
controllers/dialysis_api_controller.go View File

@@ -83,6 +83,8 @@ func DialysisApiRegistRouters() {
83 83
 	beego.Router("/api/patient/getdialysissetting", &DialysisApiController{}, "Get:GetDialysisSetting")
84 84
 
85 85
 	beego.Router("/api/patient/getdialysisparameter", &DialysisApiController{}, "Get:GetDialysisParameterList")
86
+
87
+	beego.Router("/api/patient/getdialysisgoodtotalcount", &DialysisApiController{}, "Get:GetDialysisGoodTotalCount")
86 88
 }
87 89
 
88 90
 func (c *DialysisApiController) GetQueueCall() {
@@ -4411,3 +4413,29 @@ func (this *DialysisApiController) GetDialysisParameterList() {
4411 4413
 		return
4412 4414
 	}
4413 4415
 }
4416
+
4417
+func (this *DialysisApiController) GetDialysisGoodTotalCount() {
4418
+
4419
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4420
+
4421
+	schedule_type, _ := this.GetInt64("schedule_type")
4422
+
4423
+	partion_type, _ := this.GetInt64("partion_type")
4424
+
4425
+	start_time := this.GetString("schedule_date")
4426
+	timeLayout := "2006-01-02"
4427
+	loc, _ := time.LoadLocation("Local")
4428
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4429
+
4430
+	list, err := service.GetDialysisGoodTotalCount(orgId, schedule_type, partion_type, startTime.Unix())
4431
+	if err == nil {
4432
+		this.ServeSuccessJSON(map[string]interface{}{
4433
+			"list": list,
4434
+		})
4435
+		return
4436
+
4437
+	} else {
4438
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4439
+		return
4440
+	}
4441
+}

+ 1 - 1
controllers/doctors_api_controller.go View File

@@ -199,7 +199,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
199 199
 func (c *DoctorsApiController) GetAllDoctorAndNurse() {
200 200
 
201 201
 	adminUserInfo := c.GetAdminUserInfo()
202
-	doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
202
+	doctors, nursers, _ := service.GetAllDoctorAndNurseSix(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
203 203
 
204 204
 	c.ServeSuccessJSON(map[string]interface{}{
205 205
 		"doctors": doctors,

+ 10 - 1
controllers/drug_stock_api_contorller.go View File

@@ -3623,10 +3623,14 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3623 3623
 				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3624 3624
 				if it.MaxUnit == baseDrug.MaxUnit {
3625 3625
 					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3626
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3626 3627
 				}
3628
+			}
3629
+			for _, it := range drugInfolist {
3627 3630
 				total_count += it.WarehousingCount
3628
-				over_count += it.StockMaxNumber*baseDrug.MinNumber + it.StockMinNumber
3631
+				over_count += it.StockMaxNumber + it.StockMinNumber
3629 3632
 			}
3633
+			fmt.Println("over_countwoowoowowow", over_count)
3630 3634
 			//查询该仓库是否有默认数据
3631 3635
 			_, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
3632 3636
 			if errcode == gorm.ErrRecordNotFound {
@@ -3722,6 +3726,11 @@ func (c *StockDrugApiController) ReturnCheckWarehouseingInfo() {
3722 3726
 		}
3723 3727
 		drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3724 3728
 		var over_count int64 //剩余库存
3729
+		for _, it := range drugInfolist {
3730
+			if it.MaxUnit == medical.MaxUnit {
3731
+				it.StockMaxNumber = it.StockMaxNumber * medical.MinNumber
3732
+			}
3733
+		}
3725 3734
 		for _, it := range drugInfolist {
3726 3735
 			over_count += it.StockMaxNumber*medical.MinNumber + it.StockMinNumber
3727 3736
 		}

+ 3 - 0
controllers/his_api_controller.go View File

@@ -2670,6 +2670,8 @@ func (c *HisApiController) DeletePrescription() {
2670 2670
 						//更新库存
2671 2671
 						service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, flush_count)
2672 2672
 
2673
+						//更新基础库库存
2674
+						service.UpdateGoodInfoSumCountSix(item.ProjectId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
2673 2675
 						//查询今日该耗材退库数量
2674 2676
 						//cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2675 2677
 						//var cancel_Count int64
@@ -3061,6 +3063,7 @@ func (c *HisApiController) DeleteProject() {
3061 3063
 
3062 3064
 				//更新剩余库存
3063 3065
 				service.UpdateSumGood(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, over_count)
3066
+
3064 3067
 				//查询今日该患者开了多少耗材
3065 3068
 				//projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
3066 3069
 				//

+ 215 - 0
models/new_stock_models.go View File

@@ -177,3 +177,218 @@ type XtDialysisSetting struct {
177 177
 func (XtDialysisSetting) TableName() string {
178 178
 	return "xt_dialysis_setting"
179 179
 }
180
+
181
+type VmStockFlowTwenty struct {
182
+	ID                  int64           `gorm:"column:id" json:"id" form:"id"`
183
+	WarehousingId       int64           `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
184
+	GoodId              int64           `gorm:"column:good_id" json:"good_id" form:"good_id"`
185
+	Count               int64           `gorm:"column:count" json:"count" form:"count"`
186
+	UserOrgId           int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
187
+	PatientId           int64           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
188
+	SystemTime          int64           `gorm:"column:system_time" json:"system_time" form:"system_time"`
189
+	ConsumableType      int64           `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
190
+	IsSys               int64           `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
191
+	Price               float64         `gorm:"column:price" json:"price" form:"price"`
192
+	WarehousingDetailId int64           `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
193
+	BuyPrice            float64         `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
194
+	IsRead              int64           `gorm:"column:is_read" json:"is_read" form:"is_read"`
195
+	OverCount           int64           `gorm:"column:over_count" json:"over_count" form:"over_count"`
196
+	Ctime               int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
197
+	WarehousingInfo     WarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingId" json:"xt_warehouse_info"`
198
+}
199
+
200
+func (VmStockFlowTwenty) TableName() string {
201
+	return "xt_stock_flow"
202
+}
203
+
204
+type GoodInfoTwenty struct {
205
+	ID                     int64                   `gorm:"column:id" json:"id" form:"id"`
206
+	SpecificationName      string                  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
207
+	GoodTypeId             int64                   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
208
+	BuyPrice               float64                 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
209
+	Manufacturer           int64                   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
210
+	Status                 int64                   `gorm:"column:status" json:"status" form:"status"`
211
+	OrgId                  int64                   `gorm:"column:org_id" json:"org_id" form:"org_id"`
212
+	GoodName               string                  `gorm:"column:good_name" json:"good_name" form:"good_name"`
213
+	RetailPrice            float64                 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
214
+	Ctime                  int64                   `gorm:"column:ctime" json:"ctime" form:"ctime"`
215
+	PackingUnit            string                  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
216
+	PackingPrice           float64                 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
217
+	StWarehousingInfo      []*StWarehousingInfo    `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
218
+	WarehousingInfoOne     []*StartWarehousingInfo `gorm:"json:"warehouse_info"` //期间增加
219
+	WarehousingInfoStart   []*StartWarehousingInfo `gorm:"json:"warehouse_info_start"`
220
+	WarehousingInfoEnd     []*StartWarehousingInfo `gorm:"json:"warehouse_info_end"`
221
+	WarehouseOutInfoEnd    []*VmStockFlowTwenty
222
+	WarehouseOutInfoStart  []*VmStockFlowTwenty
223
+	WarehouseInfoEnd       []*VmStockFlowTwenty //期末入库量
224
+	StartFlowWarehouseInfo []*VmStockFlowTwenty //本期增加
225
+	//期初结余
226
+	StartFlowInfo    []*VmStockFlowTwenty
227
+	StartOutFlowInfo []*VmStockFlowTwenty
228
+	//期末结余
229
+	EndFlowInfo    []*VmStockFlowTwenty
230
+	EndFlowOutInfo []*VmStockFlowTwenty
231
+	//期初退库
232
+	StartCancelFlowInfo []*VmStockFlowTwenty
233
+	//期末退库
234
+	EndCancelFLowInfo []*VmStockFlowTwenty
235
+
236
+	StartEndCancelFLowInfo []*VmStockFlowTwenty
237
+
238
+	WareStartStockInventoryProfit []*VmStockFlowTwenty //期初盘盈
239
+	WareStartStockInventoryLosses []*VmStockFlowTwenty //期初盘亏
240
+
241
+	WareEndStockInventoryProfit []*VmStockFlowTwenty //期末盘盈
242
+	WareEndStockInventoryLosses []*VmStockFlowTwenty //期末盘亏
243
+
244
+	WareStartEndStockInventoryProfit []*VmStockFlowTwenty //期间盘盈
245
+	WareStartEndStockInventoryLosses []*VmStockFlowTwenty //期间盘亏
246
+}
247
+
248
+func (GoodInfoTwenty) TableName() string {
249
+	return "xt_good_information"
250
+}
251
+
252
+type CancelStockInfoTwenty struct {
253
+	ID              int64   `gorm:"column:id" json:"id"`
254
+	GoodId          int64   `gorm:"column:good_id" json:"good_id"`
255
+	Count           int64   `gorm:"column:count" json:"count"`
256
+	Price           float64 `gorm:"column:price" json:"price"`
257
+	Ctime           int64   `gorm:"column:ctime" json:"ctime"`
258
+	Mtime           int64   `gorm:"column:mtime" json:"mtime"`
259
+	Status          int64   `gorm:"column:status" json:"status"`
260
+	OrgId           int64   `gorm:"column:org_id" json:"org_id"`
261
+	Number          string  `gorm:"column:number" json:"number" form:"number"`
262
+	WarehouseInfoId int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
263
+	PatientId       int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
264
+	RecordDate      int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
265
+	IsCheck         int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
266
+}
267
+
268
+func (CancelStockInfoTwenty) TableName() string {
269
+	return "xt_cancel_stock_info"
270
+}
271
+
272
+type WarehouseOutInfoTwenty struct {
273
+	ID               int64           `gorm:"column:id" json:"id"`
274
+	WarehouseOutId   int64           `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
275
+	WarehouseInfotId int64           `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
276
+	GoodId           int64           `gorm:"column:good_id" json:"good_id"`
277
+	Count            int64           `gorm:"column:count" json:"count"`
278
+	Price            float64         `gorm:"column:price" json:"price"`
279
+	TotalPrice       float64         `gorm:"column:total_price" json:"total_price"`
280
+	Mtime            int64           `gorm:"column:mtime" json:"mtime"`
281
+	Ctime            int64           `gorm:"column:ctime" json:"ctime"`
282
+	Status           int64           `gorm:"column:status" json:"status"`
283
+	OrgId            int64           `gorm:"column:org_id" json:"org_id"`
284
+	IsSys            int64           `gorm:"column:is_sys" json:"is_sys"`
285
+	SysRecordTime    int64           `gorm:"column:sys_record_time" json:"sys_record_time"`
286
+	PatientId        int64           `gorm:"column:patient_id" json:"patient_id"`
287
+	ConsumableType   int64           `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
288
+	ProjectId        int64           `gorm:"column:project_id" json:"project_id" form:"project_id"`
289
+	StorehouseId     int64           `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
290
+	BuyPrice         float64         `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
291
+	StockCount       string          `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
292
+	IsCheck          int64           `gorm:"column:is_check" json:"is_check" form:"is_check"`
293
+	WarehousingInfo  WarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId" `
294
+	OverCount        int64           `gorm:"column:over_count" json:"over_count" form:"over_count"`
295
+}
296
+
297
+func (WarehouseOutInfoTwenty) TableName() string {
298
+	return "xt_warehouse_out_info"
299
+}
300
+
301
+type WarehousingInfoTwenty struct {
302
+	ID               int64   `gorm:"column:id" json:"id"`
303
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id"`
304
+	GoodId           int64   `gorm:"column:good_id" json:"good_id"`
305
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count"`
306
+	Price            float64 `gorm:"column:price" json:"price"`
307
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price"`
308
+	Dealer           int64   `gorm:"column:dealer" json:"dealer"`
309
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer"`
310
+	Ctime            int64   `gorm:"column:ctime" json:"ctime"`
311
+	Mtime            int64   `gorm:"column:mtime" json:"mtime"`
312
+	Status           int64   `gorm:"column:status" json:"status"`
313
+	OrgId            int64   `gorm:"column:org_id" json:"org_id"`
314
+	StockCount       int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
315
+	WarehouseInfoId  int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
316
+	PackingPrice     float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
317
+	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
318
+	IsCheck          int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
319
+}
320
+
321
+func (WarehousingInfoTwenty) TableName() string {
322
+	return "xt_warehouse_info"
323
+}
324
+
325
+type VmBaseDrugTwenty struct {
326
+	ID                               int64             `gorm:"column:id" json:"id" form:"id"`
327
+	DrugType                         int64             `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
328
+	DrugName                         string            `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
329
+	MaxUnit                          string            `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
330
+	MinNumber                        int64             `gorm:"column:min_number" json:"min_number" form:"min_number"`
331
+	MinUnit                          string            `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
332
+	Dose                             string            `gorm:"column:dose" json:"dose" form:"dose"`
333
+	DoseUnit                         string            `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
334
+	RetailPrice                      float64           `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
335
+	MinPrice                         float64           `gorm:"column:min_price" json:"min_price" form:"min_price"`
336
+	LastPrice                        float64           `gorm:"column:last_price" json:"last_price" form:"last_price"`
337
+	Manufacturer                     int64             `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
338
+	Status                           int64             `gorm:"column:status" json:"status" form:"status"`
339
+	Ctime                            int64             `gorm:"column:ctime" json:"ctime" form:"ctime"`
340
+	Mtime                            int64             `gorm:"column:mtime" json:"mtime" form:"mtime"`
341
+	OrgId                            int64             `gorm:"column:org_id" json:"org_id" form:"org_id"`
342
+	DrugFlowWarehouseInfo            []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_flow_info"`
343
+	DrugActFlowWarehouseInfo         []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_act_flow_info"`
344
+	DrugWarehouseInfoStart           []*DrugFlowTwenty //期初入库结余
345
+	DrugWarehouseOutInfoStart        []*DrugFlowTwenty //期初出库结余
346
+	DrugWarehouseOutInfoEnd          []*DrugFlowTwenty //期末出库结余
347
+	DrugWarehouseInfoEnd             []*DrugFlowTwenty //期末入库结余
348
+	DrugWarehouseInfoStartEnd        []*DrugFlowTwenty //期中增加
349
+	DrugWarehouseOutInfoStartEnd     []*DrugFlowTwenty //  期中减少
350
+	WareStartStockInventoryProfit    []*DrugFlowTwenty //期初盘盈
351
+	WareStartStockInventoryLosses    []*DrugFlowTwenty //期初盘亏
352
+	WareEndStockInventoryProfit      []*DrugFlowTwenty //期末盘盈
353
+	WareEndStockInventoryLosses      []*DrugFlowTwenty //期末盘亏
354
+	WareStartEndStockInventoryProfit []*DrugFlowTwenty //期间盘盈
355
+	WareStartEndStockInventoryLosses []*DrugFlowTwenty //期间盘亏
356
+	WareStartStockCancelInfo         []*DrugFlowTwenty //期初结余退库
357
+	WareEndStockCancelInfo           []*DrugFlowTwenty //期末结余退库
358
+	WareStartEndStockCancelInfo      []*DrugFlowTwenty //期中减少退库
359
+
360
+}
361
+
362
+func (VmBaseDrugTwenty) TableName() string {
363
+	return "xt_base_drug"
364
+}
365
+
366
+type DrugFlowTwenty struct {
367
+	ID                     int64                  `gorm:"column:id" json:"id" form:"id"`
368
+	WarehousingId          int64                  `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
369
+	DrugId                 int64                  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
370
+	Count                  int64                  `gorm:"column:count" json:"count" form:"count"`
371
+	UserOrgId              int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
372
+	PatientId              int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
373
+	SystemTime             int64                  `gorm:"column:system_time" json:"system_time" form:"system_time"`
374
+	ConsumableType         int64                  `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
375
+	Manufacturer           int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
376
+	Status                 int64                  `gorm:"column:status" json:"status" form:"status"`
377
+	Ctime                  int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
378
+	Mtime                  int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
379
+	Price                  float64                `gorm:"column:price" json:"price" form:"price"`
380
+	WarehousingDetailId    int64                  `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
381
+	WarehouseOutDetailId   int64                  `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
382
+	CancelOutDetailId      int64                  `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
383
+	MaxUnit                string                 `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
384
+	MinUnit                string                 `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
385
+	StorehouseId           int64                  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
386
+	DrugWarehouseInfoOne   DrugWarehouseInfo      `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingDetailId"json:"xt_drug_warehouse_info" `
387
+	IsRead                 int64                  `gorm:"column:is_read" json:"is_read" form:"is_read"`
388
+	IsCheck                int64                  `gorm:"column:is_check" json:"is_check" form:"is_check"`
389
+	XtDrugWarehouseOutInfo XtDrugWarehouseOutInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId"json:"xt_drug_warehouse_out_info" `
390
+}
391
+
392
+func (DrugFlowTwenty) TableName() string {
393
+	return "xt_drug_flow"
394
+}

+ 25 - 0
service/dialysis_solution_service.go View File

@@ -163,3 +163,28 @@ func GetDialysisParameterList(keywords string, limit int64, page int64, partitio
163 163
 
164 164
 	return schedule, total, err
165 165
 }
166
+
167
+func GetDialysisGoodTotalCount(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
168
+
169
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
170
+
171
+	if scheduleDate > 0 {
172
+		db = db.Where("schedule_date = ?", scheduleDate)
173
+	}
174
+	if schedule_type > 0 {
175
+		db = db.Where("schedule_type = ?", schedule_type)
176
+	}
177
+	if partition_id > 0 {
178
+		db = db.Where("partition_id = ?", partition_id)
179
+	}
180
+	if orgID > 0 {
181
+		db = db.Where("user_org_id  = ?", orgID)
182
+	}
183
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
184
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
185
+		Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
186
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
187
+
188
+	return schedule, err
189
+
190
+}

+ 31 - 31
service/self_drug_service.go View File

@@ -1582,7 +1582,7 @@ func GetGoodExpiryDateQuery(storehouse_id int64, expiry_type int64, keyword stri
1582 1582
 	return info, total, err
1583 1583
 }
1584 1584
 
1585
-func GetGoodPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64) (goodinfo []*models.GoodInfo, total int64, err error) {
1585
+func GetGoodPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64) (goodinfo []*models.GoodInfoTwenty, total int64, err error) {
1586 1586
 
1587 1587
 	db := XTReadDB().Model(&goodinfo).Where("status = 1 and total_count > 0")
1588 1588
 	offset := (page - 1) * limit
@@ -1675,7 +1675,7 @@ func GetDrugExpiryDateQuery(storehouse_id int64, expiry_type int64, keyword stri
1675 1675
 	return info, total, err
1676 1676
 }
1677 1677
 
1678
-func GetDrugPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrug, total int64, err error) {
1678
+func GetDrugPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrugTwenty, total int64, err error) {
1679 1679
 
1680 1680
 	db := XTReadDB().Model(&druginfo).Where("status = 1")
1681 1681
 	offset := (page - 1) * limit
@@ -1993,7 +1993,7 @@ func GetAddGoodWarehouseInfoList(good_id int64, orgid int64, startime int64, end
1993 1993
 	return info, err
1994 1994
 }
1995 1995
 
1996
-func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64) (info []*models.VmStockFlow, err error) {
1996
+func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
1997 1997
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type =1")
1998 1998
 	if good_id > 0 {
1999 1999
 		db = db.Where("good_id = ?", good_id)
@@ -2011,7 +2011,7 @@ func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64)
2011 2011
 	return info, err
2012 2012
 }
2013 2013
 
2014
-func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2014
+func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2015 2015
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
2016 2016
 	if good_id > 0 {
2017 2017
 		db = db.Where("good_id = ?", good_id)
@@ -2029,7 +2029,7 @@ func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endt
2029 2029
 	return outinfo, err
2030 2030
 }
2031 2031
 
2032
-func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2032
+func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2033 2033
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 7)")
2034 2034
 	if good_id > 0 {
2035 2035
 		db = db.Where("good_id = ?", good_id)
@@ -2047,7 +2047,7 @@ func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endti
2047 2047
 	return outinfo, err
2048 2048
 }
2049 2049
 
2050
-func FindeStartFlowInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlow, err error) {
2050
+func FindeStartFlowInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlowTwenty, err error) {
2051 2051
 
2052 2052
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2053 2053
 	if good_id > 0 {
@@ -2063,7 +2063,7 @@ func FindeStartFlowInfo(good_id int64, orgid int64, startime int64) (info []*mod
2063 2063
 	return info, err
2064 2064
 }
2065 2065
 
2066
-func FindeStartFlowOutInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlow, err error) {
2066
+func FindeStartFlowOutInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlowTwenty, err error) {
2067 2067
 
2068 2068
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 2 or consumable_type = 3)")
2069 2069
 	if good_id > 0 {
@@ -2079,7 +2079,7 @@ func FindeStartFlowOutInfo(good_id int64, orgid int64, startime int64) (info []*
2079 2079
 	return info, err
2080 2080
 }
2081 2081
 
2082
-func FindeStartCancelInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlow, err error) {
2082
+func FindeStartCancelInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlowTwenty, err error) {
2083 2083
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 4 or consumable_type = 7)")
2084 2084
 	if good_id > 0 {
2085 2085
 		db = db.Where("good_id = ?", good_id)
@@ -2094,7 +2094,7 @@ func FindeStartCancelInfo(good_id int64, orgid int64, startime int64) (info []*m
2094 2094
 	return info, err
2095 2095
 }
2096 2096
 
2097
-func FindEndStartFlowInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlow, err error) {
2097
+func FindEndStartFlowInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
2098 2098
 
2099 2099
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2100 2100
 	if good_id > 0 {
@@ -2110,7 +2110,7 @@ func FindEndStartFlowInfo(good_id int64, orgid int64, endtime int64) (info []*mo
2110 2110
 	return info, err
2111 2111
 }
2112 2112
 
2113
-func FindeEndFLowOutInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlow, err error) {
2113
+func FindeEndFLowOutInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
2114 2114
 
2115 2115
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 2 or consumable_type = 3)")
2116 2116
 	if good_id > 0 {
@@ -2126,7 +2126,7 @@ func FindeEndFLowOutInfo(good_id int64, orgid int64, endtime int64) (info []*mod
2126 2126
 	return info, err
2127 2127
 }
2128 2128
 
2129
-func FindEndCancelInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlow, err error) {
2129
+func FindEndCancelInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
2130 2130
 
2131 2131
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 4 or consumable_type = 7)")
2132 2132
 	if good_id > 0 {
@@ -2142,7 +2142,7 @@ func FindEndCancelInfo(good_id int64, orgid int64, endtime int64) (info []*model
2142 2142
 	return info, err
2143 2143
 }
2144 2144
 
2145
-func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlow, err error) {
2145
+func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2146 2146
 
2147 2147
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
2148 2148
 	if good_id > 0 {
@@ -2158,7 +2158,7 @@ func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64) (outinfo
2158 2158
 	return outinfo, err
2159 2159
 }
2160 2160
 
2161
-func FindeStartStockInventoryProfit(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlow, err error) {
2161
+func FindeStartStockInventoryProfit(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2162 2162
 
2163 2163
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2164 2164
 	if good_id > 0 {
@@ -2174,7 +2174,7 @@ func FindeStartStockInventoryProfit(good_id int64, orgid int64, startime int64)
2174 2174
 	return outinfo, err
2175 2175
 }
2176 2176
 
2177
-func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2177
+func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2178 2178
 
2179 2179
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2180 2180
 	if good_id > 0 {
@@ -2193,7 +2193,7 @@ func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, end
2193 2193
 	return outinfo, err
2194 2194
 }
2195 2195
 
2196
-func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2196
+func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2197 2197
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2198 2198
 	if good_id > 0 {
2199 2199
 		db = db.Where("good_id = ?", good_id)
@@ -2211,7 +2211,7 @@ func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, en
2211 2211
 	return outinfo, err
2212 2212
 }
2213 2213
 
2214
-func FindStartStockInventoryLosses(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlow, err error) {
2214
+func FindStartStockInventoryLosses(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2215 2215
 
2216 2216
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2217 2217
 	if good_id > 0 {
@@ -2227,7 +2227,7 @@ func FindStartStockInventoryLosses(good_id int64, orgid int64, startime int64) (
2227 2227
 	return outinfo, err
2228 2228
 }
2229 2229
 
2230
-func GetDrugWarehouseInfoStart(drug_id int64, orgid int64, startTime int64) (info []*models.DrugFlow, err error) {
2230
+func GetDrugWarehouseInfoStart(drug_id int64, orgid int64, startTime int64) (info []*models.DrugFlowTwenty, err error) {
2231 2231
 
2232 2232
 	db := XTReadDB().Model(&info).Where("status = 1 and  consumable_type=1 ")
2233 2233
 	if drug_id > 0 {
@@ -2243,7 +2243,7 @@ func GetDrugWarehouseInfoStart(drug_id int64, orgid int64, startTime int64) (inf
2243 2243
 	return info, err
2244 2244
 }
2245 2245
 
2246
-func DrugWarehouseInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlow, err error) {
2246
+func DrugWarehouseInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2247 2247
 
2248 2248
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2249 2249
 	if drug_id > 0 {
@@ -2259,7 +2259,7 @@ func DrugWarehouseInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*mo
2259 2259
 	return info, err
2260 2260
 }
2261 2261
 
2262
-func DrugWarehouseOutInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlow, err error) {
2262
+func DrugWarehouseOutInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2263 2263
 
2264 2264
 	db := XTReadDB().Model(&info).Where("status = 1 and (consumable_type = 2 or consumable_type= 3)")
2265 2265
 	if drug_id > 0 {
@@ -2275,7 +2275,7 @@ func DrugWarehouseOutInfoEnd(drug_id int64, orgid int64, endTime int64) (info []
2275 2275
 	return info, err
2276 2276
 }
2277 2277
 
2278
-func GetEndDrugFlowCancelInfo(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlow, err error) {
2278
+func GetEndDrugFlowCancelInfo(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2279 2279
 	db := XTReadDB().Model(&info).Where("status = 1 and (consumable_type = 4 or consumable_type= 7)")
2280 2280
 	if drug_id > 0 {
2281 2281
 		db = db.Where("drug_id = ?", drug_id)
@@ -2290,7 +2290,7 @@ func GetEndDrugFlowCancelInfo(drug_id int64, orgid int64, endTime int64) (info [
2290 2290
 	return info, err
2291 2291
 }
2292 2292
 
2293
-func GetDrugWarehouseStartEnd(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlow, err error) {
2293
+func GetDrugWarehouseStartEnd(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2294 2294
 	db := XTReadDB().Model(&info).Where("status = 1 and  consumable_type = 1")
2295 2295
 	if drug_id > 0 {
2296 2296
 		db = db.Where("drug_id = ?", drug_id)
@@ -2308,7 +2308,7 @@ func GetDrugWarehouseStartEnd(drug_id int64, orgid int64, startTime int64, endTi
2308 2308
 	return info, err
2309 2309
 }
2310 2310
 
2311
-func FindeDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlow, err error) {
2311
+func FindeDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2312 2312
 	db := XTReadDB().Model(&info).Where("status = 1  and (consumable_type = 2 or consumable_type= 3)")
2313 2313
 	if drug_id > 0 {
2314 2314
 		db = db.Where("drug_id = ?", drug_id)
@@ -2326,7 +2326,7 @@ func FindeDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endT
2326 2326
 	return info, err
2327 2327
 }
2328 2328
 
2329
-func FindStartEndDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlow, err error) {
2329
+func FindStartEndDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2330 2330
 	db := XTReadDB().Model(&info).Where("status = 1  and (consumable_type= 7)")
2331 2331
 	if drug_id > 0 {
2332 2332
 		db = db.Where("drug_id = ?", drug_id)
@@ -2396,7 +2396,7 @@ func GetDrugFlowSart(drug_id int64, user_org_id int64, ctime int64) (flow []*mod
2396 2396
 	return flow, err
2397 2397
 }
2398 2398
 
2399
-func GetDrugFlowOut(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2399
+func GetDrugFlowOut(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2400 2400
 
2401 2401
 	db := XTReadDB().Model(&flow).Where("status = 1  and (consumable_type = 2 or consumable_type= 3)")
2402 2402
 	if drug_id > 0 {
@@ -2412,7 +2412,7 @@ func GetDrugFlowOut(drug_id int64, user_org_id int64, ctime int64) (flow []*mode
2412 2412
 	return flow, err
2413 2413
 }
2414 2414
 
2415
-func GetStartDrugFlowCancelInfo(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2415
+func GetStartDrugFlowCancelInfo(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2416 2416
 
2417 2417
 	db := XTReadDB().Model(&flow).Where("status = 1  and (consumable_type = 4 or consumable_type = 7)")
2418 2418
 
@@ -2429,7 +2429,7 @@ func GetStartDrugFlowCancelInfo(drug_id int64, user_org_id int64, ctime int64) (
2429 2429
 	return flow, err
2430 2430
 }
2431 2431
 
2432
-func GetDrugFlowStartProfit(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2432
+func GetDrugFlowStartProfit(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2433 2433
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 10")
2434 2434
 	if drug_id > 0 {
2435 2435
 		db = db.Where("drug_id = ?", drug_id)
@@ -2444,7 +2444,7 @@ func GetDrugFlowStartProfit(drug_id int64, user_org_id int64, ctime int64) (flow
2444 2444
 	return flow, err
2445 2445
 }
2446 2446
 
2447
-func GetDrugFlowStartLosses(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2447
+func GetDrugFlowStartLosses(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2448 2448
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11 ")
2449 2449
 	if drug_id > 0 {
2450 2450
 		db = db.Where("drug_id = ?", drug_id)
@@ -2459,7 +2459,7 @@ func GetDrugFlowStartLosses(drug_id int64, user_org_id int64, ctime int64) (flow
2459 2459
 	return flow, err
2460 2460
 }
2461 2461
 
2462
-func GetDrugFlowEndProfit(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlow, err error) {
2462
+func GetDrugFlowEndProfit(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2463 2463
 
2464 2464
 	db := XTReadDB().Model(&flow).Where("status = 1 and consumable_type = 10")
2465 2465
 	if drug_id > 0 {
@@ -2475,7 +2475,7 @@ func GetDrugFlowEndProfit(drug_id int64, user_org_id int64, endtime int64) (flow
2475 2475
 	return flow, err
2476 2476
 }
2477 2477
 
2478
-func GetDrugFlowEndLosses(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlow, err error) {
2478
+func GetDrugFlowEndLosses(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2479 2479
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11")
2480 2480
 	if drug_id > 0 {
2481 2481
 		db = db.Where("drug_id = ?", drug_id)
@@ -2490,7 +2490,7 @@ func GetDrugFlowEndLosses(drug_id int64, user_org_id int64, endtime int64) (flow
2490 2490
 	return flow, err
2491 2491
 }
2492 2492
 
2493
-func GetDrugFlowStartEndProfit(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlow, err error) {
2493
+func GetDrugFlowStartEndProfit(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2494 2494
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 10 ")
2495 2495
 	if drug_id > 0 {
2496 2496
 		db = db.Where("drug_id = ?", drug_id)
@@ -2508,7 +2508,7 @@ func GetDrugFlowStartEndProfit(drug_id int64, user_org_id int64, startime int64,
2508 2508
 	return flow, err
2509 2509
 }
2510 2510
 
2511
-func GetDrugFlowStartEndLosses(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlow, err error) {
2511
+func GetDrugFlowStartEndLosses(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2512 2512
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11 ")
2513 2513
 	if drug_id > 0 {
2514 2514
 		db = db.Where("drug_id = ?", drug_id)

+ 20 - 0
service/user_service.go View File

@@ -48,6 +48,26 @@ func GetAllDoctorAndNurse(orgId, appid int64) (doctors []AdminUserList, nurses [
48 48
 	return
49 49
 }
50 50
 
51
+func GetAllDoctorAndNurseSix(orgId, appid int64) (doctors []AdminUserList, nurses []AdminUserList, err error) {
52
+
53
+	var users []AdminUserList
54
+	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("org_id=? and app_id =? and uar.user_type IN (2,3) and ua.status=1", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&users).Error
55
+	if err != nil {
56
+		return
57
+	}
58
+	if len(users) == 0 {
59
+		return
60
+	}
61
+	for _, item := range users {
62
+		if item.UserType == 2 {
63
+			doctors = append(doctors, item)
64
+		} else {
65
+			nurses = append(nurses, item)
66
+		}
67
+	}
68
+	return
69
+}
70
+
51 71
 func GetAllAdminUsers(orgId, appid int64) (list []*AdminUserList, err error) {
52 72
 
53 73
 	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.org_id=? and uar.app_id =? and ua.status=1", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error