|
@@ -20,11 +20,10 @@ import (
|
20
|
20
|
"gdyb/utils"
|
21
|
21
|
"github.com/astaxie/beego"
|
22
|
22
|
"github.com/axgle/mahonia"
|
|
23
|
+ "github.com/go-ole/go-ole/oleutil"
|
23
|
24
|
"github.com/gorilla/websocket"
|
24
|
25
|
"github.com/jinzhu/gorm"
|
25
|
26
|
"github.com/shopspring/decimal"
|
26
|
|
- "github.com/go-ole/go-ole"
|
27
|
|
- "github.com/go-ole/go-ole/oleutil"
|
28
|
27
|
"io"
|
29
|
28
|
"io/ioutil"
|
30
|
29
|
//"math"
|
|
@@ -215,7 +214,6 @@ func (c *HisApiController) Get3508() {
|
215
|
214
|
|
216
|
215
|
struct3508.FixmedinsCode = miConfig.Code
|
217
|
216
|
|
218
|
|
-
|
219
|
217
|
struct3508.AccessKey = miConfig.AccessKey
|
220
|
218
|
struct3508.Opter = curRoles.UserName
|
221
|
219
|
struct3508.RequestUrl = miConfig.Url
|
|
@@ -701,6 +699,7 @@ func (c *HisApiController) FJ3501AND3502() {
|
701
|
699
|
drug.PcDate = time.Now().Format("2006-01-02")
|
702
|
700
|
err := service.SaveW(drug)
|
703
|
701
|
if err == nil {
|
|
702
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
|
704
|
703
|
var struct3502 models.Struct3502
|
705
|
704
|
struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
|
706
|
705
|
struct3502.FixmedinsHilistId = miConfig.Code
|
|
@@ -723,7 +722,7 @@ func (c *HisApiController) FJ3501AND3502() {
|
723
|
722
|
struct3502.SecretKey = miConfig.SecretKey
|
724
|
723
|
struct3502.Memo = ""
|
725
|
724
|
struct3502.InvChgType = "108"
|
726
|
|
- struct3502.FixmedinsBchno = drug.Bchno
|
|
725
|
+ struct3502.FixmedinsBchno = bg_number
|
727
|
726
|
struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
|
728
|
727
|
struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
|
729
|
728
|
result11, result22, _ := service.FJyb3502(struct3502)
|
|
@@ -749,6 +748,7 @@ func (c *HisApiController) FJ3501AND3502() {
|
749
|
748
|
})
|
750
|
749
|
} else {
|
751
|
750
|
drug.IsBg = 1
|
|
751
|
+ drug.BgBchno = bg_number
|
752
|
752
|
service.SaveW(drug)
|
753
|
753
|
}
|
754
|
754
|
}
|
|
@@ -760,6 +760,7 @@ func (c *HisApiController) FJ3501AND3502() {
|
760
|
760
|
//变更
|
761
|
761
|
if drug.IsPc == 1 && drug.IsBg == 0 {
|
762
|
762
|
var res3 ResultSix
|
|
763
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
|
763
|
764
|
|
764
|
765
|
var struct3502 models.Struct3502
|
765
|
766
|
struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
|
|
@@ -784,7 +785,7 @@ func (c *HisApiController) FJ3501AND3502() {
|
784
|
785
|
struct3502.SignKey = miConfig.SignKey
|
785
|
786
|
struct3502.SecretKey = miConfig.SecretKey
|
786
|
787
|
|
787
|
|
- struct3502.FixmedinsBchno = drug.Bchno
|
|
788
|
+ struct3502.FixmedinsBchno = bg_number
|
788
|
789
|
struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
|
789
|
790
|
struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
|
790
|
791
|
result1, result2, _ := service.FJyb3502(struct3502)
|
|
@@ -805,8 +806,7 @@ func (c *HisApiController) FJ3501AND3502() {
|
805
|
806
|
errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
|
806
|
807
|
} else {
|
807
|
808
|
drug.IsBg = 1
|
808
|
|
- //drug.Bchno = number
|
809
|
|
- //drug.PcDate = time.Now().Format("2006-01-02")
|
|
809
|
+ drug.BgBchno = bg_number
|
810
|
810
|
service.SaveW(drug)
|
811
|
811
|
}
|
812
|
812
|
}
|
|
@@ -890,7 +890,7 @@ func (c *HisApiController) DeletePCandBG() {
|
890
|
890
|
struct3507_2.Enckey = miConfig.EncKey
|
891
|
891
|
struct3507_2.SignKey = miConfig.SignKey
|
892
|
892
|
struct3507_2.SecretKey = miConfig.SecretKey
|
893
|
|
- struct3507_2.FixmedinsBchno = item.Bchno
|
|
893
|
+ struct3507_2.FixmedinsBchno = item.BgBchno
|
894
|
894
|
struct3507_2.InvDataType = "2"
|
895
|
895
|
result11, result22, _ := service.FJyb3507(struct3507_2)
|
896
|
896
|
saveLog(result11, result22, "3507", "3507")
|
|
@@ -910,6 +910,7 @@ func (c *HisApiController) DeletePCandBG() {
|
910
|
910
|
if res2.Infcode != -1 {
|
911
|
911
|
item.IsBg = 0
|
912
|
912
|
item.Bchno = ""
|
|
913
|
+ item.BgBchno = ""
|
913
|
914
|
item.PcDate = ""
|
914
|
915
|
service.SaveW(item)
|
915
|
916
|
} else {
|
|
@@ -926,6 +927,52 @@ func (c *HisApiController) DeletePCandBG() {
|
926
|
927
|
var res FJ3507Result
|
927
|
928
|
var struct3507 models.Struct3507
|
928
|
929
|
struct3507.FixmedinsBchno = item.Bchno
|
|
930
|
+ struct3507.InvDataType = "1"
|
|
931
|
+ struct3507.Opter = roles.UserName
|
|
932
|
+ struct3507.FixmedinsCode = miConfig.Code
|
|
933
|
+ struct3507.OrgName = miConfig.OrgName
|
|
934
|
+ struct3507.AccessKey = miConfig.AccessKey
|
|
935
|
+ struct3507.RequestUrl = miConfig.Url
|
|
936
|
+ struct3507.SecretKey = miConfig.SecretKey
|
|
937
|
+ struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
|
|
938
|
+ struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
|
|
939
|
+ struct3507.Url = miConfig.Url
|
|
940
|
+ struct3507.AppId = miConfig.Cainfo
|
|
941
|
+ struct3507.AppSecret = miConfig.AppSecret
|
|
942
|
+ struct3507.Enckey = miConfig.EncKey
|
|
943
|
+ struct3507.SignKey = miConfig.SignKey
|
|
944
|
+ struct3507.SecretKey = miConfig.SecretKey
|
|
945
|
+ result, result1, _ := service.FJyb3507(struct3507)
|
|
946
|
+ saveLog(result, result1, "3507", "3507")
|
|
947
|
+
|
|
948
|
+ var respJSON3 map[string]interface{}
|
|
949
|
+ if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
|
|
950
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
951
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
952
|
+ return
|
|
953
|
+ }
|
|
954
|
+ userJSONBytes3, _ := json.Marshal(respJSON3)
|
|
955
|
+ if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
|
|
956
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
957
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
958
|
+ return
|
|
959
|
+ }
|
|
960
|
+ if res.Infcode != -1 {
|
|
961
|
+ item.IsPc = 0
|
|
962
|
+ item.Bchno = ""
|
|
963
|
+ item.BgBchno = ""
|
|
964
|
+ item.PcDate = ""
|
|
965
|
+ service.SaveW(item)
|
|
966
|
+ } else {
|
|
967
|
+ err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
|
|
968
|
+ }
|
|
969
|
+ }
|
|
970
|
+
|
|
971
|
+ if item.IsPc == 0 && item.IsBg == 1 {
|
|
972
|
+
|
|
973
|
+ var res FJ3507Result
|
|
974
|
+ var struct3507 models.Struct3507
|
|
975
|
+ struct3507.FixmedinsBchno = item.BgBchno
|
929
|
976
|
struct3507.InvDataType = "2"
|
930
|
977
|
struct3507.Opter = roles.UserName
|
931
|
978
|
struct3507.FixmedinsCode = miConfig.Code
|
|
@@ -959,6 +1006,7 @@ func (c *HisApiController) DeletePCandBG() {
|
959
|
1006
|
if res.Infcode != -1 {
|
960
|
1007
|
item.IsBg = 0
|
961
|
1008
|
item.Bchno = ""
|
|
1009
|
+ item.BgBchno = ""
|
962
|
1010
|
item.PcDate = ""
|
963
|
1011
|
service.SaveW(item)
|
964
|
1012
|
} else {
|
|
@@ -981,6 +1029,7 @@ func (c *HisApiController) DeletePCandBG() {
|
981
|
1029
|
}
|
982
|
1030
|
|
983
|
1031
|
}
|
|
1032
|
+
|
984
|
1033
|
func (c *HisApiController) DeleteXSandBG() {
|
985
|
1034
|
ids := c.GetString("ids")
|
986
|
1035
|
id_arr := strings.Split(ids, ",")
|
|
@@ -1032,6 +1081,8 @@ func (c *HisApiController) DeleteXSandBG() {
|
1032
|
1081
|
if res.Infcode != -1 {
|
1033
|
1082
|
item.IsSale = 0
|
1034
|
1083
|
item.SaleDate = ""
|
|
1084
|
+ item.Bchno = ""
|
|
1085
|
+
|
1035
|
1086
|
err2 := service.SaveDF(item)
|
1036
|
1087
|
if err2 == nil {
|
1037
|
1088
|
var struct3507_2 models.Struct3507
|
|
@@ -1050,7 +1101,7 @@ func (c *HisApiController) DeleteXSandBG() {
|
1050
|
1101
|
struct3507_2.Enckey = miConfig.EncKey
|
1051
|
1102
|
struct3507_2.SignKey = miConfig.SignKey
|
1052
|
1103
|
struct3507_2.SecretKey = miConfig.SecretKey
|
1053
|
|
- struct3507_2.FixmedinsBchno = item.Bchno
|
|
1104
|
+ struct3507_2.FixmedinsBchno = item.BgBchno
|
1054
|
1105
|
struct3507_2.InvDataType = "2"
|
1055
|
1106
|
result11, result22, _ := service.FJyb3507(struct3507_2)
|
1056
|
1107
|
saveLog(result11, result22, "3507", "3507")
|
|
@@ -1069,7 +1120,7 @@ func (c *HisApiController) DeleteXSandBG() {
|
1069
|
1120
|
}
|
1070
|
1121
|
if res2.Infcode != -1 {
|
1071
|
1122
|
item.IsChange = 0
|
1072
|
|
- item.Bchno = ""
|
|
1123
|
+ item.BgBchno = ""
|
1073
|
1124
|
service.SaveDF2(item)
|
1074
|
1125
|
} else {
|
1075
|
1126
|
err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
|
|
@@ -1120,6 +1171,7 @@ func (c *HisApiController) DeleteXSandBG() {
|
1120
|
1171
|
if res.Infcode != -1 {
|
1121
|
1172
|
item.IsSale = 0
|
1122
|
1173
|
item.SaleDate = ""
|
|
1174
|
+ item.Bchno = ""
|
1123
|
1175
|
err2 := service.SaveDF(item)
|
1124
|
1176
|
if err2 == nil {
|
1125
|
1177
|
var struct3507_2 models.Struct3507
|
|
@@ -1128,7 +1180,6 @@ func (c *HisApiController) DeleteXSandBG() {
|
1128
|
1180
|
struct3507_2.RequestUrl = miConfig.Url
|
1129
|
1181
|
struct3507_2.Opter = roles.UserName
|
1130
|
1182
|
struct3507_2.FixmedinsCode = miConfig.Code
|
1131
|
|
-
|
1132
|
1183
|
struct3507_2.SecretKey = miConfig.SecretKey
|
1133
|
1184
|
struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
|
1134
|
1185
|
struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
|
|
@@ -1138,11 +1189,10 @@ func (c *HisApiController) DeleteXSandBG() {
|
1138
|
1189
|
struct3507_2.Enckey = miConfig.EncKey
|
1139
|
1190
|
struct3507_2.SignKey = miConfig.SignKey
|
1140
|
1191
|
struct3507_2.SecretKey = miConfig.SecretKey
|
1141
|
|
- struct3507_2.FixmedinsBchno = item.Bchno
|
|
1192
|
+ struct3507_2.FixmedinsBchno = item.BgBchno
|
1142
|
1193
|
struct3507_2.InvDataType = "2"
|
1143
|
1194
|
result11, result22, _ := service.FJyb3507(struct3507_2)
|
1144
|
1195
|
saveLog(result11, result22, "3507", "3507")
|
1145
|
|
-
|
1146
|
1196
|
var respJSON3 map[string]interface{}
|
1147
|
1197
|
if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
|
1148
|
1198
|
utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
@@ -1157,7 +1207,7 @@ func (c *HisApiController) DeleteXSandBG() {
|
1157
|
1207
|
}
|
1158
|
1208
|
if res2.Infcode != -1 {
|
1159
|
1209
|
item.IsChange = 0
|
1160
|
|
- item.Bchno = ""
|
|
1210
|
+ item.BgBchno = ""
|
1161
|
1211
|
service.SaveDF2(item)
|
1162
|
1212
|
} else {
|
1163
|
1213
|
err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
|
|
@@ -1249,6 +1299,8 @@ func (c *HisApiController) DeleteXSandBG() {
|
1249
|
1299
|
if res.Infcode != -1 {
|
1250
|
1300
|
item.IsSale = 0
|
1251
|
1301
|
item.SaleDate = ""
|
|
1302
|
+ item.Bchno = ""
|
|
1303
|
+
|
1252
|
1304
|
service.SaveDF(item)
|
1253
|
1305
|
} else {
|
1254
|
1306
|
err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
|
|
@@ -1258,7 +1310,7 @@ func (c *HisApiController) DeleteXSandBG() {
|
1258
|
1310
|
|
1259
|
1311
|
var res FJ3507Result
|
1260
|
1312
|
var struct3507 models.Struct3507
|
1261
|
|
- struct3507.FixmedinsBchno = item.Bchno
|
|
1313
|
+ struct3507.FixmedinsBchno = item.BgBchno
|
1262
|
1314
|
struct3507.InvDataType = "2"
|
1263
|
1315
|
struct3507.Opter = roles.UserName
|
1264
|
1316
|
struct3507.FixmedinsCode = miConfig.Code
|
|
@@ -1291,7 +1343,7 @@ func (c *HisApiController) DeleteXSandBG() {
|
1291
|
1343
|
}
|
1292
|
1344
|
if res.Infcode != -1 {
|
1293
|
1345
|
item.IsChange = 0
|
1294
|
|
- item.Bchno = ""
|
|
1346
|
+ item.BgBchno = ""
|
1295
|
1347
|
service.SaveDF2(item)
|
1296
|
1348
|
} else {
|
1297
|
1349
|
err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
|
|
@@ -1325,8 +1377,6 @@ func (c *HisApiController) ChangeDrug() {
|
1325
|
1377
|
for _, item := range flows {
|
1326
|
1378
|
var res3 ResultSix
|
1327
|
1379
|
if item.ConsumableType == 3 { //3为自动出库 7为自动退库
|
1328
|
|
- number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3507"
|
1329
|
|
-
|
1330
|
1380
|
prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
|
1331
|
1381
|
if prescription.OrderStatus == 2 {
|
1332
|
1382
|
//已经结算
|
|
@@ -1334,7 +1384,9 @@ func (c *HisApiController) ChangeDrug() {
|
1334
|
1384
|
if item.IsSale == 1 { //是否已经销售,1是 0否
|
1335
|
1385
|
//是否已经变更 1是 0否
|
1336
|
1386
|
if item.IsChange == 0 { //没变更,进行变更操作
|
1337
|
|
- result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
|
|
1387
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
1388
|
+
|
|
1389
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
|
1338
|
1390
|
saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
|
1339
|
1391
|
var respJSON3 map[string]interface{}
|
1340
|
1392
|
if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
|
|
@@ -1350,7 +1402,7 @@ func (c *HisApiController) ChangeDrug() {
|
1350
|
1402
|
}
|
1351
|
1403
|
if res3.Infcode != -1 {
|
1352
|
1404
|
item.IsChange = 1
|
1353
|
|
- item.Bchno = item.NewDrugWarehouseInfo.Bchno
|
|
1405
|
+ item.BgBchno = bg_number
|
1354
|
1406
|
service.SaveDF2(item)
|
1355
|
1407
|
} else {
|
1356
|
1408
|
err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
@@ -1358,9 +1410,10 @@ func (c *HisApiController) ChangeDrug() {
|
1358
|
1410
|
}
|
1359
|
1411
|
} else { //没销售,
|
1360
|
1412
|
var res FJ3507Result
|
|
1413
|
+ number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
|
1361
|
1414
|
|
1362
|
1415
|
//进行商品销售接口
|
1363
|
|
- result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
|
|
1416
|
+ result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
|
1364
|
1417
|
saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
|
1365
|
1418
|
var respJSON3 map[string]interface{}
|
1366
|
1419
|
if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
|
|
@@ -1376,11 +1429,15 @@ func (c *HisApiController) ChangeDrug() {
|
1376
|
1429
|
}
|
1377
|
1430
|
if res.Infcode != -1 {
|
1378
|
1431
|
item.IsSale = 1
|
|
1432
|
+ item.Bchno = number
|
1379
|
1433
|
item.SaleDate = time.Now().Format("2006-01-02")
|
|
1434
|
+
|
1380
|
1435
|
err5 := service.SaveDF(item)
|
1381
|
1436
|
if err5 == nil {
|
1382
|
1437
|
if item.IsChange == 0 { //没变更,进行变更操作
|
1383
|
|
- result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
|
|
1438
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
1439
|
+
|
|
1440
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
|
1384
|
1441
|
saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
|
1385
|
1442
|
|
1386
|
1443
|
var respJSON3 map[string]interface{}
|
|
@@ -1397,7 +1454,7 @@ func (c *HisApiController) ChangeDrug() {
|
1397
|
1454
|
}
|
1398
|
1455
|
if res3.Infcode != -1 {
|
1399
|
1456
|
item.IsChange = 1
|
1400
|
|
- item.Bchno = item.NewDrugWarehouseInfo.Bchno
|
|
1457
|
+ item.BgBchno = bg_number
|
1401
|
1458
|
service.SaveDF2(item)
|
1402
|
1459
|
} else {
|
1403
|
1460
|
err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
@@ -1411,7 +1468,9 @@ func (c *HisApiController) ChangeDrug() {
|
1411
|
1468
|
|
1412
|
1469
|
} else { //还没结算
|
1413
|
1470
|
if item.IsChange == 0 { //没变更,进行变更操作
|
1414
|
|
- result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
|
|
1471
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
1472
|
+
|
|
1473
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
|
1415
|
1474
|
saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
|
1416
|
1475
|
|
1417
|
1476
|
var respJSON3 map[string]interface{}
|
|
@@ -1428,7 +1487,7 @@ func (c *HisApiController) ChangeDrug() {
|
1428
|
1487
|
}
|
1429
|
1488
|
if res3.Infcode != -1 {
|
1430
|
1489
|
item.IsChange = 1
|
1431
|
|
- item.Bchno = item.NewDrugWarehouseInfo.Bchno
|
|
1490
|
+ item.BgBchno = bg_number
|
1432
|
1491
|
service.SaveDF2(item)
|
1433
|
1492
|
} else {
|
1434
|
1493
|
err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
@@ -1443,7 +1502,9 @@ func (c *HisApiController) ChangeDrug() {
|
1443
|
1502
|
if item.IsSale == 2 { //是否已经销售,1是 0否
|
1444
|
1503
|
//是否已经变更 1是 0否
|
1445
|
1504
|
if item.IsChange == 0 { //没变更,进行变更操作
|
1446
|
|
- result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
|
|
1505
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
1506
|
+
|
|
1507
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
|
1447
|
1508
|
saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
|
1448
|
1509
|
|
1449
|
1510
|
var respJSON3 map[string]interface{}
|
|
@@ -1460,7 +1521,7 @@ func (c *HisApiController) ChangeDrug() {
|
1460
|
1521
|
}
|
1461
|
1522
|
if res3.Infcode != -1 {
|
1462
|
1523
|
item.IsChange = 1
|
1463
|
|
- item.Bchno = item.NewDrugWarehouseInfo.Bchno
|
|
1524
|
+ item.BgBchno = bg_number
|
1464
|
1525
|
service.SaveDF2(item)
|
1465
|
1526
|
} else {
|
1466
|
1527
|
err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
@@ -1468,13 +1529,15 @@ func (c *HisApiController) ChangeDrug() {
|
1468
|
1529
|
}
|
1469
|
1530
|
} else { //没销售,
|
1470
|
1531
|
//进行商品销售退货接口
|
1471
|
|
- result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
|
|
1532
|
+ number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
|
|
1533
|
+
|
|
1534
|
+ result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
|
1472
|
1535
|
saveLog(result111, result222, "3506", "销售退货")
|
1473
|
1536
|
var res7 FJ3507Result
|
1474
|
1537
|
|
1475
|
1538
|
//进行商品销售接口
|
1476
|
|
- result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
|
1477
|
|
- saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
|
|
1539
|
+ //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
|
|
1540
|
+ //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
|
1478
|
1541
|
var respJSON3 map[string]interface{}
|
1479
|
1542
|
if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
|
1480
|
1543
|
utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
@@ -1490,9 +1553,12 @@ func (c *HisApiController) ChangeDrug() {
|
1490
|
1553
|
if res7.Infcode != -1 {
|
1491
|
1554
|
item.IsSale = 2
|
1492
|
1555
|
item.SaleDate = item.SaleDate
|
|
1556
|
+ item.Bchno = number
|
1493
|
1557
|
service.SaveDF(item)
|
1494
|
1558
|
if item.IsChange == 0 { //没变更,进行变更操作
|
1495
|
|
- result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
|
|
1559
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
1560
|
+
|
|
1561
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
|
1496
|
1562
|
saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
|
1497
|
1563
|
|
1498
|
1564
|
var respJSON3 map[string]interface{}
|
|
@@ -1509,7 +1575,7 @@ func (c *HisApiController) ChangeDrug() {
|
1509
|
1575
|
}
|
1510
|
1576
|
if res3.Infcode != -1 {
|
1511
|
1577
|
item.IsChange = 1
|
1512
|
|
- item.Bchno = item.NewDrugWarehouseInfo.Bchno
|
|
1578
|
+ item.BgBchno = bg_number
|
1513
|
1579
|
service.SaveDF2(item)
|
1514
|
1580
|
} else {
|
1515
|
1581
|
err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
@@ -1521,7 +1587,9 @@ func (c *HisApiController) ChangeDrug() {
|
1521
|
1587
|
}
|
1522
|
1588
|
} else { //还没结算
|
1523
|
1589
|
if item.IsChange == 0 { //没变更,进行变更操作
|
1524
|
|
- result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
|
|
1590
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
1591
|
+
|
|
1592
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles, bg_number)
|
1525
|
1593
|
saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
|
1526
|
1594
|
|
1527
|
1595
|
var respJSON3 map[string]interface{}
|
|
@@ -1538,7 +1606,7 @@ func (c *HisApiController) ChangeDrug() {
|
1538
|
1606
|
}
|
1539
|
1607
|
if res3.Infcode != -1 {
|
1540
|
1608
|
item.IsChange = 1
|
1541
|
|
- item.Bchno = item.NewDrugWarehouseInfo.Bchno
|
|
1609
|
+ item.BgBchno = bg_number
|
1542
|
1610
|
service.SaveDF2(item)
|
1543
|
1611
|
} else {
|
1544
|
1612
|
err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
@@ -1546,32 +1614,6 @@ func (c *HisApiController) ChangeDrug() {
|
1546
|
1614
|
}
|
1547
|
1615
|
}
|
1548
|
1616
|
}
|
1549
|
|
- //else { //其他方式
|
1550
|
|
- // //if item.IsChange == 0 { //没变更,进行变更操作
|
1551
|
|
- // // result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
|
1552
|
|
- // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
|
1553
|
|
- // //
|
1554
|
|
- // // var respJSON3 map[string]interface{}
|
1555
|
|
- // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
|
1556
|
|
- // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
1557
|
|
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1558
|
|
- // // return
|
1559
|
|
- // // }
|
1560
|
|
- // // userJSONBytes3, _ := json.Marshal(respJSON3)
|
1561
|
|
- // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
|
1562
|
|
- // // utils.ErrorLog("解析失败:%v", err)
|
1563
|
|
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1564
|
|
- // // return
|
1565
|
|
- // // }
|
1566
|
|
- // // if res3.Infcode != -1{
|
1567
|
|
- // // item.IsChange = 1
|
1568
|
|
- // // item.Bchno = item.NewDrugWarehouseInfo.Bchno
|
1569
|
|
- // // service.SaveDF2(item)
|
1570
|
|
- // // }else{
|
1571
|
|
- // // err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
|
1572
|
|
- // // }
|
1573
|
|
- // //}
|
1574
|
|
- //}
|
1575
|
1617
|
}
|
1576
|
1618
|
if len(err) == 0 {
|
1577
|
1619
|
c.ServeSuccessJSON(map[string]interface{}{
|
|
@@ -1584,7 +1626,7 @@ func (c *HisApiController) ChangeDrug() {
|
1584
|
1626
|
})
|
1585
|
1627
|
}
|
1586
|
1628
|
}
|
1587
|
|
-func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string) {
|
|
1629
|
+func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
|
1588
|
1630
|
var struct3502 models.Struct3502
|
1589
|
1631
|
struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
|
1590
|
1632
|
struct3502.FixmedinsHilistId = miConfig.Code
|
|
@@ -1606,18 +1648,18 @@ func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsu
|
1606
|
1648
|
struct3502.SignKey = miConfig.SignKey
|
1607
|
1649
|
struct3502.SecretKey = miConfig.SecretKey
|
1608
|
1650
|
struct3502.InvChgType = chgType
|
1609
|
|
- struct3502.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
|
|
1651
|
+ struct3502.FixmedinsBchno = number
|
1610
|
1652
|
struct3502.Cnt = strconv.FormatInt(count, 10)
|
1611
|
1653
|
struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
|
1612
|
1654
|
result1, result2, _ := service.FJyb3502(struct3502)
|
1613
|
1655
|
return result1, result2
|
1614
|
1656
|
}
|
1615
|
|
-func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string) {
|
|
1657
|
+func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
|
1616
|
1658
|
var struct3505 models.Struct3505
|
1617
|
1659
|
struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
|
1618
|
1660
|
struct3505.FixmedinsHilistId = miConfig.Code
|
1619
|
1661
|
struct3505.FixmedinsHilistName = miConfig.OrgName
|
1620
|
|
- struct3505.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
|
|
1662
|
+ struct3505.FixmedinsBchno = number
|
1621
|
1663
|
struct3505.Opter = role.UserName
|
1622
|
1664
|
|
1623
|
1665
|
struct3505.FixmedinsCode = miConfig.Code
|
|
@@ -1659,13 +1701,13 @@ func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow,
|
1659
|
1701
|
return result1, result2
|
1660
|
1702
|
|
1661
|
1703
|
}
|
1662
|
|
-func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string) {
|
|
1704
|
+func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
|
1663
|
1705
|
var struct3506 models.Struct3506
|
1664
|
1706
|
struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
|
1665
|
1707
|
struct3506.FixmedinsHilistId = miConfig.Code
|
1666
|
1708
|
struct3506.FixmedinsHilistName = miConfig.OrgName
|
1667
|
1709
|
struct3506.FixmedinsCode = miConfig.Code
|
1668
|
|
- struct3506.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
|
|
1710
|
+ struct3506.FixmedinsBchno = number
|
1669
|
1711
|
struct3506.Opter = role.UserName
|
1670
|
1712
|
order := service.GetHisOrderByNumber(pre.BatchNumber)
|
1671
|
1713
|
struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
|