|
@@ -4,10 +4,12 @@ import (
|
4
|
4
|
"XT_New/enums"
|
5
|
5
|
"XT_New/models"
|
6
|
6
|
"XT_New/service"
|
|
7
|
+ "XT_New/utils"
|
7
|
8
|
"encoding/json"
|
8
|
9
|
"fmt"
|
9
|
10
|
"github.com/astaxie/beego"
|
10
|
11
|
"github.com/jinzhu/gorm"
|
|
12
|
+ "reflect"
|
11
|
13
|
"strconv"
|
12
|
14
|
"strings"
|
13
|
15
|
"time"
|
|
@@ -52,6 +54,21 @@ func SelfDrugRouters() {
|
52
|
54
|
beego.Router("/api/drug/getpatientdetail", &SelfDrugApiController{}, "Get:GetPatientDetail")
|
53
|
55
|
|
54
|
56
|
beego.Router("/api/drug/getselfstockquery", &SelfDrugApiController{}, "Get:GetSelfStockQuery")
|
|
57
|
+ beego.Router("/api/drug/postsearchdrugwarehouselist", &SelfDrugApiController{}, "Get:PostSearchDrugWarehouseList")
|
|
58
|
+ beego.Router("/api/drug/savedrugpriceone", &SelfDrugApiController{}, "Post:SaveDrugPrice")
|
|
59
|
+ beego.Router("/api/drug/drugpricelist", &SelfDrugApiController{}, "Get:GetDrugPriceList")
|
|
60
|
+ beego.Router("/api/drug/savecheckdrugprice", &SelfDrugApiController{}, "Get:SaveCheckDrugPrice")
|
|
61
|
+ beego.Router("/api/drug/savedrugdamageone", &SelfDrugApiController{}, "Post:SaveDrugDamage")
|
|
62
|
+ beego.Router("/api/drug/getdrugdamagelist", &SelfDrugApiController{}, "Get:GetDrugDamageList")
|
|
63
|
+ beego.Router("/api/drug/savedrugdamageprice", &SelfDrugApiController{}, "Get:SaveDrugDamagePrice")
|
|
64
|
+ beego.Router("/api/drug/getdrugmodifyprice", &SelfDrugApiController{}, "Get:GetDrugModifyPrice")
|
|
65
|
+ beego.Router("/api/drug/modifydrugprice", &SelfDrugApiController{}, "Get:ModifyDrugPrice")
|
|
66
|
+ beego.Router("/api/drug/getmodifypriceprint", &SelfDrugApiController{}, "Get:GetModifyPricePrint")
|
|
67
|
+ beego.Router("/api/drug/getdrugdamagedetail", &SelfDrugApiController{}, "Get:GetDrugDamageDetail")
|
|
68
|
+ beego.Router("/api/drug/modifydrugdamage", &SelfDrugApiController{}, "Get:ModifyDrugDamage")
|
|
69
|
+ beego.Router("/api/drug/deletedrugdamage", &SelfDrugApiController{}, "Get:DeleteDrugDamage")
|
|
70
|
+ beego.Router("/api/drug/getdrugdamageprint", &SelfDrugApiController{}, "Get:GetDrugDamagePrint")
|
|
71
|
+ beego.Router("/api/drug/warehouseinfobyid", &SelfDrugApiController{}, "Get:GetWarehoseInfoById")
|
55
|
72
|
}
|
56
|
73
|
|
57
|
74
|
func (this *SelfDrugApiController) GetCurrentPatient() {
|
|
@@ -913,3 +930,627 @@ func (this *SelfDrugApiController) GetSelfStockQuery() {
|
913
|
930
|
"stockOutQuery": stockOutQuery,
|
914
|
931
|
})
|
915
|
932
|
}
|
|
933
|
+
|
|
934
|
+func (this *SelfDrugApiController) PostSearchDrugWarehouseList() {
|
|
935
|
+
|
|
936
|
+ keyword := this.GetString("keyword")
|
|
937
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
938
|
+ list, err := service.PostSearchDrugWarehouseList(keyword, orgId)
|
|
939
|
+ manufacturerList, err := service.GetAllManufacturerList(orgId)
|
|
940
|
+ dealerList, err := service.GetAllDealerList(orgId)
|
|
941
|
+ if err != nil {
|
|
942
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
|
|
943
|
+ return
|
|
944
|
+ }
|
|
945
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
946
|
+ "list": list,
|
|
947
|
+ "manufacturerList": manufacturerList,
|
|
948
|
+ "dealerList": dealerList,
|
|
949
|
+ })
|
|
950
|
+}
|
|
951
|
+
|
|
952
|
+func (this *SelfDrugApiController) SaveDrugPrice() {
|
|
953
|
+ fmt.Println("999999999999999999999")
|
|
954
|
+ timeLayout := "2006-01-02"
|
|
955
|
+ loc, _ := time.LoadLocation("Local")
|
|
956
|
+ dataBody := make(map[string]interface{}, 0)
|
|
957
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
958
|
+ fmt.Println(err)
|
|
959
|
+
|
|
960
|
+ tableData, _ := dataBody["tableData"].([]interface{})
|
|
961
|
+ fmt.Println("999939433443", tableData)
|
|
962
|
+ if len(tableData) > 0 {
|
|
963
|
+ for _, item := range tableData {
|
|
964
|
+ items := item.(map[string]interface{})
|
|
965
|
+
|
|
966
|
+ if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
|
|
967
|
+ utils.ErrorLog("drug_name")
|
|
968
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
969
|
+ return
|
|
970
|
+ }
|
|
971
|
+ drug_name := items["drug_name"].(string)
|
|
972
|
+ fmt.Println("drug_aname23232323232", drug_name)
|
|
973
|
+ if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
|
|
974
|
+ utils.ErrorLog("drug_name")
|
|
975
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
976
|
+ return
|
|
977
|
+ }
|
|
978
|
+
|
|
979
|
+ if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
|
|
980
|
+ utils.ErrorLog("retail_price")
|
|
981
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
982
|
+ return
|
|
983
|
+ }
|
|
984
|
+ retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
|
|
985
|
+
|
|
986
|
+ if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
|
|
987
|
+ utils.ErrorLog("warehousing_order")
|
|
988
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
989
|
+ return
|
|
990
|
+ }
|
|
991
|
+ warehousing_order := items["warehousing_order"].(string)
|
|
992
|
+
|
|
993
|
+ if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
|
|
994
|
+ utils.ErrorLog("number")
|
|
995
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
996
|
+ return
|
|
997
|
+ }
|
|
998
|
+ number := items["number"].(string)
|
|
999
|
+
|
|
1000
|
+ if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
|
|
1001
|
+ utils.ErrorLog("dealer")
|
|
1002
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1003
|
+ return
|
|
1004
|
+ }
|
|
1005
|
+ dealer := items["dealer"].(string)
|
|
1006
|
+
|
|
1007
|
+ if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
|
|
1008
|
+ utils.ErrorLog("manufacturer")
|
|
1009
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1010
|
+ return
|
|
1011
|
+ }
|
|
1012
|
+ manufacturer := items["manufacturer"].(string)
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+ if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
|
|
1022
|
+ utils.ErrorLog("remark")
|
|
1023
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1024
|
+ return
|
|
1025
|
+ }
|
|
1026
|
+ remark := items["remark"].(string)
|
|
1027
|
+
|
|
1028
|
+ if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
|
|
1029
|
+ utils.ErrorLog("warehousing_unit")
|
|
1030
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1031
|
+ return
|
|
1032
|
+ }
|
|
1033
|
+ warehousing_unit := items["warehousing_unit"].(string)
|
|
1034
|
+
|
|
1035
|
+ if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
|
|
1036
|
+ utils.ErrorLog("last_price")
|
|
1037
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1038
|
+ return
|
|
1039
|
+ }
|
|
1040
|
+ last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
|
|
1041
|
+
|
|
1042
|
+ if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
|
|
1043
|
+ utils.ErrorLog("count")
|
|
1044
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1045
|
+ return
|
|
1046
|
+ }
|
|
1047
|
+ count := int64(items["count"].(float64))
|
|
1048
|
+
|
|
1049
|
+ if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
|
|
1050
|
+ utils.ErrorLog("new_price")
|
|
1051
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1052
|
+ return
|
|
1053
|
+ }
|
|
1054
|
+ new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
|
|
1055
|
+
|
|
1056
|
+ if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
|
|
1057
|
+ utils.ErrorLog("drug_id")
|
|
1058
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1059
|
+ return
|
|
1060
|
+ }
|
|
1061
|
+ drug_id := int64(items["drug_id"].(float64))
|
|
1062
|
+
|
|
1063
|
+ if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
|
|
1064
|
+ utils.ErrorLog("start_time")
|
|
1065
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1066
|
+ return
|
|
1067
|
+ }
|
|
1068
|
+ var startTime int64
|
|
1069
|
+ start_time := items["start_time"].(string)
|
|
1070
|
+ if len(start_time) > 0 {
|
|
1071
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
1072
|
+ if err != nil {
|
|
1073
|
+ fmt.Println(err)
|
|
1074
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1075
|
+ return
|
|
1076
|
+ }
|
|
1077
|
+ startTime = theTime.Unix()
|
|
1078
|
+ }
|
|
1079
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1080
|
+ Creater := this.GetAdminUserInfo().AdminUser.Id
|
|
1081
|
+
|
|
1082
|
+ drugAdjust := models.XtDrugAdjustPrice{
|
|
1083
|
+ DrugName: drug_name,
|
|
1084
|
+ SpecificationName: "",
|
|
1085
|
+ WarehousingUnit: warehousing_unit,
|
|
1086
|
+ Count: count,
|
|
1087
|
+ LastPrice: last_price,
|
|
1088
|
+ RetailPrice: retail_price,
|
|
1089
|
+ NewPrice: new_price,
|
|
1090
|
+ Manufacturer: manufacturer,
|
|
1091
|
+ Dealer: dealer,
|
|
1092
|
+ Remark: remark,
|
|
1093
|
+ DrugId: drug_id,
|
|
1094
|
+ UserOrgId: orgId,
|
|
1095
|
+ Ctime: time.Now().Unix(),
|
|
1096
|
+ Mtime: 0,
|
|
1097
|
+ Status: 1,
|
|
1098
|
+ WarehousingOrder: warehousing_order,
|
|
1099
|
+ Number: number,
|
|
1100
|
+ StartTime: startTime,
|
|
1101
|
+ Creater: Creater,
|
|
1102
|
+ Checker: 0,
|
|
1103
|
+ CheckerStatus: 2,
|
|
1104
|
+ CheckerTime: 0,
|
|
1105
|
+ }
|
|
1106
|
+
|
|
1107
|
+ err := service.CreateDrugPrice(drugAdjust)
|
|
1108
|
+ fmt.Println(err)
|
|
1109
|
+ }
|
|
1110
|
+ }
|
|
1111
|
+ returnData := make(map[string]interface{}, 0)
|
|
1112
|
+ returnData["msg"] = "ok"
|
|
1113
|
+ this.ServeSuccessJSON(returnData)
|
|
1114
|
+ return
|
|
1115
|
+}
|
|
1116
|
+
|
|
1117
|
+func (this *SelfDrugApiController) GetDrugPriceList() {
|
|
1118
|
+
|
|
1119
|
+ timeLayout := "2006-01-02"
|
|
1120
|
+ loc, _ := time.LoadLocation("Local")
|
|
1121
|
+ dataBody := make(map[string]interface{}, 0)
|
|
1122
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
1123
|
+ fmt.Println(err)
|
|
1124
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1125
|
+ keyword := this.GetString("keyword")
|
|
1126
|
+
|
|
1127
|
+ start_time := this.GetString("start_time")
|
|
1128
|
+ end_time := this.GetString("end_time")
|
|
1129
|
+ var startTime int64
|
|
1130
|
+ if len(start_time) > 0 {
|
|
1131
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
1132
|
+ if err != nil {
|
|
1133
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1134
|
+ return
|
|
1135
|
+ }
|
|
1136
|
+ startTime = theTime.Unix()
|
|
1137
|
+ }
|
|
1138
|
+ var endTime int64
|
|
1139
|
+ if len(end_time) > 0 {
|
|
1140
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
1141
|
+ if err != nil {
|
|
1142
|
+ utils.ErrorLog(err.Error())
|
|
1143
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1144
|
+ return
|
|
1145
|
+ }
|
|
1146
|
+ endTime = theTime.Unix()
|
|
1147
|
+ }
|
|
1148
|
+ limit, _ := this.GetInt64("limit")
|
|
1149
|
+ page, _ := this.GetInt64("page")
|
|
1150
|
+ list, total, err := service.GetDrugPriceList(startTime, endTime, orgId, keyword, limit, page)
|
|
1151
|
+ doctorList, err := service.GetAllDoctorThree(orgId)
|
|
1152
|
+ if err != nil {
|
|
1153
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
|
|
1154
|
+ return
|
|
1155
|
+ }
|
|
1156
|
+
|
|
1157
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1158
|
+ "total": total,
|
|
1159
|
+ "list": list,
|
|
1160
|
+ "doctorList": doctorList,
|
|
1161
|
+ })
|
|
1162
|
+}
|
|
1163
|
+
|
|
1164
|
+func (this *SelfDrugApiController) SaveCheckDrugPrice() {
|
|
1165
|
+ timeLayout := "2006-01-02"
|
|
1166
|
+ loc, _ := time.LoadLocation("Local")
|
|
1167
|
+ dataBody := make(map[string]interface{}, 0)
|
|
1168
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
1169
|
+ fmt.Println(err)
|
|
1170
|
+ idstr := this.GetString("ids")
|
|
1171
|
+ ids := strings.Split(idstr, ",")
|
|
1172
|
+ check_time := this.GetString("check_time")
|
|
1173
|
+ var checkTime int64
|
|
1174
|
+ if len(check_time) > 0 {
|
|
1175
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
|
|
1176
|
+ if err != nil {
|
|
1177
|
+ fmt.Println(err)
|
|
1178
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1179
|
+ return
|
|
1180
|
+ }
|
|
1181
|
+ checkTime = theTime.Unix()
|
|
1182
|
+ }
|
|
1183
|
+ checker, _ := this.GetInt64("checker")
|
|
1184
|
+ adjustPrice := models.XtDrugAdjustPrice{
|
|
1185
|
+ Checker: checker,
|
|
1186
|
+ CheckerStatus: 1,
|
|
1187
|
+ CheckerTime: checkTime,
|
|
1188
|
+ }
|
|
1189
|
+ err = service.UpdateDrugAdjuestPrice(ids, adjustPrice)
|
|
1190
|
+ fmt.Println("err", err)
|
|
1191
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1192
|
+ "adjustPrice": adjustPrice,
|
|
1193
|
+ })
|
|
1194
|
+}
|
|
1195
|
+
|
|
1196
|
+func (this *SelfDrugApiController) SaveDrugDamage() {
|
|
1197
|
+ fmt.Println("999999999999999999999")
|
|
1198
|
+ timeLayout := "2006-01-02"
|
|
1199
|
+ loc, _ := time.LoadLocation("Local")
|
|
1200
|
+ dataBody := make(map[string]interface{}, 0)
|
|
1201
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
1202
|
+ fmt.Println(err)
|
|
1203
|
+
|
|
1204
|
+ tableData, _ := dataBody["tableData"].([]interface{})
|
|
1205
|
+ fmt.Println("999939433443", tableData)
|
|
1206
|
+ if len(tableData) > 0 {
|
|
1207
|
+ for _, item := range tableData {
|
|
1208
|
+ items := item.(map[string]interface{})
|
|
1209
|
+ drug_name := items["drug_name"].(string)
|
|
1210
|
+ fmt.Println("durg_nae232333223332232323323223232323", drug_name)
|
|
1211
|
+ if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
|
|
1212
|
+ utils.ErrorLog("drug_name")
|
|
1213
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1214
|
+ return
|
|
1215
|
+ }
|
|
1216
|
+
|
|
1217
|
+ if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
|
|
1218
|
+ utils.ErrorLog("retail_price")
|
|
1219
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1220
|
+ return
|
|
1221
|
+ }
|
|
1222
|
+ retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
|
|
1223
|
+
|
|
1224
|
+ if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
|
|
1225
|
+ utils.ErrorLog("warehousing_order")
|
|
1226
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1227
|
+ return
|
|
1228
|
+ }
|
|
1229
|
+ warehousing_order := items["warehousing_order"].(string)
|
|
1230
|
+
|
|
1231
|
+ if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
|
|
1232
|
+ utils.ErrorLog("number")
|
|
1233
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1234
|
+ return
|
|
1235
|
+ }
|
|
1236
|
+ number := items["number"].(string)
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+ if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
|
|
1246
|
+ utils.ErrorLog("manufacturer")
|
|
1247
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1248
|
+ return
|
|
1249
|
+ }
|
|
1250
|
+ manufacturer := items["manufacturer"].(string)
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+ if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
|
|
1260
|
+ utils.ErrorLog("remark")
|
|
1261
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1262
|
+ return
|
|
1263
|
+ }
|
|
1264
|
+ remark := items["remark"].(string)
|
|
1265
|
+
|
|
1266
|
+ if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
|
|
1267
|
+ utils.ErrorLog("warehousing_unit")
|
|
1268
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1269
|
+ return
|
|
1270
|
+ }
|
|
1271
|
+ warehousing_unit := items["warehousing_unit"].(string)
|
|
1272
|
+
|
|
1273
|
+ if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
|
|
1274
|
+ utils.ErrorLog("last_price")
|
|
1275
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1276
|
+ return
|
|
1277
|
+ }
|
|
1278
|
+ last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
|
|
1279
|
+
|
|
1280
|
+ if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
|
|
1281
|
+ utils.ErrorLog("count")
|
|
1282
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1283
|
+ return
|
|
1284
|
+ }
|
|
1285
|
+ count := int64(items["count"].(float64))
|
|
1286
|
+
|
|
1287
|
+ if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
|
|
1288
|
+ utils.ErrorLog("new_price")
|
|
1289
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1290
|
+ return
|
|
1291
|
+ }
|
|
1292
|
+ new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
|
|
1293
|
+
|
|
1294
|
+ if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
|
|
1295
|
+ utils.ErrorLog("drug_id")
|
|
1296
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1297
|
+ return
|
|
1298
|
+ }
|
|
1299
|
+ drug_id := int64(items["drug_id"].(float64))
|
|
1300
|
+
|
|
1301
|
+ if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
|
|
1302
|
+ utils.ErrorLog("start_time")
|
|
1303
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1304
|
+ return
|
|
1305
|
+ }
|
|
1306
|
+ var startTime int64
|
|
1307
|
+ start_time := items["start_time"].(string)
|
|
1308
|
+ if len(start_time) > 0 {
|
|
1309
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
1310
|
+ if err != nil {
|
|
1311
|
+ fmt.Println(err)
|
|
1312
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1313
|
+ return
|
|
1314
|
+ }
|
|
1315
|
+ startTime = theTime.Unix()
|
|
1316
|
+ }
|
|
1317
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1318
|
+ Creater := this.GetAdminUserInfo().AdminUser.Id
|
|
1319
|
+
|
|
1320
|
+ drugDamage := models.XtDrugDamage{
|
|
1321
|
+ DrugName: drug_name,
|
|
1322
|
+ SpecificationName: "",
|
|
1323
|
+ WarehousingUnit: warehousing_unit,
|
|
1324
|
+ Count: count,
|
|
1325
|
+ LastPrice: last_price,
|
|
1326
|
+ RetailPrice: retail_price,
|
|
1327
|
+ NewPrice: new_price,
|
|
1328
|
+ Manufacturer: manufacturer,
|
|
1329
|
+ Dealer: "",
|
|
1330
|
+ Remark: remark,
|
|
1331
|
+ DrugId: drug_id,
|
|
1332
|
+ UserOrgId: orgId,
|
|
1333
|
+ Ctime: time.Now().Unix(),
|
|
1334
|
+ Mtime: 0,
|
|
1335
|
+ Status: 1,
|
|
1336
|
+ WarehousingOrder: warehousing_order,
|
|
1337
|
+ Number: number,
|
|
1338
|
+ StartTime: startTime,
|
|
1339
|
+ Creater: Creater,
|
|
1340
|
+ Checker: 0,
|
|
1341
|
+ CheckerStatus: 2,
|
|
1342
|
+ CheckerTime: 0,
|
|
1343
|
+ }
|
|
1344
|
+
|
|
1345
|
+ err := service.CreateDrugDamage(drugDamage)
|
|
1346
|
+ fmt.Println(err)
|
|
1347
|
+ }
|
|
1348
|
+ }
|
|
1349
|
+ returnData := make(map[string]interface{}, 0)
|
|
1350
|
+ returnData["msg"] = "ok"
|
|
1351
|
+ this.ServeSuccessJSON(returnData)
|
|
1352
|
+}
|
|
1353
|
+
|
|
1354
|
+func (this *SelfDrugApiController) GetDrugDamageList() {
|
|
1355
|
+
|
|
1356
|
+ timeLayout := "2006-01-02"
|
|
1357
|
+ loc, _ := time.LoadLocation("Local")
|
|
1358
|
+ dataBody := make(map[string]interface{}, 0)
|
|
1359
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
1360
|
+ fmt.Println(err)
|
|
1361
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
1362
|
+ keyword := this.GetString("keyword")
|
|
1363
|
+ fmt.Println("keywoer2r2r32rwrwr", keyword)
|
|
1364
|
+ start_time := this.GetString("start_time")
|
|
1365
|
+ end_time := this.GetString("end_time")
|
|
1366
|
+ var startTime int64
|
|
1367
|
+ if len(start_time) > 0 {
|
|
1368
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
1369
|
+ if err != nil {
|
|
1370
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1371
|
+ return
|
|
1372
|
+ }
|
|
1373
|
+ startTime = theTime.Unix()
|
|
1374
|
+ }
|
|
1375
|
+ var endTime int64
|
|
1376
|
+ if len(end_time) > 0 {
|
|
1377
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
1378
|
+ if err != nil {
|
|
1379
|
+ utils.ErrorLog(err.Error())
|
|
1380
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1381
|
+ return
|
|
1382
|
+ }
|
|
1383
|
+ endTime = theTime.Unix()
|
|
1384
|
+ }
|
|
1385
|
+
|
|
1386
|
+ limit, _ := this.GetInt64("limit")
|
|
1387
|
+ page, _ := this.GetInt64("page")
|
|
1388
|
+ list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page)
|
|
1389
|
+ doctorList, err := service.GetAllDoctorThree(orgId)
|
|
1390
|
+ if err != nil {
|
|
1391
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
|
|
1392
|
+ return
|
|
1393
|
+ }
|
|
1394
|
+ fmt.Println("list232332", list)
|
|
1395
|
+ fmt.Println("total", total)
|
|
1396
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1397
|
+ "total": total,
|
|
1398
|
+ "list": list,
|
|
1399
|
+ "doctorList": doctorList,
|
|
1400
|
+ })
|
|
1401
|
+}
|
|
1402
|
+
|
|
1403
|
+func (this *SelfDrugApiController) SaveDrugDamagePrice() {
|
|
1404
|
+
|
|
1405
|
+ timeLayout := "2006-01-02"
|
|
1406
|
+ loc, _ := time.LoadLocation("Local")
|
|
1407
|
+ dataBody := make(map[string]interface{}, 0)
|
|
1408
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
1409
|
+ fmt.Println(err)
|
|
1410
|
+ idstr := this.GetString("ids")
|
|
1411
|
+ ids := strings.Split(idstr, ",")
|
|
1412
|
+ check_time := this.GetString("check_time")
|
|
1413
|
+ var checkTime int64
|
|
1414
|
+ if len(check_time) > 0 {
|
|
1415
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
|
|
1416
|
+ if err != nil {
|
|
1417
|
+ fmt.Println(err)
|
|
1418
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1419
|
+ return
|
|
1420
|
+ }
|
|
1421
|
+ checkTime = theTime.Unix()
|
|
1422
|
+ }
|
|
1423
|
+ checker, _ := this.GetInt64("checker")
|
|
1424
|
+ damage := models.XtDrugDamage{
|
|
1425
|
+ Checker: checker,
|
|
1426
|
+ CheckerStatus: 1,
|
|
1427
|
+ CheckerTime: checkTime,
|
|
1428
|
+ }
|
|
1429
|
+ err = service.UpdateDrugDamage(ids, damage)
|
|
1430
|
+ fmt.Println(err)
|
|
1431
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1432
|
+ "damage": damage,
|
|
1433
|
+ })
|
|
1434
|
+}
|
|
1435
|
+
|
|
1436
|
+func (this *SelfDrugApiController) GetDrugModifyPrice() {
|
|
1437
|
+
|
|
1438
|
+ id, _ := this.GetInt64("id")
|
|
1439
|
+ detail, err := service.GetDrugModifyPrice(id)
|
|
1440
|
+ fmt.Println(err)
|
|
1441
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1442
|
+ "detail": detail,
|
|
1443
|
+ })
|
|
1444
|
+}
|
|
1445
|
+
|
|
1446
|
+func (this *SelfDrugApiController) ModifyDrugPrice() {
|
|
1447
|
+
|
|
1448
|
+ drug_name := this.GetString("drug_name")
|
|
1449
|
+ retailPrice := this.GetString("retail_price")
|
|
1450
|
+ retail_price, _ := strconv.ParseFloat(retailPrice, 64)
|
|
1451
|
+ newPrice := this.GetString("new_price")
|
|
1452
|
+ new_price, _ := strconv.ParseFloat(newPrice, 64)
|
|
1453
|
+ count, _ := this.GetInt64("count")
|
|
1454
|
+ remark := this.GetString("remark")
|
|
1455
|
+ id, _ := this.GetInt64("id")
|
|
1456
|
+ adjustPrice := models.XtDrugAdjustPrice{
|
|
1457
|
+ DrugName: drug_name,
|
|
1458
|
+ Count: count,
|
|
1459
|
+ RetailPrice: retail_price,
|
|
1460
|
+ NewPrice: new_price,
|
|
1461
|
+ Remark: remark,
|
|
1462
|
+ }
|
|
1463
|
+ err := service.ModifyDrugPrice(id, adjustPrice)
|
|
1464
|
+ fmt.Println(err)
|
|
1465
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1466
|
+ "adjustPrice": adjustPrice,
|
|
1467
|
+ })
|
|
1468
|
+}
|
|
1469
|
+
|
|
1470
|
+func (this *SelfDrugApiController) GetModifyPricePrint() {
|
|
1471
|
+
|
|
1472
|
+ ids := this.GetString("ids")
|
|
1473
|
+ idsSplit := strings.Split(ids, ",")
|
|
1474
|
+ list, err := service.GetModifyPricePrint(idsSplit)
|
|
1475
|
+ fmt.Println(err)
|
|
1476
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1477
|
+ "list": list,
|
|
1478
|
+ })
|
|
1479
|
+}
|
|
1480
|
+
|
|
1481
|
+func (this *SelfDrugApiController) GetDrugDamageDetail() {
|
|
1482
|
+
|
|
1483
|
+ id, _ := this.GetInt64("id")
|
|
1484
|
+ detail, _ := service.GetDrugDamageDetail(id)
|
|
1485
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1486
|
+ "detail": detail,
|
|
1487
|
+ })
|
|
1488
|
+}
|
|
1489
|
+
|
|
1490
|
+func (this *SelfDrugApiController) ModifyDrugDamage() {
|
|
1491
|
+
|
|
1492
|
+ id, _ := this.GetInt64("id")
|
|
1493
|
+ drug_id, _ := this.GetInt64("drug_id")
|
|
1494
|
+ drug_name := this.GetString("drug_name")
|
|
1495
|
+
|
|
1496
|
+ lastPrice := this.GetString("last_price")
|
|
1497
|
+ last_price, _ := strconv.ParseFloat(lastPrice, 64)
|
|
1498
|
+ newPrice := this.GetString("new_price")
|
|
1499
|
+ new_price, _ := strconv.ParseFloat(newPrice, 64)
|
|
1500
|
+ manufacturer := this.GetString("manufacturer")
|
|
1501
|
+ number := this.GetString("number")
|
|
1502
|
+ retailPrice := this.GetString("retail_price")
|
|
1503
|
+ retail_price, _ := strconv.ParseFloat(retailPrice, 64)
|
|
1504
|
+ remark := this.GetString("remark")
|
|
1505
|
+ count, _ := this.GetInt64("count")
|
|
1506
|
+ warehousing_unit := this.GetString("warehousing_unit")
|
|
1507
|
+
|
|
1508
|
+ damage := models.XtDrugDamage{
|
|
1509
|
+ DrugName: drug_name,
|
|
1510
|
+ SpecificationName: "",
|
|
1511
|
+ WarehousingUnit: warehousing_unit,
|
|
1512
|
+ Count: count,
|
|
1513
|
+ LastPrice: last_price,
|
|
1514
|
+ RetailPrice: retail_price,
|
|
1515
|
+ NewPrice: new_price,
|
|
1516
|
+ Manufacturer: manufacturer,
|
|
1517
|
+ Dealer: "",
|
|
1518
|
+ Remark: remark,
|
|
1519
|
+ DrugId: drug_id,
|
|
1520
|
+ Number: number,
|
|
1521
|
+ }
|
|
1522
|
+ err := service.ModifyDrugDamage(id, damage)
|
|
1523
|
+ fmt.Println(err)
|
|
1524
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1525
|
+ "damage": damage,
|
|
1526
|
+ })
|
|
1527
|
+}
|
|
1528
|
+
|
|
1529
|
+func (this *SelfDrugApiController) DeleteDrugDamage() {
|
|
1530
|
+
|
|
1531
|
+ id, _ := this.GetInt64("id")
|
|
1532
|
+ err := service.DeleteDrugDamage(id)
|
|
1533
|
+ fmt.Println(err)
|
|
1534
|
+ returnData := make(map[string]interface{}, 0)
|
|
1535
|
+ returnData["msg"] = "ok"
|
|
1536
|
+ this.ServeSuccessJSON(returnData)
|
|
1537
|
+}
|
|
1538
|
+
|
|
1539
|
+func (this *SelfDrugApiController) GetDrugDamagePrint() {
|
|
1540
|
+
|
|
1541
|
+ idsSplit := this.GetString("ids")
|
|
1542
|
+ ids := strings.Split(idsSplit, ",")
|
|
1543
|
+ list, _ := service.GetDrugDamagePrint(ids)
|
|
1544
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1545
|
+ "list": list,
|
|
1546
|
+ })
|
|
1547
|
+}
|
|
1548
|
+
|
|
1549
|
+func (this *SelfDrugApiController) GetWarehoseInfoById() {
|
|
1550
|
+
|
|
1551
|
+ id, _ := this.GetInt64("id")
|
|
1552
|
+ list, _ := service.GetWarehoseInfoById(id)
|
|
1553
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1554
|
+ "list": list,
|
|
1555
|
+ })
|
|
1556
|
+}
|