Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
22d06cdc31

+ 2 - 2
conf/app.conf View File

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

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

@@ -309,13 +309,11 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
309 309
 func (this *StaffScheduleApiController) DeleteSchedule() {
310 310
 	id, _ := this.GetInt64("id")
311 311
 	fmt.Println("id", id)
312
-	err := service.DeleteSchedule(id)
312
+
313 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 317
 	redis := service.RedisClient()
320 318
 
321 319
 	//处方
@@ -339,9 +337,10 @@ func (this *StaffScheduleApiController) DeleteSchedule() {
339 337
 
340 338
 	keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
341 339
 	redis.Set(keySeven, "", time.Second)
342
-	fmt.Println(err)
340
+
343 341
 	defer redis.Close()
344 342
 	fmt.Println(err)
343
+
345 344
 	returnData := make(map[string]interface{}, 0)
346 345
 	returnData["msg"] = "ok"
347 346
 	this.ServeSuccessJSON(returnData)

+ 10 - 0
service/schedule_service.go View File

@@ -242,6 +242,16 @@ func GetSchedule(orgID, id int64) (*models.Schedule, error) {
242 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 255
 func UpdateSchedule(m *models.Schedule) error {
246 256
 	utx := XTWriteDB().Begin()
247 257
 	err := utx.Save(&m).Error

+ 73 - 0
service/stock_service.go View File

@@ -2424,6 +2424,11 @@ func DeleteCancelStock(ids []string) (err error) {
2424 2424
 		ut.Rollback()
2425 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 2432
 	ut.Commit()
2428 2433
 	return
2429 2434
 }
@@ -5377,6 +5382,13 @@ func GetCurrentWarehosueInfo(id int64) (info []*models.DrugWarehouseInfo, err er
5377 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 5392
 func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
5381 5393
 
5382 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,6 +5495,12 @@ func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error
5483 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 5504
 func UpdatedStockFlowByGoodIdOne(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5487 5505
 
5488 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,6 +5554,12 @@ func IsExsitStockFlow(goodid int64, cancel_order_number string) (*models.VmStock
5536 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 5563
 func UpdateStockFlowThree(id int64, flow models.VmStockFlow) error {
5540 5564
 
5541 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,6 +5593,33 @@ func ModifyDrugWarehouseOutInfoOne(info models.DrugWarehouseOutInfo, drugid int6
5569 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 5623
 func ModifyDrugFlow(flow models.DrugFlow, warehouse_out_order_number string, drugid int64, patient_id int64) error {
5573 5624
 
5574 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,6 +5632,28 @@ func ModifyDrugFlowOne(flow models.DrugFlow, warehouse_out_order_number string,
5581 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 5657
 func ModifyAutoMaticReduce(auto models.DrugAutomaticReduceDetail, patientid int64, recordate int64, drugid int64) error {
5585 5658
 
5586 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