Sfoglia il codice sorgente

11月8日库存管理

XMLWAN 3 anni fa
parent
commit
22d06cdc31

+ 2 - 2
conf/app.conf Vedi File

1
 appname = 血透
1
 appname = 血透
2
-httpport = 9529
3
-runmode = dev
2
+httpport = 9531
3
+runmode = prod
4
 
4
 
5
 #
5
 #
6
 copyrequestbody = true
6
 copyrequestbody = true

+ 6 - 7
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Vedi File

309
 func (this *StaffScheduleApiController) DeleteSchedule() {
309
 func (this *StaffScheduleApiController) DeleteSchedule() {
310
 	id, _ := this.GetInt64("id")
310
 	id, _ := this.GetInt64("id")
311
 	fmt.Println("id", id)
311
 	fmt.Println("id", id)
312
-	err := service.DeleteSchedule(id)
312
+
313
 	org_id := this.GetMobileAdminUserInfo().Org.Id
313
 	org_id := this.GetMobileAdminUserInfo().Org.Id
314
-	schedule, _ := service.GetSchedule(org_id, id)
315
-	if schedule == nil {
316
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
317
-		return
318
-	}
314
+	err := service.DeleteSchedule(id)
315
+	schedule, _ := service.GetScheduleNight(org_id, id)
316
+
319
 	redis := service.RedisClient()
317
 	redis := service.RedisClient()
320
 
318
 
321
 	//处方
319
 	//处方
339
 
337
 
340
 	keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
338
 	keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
341
 	redis.Set(keySeven, "", time.Second)
339
 	redis.Set(keySeven, "", time.Second)
342
-	fmt.Println(err)
340
+
343
 	defer redis.Close()
341
 	defer redis.Close()
344
 	fmt.Println(err)
342
 	fmt.Println(err)
343
+
345
 	returnData := make(map[string]interface{}, 0)
344
 	returnData := make(map[string]interface{}, 0)
346
 	returnData["msg"] = "ok"
345
 	returnData["msg"] = "ok"
347
 	this.ServeSuccessJSON(returnData)
346
 	this.ServeSuccessJSON(returnData)

+ 10 - 0
service/schedule_service.go Vedi File

242
 	return &schedule, nil
242
 	return &schedule, nil
243
 }
243
 }
244
 
244
 
245
+func GetScheduleNight(orgID, id int64) (*models.Schedule, error) {
246
+	var schedule models.Schedule
247
+	var err error
248
+	err = readDb.Model(&models.Schedule{}).Where("id = ? and user_org_id=?", id, orgID).First(&schedule).Error
249
+	if err != nil {
250
+		return nil, err
251
+	}
252
+	return &schedule, nil
253
+}
254
+
245
 func UpdateSchedule(m *models.Schedule) error {
255
 func UpdateSchedule(m *models.Schedule) error {
246
 	utx := XTWriteDB().Begin()
256
 	utx := XTWriteDB().Begin()
247
 	err := utx.Save(&m).Error
257
 	err := utx.Save(&m).Error

+ 73 - 0
service/stock_service.go Vedi File

2424
 		ut.Rollback()
2424
 		ut.Rollback()
2425
 		return
2425
 		return
2426
 	}
2426
 	}
2427
+	err = ut.Model(&models.VmStockFlow{}).Where("cancel_stock_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2428
+	if err != nil {
2429
+		ut.Rollback()
2430
+		return
2431
+	}
2427
 	ut.Commit()
2432
 	ut.Commit()
2428
 	return
2433
 	return
2429
 }
2434
 }
5377
 	return info, err
5382
 	return info, err
5378
 }
5383
 }
5379
 
5384
 
5385
+func GetCurrentWarehosueInfoOne(id int64) (models.DrugWarehouseInfo, error) {
5386
+
5387
+	info := models.DrugWarehouseInfo{}
5388
+	err := XTReadDB().Model(&info).Where("id=?", id).Find(&info).Error
5389
+	return info, err
5390
+}
5391
+
5380
 func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
5392
 func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
5381
 
5393
 
5382
 	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber, "stock_min_number": info.StockMinNumber}).Error
5394
 	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber, "stock_min_number": info.StockMinNumber}).Error
5483
 	return err
5495
 	return err
5484
 }
5496
 }
5485
 
5497
 
5498
+func UpdatedStockFlowByGoodId(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5499
+
5500
+	err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count}).Error
5501
+	return err
5502
+}
5503
+
5486
 func UpdatedStockFlowByGoodIdOne(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5504
 func UpdatedStockFlowByGoodIdOne(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5487
 
5505
 
5488
 	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
5506
 	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
5536
 	return &flow, nil
5554
 	return &flow, nil
5537
 }
5555
 }
5538
 
5556
 
5557
+func UpdateStockFlowTwo(id int64, flow models.VmStockFlow) error {
5558
+
5559
+	err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count}).Error
5560
+	return err
5561
+}
5562
+
5539
 func UpdateStockFlowThree(id int64, flow models.VmStockFlow) error {
5563
 func UpdateStockFlowThree(id int64, flow models.VmStockFlow) error {
5540
 
5564
 
5541
 	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, "product_date": flow.ProductDate, "expire_date": flow.ExpireDate}).Error
5565
 	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, "product_date": flow.ProductDate, "expire_date": flow.ExpireDate}).Error
5569
 	return err
5593
 	return err
5570
 }
5594
 }
5571
 
5595
 
5596
+func GetDrugWarehouseOutInfoByWarehosueId(drugid int64, patientid int64, recorddate int64, warehosueinfoid int64) (*models.DrugWarehouseOutInfo, error) {
5597
+	info := models.DrugWarehouseOutInfo{}
5598
+	err := XTReadDB().Model(&info).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and warehouse_info_id  = ? and status = 1", drugid, patientid, recorddate, warehosueinfoid).Find(&info).Error
5599
+	if err == gorm.ErrRecordNotFound {
5600
+		return nil, err
5601
+	}
5602
+	if err != nil {
5603
+		return nil, err
5604
+	}
5605
+	return &info, nil
5606
+}
5607
+
5608
+func GetDrugFlowRecord(warehouse_out_order_number string, drugid int64, patientid int64) (*models.DrugFlow, error) {
5609
+
5610
+	drugFlow := models.DrugFlow{}
5611
+
5612
+	err := XTReadDB().Where("warehouse_out_order_number = ? and drug_id =? and patient_id = ? and status = 1", warehouse_out_order_number, drugid, patientid).Find(&drugFlow).Error
5613
+
5614
+	if err == gorm.ErrRecordNotFound {
5615
+		return nil, err
5616
+	}
5617
+	if err != nil {
5618
+		return nil, err
5619
+	}
5620
+	return &drugFlow, nil
5621
+}
5622
+
5572
 func ModifyDrugFlow(flow models.DrugFlow, warehouse_out_order_number string, drugid int64, patient_id int64) error {
5623
 func ModifyDrugFlow(flow models.DrugFlow, warehouse_out_order_number string, drugid int64, patient_id int64) error {
5573
 
5624
 
5574
 	err := XTWriteDB().Model(&flow).Where("warehouse_out_order_number = ? and drug_id = ? and patient_id = ? and status = 1", warehouse_out_order_number, drugid, patient_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit}).Error
5625
 	err := XTWriteDB().Model(&flow).Where("warehouse_out_order_number = ? and drug_id = ? and patient_id = ? and status = 1", warehouse_out_order_number, drugid, patient_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit}).Error
5581
 	return err
5632
 	return err
5582
 }
5633
 }
5583
 
5634
 
5635
+func GetDrugAutoReduceRecordOne(drugid int64, patientid int64, recorddate int64) (detail []*models.DrugAutomaticReduceDetail, err error) {
5636
+
5637
+	err = XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time  = ? and status = 1", drugid, patientid, recorddate).Find(&detail).Error
5638
+
5639
+	return detail, err
5640
+}
5641
+
5642
+func GetDrugAutoReduceRecord(drugid int64, patientid int64, recorddate int64) (*models.DrugAutomaticReduceDetail, error) {
5643
+
5644
+	detail := models.DrugAutomaticReduceDetail{}
5645
+
5646
+	err := XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time  = ? and status = 1", drugid, patientid, recorddate).Find(&detail).Error
5647
+
5648
+	if err == gorm.ErrRecordNotFound {
5649
+		return nil, err
5650
+	}
5651
+	if err != nil {
5652
+		return nil, err
5653
+	}
5654
+	return &detail, nil
5655
+}
5656
+
5584
 func ModifyAutoMaticReduce(auto models.DrugAutomaticReduceDetail, patientid int64, recordate int64, drugid int64) error {
5657
 func ModifyAutoMaticReduce(auto models.DrugAutomaticReduceDetail, patientid int64, recordate int64, drugid int64) error {
5585
 
5658
 
5586
 	err := XTWriteDB().Model(&auto).Where("patient_id = ? and record_time = ? and drug_id = ? and status = 1", patientid, recordate, drugid).Updates(map[string]interface{}{"count": auto.Count, "count_unit": auto.CountUnit}).Error
5659
 	err := XTWriteDB().Model(&auto).Where("patient_id = ? and record_time = ? and drug_id = ? and status = 1", patientid, recordate, drugid).Updates(map[string]interface{}{"count": auto.Count, "count_unit": auto.CountUnit}).Error