|
@@ -69,6 +69,10 @@ func AutoCreateStock() {
|
69
|
69
|
var NewDrugWarehouseOut []*models.NewDrugWarehouseOutInfo
|
70
|
70
|
var NewDrugCancelStock []*models.NewDrugCancelStockInfo
|
71
|
71
|
|
|
72
|
+ var XtDrugInventorys []*models.XtDrugInventory
|
|
73
|
+
|
|
74
|
+ readDb.Model(&models.XtDrugInventory{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("BaseDrugLib", "status = 1").Find(&XtDrugInventorys)
|
|
75
|
+
|
72
|
76
|
//readDb.Model(&models.NewWarehousingInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).First(&NewWarehousing)
|
73
|
77
|
//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)
|
74
|
78
|
//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)
|
|
@@ -81,6 +85,19 @@ func AutoCreateStock() {
|
81
|
85
|
//readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1 AND id >= 366003", org_id).Preload("NewDrugWarehouseInfo","status = 1").Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOut)
|
82
|
86
|
//readDb.Model(&models.NewDrugCancelStockInfo{}).Where("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)
|
83
|
87
|
|
|
88
|
+ for _, item := range XtDrugInventorys {
|
|
89
|
+ res := Post3501ForDrug(org_id, item)
|
|
90
|
+ if res.Infcode == 0 {
|
|
91
|
+ writeDb.Model(&models.XtDrugInventory{}).Where("id = ?", item.ID).Updates(map[string]interface{}{
|
|
92
|
+ "is_upload": 1,
|
|
93
|
+ })
|
|
94
|
+ } else {
|
|
95
|
+
|
|
96
|
+ continue
|
|
97
|
+ }
|
|
98
|
+
|
|
99
|
+ }
|
|
100
|
+
|
84
|
101
|
for _, item := range NewWarehousing {
|
85
|
102
|
res := Post3503ForGoodInfo(org_id, item)
|
86
|
103
|
if res.Infcode == 0 {
|
|
@@ -152,6 +169,143 @@ func AutoCreateStock() {
|
152
|
169
|
|
153
|
170
|
}
|
154
|
171
|
|
|
172
|
+func Post3501ForGoodInfo(org_id int64, infos *models.XtDrugInventory) ResultSix {
|
|
173
|
+ var res ResultSix
|
|
174
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
175
|
+ data := make(map[string]interface{})
|
|
176
|
+ var struct3501s []models.Struct3501
|
|
177
|
+ var struct3501 models.Struct3501
|
|
178
|
+ struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber
|
|
179
|
+ struct3501.FixmedinsHilistId = miConfig.Code
|
|
180
|
+ struct3501.FixmedinsHilistName = miConfig.OrgName
|
|
181
|
+ struct3501.FixmedinsBchno = infos.BatchNumber
|
|
182
|
+ struct3501.RxFlag = "0"
|
|
183
|
+ struct3501.Invdate = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
184
|
+ struct3501.OrgName = miConfig.OrgName
|
|
185
|
+ struct3501.AccessKey = miConfig.AccessKey
|
|
186
|
+ struct3501.RequestUrl = miConfig.Url
|
|
187
|
+ struct3501.SecretKey = miConfig.SecretKey
|
|
188
|
+ struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
|
|
189
|
+ struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
|
|
190
|
+ struct3501.InvCnt = strconv.FormatInt(infos.Count, 10)
|
|
191
|
+ struct3501.ManuDate = time.Unix(infos.DrugWarehouseInfo.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
192
|
+ struct3501.ExpyEnd = time.Unix(infos.DrugWarehouseInfo.ExpiryDate, 0).Format("2006-01-02 15:04:05")
|
|
193
|
+
|
|
194
|
+ struct3501s = append(struct3501s, struct3501)
|
|
195
|
+ data["struct_3501s"] = struct3501s[0]
|
|
196
|
+ client := &http.Client{}
|
|
197
|
+ bytesData, _ := json.Marshal(data)
|
|
198
|
+ var req *http.Request
|
|
199
|
+
|
|
200
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
201
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
202
|
+ } else {
|
|
203
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
204
|
+ }
|
|
205
|
+
|
|
206
|
+ resp, _ := client.Do(req)
|
|
207
|
+ defer resp.Body.Close()
|
|
208
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
209
|
+ if ioErr != nil {
|
|
210
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
211
|
+ res.Infcode = -1
|
|
212
|
+ return res
|
|
213
|
+ }
|
|
214
|
+ var respJSON map[string]interface{}
|
|
215
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
216
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
217
|
+ res.Infcode = -1
|
|
218
|
+ return res
|
|
219
|
+ }
|
|
220
|
+
|
|
221
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
222
|
+
|
|
223
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
224
|
+ result, _ := json.Marshal(respJSON)
|
|
225
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
226
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
227
|
+ res.Infcode = -1
|
|
228
|
+ return res
|
|
229
|
+ }
|
|
230
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
231
|
+ res.Output = resSix10265.Output
|
|
232
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
233
|
+ res.Cainfo = resSix10265.Cainfo
|
|
234
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
235
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
236
|
+ res.Infcode = infocode
|
|
237
|
+
|
|
238
|
+ return res
|
|
239
|
+}
|
|
240
|
+func Post3501ForDrug(org_id int64, infos *models.XtDrugInventory) ResultSix {
|
|
241
|
+ var res ResultSix
|
|
242
|
+ miConfig, _ := FindMedicalInsuranceInfo(org_id)
|
|
243
|
+ data := make(map[string]interface{})
|
|
244
|
+ var struct3501s []models.Struct3501
|
|
245
|
+ var struct3501 models.Struct3501
|
|
246
|
+ struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber
|
|
247
|
+ struct3501.FixmedinsHilistId = miConfig.Code
|
|
248
|
+ struct3501.FixmedinsHilistName = miConfig.OrgName
|
|
249
|
+ struct3501.FixmedinsBchno = infos.BatchNumber
|
|
250
|
+ struct3501.RxFlag = "0"
|
|
251
|
+ struct3501.Invdate = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
|
|
252
|
+ struct3501.OrgName = miConfig.OrgName
|
|
253
|
+ struct3501.AccessKey = miConfig.AccessKey
|
|
254
|
+ struct3501.RequestUrl = miConfig.Url
|
|
255
|
+ struct3501.SecretKey = miConfig.SecretKey
|
|
256
|
+ struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
|
|
257
|
+ struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
|
|
258
|
+ struct3501.InvCnt = strconv.FormatInt(infos.Count, 10)
|
|
259
|
+ struct3501.ManuDate = time.Unix(infos.DrugWarehouseInfo.ProductDate, 0).Format("2006-01-02 15:04:05")
|
|
260
|
+ struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05")
|
|
261
|
+
|
|
262
|
+ struct3501s = append(struct3501s, struct3501)
|
|
263
|
+ data["struct_3501s"] = struct3501s[0]
|
|
264
|
+ client := &http.Client{}
|
|
265
|
+ bytesData, _ := json.Marshal(data)
|
|
266
|
+ var req *http.Request
|
|
267
|
+
|
|
268
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
269
|
+ req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
270
|
+ } else {
|
|
271
|
+ req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ resp, _ := client.Do(req)
|
|
275
|
+ defer resp.Body.Close()
|
|
276
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
277
|
+ if ioErr != nil {
|
|
278
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
279
|
+ res.Infcode = -1
|
|
280
|
+ return res
|
|
281
|
+ }
|
|
282
|
+ var respJSON map[string]interface{}
|
|
283
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
284
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
285
|
+ res.Infcode = -1
|
|
286
|
+ return res
|
|
287
|
+ }
|
|
288
|
+
|
|
289
|
+ var resSix10265 ResultSix10265 //1101结果
|
|
290
|
+
|
|
291
|
+ respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
|
|
292
|
+ result, _ := json.Marshal(respJSON)
|
|
293
|
+ if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
|
|
294
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
295
|
+ res.Infcode = -1
|
|
296
|
+ return res
|
|
297
|
+ }
|
|
298
|
+ res.InfRefmsgid = resSix10265.InfRefmsgid
|
|
299
|
+ res.Output = resSix10265.Output
|
|
300
|
+ res.ErrMsg = resSix10265.ErrMsg
|
|
301
|
+ res.Cainfo = resSix10265.Cainfo
|
|
302
|
+ res.WarnMsg = resSix10265.WarnMsg
|
|
303
|
+ infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
|
|
304
|
+ res.Infcode = infocode
|
|
305
|
+
|
|
306
|
+ return res
|
|
307
|
+}
|
|
308
|
+
|
155
|
309
|
//采购
|
156
|
310
|
func Post3503ForGoodInfo(org_id int64, infos *models.NewWarehousingInfo) ResultSix {
|
157
|
311
|
fmt.Println(&infos)
|