csx 3 vuotta sitten
vanhempi
commit
5c62c3a509

+ 26 - 14
controllers/drug_stock_api_contorller.go Näytä tiedosto

1183
 				}
1183
 				}
1184
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
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
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1186
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1194
 
1187
 
1195
 				total := float64(count) * price
1188
 				total := float64(count) * price
1233
 					}
1226
 					}
1234
 
1227
 
1235
 				}
1228
 				}
1236
-
1229
+				fmt.Println("孟子", warehouseOut.ID)
1237
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1230
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1231
+
1238
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1232
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1239
 					WarehouseOutId:          warehouseOut.ID,
1233
 					WarehouseOutId:          warehouseOut.ID,
1240
 					DrugId:                  drug_id,
1234
 					DrugId:                  drug_id,
1259
 					WarehouseInfoId:         warehouse_info_id,
1253
 					WarehouseInfoId:         warehouse_info_id,
1260
 				}
1254
 				}
1261
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1255
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1256
+				fmt.Println("hhhhhhhhhhhhhhhh", warehouseOut.ID)
1262
 
1257
 
1263
 				drugflow := &models.DrugFlow{
1258
 				drugflow := &models.DrugFlow{
1264
 					WarehouseOutId:          warehouseOut.ID,
1259
 					WarehouseOutId:          warehouseOut.ID,
1265
-					WarehouseOutOrderNumber: warehousing_out_order,
1260
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1266
 					DrugId:                  drug_id,
1261
 					DrugId:                  drug_id,
1267
 					Number:                  number,
1262
 					Number:                  number,
1268
 					ProductDate:             productDates,
1263
 					ProductDate:             productDates,
1344
 			return
1339
 			return
1345
 		} else {
1340
 		} else {
1346
 			service.AddSigleDrugWarehouseOut(&warehouseOut)
1341
 			service.AddSigleDrugWarehouseOut(&warehouseOut)
1342
+			list, _ := service.GetLastWarehouseOut(adminUserInfo.CurrentOrgId)
1343
+			for _, item := range drugFlow {
1344
+				item.WarehouseOutId = list.ID
1345
+			}
1347
 			service.CreateDrugFlow(drugFlow)
1346
 			service.CreateDrugFlow(drugFlow)
1348
 			// 出库流程
1347
 			// 出库流程
1349
 			// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
1348
 			// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
2138
 				batch_number := items["batch_number"].(string)
2137
 				batch_number := items["batch_number"].(string)
2139
 				max_unit := items["max_unit"].(string)
2138
 				max_unit := items["max_unit"].(string)
2140
 				batch_number_id := int64(items["batch_number_id"].(float64))
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
 				fmt.Println("99999999999999999999", batch_number_id)
2154
 				fmt.Println("99999999999999999999", batch_number_id)
2143
 				cancelStockInfo := &models.DrugCancelStockInfo{
2155
 				cancelStockInfo := &models.DrugCancelStockInfo{
2144
 					OrderNumber:      cancelStock.OrderNumber,
2156
 					OrderNumber:      cancelStock.OrderNumber,
2182
 					IsEdit:                  0,
2194
 					IsEdit:                  0,
2183
 					CancelStockId:           cancelStock.ID,
2195
 					CancelStockId:           cancelStock.ID,
2184
 					CancelOrderNumber:       cancelStock.OrderNumber,
2196
 					CancelOrderNumber:       cancelStock.OrderNumber,
2185
-					Manufacturer:            0,
2186
-					Dealer:                  0,
2197
+					Manufacturer:            manufacturer_id,
2198
+					Dealer:                  dealer_id,
2187
 					Creator:                 adminUserInfo.AdminUser.Id,
2199
 					Creator:                 adminUserInfo.AdminUser.Id,
2188
 					UpdateCreator:           0,
2200
 					UpdateCreator:           0,
2189
 					Status:                  1,
2201
 					Status:                  1,
3037
 	adminUserInfo := c.GetAdminUserInfo()
3049
 	adminUserInfo := c.GetAdminUserInfo()
3038
 	orgId := adminUserInfo.CurrentOrgId
3050
 	orgId := adminUserInfo.CurrentOrgId
3039
 	if order_type == 2 {
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
 		if err == nil {
3054
 		if err == nil {
3043
 			c.ServeSuccessJSON(map[string]interface{}{
3055
 			c.ServeSuccessJSON(map[string]interface{}{
3044
 				"list": list,
3056
 				"list": list,

+ 11 - 9
controllers/gobal_config_api_controller.go Näytä tiedosto

1682
 	keyword := c.GetString("keyword")
1682
 	keyword := c.GetString("keyword")
1683
 	limit, _ := c.GetInt64("limit")
1683
 	limit, _ := c.GetInt64("limit")
1684
 	page, _ := c.GetInt64("page")
1684
 	page, _ := c.GetInt64("page")
1685
+	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword)
1685
 	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1686
 	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1687
+
1686
 	if err != nil {
1688
 	if err != nil {
1687
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1689
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1688
 		return
1690
 		return
1689
 	}
1691
 	}
1690
 	c.ServeSuccessJSON(map[string]interface{}{
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
 	}
1853
 	}
1851
 	adminUserInfo := c.GetAdminUserInfo()
1854
 	adminUserInfo := c.GetAdminUserInfo()
1852
 
1855
 
1853
-	//查询入库数量
1854
-	//list, total, err := service.GetDrugStockList(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1855
-
1856
 	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1856
 	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1857
 	fmt.Println("total232323232323232232323", total)
1857
 	fmt.Println("total232323232323232232323", total)
1858
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
1858
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2035
 	start_time, _ := c.GetInt64("start_time")
2035
 	start_time, _ := c.GetInt64("start_time")
2036
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2036
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2037
 	list, err := service.GetSingleOrderDetail(id, orgId)
2037
 	list, err := service.GetSingleOrderDetail(id, orgId)
2038
-	outList, err := service.GetAllSingleDrugDetail(id, orgId)
2039
 	dealerList, err := service.GetAllDealerList(orgId)
2038
 	dealerList, err := service.GetAllDealerList(orgId)
2040
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2039
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2041
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2040
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2041
+
2042
 	if err != nil {
2042
 	if err != nil {
2043
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2043
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2044
 		return
2044
 		return
2047
 		"list":             list,
2047
 		"list":             list,
2048
 		"dealerList":       dealerList,
2048
 		"dealerList":       dealerList,
2049
 		"manufacturerList": manufacturerList,
2049
 		"manufacturerList": manufacturerList,
2050
-		"outList":          outList,
2051
 		"drugFlowList":     drugFlowList,
2050
 		"drugFlowList":     drugFlowList,
2052
 	})
2051
 	})
2053
 }
2052
 }
2099
 	ids := strings.Split(id, ",")
2098
 	ids := strings.Split(id, ",")
2100
 	admin := c.GetAdminUserInfo()
2099
 	admin := c.GetAdminUserInfo()
2101
 	info, _ := service.FindeDrugWarehouseOutOrder(ids, admin.CurrentOrgId)
2100
 	info, _ := service.FindeDrugWarehouseOutOrder(ids, admin.CurrentOrgId)
2101
+	//info, _ := service.GetExportOutOrderDrugListOne(ids)
2102
 	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
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
 	c.ServeSuccessJSON(map[string]interface{}{
2105
 	c.ServeSuccessJSON(map[string]interface{}{
2105
 		"info":             info,
2106
 		"info":             info,
2106
 		"warehousing":      warehousing,
2107
 		"warehousing":      warehousing,
2138
 	orderId := c.GetString("order_id")
2139
 	orderId := c.GetString("order_id")
2139
 	ids := strings.Split(orderId, ",")
2140
 	ids := strings.Split(orderId, ",")
2140
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2141
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2141
-	list, _ := service.GetExportOutOrderDrugList(ids)
2142
+	//list, _ := service.GetExportOutOrderDrugList(ids)
2143
+	list, _ := service.GetExportOutOrderDrugListOne(ids)
2142
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2144
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2143
 	dealerList, _ := service.GetAllDealerList(orgId)
2145
 	dealerList, _ := service.GetAllDealerList(orgId)
2144
 	c.ServeSuccessJSON(map[string]interface{}{
2146
 	c.ServeSuccessJSON(map[string]interface{}{

+ 13 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go Näytä tiedosto

1702
 	change_nurse, _ := this.GetInt64("change_nurse")
1702
 	change_nurse, _ := this.GetInt64("change_nurse")
1703
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
1703
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
1704
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
1704
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
1705
+	zone_id, _ := this.GetInt64("zone_id")
1706
+	fmt.Println("zone23333232323232232332232323", zone_id)
1705
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
1707
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
1706
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1708
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1707
 		return
1709
 		return
1872
 		ChangeNurse:            change_nurse,
1874
 		ChangeNurse:            change_nurse,
1873
 		DifficultPunctureNurse: difficult_puncture_nurse,
1875
 		DifficultPunctureNurse: difficult_puncture_nurse,
1874
 		NewFistulaNurse:        new_fistula_nurse,
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
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1890
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1879
 
1891
 
1880
 	var tempdispose string
1892
 	var tempdispose string
1969
 		http.PostForm(api, values)
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
 	this.ServeSuccessJSON(map[string]interface{}{
1984
 	this.ServeSuccessJSON(map[string]interface{}{
1978
 		"dialysis_order": newdialysisRecord,
1985
 		"dialysis_order": newdialysisRecord,
1979
 		"monitor":        record,
1986
 		"monitor":        record,

+ 11 - 1
controllers/print_data_api_controller.go Näytä tiedosto

207
 
207
 
208
 	//出库详情
208
 	//出库详情
209
 	if types == 2 {
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
 		stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
212
 		stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
212
 		if err != nil {
213
 		if err != nil {
213
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
214
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
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 Näytä tiedosto

74
 	beego.Router("/api/drug/savedrugcheckinventory", &SelfDrugApiController{}, "Get:SaveDrugCheckInventory")
74
 	beego.Router("/api/drug/savedrugcheckinventory", &SelfDrugApiController{}, "Get:SaveDrugCheckInventory")
75
 	beego.Router("/api/drug/getdruginventorydetail", &SelfDrugApiController{}, "Get:GetDrugInventoryDetail")
75
 	beego.Router("/api/drug/getdruginventorydetail", &SelfDrugApiController{}, "Get:GetDrugInventoryDetail")
76
 	beego.Router("/api/drug/modifyinventory", &SelfDrugApiController{}, "Get:ModifyInventory")
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
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
78
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
80
 	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
80
 	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
1869
 
1869
 
1870
 			numbers := items["number"].(string)
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
 			if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
1872
 			if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
1881
 				utils.ErrorLog("warehouse_info_id")
1873
 				utils.ErrorLog("warehouse_info_id")
1882
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1874
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1891
 			}
1883
 			}
1892
 
1884
 
1893
 			total := items["total"].(string)
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
 			inventory := models.XtDrugInventory{
1891
 			inventory := models.XtDrugInventory{
1895
 
1892
 
1896
 				DrugName:          drug_name,
1893
 				DrugName:          drug_name,
1921
 				//BatchNumber:       batch_number,
1918
 				//BatchNumber:       batch_number,
1922
 				Total:           total,
1919
 				Total:           total,
1923
 				WarehouseInfoId: warehouse_info_id,
1920
 				WarehouseInfoId: warehouse_info_id,
1921
+				DrugOriginPlace: drug_origin_place,
1922
+				MinUnit:         min_unit,
1923
+				MinCount:        min_count,
1924
 			}
1924
 			}
1925
 			err = service.CreateDrugInventory(inventory)
1925
 			err = service.CreateDrugInventory(inventory)
1926
 			fmt.Println(err)
1926
 			fmt.Println(err)
2026
 		lastInfo, _ := service.GetLastDrugWarehouseInfo(item.DrugId)
2026
 		lastInfo, _ := service.GetLastDrugWarehouseInfo(item.DrugId)
2027
 		firstInfo, _ := service.GetFirstDrugWarehouseInfo(item.DrugId)
2027
 		firstInfo, _ := service.GetFirstDrugWarehouseInfo(item.DrugId)
2028
 		stock_total = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
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
 		if stock_total > proof_count {
2032
 		if stock_total > proof_count {
2231
 	stock_max_number, _ := this.GetInt64("stock_max_number")
2231
 	stock_max_number, _ := this.GetInt64("stock_max_number")
2232
 	stock_min_number, _ := this.GetInt64("stock_min_number")
2232
 	stock_min_number, _ := this.GetInt64("stock_min_number")
2233
 	warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
2233
 	warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
2234
+	min_count, _ := this.GetInt64("min_count")
2235
+	min_unit := this.GetString("min_unit")
2234
 	inventory := models.XtDrugInventory{
2236
 	inventory := models.XtDrugInventory{
2235
 		DrugName:          drug_name,
2237
 		DrugName:          drug_name,
2236
 		SpecificationName: specification_name,
2238
 		SpecificationName: specification_name,
2248
 		StockMaxNumber:    stock_max_number,
2250
 		StockMaxNumber:    stock_max_number,
2249
 		StockMinNumber:    stock_min_number,
2251
 		StockMinNumber:    stock_min_number,
2250
 		WarehouseInfoId:   warehouse_info_id,
2252
 		WarehouseInfoId:   warehouse_info_id,
2253
+		MinCount:          min_count,
2254
+		MinUnit:           min_unit,
2251
 	}
2255
 	}
2252
 	err := service.ModifyDrugInventory(id, inventory)
2256
 	err := service.ModifyDrugInventory(id, inventory)
2253
 	if err != nil {
2257
 	if err != nil {

+ 32 - 29
controllers/stock_in_api_controller.go Näytä tiedosto

1828
 		ReturnTime:  cancelStockDate.Unix(),
1828
 		ReturnTime:  cancelStockDate.Unix(),
1829
 		Type:        types,
1829
 		Type:        types,
1830
 	}
1830
 	}
1831
-	service.AddSigleCancelStock(&cancelStock)
1831
+
1832
 	dataBody := make(map[string]interface{}, 0)
1832
 	dataBody := make(map[string]interface{}, 0)
1833
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1833
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1834
 	if err != nil {
1834
 	if err != nil {
1973
 
1973
 
1974
 	for _, item := range cancelStockInfos {
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
 		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
1978
 		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
1988
 		if item.Count > info.Count {
1979
 		if item.Count > info.Count {
1989
 			service.UpdateCancelInfo(item.CancelStockId)
1980
 			service.UpdateCancelInfo(item.CancelStockId)
2004
 		}
1995
 		}
2005
 
1996
 
2006
 		if item.Count <= infolist.WarehousingCount {
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
 			errs := service.CreateCancelStockInfo(cancelStockInfos)
2006
 			errs := service.CreateCancelStockInfo(cancelStockInfos)
2009
 			if len(stockFLow) > 0 {
2007
 			if len(stockFLow) > 0 {
2010
 				service.CreateStockFlow(stockFLow)
2008
 				service.CreateStockFlow(stockFLow)
2025
 			}
2023
 			}
2026
 			//更改入库数量
2024
 			//更改入库数量
2027
 			errs = service.UpdateWareInfoById(item.WarehouseInfoId, item.Count)
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
 			break
2026
 			break
2035
 		}
2027
 		}
2036
 	}
2028
 	}
2379
 
2371
 
2380
 		for _, item := range cancelStockInfos {
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
 			if item.Count > info.Count {
2375
 			if item.Count > info.Count {
2384
 				c.ServeSuccessJSON(map[string]interface{}{
2376
 				c.ServeSuccessJSON(map[string]interface{}{
2385
 					"msg": "2",
2377
 					"msg": "2",
2667
 		}
2659
 		}
2668
 	} else if types == 4 {
2660
 	} else if types == 4 {
2669
 		list3, total, err = service.FindCancelDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer)
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
 		if err == nil {
2663
 		if err == nil {
2671
 			this.ServeSuccessJSON(map[string]interface{}{
2664
 			this.ServeSuccessJSON(map[string]interface{}{
2672
-				"list":  list3,
2673
-				"total": total,
2665
+				"list":      list3,
2666
+				"total":     total,
2667
+				"listgroup": listGroup,
2674
 			})
2668
 			})
2675
 		} else {
2669
 		} else {
2676
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2670
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
5303
 
5297
 
5304
 	if errcodes == gorm.ErrRecordNotFound {
5298
 	if errcodes == gorm.ErrRecordNotFound {
5305
 		service.AddSigleWarehouseOut(&warehouseOut)
5299
 		service.AddSigleWarehouseOut(&warehouseOut)
5300
+
5306
 	}
5301
 	}
5302
+	out, _ := service.GetLastGoodWarehouseOut(adminUserInfo.CurrentOrgId)
5307
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
5303
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
5308
 	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
5304
 	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
5309
 	var manufacturer_id int64
5305
 	var manufacturer_id int64
5320
 				dealer_id = its.ID
5316
 				dealer_id = its.ID
5321
 			}
5317
 			}
5322
 		}
5318
 		}
5319
+		goodinfo, _ := service.GetGoodInformationByGoodId(item.GoodId)
5323
 		//插入出库单
5320
 		//插入出库单
5324
 		warehouseOutInfo := &models.WarehouseOutInfo{
5321
 		warehouseOutInfo := &models.WarehouseOutInfo{
5325
-			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5326
-			WarehouseOutId:          warehouseOut.ID,
5322
+			WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
5323
+			WarehouseOutId:          out.ID,
5327
 			GoodId:                  item.GoodId,
5324
 			GoodId:                  item.GoodId,
5328
 			Count:                   item.Count,
5325
 			Count:                   item.Count,
5329
 			Price:                   item.PackingPrice,
5326
 			Price:                   item.PackingPrice,
5338
 			ProductDate:             item.ProductDate,
5335
 			ProductDate:             item.ProductDate,
5339
 			Dealer:                  dealer_id,
5336
 			Dealer:                  dealer_id,
5340
 			LicenseNumber:           item.LicenseNumber,
5337
 			LicenseNumber:           item.LicenseNumber,
5338
+			GoodTypeId:              goodinfo.GoodTypeId,
5341
 		}
5339
 		}
5342
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5340
 		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5343
 		fmt.Println("99999999999999", errOne)
5341
 		fmt.Println("99999999999999", errOne)
5362
 			ConsumableType:          5,
5360
 			ConsumableType:          5,
5363
 			IsSys:                   0,
5361
 			IsSys:                   0,
5364
 			WarehousingOrder:        "",
5362
 			WarehousingOrder:        "",
5365
-			WarehouseOutId:          warehouseOutInfo.ID,
5363
+			WarehouseOutId:          out.ID,
5366
 			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
5364
 			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
5367
 			IsEdit:                  0,
5365
 			IsEdit:                  0,
5368
 			CancelStockId:           0,
5366
 			CancelStockId:           0,
5687
 
5685
 
5688
 		//查询该耗材最后1条批次
5686
 		//查询该耗材最后1条批次
5689
 		info, _ := service.GetLastWarehouseInfo(item.GoodId)
5687
 		info, _ := service.GetLastWarehouseInfo(item.GoodId)
5688
+		good, _ := service.GetGoodInformationByGoodId(item.GoodId)
5690
 		fmt.Println("总共", item.Count)
5689
 		fmt.Println("总共", item.Count)
5691
 		fmt.Println("数据", list.StockCount)
5690
 		fmt.Println("数据", list.StockCount)
5692
 		//盘点盘点库存和et实际库存的大小
5691
 		//盘点盘点库存和et实际库存的大小
5734
 				StockCount:       item.Count - list.StockCount,
5733
 				StockCount:       item.Count - list.StockCount,
5735
 				Dealer:           dealer_id,
5734
 				Dealer:           dealer_id,
5736
 				LicenseNumber:    info.LicenseNumber,
5735
 				LicenseNumber:    info.LicenseNumber,
5736
+				WarehouseInfoId:  item.WarehousingInfoId,
5737
+				GoodTypeId:       good.GoodTypeId,
5737
 			}
5738
 			}
5738
 
5739
 
5739
 			flow := models.VmStockFlow{
5740
 			flow := models.VmStockFlow{
5790
 			}
5791
 			}
5791
 			err = service.CreateWarehouseOut(warehouseOut)
5792
 			err = service.CreateWarehouseOut(warehouseOut)
5792
 			fmt.Println(err)
5793
 			fmt.Println(err)
5794
+			out, _ := service.GetLastGoodWarehouseOut(adminUserInfo.CurrentOrgId)
5793
 			warehouseOutInfo := &models.WarehouseOutInfo{
5795
 			warehouseOutInfo := &models.WarehouseOutInfo{
5794
-				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5795
-				WarehouseOutId:          warehouseOut.ID,
5796
+				WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
5797
+				WarehouseOutId:          out.ID,
5796
 				GoodId:                  warehouseInfo.GoodId,
5798
 				GoodId:                  warehouseInfo.GoodId,
5797
 				Count:                   list.StockCount - item.Count,
5799
 				Count:                   list.StockCount - item.Count,
5798
 				Price:                   warehouseInfo.Price,
5800
 				Price:                   warehouseInfo.Price,
5807
 				ProductDate:             warehouseInfo.ProductDate,
5809
 				ProductDate:             warehouseInfo.ProductDate,
5808
 				Dealer:                  dealer_id,
5810
 				Dealer:                  dealer_id,
5809
 				LicenseNumber:           warehouseInfo.LicenseNumber,
5811
 				LicenseNumber:           warehouseInfo.LicenseNumber,
5812
+				GoodTypeId:              good.GoodTypeId,
5810
 			}
5813
 			}
5811
 
5814
 
5812
 			stockFlow := models.VmStockFlow{
5815
 			stockFlow := models.VmStockFlow{
5821
 				ConsumableType:          2,
5824
 				ConsumableType:          2,
5822
 				IsSys:                   2,
5825
 				IsSys:                   2,
5823
 				WarehousingOrder:        "",
5826
 				WarehousingOrder:        "",
5824
-				WarehouseOutId:          warehouseOut.ID,
5827
+				WarehouseOutId:          out.ID,
5825
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5828
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5826
 				IsEdit:                  1,
5829
 				IsEdit:                  1,
5827
 				CancelStockId:           0,
5830
 				CancelStockId:           0,
5835
 				Mtime:                   0,
5838
 				Mtime:                   0,
5836
 				Price:                   warehouseInfo.Price,
5839
 				Price:                   warehouseInfo.Price,
5837
 				WarehousingDetailId:     0,
5840
 				WarehousingDetailId:     0,
5838
-				WarehouseOutDetailId:    warehouseOutInfo.ID,
5841
+				WarehouseOutDetailId:    out.ID,
5839
 				CancelOutDetailId:       0,
5842
 				CancelOutDetailId:       0,
5840
 				ProductDate:             warehouseInfo.ProductDate,
5843
 				ProductDate:             warehouseInfo.ProductDate,
5841
 				ExpireDate:              warehouseInfo.ExpiryDate,
5844
 				ExpireDate:              warehouseInfo.ExpiryDate,

+ 1 - 0
models/dialysis.go Näytä tiedosto

802
 	ChangeNurse            int64         `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
802
 	ChangeNurse            int64         `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
803
 	DifficultPunctureNurse int64         `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
803
 	DifficultPunctureNurse int64         `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
804
 	NewFistulaNurse        int64         `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
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
 func (DialysisOrder) TableName() string {
808
 func (DialysisOrder) TableName() string {

+ 42 - 0
models/self_drug_models.go Näytä tiedosto

504
 	MinNumber        int64   `json:"min_number"`
504
 	MinNumber        int64   `json:"min_number"`
505
 	Dose             float64 `json:"dose"`
505
 	Dose             float64 `json:"dose"`
506
 	DoseUnit         string  `json:"dose_unit"`
506
 	DoseUnit         string  `json:"dose_unit"`
507
+	Unit             string  `json:"unit"`
507
 }
508
 }
508
 
509
 
509
 type BloodDrugSalesReturnInfo struct {
510
 type BloodDrugSalesReturnInfo struct {
799
 	ProofCount        int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
800
 	ProofCount        int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
800
 	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
801
 	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
801
 	StockMinNumber    int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
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
 func (XtDrugInventory) TableName() string {
807
 func (XtDrugInventory) TableName() string {
834
 	DoseUnit          string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
837
 	DoseUnit          string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
835
 	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
838
 	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
836
 	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
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
 	Total             string  `gorm:"column:total" json:"total" form:"total"`
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
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
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 Näytä tiedosto

130
 	GoodInfo         GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
130
 	GoodInfo         GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
131
 	Type             int64       `gorm:"column:type" json:"type"`
131
 	Type             int64       `gorm:"column:type" json:"type"`
132
 	LicenseNumber    string      `gorm:"column:license_number" json:"license_number" form:"license_number"`
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
 func (WarehousingInfo) TableName() string {
136
 func (WarehousingInfo) TableName() string {
1039
 func (XtStockCorrectRecord) TableName() string {
1040
 func (XtStockCorrectRecord) TableName() string {
1040
 	return "xt_stock_correct_record"
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 Näytä tiedosto

351
 func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
351
 func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
352
 	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
352
 	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
353
 		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
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
 		Where("status = 1 ").
356
 		Where("status = 1 ").
357
 		Find(&prescription).Error
357
 		Find(&prescription).Error

+ 16 - 0
service/drug_stock_service.go Näytä tiedosto

260
 	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
260
 	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
261
 	return list, err
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 Näytä tiedosto

339
 	return outinfo, total, err
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
 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) {
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
 	likeKey := "%" + keyword + "%"
375
 	likeKey := "%" + keyword + "%"
364
 	}
395
 	}
365
 
396
 
366
 	if manufacturerId > 0 {
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
 	} else {
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
 	return cancel, total, err
403
 	return cancel, total, err
757
 	return info, err
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
 	return drugflow, err
794
 	return drugflow, err
764
 }
795
 }
765
 
796
 

+ 1 - 2
service/manage_service.go Näytä tiedosto

813
 	if orgId > 0 {
813
 	if orgId > 0 {
814
 		db = db.Where("x.user_org_id = ?", orgId)
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
 	if err != nil {
817
 	if err != nil {
818
-
819
 		return
818
 		return
820
 	}
819
 	}
821
 	return
820
 	return

+ 36 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Näytä tiedosto

253
 	return auto, err
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 Näytä tiedosto

829
 }
829
 }
830
 
830
 
831
 func GetDrugPriceList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugAdjustPrice, total int64, err error) {
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
 	likeKey := "%" + keyword + "%"
833
 	likeKey := "%" + keyword + "%"
850
 	offset := (page - 1) * limit
834
 	offset := (page - 1) * limit
851
 	db := XTReadDB().Table("xt_drug_adjust_price as x").Where("x.status = 1")
835
 	db := XTReadDB().Table("xt_drug_adjust_price as x").Where("x.status = 1")
858
 	if orgId > 0 {
842
 	if orgId > 0 {
859
 		db = db.Where("x.user_org_id = ?", orgId)
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
 	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
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
 	return adjust, total, err
852
 	return adjust, total, err
863
 
853
 
990
 	if endtime > 0 {
980
 	if endtime > 0 {
991
 		db = db.Where("x.start_time<=?", endtime)
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
 	return list, total, err
984
 	return list, total, err
995
 }
985
 }
996
 
986
 
1042
 
1032
 
1043
 func ModifyDrugInventory(id int64, info models.XtDrugInventory) error {
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
 	return err
1036
 	return err
1047
 }
1037
 }
1048
 
1038
 
1072
 	if orgid > 0 {
1062
 	if orgid > 0 {
1073
 		db = db.Where("x.user_org_id = ?", orgid)
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
 	return list, total, err
1066
 	return list, total, err
1077
 }
1067
 }
1078
 
1068
 

+ 32 - 0
service/statistics_service/index_evaluation_service.go Näytä tiedosto

1276
 	var NewTotalSix int64
1276
 	var NewTotalSix int64
1277
 	var NewTotalSeven int64
1277
 	var NewTotalSeven int64
1278
 	var NewTotalEight int64
1278
 	var NewTotalEight int64
1279
+	var NewTotalNight int64
1280
+	var NewTotalTen int64
1279
 
1281
 
1280
 	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)
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
 	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)
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
 	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)
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
 	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)
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
 	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)
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
 	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)
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
 	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)
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
 
1393
 
1390
 		}
1394
 		}
1391
 		break
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 Näytä tiedosto

517
 	return info, err
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
 func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
527
 func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
521
 	if len(drugflow) > 0 {
528
 	if len(drugflow) > 0 {
522
 		utx := writeDb.Begin()
529
 		utx := writeDb.Begin()
525
 			insertParams := make([]string, 0)
532
 			insertParams := make([]string, 0)
526
 			insertData := make([]interface{}, 0)
533
 			insertData := make([]interface{}, 0)
527
 			for _, info := range drugflow {
534
 			for _, info := range drugflow {
535
+				fmt.Println("hhhhhh", info.WarehouseOutId)
528
 				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
536
 				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
529
 				insertData = append(insertData, info.WarehousingId)
537
 				insertData = append(insertData, info.WarehousingId)
530
 				insertData = append(insertData, info.DrugId)
538
 				insertData = append(insertData, info.DrugId)
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
 func AddSigleCancelStock(cancelStock *models.CancelStock) error {
1510
 func AddSigleCancelStock(cancelStock *models.CancelStock) error {
1490
 	err := writeDb.Create(&cancelStock).Error
1511
 	err := writeDb.Create(&cancelStock).Error
1491
 	return err
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
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1522
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1496
 	err := writeDb.Create(&cancelStock).Error
1523
 	err := writeDb.Create(&cancelStock).Error
1497
 	return err
1524
 	return err
2410
 	return
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
 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) {
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
 	db := readDb.Model(&models.CancelStockInfo{})
2470
 	db := readDb.Model(&models.CancelStockInfo{})
2415
 	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
2471
 	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
3776
 	return &info, nil
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
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status =1")
3837
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status =1")
3782
 	if goodid > 0 {
3838
 	if goodid > 0 {
3785
 	if orgid > 0 {
3841
 	if orgid > 0 {
3786
 		db = db.Where("x.org_id = ?", orgid)
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
 	err = db.Select("x.good_id,sum(x.count) as count").Scan(&info).Error
3847
 	err = db.Select("x.good_id,sum(x.count) as count").Scan(&info).Error
3789
 	return info, err
3848
 	return info, err
3790
 }
3849
 }
3863
 	return out, err
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
 func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid int64) (models.WarehouseOutInfo, error) {
3936
 func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid int64) (models.WarehouseOutInfo, error) {
3867
 
3937
 
3868
 	info := models.WarehouseOutInfo{}
3938
 	info := models.WarehouseOutInfo{}
4048
 		db = db.Where("good_id = ?", good_id)
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
 	return flow, total, err
4123
 	return flow, total, err
4054
 }
4124
 }
4292
 	return err
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
 func CreateWarehouseInfo(info models.WarehousingInfo) error {
4371
 func CreateWarehouseInfo(info models.WarehousingInfo) error {
4296
 
4372
 
4297
 	err := XTReadDB().Create(&info).Error
4373
 	err := XTReadDB().Create(&info).Error
4492
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4568
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4493
 	fmt.Println(table, tab)
4569
 	fmt.Println(table, tab)
4494
 	if startime > 0 {
4570
 	if startime > 0 {
4495
-		db = db.Where("x.start_time>=?", startime)
4571
+		db = db.Where("x.ctime>=?", startime)
4496
 	}
4572
 	}
4497
 	if endtime > 0 {
4573
 	if endtime > 0 {
4498
-		db = db.Where("x.end_time<=?", endtime)
4574
+		db = db.Where("x.ctime<=?", endtime)
4499
 	}
4575
 	}
4500
 	if len(keyword) > 0 {
4576
 	if len(keyword) > 0 {
4501
 		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
4577
 		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
4532
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4608
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4533
 
4609
 
4534
 	info := models.WarehousingInfo{}
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
 	return info, err
4619
 	return info, err
4537
 }
4620
 }
4538
 
4621
 
4660
 
4743
 
4661
 func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4744
 func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4662
 	info := models.WarehousingInfo{}
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
 	return info, err
4754
 	return info, err
4665
 }
4755
 }

+ 41 - 12
service/warhouse_service.go Näytä tiedosto

91
 
91
 
92
 	fmt.Println("单位1", advice.PrescribingNumber)
92
 	fmt.Println("单位1", advice.PrescribingNumber)
93
 	fmt.Println("单位2", drup.MaxUnit)
93
 	fmt.Println("单位2", drup.MaxUnit)
94
+	var drug_price float64
94
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
95
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
95
 		deliver_number = count * drup.MinNumber
96
 		deliver_number = count * drup.MinNumber
97
+
96
 	} else {
98
 	} else {
97
 		deliver_number = count
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
 	fmt.Println("deliver_number88888888888", deliver_number)
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
 	if stock_number >= deliver_number {
137
 	if stock_number >= deliver_number {
134
 			DrugId:                  advice.DrugId,
150
 			DrugId:                  advice.DrugId,
135
 			Number:                  warehouse.Number,
151
 			Number:                  warehouse.Number,
136
 			BatchNumber:             warehouse.BatchNumber,
152
 			BatchNumber:             warehouse.BatchNumber,
137
-			Price:                   baseInfo.RetailPrice,
153
+			Price:                   drug_price,
138
 			CountUnit:               advice.PrescribingNumberUnit,
154
 			CountUnit:               advice.PrescribingNumberUnit,
139
-			RetailPrice:             baseInfo.RetailPrice,
155
+			RetailPrice:             drug_price,
140
 			ProductDate:             warehouse.ProductDate,
156
 			ProductDate:             warehouse.ProductDate,
141
 			ExpiryDate:              warehouse.ExpiryDate,
157
 			ExpiryDate:              warehouse.ExpiryDate,
142
 			PatientId:               advice.PatientId,
158
 			PatientId:               advice.PatientId,
154
 			ProductDate:             warehouse.ProductDate,
170
 			ProductDate:             warehouse.ProductDate,
155
 			ExpireDate:              warehouse.ExpiryDate,
171
 			ExpireDate:              warehouse.ExpiryDate,
156
 			Count:                   count,
172
 			Count:                   count,
157
-			Price:                   baseInfo.RetailPrice,
173
+			Price:                   drug_price,
158
 			Status:                  1,
174
 			Status:                  1,
159
 			Ctime:                   time.Now().Unix(),
175
 			Ctime:                   time.Now().Unix(),
160
 			UserOrgId:               orgID,
176
 			UserOrgId:               orgID,
255
 			DrugId:                  advice.DrugId,
271
 			DrugId:                  advice.DrugId,
256
 			Number:                  warehouse.Number,
272
 			Number:                  warehouse.Number,
257
 			BatchNumber:             warehouse.BatchNumber,
273
 			BatchNumber:             warehouse.BatchNumber,
258
-			Price:                   baseInfo.RetailPrice,
274
+			Price:                   drug_price,
259
 			CountUnit:               advice.PrescribingNumberUnit,
275
 			CountUnit:               advice.PrescribingNumberUnit,
260
 			ProductDate:             warehouse.ProductDate,
276
 			ProductDate:             warehouse.ProductDate,
261
 			ExpiryDate:              warehouse.ExpiryDate,
277
 			ExpiryDate:              warehouse.ExpiryDate,
310
 			ProductDate:             warehouse.ProductDate,
326
 			ProductDate:             warehouse.ProductDate,
311
 			ExpireDate:              warehouse.ExpiryDate,
327
 			ExpireDate:              warehouse.ExpiryDate,
312
 			Count:                   stock_number,
328
 			Count:                   stock_number,
313
-			Price:                   baseInfo.RetailPrice,
329
+			Price:                   drug_price,
314
 			Status:                  1,
330
 			Status:                  1,
315
 			Ctime:                   time.Now().Unix(),
331
 			Ctime:                   time.Now().Unix(),
316
 			UserOrgId:               orgID,
332
 			UserOrgId:               orgID,
417
 		deliver_number = count
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
 			DrugId:                  advice.DrugId,
480
 			DrugId:                  advice.DrugId,
452
 			Number:                  warehouse.Number,
481
 			Number:                  warehouse.Number,
453
 			BatchNumber:             warehouse.BatchNumber,
482
 			BatchNumber:             warehouse.BatchNumber,
454
-			Price:                   baseInfo.RetailPrice,
483
+			Price:                   min_price,
455
 			CountUnit:               baseInfo.MaxUnit,
484
 			CountUnit:               baseInfo.MaxUnit,
456
-			RetailPrice:             baseInfo.RetailPrice,
485
+			RetailPrice:             min_price,
457
 			ProductDate:             warehouse.ProductDate,
486
 			ProductDate:             warehouse.ProductDate,
458
 			ExpiryDate:              warehouse.ExpiryDate,
487
 			ExpiryDate:              warehouse.ExpiryDate,
459
 			PatientId:               advice.PatientId,
488
 			PatientId:               advice.PatientId,
471
 			ProductDate:             warehouse.ProductDate,
500
 			ProductDate:             warehouse.ProductDate,
472
 			ExpireDate:              warehouse.ExpiryDate,
501
 			ExpireDate:              warehouse.ExpiryDate,
473
 			Count:                   count,
502
 			Count:                   count,
474
-			Price:                   baseInfo.RetailPrice,
503
+			Price:                   min_price,
475
 			Status:                  1,
504
 			Status:                  1,
476
 			Ctime:                   time.Now().Unix(),
505
 			Ctime:                   time.Now().Unix(),
477
 			UserOrgId:               orgID,
506
 			UserOrgId:               orgID,
569
 			DrugId:                  advice.DrugId,
598
 			DrugId:                  advice.DrugId,
570
 			Number:                  warehouse.Number,
599
 			Number:                  warehouse.Number,
571
 			BatchNumber:             warehouse.BatchNumber,
600
 			BatchNumber:             warehouse.BatchNumber,
572
-			Price:                   baseInfo.RetailPrice,
573
-			RetailPrice:             baseInfo.RetailPrice,
601
+			Price:                   min_price,
602
+			RetailPrice:             min_price,
574
 			ProductDate:             warehouse.ProductDate,
603
 			ProductDate:             warehouse.ProductDate,
575
 			ExpiryDate:              warehouse.ExpiryDate,
604
 			ExpiryDate:              warehouse.ExpiryDate,
576
 			PatientId:               advice.PatientId,
605
 			PatientId:               advice.PatientId,
589
 			ProductDate:             warehouse.ProductDate,
618
 			ProductDate:             warehouse.ProductDate,
590
 			ExpireDate:              warehouse.ExpiryDate,
619
 			ExpireDate:              warehouse.ExpiryDate,
591
 			Count:                   stock_number,
620
 			Count:                   stock_number,
592
-			Price:                   baseInfo.RetailPrice,
621
+			Price:                   min_price,
593
 			Status:                  1,
622
 			Status:                  1,
594
 			Ctime:                   time.Now().Unix(),
623
 			Ctime:                   time.Now().Unix(),
595
 			UserOrgId:               orgID,
624
 			UserOrgId:               orgID,