|
@@ -0,0 +1,609 @@
|
|
1
|
+package service
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "bytes"
|
|
5
|
+ "encoding/json"
|
|
6
|
+ "gdyb/models"
|
|
7
|
+ "gdyb/utils"
|
|
8
|
+ "github.com/astaxie/beego"
|
|
9
|
+ "github.com/robfig/cron"
|
|
10
|
+ "io/ioutil"
|
|
11
|
+ "math/rand"
|
|
12
|
+ "net/http"
|
|
13
|
+ "strconv"
|
|
14
|
+ "time"
|
|
15
|
+)
|
|
16
|
+
|
|
17
|
+type ResultSix struct {
|
|
18
|
+ Cainfo interface{} `json:"cainfo"`
|
|
19
|
+ ErrMsg string `json:"err_msg"`
|
|
20
|
+ InfRefmsgid string `json:"inf_refmsgid"`
|
|
21
|
+ Infcode int64 `json:"infcode"`
|
|
22
|
+ Output struct {
|
|
23
|
+ } `json:"output"`
|
|
24
|
+ RefmsgTime string `json:"refmsg_time"`
|
|
25
|
+ RespondTime string `json:"respond_time"`
|
|
26
|
+ Signtype interface{} `json:"signtype"`
|
|
27
|
+ WarnMsg interface{} `json:"warn_msg"`
|
|
28
|
+}
|
|
29
|
+
|
|
30
|
+type ResultSix10265 struct {
|
|
31
|
+ Cainfo interface{} `json:"cainfo"`
|
|
32
|
+ ErrMsg string `json:"err_msg"`
|
|
33
|
+ InfRefmsgid string `json:"inf_refmsgid"`
|
|
34
|
+ Infcode string `json:"infcode"`
|
|
35
|
+ Output struct {
|
|
36
|
+ } `json:"output"`
|
|
37
|
+ RefmsgTime string `json:"refmsg_time"`
|
|
38
|
+ RespondTime string `json:"respond_time"`
|
|
39
|
+ Signtype interface{} `json:"signtype"`
|
|
40
|
+ WarnMsg interface{} `json:"warn_msg"`
|
|
41
|
+}
|
|
42
|
+
|
|
43
|
+// cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
|
|
44
|
+var createWeekSchedulesCronJob *cron.Cron
|
|
45
|
+
|
|
46
|
+func init() {
|
|
47
|
+ utils.InfoLog("开启自动排班定时任务")
|
|
48
|
+ createWeekSchedulesCronJob = cron.New()
|
|
49
|
+ spec := "0 0 18 * * ?" // 每天6点上传当天数据
|
|
50
|
+ //spec := "0 */1 * * * ?"
|
|
51
|
+ createWeekSchedulesCronJob.AddFunc(spec, func() {
|
|
52
|
+ AutoCreateStock()
|
|
53
|
+
|
|
54
|
+ })
|
|
55
|
+}
|
|
56
|
+
|
|
57
|
+func BeginAutoCreateWeekSchedulesJob() {
|
|
58
|
+ createWeekSchedulesCronJob.Start()
|
|
59
|
+}
|
|
60
|
+
|
|
61
|
+func AutoCreateStock() {
|
|
62
|
+ org_id, _ := beego.AppConfig.Int64("org_id")
|
|
63
|
+ var NewWarehousing []*models.NewWarehousingInfo
|
|
64
|
+ var NewWarehouseOut []*models.NewWarehouseOutInfo
|
|
65
|
+ var NewCancelStock []*models.NewCancelStockInfo
|
|
66
|
+
|
|
67
|
+ var NewDrugWarehouse []*models.NewDrugWarehouseInfo
|
|
68
|
+ var NewDrugWarehouseOut []*models.NewDrugWarehouseOutInfo
|
|
69
|
+ var NewDrugCancelStock []*models.NewDrugCancelStockInfo
|
|
70
|
+
|
|
71
|
+ readDb.Model(&models.NewWarehousingInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewWarehousing)
|
|
72
|
+ readDb.Model(&models.NewWarehouseOutInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewWarehouseOut)
|
|
73
|
+ readDb.Model(&models.NewCancelStockInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewCancelStock)
|
|
74
|
+
|
|
75
|
+ readDb.Model(&models.NewDrugWarehouseInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouse)
|
|
76
|
+ readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOut)
|
|
77
|
+ readDb.Model(&models.NewDrugCancelStockInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugCancelStock)
|
|
78
|
+
|
|
79
|
+ for _, item := range NewWarehousing {
|
|
80
|
+ res := Post3503ForGoodInfo(org_id, item)
|
|
81
|
+ if res.Infcode == 0 {
|
|
82
|
+ writeDb.Model(&models.NewWarehousingInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{
|
|
83
|
+ "is_upload": 1,
|
|
84
|
+ })
|
|
85
|
+ } else {
|
|
86
|
+
|
|
87
|
+ continue
|
|
88
|
+ }
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ for _, item := range NewWarehouseOut {
|
|
92
|
+ res := Post3505ForGoodInfo(org_id, item)
|
|
93
|
+ if res.Infcode == 0 {
|
|
94
|
+ writeDb.Model(&models.NewWarehouseOutInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{
|
|
95
|
+ "is_upload": 1,
|
|
96
|
+ })
|
|
97
|
+ } else {
|
|
98
|
+
|
|
99
|
+ continue
|
|
100
|
+ }
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ for _, item := range NewCancelStock {
|
|
104
|
+ res := Post3506ForGoodInfo(org_id, item)
|
|
105
|
+ if res.Infcode == 0 {
|
|
106
|
+ writeDb.Model(&models.NewCancelStockInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{
|
|
107
|
+ "is_upload": 1,
|
|
108
|
+ })
|
|
109
|
+ } else {
|
|
110
|
+
|
|
111
|
+ continue
|
|
112
|
+ }
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ for _, item := range NewDrugWarehouse {
|
|
116
|
+ res := Post3503ForDrug(org_id, item)
|
|
117
|
+ if res.Infcode == 0 {
|
|
118
|
+ writeDb.Model(&models.NewDrugWarehouseInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{
|
|
119
|
+ "is_upload": 1,
|
|
120
|
+ })
|
|
121
|
+ } else {
|
|
122
|
+
|
|
123
|
+ continue
|
|
124
|
+ }
|
|
125
|
+ }
|
|
126
|
+
|
|
127
|
+ for _, item := range NewDrugWarehouseOut {
|
|
128
|
+ res := Post3505ForDrug(org_id, item)
|
|
129
|
+ if res.Infcode == 0 {
|
|
130
|
+ writeDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{
|
|
131
|
+ "is_upload": 1,
|
|
132
|
+ })
|
|
133
|
+ }
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ for _, item := range NewDrugCancelStock {
|
|
137
|
+ res := Post3506ForDrug(org_id, item)
|
|
138
|
+ if res.Infcode == 0 {
|
|
139
|
+ writeDb.Model(&models.NewDrugCancelStockInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{
|
|
140
|
+ "is_upload": 1,
|
|
141
|
+ })
|
|
142
|
+ } else {
|
|
143
|
+
|
|
144
|
+ continue
|
|
145
|
+ }
|
|
146
|
+ }
|
|
147
|
+
|
|
148
|
+}
|
|
149
|
+
|
|
150
|
+//采购
|
|
151
|
+func Post3503ForGoodInfo(org_id int64, infos *models.NewWarehousingInfo) ResultSix {
|
|
152
|
+
|
|
153
|
+ var res ResultSix
|
|
154
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
155
|
+ data := make(map[string]interface{})
|
|
156
|
+ var struct3503s []models.Struct3503
|
|
157
|
+ var struct3503 models.Struct3503
|
|
158
|
+ struct3503.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber
|
|
159
|
+ struct3503.FixmedinsHilistId = miConfig.Code
|
|
160
|
+ struct3503.FixmedinsHilistName = miConfig.OrgName
|
|
161
|
+ struct3503.FixmedinsBchno = infos.Number
|
|
162
|
+ struct3503.SplerName = infos.Dealers.DealerName
|
|
163
|
+ struct3503.ManuLotnum = infos.Number
|
|
164
|
+ struct3503.ProdentpName = infos.Manufacturers.ManufacturerName
|
|
165
|
+ struct3503.Aprvno = infos.LicenseNumber
|
|
166
|
+ struct3503.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
167
|
+ struct3503.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05")
|
|
168
|
+ struct3503.PurcRetnCnt = strconv.FormatInt(infos.TotalCount, 10)
|
|
169
|
+ struct3503.RxFlag = "0"
|
|
170
|
+ struct3503.PurcRetnStoinTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
171
|
+ struct3503.PurcRetnOpterName = "仓管员"
|
|
172
|
+ struct3503.OrgName = miConfig.OrgName
|
|
173
|
+ struct3503.AccessKey = miConfig.AccessKey
|
|
174
|
+ struct3503.RequestUrl = miConfig.Url
|
|
175
|
+ struct3503.SecretKey = miConfig.SecretKey
|
|
176
|
+ struct3503.Memo = ""
|
|
177
|
+ struct3503s = append(struct3503s, struct3503)
|
|
178
|
+ data["struct_3501s"] = struct3503s
|
|
179
|
+ client := &http.Client{}
|
|
180
|
+ bytesData, _ := json.Marshal(data)
|
|
181
|
+ var req *http.Request
|
|
182
|
+
|
|
183
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
184
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3503", bytes.NewReader(bytesData))
|
|
185
|
+ } else {
|
|
186
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3503", bytes.NewReader(bytesData))
|
|
187
|
+ }
|
|
188
|
+
|
|
189
|
+ resp, _ := client.Do(req)
|
|
190
|
+ defer resp.Body.Close()
|
|
191
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
192
|
+ if ioErr != nil {
|
|
193
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
194
|
+ res.Infcode = -1
|
|
195
|
+ return res
|
|
196
|
+ }
|
|
197
|
+ var respJSON map[string]interface{}
|
|
198
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
199
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
200
|
+ res.Infcode = -1
|
|
201
|
+ return res
|
|
202
|
+ }
|
|
203
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
204
|
+
|
|
205
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
206
|
+ result, _ := json.Marshal(respJSON)
|
|
207
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
208
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
209
|
+ res.Infcode = -1
|
|
210
|
+ return res
|
|
211
|
+
|
|
212
|
+ }
|
|
213
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
214
|
+ res.Output = resSix10265.Output
|
|
215
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
216
|
+ res.Cainfo = resSix10265.Cainfo
|
|
217
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
218
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
219
|
+ res.Infcode = infocode
|
|
220
|
+ return res
|
|
221
|
+}
|
|
222
|
+func Post3503ForDrug(org_id int64, infos *models.NewDrugWarehouseInfo) ResultSix {
|
|
223
|
+ var res ResultSix
|
|
224
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
225
|
+ data := make(map[string]interface{})
|
|
226
|
+ var struct3501s []models.Struct3503
|
|
227
|
+ var struct3501 models.Struct3503
|
|
228
|
+ struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber
|
|
229
|
+ struct3501.FixmedinsHilistId = miConfig.Code
|
|
230
|
+ struct3501.FixmedinsHilistName = miConfig.OrgName
|
|
231
|
+ struct3501.FixmedinsBchno = infos.BatchNumber
|
|
232
|
+ struct3501.SplerName = infos.Dealers.DealerName
|
|
233
|
+ struct3501.ManuLotnum = infos.BatchNumber
|
|
234
|
+ struct3501.ProdentpName = infos.Manufacturers.ManufacturerName
|
|
235
|
+ struct3501.Aprvno = infos.BaseDrugLib.Number
|
|
236
|
+ struct3501.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
237
|
+ struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05")
|
|
238
|
+ struct3501.PurcRetnCnt = strconv.FormatInt(infos.WarehousingCount, 10)
|
|
239
|
+ struct3501.RxFlag = "0"
|
|
240
|
+ struct3501.PurcRetnStoinTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
241
|
+ struct3501.PurcRetnOpterName = "仓管员"
|
|
242
|
+ struct3501.OrgName = miConfig.OrgName
|
|
243
|
+ struct3501.AccessKey = miConfig.AccessKey
|
|
244
|
+ struct3501.RequestUrl = miConfig.Url
|
|
245
|
+ struct3501.SecretKey = miConfig.SecretKey
|
|
246
|
+ struct3501.Memo = ""
|
|
247
|
+ struct3501s = append(struct3501s, struct3501)
|
|
248
|
+ data["struct_3501s"] = struct3501s
|
|
249
|
+ client := &http.Client{}
|
|
250
|
+ bytesData, _ := json.Marshal(data)
|
|
251
|
+ var req *http.Request
|
|
252
|
+
|
|
253
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
254
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3503", bytes.NewReader(bytesData))
|
|
255
|
+ } else {
|
|
256
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3503", bytes.NewReader(bytesData))
|
|
257
|
+ }
|
|
258
|
+
|
|
259
|
+ resp, _ := client.Do(req)
|
|
260
|
+ defer resp.Body.Close()
|
|
261
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
262
|
+ if ioErr != nil {
|
|
263
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
264
|
+ res.Infcode = -1
|
|
265
|
+ return res
|
|
266
|
+ }
|
|
267
|
+ var respJSON map[string]interface{}
|
|
268
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
269
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
270
|
+ res.Infcode = -1
|
|
271
|
+ return res
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
275
|
+
|
|
276
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
277
|
+ result, _ := json.Marshal(respJSON)
|
|
278
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
279
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
280
|
+ res.Infcode = -1
|
|
281
|
+ return res
|
|
282
|
+ }
|
|
283
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
284
|
+ res.Output = resSix10265.Output
|
|
285
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
286
|
+ res.Cainfo = resSix10265.Cainfo
|
|
287
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
288
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
289
|
+ res.Infcode = infocode
|
|
290
|
+
|
|
291
|
+ return res
|
|
292
|
+}
|
|
293
|
+
|
|
294
|
+//销售
|
|
295
|
+func Post3505ForGoodInfo(org_id int64, infos *models.NewWarehouseOutInfo) ResultSix {
|
|
296
|
+ var res ResultSix
|
|
297
|
+
|
|
298
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
299
|
+ data := make(map[string]interface{})
|
|
300
|
+ var struct3501s []models.Struct3505
|
|
301
|
+ var struct3501 models.Struct3505
|
|
302
|
+
|
|
303
|
+ struct3501.OrgName = miConfig.OrgName
|
|
304
|
+ struct3501.AccessKey = miConfig.AccessKey
|
|
305
|
+ struct3501.RequestUrl = miConfig.Url
|
|
306
|
+ struct3501.SecretKey = miConfig.SecretKey
|
|
307
|
+
|
|
308
|
+ struct3501.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber
|
|
309
|
+ struct3501.FixmedinsHilistId = miConfig.Code
|
|
310
|
+ struct3501.FixmedinsHilistName = miConfig.OrgName
|
|
311
|
+ struct3501.FixmedinsBchno = infos.Number
|
|
312
|
+ if org_id == 10188 {
|
|
313
|
+ struct3501.PrscDrName = "王曙光"
|
|
314
|
+ struct3501.PharName = "王曙光"
|
|
315
|
+ struct3501.PharPracCertNo = ""
|
|
316
|
+
|
|
317
|
+ } else if org_id == 10217 {
|
|
318
|
+ struct3501.PrscDrName = "王云刚"
|
|
319
|
+ struct3501.PharName = "王云刚"
|
|
320
|
+ struct3501.PharPracCertNo = ""
|
|
321
|
+ }
|
|
322
|
+ timestamp := time.Now().Unix()
|
|
323
|
+ tempTime := time.Unix(timestamp, 0)
|
|
324
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
325
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
326
|
+ ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
|
|
327
|
+ struct3501.MdtrtSn = ipt_otp_no
|
|
328
|
+ struct3501.ManuLotnum = infos.Number
|
|
329
|
+ struct3501.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
330
|
+ struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05")
|
|
331
|
+ struct3501.RxFlag = "0"
|
|
332
|
+ struct3501.TrdnFlag = "1"
|
|
333
|
+ struct3501.RtalDocno = strconv.FormatInt(int64(infos.ID), 10)
|
|
334
|
+ struct3501.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10)
|
|
335
|
+ struct3501.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
336
|
+ struct3501.SelRetnOpterName = "仓管员"
|
|
337
|
+ struct3501s = append(struct3501s, struct3501)
|
|
338
|
+ data["struct_3501s"] = struct3501s
|
|
339
|
+ client := &http.Client{}
|
|
340
|
+ bytesData, _ := json.Marshal(data)
|
|
341
|
+ var req *http.Request
|
|
342
|
+
|
|
343
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
344
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
345
|
+ } else {
|
|
346
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
347
|
+ }
|
|
348
|
+
|
|
349
|
+ resp, _ := client.Do(req)
|
|
350
|
+ defer resp.Body.Close()
|
|
351
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
352
|
+ if ioErr != nil {
|
|
353
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
354
|
+ res.Infcode = -1
|
|
355
|
+ return res
|
|
356
|
+ }
|
|
357
|
+ var respJSON map[string]interface{}
|
|
358
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
359
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
360
|
+ res.Infcode = -1
|
|
361
|
+ return res
|
|
362
|
+ }
|
|
363
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
364
|
+
|
|
365
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
366
|
+ result, _ := json.Marshal(respJSON)
|
|
367
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
368
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
369
|
+ res.Infcode = -1
|
|
370
|
+ return res
|
|
371
|
+ }
|
|
372
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
373
|
+ res.Output = resSix10265.Output
|
|
374
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
375
|
+ res.Cainfo = resSix10265.Cainfo
|
|
376
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
377
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
378
|
+ res.Infcode = infocode
|
|
379
|
+
|
|
380
|
+ return res
|
|
381
|
+}
|
|
382
|
+func Post3505ForDrug(org_id int64, infos *models.NewDrugWarehouseOutInfo) ResultSix {
|
|
383
|
+ var res ResultSix
|
|
384
|
+
|
|
385
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
386
|
+ data := make(map[string]interface{})
|
|
387
|
+ var struct3501s []models.Struct3505
|
|
388
|
+ var struct3501 models.Struct3505
|
|
389
|
+
|
|
390
|
+ struct3501.OrgName = miConfig.OrgName
|
|
391
|
+ struct3501.AccessKey = miConfig.AccessKey
|
|
392
|
+ struct3501.RequestUrl = miConfig.Url
|
|
393
|
+ struct3501.SecretKey = miConfig.SecretKey
|
|
394
|
+
|
|
395
|
+ struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber
|
|
396
|
+ struct3501.FixmedinsHilistId = miConfig.Code
|
|
397
|
+ struct3501.FixmedinsHilistName = miConfig.OrgName
|
|
398
|
+ struct3501.FixmedinsBchno = infos.BatchNumber
|
|
399
|
+ if org_id == 10188 {
|
|
400
|
+ struct3501.PrscDrName = "王曙光"
|
|
401
|
+ struct3501.PharName = "王曙光"
|
|
402
|
+ struct3501.PharPracCertNo = ""
|
|
403
|
+
|
|
404
|
+ } else if org_id == 10217 {
|
|
405
|
+ struct3501.PrscDrName = "王云刚"
|
|
406
|
+ struct3501.PharName = "王云刚"
|
|
407
|
+ struct3501.PharPracCertNo = ""
|
|
408
|
+ }
|
|
409
|
+ timestamp := time.Now().Unix()
|
|
410
|
+ tempTime := time.Unix(timestamp, 0)
|
|
411
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
412
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
413
|
+ ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
|
|
414
|
+ struct3501.MdtrtSn = ipt_otp_no
|
|
415
|
+ struct3501.ManuLotnum = infos.BatchNumber
|
|
416
|
+ struct3501.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
417
|
+ struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05")
|
|
418
|
+ struct3501.RxFlag = "0"
|
|
419
|
+ struct3501.TrdnFlag = "1"
|
|
420
|
+ struct3501.RtalDocno = strconv.FormatInt(int64(infos.ID), 10)
|
|
421
|
+ struct3501.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10)
|
|
422
|
+ struct3501.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
423
|
+ struct3501.SelRetnOpterName = "仓管员"
|
|
424
|
+
|
|
425
|
+ struct3501s = append(struct3501s, struct3501)
|
|
426
|
+ data["struct_3501s"] = struct3501s
|
|
427
|
+ client := &http.Client{}
|
|
428
|
+ bytesData, _ := json.Marshal(data)
|
|
429
|
+ var req *http.Request
|
|
430
|
+
|
|
431
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
432
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
|
|
433
|
+ } else {
|
|
434
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
|
|
435
|
+ }
|
|
436
|
+
|
|
437
|
+ resp, _ := client.Do(req)
|
|
438
|
+ defer resp.Body.Close()
|
|
439
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
440
|
+ if ioErr != nil {
|
|
441
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
442
|
+ res.Infcode = -1
|
|
443
|
+ return res
|
|
444
|
+ }
|
|
445
|
+ var respJSON map[string]interface{}
|
|
446
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
447
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
448
|
+ res.Infcode = -1
|
|
449
|
+ return res
|
|
450
|
+ }
|
|
451
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
452
|
+
|
|
453
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
454
|
+ result, _ := json.Marshal(respJSON)
|
|
455
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
456
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
457
|
+ res.Infcode = -1
|
|
458
|
+ return res
|
|
459
|
+ }
|
|
460
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
461
|
+ res.Output = resSix10265.Output
|
|
462
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
463
|
+ res.Cainfo = resSix10265.Cainfo
|
|
464
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
465
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
466
|
+ res.Infcode = infocode
|
|
467
|
+
|
|
468
|
+ return res
|
|
469
|
+}
|
|
470
|
+
|
|
471
|
+//销售退货
|
|
472
|
+func Post3506ForGoodInfo(org_id int64, infos *models.NewCancelStockInfo) ResultSix {
|
|
473
|
+ var res ResultSix
|
|
474
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
475
|
+ data := make(map[string]interface{})
|
|
476
|
+ var struct3501s []models.Struct3506
|
|
477
|
+ var struct3501 models.Struct3506
|
|
478
|
+
|
|
479
|
+ struct3501.OrgName = miConfig.OrgName
|
|
480
|
+ struct3501.AccessKey = miConfig.AccessKey
|
|
481
|
+ struct3501.RequestUrl = miConfig.Url
|
|
482
|
+ struct3501.SecretKey = miConfig.SecretKey
|
|
483
|
+ struct3501.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber
|
|
484
|
+ struct3501.FixmedinsHilistId = miConfig.Code
|
|
485
|
+ struct3501.FixmedinsHilistName = miConfig.OrgName
|
|
486
|
+ struct3501.FixmedinsBchno = infos.Number
|
|
487
|
+ struct3501.ManuLotnum = infos.Number
|
|
488
|
+ struct3501.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
489
|
+ //struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05")
|
|
490
|
+ struct3501.RxFlag = "0"
|
|
491
|
+ struct3501.TrdnFlag = "1"
|
|
492
|
+ struct3501.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10)
|
|
493
|
+ struct3501.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
494
|
+ struct3501.SelRetnOpterName = "仓管员"
|
|
495
|
+ struct3501.Memo = ""
|
|
496
|
+
|
|
497
|
+ struct3501s = append(struct3501s, struct3501)
|
|
498
|
+ data["struct_3501s"] = struct3501s
|
|
499
|
+ client := &http.Client{}
|
|
500
|
+ bytesData, _ := json.Marshal(data)
|
|
501
|
+ var req *http.Request
|
|
502
|
+
|
|
503
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
504
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
505
|
+ } else {
|
|
506
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
507
|
+ }
|
|
508
|
+
|
|
509
|
+ resp, _ := client.Do(req)
|
|
510
|
+ defer resp.Body.Close()
|
|
511
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
512
|
+ if ioErr != nil {
|
|
513
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
514
|
+ res.Infcode = -1
|
|
515
|
+ return res
|
|
516
|
+ }
|
|
517
|
+ var respJSON map[string]interface{}
|
|
518
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
519
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
520
|
+ res.Infcode = -1
|
|
521
|
+ return res
|
|
522
|
+ }
|
|
523
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
524
|
+
|
|
525
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
526
|
+ result, _ := json.Marshal(respJSON)
|
|
527
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
528
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
529
|
+ res.Infcode = -1
|
|
530
|
+ return res
|
|
531
|
+ }
|
|
532
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
533
|
+ res.Output = resSix10265.Output
|
|
534
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
535
|
+ res.Cainfo = resSix10265.Cainfo
|
|
536
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
537
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
538
|
+ res.Infcode = infocode
|
|
539
|
+
|
|
540
|
+ return res
|
|
541
|
+}
|
|
542
|
+func Post3506ForDrug(org_id int64, infos *models.NewDrugCancelStockInfo) ResultSix {
|
|
543
|
+ var res ResultSix
|
|
544
|
+
|
|
545
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
546
|
+ data := make(map[string]interface{})
|
|
547
|
+ var struct3501s []models.Struct3506
|
|
548
|
+ var struct3501 models.Struct3506
|
|
549
|
+ struct3501.OrgName = miConfig.OrgName
|
|
550
|
+ struct3501.AccessKey = miConfig.AccessKey
|
|
551
|
+ struct3501.RequestUrl = miConfig.Url
|
|
552
|
+ struct3501.SecretKey = miConfig.SecretKey
|
|
553
|
+ struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber
|
|
554
|
+ struct3501.FixmedinsHilistId = miConfig.Code
|
|
555
|
+ struct3501.FixmedinsHilistName = miConfig.OrgName
|
|
556
|
+ struct3501.FixmedinsBchno = infos.BatchNumber
|
|
557
|
+ struct3501.ManuLotnum = infos.BatchNumber
|
|
558
|
+ struct3501.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
559
|
+ struct3501.RxFlag = "0"
|
|
560
|
+ struct3501.TrdnFlag = "1"
|
|
561
|
+ struct3501.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10)
|
|
562
|
+ struct3501.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
563
|
+ struct3501.SelRetnOpterName = "仓管员"
|
|
564
|
+ struct3501.Memo = ""
|
|
565
|
+ struct3501s = append(struct3501s, struct3501)
|
|
566
|
+ data["struct_3501s"] = struct3501s
|
|
567
|
+ client := &http.Client{}
|
|
568
|
+ bytesData, _ := json.Marshal(data)
|
|
569
|
+ var req *http.Request
|
|
570
|
+
|
|
571
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
572
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
573
|
+ } else {
|
|
574
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
575
|
+ }
|
|
576
|
+
|
|
577
|
+ resp, _ := client.Do(req)
|
|
578
|
+ defer resp.Body.Close()
|
|
579
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
580
|
+ if ioErr != nil {
|
|
581
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
582
|
+ res.Infcode = -1
|
|
583
|
+ return res
|
|
584
|
+ }
|
|
585
|
+ var respJSON map[string]interface{}
|
|
586
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
587
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
588
|
+ res.Infcode = -1
|
|
589
|
+ return res
|
|
590
|
+ }
|
|
591
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
592
|
+
|
|
593
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
594
|
+ result, _ := json.Marshal(respJSON)
|
|
595
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
596
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
597
|
+ res.Infcode = -1
|
|
598
|
+ return res
|
|
599
|
+ }
|
|
600
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
601
|
+ res.Output = resSix10265.Output
|
|
602
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
603
|
+ res.Cainfo = resSix10265.Cainfo
|
|
604
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
605
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
606
|
+ res.Infcode = infocode
|
|
607
|
+
|
|
608
|
+ return res
|
|
609
|
+}
|