Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
51117b08c1

+ 1 - 1
conf/app.conf View File

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

+ 6 - 6
controllers/base_api_controller.go View File

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		//userAdmin.ModifyTime = 1530786071
82 82
 		//var subscibe models.ServeSubscibe
83 83
 		//subscibe.ID = 1
84
-		//subscibe.OrgId = 4
84
+		//subscibe.OrgId = 9671
85 85
 		//subscibe.PeriodStart = 1538035409
86 86
 		//subscibe.PeriodEnd = 1569571409
87 87
 		//subscibe.State = 1
@@ -91,8 +91,8 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		//subscibes[4] = &subscibe
93 93
 		//var adminUserInfo service.AdminUserInfo
94
-		//adminUserInfo.CurrentOrgId = 4
95
-		//adminUserInfo.CurrentAppId = 4
94
+		//adminUserInfo.CurrentOrgId = 9671
95
+		//adminUserInfo.CurrentAppId = 9671
96 96
 		//adminUserInfo.AdminUser = &userAdmin
97 97
 		//adminUserInfo.Subscibes = subscibes
98 98
 		//this.SetSession("admin_user_info", &adminUserInfo)
@@ -327,7 +327,7 @@ func (this *BaseServeAPIController) Prepare() {
327 327
 		//userAdmin.ModifyTime = 1530786071
328 328
 		//var subscibe models.ServeSubscibe
329 329
 		//subscibe.ID = 1
330
-		//subscibe.OrgId = 4
330
+		//subscibe.OrgId = 9671
331 331
 		//subscibe.PeriodStart = 1538035409
332 332
 		//subscibe.PeriodEnd = 1569571409
333 333
 		//subscibe.State = 1
@@ -337,8 +337,8 @@ func (this *BaseServeAPIController) Prepare() {
337 337
 		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338 338
 		//subscibes[4] = &subscibe
339 339
 		//var adminUserInfo service.AdminUserInfo
340
-		//adminUserInfo.CurrentOrgId = 4
341
-		//adminUserInfo.CurrentAppId = 4
340
+		//adminUserInfo.CurrentOrgId = 9671
341
+		//adminUserInfo.CurrentAppId = 9671
342 342
 		//adminUserInfo.AdminUser = &userAdmin
343 343
 		//adminUserInfo.Subscibes = subscibes
344 344
 		//this.SetSession("admin_user_info", &adminUserInfo)

+ 24 - 12
controllers/drug_stock_api_contorller.go View File

@@ -1183,13 +1183,6 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1183 1183
 				}
1184 1184
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1185 1185
 
1186
-				//if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
1187
-				//	utils.ErrorLog("last_price")
1188
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1189
-				//	return
1190
-				//}
1191
-				//last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
1192
-				//fmt.Println(last_price)
1193 1186
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1194 1187
 
1195 1188
 				total := float64(count) * price
@@ -1233,8 +1226,9 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1233 1226
 					}
1234 1227
 
1235 1228
 				}
1236
-
1229
+				fmt.Println("孟子", warehouseOut.ID)
1237 1230
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1231
+
1238 1232
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1239 1233
 					WarehouseOutId:          warehouseOut.ID,
1240 1234
 					DrugId:                  drug_id,
@@ -1259,10 +1253,11 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1259 1253
 					WarehouseInfoId:         warehouse_info_id,
1260 1254
 				}
1261 1255
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1256
+				fmt.Println("hhhhhhhhhhhhhhhh", warehouseOut.ID)
1262 1257
 
1263 1258
 				drugflow := &models.DrugFlow{
1264 1259
 					WarehouseOutId:          warehouseOut.ID,
1265
-					WarehouseOutOrderNumber: warehousing_out_order,
1260
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1266 1261
 					DrugId:                  drug_id,
1267 1262
 					Number:                  number,
1268 1263
 					ProductDate:             productDates,
@@ -1344,6 +1339,10 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1344 1339
 			return
1345 1340
 		} else {
1346 1341
 			service.AddSigleDrugWarehouseOut(&warehouseOut)
1342
+			list, _ := service.GetLastWarehouseOut(adminUserInfo.CurrentOrgId)
1343
+			for _, item := range drugFlow {
1344
+				item.WarehouseOutId = list.ID
1345
+			}
1347 1346
 			service.CreateDrugFlow(drugFlow)
1348 1347
 			// 出库流程
1349 1348
 			// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
@@ -2138,7 +2137,20 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2138 2137
 				batch_number := items["batch_number"].(string)
2139 2138
 				max_unit := items["max_unit"].(string)
2140 2139
 				batch_number_id := int64(items["batch_number_id"].(float64))
2141
-
2140
+				var manufacturer_id int64
2141
+				var dealer_id int64
2142
+				manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2143
+				dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
2144
+				for _, item := range manufacturerList {
2145
+					if manufacturer == item.ManufacturerName {
2146
+						manufacturer_id = item.ID
2147
+					}
2148
+				}
2149
+				for _, item := range dealerList {
2150
+					if dealer == item.DealerName {
2151
+						dealer_id = item.ID
2152
+					}
2153
+				}
2142 2154
 				fmt.Println("99999999999999999999", batch_number_id)
2143 2155
 				cancelStockInfo := &models.DrugCancelStockInfo{
2144 2156
 					OrderNumber:      cancelStock.OrderNumber,
@@ -2182,8 +2194,8 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2182 2194
 					IsEdit:                  0,
2183 2195
 					CancelStockId:           cancelStock.ID,
2184 2196
 					CancelOrderNumber:       cancelStock.OrderNumber,
2185
-					Manufacturer:            0,
2186
-					Dealer:                  0,
2197
+					Manufacturer:            manufacturer_id,
2198
+					Dealer:                  dealer_id,
2187 2199
 					Creator:                 adminUserInfo.AdminUser.Id,
2188 2200
 					UpdateCreator:           0,
2189 2201
 					Status:                  1,

+ 6 - 7
controllers/gobal_config_api_controller.go View File

@@ -1682,14 +1682,17 @@ func (c *GobalConfigApiController) GetDrugCancelDetail() {
1682 1682
 	keyword := c.GetString("keyword")
1683 1683
 	limit, _ := c.GetInt64("limit")
1684 1684
 	page, _ := c.GetInt64("page")
1685
+	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword)
1685 1686
 	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1687
+
1686 1688
 	if err != nil {
1687 1689
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1688 1690
 		return
1689 1691
 	}
1690 1692
 	c.ServeSuccessJSON(map[string]interface{}{
1691
-		"order": order,
1692
-		"total": total,
1693
+		"order":      order,
1694
+		"total":      total,
1695
+		"orderPrint": orderPrint,
1693 1696
 	})
1694 1697
 }
1695 1698
 
@@ -1850,9 +1853,6 @@ func (c *GobalConfigApiController) GetDrugStockList() {
1850 1853
 	}
1851 1854
 	adminUserInfo := c.GetAdminUserInfo()
1852 1855
 
1853
-	//查询入库数量
1854
-	//list, total, err := service.GetDrugStockList(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1855
-
1856 1856
 	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1857 1857
 	fmt.Println("total232323232323232232323", total)
1858 1858
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
@@ -2035,10 +2035,10 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2035 2035
 	start_time, _ := c.GetInt64("start_time")
2036 2036
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2037 2037
 	list, err := service.GetSingleOrderDetail(id, orgId)
2038
-	outList, err := service.GetAllSingleDrugDetail(id, orgId)
2039 2038
 	dealerList, err := service.GetAllDealerList(orgId)
2040 2039
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2041 2040
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2041
+
2042 2042
 	if err != nil {
2043 2043
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2044 2044
 		return
@@ -2047,7 +2047,6 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2047 2047
 		"list":             list,
2048 2048
 		"dealerList":       dealerList,
2049 2049
 		"manufacturerList": manufacturerList,
2050
-		"outList":          outList,
2051 2050
 		"drugFlowList":     drugFlowList,
2052 2051
 	})
2053 2052
 }

+ 13 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -1702,6 +1702,8 @@ func (this *DialysisAPIController) StartDialysis() {
1702 1702
 	change_nurse, _ := this.GetInt64("change_nurse")
1703 1703
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
1704 1704
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
1705
+	zone_id, _ := this.GetInt64("zone_id")
1706
+	fmt.Println("zone23333232323232232332232323", zone_id)
1705 1707
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
1706 1708
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1707 1709
 		return
@@ -1872,9 +1874,19 @@ func (this *DialysisAPIController) StartDialysis() {
1872 1874
 		ChangeNurse:            change_nurse,
1873 1875
 		DifficultPunctureNurse: difficult_puncture_nurse,
1874 1876
 		NewFistulaNurse:        new_fistula_nurse,
1877
+		ZoneId:                 zone_id,
1878
+	}
1879
+	//查询该床位是否有人用了
1880
+	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
1881
+	if errorscode == gorm.ErrRecordNotFound {
1882
+		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
1883
+		if createErr != nil {
1884
+			this.ErrorLog("上机失败:%v", createErr)
1885
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1886
+			return
1887
+		}
1875 1888
 	}
1876 1889
 
1877
-	createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
1878 1890
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1879 1891
 
1880 1892
 	var tempdispose string
@@ -1969,11 +1981,6 @@ func (this *DialysisAPIController) StartDialysis() {
1969 1981
 		http.PostForm(api, values)
1970 1982
 	}()
1971 1983
 
1972
-	if createErr != nil {
1973
-		this.ErrorLog("上机失败:%v", createErr)
1974
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1975
-		return
1976
-	}
1977 1984
 	this.ServeSuccessJSON(map[string]interface{}{
1978 1985
 		"dialysis_order": newdialysisRecord,
1979 1986
 		"monitor":        record,

+ 14 - 10
controllers/self_drug_api_congtroller.go View File

@@ -74,7 +74,7 @@ func SelfDrugRouters() {
74 74
 	beego.Router("/api/drug/savedrugcheckinventory", &SelfDrugApiController{}, "Get:SaveDrugCheckInventory")
75 75
 	beego.Router("/api/drug/getdruginventorydetail", &SelfDrugApiController{}, "Get:GetDrugInventoryDetail")
76 76
 	beego.Router("/api/drug/modifyinventory", &SelfDrugApiController{}, "Get:ModifyInventory")
77
-	beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Delete:DeleteDrugInventory")
77
+	beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Get:DeleteDrugInventory")
78 78
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
79 79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
80 80
 	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
@@ -1869,14 +1869,6 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
1869 1869
 
1870 1870
 			numbers := items["number"].(string)
1871 1871
 
1872
-			//if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
1873
-			//	utils.ErrorLog("batch_number")
1874
-			//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1875
-			//	return
1876
-			//}
1877
-			//
1878
-			//batch_number := items["batch_number"].(string)
1879
-
1880 1872
 			if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
1881 1873
 				utils.ErrorLog("warehouse_info_id")
1882 1874
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1891,6 +1883,11 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
1891 1883
 			}
1892 1884
 
1893 1885
 			total := items["total"].(string)
1886
+
1887
+			drug_origin_place := items["drug_origin_place"].(string)
1888
+
1889
+			min_count := int64(items["min_count"].(float64))
1890
+			min_unit := items["min_unit"].(string)
1894 1891
 			inventory := models.XtDrugInventory{
1895 1892
 
1896 1893
 				DrugName:          drug_name,
@@ -1921,6 +1918,9 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
1921 1918
 				//BatchNumber:       batch_number,
1922 1919
 				Total:           total,
1923 1920
 				WarehouseInfoId: warehouse_info_id,
1921
+				DrugOriginPlace: drug_origin_place,
1922
+				MinUnit:         min_unit,
1923
+				MinCount:        min_count,
1924 1924
 			}
1925 1925
 			err = service.CreateDrugInventory(inventory)
1926 1926
 			fmt.Println(err)
@@ -2026,7 +2026,7 @@ func (this *SelfDrugApiController) SaveDrugCheckInventory() {
2026 2026
 		lastInfo, _ := service.GetLastDrugWarehouseInfo(item.DrugId)
2027 2027
 		firstInfo, _ := service.GetFirstDrugWarehouseInfo(item.DrugId)
2028 2028
 		stock_total = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
2029
-		proof_count = item.StockMaxNumber*drug.MinNumber + item.StockMinNumber
2029
+		proof_count = item.Count*drug.MinNumber + item.MinCount
2030 2030
 
2031 2031
 		//判断 如果库存数量 大于盘点库存,则出库
2032 2032
 		if stock_total > proof_count {
@@ -2231,6 +2231,8 @@ func (this *SelfDrugApiController) ModifyInventory() {
2231 2231
 	stock_max_number, _ := this.GetInt64("stock_max_number")
2232 2232
 	stock_min_number, _ := this.GetInt64("stock_min_number")
2233 2233
 	warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
2234
+	min_count, _ := this.GetInt64("min_count")
2235
+	min_unit := this.GetString("min_unit")
2234 2236
 	inventory := models.XtDrugInventory{
2235 2237
 		DrugName:          drug_name,
2236 2238
 		SpecificationName: specification_name,
@@ -2248,6 +2250,8 @@ func (this *SelfDrugApiController) ModifyInventory() {
2248 2250
 		StockMaxNumber:    stock_max_number,
2249 2251
 		StockMinNumber:    stock_min_number,
2250 2252
 		WarehouseInfoId:   warehouse_info_id,
2253
+		MinCount:          min_count,
2254
+		MinUnit:           min_unit,
2251 2255
 	}
2252 2256
 	err := service.ModifyDrugInventory(id, inventory)
2253 2257
 	if err != nil {

+ 17 - 22
controllers/stock_in_api_controller.go View File

@@ -1828,7 +1828,7 @@ func (c *StockManagerApiController) CreateCancelStock() {
1828 1828
 		ReturnTime:  cancelStockDate.Unix(),
1829 1829
 		Type:        types,
1830 1830
 	}
1831
-	service.AddSigleCancelStock(&cancelStock)
1831
+
1832 1832
 	dataBody := make(map[string]interface{}, 0)
1833 1833
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1834 1834
 	if err != nil {
@@ -1973,17 +1973,8 @@ func (c *StockManagerApiController) CreateCancelStock() {
1973 1973
 
1974 1974
 	for _, item := range cancelStockInfos {
1975 1975
 
1976
-		////查找该耗材是否有出库记录
1977
-		//_, errcode := service.GetWarehoureOutOrderInfo(item.GoodId, item.OrgId)
1978
-		//if errcode == gorm.ErrRecordNotFound {
1979
-		//	c.ServeSuccessJSON(map[string]interface{}{
1980
-		//		"msg": "1",
1981
-		//	})
1982
-		//	return
1983
-		//}
1984
-
1985
-		//统计该耗材的出库数量
1986
-		info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId)
1976
+		//统计该批次耗材的出库数量
1977
+		info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId, item.WarehouseInfoId)
1987 1978
 		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
1988 1979
 		if item.Count > info.Count {
1989 1980
 			service.UpdateCancelInfo(item.CancelStockId)
@@ -2004,7 +1995,14 @@ func (c *StockManagerApiController) CreateCancelStock() {
2004 1995
 		}
2005 1996
 
2006 1997
 		if item.Count <= infolist.WarehousingCount {
2007
-
1998
+			_, msgerrkonde := service.GetCancelStockDetailByOrderNumber(orderNumber, adminUserInfo.CurrentOrgId)
1999
+			if msgerrkonde == gorm.ErrRecordNotFound {
2000
+				service.AddSigleCancelStock(&cancelStock)
2001
+			}
2002
+			listcancel, _ := service.GetLastCancelStockById(adminUserInfo.CurrentOrgId)
2003
+			for _, it := range cancelStockInfos {
2004
+				it.CancelStockId = listcancel.ID
2005
+			}
2008 2006
 			errs := service.CreateCancelStockInfo(cancelStockInfos)
2009 2007
 			if len(stockFLow) > 0 {
2010 2008
 				service.CreateStockFlow(stockFLow)
@@ -2025,12 +2023,6 @@ func (c *StockManagerApiController) CreateCancelStock() {
2025 2023
 			}
2026 2024
 			//更改入库数量
2027 2025
 			errs = service.UpdateWareInfoById(item.WarehouseInfoId, item.Count)
2028
-
2029
-			//查询该耗材的入库记录
2030
-			//list, _ := service.GetWarehoureOrderInfoList(item.GoodId, item.OrgId)
2031
-			////调用退库的方法
2032
-			//parseDateErr := service.UpdateCancelOut(list, item.Count)
2033
-			//fmt.Println("999999999999", parseDateErr)
2034 2026
 			break
2035 2027
 		}
2036 2028
 	}
@@ -2379,7 +2371,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2379 2371
 
2380 2372
 		for _, item := range cancelStockInfos {
2381 2373
 			//统计该耗材的出库数量
2382
-			info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId)
2374
+			info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId, item.WarehouseInfoId)
2383 2375
 			if item.Count > info.Count {
2384 2376
 				c.ServeSuccessJSON(map[string]interface{}{
2385 2377
 					"msg": "2",
@@ -2667,10 +2659,12 @@ func (this *StockManagerApiController) GetDetailInfo() {
2667 2659
 		}
2668 2660
 	} else if types == 4 {
2669 2661
 		list3, total, err = service.FindCancelDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer)
2662
+		listGroup, err := service.FindeCancelGroup(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer)
2670 2663
 		if err == nil {
2671 2664
 			this.ServeSuccessJSON(map[string]interface{}{
2672
-				"list":  list3,
2673
-				"total": total,
2665
+				"list":      list3,
2666
+				"total":     total,
2667
+				"listgroup": listGroup,
2674 2668
 			})
2675 2669
 		} else {
2676 2670
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -5734,6 +5728,7 @@ func (this *StockManagerApiController) SaveCheckInventory() {
5734 5728
 				StockCount:       item.Count - list.StockCount,
5735 5729
 				Dealer:           dealer_id,
5736 5730
 				LicenseNumber:    info.LicenseNumber,
5731
+				WarehouseInfoId:  item.WarehousingInfoId,
5737 5732
 			}
5738 5733
 
5739 5734
 			flow := models.VmStockFlow{

+ 1 - 0
models/dialysis.go View File

@@ -802,6 +802,7 @@ type DialysisOrder struct {
802 802
 	ChangeNurse            int64         `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
803 803
 	DifficultPunctureNurse int64         `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
804 804
 	NewFistulaNurse        int64         `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
805
+	ZoneId                 int64         `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
805 806
 }
806 807
 
807 808
 func (DialysisOrder) TableName() string {

+ 6 - 0
models/self_drug_models.go View File

@@ -504,6 +504,7 @@ type BloodDrugCancelStockInfo struct {
504 504
 	MinNumber        int64   `json:"min_number"`
505 505
 	Dose             float64 `json:"dose"`
506 506
 	DoseUnit         string  `json:"dose_unit"`
507
+	Unit             string  `json:"unit"`
507 508
 }
508 509
 
509 510
 type BloodDrugSalesReturnInfo struct {
@@ -799,6 +800,8 @@ type XtDrugInventory struct {
799 800
 	ProofCount        int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
800 801
 	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
801 802
 	StockMinNumber    int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
803
+	MinCount          int64   `gorm:"column:min_count" json:"min_count" form:"min_count"`
804
+	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
802 805
 }
803 806
 
804 807
 func (XtDrugInventory) TableName() string {
@@ -834,6 +837,9 @@ type VmDrugInventory struct {
834 837
 	DoseUnit          string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
835 838
 	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
836 839
 	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
840
+	MinCount          int64   `gorm:"column:min_count" json:"min_count" form:"min_count"`
837 841
 	Total             string  `gorm:"column:total" json:"total" form:"total"`
842
+	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
843
+	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
838 844
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
839 845
 }

+ 1 - 0
models/stock_models.go View File

@@ -130,6 +130,7 @@ type WarehousingInfo struct {
130 130
 	GoodInfo         GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
131 131
 	Type             int64       `gorm:"column:type" json:"type"`
132 132
 	LicenseNumber    string      `gorm:"column:license_number" json:"license_number" form:"license_number"`
133
+	WarehouseInfoId  int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
133 134
 }
134 135
 
135 136
 func (WarehousingInfo) TableName() string {

+ 35 - 4
service/gobal_config_service.go View File

@@ -339,6 +339,37 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
339 339
 	return outinfo, total, err
340 340
 }
341 341
 
342
+func GetDrugCancelOrderPrint(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string) (info []*models.BloodDrugCancelStockInfo, err error) {
343
+	likeKey := "%" + keyword + "%"
344
+	db := XTReadDB().Table("xt_drug_cancel_stock_info as x").Where("x.status =1")
345
+	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
346
+	dbTwo := XTReadDB().Table("xt_drug_cancel_stock as t").Where("t.status = 1")
347
+	fmt.Print(dbOne, dbTwo)
348
+	if startime > 0 {
349
+		db = db.Where("x.ctime >= ?", startime)
350
+	}
351
+	if endtime > 0 {
352
+		db = db.Where("x.ctime<=?", endtime)
353
+	}
354
+	if orgid > 0 {
355
+		db = db.Where("x.org_id = ?", orgid)
356
+	}
357
+	if orderType > 0 {
358
+		db = db.Where("x.type = ? ", orderType)
359
+	}
360
+	if len(keyword) > 0 {
361
+		db = db.Where("x.order_number like ? or s.drug_spec like ? or t.creater like ?", likeKey, likeKey, likeKey)
362
+	}
363
+
364
+	if manufacturerId > 0 {
365
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
366
+	} else {
367
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
368
+	}
369
+
370
+	return info, err
371
+}
372
+
342 373
 func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64) (cancel []*models.BloodDrugCancelStockInfo, total int64, err error) {
343 374
 
344 375
 	likeKey := "%" + keyword + "%"
@@ -364,9 +395,9 @@ func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType in
364 395
 	}
365 396
 
366 397
 	if manufacturerId > 0 {
367
-		err = db.Select("x.id,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
398
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
368 399
 	} else {
369
-		err = db.Select("x.id,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
400
+		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,x.dealer,x.manufacturer,x.retail_price,x.retail_total_price,x.number,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&cancel).Error
370 401
 	}
371 402
 
372 403
 	return cancel, total, err
@@ -757,9 +788,9 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
757 788
 	return info, err
758 789
 }
759 790
 
760
-func GetDrugStockFlowDetail(id int64, orgid int64) (drugflow []*models.XtDrugAutomaticReduceDetail, err error) {
791
+func GetDrugStockFlowDetail(record_time int64, orgid int64) (drugflow []*models.XtDrugAutomaticReduceDetail, err error) {
761 792
 
762
-	err = XTReadDB().Where("record_time = ? and org_id = ? and status = 1", id, orgid).Find(&drugflow).Error
793
+	err = XTReadDB().Where("record_time = ? and org_id = ? and status = 1", record_time, orgid).Preload("XtBaseDrug", "status = 1").Find(&drugflow).Error
763 794
 	return drugflow, err
764 795
 }
765 796
 

+ 1 - 2
service/manage_service.go View File

@@ -813,9 +813,8 @@ func GetUserForm(id int64, orgId int64, limit int64, page int64) (infor []*model
813 813
 	if orgId > 0 {
814 814
 		db = db.Where("x.user_org_id = ?", orgId)
815 815
 	}
816
-	err = db.Group("x.id").Select("x.id,x.date,x.class,x.zone,x.bed_number,x.patient_id,x.contagion,x.dialysis_mode,x.start_time,x.end_time,x.dialysis_hour,x.hyperfiltratio,x.weight_loss,x.warning_value,x.user_total,x.move,x.failure_stage,x.fault_description,x.code_information,x.disinfect_type,x.disinfectant_type,x.disinfection,x.machine_run,x.fluid_path,x.disinfectant,x.disinfection_status,x.disinfection_residue,x.long_time,x.disinfec_startime,x.disinfec_endtime,x.dialysis_checked,x.dialysis_name,x.norms,x.dialysis_concentration,x.germ_checked,x.germ_name,x.germ_number,x.clean,x.sign_name,x.equiment_id,x.bed,p.name,r.user_name").Count(&total).Joins("Left Join sgj_xt.xt_patients as p on p.id = x.patient_id").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.sign_name").Offset(offset).Limit(limit).Scan(&infor).Error
816
+	err = db.Group("x.id").Select("x.id,x.date,x.class,x.zone,x.bed_number,x.patient_id,x.contagion,x.dialysis_mode,x.start_time,x.end_time,x.dialysis_hour,x.hyperfiltratio,x.weight_loss,x.warning_value,x.user_total,x.move,x.failure_stage,x.fault_description,x.code_information,x.disinfect_type,x.disinfectant_type,x.disinfection,x.machine_run,x.fluid_path,x.disinfectant,x.disinfection_status,x.disinfection_residue,x.long_time,x.disinfec_startime,x.disinfec_endtime,x.dialysis_checked,x.dialysis_name,x.norms,x.dialysis_concentration,x.germ_checked,x.germ_name,x.germ_number,x.clean,x.sign_name,x.equiment_id,x.bed,p.name,r.user_name").Count(&total).Joins("Left Join sgj_xt.xt_patients as p on p.id = x.patient_id").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.sign_name").Offset(offset).Limit(limit).Order("x.date desc").Scan(&infor).Error
817 817
 	if err != nil {
818
-
819 818
 		return
820 819
 	}
821 820
 	return

+ 10 - 20
service/self_drug_service.go View File

@@ -829,23 +829,7 @@ func CreateDrugPrice(price models.XtDrugAdjustPrice) error {
829 829
 }
830 830
 
831 831
 func GetDrugPriceList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugAdjustPrice, total int64, err error) {
832
-	//likeKey := "%" + keyword + "%"
833
-	//offset := (page - 1) * limit
834
-	//db := XTReadDB().Model(&adjust).Where("status = 1")
835
-	//if startime > 0 {
836
-	//	db = db.Where("ctime >=?", startime)
837
-	//}
838
-	//if endtime > 0 {
839
-	//	db = db.Where("ctime<=?", endtime)
840
-	//}
841
-	//if orgId > 0 {
842
-	//	db = db.Where("user_org_id = ?", orgId)
843
-	//}
844
-	//if len(keyword) > 0 {
845
-	//	db = db.Where("warehousing_order like ?", likeKey)
846
-	//}
847
-	//err = db.Count(&total).Offset(offset).Limit(limit).Find(&adjust).Error
848
-	//return adjust, total, err
832
+
849 833
 	likeKey := "%" + keyword + "%"
850 834
 	offset := (page - 1) * limit
851 835
 	db := XTReadDB().Table("xt_drug_adjust_price as x").Where("x.status = 1")
@@ -858,6 +842,12 @@ func GetDrugPriceList(startime int64, endtime int64, orgId int64, keyword string
858 842
 	if orgId > 0 {
859 843
 		db = db.Where("x.user_org_id = ?", orgId)
860 844
 	}
845
+	if startime > 0 {
846
+		db = db.Where("x.ctime>=?", startime)
847
+	}
848
+	if endtime > 0 {
849
+		db = db.Where("x.ctime<=?", endtime)
850
+	}
861 851
 	err = db.Group("x.id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
862 852
 	return adjust, total, err
863 853
 
@@ -990,7 +980,7 @@ func GetDrugInventoryList(keyword string, page int64, limit int64, orgid int64,
990 980
 	if endtime > 0 {
991 981
 		db = db.Where("x.start_time<=?", endtime)
992 982
 	}
993
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
983
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.min_count,x.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
994 984
 	return list, total, err
995 985
 }
996 986
 
@@ -1042,7 +1032,7 @@ func GetDrugInventoryDetail(id int64) (models.XtDrugInventory, error) {
1042 1032
 
1043 1033
 func ModifyDrugInventory(id int64, info models.XtDrugInventory) error {
1044 1034
 
1045
-	err := XTWriteDB().Model(&info).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": info.DrugName, "specification_name": info.SpecificationName, "warehousing_unit": info.WarehousingUnit, "count": info.Count, "last_price": info.LastPrice, "manufacturer": info.Manufacturer, "remark": info.Remark, "drug_id": info.DrugId, "warehousing_order": info.WarehousingOrder, "number": info.Number, "total": info.Number, "drug_origin_place": info.DrugOriginPlace, "stock_max_number": info.StockMaxNumber, "stock_min_number": info.StockMinNumber, "warehouse_info_id": info.WarehouseInfoId}).Error
1035
+	err := XTWriteDB().Model(&info).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": info.DrugName, "specification_name": info.SpecificationName, "warehousing_unit": info.WarehousingUnit, "count": info.Count, "last_price": info.LastPrice, "manufacturer": info.Manufacturer, "remark": info.Remark, "drug_id": info.DrugId, "warehousing_order": info.WarehousingOrder, "number": info.Number, "total": info.Number, "drug_origin_place": info.DrugOriginPlace, "stock_max_number": info.StockMaxNumber, "stock_min_number": info.StockMinNumber, "warehouse_info_id": info.WarehouseInfoId, "min_count": info.MinCount, "min_unit": info.MinUnit}).Error
1046 1036
 	return err
1047 1037
 }
1048 1038
 
@@ -1072,7 +1062,7 @@ func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid i
1072 1062
 	if orgid > 0 {
1073 1063
 		db = db.Where("x.user_org_id = ?", orgid)
1074 1064
 	}
1075
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1065
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,t.dose,t.dose_unit,t.max_unit,x.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1076 1066
 	return list, total, err
1077 1067
 }
1078 1068
 

+ 32 - 0
service/statistics_service/index_evaluation_service.go View File

@@ -1276,12 +1276,16 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1276 1276
 	var NewTotalSix int64
1277 1277
 	var NewTotalSeven int64
1278 1278
 	var NewTotalEight int64
1279
+	var NewTotalNight int64
1280
+	var NewTotalTen int64
1279 1281
 
1280 1282
 	db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalOne)
1281 1283
 	db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalFive)
1282 1284
 	db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalSix)
1283 1285
 	db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalSeven)
1284 1286
 	db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalEight)
1287
+	db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalNight)
1288
+	db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalTen)
1285 1289
 	db.Table("xt_monitoring_record as monitor ").Joins("join xt_schedule sch On sch.schedule_date = monitor.monitoring_date AND sch.patient_id = monitor.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("monitor.user_org_id = ? AND monitor.status = 1  AND monitor.monitoring_date >= ? AND monitor.monitoring_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalThree)
1286 1290
 	db.Table("xt_treatment_summary as summary").Joins("join xt_schedule sch On sch.schedule_date = summary.assessment_date AND sch.patient_id = summary.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("summary.user_org_id = ? AND summary.status = 1  AND summary.assessment_date >= ? AND summary.assessment_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalFour)
1287 1291
 
@@ -1389,6 +1393,34 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1389 1393
 
1390 1394
 		}
1391 1395
 		break
1396
+	case 8:
1397
+		for _, item := range datas {
1398
+			var Total int64
1399
+			db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.finish_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
1400
+			item.FinshNurserCount = Total
1401
+			if math.IsNaN(float64(item.FinshNurserCount) / float64(NewTotalNight)) {
1402
+				item.FinshNurseRatio = "0.0"
1403
+			} else {
1404
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.FinshNurserCount)/float64(NewTotalNight))*100), 64)
1405
+				item.FinshNurseRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1406
+			}
1407
+
1408
+		}
1409
+		break
1410
+	case 9:
1411
+		for _, item := range datas {
1412
+			var Total int64
1413
+			db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.washpipe_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
1414
+			item.WashpipeNurserCount = Total
1415
+			if math.IsNaN(float64(item.WashpipeNurserCount) / float64(NewTotalTen)) {
1416
+				item.WashpipeNurseRatio = "0.0"
1417
+			} else {
1418
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.WashpipeNurserCount)/float64(NewTotalTen))*100), 64)
1419
+				item.WashpipeNurseRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1420
+			}
1421
+
1422
+		}
1423
+		break
1392 1424
 
1393 1425
 	}
1394 1426
 

+ 79 - 6
service/stock_service.go View File

@@ -517,6 +517,13 @@ func FindeLastWarehouseInfo(id int64) (models.DrugWarehouseInfo, error) {
517 517
 	return info, err
518 518
 }
519 519
 
520
+func GetLastWarehouseOut(orgid int64) (models.DrugWarehouseOut, error) {
521
+
522
+	out := models.DrugWarehouseOut{}
523
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&out).Error
524
+	return out, err
525
+}
526
+
520 527
 func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
521 528
 	if len(drugflow) > 0 {
522 529
 		utx := writeDb.Begin()
@@ -525,6 +532,7 @@ func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
525 532
 			insertParams := make([]string, 0)
526 533
 			insertData := make([]interface{}, 0)
527 534
 			for _, info := range drugflow {
535
+				fmt.Println("hhhhhh", info.WarehouseOutId)
528 536
 				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
529 537
 				insertData = append(insertData, info.WarehousingId)
530 538
 				insertData = append(insertData, info.DrugId)
@@ -1486,12 +1494,31 @@ func FindWarehouseInfoByGoodTypeId(good_type_id int64) (models.WarehousingInfo,
1486 1494
 
1487 1495
 }
1488 1496
 
1497
+func GetCancelStockDetailByOrderNumber(ordernumber string, orgid int64) (*models.CancelStock, error) {
1498
+
1499
+	stock := models.CancelStock{}
1500
+	err := XTReadDB().Where("order_number = ? and org_id = ? and status = 1", ordernumber, orgid).Find(&stock).Error
1501
+	if err == gorm.ErrRecordNotFound {
1502
+		return nil, err
1503
+	}
1504
+	if err != nil {
1505
+		return nil, err
1506
+	}
1507
+	return &stock, nil
1508
+}
1509
+
1489 1510
 func AddSigleCancelStock(cancelStock *models.CancelStock) error {
1490 1511
 	err := writeDb.Create(&cancelStock).Error
1491 1512
 	return err
1492 1513
 
1493 1514
 }
1494 1515
 
1516
+func GetLastCancelStockById(orgid int64) (models.CancelStock, error) {
1517
+	stock := models.CancelStock{}
1518
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&stock).Error
1519
+	return stock, err
1520
+}
1521
+
1495 1522
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1496 1523
 	err := writeDb.Create(&cancelStock).Error
1497 1524
 	return err
@@ -2410,6 +2437,35 @@ func FindSalesReturnDetailList(orgId int64, page int64, limit int64, startTime i
2410 2437
 	return
2411 2438
 }
2412 2439
 
2440
+func FindeCancelGroup(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64) (list []*models.CancelStockInfo, err error) {
2441
+	db := readDb.Model(&models.CancelStockInfo{})
2442
+	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
2443
+	if len(keywords) > 0 {
2444
+		likeKey := "%" + keywords + "%"
2445
+		db = db.Joins("join xt_cancel_stock on xt_cancel_stock.id = xt_cancel_stock_info.cancel_stock_id AND xt_cancel_stock.return_time >=? AND xt_cancel_stock.return_time<= ? AND xt_cancel_stock.status = 1 AND xt_cancel_stock.org_id = ?", startTime, endTime, orgId)
2446
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_cancel_stock.creater")
2447
+		db = db.Joins("join xt_good_information on xt_good_information.id = xt_cancel_stock_info.good_id")
2448
+
2449
+		db = db.Where("sgj_user_admin_role.user_name LIKE ? OR xt_cancel_stock_info.order_number LIKE ? OR xt_good_information.specification_name LIKE ?", likeKey, likeKey, likeKey).Group("xt_cancel_stock_info.id")
2450
+	} else {
2451
+		db = db.Joins("join xt_cancel_stock on xt_cancel_stock.id = xt_cancel_stock_info.cancel_stock_id AND xt_cancel_stock.return_time >=? AND xt_cancel_stock.return_time<= ? ", startTime, endTime)
2452
+	}
2453
+
2454
+	if manufacturer > 0 {
2455
+		db = db.Joins("join xt_cancel_stock as cs on cs.id = xt_cancel_stock_info.cancel_stock_id AND cs.manufacturer =?", manufacturer)
2456
+	}
2457
+
2458
+	if order_type > 0 {
2459
+		db = db.Where("xt_cancel_stock_info.type = ?", order_type)
2460
+	}
2461
+
2462
+	db = db.Preload("CancelStock", "status = 1 AND org_id = ?", orgId)
2463
+	db = db.Preload("GoodInfo", "status = 1 AND org_id = ?", orgId)
2464
+
2465
+	err = db.Group("xt_cancel_stock_info.good_id").Order("xt_cancel_stock_info.ctime desc").Find(&list).Error
2466
+	return
2467
+}
2468
+
2413 2469
 func FindCancelDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64) (list []*models.CancelStockInfo, total int64, err error) {
2414 2470
 	db := readDb.Model(&models.CancelStockInfo{})
2415 2471
 	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
@@ -3776,7 +3832,7 @@ func GetWarehoureOutOrderInfo(goodid int64, orgid int64) (*models.WarehouseOutIn
3776 3832
 	return &info, nil
3777 3833
 }
3778 3834
 
3779
-func GetWarehoureOrderInfoCount(goodid int64, orgid int64) (info models.WarehouseOutInfo, err error) {
3835
+func GetWarehoureOrderInfoCount(goodid int64, orgid int64, id int64) (info models.WarehouseOutInfo, err error) {
3780 3836
 
3781 3837
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status =1")
3782 3838
 	if goodid > 0 {
@@ -3785,6 +3841,9 @@ func GetWarehoureOrderInfoCount(goodid int64, orgid int64) (info models.Warehous
3785 3841
 	if orgid > 0 {
3786 3842
 		db = db.Where("x.org_id = ?", orgid)
3787 3843
 	}
3844
+	if id > 0 {
3845
+		db = db.Where("x.warehouse_info_id = ?", id)
3846
+	}
3788 3847
 	err = db.Select("x.good_id,sum(x.count) as count").Scan(&info).Error
3789 3848
 	return info, err
3790 3849
 }
@@ -4048,7 +4107,7 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
4048 4107
 		db = db.Where("good_id = ?", good_id)
4049 4108
 	}
4050 4109
 
4051
-	err = db.Count(&total).Offset(offset).Limit(limit).Find(&flow).Error
4110
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&flow).Error
4052 4111
 
4053 4112
 	return flow, total, err
4054 4113
 }
@@ -4492,10 +4551,10 @@ func GetInventorylist(startime int64, endtime int64, page int64, limit int64, in
4492 4551
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4493 4552
 	fmt.Println(table, tab)
4494 4553
 	if startime > 0 {
4495
-		db = db.Where("x.start_time>=?", startime)
4554
+		db = db.Where("x.ctime>=?", startime)
4496 4555
 	}
4497 4556
 	if endtime > 0 {
4498
-		db = db.Where("x.end_time<=?", endtime)
4557
+		db = db.Where("x.ctime<=?", endtime)
4499 4558
 	}
4500 4559
 	if len(keyword) > 0 {
4501 4560
 		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
@@ -4532,7 +4591,14 @@ func GetInventoryDetailById(id []string) (list []*models.XtStockInventory, err e
4532 4591
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4533 4592
 
4534 4593
 	info := models.WarehousingInfo{}
4535
-	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
4594
+	//err := XTReadDB().Model(&info).Where("id = ? or warehouse_info_id and status = 1", id).Find(&info).Error
4595
+	//return info, err
4596
+
4597
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4598
+	if id > 0 {
4599
+		db = db.Where("x.id = ? or x.warehouse_info_id = ?", id, id)
4600
+	}
4601
+	err := db.Select("sum(x.warehousing_count) as warehousing_count,sum(x.stock_count) as stock_count").Scan(&info).Error
4536 4602
 	return info, err
4537 4603
 }
4538 4604
 
@@ -4660,6 +4726,13 @@ func CeateStockCorrectRecord(record models.XtStockCorrectRecord) error {
4660 4726
 
4661 4727
 func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4662 4728
 	info := models.WarehousingInfo{}
4663
-	err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
4729
+	//err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
4730
+	//return info, err
4731
+
4732
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4733
+	if id > 0 {
4734
+		db = db.Where("x.id = ? or x.warehouse_info_id = ?", id, id)
4735
+	}
4736
+	err := db.Select("sum(x.stock_count) as stock_count").Scan(&info).Error
4664 4737
 	return info, err
4665 4738
 }

+ 41 - 12
service/warhouse_service.go View File

@@ -91,12 +91,28 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
91 91
 
92 92
 	fmt.Println("单位1", advice.PrescribingNumber)
93 93
 	fmt.Println("单位2", drup.MaxUnit)
94
+	var drug_price float64
94 95
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
95 96
 		deliver_number = count * drup.MinNumber
97
+
96 98
 	} else {
97 99
 		deliver_number = count
100
+
101
+	}
102
+
103
+	if advice.PrescribingNumberUnit == drup.MaxUnit {
104
+		drug_price = drup.RetailPrice
105
+	}
106
+
107
+	if advice.PrescribingNumberUnit == drup.MinUnit {
108
+		drug_price = drup.MinPrice
109
+	}
110
+
111
+	if advice.PrescribingNumberUnit != drup.MaxUnit || advice.PrescribingNumberUnit != drup.MinUnit {
112
+		drug_price = drup.RetailPrice
98 113
 	}
99 114
 
115
+	fmt.Println("hhhh233232322333232323332323323232323232323223", drug_price)
100 116
 	// 根据先进先出原则,查询最先入库的批次,进行出库
101 117
 	// 如果没有对应的库存,则报错
102 118
 	//开启事物
@@ -115,7 +131,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
115 131
 	fmt.Println("deliver_number88888888888", deliver_number)
116 132
 
117 133
 	//查找药品信息
118
-	baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
134
+	//baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
119 135
 
120 136
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
121 137
 	if stock_number >= deliver_number {
@@ -134,9 +150,9 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
134 150
 			DrugId:                  advice.DrugId,
135 151
 			Number:                  warehouse.Number,
136 152
 			BatchNumber:             warehouse.BatchNumber,
137
-			Price:                   baseInfo.RetailPrice,
153
+			Price:                   drug_price,
138 154
 			CountUnit:               advice.PrescribingNumberUnit,
139
-			RetailPrice:             baseInfo.RetailPrice,
155
+			RetailPrice:             drug_price,
140 156
 			ProductDate:             warehouse.ProductDate,
141 157
 			ExpiryDate:              warehouse.ExpiryDate,
142 158
 			PatientId:               advice.PatientId,
@@ -154,7 +170,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
154 170
 			ProductDate:             warehouse.ProductDate,
155 171
 			ExpireDate:              warehouse.ExpiryDate,
156 172
 			Count:                   count,
157
-			Price:                   baseInfo.RetailPrice,
173
+			Price:                   drug_price,
158 174
 			Status:                  1,
159 175
 			Ctime:                   time.Now().Unix(),
160 176
 			UserOrgId:               orgID,
@@ -255,7 +271,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
255 271
 			DrugId:                  advice.DrugId,
256 272
 			Number:                  warehouse.Number,
257 273
 			BatchNumber:             warehouse.BatchNumber,
258
-			Price:                   baseInfo.RetailPrice,
274
+			Price:                   drug_price,
259 275
 			CountUnit:               advice.PrescribingNumberUnit,
260 276
 			ProductDate:             warehouse.ProductDate,
261 277
 			ExpiryDate:              warehouse.ExpiryDate,
@@ -310,7 +326,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
310 326
 			ProductDate:             warehouse.ProductDate,
311 327
 			ExpireDate:              warehouse.ExpiryDate,
312 328
 			Count:                   stock_number,
313
-			Price:                   baseInfo.RetailPrice,
329
+			Price:                   drug_price,
314 330
 			Status:                  1,
315 331
 			Ctime:                   time.Now().Unix(),
316 332
 			UserOrgId:               orgID,
@@ -417,6 +433,19 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
417 433
 		deliver_number = count
418 434
 	}
419 435
 
436
+	var min_price float64
437
+
438
+	if advice.PrescribingNumberUnit == drup.MaxUnit {
439
+		min_price = drup.RetailPrice
440
+	}
441
+	if advice.PrescribingNumberUnit == drup.MinUnit {
442
+		min_price = drup.MinPrice
443
+	}
444
+
445
+	if advice.PrescribingNumberUnit != drup.MaxUnit && advice.PrescribingNumberUnit != drup.MinUnit {
446
+		min_price = drup.RetailPrice
447
+	}
448
+
420 449
 	// 根据先进先出原则,查询最先入库的批次,进行出库
421 450
 	// 如果没有对应的库存,则报错
422 451
 	//开启事物
@@ -451,9 +480,9 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
451 480
 			DrugId:                  advice.DrugId,
452 481
 			Number:                  warehouse.Number,
453 482
 			BatchNumber:             warehouse.BatchNumber,
454
-			Price:                   baseInfo.RetailPrice,
483
+			Price:                   min_price,
455 484
 			CountUnit:               baseInfo.MaxUnit,
456
-			RetailPrice:             baseInfo.RetailPrice,
485
+			RetailPrice:             min_price,
457 486
 			ProductDate:             warehouse.ProductDate,
458 487
 			ExpiryDate:              warehouse.ExpiryDate,
459 488
 			PatientId:               advice.PatientId,
@@ -471,7 +500,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
471 500
 			ProductDate:             warehouse.ProductDate,
472 501
 			ExpireDate:              warehouse.ExpiryDate,
473 502
 			Count:                   count,
474
-			Price:                   baseInfo.RetailPrice,
503
+			Price:                   min_price,
475 504
 			Status:                  1,
476 505
 			Ctime:                   time.Now().Unix(),
477 506
 			UserOrgId:               orgID,
@@ -569,8 +598,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
569 598
 			DrugId:                  advice.DrugId,
570 599
 			Number:                  warehouse.Number,
571 600
 			BatchNumber:             warehouse.BatchNumber,
572
-			Price:                   baseInfo.RetailPrice,
573
-			RetailPrice:             baseInfo.RetailPrice,
601
+			Price:                   min_price,
602
+			RetailPrice:             min_price,
574 603
 			ProductDate:             warehouse.ProductDate,
575 604
 			ExpiryDate:              warehouse.ExpiryDate,
576 605
 			PatientId:               advice.PatientId,
@@ -589,7 +618,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
589 618
 			ProductDate:             warehouse.ProductDate,
590 619
 			ExpireDate:              warehouse.ExpiryDate,
591 620
 			Count:                   stock_number,
592
-			Price:                   baseInfo.RetailPrice,
621
+			Price:                   min_price,
593 622
 			Status:                  1,
594 623
 			Ctime:                   time.Now().Unix(),
595 624
 			UserOrgId:               orgID,