소스 검색

修改redis清除数据时间

csx 4 년 전
부모
커밋
1c64ffccaf
4개의 변경된 파일356개의 추가작업 그리고 0개의 파일을 삭제
  1. 334 0
      controllers/public_api_controller.go
  2. 8 0
      controllers/stock_good_api_controller.go
  3. 9 0
      service/app_version.go
  4. 5 0
      service/stock_service.go

+ 334 - 0
controllers/public_api_controller.go 파일 보기

@@ -26,6 +26,7 @@ func PublicApiRegistRouters() {
26 26
 	beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
27 27
 	beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
28 28
 	beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
29
+	beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
29 30
 
30 31
 }
31 32
 
@@ -903,3 +904,336 @@ func (c *PublicApiController) HandleStockData() {
903 904
 	}
904 905
 
905 906
 }
907
+
908
+func (c *PublicApiController) HandleComData() {
909
+	org_ids := []int64{3907}
910
+
911
+	for _, id := range org_ids {
912
+		//查处所有处方记录
913
+		prescriptions, _ := service.FindAllPrescription(id)
914
+		if id == 3907 {
915
+
916
+			for _, item := range prescriptions {
917
+				before := &models.DialysisBeforePrepare{
918
+					UserOrgId:  id,
919
+					PatientId:  item.PatientId,
920
+					RecordDate: item.RecordDate,
921
+					Count:      1,
922
+					Ctime:      item.RecordDate,
923
+					Mtime:      item.RecordDate,
924
+					Creater:    item.Creater,
925
+					Modifier:   item.Creater,
926
+					Status:     1,
927
+				}
928
+
929
+				if item.Niprocart > 0 {
930
+					before.GoodId = item.Niprocart
931
+					before.GoodTypeId = 241
932
+					service.AddSigleDialysisBeforePre(before)
933
+				}
934
+
935
+				if item.Jms > 0 {
936
+					before.GoodId = item.Jms
937
+					before.GoodTypeId = 233
938
+					service.AddSigleDialysisBeforePre(before)
939
+
940
+				}
941
+
942
+				if item.FistulaNeedleSet > 0 {
943
+
944
+					before.GoodId = item.FistulaNeedleSet
945
+					before.GoodTypeId = 233
946
+					service.AddSigleDialysisBeforePre(before)
947
+				}
948
+
949
+				if item.FistulaNeedleSet16 > 0 {
950
+					before.GoodId = item.FistulaNeedleSet16
951
+					before.GoodTypeId = 233
952
+					service.AddSigleDialysisBeforePre(before)
953
+
954
+				}
955
+
956
+				if item.Hemoperfusion > 0 {
957
+					before.GoodId = item.Hemoperfusion
958
+					before.GoodTypeId = 235
959
+					service.AddSigleDialysisBeforePre(before)
960
+
961
+				}
962
+
963
+				if item.DialyserSterilised > 0 {
964
+					before.GoodId = item.DialyserSterilised
965
+					before.GoodTypeId = 234
966
+					service.AddSigleDialysisBeforePre(before)
967
+
968
+				}
969
+
970
+				if item.Filtryzer > 0 {
971
+					before.GoodId = item.Filtryzer
972
+					before.GoodTypeId = 234
973
+					service.AddSigleDialysisBeforePre(before)
974
+
975
+				}
976
+
977
+				if item.Dialyzers > 0 {
978
+					before.GoodId = item.Dialyzers
979
+					before.GoodTypeId = 234
980
+					service.AddSigleDialysisBeforePre(before)
981
+
982
+				}
983
+
984
+				if item.Injector > 0 {
985
+					before.GoodId = item.Injector
986
+					before.GoodTypeId = 238
987
+					service.AddSigleDialysisBeforePre(before)
988
+
989
+				}
990
+
991
+				if item.Bloodlines > 0 {
992
+					before.GoodId = item.Bloodlines
993
+					before.GoodTypeId = 236
994
+					service.AddSigleDialysisBeforePre(before)
995
+
996
+				}
997
+
998
+				if item.TubingHemodialysis > 0 {
999
+					before.GoodId = item.TubingHemodialysis
1000
+					before.GoodTypeId = 237
1001
+					service.AddSigleDialysisBeforePre(before)
1002
+
1003
+				}
1004
+
1005
+				if item.Package > 0 {
1006
+					before.GoodId = item.Package
1007
+					before.GoodTypeId = 239
1008
+					service.AddSigleDialysisBeforePre(before)
1009
+
1010
+				}
1011
+
1012
+				if item.ALiquid > 0 {
1013
+					before.GoodId = item.ALiquid
1014
+					before.GoodTypeId = 242
1015
+					service.AddSigleDialysisBeforePre(before)
1016
+
1017
+				}
1018
+
1019
+			}
1020
+
1021
+		} else if id == 9779 {
1022
+
1023
+			for _, item := range prescriptions {
1024
+				before := &models.DialysisBeforePrepare{
1025
+					UserOrgId:  id,
1026
+					PatientId:  item.PatientId,
1027
+					RecordDate: item.RecordDate,
1028
+					Count:      1,
1029
+					Ctime:      item.RecordDate,
1030
+					Mtime:      item.RecordDate,
1031
+					Creater:    item.Creater,
1032
+					Modifier:   item.Creater,
1033
+					Status:     1,
1034
+				}
1035
+
1036
+				if item.Niprocart > 0 {
1037
+					before.GoodId = item.Niprocart
1038
+					before.GoodTypeId = 2
1039
+					service.AddSigleDialysisBeforePre(before)
1040
+				}
1041
+
1042
+				if item.Jms > 0 {
1043
+					before.GoodId = item.Jms
1044
+					before.GoodTypeId = 233
1045
+					service.AddSigleDialysisBeforePre(before)
1046
+
1047
+				}
1048
+
1049
+				if item.FistulaNeedleSet > 0 {
1050
+
1051
+					before.GoodId = item.FistulaNeedleSet
1052
+					before.GoodTypeId = 233
1053
+					service.AddSigleDialysisBeforePre(before)
1054
+				}
1055
+
1056
+				if item.FistulaNeedleSet16 > 0 {
1057
+					before.GoodId = item.FistulaNeedleSet16
1058
+					before.GoodTypeId = 233
1059
+					service.AddSigleDialysisBeforePre(before)
1060
+
1061
+				}
1062
+
1063
+				if item.Hemoperfusion > 0 {
1064
+					before.GoodId = item.Hemoperfusion
1065
+					before.GoodTypeId = 235
1066
+					service.AddSigleDialysisBeforePre(before)
1067
+
1068
+				}
1069
+
1070
+				if item.DialyserSterilised > 0 {
1071
+					before.GoodId = item.DialyserSterilised
1072
+					before.GoodTypeId = 234
1073
+					service.AddSigleDialysisBeforePre(before)
1074
+
1075
+				}
1076
+
1077
+				if item.Filtryzer > 0 {
1078
+					before.GoodId = item.Filtryzer
1079
+					before.GoodTypeId = 234
1080
+					service.AddSigleDialysisBeforePre(before)
1081
+
1082
+				}
1083
+
1084
+				if item.Dialyzers > 0 {
1085
+					before.GoodId = item.Dialyzers
1086
+					before.GoodTypeId = 234
1087
+					service.AddSigleDialysisBeforePre(before)
1088
+
1089
+				}
1090
+
1091
+				if item.Injector > 0 {
1092
+					before.GoodId = item.Injector
1093
+					before.GoodTypeId = 238
1094
+					service.AddSigleDialysisBeforePre(before)
1095
+
1096
+				}
1097
+
1098
+				if item.Bloodlines > 0 {
1099
+					before.GoodId = item.Bloodlines
1100
+					before.GoodTypeId = 236
1101
+					service.AddSigleDialysisBeforePre(before)
1102
+
1103
+				}
1104
+
1105
+				if item.TubingHemodialysis > 0 {
1106
+					before.GoodId = item.TubingHemodialysis
1107
+					before.GoodTypeId = 237
1108
+					service.AddSigleDialysisBeforePre(before)
1109
+
1110
+				}
1111
+
1112
+				if item.Package > 0 {
1113
+					before.GoodId = item.Package
1114
+					before.GoodTypeId = 239
1115
+					service.AddSigleDialysisBeforePre(before)
1116
+
1117
+				}
1118
+
1119
+				if item.ALiquid > 0 {
1120
+					before.GoodId = item.ALiquid
1121
+					before.GoodTypeId = 242
1122
+					service.AddSigleDialysisBeforePre(before)
1123
+
1124
+				}
1125
+
1126
+			}
1127
+
1128
+		} else if id == 9883 {
1129
+
1130
+			for _, item := range prescriptions {
1131
+				before := &models.DialysisBeforePrepare{
1132
+					UserOrgId:  id,
1133
+					PatientId:  item.PatientId,
1134
+					RecordDate: item.RecordDate,
1135
+					Count:      1,
1136
+					Ctime:      item.RecordDate,
1137
+					Mtime:      item.RecordDate,
1138
+					Creater:    item.Creater,
1139
+					Modifier:   item.Creater,
1140
+					Status:     1,
1141
+				}
1142
+
1143
+				if item.Niprocart > 0 {
1144
+					before.GoodId = item.Niprocart
1145
+					before.GoodTypeId = 241
1146
+					service.AddSigleDialysisBeforePre(before)
1147
+				}
1148
+
1149
+				if item.Jms > 0 {
1150
+					before.GoodId = item.Jms
1151
+					before.GoodTypeId = 233
1152
+					service.AddSigleDialysisBeforePre(before)
1153
+
1154
+				}
1155
+
1156
+				if item.FistulaNeedleSet > 0 {
1157
+
1158
+					before.GoodId = item.FistulaNeedleSet
1159
+					before.GoodTypeId = 233
1160
+					service.AddSigleDialysisBeforePre(before)
1161
+				}
1162
+
1163
+				if item.FistulaNeedleSet16 > 0 {
1164
+					before.GoodId = item.FistulaNeedleSet16
1165
+					before.GoodTypeId = 233
1166
+					service.AddSigleDialysisBeforePre(before)
1167
+
1168
+				}
1169
+
1170
+				if item.Hemoperfusion > 0 {
1171
+					before.GoodId = item.Hemoperfusion
1172
+					before.GoodTypeId = 235
1173
+					service.AddSigleDialysisBeforePre(before)
1174
+
1175
+				}
1176
+
1177
+				if item.DialyserSterilised > 0 {
1178
+					before.GoodId = item.DialyserSterilised
1179
+					before.GoodTypeId = 234
1180
+					service.AddSigleDialysisBeforePre(before)
1181
+
1182
+				}
1183
+
1184
+				if item.Filtryzer > 0 {
1185
+					before.GoodId = item.Filtryzer
1186
+					before.GoodTypeId = 234
1187
+					service.AddSigleDialysisBeforePre(before)
1188
+
1189
+				}
1190
+
1191
+				if item.Dialyzers > 0 {
1192
+					before.GoodId = item.Dialyzers
1193
+					before.GoodTypeId = 234
1194
+					service.AddSigleDialysisBeforePre(before)
1195
+
1196
+				}
1197
+
1198
+				if item.Injector > 0 {
1199
+					before.GoodId = item.Injector
1200
+					before.GoodTypeId = 238
1201
+					service.AddSigleDialysisBeforePre(before)
1202
+
1203
+				}
1204
+
1205
+				if item.Bloodlines > 0 {
1206
+					before.GoodId = item.Bloodlines
1207
+					before.GoodTypeId = 236
1208
+					service.AddSigleDialysisBeforePre(before)
1209
+
1210
+				}
1211
+
1212
+				if item.TubingHemodialysis > 0 {
1213
+					before.GoodId = item.TubingHemodialysis
1214
+					before.GoodTypeId = 237
1215
+					service.AddSigleDialysisBeforePre(before)
1216
+
1217
+				}
1218
+
1219
+				if item.Package > 0 {
1220
+					before.GoodId = item.Package
1221
+					before.GoodTypeId = 239
1222
+					service.AddSigleDialysisBeforePre(before)
1223
+
1224
+				}
1225
+
1226
+				if item.ALiquid > 0 {
1227
+					before.GoodId = item.ALiquid
1228
+					before.GoodTypeId = 242
1229
+					service.AddSigleDialysisBeforePre(before)
1230
+
1231
+				}
1232
+
1233
+			}
1234
+
1235
+		}
1236
+
1237
+	}
1238
+
1239
+}

+ 8 - 0
controllers/stock_good_api_controller.go 파일 보기

@@ -124,10 +124,18 @@ func (c *StockGoodApiController) DeleteGoodType() {
124 124
 	id, _ := c.GetInt64("id", 0)
125 125
 	adminUserInfo := c.GetAdminUserInfo()
126 126
 	goodInfo, _ := service.FindGoodInfoByGoodId(id)
127
+	autoDetail, _ := service.FindStockOutDetailGoodInfoByGoodId(id)
128
+
127 129
 	if len(goodInfo) > 0 {
128 130
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodTypeFail)
129 131
 		return
130 132
 	}
133
+
134
+	if len(autoDetail) > 0 {
135
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
136
+		return
137
+	}
138
+
131 139
 	err := service.DeleteGoodTypeById(id, adminUserInfo.AdminUser.Id)
132 140
 	if err == nil {
133 141
 		c.ServeSuccessJSON(map[string]interface{}{

+ 9 - 0
service/app_version.go 파일 보기

@@ -229,3 +229,12 @@ func FindAllOrgByImportType() (org []*models.Org, err error) {
229 229
 	err = readUserDb.Model(&models.Org{}).Where("status =1 AND import = 0").Find(&org).Error
230 230
 	return
231 231
 }
232
+
233
+func FindAllPrescription(org_id int64) (prescription []*models.DialysisPrescription, err error) {
234
+	err = readDb.Model(&models.DialysisPrescription{}).Where("user_org_id=? AND status= 1 AND record_date >= 1593446400", org_id).Find(&prescription).Error
235
+	return
236
+}
237
+
238
+func AddSigleDialysisBeforePre(before *models.DialysisBeforePrepare) {
239
+	writeDb.Create(&before)
240
+}

+ 5 - 0
service/stock_service.go 파일 보기

@@ -213,6 +213,11 @@ func FindGoodInfoByGoodId(id int64) (list []*models.GoodInfo, err error) {
213 213
 	return list, err
214 214
 }
215 215
 
216
+func FindStockOutDetailGoodInfoByGoodId(id int64) (list []*models.AutomaticReduceDetail, err error) {
217
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("good_type_id = ? AND status = 1", id).Find(&list).Error
218
+	return list, err
219
+}
220
+
216 221
 func FindGoodInfoById(id int64) (*models.GoodInfo, error) {
217 222
 	goodInfo := &models.GoodInfo{}
218 223
 	err := readDb.Model(&models.GoodInfo{}).Where("id = ? AND status = 1", id).First(&goodInfo).Error