Bladeren bron

11月8日库存管理

XMLWAN 3 jaren geleden
bovenliggende
commit
414d7b48a3
3 gewijzigde bestanden met toevoegingen van 73 en 11 verwijderingen
  1. 53 7
      controllers/supply_order_api_contorller.go
  2. 1 1
      service/gobal_config_service.go
  3. 19 3
      service/supply_service.go

+ 53 - 7
controllers/supply_order_api_contorller.go Bestand weergeven

25
 	beego.Router("/api/supply/getallsupply", &SupplyOrderApiController{}, "get:GetAllSupply")
25
 	beego.Router("/api/supply/getallsupply", &SupplyOrderApiController{}, "get:GetAllSupply")
26
 	beego.Router("/api/supply/getallpurchaseorderlist", &SupplyOrderApiController{}, "get:GetAllPurchaseOrderList")
26
 	beego.Router("/api/supply/getallpurchaseorderlist", &SupplyOrderApiController{}, "get:GetAllPurchaseOrderList")
27
 	beego.Router("/api/supply/updatepurchaseorder", &SupplyOrderApiController{}, "Post:UpdatePurchaseOrder")
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
 func (this *SupplyOrderApiController) GetInitOrder() {
32
 func (this *SupplyOrderApiController) GetInitOrder() {
130
 			for _, item := range thisStockIn {
132
 			for _, item := range thisStockIn {
131
 				items := item.(map[string]interface{})
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
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
137
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
136
 					return
138
 					return
137
 				}
139
 				}
138
-				id := int64(items["id"].(float64))
140
+				project_id := int64(items["project_id"].(float64))
139
 
141
 
140
 				if items["supply_count"] == nil || reflect.TypeOf(items["supply_count"]).String() != "float64" {
142
 				if items["supply_count"] == nil || reflect.TypeOf(items["supply_count"]).String() != "float64" {
141
 					utils.ErrorLog("supply_count")
143
 					utils.ErrorLog("supply_count")
236
 					Status:                  1,
238
 					Status:                  1,
237
 					Mtime:                   0,
239
 					Mtime:                   0,
238
 					WarehousingId:           warehouseInfo.ID,
240
 					WarehousingId:           warehouseInfo.ID,
239
-					ProjectId:               id,
241
+					ProjectId:               project_id,
240
 					SupplyLicenseNumber:     supply_license_number,
242
 					SupplyLicenseNumber:     supply_license_number,
241
 					SupplyType:              supply_type,
243
 					SupplyType:              supply_type,
242
 					SupplySpecificationName: supply_specification_name,
244
 					SupplySpecificationName: supply_specification_name,
438
 				supply_total_price := items["supply_total_price"].(string)
440
 				supply_total_price := items["supply_total_price"].(string)
439
 
441
 
440
 				supply_total_price_float, _ := strconv.ParseFloat(supply_total_price, 64)
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
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
445
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
444
 					return
446
 					return
445
 				}
447
 				}
446
-				is_source := int64(items["is_source"].(float64))
448
+				is_source := int64(items["type"].(float64))
447
 
449
 
448
 				if items["supply_type"] == nil || reflect.TypeOf(items["supply_type"]).String() != "string" {
450
 				if items["supply_type"] == nil || reflect.TypeOf(items["supply_type"]).String() != "string" {
449
 					utils.ErrorLog("supply_type")
451
 					utils.ErrorLog("supply_type")
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 Bestand weergeven

809
 		db = db.Where("x.warehouse_out_id = ?", id)
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
 	return info, err
813
 	return info, err
814
 }
814
 }
815
 
815
 

+ 19 - 3
service/supply_service.go Bestand weergeven

1
 package service
1
 package service
2
 
2
 
3
-import "XT_New/models"
3
+import (
4
+	"XT_New/models"
5
+	"time"
6
+)
4
 
7
 
5
 func GetSupplyDrugList(orgid int64) (drug []*models.SpBaseDrug, err error) {
8
 func GetSupplyDrugList(orgid int64) (drug []*models.SpBaseDrug, err error) {
6
 
9
 
90
 
93
 
91
 func ModefySupplyWarehouseInfo(id int64, info models.SupplierWarehouseInfo) error {
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
 	return err
97
 	return err
95
 }
98
 }
96
 
99
 
97
 func ModifySupplyWarehouseOrder(order *models.SupplierWarehousingInfoOrder) error {
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
 	return err
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
+}