|
@@ -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
|
+}
|