Przeglądaj źródła

11月8日库存管理

XMLWAN 3 lat temu
rodzic
commit
414d7b48a3

+ 53 - 7
controllers/supply_order_api_contorller.go Wyświetl plik

@@ -25,6 +25,8 @@ func SupplyOrderApiRegistRouters() {
25 25
 	beego.Router("/api/supply/getallsupply", &SupplyOrderApiController{}, "get:GetAllSupply")
26 26
 	beego.Router("/api/supply/getallpurchaseorderlist", &SupplyOrderApiController{}, "get:GetAllPurchaseOrderList")
27 27
 	beego.Router("/api/supply/updatepurchaseorder", &SupplyOrderApiController{}, "Post:UpdatePurchaseOrder")
28
+	beego.Router("/api/supply/checkpurchaseorder", &SupplyOrderApiController{}, "get:UpdateSupplyWaresing")
29
+	beego.Router("/api/supply/getpurchaseorderdetail", &SupplyOrderApiController{}, "get:GetPurchaseOrderDetail")
28 30
 }
29 31
 
30 32
 func (this *SupplyOrderApiController) GetInitOrder() {
@@ -130,12 +132,12 @@ func (this *SupplyOrderApiController) SavePurchaseOrder() {
130 132
 			for _, item := range thisStockIn {
131 133
 				items := item.(map[string]interface{})
132 134
 
133
-				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
134
-					utils.ErrorLog("id")
135
+				if items["project_id"] == nil || reflect.TypeOf(items["project_id"]).String() != "float64" {
136
+					utils.ErrorLog("project_id")
135 137
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
136 138
 					return
137 139
 				}
138
-				id := int64(items["id"].(float64))
140
+				project_id := int64(items["project_id"].(float64))
139 141
 
140 142
 				if items["supply_count"] == nil || reflect.TypeOf(items["supply_count"]).String() != "float64" {
141 143
 					utils.ErrorLog("supply_count")
@@ -236,7 +238,7 @@ func (this *SupplyOrderApiController) SavePurchaseOrder() {
236 238
 					Status:                  1,
237 239
 					Mtime:                   0,
238 240
 					WarehousingId:           warehouseInfo.ID,
239
-					ProjectId:               id,
241
+					ProjectId:               project_id,
240 242
 					SupplyLicenseNumber:     supply_license_number,
241 243
 					SupplyType:              supply_type,
242 244
 					SupplySpecificationName: supply_specification_name,
@@ -438,12 +440,12 @@ func (this *SupplyOrderApiController) UpdatePurchaseOrder() {
438 440
 				supply_total_price := items["supply_total_price"].(string)
439 441
 
440 442
 				supply_total_price_float, _ := strconv.ParseFloat(supply_total_price, 64)
441
-				if items["is_source"] == nil || reflect.TypeOf(items["is_source"]).String() != "float64" {
442
-					utils.ErrorLog("is_source")
443
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
444
+					utils.ErrorLog("type")
443 445
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
444 446
 					return
445 447
 				}
446
-				is_source := int64(items["is_source"].(float64))
448
+				is_source := int64(items["type"].(float64))
447 449
 
448 450
 				if items["supply_type"] == nil || reflect.TypeOf(items["supply_type"]).String() != "string" {
449 451
 					utils.ErrorLog("supply_type")
@@ -553,3 +555,47 @@ func (this *SupplyOrderApiController) UpdatePurchaseOrder() {
553 555
 
554 556
 	}
555 557
 }
558
+
559
+func (this *SupplyOrderApiController) UpdateSupplyWaresing() {
560
+
561
+	id, _ := this.GetInt64("id")
562
+	recordDateStr := time.Now().Format("2006-01-02")
563
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
564
+
565
+	record_date := recordDate.Unix()
566
+	checker := this.GetAdminUserInfo().AdminUser.Id
567
+	info := models.SupplierWarehouseInfo{
568
+		Mtime:     time.Now().Unix(),
569
+		Status:    1,
570
+		IsCheck:   1,
571
+		Checker:   checker,
572
+		CheckTime: record_date,
573
+	}
574
+	parseDateErr := service.UpdateSupplyWaresing(id, info)
575
+	if parseDateErr == nil {
576
+		this.ServeSuccessJSON(map[string]interface{}{
577
+			"info": info,
578
+		})
579
+	} else {
580
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
581
+	}
582
+}
583
+
584
+func (this *SupplyOrderApiController) GetPurchaseOrderDetail() {
585
+
586
+	id, _ := this.GetInt64("id")
587
+	info, _ := service.GetPurchaseOrderDetail(id)
588
+	//查询
589
+	orderInfo, err := service.GetSupplyWarehousingOrderInfo(id)
590
+	orgId := this.GetAdminUserInfo().CurrentOrgId
591
+	supplyList, _ := service.GetSupplierList(orgId)
592
+	if err == nil {
593
+		this.ServeSuccessJSON(map[string]interface{}{
594
+			"info":       info,
595
+			"orderInfo":  orderInfo,
596
+			"supplyList": supplyList,
597
+		})
598
+	} else {
599
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
600
+	}
601
+}

+ 1 - 1
service/gobal_config_service.go Wyświetl plik

@@ -809,7 +809,7 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
809 809
 		db = db.Where("x.warehouse_out_id = ?", id)
810 810
 	}
811 811
 
812
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
812
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price as total_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,t.retail_price ,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
813 813
 	return info, err
814 814
 }
815 815
 

+ 19 - 3
service/supply_service.go Wyświetl plik

@@ -1,6 +1,9 @@
1 1
 package service
2 2
 
3
-import "XT_New/models"
3
+import (
4
+	"XT_New/models"
5
+	"time"
6
+)
4 7
 
5 8
 func GetSupplyDrugList(orgid int64) (drug []*models.SpBaseDrug, err error) {
6 9
 
@@ -90,12 +93,25 @@ func GetSupplyWarehousingOrderInfo(id int64) (order []*models.SupplierWarehousin
90 93
 
91 94
 func ModefySupplyWarehouseInfo(id int64, info models.SupplierWarehouseInfo) error {
92 95
 
93
-	err := XTWriteDB().Where("id = ? and status = 1", id).Updates(map[string]interface{}{"rate_of_concession": info.RateOfConcession, "discount_amount": info.DiscountAmount, "document_date": info.DocumentDate, "delivery_date": info.DeliveryDate, "supplier_id": info.SupplierId}).Error
96
+	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"rate_of_concession": info.RateOfConcession, "discount_amount": info.DiscountAmount, "document_date": info.DocumentDate, "delivery_date": info.DeliveryDate, "supplier_id": info.SupplierId}).Error
94 97
 	return err
95 98
 }
96 99
 
97 100
 func ModifySupplyWarehouseOrder(order *models.SupplierWarehousingInfoOrder) error {
98 101
 
99
-	err := XTWriteDB().Model(&order).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{}).Updates(map[string]interface{}{"is_source": order.IsSource, "count": order.Count, "price": order.Price, "amount": order.Amount, "remark": order.Remark, "project_id": order.ProjectId, "supply_license_number": order.SupplyLicenseNumber, "supply_type": order.SupplyType, "supply_specification_name": order.SupplySpecificationName, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name}).Error
102
+	err := XTWriteDB().Model(&models.SupplierWarehousingInfoOrder{}).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{}).Updates(map[string]interface{}{"is_source": order.IsSource, "count": order.Count, "price": order.Price, "amount": order.Amount, "remark": order.Remark, "project_id": order.ProjectId, "supply_license_number": order.SupplyLicenseNumber, "supply_type": order.SupplyType, "supply_specification_name": order.SupplySpecificationName, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name}).Error
100 103
 	return err
101 104
 }
105
+
106
+func UpdateSupplyWaresing(id int64, info models.SupplierWarehouseInfo) error {
107
+
108
+	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"is_check": info.IsCheck, "checker": info.Checker, "check_time": info.CheckTime, "mtime": time.Now().Unix()}).Error
109
+	return err
110
+}
111
+
112
+func GetPurchaseOrderDetail(id int64) (models.SupplierWarehouseInfo, error) {
113
+
114
+	info := models.SupplierWarehouseInfo{}
115
+	err := XTReadDB().Model(&info).Where("id =? and status =1", id).Find(&info).Error
116
+	return info, err
117
+}