瀏覽代碼

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 1 年之前
父節點
當前提交
9182095d15

+ 9 - 0
controllers/drug_stock_api_contorller.go 查看文件

@@ -1408,12 +1408,15 @@ func (c *StockDrugApiController) GetDrugWarehouseOutList() {
1408 1408
 	warehouseOutList, total, err := service.FindAllDrugWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id, way_type, check_type)
1409 1409
 
1410 1410
 	houseList, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
1411
+
1412
+	patients, _ := service.GetAllpatient(adminUserInfo.CurrentOrgId)
1411 1413
 	fmt.Println(err)
1412 1414
 	if err == nil {
1413 1415
 		c.ServeSuccessJSON(map[string]interface{}{
1414 1416
 			"list":      warehouseOutList,
1415 1417
 			"total":     total,
1416 1418
 			"houseList": houseList,
1419
+			"patients":  patients,
1417 1420
 		})
1418 1421
 	} else {
1419 1422
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -1670,6 +1673,8 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1670 1673
 
1671 1674
 				admin_user_id := int64(items["admin_user_id"].(float64))
1672 1675
 
1676
+				patient_id := int64(items["patient_id"].(float64))
1677
+
1673 1678
 				//if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
1674 1679
 				//  utils.ErrorLog("last_price")
1675 1680
 				//  c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1708,6 +1713,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1708 1713
 						StorehouseId:            storehouse_id,
1709 1714
 						AdminUserId:             admin_user_id,
1710 1715
 						StockCount:              stock_count,
1716
+						PatientId:               patient_id,
1711 1717
 					}
1712 1718
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1713 1719
 
@@ -1737,6 +1743,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1737 1743
 						StorehouseId:            storehouse_id,
1738 1744
 						AdminUserId:             admin_user_id,
1739 1745
 						StockCount:              stock_count,
1746
+						PatientId:               patient_id,
1740 1747
 					}
1741 1748
 
1742 1749
 					drugFlow = append(drugFlow, drugflow)
@@ -1785,6 +1792,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1785 1792
 						StorehouseId:            storehouse_id,
1786 1793
 						AdminUserId:             admin_user_id,
1787 1794
 						StockCount:              stock_count,
1795
+						PatientId:               patient_id,
1788 1796
 					}
1789 1797
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1790 1798
 
@@ -1814,6 +1822,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1814 1822
 						StorehouseId:            storehouse_id,
1815 1823
 						AdminUserId:             admin_user_id,
1816 1824
 						StockCount:              stock_count,
1825
+						PatientId:               patient_id,
1817 1826
 					}
1818 1827
 
1819 1828
 					drugFlow = append(drugFlow, drugflow)

+ 10 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -5399,6 +5399,11 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
5399 5399
 			advice.DrugNameId = drug_name_id
5400 5400
 		}
5401 5401
 
5402
+		if adviceNameM["remark"] != nil && reflect.TypeOf(adviceNameM["remark"]).String() == "string" {
5403
+			remark, _ := adviceNameM["remark"].(string)
5404
+			advice.Remark = remark
5405
+		}
5406
+
5402 5407
 		if adviceNameM["groupno"] != nil || reflect.TypeOf(adviceNameM["groupno"]).String() == "float64" {
5403 5408
 			groupno := int64(adviceNameM["groupno"].(float64))
5404 5409
 			advice.GroupNo = groupno
@@ -5485,6 +5490,11 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
5485 5490
 						advice.GroupNo = groupno
5486 5491
 					}
5487 5492
 
5493
+					if childMap["remark"] != nil && reflect.TypeOf(childMap["remark"]).String() == "string" {
5494
+						remark, _ := childMap["remark"].(string)
5495
+						child.Remark = remark
5496
+					}
5497
+
5488 5498
 					child.DeliveryWay = advice.DeliveryWay
5489 5499
 					child.ExecutionFrequency = advice.ExecutionFrequency
5490 5500
 					advice.Children = append(advice.Children, &child)

+ 57 - 0
controllers/stock_in_api_controller.go 查看文件

@@ -157,6 +157,8 @@ func StockManagerApiRegistRouters() {
157 157
 	beego.Router("/api/stock/getnewgoodwarehouseinfo", &StockManagerApiController{}, "Get:GetNewGoodWarehouseInfo")
158 158
 	beego.Router("/api/stock/getnewwarehouseoutinfolist", &StockManagerApiController{}, "Get:GetNewWarehouseOutInfoList")
159 159
 
160
+	beego.Router("/api/stock/getstockfloworderlist", &StockManagerApiController{}, "Get:GetStockFlowOrderList")
161
+
160 162
 }
161 163
 func (c *StockManagerApiController) HandleRefundStock() {
162 164
 	order_id, _ := c.GetInt64("order_id", 0)
@@ -1490,12 +1492,15 @@ func (c *StockManagerApiController) GetWarehouseOutList() {
1490 1492
 	}
1491 1493
 	warehouseOutList, total, err := service.FindAllWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id, way_type, check_type)
1492 1494
 	houselist, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
1495
+	patients, _ := service.GetAllpatient(adminUserInfo.CurrentOrgId)
1493 1496
 	fmt.Println(err)
1497
+
1494 1498
 	if err == nil {
1495 1499
 		c.ServeSuccessJSON(map[string]interface{}{
1496 1500
 			"list":      warehouseOutList,
1497 1501
 			"total":     total,
1498 1502
 			"houselist": houselist,
1503
+			"patients":  patients,
1499 1504
 		})
1500 1505
 	} else {
1501 1506
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -7951,3 +7956,55 @@ func (this *StockManagerApiController) GetNewWarehouseOutInfoList() {
7951 7956
 		"storeHouseList":   storeHouseList,
7952 7957
 	})
7953 7958
 }
7959
+
7960
+func (this *StockManagerApiController) GetStockFlowOrderList() {
7961
+
7962
+	good_id, _ := this.GetInt64("good_id")
7963
+	orgId := this.GetAdminUserInfo().CurrentOrgId
7964
+	list, _ := service.GetStockFlowOrderList(good_id, orgId)
7965
+	fmt.Println("listowowowow", list)
7966
+	for index, _ := range list {
7967
+		fmt.Println("index", index)
7968
+		if list[index].ConsumableType == 3 || list[index].ConsumableType == 2 || list[index].ConsumableType == 11 || list[index].ConsumableType == 12 || list[index].ConsumableType == 15 {
7969
+			var count int64
7970
+			if index == 0 {
7971
+				count = list[index].OverCount - list[index].Count
7972
+				fmt.Println("id", list[index].ID)
7973
+				fmt.Println("woowowow", list[index].OverCount)
7974
+				fmt.Println("wowoowowowoww", list[index].Count)
7975
+				service.UpdateOverCount(list[index+1].ID, count)
7976
+			}
7977
+
7978
+			if index >= 1 {
7979
+				count = list[index-1].OverCount - list[index].Count
7980
+				fmt.Println("id", list[index].ID)
7981
+				fmt.Println("over_count", list[index-1].OverCount)
7982
+				fmt.Println("wowoowowowoww", list[index].Count)
7983
+				service.UpdateOverCount(list[index].ID, count)
7984
+			}
7985
+
7986
+		}
7987
+		if list[index].ConsumableType == 7 || list[index].ConsumableType == 4 || list[index].ConsumableType == 1 || list[index].ConsumableType == 10 || list[index].ConsumableType == 13 {
7988
+
7989
+			if index == 0 {
7990
+				var count int64
7991
+				count = list[index].OverCount + list[index].Count
7992
+				fmt.Println("id=", list[index].ID)
7993
+				fmt.Println("over_count", list[index].OverCount)
7994
+				fmt.Println("count", list[index].Count)
7995
+				service.UpdateOverCount(list[index+1].ID, count)
7996
+			}
7997
+
7998
+			if index >= 1 {
7999
+				var count int64
8000
+				count = list[index-1].OverCount + list[index].Count
8001
+				fmt.Println("id=", list[index].ID)
8002
+				fmt.Println("over_count", list[index-1].OverCount)
8003
+				fmt.Println("count", list[index].Count)
8004
+				service.UpdateOverCount(list[index].ID, count)
8005
+			}
8006
+
8007
+		}
8008
+
8009
+	}
8010
+}

+ 12 - 0
service/secondary_service.go 查看文件

@@ -1149,3 +1149,15 @@ func DeleteSecondOrderInfo(id int64) error {
1149 1149
 	err := XTWriteDB().Model(&models.XtSecondWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"status": 0}).Error
1150 1150
 	return err
1151 1151
 }
1152
+
1153
+func GetStockFlowOrderList(good_id int64, user_org_id int64) (list []*models.VmStockFlow, err error) {
1154
+
1155
+	err = XTReadDB().Where("good_id = ? and user_org_id =? and ctime>=1704038400 and ctime<=1706716799 and status=1", good_id, user_org_id).Order("ctime asc").Find(&list).Error
1156
+	return list, err
1157
+}
1158
+
1159
+func UpdateOverCount(id int64, count int64) (err error) {
1160
+
1161
+	err = XTWriteDB().Model(models.VmStockFlow{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"over_count": count}).Error
1162
+	return err
1163
+}

+ 3 - 3
service/stock_service.go 查看文件

@@ -4304,7 +4304,7 @@ func GetOrderDetialByOrderId(id int64, orgid int64) (out []*models.WarehouseOutI
4304 4304
 	if orgid > 0 {
4305 4305
 		db = db.Where("x.org_id = ?", orgid)
4306 4306
 	}
4307
-	err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,x.supply_cancel_out_id,x.supply_warehouse_id,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.register_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id,x.warehouse_info_id").Order("x.ctime desc").Scan(&out).Error
4307
+	err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.patient_id,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,x.supply_cancel_out_id,x.supply_warehouse_id,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.register_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id,x.warehouse_info_id").Order("x.ctime desc").Scan(&out).Error
4308 4308
 	return out, err
4309 4309
 }
4310 4310
 
@@ -4334,7 +4334,7 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
4334 4334
 		db = db.Where("x.org_id = ?", orgid)
4335 4335
 	}
4336 4336
 
4337
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,x.remark,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price,x.register_number").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4337
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,x.remark,x.patient_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price,x.register_number").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4338 4338
 
4339 4339
 	return out, err
4340 4340
 }
@@ -7693,7 +7693,7 @@ func UpdateDrugWarehouseInfoTwenty(id int64, info *models.DrugWarehouseInfo) err
7693 7693
 
7694 7694
 func UpdatedDrugWarehouseInfo(info *models.DrugWarehouseOutInfo, id int64) error {
7695 7695
 
7696
-	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "count_unit": info.CountUnit, "price": info.Price, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "batch_number": info.BatchNumber, "admin_user_id": info.AdminUserId, "last_price": info.LastPrice, "stock_count": info.StockCount, "storehouse_id": info.StorehouseId}).Error
7696
+	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "count_unit": info.CountUnit, "price": info.Price, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "batch_number": info.BatchNumber, "admin_user_id": info.AdminUserId, "last_price": info.LastPrice, "stock_count": info.StockCount, "storehouse_id": info.StorehouseId, "patient_id": info.PatientId}).Error
7697 7697
 	return err
7698 7698
 }
7699 7699