소스 검색

耗材参数

XMLWAN 3 년 전
부모
커밋
2e84f47aa9

+ 17 - 4
controllers/drug_stock_api_contorller.go 파일 보기

@@ -592,6 +592,19 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
592 592
 				}
593 593
 				id := int64(items["id"].(float64))
594 594
 
595
+				if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "float64" {
596
+					utils.ErrorLog("dealer")
597
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
598
+					return
599
+				}
600
+				dealer := int64(items["dealer"].(float64))
601
+
602
+				if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "float64" {
603
+					utils.ErrorLog("manufacturer")
604
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
605
+					return
606
+				}
607
+				manufacturer := int64(items["manufacturer"].(float64))
595 608
 				if id == 0 {
596 609
 					warehouseInfo := &models.DrugWarehouseInfo{
597 610
 						WarehousingOrder: warehouse.WarehousingOrder,
@@ -608,8 +621,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
608 621
 						Remark:           remark,
609 622
 						OrgId:            adminUserInfo.CurrentOrgId,
610 623
 						Type:             types,
611
-						Manufacturer:     manufacturer_id,
612
-						Dealer:           dealer_id,
624
+						Manufacturer:     manufacturer,
625
+						Dealer:           dealer,
613 626
 						RetailPrice:      retail_price,
614 627
 						RetailTotalPrice: retail_price_total,
615 628
 					}
@@ -632,8 +645,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
632 645
 						Remark:           remark,
633 646
 						OrgId:            adminUserInfo.CurrentOrgId,
634 647
 						Type:             types,
635
-						Manufacturer:     manufacturer_id,
636
-						Dealer:           dealer_id,
648
+						Manufacturer:     manufacturer,
649
+						Dealer:           dealer,
637 650
 						RetailPrice:      retail_price,
638 651
 						RetailTotalPrice: retail_price_total,
639 652
 					}

+ 97 - 0
controllers/gobal_config_api_controller.go 파일 보기

@@ -79,6 +79,12 @@ func GobalConfigRegistRouters() {
79 79
 	beego.Router("/api/drugstock/getdrugoutdetail", &GobalConfigApiController{}, "get:GetDrugOutDetail")
80 80
 
81 81
 	beego.Router("/api/drugstock/getdrugcanceldetail", &GobalConfigApiController{}, "get:GetDrugCancelDetail")
82
+
83
+	beego.Router("/api/monitor/open", &GobalConfigApiController{}, "get:AddMonitorOpen")
84
+	beego.Router("/api/monitor/getmonitorconfig", &GobalConfigApiController{}, "Get:GetMonitorConfig")
85
+	beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
86
+	beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
87
+
82 88
 }
83 89
 
84 90
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1603,3 +1609,94 @@ func (c *GobalConfigApiController) GetDrugCancelDetail() {
1603 1609
 		"total": total,
1604 1610
 	})
1605 1611
 }
1612
+
1613
+func (c *GobalConfigApiController) AddMonitorOpen() {
1614
+
1615
+	is_open, _ := c.GetInt64("is_open")
1616
+	fmt.Println("is_open22222222", is_open)
1617
+	adminUserInfo := c.GetAdminUserInfo()
1618
+	orgId := adminUserInfo.CurrentOrgId
1619
+	config := models.XtMonitorConfig{
1620
+		IsOpen:    is_open,
1621
+		UserOrgId: orgId,
1622
+		Status:    1,
1623
+		Ctime:     time.Now().Unix(),
1624
+	}
1625
+	//查询该机构是否存在
1626
+	_, errcode := service.GetMonitorConfigById(orgId)
1627
+	if errcode == gorm.ErrRecordNotFound {
1628
+		err := service.AddMonitorOpen(&config)
1629
+		if err != nil {
1630
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1631
+			return
1632
+		}
1633
+		c.ServeSuccessJSON(map[string]interface{}{
1634
+			"config": config,
1635
+		})
1636
+	} else if errcode == nil {
1637
+		err := service.UpdateMonitorOpen(orgId, &config)
1638
+		fmt.Println("err", err)
1639
+	}
1640
+
1641
+}
1642
+
1643
+func (c *GobalConfigApiController) GetMonitorConfig() {
1644
+
1645
+	userInfo := c.GetAdminUserInfo()
1646
+	orgId := userInfo.CurrentOrgId
1647
+
1648
+	config, err := service.GetMonitorConfig(orgId)
1649
+	if err != nil {
1650
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1651
+		return
1652
+	}
1653
+	c.ServeSuccessJSON(map[string]interface{}{
1654
+		"config": config,
1655
+	})
1656
+
1657
+}
1658
+
1659
+func (c *GobalConfigApiController) AddOrderConfig() {
1660
+
1661
+	is_open, _ := c.GetInt64("is_open")
1662
+	fmt.Println("344555555555555", is_open)
1663
+	adminUserInfo := c.GetAdminUserInfo()
1664
+	orgId := adminUserInfo.CurrentOrgId
1665
+	config := models.XtOrderConfig{
1666
+		IsOpen:    is_open,
1667
+		UserOrgId: orgId,
1668
+		Status:    1,
1669
+		Ctime:     time.Now().Unix(),
1670
+	}
1671
+	//查询
1672
+	_, errcode := service.GetOrderConfigById(orgId)
1673
+	if errcode == gorm.ErrRecordNotFound {
1674
+		err := service.AddOrderConfig(&config)
1675
+		if err != nil {
1676
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1677
+			return
1678
+		}
1679
+		c.ServeSuccessJSON(map[string]interface{}{
1680
+			"config": config,
1681
+		})
1682
+	} else if errcode == nil {
1683
+
1684
+		err := service.UpdateOrderConfig(orgId, &config)
1685
+		fmt.Println("2222", err)
1686
+	}
1687
+
1688
+}
1689
+
1690
+func (c *GobalConfigApiController) GetOrderConfig() {
1691
+
1692
+	adminUserInfo := c.GetAdminUserInfo()
1693
+	orgId := adminUserInfo.CurrentOrgId
1694
+	config, err := service.GetOrderConfig(orgId)
1695
+	if err != nil {
1696
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1697
+		return
1698
+	}
1699
+	c.ServeSuccessJSON(map[string]interface{}{
1700
+		"config": config,
1701
+	})
1702
+}

+ 192 - 0
controllers/his_api_controller.go 파일 보기

@@ -84,6 +84,7 @@ func HisManagerApiRegistRouters() {
84 84
 
85 85
 	//beego.Router("/api/export/template", &HisApiController{}, "get:ExportOrderTemplate")
86 86
 
87
+	beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
87 88
 }
88 89
 
89 90
 func (c *HisApiController) Sscard() {
@@ -2803,3 +2804,194 @@ func (c *HisApiController) GetPutOnRecordList() {
2803 2804
 //
2804 2805
 //
2805 2806
 //}
2807
+
2808
+func (c *HisApiController) PostProjectInformation() {
2809
+
2810
+	dataBody := make(map[string]interface{}, 0)
2811
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
2812
+	if err != nil {
2813
+		utils.ErrorLog(err.Error())
2814
+		return
2815
+	}
2816
+	utils.ErrorLog("%v", dataBody)
2817
+	var projectList []*models.HisProject
2818
+	var total_goods []interface{}
2819
+	tempProjects := dataBody["projects"].([]interface{})
2820
+
2821
+	total_goods = tempProjects
2822
+	for index, projectMap := range tempProjects {
2823
+
2824
+		projectM := projectMap.(map[string]interface{})
2825
+
2826
+		var project models.HisProject
2827
+		if projectM["project_name"] == nil || reflect.TypeOf(projectM["project_name"]).String() != "string" {
2828
+			utils.ErrorLog("project_name")
2829
+			return
2830
+		}
2831
+
2832
+		project_name, _ := projectM["project_name"].(string)
2833
+		if len(project_name) == 0 { //名字为空则生成一条导入错误日志
2834
+			err_log := models.ExportErrLog{
2835
+				LogType:    6,
2836
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2837
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的项目名称不能为空",
2838
+				Status:     1,
2839
+				CreateTime: time.Now().Unix(),
2840
+				UpdateTime: time.Now().Unix(),
2841
+				ExportTime: time.Now().Unix(),
2842
+			}
2843
+			service.CreateExportErrLog(&err_log)
2844
+			continue
2845
+		}
2846
+
2847
+		project.ProjectName = project_name
2848
+
2849
+		price := projectM["price"].(float64)
2850
+
2851
+		if price <= 0 { //名字为空则生成一条导入错误日志
2852
+			err_log := models.ExportErrLog{
2853
+				LogType:    6,
2854
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2855
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的零价不能为空",
2856
+				Status:     1,
2857
+				CreateTime: time.Now().Unix(),
2858
+				UpdateTime: time.Now().Unix(),
2859
+				ExportTime: time.Now().Unix(),
2860
+			}
2861
+			service.CreateExportErrLog(&err_log)
2862
+			continue
2863
+		}
2864
+
2865
+		project.Price = price
2866
+
2867
+		if projectM["unit"] == nil || reflect.TypeOf(projectM["unit"]).String() != "string" {
2868
+			utils.ErrorLog("unit_id")
2869
+			return
2870
+		}
2871
+
2872
+		unit := projectM["unit"].(string)
2873
+		if len(unit) == 0 { //名字为空则生成一条导入错误日志
2874
+			err_log := models.ExportErrLog{
2875
+				LogType:    6,
2876
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2877
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空",
2878
+				Status:     1,
2879
+				CreateTime: time.Now().Unix(),
2880
+				UpdateTime: time.Now().Unix(),
2881
+				ExportTime: time.Now().Unix(),
2882
+			}
2883
+			service.CreateExportErrLog(&err_log)
2884
+			continue
2885
+		}
2886
+		project.Unit = unit
2887
+
2888
+		if projectM["cost_classify_id"] == nil || reflect.TypeOf(projectM["cost_classify_id"]).String() != "float64" {
2889
+			utils.ErrorLog("cost_classify_id")
2890
+			return
2891
+		}
2892
+
2893
+		cost_classify_id := int64(projectM["cost_classify_id"].(float64))
2894
+		if cost_classify_id <= 0 { //名字为空则生成一条导入错误日志
2895
+			err_log := models.ExportErrLog{
2896
+				LogType:    6,
2897
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2898
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
2899
+				Status:     1,
2900
+				CreateTime: time.Now().Unix(),
2901
+				UpdateTime: time.Now().Unix(),
2902
+				ExportTime: time.Now().Unix(),
2903
+			}
2904
+			service.CreateExportErrLog(&err_log)
2905
+			continue
2906
+		}
2907
+		project.CostClassify = cost_classify_id
2908
+		executive_section_id := int64(projectM["executive_section_id"].(float64))
2909
+		if executive_section_id <= 0 { //名字为空则生成一条导入错误日志
2910
+			err_log := models.ExportErrLog{
2911
+				LogType:    6,
2912
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2913
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
2914
+				Status:     1,
2915
+				CreateTime: time.Now().Unix(),
2916
+				UpdateTime: time.Now().Unix(),
2917
+				ExportTime: time.Now().Unix(),
2918
+			}
2919
+			service.CreateExportErrLog(&err_log)
2920
+			continue
2921
+		}
2922
+
2923
+		project.ExecutiveSection = executive_section_id
2924
+
2925
+		if projectM["medical_insurance_level_id"] == nil || reflect.TypeOf(projectM["medical_insurance_level_id"]).String() != "float64" {
2926
+			utils.ErrorLog("medical_insurance_level_id")
2927
+			return
2928
+		}
2929
+
2930
+		medical_insurance_level_id := int64(projectM["medical_insurance_level_id"].(float64))
2931
+		if executive_section_id <= 0 { //名字为空则生成一条导入错误日志
2932
+			err_log := models.ExportErrLog{
2933
+				LogType:    6,
2934
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2935
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
2936
+				Status:     1,
2937
+				CreateTime: time.Now().Unix(),
2938
+				UpdateTime: time.Now().Unix(),
2939
+				ExportTime: time.Now().Unix(),
2940
+			}
2941
+			service.CreateExportErrLog(&err_log)
2942
+			continue
2943
+		}
2944
+
2945
+		project.MedicalCoverage = medical_insurance_level_id
2946
+
2947
+		projectList = append(projectList, &project)
2948
+	}
2949
+	adminUser := c.GetAdminUserInfo()
2950
+	orgId := adminUser.CurrentOrgId
2951
+	export_time := time.Now().Unix()
2952
+	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
2953
+	if len(projectList) > 0 {
2954
+		for _, item := range projectList {
2955
+			service.CreateProjectInfomation(item, orgId)
2956
+
2957
+			log := models.ExportLog{
2958
+				LogType:    6,
2959
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2960
+				TotalNum:   int64(len(total_goods)),
2961
+				FailNum:    int64(len(errLogs)),
2962
+				SuccessNum: int64(len(projectList)),
2963
+				CreateTime: time.Now().Unix(),
2964
+				UpdateTime: time.Now().Unix(),
2965
+				ExportTime: export_time,
2966
+				Status:     1,
2967
+			}
2968
+			service.CreateExportLog(&log)
2969
+			c.ServeSuccessJSON(map[string]interface{}{
2970
+				"msg":         "导入成功",
2971
+				"total_num":   len(total_goods),
2972
+				"success_num": len(projectList),
2973
+				"fail_num":    int64(len(errLogs)),
2974
+			})
2975
+		}
2976
+	} else {
2977
+		log := models.ExportLog{
2978
+			LogType:    6,
2979
+			UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2980
+			TotalNum:   int64(len(total_goods)),
2981
+			FailNum:    int64(len(errLogs)),
2982
+			SuccessNum: int64(len(projectList)),
2983
+			CreateTime: time.Now().Unix(),
2984
+			UpdateTime: time.Now().Unix(),
2985
+			ExportTime: export_time,
2986
+			Status:     1,
2987
+		}
2988
+		service.CreateExportLog(&log)
2989
+
2990
+		c.ServeSuccessJSON(map[string]interface{}{
2991
+			"msg":         "导入成功",
2992
+			"total_num":   len(total_goods),
2993
+			"success_num": len(projectList),
2994
+			"fail_num":    int64(len(errLogs)),
2995
+		})
2996
+	}
2997
+}

+ 654 - 10
controllers/stock_in_api_controller.go 파일 보기

@@ -69,6 +69,8 @@ func StockManagerApiRegistRouters() {
69 69
 	beego.Router("/api/warehouseout/getoutstocktotalcount", &StockManagerApiController{}, "Get:GetOutStockTotalCount")
70 70
 
71 71
 	beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
72
+
73
+	beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
72 74
 }
73 75
 
74 76
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -1247,9 +1249,13 @@ func (c *StockManagerApiController) GetWarehouseOutInfoList() {
1247 1249
 	id, _ := c.GetInt64("id", 0)
1248 1250
 	warehouseOutInfo, _ := service.FindWarehouseOutInfoById(id)
1249 1251
 	warehouseOut, _ := service.FindWareHouseOutById(id)
1252
+	adminUserInfo := c.GetAdminUserInfo()
1253
+	orgId := adminUserInfo.CurrentOrgId
1254
+	wareoutList, _ := service.GetWareOutInfoById(id, orgId)
1250 1255
 	c.ServeSuccessJSON(map[string]interface{}{
1251
-		"list": warehouseOutInfo,
1252
-		"info": warehouseOut,
1256
+		"list":        warehouseOutInfo,
1257
+		"info":        warehouseOut,
1258
+		"wareoutList": wareoutList,
1253 1259
 	})
1254 1260
 
1255 1261
 }
@@ -2010,14 +2016,16 @@ func (this *StockManagerApiController) AddGoodInformation() {
2010 2016
 		return
2011 2017
 	}
2012 2018
 	utils.ErrorLog("%v", dataBody)
2013
-
2019
+	var goods []*models.GoodInfo
2020
+	var total_goods []interface{}
2014 2021
 	tempGoods := dataBody["goods"].([]interface{})
2015 2022
 	fmt.Println("3333333333", tempGoods)
2016
-	var goods []*models.GoodInfo
2023
+	total_goods = tempGoods
2017 2024
 	for index, goodMap := range tempGoods {
2018 2025
 		goodNameM := goodMap.(map[string]interface{})
2019 2026
 		fmt.Println("00000", goodNameM)
2020 2027
 		var good models.GoodInfo
2028
+
2021 2029
 		if goodNameM["good_name"] == nil || reflect.TypeOf(goodNameM["good_name"]).String() != "string" {
2022 2030
 			utils.ErrorLog("good_name")
2023 2031
 			return
@@ -2039,24 +2047,660 @@ func (this *StockManagerApiController) AddGoodInformation() {
2039 2047
 		}
2040 2048
 		fmt.Println("33333333", good_name)
2041 2049
 		good.GoodName = good_name
2042
-		if goodNameM["medical_insurance_level"] == nil || reflect.TypeOf(goodNameM["medical_insurance_level"]).String() != "string" {
2043
-			utils.ErrorLog("medical_insurance_level")
2050
+
2051
+		if goodNameM["good_kind_id"] == nil || reflect.TypeOf(goodNameM["good_kind_id"]).String() != "float64" {
2052
+			utils.ErrorLog("good_kind_id")
2053
+			return
2054
+		}
2055
+
2056
+		good_kind := int64(goodNameM["good_kind_id"].(float64))
2057
+		if good_kind <= 0 { //名字为空则生成一条导入错误日志
2058
+			err_log := models.ExportErrLog{
2059
+				LogType:    5,
2060
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2061
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的耗材种类不能为空",
2062
+				Status:     1,
2063
+				CreateTime: time.Now().Unix(),
2064
+				UpdateTime: time.Now().Unix(),
2065
+				ExportTime: time.Now().Unix(),
2066
+			}
2067
+			service.CreateExportErrLog(&err_log)
2068
+			continue
2069
+		}
2070
+		fmt.Println("33333333", good_kind)
2071
+		good.GoodKind = good_kind
2072
+
2073
+		if goodNameM["good_type_id"] == nil || reflect.TypeOf(goodNameM["good_type_id"]).String() != "float64" {
2074
+			utils.ErrorLog("good_type_id")
2075
+			return
2076
+		}
2077
+
2078
+		good_type := int64(goodNameM["good_type_id"].(float64))
2079
+
2080
+		if good_type <= 0 { //名字为空则生成一条导入错误日志
2081
+			err_log := models.ExportErrLog{
2082
+				LogType:    5,
2083
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2084
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的耗材类型不能为空",
2085
+				Status:     1,
2086
+				CreateTime: time.Now().Unix(),
2087
+				UpdateTime: time.Now().Unix(),
2088
+				ExportTime: time.Now().Unix(),
2089
+			}
2090
+			service.CreateExportErrLog(&err_log)
2091
+			continue
2092
+		}
2093
+		fmt.Println("33333333", good_type)
2094
+		good.GoodTypeId = good_type
2095
+
2096
+		if goodNameM["medical_insurance_id"] == nil || reflect.TypeOf(goodNameM["medical_insurance_id"]).String() != "float64" {
2097
+			utils.ErrorLog("medical_insurance_id")
2098
+			return
2099
+		}
2100
+		medical_insurance_id := int64(goodNameM["medical_insurance_id"].(float64))
2101
+		if medical_insurance_id < 0 { //名字为空则生成一条导入错误日志
2102
+			err_log := models.ExportErrLog{
2103
+				LogType:    5,
2104
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2105
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2106
+				Status:     1,
2107
+				CreateTime: time.Now().Unix(),
2108
+				UpdateTime: time.Now().Unix(),
2109
+				ExportTime: time.Now().Unix(),
2110
+			}
2111
+			service.CreateExportErrLog(&err_log)
2112
+			continue
2113
+		}
2114
+		good.MedicalInsuranceLevel = medical_insurance_id
2115
+
2116
+		if goodNameM["specification_name"] == nil || reflect.TypeOf(goodNameM["specification_name"]).String() != "string" {
2117
+			utils.ErrorLog("specification_name")
2118
+			return
2119
+		}
2120
+		specification_name := goodNameM["specification_name"].(string)
2121
+		if len(specification_name) == 0 { //名字为空则生成一条导入错误日志
2122
+			err_log := models.ExportErrLog{
2123
+				LogType:    5,
2124
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2125
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "规格型号不能为空",
2126
+				Status:     1,
2127
+				CreateTime: time.Now().Unix(),
2128
+				UpdateTime: time.Now().Unix(),
2129
+				ExportTime: time.Now().Unix(),
2130
+			}
2131
+			service.CreateExportErrLog(&err_log)
2132
+			continue
2133
+		}
2134
+
2135
+		good.SpecificationName = specification_name
2136
+
2137
+		if goodNameM["manufacturer_id"] == nil || reflect.TypeOf(goodNameM["manufacturer_id"]).String() != "float64" {
2138
+			utils.ErrorLog("manufacturer_id")
2139
+			return
2140
+		}
2141
+
2142
+		manufacturer_id := int64(goodNameM["manufacturer_id"].(float64))
2143
+		if manufacturer_id <= 0 { //名字为空则生成一条导入错误日志
2144
+			err_log := models.ExportErrLog{
2145
+				LogType:    5,
2146
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2147
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的生产厂商不能为空",
2148
+				Status:     1,
2149
+				CreateTime: time.Now().Unix(),
2150
+				UpdateTime: time.Now().Unix(),
2151
+				ExportTime: time.Now().Unix(),
2152
+			}
2153
+			service.CreateExportErrLog(&err_log)
2154
+			continue
2155
+		}
2156
+		fmt.Println("33333333", manufacturer_id)
2157
+		good.Manufacturer = manufacturer_id
2158
+
2159
+		if goodNameM["unit_id"] == nil || reflect.TypeOf(goodNameM["unit_id"]).String() != "float64" {
2160
+			utils.ErrorLog("unit_id")
2161
+			return
2162
+		}
2163
+
2164
+		unit_id := int64(goodNameM["unit_id"].(float64))
2165
+		if unit_id > 0 { //名字为空则生成一条导入错误日志
2166
+			err_log := models.ExportErrLog{
2167
+				LogType:    5,
2168
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2169
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空",
2170
+				Status:     1,
2171
+				CreateTime: time.Now().Unix(),
2172
+				UpdateTime: time.Now().Unix(),
2173
+				ExportTime: time.Now().Unix(),
2174
+			}
2175
+			service.CreateExportErrLog(&err_log)
2176
+			continue
2177
+		}
2178
+		fmt.Println("33333333", unit_id)
2179
+		good.GoodUnit = unit_id
2180
+
2181
+		if goodNameM["retail_price"] == nil || reflect.TypeOf(goodNameM["retail_price"]).String() != "float64" {
2182
+			utils.ErrorLog("retail_price")
2183
+			return
2184
+		}
2185
+
2186
+		retail_price := goodNameM["retail_price"].(float64)
2187
+		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2188
+			err_log := models.ExportErrLog{
2189
+				LogType:    5,
2190
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2191
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的价格不能为空",
2192
+				Status:     1,
2193
+				CreateTime: time.Now().Unix(),
2194
+				UpdateTime: time.Now().Unix(),
2195
+				ExportTime: time.Now().Unix(),
2196
+			}
2197
+			service.CreateExportErrLog(&err_log)
2198
+			continue
2199
+		}
2200
+		fmt.Println("33333333", retail_price)
2201
+		good.RetailPrice = retail_price
2202
+
2203
+		if goodNameM["stock_warn_count"] == nil || reflect.TypeOf(goodNameM["stock_warn_count"]).String() != "float64" {
2204
+			utils.ErrorLog("stock_warn_count")
2205
+			return
2206
+		}
2207
+
2208
+		stock_warn_count := int64(goodNameM["stock_warn_count"].(float64))
2209
+		if stock_warn_count > 0 { //名字为空则生成一条导入错误日志
2210
+			err_log := models.ExportErrLog{
2211
+				LogType:    5,
2212
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2213
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的库存警戒不能为空",
2214
+				Status:     1,
2215
+				CreateTime: time.Now().Unix(),
2216
+				UpdateTime: time.Now().Unix(),
2217
+				ExportTime: time.Now().Unix(),
2218
+			}
2219
+			service.CreateExportErrLog(&err_log)
2220
+			continue
2221
+		}
2222
+		fmt.Println("33333333", stock_warn_count)
2223
+		good.StockWarnCount = stock_warn_count
2224
+
2225
+		if goodNameM["dealer_id"] == nil || reflect.TypeOf(goodNameM["dealer_id"]).String() != "float64" {
2226
+			utils.ErrorLog("dealer_id")
2227
+			return
2228
+		}
2229
+
2230
+		dealer_id := int64(goodNameM["dealer_id"].(float64))
2231
+		if dealer_id <= 0 { //名字为空则生成一条导入错误日志
2232
+			err_log := models.ExportErrLog{
2233
+				LogType:    5,
2234
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2235
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的经销商不能为空",
2236
+				Status:     1,
2237
+				CreateTime: time.Now().Unix(),
2238
+				UpdateTime: time.Now().Unix(),
2239
+				ExportTime: time.Now().Unix(),
2240
+			}
2241
+			service.CreateExportErrLog(&err_log)
2242
+			continue
2243
+		}
2244
+		fmt.Println("33333333", dealer_id)
2245
+		good.Dealer = dealer_id
2246
+
2247
+		if goodNameM["pinyin"] == nil || reflect.TypeOf(goodNameM["pinyin"]).String() != "string" {
2248
+			utils.ErrorLog("pinyin")
2249
+			return
2250
+		}
2251
+		pinyin := goodNameM["pinyin"].(string)
2252
+
2253
+		good.Pinyin = pinyin
2254
+
2255
+		if goodNameM["wubi"] == nil || reflect.TypeOf(goodNameM["wubi"]).String() != "string" {
2256
+			utils.ErrorLog("wubi")
2257
+			return
2258
+		}
2259
+		wubi := goodNameM["wubi"].(string)
2260
+
2261
+		good.Pinyin = wubi
2262
+
2263
+		if goodNameM["buy_price"] == nil || reflect.TypeOf(goodNameM["buy_price"]).String() != "float64" {
2264
+			utils.ErrorLog("buy_price")
2265
+			return
2266
+		}
2267
+
2268
+		buy_price := goodNameM["buy_price"].(float64)
2269
+		good.BuyPrice = buy_price
2270
+
2271
+		if goodNameM["social_security_directory_code"] == nil || reflect.TypeOf(goodNameM["social_security_directory_code"]).String() != "string" {
2272
+			utils.ErrorLog("social_security_directory_code")
2273
+			return
2274
+		}
2275
+		social_security_directory_code := goodNameM["social_security_directory_code"].(string)
2276
+
2277
+		good.SocialSecurityDirectoryCode = social_security_directory_code
2278
+
2279
+		if goodNameM["is_special_diseases"] == nil || reflect.TypeOf(goodNameM["is_special_diseases"]).String() != "float64" {
2280
+			utils.ErrorLog("is_special_diseases")
2281
+			return
2282
+		}
2283
+
2284
+		is_special_diseases := int64(goodNameM["is_special_diseases"].(float64))
2285
+		good.IsSpecialDiseases = is_special_diseases
2286
+
2287
+		if goodNameM["is_record"] == nil || reflect.TypeOf(goodNameM["is_record"]).String() != "float64" {
2288
+			utils.ErrorLog("is_record")
2289
+			return
2290
+		}
2291
+
2292
+		is_record := int64(goodNameM["is_record"].(float64))
2293
+		good.IsRecord = is_record
2294
+
2295
+		if goodNameM["good_status"] == nil || reflect.TypeOf(goodNameM["good_status"]).String() != "string" {
2296
+			utils.ErrorLog("good_status")
2297
+			return
2298
+		}
2299
+		good_status := goodNameM["good_status"].(string)
2300
+		good.GoodStatus = good_status
2301
+
2302
+		if goodNameM["medical_insurance_number"] == nil || reflect.TypeOf(goodNameM["medical_insurance_number"]).String() != "string" {
2303
+			utils.ErrorLog("medical_insurance_number")
2304
+			return
2305
+		}
2306
+		medical_insurance_number := goodNameM["medical_insurance_number"].(string)
2307
+		good.MedicalInsuranceNumber = medical_insurance_number
2308
+
2309
+		if goodNameM["production_type"] == nil || reflect.TypeOf(goodNameM["production_type"]).String() != "string" {
2310
+			utils.ErrorLog("production_type")
2044 2311
 			return
2045 2312
 		}
2046
-		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2047
-		medical_insurance_levels, _ := strconv.ParseInt(medical_insurance_level, 10, 64)
2048
-		good.MedicalInsuranceLevel = medical_insurance_levels
2313
+		production_type := goodNameM["production_type"].(string)
2314
+		good.ProductionType = production_type
2315
+
2316
+		if goodNameM["remark"] == nil || reflect.TypeOf(goodNameM["remark"]).String() != "string" {
2317
+			utils.ErrorLog("remark")
2318
+			return
2319
+		}
2320
+		remark := goodNameM["remark"].(string)
2321
+		good.Remark = remark
2049 2322
 
2050 2323
 		goods = append(goods, &good)
2051 2324
 	}
2052 2325
 	adminUser := this.GetAdminUserInfo()
2053 2326
 	orgId := adminUser.CurrentOrgId
2327
+	export_time := time.Now().Unix()
2328
+	errLogs, _ := service.FindPatientExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
2054 2329
 	if len(goods) > 0 {
2055 2330
 		for _, item := range goods {
2056 2331
 			service.CreateGoodsInfomation(item, orgId)
2332
+
2333
+			log := models.ExportLog{
2334
+				LogType:    1,
2335
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2336
+				TotalNum:   int64(len(total_goods)),
2337
+				FailNum:    int64(len(errLogs)),
2338
+				SuccessNum: int64(len(goods)),
2339
+				CreateTime: time.Now().Unix(),
2340
+				UpdateTime: time.Now().Unix(),
2341
+				ExportTime: export_time,
2342
+				Status:     1,
2343
+			}
2344
+			service.CreateExportLog(&log)
2057 2345
 			this.ServeSuccessJSON(map[string]interface{}{
2058
-				"msg": "导入成功",
2346
+				"msg":         "导入成功",
2347
+				"total_num":   len(total_goods),
2348
+				"success_num": len(goods),
2349
+				"fail_num":    int64(len(errLogs)),
2059 2350
 			})
2060 2351
 		}
2061 2352
 	}
2062 2353
 }
2354
+
2355
+func (this *StockManagerApiController) AddDrugInformation() {
2356
+	dataBody := make(map[string]interface{}, 0)
2357
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
2358
+	if err != nil {
2359
+		utils.ErrorLog(err.Error())
2360
+		return
2361
+	}
2362
+	utils.ErrorLog("%v", dataBody)
2363
+	var drugList []*models.BaseDrugLib
2364
+	var total_goods []interface{}
2365
+	tempDrugs := dataBody["drugs"].([]interface{})
2366
+
2367
+	total_goods = tempDrugs
2368
+	for index, drugMap := range tempDrugs {
2369
+		goodNameM := drugMap.(map[string]interface{})
2370
+		var drug models.BaseDrugLib
2371
+		if goodNameM["drug_name"] == nil || reflect.TypeOf(goodNameM["drug_name"]).String() != "string" {
2372
+			utils.ErrorLog("drug_name")
2373
+			return
2374
+		}
2375
+
2376
+		drug_name, _ := goodNameM["drug_name"].(string)
2377
+		if len(drug_name) == 0 { //名字为空则生成一条导入错误日志
2378
+			err_log := models.ExportErrLog{
2379
+				LogType:    4,
2380
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2381
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的药品名称不能为空",
2382
+				Status:     1,
2383
+				CreateTime: time.Now().Unix(),
2384
+				UpdateTime: time.Now().Unix(),
2385
+				ExportTime: time.Now().Unix(),
2386
+			}
2387
+			service.CreateExportErrLog(&err_log)
2388
+			continue
2389
+		}
2390
+
2391
+		drug.DrugName = drug_name
2392
+
2393
+		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
2394
+			utils.ErrorLog("drug_alias")
2395
+			return
2396
+		}
2397
+
2398
+		drug_alias, _ := goodNameM["drug_alias"].(string)
2399
+		if len(drug_alias) == 0 { //名字为空则生成一条导入错误日志
2400
+			err_log := models.ExportErrLog{
2401
+				LogType:    4,
2402
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2403
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的药品别名不能为空",
2404
+				Status:     1,
2405
+				CreateTime: time.Now().Unix(),
2406
+				UpdateTime: time.Now().Unix(),
2407
+				ExportTime: time.Now().Unix(),
2408
+			}
2409
+			service.CreateExportErrLog(&err_log)
2410
+			continue
2411
+		}
2412
+
2413
+		drug.DrugAlias = drug_alias
2414
+
2415
+		drug_spec, _ := goodNameM["drug_spec"].(string)
2416
+		if len(drug_spec) == 0 { //名字为空则生成一条导入错误日志
2417
+			err_log := models.ExportErrLog{
2418
+				LogType:    4,
2419
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2420
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的药品规格不能为空",
2421
+				Status:     1,
2422
+				CreateTime: time.Now().Unix(),
2423
+				UpdateTime: time.Now().Unix(),
2424
+				ExportTime: time.Now().Unix(),
2425
+			}
2426
+			service.CreateExportErrLog(&err_log)
2427
+			continue
2428
+		}
2429
+
2430
+		drug.DrugSpec = drug_spec
2431
+
2432
+		drug_type_id := int64(goodNameM["drug_type_id"].(float64))
2433
+		if drug_type_id <= 0 { //名字为空则生成一条导入错误日志
2434
+			err_log := models.ExportErrLog{
2435
+				LogType:    4,
2436
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2437
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的药品规格不能为空",
2438
+				Status:     1,
2439
+				CreateTime: time.Now().Unix(),
2440
+				UpdateTime: time.Now().Unix(),
2441
+				ExportTime: time.Now().Unix(),
2442
+			}
2443
+			service.CreateExportErrLog(&err_log)
2444
+			continue
2445
+		}
2446
+
2447
+		drug.DrugType = drug_type_id
2448
+
2449
+		drug_stock_limit, _ := goodNameM["drug_stock_limit"].(string)
2450
+		if len(drug_stock_limit) == 0 { //名字为空则生成一条导入错误日志
2451
+			err_log := models.ExportErrLog{
2452
+				LogType:    4,
2453
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2454
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的药品规格不能为空",
2455
+				Status:     1,
2456
+				CreateTime: time.Now().Unix(),
2457
+				UpdateTime: time.Now().Unix(),
2458
+				ExportTime: time.Now().Unix(),
2459
+			}
2460
+			service.CreateExportErrLog(&err_log)
2461
+			continue
2462
+		}
2463
+
2464
+		drug.DrugStockLimit = drug_stock_limit
2465
+
2466
+		drug_origin_place, _ := goodNameM["drug_origin_place"].(string)
2467
+		if len(drug_origin_place) == 0 { //名字为空则生成一条导入错误日志
2468
+			err_log := models.ExportErrLog{
2469
+				LogType:    4,
2470
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2471
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的产地不能为空",
2472
+				Status:     1,
2473
+				CreateTime: time.Now().Unix(),
2474
+				UpdateTime: time.Now().Unix(),
2475
+				ExportTime: time.Now().Unix(),
2476
+			}
2477
+			service.CreateExportErrLog(&err_log)
2478
+			continue
2479
+		}
2480
+
2481
+		drug.DrugOriginPlace = drug_origin_place
2482
+
2483
+		drug_dosage_form_id := int64(goodNameM["drug_dosage_form_id"].(float64))
2484
+		if drug_dosage_form_id <= 0 { //名字为空则生成一条导入错误日志
2485
+			err_log := models.ExportErrLog{
2486
+				LogType:    4,
2487
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2488
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的药品剂型不能为空",
2489
+				Status:     1,
2490
+				CreateTime: time.Now().Unix(),
2491
+				UpdateTime: time.Now().Unix(),
2492
+				ExportTime: time.Now().Unix(),
2493
+			}
2494
+			service.CreateExportErrLog(&err_log)
2495
+			continue
2496
+		}
2497
+
2498
+		drug.DrugDosageForm = drug_dosage_form_id
2499
+
2500
+		medical_insurance_level_id := int64(goodNameM["medical_insurance_level_id"].(float64))
2501
+		if medical_insurance_level_id <= 0 { //名字为空则生成一条导入错误日志
2502
+			err_log := models.ExportErrLog{
2503
+				LogType:    4,
2504
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2505
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2506
+				Status:     1,
2507
+				CreateTime: time.Now().Unix(),
2508
+				UpdateTime: time.Now().Unix(),
2509
+				ExportTime: time.Now().Unix(),
2510
+			}
2511
+			service.CreateExportErrLog(&err_log)
2512
+			continue
2513
+		}
2514
+
2515
+		drug.MedicalInsuranceLevel = medical_insurance_level_id
2516
+
2517
+		max_unit_id := goodNameM["max_unit"].(string)
2518
+		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2519
+			err_log := models.ExportErrLog{
2520
+				LogType:    4,
2521
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2522
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2523
+				Status:     1,
2524
+				CreateTime: time.Now().Unix(),
2525
+				UpdateTime: time.Now().Unix(),
2526
+				ExportTime: time.Now().Unix(),
2527
+			}
2528
+			service.CreateExportErrLog(&err_log)
2529
+			continue
2530
+		}
2531
+
2532
+		drug.MaxUnit = max_unit_id
2533
+
2534
+		min_unit := goodNameM["min_unit"].(string)
2535
+		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2536
+			err_log := models.ExportErrLog{
2537
+				LogType:    4,
2538
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2539
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2540
+				Status:     1,
2541
+				CreateTime: time.Now().Unix(),
2542
+				UpdateTime: time.Now().Unix(),
2543
+				ExportTime: time.Now().Unix(),
2544
+			}
2545
+			service.CreateExportErrLog(&err_log)
2546
+			continue
2547
+		}
2548
+
2549
+		drug.MinUnit = min_unit
2550
+
2551
+		unit_matrixing := goodNameM["unit_matrixing"].(string)
2552
+		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2553
+			err_log := models.ExportErrLog{
2554
+				LogType:    4,
2555
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2556
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2557
+				Status:     1,
2558
+				CreateTime: time.Now().Unix(),
2559
+				UpdateTime: time.Now().Unix(),
2560
+				ExportTime: time.Now().Unix(),
2561
+			}
2562
+			service.CreateExportErrLog(&err_log)
2563
+			continue
2564
+		}
2565
+
2566
+		drug.UnitMatrixing = unit_matrixing
2567
+
2568
+		retail_price := goodNameM["retail_price"].(float64)
2569
+		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2570
+			err_log := models.ExportErrLog{
2571
+				LogType:    4,
2572
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2573
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2574
+				Status:     1,
2575
+				CreateTime: time.Now().Unix(),
2576
+				UpdateTime: time.Now().Unix(),
2577
+				ExportTime: time.Now().Unix(),
2578
+			}
2579
+			service.CreateExportErrLog(&err_log)
2580
+			continue
2581
+		}
2582
+
2583
+		drug.RetailPrice = retail_price
2584
+
2585
+		last_price := goodNameM["last_price"].(float64)
2586
+		if last_price <= 0 { //名字为空则生成一条导入错误日志
2587
+			err_log := models.ExportErrLog{
2588
+				LogType:    4,
2589
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2590
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2591
+				Status:     1,
2592
+				CreateTime: time.Now().Unix(),
2593
+				UpdateTime: time.Now().Unix(),
2594
+				ExportTime: time.Now().Unix(),
2595
+			}
2596
+			service.CreateExportErrLog(&err_log)
2597
+			continue
2598
+		}
2599
+
2600
+		drug.LastPrice = last_price
2601
+
2602
+		drug_classify_id := int64(goodNameM["drug_classify_id"].(float64))
2603
+		fmt.Println("医保登记", drug_classify_id)
2604
+		fmt.Println("机构第", this.GetAdminUserInfo().CurrentOrgId)
2605
+		if drug_classify_id <= 0 { //名字为空则生成一条导入错误日志
2606
+			err_log := models.ExportErrLog{
2607
+				LogType:    4,
2608
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2609
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的医保等级不能为空",
2610
+				Status:     1,
2611
+				CreateTime: time.Now().Unix(),
2612
+				UpdateTime: time.Now().Unix(),
2613
+				ExportTime: time.Now().Unix(),
2614
+			}
2615
+			service.CreateExportErrLog(&err_log)
2616
+			continue
2617
+		}
2618
+
2619
+		drug.DrugCategory = drug_classify_id
2620
+
2621
+		manufacturer_id := int64(goodNameM["manufacturer_id"].(float64))
2622
+		if manufacturer_id <= 0 { //名字为空则生成一条导入错误日志
2623
+			err_log := models.ExportErrLog{
2624
+				LogType:    4,
2625
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2626
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的生产商不能为空",
2627
+				Status:     1,
2628
+				CreateTime: time.Now().Unix(),
2629
+				UpdateTime: time.Now().Unix(),
2630
+				ExportTime: time.Now().Unix(),
2631
+			}
2632
+			service.CreateExportErrLog(&err_log)
2633
+			continue
2634
+		}
2635
+
2636
+		drug.Manufacturer = manufacturer_id
2637
+
2638
+		dealer_id := int64(goodNameM["dealer_id"].(float64))
2639
+		if dealer_id <= 0 { //名字为空则生成一条导入错误日志
2640
+			err_log := models.ExportErrLog{
2641
+				LogType:    4,
2642
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2643
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的经销商不能为空",
2644
+				Status:     1,
2645
+				CreateTime: time.Now().Unix(),
2646
+				UpdateTime: time.Now().Unix(),
2647
+				ExportTime: time.Now().Unix(),
2648
+			}
2649
+			service.CreateExportErrLog(&err_log)
2650
+			continue
2651
+		}
2652
+
2653
+		drug.Dealer = dealer_id
2654
+
2655
+		drugList = append(drugList, &drug)
2656
+	}
2657
+
2658
+	adminUser := this.GetAdminUserInfo()
2659
+	orgId := adminUser.CurrentOrgId
2660
+	export_time := time.Now().Unix()
2661
+	errLogs, _ := service.FindPatientExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
2662
+	fmt.Println("数组", drugList)
2663
+	if len(drugList) > 0 {
2664
+		for _, item := range drugList {
2665
+			service.CreateDrugsInfomation(item, orgId)
2666
+			log := models.ExportLog{
2667
+				LogType:    4,
2668
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2669
+				TotalNum:   int64(len(total_goods)),
2670
+				FailNum:    int64(len(errLogs)),
2671
+				SuccessNum: int64(len(drugList)),
2672
+				CreateTime: time.Now().Unix(),
2673
+				UpdateTime: time.Now().Unix(),
2674
+				ExportTime: export_time,
2675
+				Status:     1,
2676
+			}
2677
+			service.CreateExportLog(&log)
2678
+			this.ServeSuccessJSON(map[string]interface{}{
2679
+				"msg":         "导入成功",
2680
+				"total_num":   len(total_goods),
2681
+				"success_num": len(drugList),
2682
+				"fail_num":    int64(len(errLogs)),
2683
+			})
2684
+		}
2685
+	} else {
2686
+		log := models.ExportLog{
2687
+			LogType:    4,
2688
+			UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2689
+			TotalNum:   int64(len(total_goods)),
2690
+			FailNum:    int64(len(errLogs)),
2691
+			SuccessNum: int64(len(drugList)),
2692
+			CreateTime: time.Now().Unix(),
2693
+			UpdateTime: time.Now().Unix(),
2694
+			ExportTime: export_time,
2695
+			Status:     1,
2696
+		}
2697
+		service.CreateExportLog(&log)
2698
+
2699
+		this.ServeSuccessJSON(map[string]interface{}{
2700
+			"msg":         "导入成功",
2701
+			"total_num":   len(total_goods),
2702
+			"success_num": len(drugList),
2703
+			"fail_num":    int64(len(errLogs)),
2704
+		})
2705
+	}
2706
+}

+ 26 - 0
models/self_drug_models.go 파일 보기

@@ -532,3 +532,29 @@ type BloodDrugWarehouseOutInfo struct {
532 532
 	Creater                 int64   `gorm:"column:creater" json:"creater" form:"creater"`
533 533
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
534 534
 }
535
+
536
+type XtMonitorConfig struct {
537
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
538
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
539
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
540
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
541
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
542
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
543
+}
544
+
545
+func (XtMonitorConfig) TableName() string {
546
+	return "xt_monitor_config"
547
+}
548
+
549
+type XtOrderConfig struct {
550
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
551
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
552
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
553
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
554
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
555
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
556
+}
557
+
558
+func (XtOrderConfig) TableName() string {
559
+	return "xt_order_config"
560
+}

+ 64 - 0
service/gobal_config_service.go 파일 보기

@@ -4,6 +4,7 @@ import (
4 4
 	"XT_New/models"
5 5
 	"fmt"
6 6
 	"github.com/jinzhu/gorm"
7
+	"time"
7 8
 )
8 9
 
9 10
 func CreateAutomaticReduceRecord(config *models.GobalConfig) (err error) {
@@ -395,3 +396,66 @@ func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoM
395 396
 
396 397
 	return autoMatic, err
397 398
 }
399
+
400
+func AddMonitorOpen(config *models.XtMonitorConfig) error {
401
+
402
+	err := XTWriteDB().Create(&config).Error
403
+
404
+	return err
405
+}
406
+
407
+func UpdateMonitorOpen(orgid int64, config *models.XtMonitorConfig) error {
408
+
409
+	err := XTWriteDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"is_open": config.IsOpen, "mtime": time.Now().Unix()}).Error
410
+	return err
411
+}
412
+
413
+func GetMonitorConfig(orgid int64) (models.XtMonitorConfig, error) {
414
+
415
+	config := models.XtMonitorConfig{}
416
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
417
+	return config, err
418
+}
419
+
420
+func AddOrderConfig(config *models.XtOrderConfig) error {
421
+
422
+	err := XTWriteDB().Create(&config).Error
423
+	return err
424
+}
425
+
426
+func UpdateOrderConfig(orgid int64, config *models.XtOrderConfig) error {
427
+
428
+	err := XTWriteDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"is_open": config.IsOpen, "mtime": time.Now().Unix()}).Error
429
+	return err
430
+}
431
+
432
+func GetOrderConfigById(orgid int64) (*models.XtOrderConfig, error) {
433
+	config := models.XtOrderConfig{}
434
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
435
+	if err == gorm.ErrRecordNotFound {
436
+		return nil, err
437
+	}
438
+	if err != nil {
439
+		return nil, err
440
+	}
441
+	return &config, nil
442
+}
443
+
444
+func GetOrderConfig(orgid int64) (models.XtOrderConfig, error) {
445
+	config := models.XtOrderConfig{}
446
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
447
+	return config, err
448
+}
449
+
450
+func GetMonitorConfigById(orgid int64) (*models.XtMonitorConfig, error) {
451
+
452
+	config := models.XtMonitorConfig{}
453
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
454
+	if err == gorm.ErrRecordNotFound {
455
+		return nil, err
456
+	}
457
+	if err != nil {
458
+		return nil, err
459
+	}
460
+	return &config, nil
461
+}

+ 1 - 0
service/mobile_dialysis_service.go 파일 보기

@@ -2039,6 +2039,7 @@ func BatchAdviceExecution(ids []string, creator int64, execution_state int64) er
2039 2039
 }
2040 2040
 
2041 2041
 func BatchHisAdviceExecution(ids []string, creator int64, execution_state int64) error {
2042
+
2042 2043
 	advice := models.HisDoctorAdviceInfo{}
2043 2044
 	err := XTWriteDB().Model(&advice).Where("id IN(?) and status = 1", ids).Updates(map[string]interface{}{"execution_state": 1, "execution_staff": creator, "execution_time": execution_state}).Error
2044 2045
 	return err

+ 50 - 0
service/stock_service.go 파일 보기

@@ -2252,3 +2252,53 @@ func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error)
2252 2252
 	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
2253 2253
 	return goodInfo, err
2254 2254
 }
2255
+
2256
+func CreateDrugsInfomation(info *models.BaseDrugLib, orgid int64) error {
2257
+
2258
+	goodInfo := models.BaseDrugLib{
2259
+		DrugName:              info.DrugName,
2260
+		DrugAlias:             info.DrugAlias,
2261
+		DrugSpec:              info.DrugSpec,
2262
+		DrugType:              info.DrugType,
2263
+		DrugStockLimit:        info.DrugStockLimit,
2264
+		DrugOriginPlace:       info.DrugOriginPlace,
2265
+		DrugDosageForm:        info.DrugDosageForm,
2266
+		MedicalInsuranceLevel: info.MedicalInsuranceLevel,
2267
+		MaxUnit:               info.MaxUnit,
2268
+		MinUnit:               info.MinUnit,
2269
+		UnitMatrixing:         info.UnitMatrixing,
2270
+		RetailPrice:           info.RetailPrice,
2271
+		LastPrice:             info.LastPrice,
2272
+		DrugClassify:          info.DrugClassify,
2273
+		Manufacturer:          info.Manufacturer,
2274
+		Dealer:                info.Dealer,
2275
+		OrgId:                 orgid,
2276
+		Status:                1,
2277
+		Ctime:                 time.Now().Unix(),
2278
+	}
2279
+	err := XTWriteDB().Create(&goodInfo).Error
2280
+	return err
2281
+}
2282
+
2283
+func CreateProjectInfomation(info *models.HisProject, orgid int64) error {
2284
+
2285
+	project := models.HisProject{
2286
+		ProjectName:      info.ProjectName,
2287
+		Price:            info.Price,
2288
+		Unit:             info.Unit,
2289
+		CostClassify:     info.CostClassify,
2290
+		ExecutiveSection: info.ExecutiveSection,
2291
+		MedicalCoverage:  info.MedicalCoverage,
2292
+		UserOrgId:        orgid,
2293
+		Status:           1,
2294
+		CreatedTime:      time.Now().Unix(),
2295
+	}
2296
+	err := XTWriteDB().Create(&project).Error
2297
+	return err
2298
+}
2299
+
2300
+func GetWareOutInfoById(warehouseoutid int64, orgid int64) (warehouseinfo []*models.WarehouseOutInfo, err error) {
2301
+
2302
+	err = XTReadDB().Model(&warehouseinfo).Where("warehouse_out_id = ? and org_id = ? and status= 1 and is_sys = 0", warehouseoutid, orgid).Find(&warehouseinfo).Error
2303
+	return warehouseinfo, err
2304
+}