Quellcode durchsuchen

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx vor 2 Jahren
Ursprung
Commit
621317166a
3 geänderte Dateien mit 204 neuen und 1 gelöschten Zeilen
  1. 49 0
      models/models_3501.go
  2. 154 0
      service/auto_create_week_schedules_service.go
  3. 1 1
      service/jsyb_service.go

+ 49 - 0
models/models_3501.go Datei anzeigen

@@ -205,3 +205,52 @@ type Struct3507 struct {
205 205
 	AccessKey      string
206 206
 	Cainfo         string
207 207
 }
208
+
209
+type XtDrugInventory struct {
210
+	ID                 int64             `gorm:"column:id" json:"id" form:"id"`
211
+	DrugName           string            `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
212
+	SpecificationName  string            `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
213
+	WarehousingUnit    string            `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
214
+	Count              int64             `gorm:"column:count" json:"count" form:"count"`
215
+	LastPrice          float64           `gorm:"column:last_price" json:"last_price" form:"last_price"`
216
+	RetailPrice        float64           `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
217
+	NewPrice           float64           `gorm:"column:new_price" json:"new_price" form:"new_price"`
218
+	Manufacturer       string            `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
219
+	Dealer             string            `gorm:"column:dealer" json:"dealer" form:"dealer"`
220
+	Remark             string            `gorm:"column:remark" json:"remark" form:"remark"`
221
+	DrugId             int64             `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
222
+	UserOrgId          int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
223
+	Ctime              int64             `gorm:"column:ctime" json:"ctime" form:"ctime"`
224
+	Mtime              int64             `gorm:"column:mtime" json:"mtime" form:"mtime"`
225
+	Status             int64             `gorm:"column:status" json:"status" form:"status"`
226
+	WarehousingOrder   string            `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
227
+	LicenseNumber      string            `gorm:"column:license_number" json:"license_number" form:"license_number"`
228
+	StartTime          int64             `gorm:"column:start_time" json:"start_time" form:"start_time"`
229
+	Creater            int64             `gorm:"column:creater" json:"creater" form:"creater"`
230
+	Checker            int64             `gorm:"column:checker" json:"checker" form:"checker"`
231
+	CheckerStatus      int64             `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
232
+	CheckerTime        int64             `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
233
+	ExpiryDate         int64             `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
234
+	ProductDate        int64             `gorm:"column:product_date" json:"product_date" form:"product_date"`
235
+	Number             string            `gorm:"column:number" json:"number" form:"number"`
236
+	BatchNumber        string            `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
237
+	Total              string            `gorm:"column:total" json:"total" form:"total"`
238
+	DrugOriginPlace    string            `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
239
+	WarehouseInfoId    int64             `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
240
+	ProofCount         int64             `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
241
+	StockMaxNumber     int64             `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
242
+	StockMinNumber     int64             `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
243
+	MinCount           int64             `gorm:"column:min_count" json:"min_count" form:"min_count"`
244
+	MinUnit            string            `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
245
+	LastStockMaxNumber int64             `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
246
+	LastStockMinNumber int64             `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
247
+	InventoryType      int64             `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
248
+	Type               int64             `gorm:"column:type" json:"type" form:"type"`
249
+	StorehouseId       int64             `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
250
+	BaseDrugLib        BaseDrugLib       `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
251
+	DrugWarehouseInfo  DrugWarehouseInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfoId"json:"drug_warehouse_info" `
252
+}
253
+
254
+func (XtDrugInventory) TableName() string {
255
+	return "xt_drug_inventory"
256
+}

+ 154 - 0
service/auto_create_week_schedules_service.go Datei anzeigen

@@ -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)

+ 1 - 1
service/jsyb_service.go Datei anzeigen

@@ -1706,7 +1706,7 @@ func Jsyb4101(struct4101 Struct4101, params models.PublicParams) (string, string
1706 1706
 func Jsyb3501(struct3501 models.Struct3501) (string, string) {
1707 1707
 	timestamp := time.Now().Unix()
1708 1708
 	// 生成输入报文
1709
-	inputMessage := SetJSInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsCode, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
1709
+	inputMessage := SetJSInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
1710 1710
 	input := make(map[string]interface{})
1711 1711
 	inputData := make(map[string]interface{})
1712 1712
 	inputMessage["infno"] = "3501"                                  // 交易编码