Explorar el Código

11月8日库存管理

XMLWAN hace 3 años
padre
commit
79c33dba66

+ 60 - 27
controllers/drug_stock_api_contorller.go Ver fichero

@@ -628,26 +628,31 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
628 628
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
629 629
 
630 630
 					drugflow := &models.DrugFlow{
631
-						WarehousingOrder: warehousing.WarehousingOrder,
632
-						WarehousingId:    id,
633
-						DrugId:           drug_id,
634
-						Number:           number,
635
-						ProductDate:      productDates,
636
-						ExpireDate:       expiryDates,
637
-						Count:            warehousing_count,
638
-						Price:            last_price,
639
-						Status:           1,
640
-						Ctime:            ctime,
641
-						UserOrgId:        adminUserInfo.CurrentOrgId,
642
-						Manufacturer:     manufacturer,
643
-						Dealer:           dealer,
644
-						BatchNumber:      batch_number,
645
-						MaxUnit:          max_unit,
646
-						MinUnit:          min_unit,
647
-						ConsumableType:   1,
648
-						IsEdit:           1,
649
-						Creator:          adminUserInfo.AdminUser.Id,
650
-						IsSys:            0,
631
+						WarehousingOrder:    warehousing.WarehousingOrder,
632
+						WarehousingId:       warehouse.ID,
633
+						DrugId:              drug_id,
634
+						Number:              number,
635
+						ProductDate:         productDates,
636
+						ExpireDate:          expiryDates,
637
+						Count:               warehousing_count,
638
+						Price:               last_price,
639
+						Status:              1,
640
+						Ctime:               ctime,
641
+						UserOrgId:           adminUserInfo.CurrentOrgId,
642
+						Manufacturer:        manufacturer,
643
+						Dealer:              dealer,
644
+						BatchNumber:         batch_number,
645
+						MaxUnit:             max_unit,
646
+						MinUnit:             min_unit,
647
+						ConsumableType:      1,
648
+						IsEdit:              1,
649
+						Creator:             adminUserInfo.AdminUser.Id,
650
+						IsSys:               0,
651
+						WarehousingDetailId: id,
652
+					}
653
+
654
+					if max_unit == min_unit {
655
+						drugflow.MaxUnit = min_unit
651 656
 					}
652 657
 
653 658
 					drugFlow = append(drugFlow, drugflow)
@@ -750,23 +755,27 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
750 755
 			//比较大小(加)
751 756
 			// 如果当前的入库数量 大于 历史入库数量
752 757
 			if item.WarehousingCount > warehouseInfo.WarehousingCount {
758
+				fmt.Println("大于333333333333333333333333")
753 759
 				total = item.WarehousingCount - warehouseInfo.WarehousingCount
754 760
 				item.StockMaxNumber = warehouseInfo.StockMaxNumber + total
755 761
 				errs = service.UpDateDrugWarehousingInfo(item)
756 762
 				if len(drugFlow) > 0 {
757 763
 					for _, it := range drugFlow {
758 764
 						flow := models.DrugFlow{
759
-							Count:        item.StockMaxNumber,
765
+							Count:        it.Count,
760 766
 							Manufacturer: it.Manufacturer,
761 767
 							Dealer:       it.Dealer,
762 768
 							Number:       it.Number,
763 769
 							BatchNumber:  it.BatchNumber,
764 770
 							Price:        it.Price,
771
+							MaxUnit:      info.MaxUnit,
772
+							ExpireDate:   it.ExpireDate,
765 773
 						}
766 774
 						if info.MaxUnit == info.MinUnit {
767 775
 							flow.MaxUnit = info.MinUnit
768 776
 						}
769
-						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
777
+
778
+						parseDateErr := service.UpdateDrugFlowNight(flow, it.DrugId, it.WarehousingDetailId)
770 779
 						fmt.Println(parseDateErr)
771 780
 
772 781
 					}
@@ -781,13 +790,19 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
781 790
 				errs = service.UpDateDrugWarehousingInfo(item)
782 791
 				if len(drugFlow) > 0 {
783 792
 					for _, it := range drugFlow {
784
-						fmt.Println(it)
785 793
 						flow := models.DrugFlow{
786
-							Count:   item.StockMaxNumber,
787
-							MaxUnit: item.MaxUnit,
788
-							MinUnit: item.MinUnit,
794
+							Count:       it.Count,
795
+							MaxUnit:     it.MaxUnit,
796
+							MinUnit:     it.MinUnit,
797
+							Number:      it.Number,
798
+							BatchNumber: it.BatchNumber,
799
+							Price:       it.Price,
800
+							ExpireDate:  it.ExpireDate,
789 801
 						}
790
-						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
802
+						if info.MaxUnit == info.MinUnit {
803
+							flow.MaxUnit = info.MinUnit
804
+						}
805
+						parseDateErr := service.UpdateDrugFlowNight(flow, it.DrugId, it.WarehousingDetailId)
791 806
 						fmt.Println(parseDateErr)
792 807
 					}
793 808
 				}
@@ -810,6 +825,24 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
810 825
 					MinUnit:      item.MinUnit,
811 826
 					RetailPrice:  item.RetailPrice,
812 827
 				}
828
+				if len(drugFlow) > 0 {
829
+					for _, it := range drugFlow {
830
+						flow := models.DrugFlow{
831
+							Count:       it.Count,
832
+							MaxUnit:     it.MaxUnit,
833
+							MinUnit:     it.MinUnit,
834
+							Number:      it.Number,
835
+							BatchNumber: it.BatchNumber,
836
+							Price:       it.Price,
837
+							ExpireDate:  it.ExpireDate,
838
+						}
839
+						if info.MaxUnit == info.MinUnit {
840
+							flow.MaxUnit = info.MinUnit
841
+						}
842
+						parseDateErr := service.UpdateDrugFlowNight(flow, it.DrugId, it.WarehousingDetailId)
843
+						fmt.Println(parseDateErr)
844
+					}
845
+				}
813 846
 				errs = service.UpDateDrugWarehousingInfoTwo(item.ID, warehouseinfo)
814 847
 			}
815 848
 		}

+ 9 - 2
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Ver fichero

@@ -710,8 +710,15 @@ func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
710 710
 func (c *StaffScheduleApiController) GetSolutionSchedule() {
711 711
 
712 712
 	orgId := c.GetMobileAdminUserInfo().Org.Id
713
-	solution, _ := service.GetSolutionSchedule(orgId)
713
+	scheduleDate := c.GetString("start_time")
714
+	zoneid, _ := c.GetInt64("zoneid")
715
+	classtype, _ := c.GetInt64("classtype")
716
+	timeLayout := "2006-01-02"
717
+	loc, _ := time.LoadLocation("Local")
718
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
719
+	fmt.Println("时间错2332233323223", theTime.Unix())
720
+	schedule, _ := service.GetSolutionScheduleBySchedule(orgId, zoneid, classtype, theTime.Unix())
714 721
 	c.ServeSuccessJSON(map[string]interface{}{
715
-		"solution": solution,
722
+		"schedule": schedule,
716 723
 	})
717 724
 }

+ 159 - 81
controllers/stock_in_api_controller.go Ver fichero

@@ -303,14 +303,32 @@ func (c *StockManagerApiController) CreateWarehouse() {
303 303
 		}
304 304
 	}
305 305
 
306
-	//入库单创建成功
307
-	errs := service.CreateWarehousingInfo(warehousingInfo)
308
-	for _, its := range stockFlow {
309
-		warehousinginfo, _ := service.GetLastWarehousingInfo(its.GoodId)
310
-		its.WarehousingDetailId = warehousinginfo.ID
306
+	for _, item := range warehousingInfo {
307
+		service.CreatedWarehouseingDetail(item)
308
+		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
309
+		flow := models.VmStockFlow{
310
+			WarehousingOrder:    item.WarehousingOrder,
311
+			WarehousingId:       item.WarehousingId,
312
+			GoodId:              item.GoodId,
313
+			Number:              item.Number,
314
+			ProductDate:         item.ProductDate,
315
+			ExpireDate:          item.ExpiryDate,
316
+			Count:               item.StockCount,
317
+			Price:               item.Price,
318
+			Status:              1,
319
+			Ctime:               ctime,
320
+			UserOrgId:           item.OrgId,
321
+			Manufacturer:        item.Manufacturer,
322
+			Dealer:              item.Dealer,
323
+			LicenseNumber:       item.LicenseNumber,
324
+			IsEdit:              1,
325
+			Creator:             adminUserInfo.AdminUser.Id,
326
+			SystemTime:          operation_time,
327
+			ConsumableType:      1,
328
+			WarehousingDetailId: warehousinginfo.ID,
329
+		}
330
+		service.CreateStockFlowOne(flow)
311 331
 	}
312
-	//创建入库单流水
313
-	service.CreateStockFlow(stockFlow)
314 332
 
315 333
 	info, _ := service.FindLastWarehousingInfo(warehousing.WarehousingOrder)
316 334
 
@@ -328,12 +346,6 @@ func (c *StockManagerApiController) CreateWarehouse() {
328 346
 		fmt.Println(parseDateErr)
329 347
 	}
330 348
 
331
-	if errs != nil {
332
-		utils.ErrorLog(errs.Error())
333
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
334
-		return
335
-	}
336
-
337 349
 	c.ServeSuccessJSON(map[string]interface{}{
338 350
 		"msg":               "入库成功",
339 351
 		"warehousing_order": warehousing_order,
@@ -695,17 +707,18 @@ func (c *StockManagerApiController) EditWarehouse() {
695 707
 
696 708
 				service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
697 709
 
698
-				flowStock := models.VmStockFlow{
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)
710
+				//flowStock := models.VmStockFlow{
711
+				//	Count:         item.WarehousingCount,
712
+				//	Number:        item.Number,
713
+				//	ProductDate:   item.ProductDate,
714
+				//	ExpireDate:    item.ExpiryDate,
715
+				//	Price:         item.Price,
716
+				//	Manufacturer:  item.Manufacturer,
717
+				//	Dealer:        item.Dealer,
718
+				//	LicenseNumber: info.LicenseNumber,
719
+				//}
720
+				//fmt.Println("大于233232322323233232232323233232233223")
721
+				//service.UpdatedStockFlowByGoodIdOne(item.WarehousingId, item.GoodId, flowStock)
709 722
 				//改变库存
710 723
 				good, _ := service.GetLastInfoMationById(info.GoodId)
711 724
 				warhouseCount := strconv.FormatInt(total, 10)
@@ -758,9 +771,16 @@ func (c *StockManagerApiController) EditWarehouse() {
758 771
 	if len(stockFlow) > 0 {
759 772
 		for _, item := range stockFlow {
760 773
 			flow := models.VmStockFlow{
761
-				Count: item.Count,
762
-			}
763
-			parseDateErr := service.UpdateStockFlow(flow, item.GoodId, item.WarehousingId)
774
+				Count:         item.Count,
775
+				Number:        item.Number,
776
+				ProductDate:   item.ProductDate,
777
+				ExpireDate:    item.ExpireDate,
778
+				Price:         item.Price,
779
+				Manufacturer:  item.Manufacturer,
780
+				Dealer:        item.Dealer,
781
+				LicenseNumber: item.LicenseNumber,
782
+			}
783
+			parseDateErr := service.UpdatedStockFlowByGoodIdOne(item.WarehousingId, item.GoodId, flow)
764 784
 			fmt.Println(parseDateErr)
765 785
 		}
766 786
 	}
@@ -2034,7 +2054,7 @@ func (c *StockManagerApiController) CreateCancelStock() {
2034 2054
 	}
2035 2055
 
2036 2056
 	var cancelStockInfos []*models.CancelStockInfo
2037
-	var stockFLow []*models.VmStockFlow
2057
+	//var stockFLow []*models.VmStockFlow
2038 2058
 	if dataBody["cancelStock"] != nil && reflect.TypeOf(dataBody["cancelStock"]).String() == "[]interface {}" {
2039 2059
 		thisStockIn, _ := dataBody["cancelStock"].([]interface{})
2040 2060
 		if len(thisStockIn) > 0 {
@@ -2131,48 +2151,48 @@ func (c *StockManagerApiController) CreateCancelStock() {
2131 2151
 				}
2132 2152
 				cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
2133 2153
 
2134
-				list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2135
-
2136
-				var manufacturer_id int64
2137
-
2138
-				for _, items := range list {
2139
-					if manufacturer == items.ManufacturerName {
2140
-						manufacturer_id = items.ID
2141
-					}
2142
-				}
2143
-
2144
-				flow := &models.VmStockFlow{
2145
-					WarehousingId:           0,
2146
-					GoodId:                  good_id,
2147
-					Number:                  number,
2148
-					LicenseNumber:           "",
2149
-					Count:                   count,
2150
-					UserOrgId:               adminUserInfo.CurrentOrgId,
2151
-					PatientId:               0,
2152
-					SystemTime:              time.Now().Unix(),
2153
-					ConsumableType:          4,
2154
-					IsSys:                   0,
2155
-					WarehousingOrder:        "",
2156
-					WarehouseOutId:          0,
2157
-					WarehouseOutOrderNumber: "",
2158
-					IsEdit:                  0,
2159
-					CancelStockId:           cancelStock.ID,
2160
-					CancelOrderNumber:       cancelStock.OrderNumber,
2161
-					Manufacturer:            manufacturer_id,
2162
-					Dealer:                  0,
2163
-					Creator:                 adminUserInfo.AdminUser.Id,
2164
-					UpdateCreator:           0,
2165
-					Status:                  1,
2166
-					Ctime:                   time.Now().Unix(),
2167
-					Mtime:                   0,
2168
-					Price:                   price,
2169
-					WarehousingDetailId:     0,
2170
-					WarehouseOutDetailId:    0,
2171
-					CancelOutDetailId:       0,
2172
-					ProductDate:             productDates,
2173
-					ExpireDate:              expiryDates,
2174
-				}
2175
-				stockFLow = append(stockFLow, flow)
2154
+				//list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2155
+				//
2156
+				//var manufacturer_id int64
2157
+
2158
+				//for _, items := range list {
2159
+				//	if manufacturer == items.ManufacturerName {
2160
+				//		manufacturer_id = items.ID
2161
+				//	}
2162
+				//}
2163
+
2164
+				//flow := &models.VmStockFlow{
2165
+				//	WarehousingId:           0,
2166
+				//	GoodId:                  good_id,
2167
+				//	Number:                  number,
2168
+				//	LicenseNumber:           "",
2169
+				//	Count:                   count,
2170
+				//	UserOrgId:               adminUserInfo.CurrentOrgId,
2171
+				//	PatientId:               0,
2172
+				//	SystemTime:              time.Now().Unix(),
2173
+				//	ConsumableType:          4,
2174
+				//	IsSys:                   0,
2175
+				//	WarehousingOrder:        "",
2176
+				//	WarehouseOutId:          0,
2177
+				//	WarehouseOutOrderNumber: "",
2178
+				//	IsEdit:                  0,
2179
+				//	CancelStockId:           cancelStock.ID,
2180
+				//	CancelOrderNumber:       cancelStock.OrderNumber,
2181
+				//	Manufacturer:            manufacturer_id,
2182
+				//	Dealer:                  0,
2183
+				//	Creator:                 adminUserInfo.AdminUser.Id,
2184
+				//	UpdateCreator:           0,
2185
+				//	Status:                  1,
2186
+				//	Ctime:                   time.Now().Unix(),
2187
+				//	Mtime:                   0,
2188
+				//	Price:                   price,
2189
+				//	WarehousingDetailId:     0,
2190
+				//	WarehouseOutDetailId:    0,
2191
+				//	CancelOutDetailId:       0,
2192
+				//	ProductDate:             productDates,
2193
+				//	ExpireDate:              expiryDates,
2194
+				//}
2195
+				//stockFLow = append(stockFLow, flow)
2176 2196
 			}
2177 2197
 		}
2178 2198
 	}
@@ -2208,17 +2228,50 @@ func (c *StockManagerApiController) CreateCancelStock() {
2208 2228
 
2209 2229
 			item.CancelStockId = listcancel.ID
2210 2230
 			errs := service.CreateCancelStockInfoOne(item)
2231
+			list, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2211 2232
 
2212
-			if len(stockFLow) > 0 {
2213
-
2214
-				for _, items := range stockFLow {
2215
-					cancelStockInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
2216
-					items.CancelStockId = listcancel.ID
2217
-					items.CancelOutDetailId = cancelStockInfo.ID
2233
+			var manufacturer_id int64
2218 2234
 
2235
+			for _, items := range list {
2236
+				if item.Manufacturer == items.ManufacturerName {
2237
+					manufacturer_id = items.ID
2219 2238
 				}
2220
-				service.CreateStockFlow(stockFLow)
2221 2239
 			}
2240
+			flow := models.VmStockFlow{
2241
+				WarehousingId:           0,
2242
+				GoodId:                  item.GoodId,
2243
+				Number:                  item.Number,
2244
+				LicenseNumber:           "",
2245
+				Count:                   item.Count,
2246
+				UserOrgId:               adminUserInfo.CurrentOrgId,
2247
+				PatientId:               0,
2248
+				SystemTime:              time.Now().Unix(),
2249
+				ConsumableType:          4,
2250
+				IsSys:                   0,
2251
+				WarehousingOrder:        "",
2252
+				WarehouseOutId:          0,
2253
+				WarehouseOutOrderNumber: "",
2254
+				IsEdit:                  0,
2255
+				CancelStockId:           cancelStock.ID,
2256
+				CancelOrderNumber:       cancelStock.OrderNumber,
2257
+				Manufacturer:            manufacturer_id,
2258
+				Dealer:                  0,
2259
+				Creator:                 adminUserInfo.AdminUser.Id,
2260
+				UpdateCreator:           0,
2261
+				Status:                  1,
2262
+				Ctime:                   time.Now().Unix(),
2263
+				Mtime:                   0,
2264
+				Price:                   item.Price,
2265
+				WarehousingDetailId:     0,
2266
+				WarehouseOutDetailId:    0,
2267
+				CancelOutDetailId:       0,
2268
+				ProductDate:             item.ProductDate,
2269
+				ExpireDate:              item.ExpiryDate,
2270
+			}
2271
+			cancelStockInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
2272
+			flow.CancelStockId = cancelStockInfo.CancelStockId
2273
+			flow.CancelOutDetailId = cancelStockInfo.ID
2274
+			service.CreateStockFlowOne(flow)
2222 2275
 			if errs != nil {
2223 2276
 				utils.ErrorLog(errs.Error())
2224 2277
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
@@ -2315,7 +2368,21 @@ func (this *StockManagerApiController) DeleteCancelStock() {
2315 2368
 	}
2316 2369
 
2317 2370
 	idArray := strings.Split(ids, ",")
2371
+	//获取
2372
+	list, _ := service.GetCancelWarehosueInfo(idArray)
2373
+	for _, item := range list {
2374
+		info, _ := service.GetCancelStockById(item.WarehouseInfoId)
2375
+		warehousingInfo := models.WarehousingInfo{
2376
+			StockCount: info.Count,
2377
+		}
2378
+		//扣减库存
2379
+		service.ModefyWarehouseInfoNight(warehousingInfo, info.WarehouseInfoId)
2380
+		//删除流水
2381
+		service.UpdatedStockFlowByCancelId(info.ID, info.GoodId)
2382
+	}
2383
+	//获取
2318 2384
 	err := service.DeleteCancelStock(idArray)
2385
+
2319 2386
 	if err != nil {
2320 2387
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
2321 2388
 	} else {
@@ -2332,8 +2399,19 @@ func (this *StockManagerApiController) DeleteCancelStockInfo() {
2332 2399
 		return
2333 2400
 	}
2334 2401
 
2402
+	//改变库存
2403
+	info, _ := service.GetCancelStockById(id)
2404
+
2405
+	warehousingInfo := models.WarehousingInfo{
2406
+		StockCount: info.Count,
2407
+	}
2408
+	//扣减库存
2409
+	service.ModefyWarehouseInfoNight(warehousingInfo, info.WarehouseInfoId)
2410
+	//删除详情
2335 2411
 	err := service.UpDateCancleStockStatus(id)
2336
-	service.UpdatedStockFlowByCancelId(id)
2412
+	//删除流水
2413
+	err = service.UpdatedStockFlowByCancelId(id, info.GoodId)
2414
+
2337 2415
 	if err != nil {
2338 2416
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
2339 2417
 	} else {
@@ -2637,7 +2715,6 @@ func (c *StockManagerApiController) EditCancelStock() {
2637 2715
 
2638 2716
 		if len(stockFlow) > 0 {
2639 2717
 			for _, itemcancel := range stockFlow {
2640
-				fmt.Println("hhh233232323323233223323232我的时间")
2641 2718
 				//查询是否存在
2642 2719
 				stockInfo, errcode := service.IsExsitStockFlow(itemcancel.GoodId, itemcancel.CancelOrderNumber)
2643 2720
 				if errcode == gorm.ErrRecordNotFound {
@@ -2668,8 +2745,6 @@ func (c *StockManagerApiController) EditCancelStock() {
2668 2745
 			for _, it := range list {
2669 2746
 				all_total += it.Count
2670 2747
 			}
2671
-			fmt.Println("最后一次出库233223323233223", info.Count)
2672
-			fmt.Println("当前出库23323223232323323", item.Count)
2673 2748
 
2674 2749
 			//比较退库库数量和最后一次退库库数据大小
2675 2750
 			//退库(加)
@@ -2709,6 +2784,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2709 2784
 			}
2710 2785
 			if item.Count == info.Count {
2711 2786
 				errs = service.UpDateCancelStockInfo(item)
2787
+
2712 2788
 			}
2713 2789
 		}
2714 2790
 	}
@@ -2727,6 +2803,8 @@ func (c *StockManagerApiController) EditCancelStock() {
2727 2803
 					Price:         itemcancel.Price,
2728 2804
 					LicenseNumber: itemcancel.LicenseNumber,
2729 2805
 					Number:        itemcancel.Number,
2806
+					ExpireDate:    itemcancel.ExpireDate,
2807
+					ProductDate:   itemcancel.ProductDate,
2730 2808
 				}
2731 2809
 				service.UpdateStockFlowThree(stockInfo.ID, flow)
2732 2810
 			}

+ 16 - 0
models/patient_models.go Ver fichero

@@ -1550,3 +1550,19 @@ type VmDialysisPrescription struct {
1550 1550
 func (VmDialysisPrescription) TableName() string {
1551 1551
 	return "xt_dialysis_prescription"
1552 1552
 }
1553
+
1554
+type XtScheduleList struct {
1555
+	UserOrgId        int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1556
+	PartitionId      int64              `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1557
+	BedId            int64              `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1558
+	PatientId        int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1559
+	ScheduleDate     int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1560
+	ScheduleType     int64              `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1561
+	ScheduleWeek     int64              `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1562
+	ModeId           int64              `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1563
+	DialysisSolution VmDialysisSolution `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"vmsolution"`
1564
+}
1565
+
1566
+func (XtScheduleList) TableName() string {
1567
+	return "xt_schedule"
1568
+}

+ 1 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver fichero

@@ -119,7 +119,7 @@ func GetAllName(orgId int64, appid int64) (list []AdminUserListTwo, err error) {
119 119
 
120 120
 func GetPatientCoursesRecords(orgID int64, id []string) (records []*models.PatientDiseaseCourse, err error) {
121 121
 	db := p_service.XTReadDB()
122
-	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id in(?) and status = 1", orgID, id).Order("record_time desc").Find(&records).Error
122
+	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id in(?) and status = 1", orgID, id).Order("record_time asc").Find(&records).Error
123 123
 	return
124 124
 }
125 125
 

+ 23 - 0
service/schedule_service.go Ver fichero

@@ -1108,3 +1108,26 @@ func GetSolutionSchedule(orgid int64) (solution []*models.VmDialysisSolution, er
1108 1108
 	}).Find(&solution).Error
1109 1109
 	return solution, err
1110 1110
 }
1111
+
1112
+func GetSolutionScheduleBySchedule(orgid int64, zonid int64, classtype int64, schedule_date int64) (schedule []*models.XtScheduleList, err error) {
1113
+
1114
+	db := XTReadDB().Model(&schedule).Where("status = 1")
1115
+	if orgid > 0 {
1116
+		db = db.Where("user_org_id =?", orgid)
1117
+	}
1118
+	if zonid > 0 {
1119
+		db = db.Where("partition_id = ?", zonid)
1120
+	}
1121
+	if classtype > 0 {
1122
+		db = db.Where("schedule_type = ?", classtype)
1123
+	}
1124
+	if schedule_date > 0 {
1125
+		db = db.Where("schedule_date = ?", schedule_date)
1126
+	}
1127
+	err = db.Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1128
+		return db.Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time asc").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1129
+			return db.Where("user_org_id = ? and status = 1", orgid).Order("id asc")
1130
+		})
1131
+	}).Find(&schedule).Error
1132
+	return schedule, err
1133
+}

+ 29 - 84
service/stock_service.go Ver fichero

@@ -659,12 +659,6 @@ func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id in
659 659
 	return flow, err
660 660
 }
661 661
 
662
-func UpdateDrugFlowTen(patientid int64, warehouse_out_number string, drug_id int64) (models.DrugFlow, error) {
663
-	flow := models.DrugFlow{}
664
-	err := XTWriteDB().Model(&flow).Where("patient_id =? and warehouse_out_order_number = ? and drug_id = ? and status = 1", patientid, warehouse_out_number, drug_id).Updates(map[string]interface{}{"status": 0}).Error
665
-	return flow, err
666
-}
667
-
668 662
 func CreateDrugFlowTwo(flow *models.DrugFlow) error {
669 663
 
670 664
 	err := XTWriteDB().Create(&flow).Error
@@ -683,6 +677,12 @@ func GetLastWarehousingInfo(goodid int64) (models.WarehousingInfo, error) {
683 677
 	return info, err
684 678
 }
685 679
 
680
+func CreatedWarehouseingDetail(info *models.WarehousingInfo) error {
681
+
682
+	err := XTWriteDB().Create(&info).Error
683
+	return err
684
+}
685
+
686 686
 func FindFirstWarehousingInfoByStock(good_id int64, good_type_id int64) (info models.WarehousingInfo, err error) {
687 687
 	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
688 688
 	return info, err
@@ -2406,6 +2406,12 @@ func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64
2406 2406
 	return
2407 2407
 }
2408 2408
 
2409
+func GetCancelWarehosueInfo(ids []string) (info []*models.CancelStockInfo, err error) {
2410
+
2411
+	err = XTReadDB().Where("id IN(?) and status = 1", ids).Find(&info).Error
2412
+	return info, err
2413
+}
2414
+
2409 2415
 func DeleteCancelStock(ids []string) (err error) {
2410 2416
 	ut := writeDb.Begin()
2411 2417
 	err = ut.Model(&models.CancelStock{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -2418,11 +2424,6 @@ func DeleteCancelStock(ids []string) (err error) {
2418 2424
 		ut.Rollback()
2419 2425
 		return
2420 2426
 	}
2421
-	err = ut.Model(&models.VmStockFlow{}).Where("cancel_stock_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2422
-	if err != nil {
2423
-		ut.Rollback()
2424
-		return
2425
-	}
2426 2427
 	ut.Commit()
2427 2428
 	return
2428 2429
 }
@@ -2458,9 +2459,21 @@ func UpDateCancleStockStatus(id int64) (err error) {
2458 2459
 	return
2459 2460
 }
2460 2461
 
2461
-func UpdatedStockFlowByCancelId(id int64) (err error) {
2462
+func GetCancelStockById(id int64) (models.CancelStockInfo, error) {
2463
+	info := models.CancelStockInfo{}
2464
+	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
2465
+	return info, err
2466
+}
2467
+
2468
+func ModefyWarehouseInfoNight(info models.WarehousingInfo, id int64) error {
2469
+
2470
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", info.StockCount)).Error
2471
+	return err
2472
+}
2462 2473
 
2463
-	err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_out_detail_id = ? and status = 0", id).Updates(map[string]interface{}{"status": 0}).Error
2474
+func UpdatedStockFlowByCancelId(id int64, good_id int64) (err error) {
2475
+
2476
+	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and status = 1 and good_id = ?", id, good_id).Updates(map[string]interface{}{"status": 0}).Error
2464 2477
 	return
2465 2478
 }
2466 2479
 
@@ -4941,14 +4954,14 @@ func UpdateStockFlow(flow models.VmStockFlow, goodid int64, warehousing_id int64
4941 4954
 func UpdateDrugFlow(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4942 4955
 
4943 4956
 	drugFlow := models.DrugFlow{}
4944
-	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit, "min_unit": flow.MinUnit}).Error
4957
+	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit, "min_unit": flow.MinUnit, "price": flow.Price, "expire_date": flow.ExpireDate}).Error
4945 4958
 	return err
4946 4959
 }
4947 4960
 
4948 4961
 func UpdateDrugFlowNight(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4949 4962
 
4950 4963
 	drugFlow := models.DrugFlow{}
4951
-	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
4964
+	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_detail_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit, "min_unit": flow.MinUnit, "price": flow.Price, "expire_date": flow.ExpireDate}).Error
4952 4965
 	return err
4953 4966
 }
4954 4967
 
@@ -5364,13 +5377,6 @@ func GetCurrentWarehosueInfo(id int64) (info []*models.DrugWarehouseInfo, err er
5364 5377
 	return info, err
5365 5378
 }
5366 5379
 
5367
-func GetCurrentWarehosueInfoOne(id int64) (models.DrugWarehouseInfo, error) {
5368
-
5369
-	info := models.DrugWarehouseInfo{}
5370
-	err := XTReadDB().Model(&info).Where("id=?", id).Find(&info).Error
5371
-	return info, err
5372
-}
5373
-
5374 5380
 func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
5375 5381
 
5376 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
@@ -5477,12 +5483,6 @@ func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error
5477 5483
 	return err
5478 5484
 }
5479 5485
 
5480
-func UpdatedStockFlowByGoodId(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5481
-
5482
-	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
5483
-	return err
5484
-}
5485
-
5486 5486
 func UpdatedStockFlowByGoodIdOne(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5487 5487
 
5488 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
@@ -5536,15 +5536,9 @@ func IsExsitStockFlow(goodid int64, cancel_order_number string) (*models.VmStock
5536 5536
 	return &flow, nil
5537 5537
 }
5538 5538
 
5539
-func UpdateStockFlowTwo(id int64, flow models.VmStockFlow) error {
5540
-
5541
-	err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count}).Error
5542
-	return err
5543
-}
5544
-
5545 5539
 func UpdateStockFlowThree(id int64, flow models.VmStockFlow) error {
5546 5540
 
5547
-	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
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
5548 5542
 	return err
5549 5543
 }
5550 5544
 
@@ -5575,33 +5569,6 @@ func ModifyDrugWarehouseOutInfoOne(info models.DrugWarehouseOutInfo, drugid int6
5575 5569
 	return err
5576 5570
 }
5577 5571
 
5578
-func GetDrugWarehouseOutInfoByWarehosueId(drugid int64, patientid int64, recorddate int64, warehosueinfoid int64) (*models.DrugWarehouseOutInfo, error) {
5579
-	info := models.DrugWarehouseOutInfo{}
5580
-	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
5581
-	if err == gorm.ErrRecordNotFound {
5582
-		return nil, err
5583
-	}
5584
-	if err != nil {
5585
-		return nil, err
5586
-	}
5587
-	return &info, nil
5588
-}
5589
-
5590
-func GetDrugFlowRecord(warehouse_out_order_number string, drugid int64, patientid int64) (*models.DrugFlow, error) {
5591
-
5592
-	drugFlow := models.DrugFlow{}
5593
-
5594
-	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
5595
-
5596
-	if err == gorm.ErrRecordNotFound {
5597
-		return nil, err
5598
-	}
5599
-	if err != nil {
5600
-		return nil, err
5601
-	}
5602
-	return &drugFlow, nil
5603
-}
5604
-
5605 5572
 func ModifyDrugFlow(flow models.DrugFlow, warehouse_out_order_number string, drugid int64, patient_id int64) error {
5606 5573
 
5607 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
@@ -5614,28 +5581,6 @@ func ModifyDrugFlowOne(flow models.DrugFlow, warehouse_out_order_number string,
5614 5581
 	return err
5615 5582
 }
5616 5583
 
5617
-func GetDrugAutoReduceRecordOne(drugid int64, patientid int64, recorddate int64) (detail []*models.DrugAutomaticReduceDetail, err error) {
5618
-
5619
-	err = XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time  = ? and status = 1", drugid, patientid, recorddate).Find(&detail).Error
5620
-
5621
-	return detail, err
5622
-}
5623
-
5624
-func GetDrugAutoReduceRecord(drugid int64, patientid int64, recorddate int64) (*models.DrugAutomaticReduceDetail, error) {
5625
-
5626
-	detail := models.DrugAutomaticReduceDetail{}
5627
-
5628
-	err := XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time  = ? and status = 1", drugid, patientid, recorddate).Find(&detail).Error
5629
-
5630
-	if err == gorm.ErrRecordNotFound {
5631
-		return nil, err
5632
-	}
5633
-	if err != nil {
5634
-		return nil, err
5635
-	}
5636
-	return &detail, nil
5637
-}
5638
-
5639 5584
 func ModifyAutoMaticReduce(auto models.DrugAutomaticReduceDetail, patientid int64, recordate int64, drugid int64) error {
5640 5585
 
5641 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