|
@@ -115,6 +115,11 @@ func SelfDrugRouters() {
|
115
|
115
|
beego.Router("/api/stock/getdrugovercount", &SelfDrugApiController{}, "Get:GetDrugOverCount")
|
116
|
116
|
|
117
|
117
|
beego.Router("/api/stock/getdruginfolist", &SelfDrugApiController{}, "Get:GetDrugInventoryWarehouseInfoList")
|
|
118
|
+
|
|
119
|
+ beego.Router("/api/drug/getdrugflowdetailbyid", &SelfDrugApiController{}, "Get:GetDrugFlowDetailById")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+ beego.Router("/api/stock/getpurchaseDrugQueryList", &SelfDrugApiController{}, "Get:GetPurchaseDrugQueryList")
|
118
|
123
|
}
|
119
|
124
|
|
120
|
125
|
func (this *SelfDrugApiController) GetCurrentPatient() {
|
|
@@ -4091,3 +4096,162 @@ func (this *SelfDrugApiController) GetInventoryDetailPrintList() {
|
4091
|
4096
|
"inventoryList": inventoryList,
|
4092
|
4097
|
})
|
4093
|
4098
|
}
|
|
4099
|
+
|
|
4100
|
+func (this *SelfDrugApiController) GetDrugFlowDetailById() {
|
|
4101
|
+
|
|
4102
|
+ drug_id, _ := this.GetInt64("drug_id")
|
|
4103
|
+
|
|
4104
|
+ list, _ := service.GetDrugFlowDetailById(drug_id)
|
|
4105
|
+
|
|
4106
|
+ drugMedical, _ := service.GetBaseDrugMedical(drug_id)
|
|
4107
|
+
|
|
4108
|
+ for index, _ := range list {
|
|
4109
|
+ if list[index].ConsumableType == 3 || list[index].ConsumableType == 2 || list[index].ConsumableType == 11 || list[index].ConsumableType == 12 || list[index].ConsumableType == 15 {
|
|
4110
|
+ var count int64
|
|
4111
|
+ if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
|
|
4112
|
+ list[index].Count = list[index].Count * drugMedical.MinNumber
|
|
4113
|
+ }
|
|
4114
|
+
|
|
4115
|
+ if index == 0 {
|
|
4116
|
+ count = list[index].FlushOverCount - list[index].Count
|
|
4117
|
+ service.UpdateDrugOverCount(list[index+1].ID, count)
|
|
4118
|
+ }
|
|
4119
|
+
|
|
4120
|
+ if index >= 1 {
|
|
4121
|
+ lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
|
|
4122
|
+ count = lastStockFlow.FlushOverCount - list[index].Count
|
|
4123
|
+ service.UpdateDrugOverCount(list[index].ID, count)
|
|
4124
|
+ }
|
|
4125
|
+
|
|
4126
|
+ }
|
|
4127
|
+ if list[index].ConsumableType == 7 || list[index].ConsumableType == 4 || list[index].ConsumableType == 1 || list[index].ConsumableType == 10 || list[index].ConsumableType == 13 {
|
|
4128
|
+ if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
|
|
4129
|
+ list[index].Count = list[index].Count * drugMedical.MinNumber
|
|
4130
|
+ }
|
|
4131
|
+ if index == 0 {
|
|
4132
|
+ var count int64
|
|
4133
|
+ count = list[index].OverCount + list[index].Count
|
|
4134
|
+ service.UpdateDrugOverCount(list[index+1].ID, count)
|
|
4135
|
+ }
|
|
4136
|
+
|
|
4137
|
+ if index >= 1 {
|
|
4138
|
+ var count int64
|
|
4139
|
+ lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
|
|
4140
|
+ count = lastStockFlow.FlushOverCount + list[index].Count
|
|
4141
|
+ service.UpdateDrugOverCount(list[index].ID, count)
|
|
4142
|
+ }
|
|
4143
|
+
|
|
4144
|
+ }
|
|
4145
|
+
|
|
4146
|
+ }
|
|
4147
|
+}
|
|
4148
|
+
|
|
4149
|
+func (this *SelfDrugApiController) GetPurchaseDrugQueryList() {
|
|
4150
|
+
|
|
4151
|
+ good_type, _ := this.GetInt64("good_type")
|
|
4152
|
+
|
|
4153
|
+ keyword := this.GetString("keyword")
|
|
4154
|
+
|
|
4155
|
+ page, _ := this.GetInt64("page")
|
|
4156
|
+
|
|
4157
|
+ limit, _ := this.GetInt64("limit")
|
|
4158
|
+
|
|
4159
|
+ start_time := this.GetString("start_time")
|
|
4160
|
+ end_time := this.GetString("end_time")
|
|
4161
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
4162
|
+ timeLayout := "2006-01-02"
|
|
4163
|
+ loc, _ := time.LoadLocation("Local")
|
|
4164
|
+
|
|
4165
|
+ var startTime int64
|
|
4166
|
+
|
|
4167
|
+ if len(start_time) > 0 {
|
|
4168
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
4169
|
+ if err != nil {
|
|
4170
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4171
|
+ return
|
|
4172
|
+ }
|
|
4173
|
+ startTime = theTime.Unix()
|
|
4174
|
+ }
|
|
4175
|
+
|
|
4176
|
+ var endTime int64
|
|
4177
|
+ if len(end_time) > 0 {
|
|
4178
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
4179
|
+ if err != nil {
|
|
4180
|
+ utils.ErrorLog(err.Error())
|
|
4181
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4182
|
+ return
|
|
4183
|
+ }
|
|
4184
|
+ endTime = theTime.Unix()
|
|
4185
|
+ }
|
|
4186
|
+ var ids []int64
|
|
4187
|
+ var infoIds []int64
|
|
4188
|
+
|
|
4189
|
+ manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
|
|
4190
|
+ for _, it := range manufacturers {
|
|
4191
|
+ ids = append(ids, it.ID)
|
|
4192
|
+ }
|
|
4193
|
+ infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
|
|
4194
|
+ for _, it := range infoList {
|
|
4195
|
+ infoIds = append(infoIds, it.DrugId)
|
|
4196
|
+ }
|
|
4197
|
+ manufacturerList, _ := service.GetAllManufacturerList(orgId)
|
|
4198
|
+ list, total, err := service.GetDrugNewPurchaseStockQueryList(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
|
|
4199
|
+
|
|
4200
|
+ for _, item := range list {
|
|
4201
|
+
|
|
4202
|
+
|
|
4203
|
+ flow, _ := service.GetDrugStartFlow(item.ID, orgId, startTime)
|
|
4204
|
+
|
|
4205
|
+ item.DrugStatFlow = flow
|
|
4206
|
+
|
|
4207
|
+
|
|
4208
|
+ endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
|
|
4209
|
+
|
|
4210
|
+ item.DrugEndFlow = endFlow
|
|
4211
|
+
|
|
4212
|
+
|
|
4213
|
+
|
|
4214
|
+ drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
|
|
4215
|
+ for _, it := range drugWarehouse {
|
|
4216
|
+ item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
|
|
4217
|
+ }
|
|
4218
|
+
|
|
4219
|
+
|
|
4220
|
+ outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
|
|
4221
|
+ for _, it := range outInfo {
|
|
4222
|
+ item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
|
|
4223
|
+ }
|
|
4224
|
+
|
|
4225
|
+
|
|
4226
|
+ cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
|
|
4227
|
+ for _, it := range cancelstartInfo {
|
|
4228
|
+ item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
|
|
4229
|
+ }
|
|
4230
|
+
|
|
4231
|
+
|
|
4232
|
+ profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
|
|
4233
|
+ for _, it := range profit {
|
|
4234
|
+ item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
|
|
4235
|
+ }
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+ endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
|
|
4239
|
+ for _, it := range endLosses {
|
|
4240
|
+ item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
|
|
4241
|
+ }
|
|
4242
|
+ }
|
|
4243
|
+ if err != nil {
|
|
4244
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
|
|
4245
|
+ return
|
|
4246
|
+ }
|
|
4247
|
+ var drugType = "药品类型"
|
|
4248
|
+ drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
|
|
4249
|
+ drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
|
|
4250
|
+
|
|
4251
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
4252
|
+ "list": list,
|
|
4253
|
+ "manufacturerList": manufacturerList,
|
|
4254
|
+ "total": total,
|
|
4255
|
+ "drugTypeList": drugTypeList,
|
|
4256
|
+ })
|
|
4257
|
+}
|