|
@@ -20,14 +20,38 @@ type SupplyOrderApiController struct {
|
20
|
20
|
|
21
|
21
|
func SupplyOrderApiRegistRouters() {
|
22
|
22
|
|
|
23
|
+ //初始化商品数据
|
23
|
24
|
beego.Router("/api/supply/getinitorder", &SupplyOrderApiController{}, "get:GetInitOrder")
|
|
25
|
+ //保存购货订单
|
24
|
26
|
beego.Router("/api/supply/savepurchaseorder", &SupplyOrderApiController{}, "post:SavePurchaseOrder")
|
|
27
|
+ //获取所有供应商
|
25
|
28
|
beego.Router("/api/supply/getallsupply", &SupplyOrderApiController{}, "get:GetAllSupply")
|
|
29
|
+ //获取供应商订单列表
|
26
|
30
|
beego.Router("/api/supply/getallpurchaseorderlist", &SupplyOrderApiController{}, "get:GetAllPurchaseOrderList")
|
|
31
|
+ //修改购货订单
|
27
|
32
|
beego.Router("/api/supply/updatepurchaseorder", &SupplyOrderApiController{}, "Post:UpdatePurchaseOrder")
|
|
33
|
+ //审核购货订单
|
28
|
34
|
beego.Router("/api/supply/checkpurchaseorder", &SupplyOrderApiController{}, "get:UpdateSupplyWaresing")
|
|
35
|
+ //获取购货订单详情
|
29
|
36
|
beego.Router("/api/supply/getpurchaseorderdetail", &SupplyOrderApiController{}, "get:GetPurchaseOrderDetail")
|
|
37
|
+ //新增购货单
|
30
|
38
|
beego.Router("/api/supply/addgoodorder", &SupplyOrderApiController{}, "post:AddGoodOrder")
|
|
39
|
+ //获取购货单列表
|
|
40
|
+ beego.Router("/api/supply/getallgoodorderlist", &SupplyOrderApiController{}, "Get:GetAllGoodOderList")
|
|
41
|
+ //修改购货订单详情
|
|
42
|
+ beego.Router("/api/supply/getgoodorderdetail", &SupplyOrderApiController{}, "Get:GetGoodOrderDetail")
|
|
43
|
+ //修改购货订单
|
|
44
|
+ beego.Router("/api/supply/updategoodorder", &SupplyOrderApiController{}, "Post:UpdateGoodOrder")
|
|
45
|
+ //删除购货订单
|
|
46
|
+ beego.Router("/api/supply/deletepurchorder", &SupplyOrderApiController{}, "Get:DeletePurchOrder")
|
|
47
|
+ //生成购货单的判断
|
|
48
|
+ beego.Router("/api/supply/getallordercountlist", &SupplyOrderApiController{}, "Get:GetAllOrderCountList")
|
|
49
|
+ // 生成购货单
|
|
50
|
+ beego.Router("/api/supply/getpurchaseorderinfo", &SupplyOrderApiController{}, "Get:GetPurchOrderInfo")
|
|
51
|
+ //反审核 获取关联的购货单数据
|
|
52
|
+ beego.Router("/api/supply/getgoodorderlist", &SupplyOrderApiController{}, "Get:GetGoodOrderList")
|
|
53
|
+ //反审核购货订单
|
|
54
|
+ beego.Router("/api/supply/getreturnorder", &SupplyOrderApiController{}, "Get:GetReturnOrder")
|
31
|
55
|
}
|
32
|
56
|
|
33
|
57
|
func (this *SupplyOrderApiController) GetInitOrder() {
|
|
@@ -98,7 +122,7 @@ func (this *SupplyOrderApiController) SavePurchaseOrder() {
|
98
|
122
|
return
|
99
|
123
|
}
|
100
|
124
|
|
101
|
|
- //生成订货单
|
|
125
|
+ //生成购货订单
|
102
|
126
|
timeStr := time.Now().Format("2006-01-02")
|
103
|
127
|
timeArr := strings.Split(timeStr, "-")
|
104
|
128
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
@@ -123,6 +147,7 @@ func (this *SupplyOrderApiController) SavePurchaseOrder() {
|
123
|
147
|
DocumentDate: startTime,
|
124
|
148
|
DeliveryDate: endTime,
|
125
|
149
|
SupplierId: supplier_id,
|
|
150
|
+ IsWarehouse: 2,
|
126
|
151
|
}
|
127
|
152
|
err = service.CreateSupplyWarehouse(info)
|
128
|
153
|
warehouseInfo, _ := service.FindLastSupplyWarehouseInfo(orgId)
|
|
@@ -235,6 +260,13 @@ func (this *SupplyOrderApiController) SavePurchaseOrder() {
|
235
|
260
|
|
236
|
261
|
supply_unit := items["supply_unit"].(string)
|
237
|
262
|
|
|
263
|
+ if items["manufacturer_id"] == nil || reflect.TypeOf(items["manufacturer_id"]).String() != "float64" {
|
|
264
|
+ utils.ErrorLog("manufacturer_id")
|
|
265
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
266
|
+ return
|
|
267
|
+ }
|
|
268
|
+ manufacturer_id := int64(items["manufacturer_id"].(float64))
|
|
269
|
+
|
238
|
270
|
order := models.SupplierWarehousingInfoOrder{
|
239
|
271
|
OrderNumber: warehousing_order,
|
240
|
272
|
IsSource: is_source,
|
|
@@ -255,6 +287,7 @@ func (this *SupplyOrderApiController) SavePurchaseOrder() {
|
255
|
287
|
SupplyManufacturer: supply_manufacturer,
|
256
|
288
|
Name: name,
|
257
|
289
|
SupplyUnit: supply_unit,
|
|
290
|
+ ManufacturerId: manufacturer_id,
|
258
|
291
|
}
|
259
|
292
|
|
260
|
293
|
warehousingInfo = append(warehousingInfo, &order)
|
|
@@ -355,7 +388,7 @@ func (this *SupplyOrderApiController) UpdatePurchaseOrder() {
|
355
|
388
|
}
|
356
|
389
|
var endTime int64
|
357
|
390
|
if len(end_time) > 0 {
|
358
|
|
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
391
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
|
359
|
392
|
if err != nil {
|
360
|
393
|
utils.ErrorLog(err.Error())
|
361
|
394
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -504,6 +537,13 @@ func (this *SupplyOrderApiController) UpdatePurchaseOrder() {
|
504
|
537
|
}
|
505
|
538
|
|
506
|
539
|
supply_unit := items["supply_unit"].(string)
|
|
540
|
+
|
|
541
|
+ if items["manufacturer_id"] == nil || reflect.TypeOf(items["manufacturer_id"]).String() != "float64" {
|
|
542
|
+ utils.ErrorLog("manufacturer_id")
|
|
543
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
544
|
+ return
|
|
545
|
+ }
|
|
546
|
+ manufacturer_id := int64(items["manufacturer_id"].(float64))
|
507
|
547
|
if id > 0 {
|
508
|
548
|
order := models.SupplierWarehousingInfoOrder{
|
509
|
549
|
ID: id,
|
|
@@ -523,6 +563,7 @@ func (this *SupplyOrderApiController) UpdatePurchaseOrder() {
|
523
|
563
|
SupplyManufacturer: supply_manufacturer,
|
524
|
564
|
Name: name,
|
525
|
565
|
SupplyUnit: supply_unit,
|
|
566
|
+ ManufacturerId: manufacturer_id,
|
526
|
567
|
}
|
527
|
568
|
|
528
|
569
|
updateWarehousingInfo = append(updateWarehousingInfo, &order)
|
|
@@ -550,6 +591,7 @@ func (this *SupplyOrderApiController) UpdatePurchaseOrder() {
|
550
|
591
|
SupplyManufacturer: supply_manufacturer,
|
551
|
592
|
Name: name,
|
552
|
593
|
SupplyUnit: supply_unit,
|
|
594
|
+ ManufacturerId: manufacturer_id,
|
553
|
595
|
}
|
554
|
596
|
warehousingInfo = append(warehousingInfo, &order)
|
555
|
597
|
}
|
|
@@ -640,12 +682,767 @@ func (this *SupplyOrderApiController) AddGoodOrder() {
|
640
|
682
|
}
|
641
|
683
|
startTime = theTime.Unix()
|
642
|
684
|
}
|
643
|
|
- good_number := this.GetString("good_number")
|
644
|
|
- arrerage, _ := this.GetInt64("arrerage")
|
645
|
|
- payment, _ := this.GetInt64("payment")
|
|
685
|
+ arrerage := this.GetString("arrerage")
|
|
686
|
+ arrerage_float, _ := strconv.ParseFloat(arrerage, 64)
|
|
687
|
+ payment := this.GetString("payment")
|
|
688
|
+ payment_float, _ := strconv.ParseFloat(payment, 64)
|
646
|
689
|
warehousing_id, _ := this.GetInt64("warehousing_id")
|
647
|
690
|
number := this.GetString("number")
|
648
|
|
- rate_of_concession, _ := this.GetInt64("rate_of_concession")
|
649
|
|
- discount_amount, _ := this.GetInt64("discount_amount")
|
650
|
|
- fmt.Println(supplier_id, startTime, good_number, arrerage, payment, warehousing_id, number, rate_of_concession, discount_amount)
|
|
691
|
+ rate_of_concession := this.GetString("rate_of_concession")
|
|
692
|
+ rate_of_concession_float, _ := strconv.ParseFloat(rate_of_concession, 64)
|
|
693
|
+ discount_amount := this.GetString("discount_amount")
|
|
694
|
+ discount_amount_float, _ := strconv.ParseFloat(discount_amount, 64)
|
|
695
|
+ fmt.Println(supplier_id, startTime, arrerage, payment, warehousing_id, number, rate_of_concession, discount_amount)
|
|
696
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
697
|
+ creater := this.GetAdminUserInfo().AdminUser.Id
|
|
698
|
+ //生成购货单
|
|
699
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
700
|
+ timeArr := strings.Split(timeStr, "-")
|
|
701
|
+ total, _ := service.FindAllSupplyWarehouseOutOrder(orgId)
|
|
702
|
+ total = total + 1
|
|
703
|
+ warehousing_order := "CG" + timeArr[0] + timeArr[1] + timeArr[2] + "00" + strconv.FormatInt(total, 10)
|
|
704
|
+ recordDateStr := time.Now().Format("2006-01-02")
|
|
705
|
+ recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
706
|
+
|
|
707
|
+ warehouse_out := models.SpSupplierWarehouseOut{
|
|
708
|
+ Number: number,
|
|
709
|
+ UserOrgId: orgId,
|
|
710
|
+ Creater: creater,
|
|
711
|
+ Ctime: time.Now().Unix(),
|
|
712
|
+ Mtime: 0,
|
|
713
|
+ Status: 1,
|
|
714
|
+ RecordDate: recordDate.Unix(),
|
|
715
|
+ IsCheck: 2,
|
|
716
|
+ WarehousingId: warehousing_id,
|
|
717
|
+ GoodNumber: warehousing_order,
|
|
718
|
+ Arrearage: arrerage_float,
|
|
719
|
+ Payment: payment_float,
|
|
720
|
+ RateOfConcession: rate_of_concession_float,
|
|
721
|
+ DiscountAmount: discount_amount_float,
|
|
722
|
+ DocumentDate: startTime,
|
|
723
|
+ SupplierId: supplier_id,
|
|
724
|
+ Checker: 0,
|
|
725
|
+ CheckTime: 0,
|
|
726
|
+ }
|
|
727
|
+
|
|
728
|
+ service.CreateSupplyWarehouseOut(warehouse_out)
|
|
729
|
+
|
|
730
|
+ //获取最后一条
|
|
731
|
+ warehouseOut, _ := service.FindSupplyWarehouseOutById(orgId)
|
|
732
|
+
|
|
733
|
+ dataBody := make(map[string]interface{}, 0)
|
|
734
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
735
|
+ if err != nil {
|
|
736
|
+ utils.ErrorLog(err.Error())
|
|
737
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
738
|
+ return
|
|
739
|
+ }
|
|
740
|
+ var warehousingOut []*models.SpSupplierWarehousingOutOrder
|
|
741
|
+ if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
|
|
742
|
+ thisStockIn, _ := dataBody["stockIn"].([]interface{})
|
|
743
|
+ if len(thisStockIn) > 0 {
|
|
744
|
+ for _, item := range thisStockIn {
|
|
745
|
+ items := item.(map[string]interface{})
|
|
746
|
+
|
|
747
|
+ if items["supply_count"] == nil || reflect.TypeOf(items["supply_count"]).String() != "float64" {
|
|
748
|
+ utils.ErrorLog("supply_count")
|
|
749
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
750
|
+ return
|
|
751
|
+ }
|
|
752
|
+ supply_count := int64(items["supply_count"].(float64))
|
|
753
|
+
|
|
754
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
755
|
+ utils.ErrorLog("id")
|
|
756
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
757
|
+ return
|
|
758
|
+ }
|
|
759
|
+ id := int64(items["id"].(float64))
|
|
760
|
+
|
|
761
|
+ if items["manufacturer_id"] == nil || reflect.TypeOf(items["manufacturer_id"]).String() != "float64" {
|
|
762
|
+ utils.ErrorLog("manufacturer_id")
|
|
763
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
764
|
+ return
|
|
765
|
+ }
|
|
766
|
+ manufacturer_id := int64(items["manufacturer_id"].(float64))
|
|
767
|
+
|
|
768
|
+ if items["name"] == nil || reflect.TypeOf(items["name"]).String() != "string" {
|
|
769
|
+ utils.ErrorLog("name")
|
|
770
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
771
|
+ return
|
|
772
|
+ }
|
|
773
|
+ name := items["name"].(string)
|
|
774
|
+
|
|
775
|
+ if items["order_number"] == nil || reflect.TypeOf(items["order_number"]).String() != "string" {
|
|
776
|
+ utils.ErrorLog("order_number")
|
|
777
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
778
|
+ return
|
|
779
|
+ }
|
|
780
|
+ order_number := items["order_number"].(string)
|
|
781
|
+
|
|
782
|
+ if items["supply_price"] == nil || reflect.TypeOf(items["supply_price"]).String() != "string" {
|
|
783
|
+ utils.ErrorLog("supply_price")
|
|
784
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
785
|
+ return
|
|
786
|
+ }
|
|
787
|
+ supply_price := items["supply_price"].(string)
|
|
788
|
+
|
|
789
|
+ price_float, _ := strconv.ParseFloat(supply_price, 64)
|
|
790
|
+
|
|
791
|
+ if items["supply_total_price"] == nil || reflect.TypeOf(items["supply_total_price"]).String() != "string" {
|
|
792
|
+ utils.ErrorLog("supply_total_price")
|
|
793
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
794
|
+ return
|
|
795
|
+ }
|
|
796
|
+ supply_total_price := items["supply_total_price"].(string)
|
|
797
|
+
|
|
798
|
+ supply_total_price_float, _ := strconv.ParseFloat(supply_total_price, 64)
|
|
799
|
+
|
|
800
|
+ if items["project_id"] == nil || reflect.TypeOf(items["project_id"]).String() != "float64" {
|
|
801
|
+ utils.ErrorLog("project_id")
|
|
802
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
803
|
+ return
|
|
804
|
+ }
|
|
805
|
+ project_id := int64(items["project_id"].(float64))
|
|
806
|
+
|
|
807
|
+ if items["supply_remake"] == nil || reflect.TypeOf(items["supply_remake"]).String() != "string" {
|
|
808
|
+ utils.ErrorLog("supply_remake")
|
|
809
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
810
|
+ return
|
|
811
|
+ }
|
|
812
|
+ supply_remake := items["supply_remake"].(string)
|
|
813
|
+
|
|
814
|
+ if items["supply_batch_number"] == nil || reflect.TypeOf(items["supply_batch_number"]).String() != "string" {
|
|
815
|
+ utils.ErrorLog("supply_batch_number")
|
|
816
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
817
|
+ return
|
|
818
|
+ }
|
|
819
|
+ supply_batch_number := items["supply_batch_number"].(string)
|
|
820
|
+
|
|
821
|
+ var supply_expiry_date_time int64
|
|
822
|
+ if items["supply_expiry_date"] == nil || reflect.TypeOf(items["supply_expiry_date"]).String() != "string" {
|
|
823
|
+ utils.ErrorLog("supply_expiry_date")
|
|
824
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
825
|
+ return
|
|
826
|
+ }
|
|
827
|
+ supply_expiry_date := items["supply_expiry_date"].(string)
|
|
828
|
+
|
|
829
|
+ if len(supply_expiry_date) > 0 {
|
|
830
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", supply_expiry_date+" 00:00:00", loc)
|
|
831
|
+ if err != nil {
|
|
832
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
833
|
+ return
|
|
834
|
+ }
|
|
835
|
+ supply_expiry_date_time = theTime.Unix()
|
|
836
|
+ }
|
|
837
|
+
|
|
838
|
+ if items["supply_license_number"] == nil || reflect.TypeOf(items["supply_license_number"]).String() != "string" {
|
|
839
|
+ utils.ErrorLog("supply_license_number")
|
|
840
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
841
|
+ return
|
|
842
|
+ }
|
|
843
|
+ supply_license_number := items["supply_license_number"].(string)
|
|
844
|
+
|
|
845
|
+ var supply_product_date_time int64
|
|
846
|
+ if items["supply_product_date"] == nil || reflect.TypeOf(items["supply_product_date"]).String() != "string" {
|
|
847
|
+ utils.ErrorLog("supply_product_date")
|
|
848
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
849
|
+ return
|
|
850
|
+ }
|
|
851
|
+ supply_product_date := items["supply_product_date"].(string)
|
|
852
|
+
|
|
853
|
+ if len(supply_product_date) > 0 {
|
|
854
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", supply_product_date+" 00:00:00", loc)
|
|
855
|
+ if err != nil {
|
|
856
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
857
|
+ return
|
|
858
|
+ }
|
|
859
|
+ supply_product_date_time = theTime.Unix()
|
|
860
|
+ }
|
|
861
|
+
|
|
862
|
+ if items["supply_specification_name"] == nil || reflect.TypeOf(items["supply_specification_name"]).String() != "string" {
|
|
863
|
+ utils.ErrorLog("supply_specification_name")
|
|
864
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
865
|
+ return
|
|
866
|
+ }
|
|
867
|
+ supply_specification_name := items["supply_specification_name"].(string)
|
|
868
|
+
|
|
869
|
+ if items["supply_total"] == nil || reflect.TypeOf(items["supply_total"]).String() != "string" {
|
|
870
|
+ utils.ErrorLog("supply_total")
|
|
871
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
872
|
+ return
|
|
873
|
+ }
|
|
874
|
+ supply_total := items["supply_total"].(string)
|
|
875
|
+
|
|
876
|
+ if items["supply_type"] == nil || reflect.TypeOf(items["supply_type"]).String() != "string" {
|
|
877
|
+ utils.ErrorLog("supply_type")
|
|
878
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
879
|
+ return
|
|
880
|
+ }
|
|
881
|
+ supply_type := items["supply_type"].(string)
|
|
882
|
+
|
|
883
|
+ if items["supply_unit"] == nil || reflect.TypeOf(items["supply_unit"]).String() != "string" {
|
|
884
|
+ utils.ErrorLog("supply_unit")
|
|
885
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
886
|
+ return
|
|
887
|
+ }
|
|
888
|
+ supply_unit := items["supply_unit"].(string)
|
|
889
|
+
|
|
890
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
891
|
+ utils.ErrorLog("type")
|
|
892
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
893
|
+ return
|
|
894
|
+ }
|
|
895
|
+ is_source := int64(items["type"].(float64))
|
|
896
|
+
|
|
897
|
+ if items["supply_manufacturer"] == nil || reflect.TypeOf(items["supply_manufacturer"]).String() != "string" {
|
|
898
|
+ utils.ErrorLog("supply_manufacturer")
|
|
899
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
900
|
+ return
|
|
901
|
+ }
|
|
902
|
+ supply_manufacturer := items["supply_manufacturer"].(string)
|
|
903
|
+ order := models.SpSupplierWarehousingOutOrder{
|
|
904
|
+ OrderNumber: order_number,
|
|
905
|
+ ProjectId: project_id,
|
|
906
|
+ IsSource: is_source,
|
|
907
|
+ Count: supply_count,
|
|
908
|
+ Amount: supply_total_price_float,
|
|
909
|
+ Price: price_float,
|
|
910
|
+ Remark: supply_remake,
|
|
911
|
+ IsCheck: 2,
|
|
912
|
+ UserOrgId: orgId,
|
|
913
|
+ Status: 1,
|
|
914
|
+ Ctime: time.Now().Unix(),
|
|
915
|
+ Mtime: 0,
|
|
916
|
+ WarehouseOutId: warehouseOut.ID,
|
|
917
|
+ Type: 1,
|
|
918
|
+ SupplyBatchNumber: supply_batch_number,
|
|
919
|
+ SupplyProductDate: supply_product_date_time,
|
|
920
|
+ SupplyExpiryDate: supply_expiry_date_time,
|
|
921
|
+ WarehousingId: warehousing_id,
|
|
922
|
+ WarehouseInfoId: id,
|
|
923
|
+ SupplyType: supply_type,
|
|
924
|
+ SupplyUnit: supply_unit,
|
|
925
|
+ SupplyTotal: supply_total,
|
|
926
|
+ SupplySpecificationName: supply_specification_name,
|
|
927
|
+ SupplyLicenseNumber: supply_license_number,
|
|
928
|
+ Name: name,
|
|
929
|
+ ManufacturerId: manufacturer_id,
|
|
930
|
+ GoodNumber: warehouseOut.GoodNumber,
|
|
931
|
+ SupplyManufacturer: supply_manufacturer,
|
|
932
|
+ }
|
|
933
|
+ warehousingOut = append(warehousingOut, &order)
|
|
934
|
+ }
|
|
935
|
+ }
|
|
936
|
+ }
|
|
937
|
+
|
|
938
|
+ for _, item := range warehousingOut {
|
|
939
|
+ //如果是手动新增的,type 等于2
|
|
940
|
+ if item.WarehouseInfoId == 0 {
|
|
941
|
+ item.Type = 2
|
|
942
|
+ }
|
|
943
|
+ err = service.CreateSupplyWarehousOutOrder(item)
|
|
944
|
+ }
|
|
945
|
+
|
|
946
|
+ list, parseDateErr := service.GetSupplyWarehouseOutById(warehouseOut.ID, orgId)
|
|
947
|
+
|
|
948
|
+ if parseDateErr == nil {
|
|
949
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
950
|
+ "list": list,
|
|
951
|
+ "warehouseOut": warehouseOut,
|
|
952
|
+ })
|
|
953
|
+ } else {
|
|
954
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
955
|
+ }
|
|
956
|
+}
|
|
957
|
+
|
|
958
|
+func (this *SupplyOrderApiController) GetAllGoodOderList() {
|
|
959
|
+
|
|
960
|
+ check_id, _ := this.GetInt64("check_id")
|
|
961
|
+ start_time := this.GetString("start_time")
|
|
962
|
+ end_time := this.GetString("end_time")
|
|
963
|
+ keyword := this.GetString("keyword")
|
|
964
|
+ page, _ := this.GetInt64("page")
|
|
965
|
+ limit, _ := this.GetInt64("limit")
|
|
966
|
+ timeLayout := "2006-01-02"
|
|
967
|
+ loc, _ := time.LoadLocation("Local")
|
|
968
|
+ var startTime int64
|
|
969
|
+ if len(start_time) > 0 {
|
|
970
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
971
|
+ if err != nil {
|
|
972
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
973
|
+ return
|
|
974
|
+ }
|
|
975
|
+ startTime = theTime.Unix()
|
|
976
|
+ }
|
|
977
|
+ var endTime int64
|
|
978
|
+ if len(end_time) > 0 {
|
|
979
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
|
|
980
|
+ if err != nil {
|
|
981
|
+ utils.ErrorLog(err.Error())
|
|
982
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
983
|
+ return
|
|
984
|
+ }
|
|
985
|
+ endTime = theTime.Unix()
|
|
986
|
+
|
|
987
|
+ }
|
|
988
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
989
|
+
|
|
990
|
+ list, total, err := service.GetAllGoodOderList(check_id, keyword, page, limit, startTime, endTime, orgId)
|
|
991
|
+ if err == nil {
|
|
992
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
993
|
+ "list": list,
|
|
994
|
+ "total": total,
|
|
995
|
+ })
|
|
996
|
+ } else {
|
|
997
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
998
|
+ }
|
|
999
|
+}
|
|
1000
|
+
|
|
1001
|
+func (this *SupplyOrderApiController) GetGoodOrderDetail() {
|
|
1002
|
+
|
|
1003
|
+ id, _ := this.GetInt64("id")
|
|
1004
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1005
|
+ out, err := service.GetGoodOrderDetail(id, orgId)
|
|
1006
|
+ list, _ := service.GetSupplyWarehouseOutById(id, orgId)
|
|
1007
|
+ drugList, _ := service.GetSupplyDrugList(orgId)
|
|
1008
|
+ goodList, _ := service.GetSupplyGoodList(orgId)
|
|
1009
|
+ if err == nil {
|
|
1010
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1011
|
+ "out": out,
|
|
1012
|
+ "list": list,
|
|
1013
|
+ "goodList": goodList,
|
|
1014
|
+ "drugList": drugList,
|
|
1015
|
+ })
|
|
1016
|
+ } else {
|
|
1017
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1018
|
+ }
|
|
1019
|
+}
|
|
1020
|
+
|
|
1021
|
+func (this *SupplyOrderApiController) UpdateGoodOrder() {
|
|
1022
|
+ supplier_id, _ := this.GetInt64("supplier_id")
|
|
1023
|
+ start_time := this.GetString("start")
|
|
1024
|
+ timeLayout := "2006-01-02"
|
|
1025
|
+ loc, _ := time.LoadLocation("Local")
|
|
1026
|
+ var startTime int64
|
|
1027
|
+ if len(start_time) > 0 {
|
|
1028
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
1029
|
+ if err != nil {
|
|
1030
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1031
|
+ return
|
|
1032
|
+ }
|
|
1033
|
+ startTime = theTime.Unix()
|
|
1034
|
+ }
|
|
1035
|
+ arrerage := this.GetString("arrerage")
|
|
1036
|
+ arrerage_float, _ := strconv.ParseFloat(arrerage, 64)
|
|
1037
|
+ payment := this.GetString("payment")
|
|
1038
|
+ payment_float, _ := strconv.ParseFloat(payment, 64)
|
|
1039
|
+ warehose_out_id, _ := this.GetInt64("warehose_out_id")
|
|
1040
|
+ number := this.GetString("number")
|
|
1041
|
+ rate_of_concession := this.GetString("rate_of_concession")
|
|
1042
|
+ rate_of_concession_float, _ := strconv.ParseFloat(rate_of_concession, 64)
|
|
1043
|
+ discount_amount := this.GetString("discount_amount")
|
|
1044
|
+ discount_amount_float, _ := strconv.ParseFloat(discount_amount, 64)
|
|
1045
|
+ good_number := this.GetString("good_number")
|
|
1046
|
+ fmt.Println(supplier_id, startTime, arrerage, payment, warehose_out_id, number, rate_of_concession, discount_amount)
|
|
1047
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1048
|
+ dataBody := make(map[string]interface{}, 0)
|
|
1049
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
1050
|
+ if err != nil {
|
|
1051
|
+ utils.ErrorLog(err.Error())
|
|
1052
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1053
|
+ return
|
|
1054
|
+ }
|
|
1055
|
+ var warehousingOut []*models.SpSupplierWarehousingOutOrder
|
|
1056
|
+ var updateWarehout []*models.SpSupplierWarehousingOutOrder
|
|
1057
|
+ if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
|
|
1058
|
+ thisStockIn, _ := dataBody["stockIn"].([]interface{})
|
|
1059
|
+ if len(thisStockIn) > 0 {
|
|
1060
|
+ for _, item := range thisStockIn {
|
|
1061
|
+ items := item.(map[string]interface{})
|
|
1062
|
+
|
|
1063
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
1064
|
+ utils.ErrorLog("id")
|
|
1065
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1066
|
+ return
|
|
1067
|
+ }
|
|
1068
|
+ id := int64(items["id"].(float64))
|
|
1069
|
+
|
|
1070
|
+ if items["supply_count"] == nil || reflect.TypeOf(items["supply_count"]).String() != "float64" {
|
|
1071
|
+ utils.ErrorLog("supply_count")
|
|
1072
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1073
|
+ return
|
|
1074
|
+ }
|
|
1075
|
+ supply_count := int64(items["supply_count"].(float64))
|
|
1076
|
+
|
|
1077
|
+ if items["manufacturer_id"] == nil || reflect.TypeOf(items["manufacturer_id"]).String() != "float64" {
|
|
1078
|
+ utils.ErrorLog("manufacturer_id")
|
|
1079
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1080
|
+ return
|
|
1081
|
+ }
|
|
1082
|
+ manufacturer_id := int64(items["manufacturer_id"].(float64))
|
|
1083
|
+
|
|
1084
|
+ if items["name"] == nil || reflect.TypeOf(items["name"]).String() != "string" {
|
|
1085
|
+ utils.ErrorLog("name")
|
|
1086
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1087
|
+ return
|
|
1088
|
+ }
|
|
1089
|
+ name := items["name"].(string)
|
|
1090
|
+
|
|
1091
|
+ if items["order_number"] == nil || reflect.TypeOf(items["order_number"]).String() != "string" {
|
|
1092
|
+ utils.ErrorLog("order_number")
|
|
1093
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1094
|
+ return
|
|
1095
|
+ }
|
|
1096
|
+ order_number := items["order_number"].(string)
|
|
1097
|
+
|
|
1098
|
+ if items["supply_price"] == nil || reflect.TypeOf(items["supply_price"]).String() != "string" {
|
|
1099
|
+ utils.ErrorLog("supply_price")
|
|
1100
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1101
|
+ return
|
|
1102
|
+ }
|
|
1103
|
+ supply_price := items["supply_price"].(string)
|
|
1104
|
+
|
|
1105
|
+ price_float, _ := strconv.ParseFloat(supply_price, 64)
|
|
1106
|
+
|
|
1107
|
+ if items["supply_total_price"] == nil || reflect.TypeOf(items["supply_total_price"]).String() != "string" {
|
|
1108
|
+ utils.ErrorLog("supply_total_price")
|
|
1109
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1110
|
+ return
|
|
1111
|
+ }
|
|
1112
|
+ supply_total_price := items["supply_total_price"].(string)
|
|
1113
|
+
|
|
1114
|
+ supply_total_price_float, _ := strconv.ParseFloat(supply_total_price, 64)
|
|
1115
|
+
|
|
1116
|
+ if items["project_id"] == nil || reflect.TypeOf(items["project_id"]).String() != "float64" {
|
|
1117
|
+ utils.ErrorLog("project_id")
|
|
1118
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1119
|
+ return
|
|
1120
|
+ }
|
|
1121
|
+ project_id := int64(items["project_id"].(float64))
|
|
1122
|
+
|
|
1123
|
+ if items["supply_remake"] == nil || reflect.TypeOf(items["supply_remake"]).String() != "string" {
|
|
1124
|
+ utils.ErrorLog("supply_remake")
|
|
1125
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1126
|
+ return
|
|
1127
|
+ }
|
|
1128
|
+ supply_remake := items["supply_remake"].(string)
|
|
1129
|
+
|
|
1130
|
+ if items["supply_batch_number"] == nil || reflect.TypeOf(items["supply_batch_number"]).String() != "string" {
|
|
1131
|
+ utils.ErrorLog("supply_batch_number")
|
|
1132
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1133
|
+ return
|
|
1134
|
+ }
|
|
1135
|
+ supply_batch_number := items["supply_batch_number"].(string)
|
|
1136
|
+
|
|
1137
|
+ var supply_expiry_date_time int64
|
|
1138
|
+ if items["supply_expiry_date"] == nil || reflect.TypeOf(items["supply_expiry_date"]).String() != "string" {
|
|
1139
|
+ utils.ErrorLog("supply_expiry_date")
|
|
1140
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1141
|
+ return
|
|
1142
|
+ }
|
|
1143
|
+ supply_expiry_date := items["supply_expiry_date"].(string)
|
|
1144
|
+
|
|
1145
|
+ if len(supply_expiry_date) > 0 {
|
|
1146
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", supply_expiry_date+" 00:00:00", loc)
|
|
1147
|
+ if err != nil {
|
|
1148
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1149
|
+ return
|
|
1150
|
+ }
|
|
1151
|
+ supply_expiry_date_time = theTime.Unix()
|
|
1152
|
+ }
|
|
1153
|
+
|
|
1154
|
+ if items["supply_license_number"] == nil || reflect.TypeOf(items["supply_license_number"]).String() != "string" {
|
|
1155
|
+ utils.ErrorLog("supply_license_number")
|
|
1156
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1157
|
+ return
|
|
1158
|
+ }
|
|
1159
|
+ supply_license_number := items["supply_license_number"].(string)
|
|
1160
|
+
|
|
1161
|
+ var supply_product_date_time int64
|
|
1162
|
+ if items["supply_product_date"] == nil || reflect.TypeOf(items["supply_product_date"]).String() != "string" {
|
|
1163
|
+ utils.ErrorLog("supply_product_date")
|
|
1164
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1165
|
+ return
|
|
1166
|
+ }
|
|
1167
|
+ supply_product_date := items["supply_product_date"].(string)
|
|
1168
|
+
|
|
1169
|
+ if len(supply_product_date) > 0 {
|
|
1170
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", supply_product_date+" 00:00:00", loc)
|
|
1171
|
+ if err != nil {
|
|
1172
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1173
|
+ return
|
|
1174
|
+ }
|
|
1175
|
+ supply_product_date_time = theTime.Unix()
|
|
1176
|
+ }
|
|
1177
|
+
|
|
1178
|
+ if items["supply_specification_name"] == nil || reflect.TypeOf(items["supply_specification_name"]).String() != "string" {
|
|
1179
|
+ utils.ErrorLog("supply_specification_name")
|
|
1180
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1181
|
+ return
|
|
1182
|
+ }
|
|
1183
|
+ supply_specification_name := items["supply_specification_name"].(string)
|
|
1184
|
+
|
|
1185
|
+ if items["supply_total"] == nil || reflect.TypeOf(items["supply_total"]).String() != "string" {
|
|
1186
|
+ utils.ErrorLog("supply_total")
|
|
1187
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1188
|
+ return
|
|
1189
|
+ }
|
|
1190
|
+ supply_total := items["supply_total"].(string)
|
|
1191
|
+
|
|
1192
|
+ if items["supply_type"] == nil || reflect.TypeOf(items["supply_type"]).String() != "string" {
|
|
1193
|
+ utils.ErrorLog("supply_type")
|
|
1194
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1195
|
+ return
|
|
1196
|
+ }
|
|
1197
|
+ supply_type := items["supply_type"].(string)
|
|
1198
|
+
|
|
1199
|
+ if items["supply_unit"] == nil || reflect.TypeOf(items["supply_unit"]).String() != "string" {
|
|
1200
|
+ utils.ErrorLog("supply_unit")
|
|
1201
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1202
|
+ return
|
|
1203
|
+ }
|
|
1204
|
+ supply_unit := items["supply_unit"].(string)
|
|
1205
|
+
|
|
1206
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
1207
|
+ utils.ErrorLog("type")
|
|
1208
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1209
|
+ return
|
|
1210
|
+ }
|
|
1211
|
+ is_source := int64(items["type"].(float64))
|
|
1212
|
+
|
|
1213
|
+ if items["supply_manufacturer"] == nil || reflect.TypeOf(items["supply_manufacturer"]).String() != "string" {
|
|
1214
|
+ utils.ErrorLog("supply_manufacturer")
|
|
1215
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1216
|
+ return
|
|
1217
|
+ }
|
|
1218
|
+ supply_manufacturer := items["supply_manufacturer"].(string)
|
|
1219
|
+
|
|
1220
|
+ if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
|
|
1221
|
+ utils.ErrorLog("warehouse_info_id")
|
|
1222
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1223
|
+ return
|
|
1224
|
+ }
|
|
1225
|
+ warehouse_info_id := int64(items["warehouse_info_id"].(float64))
|
|
1226
|
+
|
|
1227
|
+ if items["warehousing_id"] == nil || reflect.TypeOf(items["warehousing_id"]).String() != "float64" {
|
|
1228
|
+ utils.ErrorLog("warehouse_info_id")
|
|
1229
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1230
|
+ return
|
|
1231
|
+ }
|
|
1232
|
+ warehousing_id := int64(items["warehousing_id"].(float64))
|
|
1233
|
+ if id > 0 {
|
|
1234
|
+ order := models.SpSupplierWarehousingOutOrder{
|
|
1235
|
+ ID: id,
|
|
1236
|
+ OrderNumber: order_number,
|
|
1237
|
+ ProjectId: project_id,
|
|
1238
|
+ IsSource: is_source,
|
|
1239
|
+ Count: supply_count,
|
|
1240
|
+ Amount: supply_total_price_float,
|
|
1241
|
+ Price: price_float,
|
|
1242
|
+ Remark: supply_remake,
|
|
1243
|
+ IsCheck: 2,
|
|
1244
|
+ UserOrgId: orgId,
|
|
1245
|
+ Status: 1,
|
|
1246
|
+ Ctime: time.Now().Unix(),
|
|
1247
|
+ Mtime: 0,
|
|
1248
|
+ WarehouseOutId: warehose_out_id,
|
|
1249
|
+ Type: 1,
|
|
1250
|
+ SupplyBatchNumber: supply_batch_number,
|
|
1251
|
+ SupplyProductDate: supply_product_date_time,
|
|
1252
|
+ SupplyExpiryDate: supply_expiry_date_time,
|
|
1253
|
+ SupplyType: supply_type,
|
|
1254
|
+ SupplyUnit: supply_unit,
|
|
1255
|
+ SupplyTotal: supply_total,
|
|
1256
|
+ SupplySpecificationName: supply_specification_name,
|
|
1257
|
+ SupplyLicenseNumber: supply_license_number,
|
|
1258
|
+ Name: name,
|
|
1259
|
+ ManufacturerId: manufacturer_id,
|
|
1260
|
+ GoodNumber: good_number,
|
|
1261
|
+ SupplyManufacturer: supply_manufacturer,
|
|
1262
|
+ WarehouseInfoId: warehouse_info_id,
|
|
1263
|
+ WarehousingId: warehousing_id,
|
|
1264
|
+ }
|
|
1265
|
+ updateWarehout = append(updateWarehout, &order)
|
|
1266
|
+ }
|
|
1267
|
+
|
|
1268
|
+ if id == 0 {
|
|
1269
|
+ order := models.SpSupplierWarehousingOutOrder{
|
|
1270
|
+ OrderNumber: order_number,
|
|
1271
|
+ ProjectId: project_id,
|
|
1272
|
+ IsSource: is_source,
|
|
1273
|
+ Count: supply_count,
|
|
1274
|
+ Amount: supply_total_price_float,
|
|
1275
|
+ Price: price_float,
|
|
1276
|
+ Remark: supply_remake,
|
|
1277
|
+ IsCheck: 2,
|
|
1278
|
+ UserOrgId: orgId,
|
|
1279
|
+ Status: 1,
|
|
1280
|
+ Ctime: time.Now().Unix(),
|
|
1281
|
+ Mtime: 0,
|
|
1282
|
+ WarehouseOutId: warehose_out_id,
|
|
1283
|
+ Type: 1,
|
|
1284
|
+ SupplyBatchNumber: supply_batch_number,
|
|
1285
|
+ SupplyProductDate: supply_product_date_time,
|
|
1286
|
+ SupplyExpiryDate: supply_expiry_date_time,
|
|
1287
|
+ WarehouseInfoId: id,
|
|
1288
|
+ SupplyType: supply_type,
|
|
1289
|
+ SupplyUnit: supply_unit,
|
|
1290
|
+ SupplyTotal: supply_total,
|
|
1291
|
+ SupplySpecificationName: supply_specification_name,
|
|
1292
|
+ SupplyLicenseNumber: supply_license_number,
|
|
1293
|
+ Name: name,
|
|
1294
|
+ ManufacturerId: manufacturer_id,
|
|
1295
|
+ GoodNumber: good_number,
|
|
1296
|
+ SupplyManufacturer: supply_manufacturer,
|
|
1297
|
+ }
|
|
1298
|
+ warehousingOut = append(warehousingOut, &order)
|
|
1299
|
+ }
|
|
1300
|
+
|
|
1301
|
+ }
|
|
1302
|
+ }
|
|
1303
|
+ }
|
|
1304
|
+ out := models.SpSupplierWarehouseOut{
|
|
1305
|
+ Arrearage: arrerage_float,
|
|
1306
|
+ Payment: payment_float,
|
|
1307
|
+ RateOfConcession: rate_of_concession_float,
|
|
1308
|
+ DiscountAmount: discount_amount_float,
|
|
1309
|
+ SupplierId: supplier_id,
|
|
1310
|
+ DocumentDate: startTime,
|
|
1311
|
+ }
|
|
1312
|
+ //更改购货单据
|
|
1313
|
+ service.UpdateGoodWarehouseOut(warehose_out_id, out)
|
|
1314
|
+
|
|
1315
|
+ for _, item := range warehousingOut {
|
|
1316
|
+ //如果是手动新增的,type 等于2
|
|
1317
|
+ if item.WarehouseInfoId == 0 {
|
|
1318
|
+ item.Type = 2
|
|
1319
|
+ }
|
|
1320
|
+ err = service.CreateSupplyWarehousOutOrder(item)
|
|
1321
|
+ }
|
|
1322
|
+ for _, item := range updateWarehout {
|
|
1323
|
+
|
|
1324
|
+ service.UpdateGoodWarehouseOutOrder(item)
|
|
1325
|
+ }
|
|
1326
|
+ if err == nil {
|
|
1327
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1328
|
+ "out": out,
|
|
1329
|
+ })
|
|
1330
|
+ } else {
|
|
1331
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1332
|
+ }
|
|
1333
|
+}
|
|
1334
|
+
|
|
1335
|
+func (this *SupplyOrderApiController) DeletePurchOrder() {
|
|
1336
|
+
|
|
1337
|
+ id, _ := this.GetInt64("id")
|
|
1338
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1339
|
+ err := service.DeletePurchOrder(id, orgId)
|
|
1340
|
+ if err == nil {
|
|
1341
|
+ returnData := make(map[string]interface{}, 0)
|
|
1342
|
+ returnData["msg"] = "ok"
|
|
1343
|
+ this.ServeSuccessJSON(returnData)
|
|
1344
|
+ return
|
|
1345
|
+ } else {
|
|
1346
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1347
|
+ }
|
|
1348
|
+
|
|
1349
|
+}
|
|
1350
|
+
|
|
1351
|
+func (this *SupplyOrderApiController) GetAllOrderCountList() {
|
|
1352
|
+
|
|
1353
|
+ id, _ := this.GetInt64("id")
|
|
1354
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1355
|
+ //获取购货订单的数据
|
|
1356
|
+ purcaseOrder, _ := service.GetAllPurcaseOrderById(id, orgId)
|
|
1357
|
+ //获取购货单的数据
|
|
1358
|
+ goodOrder, err := service.GetAllGoodOrderById(id, orgId)
|
|
1359
|
+ drugList, err := service.GetSupplyDrugList(orgId)
|
|
1360
|
+ if err == nil {
|
|
1361
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1362
|
+ "purcaseOrder": purcaseOrder,
|
|
1363
|
+ "goodOrder": goodOrder,
|
|
1364
|
+ "drugList": drugList,
|
|
1365
|
+ })
|
|
1366
|
+ } else {
|
|
1367
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1368
|
+ }
|
|
1369
|
+}
|
|
1370
|
+
|
|
1371
|
+func (this *SupplyOrderApiController) GetPurchOrderInfo() {
|
|
1372
|
+ id, _ := this.GetInt64("id")
|
|
1373
|
+ ids := this.GetString("ids")
|
|
1374
|
+ if len(ids) == 0 {
|
|
1375
|
+ info, _ := service.GetPurchaseOrderDetail(id)
|
|
1376
|
+ //查询
|
|
1377
|
+ orderInfo, err := service.GetSupplyWarehousingOrderInfo(id)
|
|
1378
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1379
|
+ supplyList, _ := service.GetSupplierList(orgId)
|
|
1380
|
+ //获取药品库数据
|
|
1381
|
+ baseList, _ := service.GetSupplyDrugList(orgId)
|
|
1382
|
+
|
|
1383
|
+ goodList, _ := service.GetSupplyGoodList(orgId)
|
|
1384
|
+ if err == nil {
|
|
1385
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1386
|
+ "info": info,
|
|
1387
|
+ "orderInfo": orderInfo,
|
|
1388
|
+ "supplyList": supplyList,
|
|
1389
|
+ "baseList": baseList,
|
|
1390
|
+ "goodList": goodList,
|
|
1391
|
+ })
|
|
1392
|
+ } else {
|
|
1393
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1394
|
+ }
|
|
1395
|
+ }
|
|
1396
|
+ if len(ids) > 0 {
|
|
1397
|
+ idArray := strings.Split(ids, ",")
|
|
1398
|
+ info, _ := service.GetPurchaseOrderDetail(id)
|
|
1399
|
+ //查询
|
|
1400
|
+ orderInfo, err := service.GetSupplyWarehousingOrderInfoTwo(id, idArray)
|
|
1401
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1402
|
+ supplyList, _ := service.GetSupplierList(orgId)
|
|
1403
|
+ //获取药品库数据
|
|
1404
|
+ baseList, _ := service.GetSupplyDrugList(orgId)
|
|
1405
|
+
|
|
1406
|
+ goodList, _ := service.GetSupplyGoodList(orgId)
|
|
1407
|
+ if err == nil {
|
|
1408
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1409
|
+ "info": info,
|
|
1410
|
+ "orderInfo": orderInfo,
|
|
1411
|
+ "supplyList": supplyList,
|
|
1412
|
+ "baseList": baseList,
|
|
1413
|
+ "goodList": goodList,
|
|
1414
|
+ })
|
|
1415
|
+ } else {
|
|
1416
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1417
|
+ }
|
|
1418
|
+ }
|
|
1419
|
+}
|
|
1420
|
+
|
|
1421
|
+func (this *SupplyOrderApiController) GetGoodOrderList() {
|
|
1422
|
+
|
|
1423
|
+ id, _ := this.GetInt64("id")
|
|
1424
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1425
|
+ list, err := service.GetGoodOrderList(id, orgId)
|
|
1426
|
+ if err == nil {
|
|
1427
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1428
|
+ "list": list,
|
|
1429
|
+ })
|
|
1430
|
+ } else {
|
|
1431
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1432
|
+ }
|
|
1433
|
+}
|
|
1434
|
+
|
|
1435
|
+func (this *SupplyOrderApiController) GetReturnOrder() {
|
|
1436
|
+
|
|
1437
|
+ id, _ := this.GetInt64("id")
|
|
1438
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1439
|
+ err := service.GetReturnOrder(id, orgId)
|
|
1440
|
+ if err == nil {
|
|
1441
|
+ returnData := make(map[string]interface{}, 0)
|
|
1442
|
+ returnData["msg"] = "ok"
|
|
1443
|
+ this.ServeSuccessJSON(returnData)
|
|
1444
|
+ return
|
|
1445
|
+ } else {
|
|
1446
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1447
|
+ }
|
651
|
1448
|
}
|