csx 3 gadus atpakaļ
vecāks
revīzija
5c62c3a509

+ 26 - 14
controllers/drug_stock_api_contorller.go Parādīt failu

@@ -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,
@@ -3037,8 +3049,8 @@ func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3037 3049
 	adminUserInfo := c.GetAdminUserInfo()
3038 3050
 	orgId := adminUserInfo.CurrentOrgId
3039 3051
 	if order_type == 2 {
3040
-		//list, err := service.GetDrugOutOrderPrint(startTime, endTime, orgId)
3041
-		list, err := service.GetDrugOutOrderPrintList(startTime, endTime, orgId)
3052
+		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId)
3053
+		//list, err := service.GetDrugOutOrderPrintList(startTime, endTime, orgId)
3042 3054
 		if err == nil {
3043 3055
 			c.ServeSuccessJSON(map[string]interface{}{
3044 3056
 				"list": list,

+ 11 - 9
controllers/gobal_config_api_controller.go Parādīt failu

@@ -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
 }
@@ -2099,8 +2098,10 @@ func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
2099 2098
 	ids := strings.Split(id, ",")
2100 2099
 	admin := c.GetAdminUserInfo()
2101 2100
 	info, _ := service.FindeDrugWarehouseOutOrder(ids, admin.CurrentOrgId)
2101
+	//info, _ := service.GetExportOutOrderDrugListOne(ids)
2102 2102
 	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
2103
-	warehousing, _ := service.FindeDrugWarehouseOutDetail(ids, admin.CurrentOrgId)
2103
+	//warehousing, _ := service.FindeDrugWarehouseOutDetail(ids, admin.CurrentOrgId)
2104
+	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2104 2105
 	c.ServeSuccessJSON(map[string]interface{}{
2105 2106
 		"info":             info,
2106 2107
 		"warehousing":      warehousing,
@@ -2138,7 +2139,8 @@ func (c *GobalConfigApiController) GetExportOutOrderDrugList() {
2138 2139
 	orderId := c.GetString("order_id")
2139 2140
 	ids := strings.Split(orderId, ",")
2140 2141
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2141
-	list, _ := service.GetExportOutOrderDrugList(ids)
2142
+	//list, _ := service.GetExportOutOrderDrugList(ids)
2143
+	list, _ := service.GetExportOutOrderDrugListOne(ids)
2142 2144
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2143 2145
 	dealerList, _ := service.GetAllDealerList(orgId)
2144 2146
 	c.ServeSuccessJSON(map[string]interface{}{

+ 13 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go Parādīt failu

@@ -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,

+ 11 - 1
controllers/print_data_api_controller.go Parādīt failu

@@ -207,7 +207,8 @@ func (this *PrintDataAPIController) GetGoodDetailPrintList() {
207 207
 
208 208
 	//出库详情
209 209
 	if types == 2 {
210
-		list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
210
+		//list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
211
+		list, _ := service.GetWarehouseOutInfoPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
211 212
 		stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
212 213
 		if err != nil {
213 214
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -219,4 +220,13 @@ func (this *PrintDataAPIController) GetGoodDetailPrintList() {
219 220
 		})
220 221
 	}
221 222
 
223
+	//退库详情
224
+	if types == 4 {
225
+
226
+		list, _ := service.GetWarehouseCancelPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
227
+		this.ServeSuccessJSON(map[string]interface{}{
228
+			"list": list,
229
+		})
230
+	}
231
+
222 232
 }

+ 14 - 10
controllers/self_drug_api_congtroller.go Parādīt failu

@@ -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 {

+ 32 - 29
controllers/stock_in_api_controller.go Parādīt failu

@@ -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)
@@ -5303,7 +5297,9 @@ func (this *StockManagerApiController) SaveCheckDamage() {
5303 5297
 
5304 5298
 	if errcodes == gorm.ErrRecordNotFound {
5305 5299
 		service.AddSigleWarehouseOut(&warehouseOut)
5300
+
5306 5301
 	}
5302
+	out, _ := service.GetLastGoodWarehouseOut(adminUserInfo.CurrentOrgId)
5307 5303
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
5308 5304
 	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
5309 5305
 	var manufacturer_id int64
@@ -5320,10 +5316,11 @@ func (this *StockManagerApiController) SaveCheckDamage() {
5320 5316
 				dealer_id = its.ID
5321 5317
 			}
5322 5318
 		}
5319
+		goodinfo, _ := service.GetGoodInformationByGoodId(item.GoodId)
5323 5320
 		//插入出库单
5324 5321
 		warehouseOutInfo := &models.WarehouseOutInfo{
5325
-			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5326
-			WarehouseOutId:          warehouseOut.ID,
5322
+			WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
5323
+			WarehouseOutId:          out.ID,
5327 5324
 			GoodId:                  item.GoodId,
5328 5325
 			Count:                   item.Count,
5329 5326
 			Price:                   item.PackingPrice,
@@ -5338,6 +5335,7 @@ func (this *StockManagerApiController) SaveCheckDamage() {
5338 5335
 			ProductDate:             item.ProductDate,
5339 5336
 			Dealer:                  dealer_id,
5340 5337
 			LicenseNumber:           item.LicenseNumber,
5338
+			GoodTypeId:              goodinfo.GoodTypeId,
5341 5339
 		}
5342 5340
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5343 5341
 		fmt.Println("99999999999999", errOne)
@@ -5362,7 +5360,7 @@ func (this *StockManagerApiController) SaveCheckDamage() {
5362 5360
 			ConsumableType:          5,
5363 5361
 			IsSys:                   0,
5364 5362
 			WarehousingOrder:        "",
5365
-			WarehouseOutId:          warehouseOutInfo.ID,
5363
+			WarehouseOutId:          out.ID,
5366 5364
 			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
5367 5365
 			IsEdit:                  0,
5368 5366
 			CancelStockId:           0,
@@ -5687,6 +5685,7 @@ func (this *StockManagerApiController) SaveCheckInventory() {
5687 5685
 
5688 5686
 		//查询该耗材最后1条批次
5689 5687
 		info, _ := service.GetLastWarehouseInfo(item.GoodId)
5688
+		good, _ := service.GetGoodInformationByGoodId(item.GoodId)
5690 5689
 		fmt.Println("总共", item.Count)
5691 5690
 		fmt.Println("数据", list.StockCount)
5692 5691
 		//盘点盘点库存和et实际库存的大小
@@ -5734,6 +5733,8 @@ func (this *StockManagerApiController) SaveCheckInventory() {
5734 5733
 				StockCount:       item.Count - list.StockCount,
5735 5734
 				Dealer:           dealer_id,
5736 5735
 				LicenseNumber:    info.LicenseNumber,
5736
+				WarehouseInfoId:  item.WarehousingInfoId,
5737
+				GoodTypeId:       good.GoodTypeId,
5737 5738
 			}
5738 5739
 
5739 5740
 			flow := models.VmStockFlow{
@@ -5790,9 +5791,10 @@ func (this *StockManagerApiController) SaveCheckInventory() {
5790 5791
 			}
5791 5792
 			err = service.CreateWarehouseOut(warehouseOut)
5792 5793
 			fmt.Println(err)
5794
+			out, _ := service.GetLastGoodWarehouseOut(adminUserInfo.CurrentOrgId)
5793 5795
 			warehouseOutInfo := &models.WarehouseOutInfo{
5794
-				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5795
-				WarehouseOutId:          warehouseOut.ID,
5796
+				WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
5797
+				WarehouseOutId:          out.ID,
5796 5798
 				GoodId:                  warehouseInfo.GoodId,
5797 5799
 				Count:                   list.StockCount - item.Count,
5798 5800
 				Price:                   warehouseInfo.Price,
@@ -5807,6 +5809,7 @@ func (this *StockManagerApiController) SaveCheckInventory() {
5807 5809
 				ProductDate:             warehouseInfo.ProductDate,
5808 5810
 				Dealer:                  dealer_id,
5809 5811
 				LicenseNumber:           warehouseInfo.LicenseNumber,
5812
+				GoodTypeId:              good.GoodTypeId,
5810 5813
 			}
5811 5814
 
5812 5815
 			stockFlow := models.VmStockFlow{
@@ -5821,7 +5824,7 @@ func (this *StockManagerApiController) SaveCheckInventory() {
5821 5824
 				ConsumableType:          2,
5822 5825
 				IsSys:                   2,
5823 5826
 				WarehousingOrder:        "",
5824
-				WarehouseOutId:          warehouseOut.ID,
5827
+				WarehouseOutId:          out.ID,
5825 5828
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5826 5829
 				IsEdit:                  1,
5827 5830
 				CancelStockId:           0,
@@ -5835,7 +5838,7 @@ func (this *StockManagerApiController) SaveCheckInventory() {
5835 5838
 				Mtime:                   0,
5836 5839
 				Price:                   warehouseInfo.Price,
5837 5840
 				WarehousingDetailId:     0,
5838
-				WarehouseOutDetailId:    warehouseOutInfo.ID,
5841
+				WarehouseOutDetailId:    out.ID,
5839 5842
 				CancelOutDetailId:       0,
5840 5843
 				ProductDate:             warehouseInfo.ProductDate,
5841 5844
 				ExpireDate:              warehouseInfo.ExpiryDate,

+ 1 - 0
models/dialysis.go Parādīt failu

@@ -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 {

+ 42 - 0
models/self_drug_models.go Parādīt failu

@@ -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,45 @@ 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
 }
846
+
847
+type SgjDrugWarehouseOutInfo struct {
848
+	ID                      int64      `gorm:"column:id" json:"id" form:"id"`
849
+	WarehouseOutId          int64      `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
850
+	DrugId                  int64      `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
851
+	WarehousingOutTarget    int64      `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
852
+	Count                   int64      `gorm:"column:count" json:"count" form:"count"`
853
+	CountUnit               string     `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
854
+	Price                   float64    `gorm:"column:price" json:"price" form:"price"`
855
+	TotalPrice              float64    `gorm:"column:total_price" json:"total_price" form:"total_price"`
856
+	ProductDate             int64      `gorm:"column:product_date" json:"product_date" form:"product_date"`
857
+	ExpiryDate              int64      `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
858
+	Mtime                   int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
859
+	Ctime                   int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
860
+	Status                  int64      `gorm:"column:status" json:"status" form:"status"`
861
+	OrgId                   int64      `gorm:"column:org_id" json:"org_id" form:"org_id"`
862
+	Remark                  string     `gorm:"column:remark" json:"remark" form:"remark"`
863
+	IsCancel                int64      `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
864
+	WarehouseOutOrderNumber string     `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
865
+	Type                    int64      `gorm:"column:type" json:"type" form:"type"`
866
+	Dealer                  int64      `gorm:"column:dealer" json:"dealer" form:"dealer"`
867
+	Manufacturer            int64      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
868
+	IsSys                   int64      `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
869
+	SysRecordTime           int64      `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
870
+	RetailPrice             float64    `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
871
+	RetailTotalPrice        float64    `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
872
+	WarehouseInfoId         int64      `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
873
+	Number                  string     `gorm:"column:number" json:"number" form:"number"`
874
+	BatchNumber             string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
875
+	PatientId               int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
876
+	XtBaseDrug              XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
877
+}
878
+
879
+func (SgjDrugWarehouseOutInfo) TableName() string {
880
+	return "xt_drug_warehouse_out_info"
881
+}

+ 65 - 0
models/stock_models.go Parādīt failu

@@ -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 {
@@ -1039,3 +1040,67 @@ type XtStockCorrectRecord struct {
1039 1040
 func (XtStockCorrectRecord) TableName() string {
1040 1041
 	return "xt_stock_correct_record"
1041 1042
 }
1043
+
1044
+type SgjWarehouseOutInfo struct {
1045
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
1046
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
1047
+	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
1048
+	GoodId                  int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
1049
+	GoodTypeId              int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1050
+	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
1051
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
1052
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
1053
+	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
1054
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
1055
+	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1056
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1057
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1058
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
1059
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
1060
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
1061
+	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
1062
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
1063
+	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
1064
+	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
1065
+	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1066
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
1067
+	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
1068
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1069
+	Number                  string  `gorm:"column:number" json:"number" form:"number"`
1070
+	LicenseNumber           string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
1071
+	ConsumableType          int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
1072
+	GoodName                string  `gorm:"column:good_name" json:"good_name"`
1073
+	SpecificationName       string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1074
+	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1075
+	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1076
+	PackingPrice            float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1077
+}
1078
+
1079
+type SgjCancelStockInfo struct {
1080
+	ID                int64   `gorm:"column:id" json:"id" form:"id"`
1081
+	GoodId            int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
1082
+	CancelStockId     int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
1083
+	GoodTypeId        int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1084
+	Count             int64   `gorm:"column:count" json:"count" form:"count"`
1085
+	Price             float64 `gorm:"column:price" json:"price" form:"price"`
1086
+	Total             float64 `gorm:"column:total" json:"total" form:"total"`
1087
+	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
1088
+	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1089
+	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1090
+	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1091
+	Status            int64   `gorm:"column:status" json:"status" form:"status"`
1092
+	OrgId             int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
1093
+	OrderNumber       string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1094
+	Type              int64   `gorm:"column:type" json:"type" form:"type"`
1095
+	Dealer            string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1096
+	Manufacturer      string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1097
+	Number            string  `gorm:"column:number" json:"number" form:"number"`
1098
+	RegisterAccount   string  `gorm:"column:register_account" json:"register_account" form:"register_account"`
1099
+	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
1100
+	WarehouseInfoId   int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
1101
+	GoodName          string  `gorm:"column:good_name" json:"good_name"`
1102
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1103
+	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1104
+	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1105
+	PackingPrice      float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1106
+}

+ 1 - 1
service/app_version.go Parādīt failu

@@ -351,7 +351,7 @@ func (HisPrescriptionInfoTemplateTwo) TableName() string {
351 351
 func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
352 352
 	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
353 353
 		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
354
-			return db.Where("status = 1").Preload("Drug", "status=1")
354
+			return db.Where("status = 1")
355 355
 		}).
356 356
 		Where("status = 1 ").
357 357
 		Find(&prescription).Error

+ 16 - 0
service/drug_stock_service.go Parādīt failu

@@ -260,3 +260,19 @@ func GetDrugOutOrderPrintList(startime int64, endtime int64, orgid int64) (list
260 260
 	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
261 261
 	return list, err
262 262
 }
263
+
264
+func GetDrugOutOrderInfoPrintList(startime int64, endtime int64, orgid int64) (list []*models.SgjDrugWarehouseOutInfo, err error) {
265
+
266
+	db := XTReadDB().Table("xt_drug_warehouse_out_info").Where("status = 1")
267
+	if startime > 0 {
268
+		db = db.Where("ctime >=?", startime)
269
+	}
270
+	if endtime > 0 {
271
+		db = db.Where("ctime<=?", endtime)
272
+	}
273
+	if orgid > 0 {
274
+		db = db.Where("org_id = ?", orgid)
275
+	}
276
+	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
277
+	return list, err
278
+}

+ 35 - 4
service/gobal_config_service.go Parādīt failu

@@ -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 Parādīt failu

@@ -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

+ 36 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Parādīt failu

@@ -253,3 +253,39 @@ func GetWarehouseOutInfoGoodDetailPrintList(orgid int64, startime int64, endtime
253 253
 	return auto, err
254 254
 
255 255
 }
256
+
257
+func GetWarehouseOutInfoPrintList(orgid int64, startime int64, endtime int64) (out []*models.SgjWarehouseOutInfo, err error) {
258
+
259
+	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
260
+	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
261
+	fmt.Println(table)
262
+	if orgid > 0 {
263
+		db = db.Where("x.org_id = ?", orgid)
264
+	}
265
+	if startime > 0 {
266
+		db = db.Where("x.ctime >= ?", startime)
267
+	}
268
+	if endtime > 0 {
269
+		db = db.Where("x.ctime<=?", endtime)
270
+	}
271
+	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
272
+	return out, err
273
+}
274
+
275
+func GetWarehouseCancelPrintList(orgid int64, startime int64, endtime int64) (cancel []*models.SgjCancelStockInfo, err error) {
276
+
277
+	db := p_service.XTReadDB().Table("xt_cancel_stock_info as x").Where("x.status = 1")
278
+	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
279
+	fmt.Println(table)
280
+	if orgid > 0 {
281
+		db = db.Where("x.org_id = ?", orgid)
282
+	}
283
+	if startime > 0 {
284
+		db = db.Where("x.ctime >= ?", startime)
285
+	}
286
+	if endtime > 0 {
287
+		db = db.Where("x.ctime<=?", endtime)
288
+	}
289
+	err = db.Select("x.ctime,x.good_id,sum(x.count) as count,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&cancel).Error
290
+	return cancel, err
291
+}

+ 10 - 20
service/self_drug_service.go Parādīt failu

@@ -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 Parādīt failu

@@ -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
 

+ 96 - 6
service/stock_service.go Parādīt failu

@@ -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
 }
@@ -3863,6 +3922,17 @@ func GetExportOutOrderDrugList(warehouse_out_id []string) (out []*models.StDrugW
3863 3922
 	return out, err
3864 3923
 }
3865 3924
 
3925
+func GetExportOutOrderDrugListOne(warehouse_out_id []string) (out []*models.StDrugWarehouseOutInfo, err error) {
3926
+	db := XTReadDB().Table("xt_drug_flow as x").Where("x.status = 1")
3927
+	table := XTReadDB().Table("xt_base_drug as b").Where("b.status = 1")
3928
+	fmt.Println("table", table)
3929
+	if len(warehouse_out_id) > 0 {
3930
+		db = db.Where("x.warehouse_out_id in(?)", warehouse_out_id)
3931
+	}
3932
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.max_unit as count_unit,x.price,x.product_date,x.expire_date as expire_date,x.warehouse_out_order_number,x.dealer,x.manufacturer,x.is_sys,x.number,x.batch_number,x.patient_id,b.dose,b.dose_unit,b.min_number,b.min_unit,b.max_unit,b.drug_name,b.drug_type,b.min_price").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&out).Error
3933
+	return out, err
3934
+}
3935
+
3866 3936
 func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid int64) (models.WarehouseOutInfo, error) {
3867 3937
 
3868 3938
 	info := models.WarehouseOutInfo{}
@@ -4048,7 +4118,7 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
4048 4118
 		db = db.Where("good_id = ?", good_id)
4049 4119
 	}
4050 4120
 
4051
-	err = db.Count(&total).Offset(offset).Limit(limit).Find(&flow).Error
4121
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&flow).Error
4052 4122
 
4053 4123
 	return flow, total, err
4054 4124
 }
@@ -4292,6 +4362,12 @@ func CreateWarehouseOut(out models.WarehouseOut) error {
4292 4362
 	return err
4293 4363
 }
4294 4364
 
4365
+func GetLastGoodWarehouseOut(orgid int64) (models.WarehouseOut, error) {
4366
+	out := models.WarehouseOut{}
4367
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&out).Error
4368
+	return out, err
4369
+}
4370
+
4295 4371
 func CreateWarehouseInfo(info models.WarehousingInfo) error {
4296 4372
 
4297 4373
 	err := XTReadDB().Create(&info).Error
@@ -4492,10 +4568,10 @@ func GetInventorylist(startime int64, endtime int64, page int64, limit int64, in
4492 4568
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4493 4569
 	fmt.Println(table, tab)
4494 4570
 	if startime > 0 {
4495
-		db = db.Where("x.start_time>=?", startime)
4571
+		db = db.Where("x.ctime>=?", startime)
4496 4572
 	}
4497 4573
 	if endtime > 0 {
4498
-		db = db.Where("x.end_time<=?", endtime)
4574
+		db = db.Where("x.ctime<=?", endtime)
4499 4575
 	}
4500 4576
 	if len(keyword) > 0 {
4501 4577
 		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
@@ -4532,7 +4608,14 @@ func GetInventoryDetailById(id []string) (list []*models.XtStockInventory, err e
4532 4608
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4533 4609
 
4534 4610
 	info := models.WarehousingInfo{}
4535
-	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
4611
+	//err := XTReadDB().Model(&info).Where("id = ? or warehouse_info_id and status = 1", id).Find(&info).Error
4612
+	//return info, err
4613
+
4614
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4615
+	if id > 0 {
4616
+		db = db.Where("x.id = ? or x.warehouse_info_id = ?", id, id)
4617
+	}
4618
+	err := db.Select("sum(x.warehousing_count) as warehousing_count,sum(x.stock_count) as stock_count").Scan(&info).Error
4536 4619
 	return info, err
4537 4620
 }
4538 4621
 
@@ -4660,6 +4743,13 @@ func CeateStockCorrectRecord(record models.XtStockCorrectRecord) error {
4660 4743
 
4661 4744
 func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4662 4745
 	info := models.WarehousingInfo{}
4663
-	err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
4746
+	//err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
4747
+	//return info, err
4748
+
4749
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4750
+	if id > 0 {
4751
+		db = db.Where("x.id = ? or x.warehouse_info_id = ?", id, id)
4752
+	}
4753
+	err := db.Select("sum(x.stock_count) as stock_count").Scan(&info).Error
4664 4754
 	return info, err
4665 4755
 }

+ 41 - 12
service/warhouse_service.go Parādīt failu

@@ -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,