XMLWAN 3 gadus atpakaļ
vecāks
revīzija
16d2d52dbf

+ 44 - 10
controllers/gobal_config_api_controller.go Parādīt failu

@@ -99,6 +99,8 @@ func GobalConfigRegistRouters() {
99 99
 	beego.Router("/api/drug/getdrugcountlist", &GobalConfigApiController{}, "Get:GetDrugCountList")
100 100
 	beego.Router("/api/drug/getsingleorderdetail", &GobalConfigApiController{}, "Get:GetSingleOrderDetail")
101 101
 	beego.Router("/api/drug/getautodrugdetial", &GobalConfigApiController{}, "Get:GetAutoDrugDetail")
102
+	beego.Router("/api/drug/getdrugorderinprint", &GobalConfigApiController{}, "Get:GetDrugOrderInPrint")
103
+	beego.Router("/api/drug/getdrugoutorderdetailprint", &GobalConfigApiController{}, "Get:GetDrugOutOrderPrint")
102 104
 }
103 105
 
104 106
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1938,18 +1940,18 @@ func (c *GobalConfigApiController) GetDrugOutStockFlow() {
1938 1940
 		endTime = theTime.Unix()
1939 1941
 	}
1940 1942
 	orgId := c.GetAdminUserInfo().CurrentOrgId
1941
-	if stock_type >= 0 && stock_type != 3 {
1942
-		outList, total, err := service.GetDrugStockOutFlow(drug_id, startTime, endTime, page, limit, orgId, stock_type)
1943 1943
 
1944
-		if err != nil {
1945
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1946
-			return
1947
-		}
1948
-		c.ServeSuccessJSON(map[string]interface{}{
1949
-			"outList": outList,
1950
-			"total":   total,
1951
-		})
1944
+	outList, total, err := service.GetDrugStockOutFlow(drug_id, startTime, endTime, page, limit, orgId, stock_type)
1945
+
1946
+	if err != nil {
1947
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1948
+		return
1952 1949
 	}
1950
+	c.ServeSuccessJSON(map[string]interface{}{
1951
+		"outList": outList,
1952
+		"total":   total,
1953
+	})
1954
+
1953 1955
 }
1954 1956
 
1955 1957
 func (c *GobalConfigApiController) GetBatchOrderDetail() {
@@ -2045,3 +2047,35 @@ func (c *GobalConfigApiController) GetAutoDrugDetail() {
2045 2047
 		"total": total,
2046 2048
 	})
2047 2049
 }
2050
+
2051
+func (c *GobalConfigApiController) GetDrugOrderInPrint() {
2052
+
2053
+	id := c.GetString("id")
2054
+	ids := strings.Split(id, ",")
2055
+	admin := c.GetAdminUserInfo()
2056
+
2057
+	info, _ := service.FindDrugWarehousingByIdOne(ids, admin.CurrentOrgId)
2058
+	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
2059
+
2060
+	warehousingInfo, _ := service.FindDrugWarehousingInfoByIdOne(ids, admin.CurrentOrgId)
2061
+
2062
+	c.ServeSuccessJSON(map[string]interface{}{
2063
+		"info":             info,
2064
+		"warehousing":      warehousingInfo,
2065
+		"manufacturerList": manufacturerList,
2066
+	})
2067
+}
2068
+
2069
+func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
2070
+	id := c.GetString("id")
2071
+	ids := strings.Split(id, ",")
2072
+	admin := c.GetAdminUserInfo()
2073
+	info, _ := service.FindeDrugWarehouseOutOrder(ids, admin.CurrentOrgId)
2074
+	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
2075
+	warehousing, _ := service.FindeDrugWarehouseOutDetail(ids, admin.CurrentOrgId)
2076
+	c.ServeSuccessJSON(map[string]interface{}{
2077
+		"info":             info,
2078
+		"warehousing":      warehousing,
2079
+		"manufacturerList": manufacturerList,
2080
+	})
2081
+}

+ 58 - 15
controllers/stock_in_api_controller.go Parādīt failu

@@ -90,6 +90,7 @@ func StockManagerApiRegistRouters() {
90 90
 	beego.Router("/api/good/getorderdetaibyid", &StockManagerApiController{}, "Get:GetOrderDetailById")
91 91
 	beego.Router("/api/good/getsingleoutorderdetail", &StockManagerApiController{}, "Get:GetSingleOutOrderDetail")
92 92
 	beego.Router("/api/stock/getexportstocklist", &StockManagerApiController{}, "Get:GetExprotStockList")
93
+	beego.Router("/api/stock/getoutexprotlist", &StockManagerApiController{}, "Get:GetOutExprotList")
93 94
 
94 95
 }
95 96
 
@@ -445,25 +446,25 @@ func (c *StockManagerApiController) GetWarehouseList() {
445 446
 	}
446 447
 }
447 448
 func (c *StockManagerApiController) GetWarehouseInfoList() {
448
-	id, _ := c.GetInt64("id", 0)
449
+	//id, _ := c.GetInt64("id", 0)
449 450
 
450
-	if id <= 0 {
451
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
452
-		return
453
-	}
451
+	id := c.GetString("id")
454 452
 
455
-	warehousing, err := service.FindWarehousingById(id)
453
+	idArray := strings.Split(id, ",")
454
+	warehousing, err := service.FindWarehousingByIdOne(idArray)
456 455
 
457 456
 	if err != nil {
458 457
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
459 458
 		return
460 459
 	}
461 460
 
462
-	if warehousing.ID <= 0 {
463
-		return
461
+	var ids []int64
462
+
463
+	for _, item := range warehousing {
464
+		ids = append(ids, item.ID)
464 465
 	}
465 466
 
466
-	warehousingInfo, err := service.FindWarehousingInfoById(id)
467
+	warehousingInfo, err := service.FindWarehousingInfoByIdOne(ids)
467 468
 	if err == nil {
468 469
 		c.ServeSuccessJSON(map[string]interface{}{
469 470
 			"info":        warehousingInfo,
@@ -3800,11 +3801,15 @@ func (this *StockManagerApiController) GetStockDrugCount() {
3800 3801
 
3801 3802
 func (this *StockManagerApiController) GetOrderDetialByOrderId() {
3802 3803
 
3803
-	id, _ := this.GetInt64("id")
3804
+	//id, _ := this.GetInt64("id")
3805
+	ids := this.GetString("id")
3806
+	idsArray := strings.Split(ids, ",")
3804 3807
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3805
-	list, _ := service.GetOrderDetialByOrderId(id, orgId)
3808
+	order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
3809
+	list, _ := service.GetOrderDetialByOrderIdOne(idsArray, orgId)
3806 3810
 	this.ServeSuccessJSON(map[string]interface{}{
3807
-		"list": list,
3811
+		"order": order,
3812
+		"list":  list,
3808 3813
 	})
3809 3814
 }
3810 3815
 
@@ -3844,14 +3849,14 @@ func (this *StockManagerApiController) GetSingleOutOrderDetail() {
3844 3849
 
3845 3850
 func (this *StockManagerApiController) GetExprotStockList() {
3846 3851
 
3847
-	id, _ := this.GetInt64("id")
3848 3852
 	adminUserInfo := this.GetAdminUserInfo()
3849 3853
 	orgId := adminUserInfo.CurrentOrgId
3850 3854
 	timeLayout := "2006-01-02"
3851 3855
 	loc, _ := time.LoadLocation("Local")
3852 3856
 	start_time := this.GetString("start_time")
3853 3857
 	end_time := this.GetString("end_time")
3854
-
3858
+	idArray := this.GetString("id")
3859
+	ids := strings.Split(idArray, ",")
3855 3860
 	var startTime int64
3856 3861
 	if len(start_time) > 0 {
3857 3862
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -3872,8 +3877,46 @@ func (this *StockManagerApiController) GetExprotStockList() {
3872 3877
 		endTime = theTime.Unix()
3873 3878
 	}
3874 3879
 
3875
-	list, _ := service.GetExprotStockList(orgId, id, startTime, endTime)
3880
+	list, _ := service.GetExprotStockList(orgId, ids, startTime, endTime)
3876 3881
 	this.ServeSuccessJSON(map[string]interface{}{
3877 3882
 		"list": list,
3878 3883
 	})
3879 3884
 }
3885
+
3886
+func (this *StockManagerApiController) GetOutExprotList() {
3887
+
3888
+	adminUserInfo := this.GetAdminUserInfo()
3889
+	orgId := adminUserInfo.CurrentOrgId
3890
+	timeLayout := "2006-01-02"
3891
+	loc, _ := time.LoadLocation("Local")
3892
+	start_time := this.GetString("start_time")
3893
+	end_time := this.GetString("end_time")
3894
+	idArray := this.GetString("id")
3895
+	ids := strings.Split(idArray, ",")
3896
+	fmt.Println("ids2222222222", ids)
3897
+	var startTime int64
3898
+	if len(start_time) > 0 {
3899
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3900
+		if err != nil {
3901
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3902
+			return
3903
+		}
3904
+		startTime = theTime.Unix()
3905
+	}
3906
+	var endTime int64
3907
+	if len(end_time) > 0 {
3908
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3909
+		if err != nil {
3910
+			utils.ErrorLog(err.Error())
3911
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3912
+			return
3913
+		}
3914
+		endTime = theTime.Unix()
3915
+	}
3916
+	list, _ := service.GetOutExprotList(orgId, ids, startTime, endTime)
3917
+	outCount, _ := service.GetOutStockTotalCountOne(startTime, endTime, orgId)
3918
+	this.ServeSuccessJSON(map[string]interface{}{
3919
+		"list":  list,
3920
+		"count": outCount,
3921
+	})
3922
+}

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

@@ -582,9 +582,9 @@ func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64
582 582
 		db = db.Where("x.is_sys = 0")
583 583
 	}
584 584
 	if stocktype == 2 {
585
-		db = db.Where("x,is_sys = 1")
585
+		db = db.Where("x.is_sys = 1")
586 586
 	}
587
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.warehouse_info_id,x.ctime").Offset(offset).Count(&total).Order("x.ctime desc").Scan(&list).Error
587
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.warehouse_info_id,x.ctime").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
588 588
 	return list, total, err
589 589
 }
590 590
 

+ 125 - 3
service/stock_service.go Parādīt failu

@@ -666,7 +666,11 @@ func FindAllDrugWarehousingList(orgId int64, page int64, limit int64, startTime
666 666
 func FindWarehousingInfoById(id int64) (list []*models.WarehousingInfo, err error) {
667 667
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? AND status = 1", id).Preload("GoodInfo").Find(&list).Error
668 668
 	return list, err
669
+}
669 670
 
671
+func FindWarehousingInfoByIdOne(id []int64) (list []*models.WarehousingInfo, err error) {
672
+	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_id in(?) AND status = 1", id).Preload("GoodInfo").Find(&list).Error
673
+	return list, err
670 674
 }
671 675
 
672 676
 func FindDrugWarehousingInfoById(id int64, org_id int64) (list []*VMDrugWarehouseInfo, err error) {
@@ -674,18 +678,54 @@ func FindDrugWarehousingInfoById(id int64, org_id int64) (list []*VMDrugWarehous
674 678
 	return list, err
675 679
 }
676 680
 
681
+func FindDrugWarehousingInfoByIdOne(id []string, org_id int64) (list []*models.StDrugWarehouseInfo, err error) {
682
+
683
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
684
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
685
+	fmt.Println(table)
686
+	if len(id) > 0 {
687
+		db = db.Where("x.warehousing_id in(?)", id)
688
+	}
689
+	if org_id > 0 {
690
+		db = db.Where("x.org_id = ?", org_id)
691
+	}
692
+	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.remark,x.batch_number,t.manufacturer,t.dealer,t.drug_name,t.last_price,t.dose_unit,t.dose,t.min_number,t.min_unit,t.max_unit,t.drug_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&list).Error
693
+	return list, err
694
+}
695
+
677 696
 func FindWarehousingById(id int64) (warehousing models.Warehousing, err error) {
678 697
 	err = readDb.Model(&models.Warehousing{}).Where("id = ? AND status = 1 ", id).First(&warehousing).Error
679 698
 	return warehousing, err
680 699
 
681 700
 }
682 701
 
702
+func FindWarehousingByIdOne(id []string) (warehousing []*models.Warehousing, err error) {
703
+	err = readDb.Model(&models.Warehousing{}).Where("id in(?) and status = 1", id).Find(&warehousing).Error
704
+	//err = readDb.Model(&models.Warehousing{}).Where("id = ? AND status = 1 ", id).First(&warehousing).Error
705
+	return warehousing, err
706
+
707
+}
708
+
683 709
 func FindDrugWarehousingById(id int64, org_id int64) (warehousing VMDrugWarehouse, err error) {
684 710
 	err = readDb.Model(&VMDrugWarehouse{}).Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Where("id = ? AND status = 1 ", id).First(&warehousing).Error
685 711
 	return warehousing, err
686 712
 
687 713
 }
688 714
 
715
+func FindDrugWarehousingByIdOne(id []string, org_id int64) (warehousing []*models.DrugWarehouse, err error) {
716
+
717
+	db := XTReadDB().Table("xt_drug_warehouse as x").Where("x.status = 1")
718
+	if len(id) > 0 {
719
+		db = db.Where("x.id in(?)", id)
720
+	}
721
+	if org_id > 0 {
722
+		db = db.Where("x.org_id = ?", org_id)
723
+	}
724
+
725
+	err = db.Select("x.id,x.warehousing_order,x.operation_time,x.org_id,x.creater,x.ctime,x.modifier,x.warehousing_time").Find(&warehousing).Error
726
+	return warehousing, err
727
+}
728
+
689 729
 //func FindDrugWarehousingById(id int64) (warehousing models.DrugWarehouse, err error) {
690 730
 //	err = readDb.Model(&models.DrugWarehouse{}).Where("id = ? AND status = 1 ", id).First(&warehousing).Error
691 731
 //	return warehousing, err
@@ -2934,6 +2974,34 @@ func GetOrderDetialByOrderId(id int64, orgid int64) (out []*models.WarehouseOutI
2934 2974
 	return out, err
2935 2975
 }
2936 2976
 
2977
+func GetWarehouseOutOrder(id []string, orgid int64) (out []*models.WarehouseOut, err error) {
2978
+
2979
+	db := XTReadDB().Table("xt_warehouse_out as x").Where("x.status = 1")
2980
+	if len(id) > 0 {
2981
+		db = db.Where("x.id in(?)", id)
2982
+	}
2983
+	if orgid > 0 {
2984
+		db = db.Where("x.org_id= ?", orgid)
2985
+	}
2986
+	err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.dealer,x.manufacturer,x.type").Find(&out).Error
2987
+	return out, err
2988
+}
2989
+
2990
+func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.WarehouseOutInfoOne, err error) {
2991
+
2992
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
2993
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
2994
+	fmt.Println(table)
2995
+	if len(id) > 0 {
2996
+		db = db.Where("x.warehouse_out_id in (?)", id)
2997
+	}
2998
+	if orgid > 0 {
2999
+		db = db.Where("x.org_id = ?", orgid)
3000
+	}
3001
+	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,t.manufacturer,x.is_sys,x.sys_record_time,x.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").Order("x.ctime desc").Scan(&out).Error
3002
+	return out, err
3003
+}
3004
+
2937 3005
 func FindUserDetailByIdOne(good_id int64, record_time int64, org_id int64) (user []*models.AutomaticReduceDetail, err error, total int64) {
2938 3006
 	db := readDb.Model(&models.AutomaticReduceDetail{})
2939 3007
 	db = db.Preload("GoodInfo", "org_id = ? AND status = 1", org_id)
@@ -2952,7 +3020,7 @@ func GetGoodInformationByGoodId(good_id int64) (models.GoodInfo, error) {
2952 3020
 	return info, err
2953 3021
 }
2954 3022
 
2955
-func GetExprotStockList(orgid int64, orderid int64, startime int64, endtime int64) (info []*models.StWarehousingInfo, err error) {
3023
+func GetExprotStockList(orgid int64, orderid []string, startime int64, endtime int64) (info []*models.StWarehousingInfo, err error) {
2956 3024
 
2957 3025
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
2958 3026
 
@@ -2962,8 +3030,8 @@ func GetExprotStockList(orgid int64, orderid int64, startime int64, endtime int6
2962 3030
 	if orgid > 0 {
2963 3031
 		db = db.Where("x.org_id = ?", orgid)
2964 3032
 	}
2965
-	if orderid > 0 {
2966
-		db = db.Where("x.warehousing_id = ?", orgid)
3033
+	if len(orderid) > 0 {
3034
+		db = db.Where("x.warehousing_id in(?)", orderid)
2967 3035
 	}
2968 3036
 	if startime > 0 {
2969 3037
 		db = db.Where("x.ctime>=?", startime)
@@ -2994,3 +3062,57 @@ func GetDrugWarehouOrderInfo(startime int64, endtime int64, orgid int64) (info [
2994 3062
 	err = db.Select("x.drug_id,x.count,x.count_unit,t.max_unit,t.min_unit,t.min_number").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&info).Error
2995 3063
 	return info, err
2996 3064
 }
3065
+
3066
+func GetOutExprotList(orgid int64, ids []string, startime int64, endtime int64) (out []*models.WarehouseOutInfoOne, err error) {
3067
+
3068
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status =1 ")
3069
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
3070
+	fmt.Println(table)
3071
+	if orgid > 0 {
3072
+		db = db.Where("x.org_id = ?", orgid)
3073
+	}
3074
+
3075
+	if len(ids) > 0 {
3076
+		db = db.Where("x.warehouse_out_id in (?)", ids)
3077
+	}
3078
+	if startime > 0 {
3079
+		db = db.Where("x.ctime>=?", startime)
3080
+	}
3081
+	if endtime > 0 {
3082
+		db = db.Where("x.ctime<=?", endtime)
3083
+	}
3084
+
3085
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,x.good_type_id,x.warehousing_out_target,Sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.number,t.good_name,t.specification_name,t.min_number,t.packing_price,t.min_unit,t.packing_unit,t.manufacturer,t.dealer").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
3086
+	return out, err
3087
+
3088
+}
3089
+
3090
+func FindeDrugWarehouseOutOrder(ids []string, orgid int64) (info []*models.DrugWarehouseOut, err error) {
3091
+
3092
+	db := XTReadDB().Table("xt_drug_warehouse_out as x").Where("x.status = 1")
3093
+	if len(ids) > 0 {
3094
+		db = db.Where("x.id in(?)", ids)
3095
+	}
3096
+	if orgid > 0 {
3097
+		db = db.Where("x.org_id = ?", orgid)
3098
+	}
3099
+
3100
+	err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.is_sys").Scan(&info).Error
3101
+	return info, err
3102
+
3103
+}
3104
+
3105
+func FindeDrugWarehouseOutDetail(ids []string, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
3106
+
3107
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status =1 ")
3108
+	table := XTReadDB().Table("x.base_drug as t").Where("t.status = 1")
3109
+	fmt.Println(table)
3110
+	if len(ids) > 0 {
3111
+		db = db.Where("x.warehouse_out_id in(?)", ids)
3112
+	}
3113
+	if orgid > 0 {
3114
+		db = db.Where("x.org_id = ?", orgid)
3115
+	}
3116
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.product_date,x.expiry_date,x.number,x.batch_number,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_name").Joins("left join xt_base_drug as t on t.id =x.drug_id").Scan(&info).Error
3117
+	return info, err
3118
+}