28169 1 vuosi sitten
vanhempi
commit
1bbb823c3e

+ 1 - 1
controllers/drug_stock_api_contorller.go Näytä tiedosto

241
 
241
 
242
 				warehouseInfo := &models.DrugWarehouseInfo{
242
 				warehouseInfo := &models.DrugWarehouseInfo{
243
 					ID:               id,
243
 					ID:               id,
244
-					WarehousingOrder: warehousing.WarehousingOrder,
244
+					WarehousingOrder: info.WarehousingOrder,
245
 					WarehousingId:    info.ID,
245
 					WarehousingId:    info.ID,
246
 					DrugId:           drug_id,
246
 					DrugId:           drug_id,
247
 					Number:           number,
247
 					Number:           number,

+ 68 - 52
controllers/his_api_controller.go Näytä tiedosto

104
 
104
 
105
 	beego.Router("/api/changeorderdesc", &HisApiController{}, "get:ChangeOrderDesc")
105
 	beego.Router("/api/changeorderdesc", &HisApiController{}, "get:ChangeOrderDesc")
106
 
106
 
107
+	beego.Router("/api/getfapiaonumber", &HisApiController{}, "get:GetFaPiaoNumber")
108
+
109
+}
110
+func (c *HisApiController) GetFaPiaoNumber() {
111
+	max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
112
+	count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
113
+	fmt.Println(count)
114
+	var zero string
115
+	number := count + 1
116
+	if number >= 1000 {
117
+		zero = "0000" + strconv.FormatInt(number, 10)
118
+	} else if number >= 10000 {
119
+		zero = "000" + strconv.FormatInt(number, 10)
120
+	} else if number >= 100000 {
121
+		zero = "00" + strconv.FormatInt(number, 10)
122
+	} else if number >= 1000000 {
123
+		zero = "0" + strconv.FormatInt(number, 10)
124
+	} else {
125
+		zero = strconv.FormatInt(number, 10)
126
+	}
127
+	c.ServeSuccessJSON(map[string]interface{}{
128
+		"fapiao_number": zero,
129
+	})
130
+	return
107
 }
131
 }
108
 func (c *HisApiController) ChangeOrderDesc() {
132
 func (c *HisApiController) ChangeOrderDesc() {
109
 	id, _ := c.GetInt64("id")
133
 	id, _ := c.GetInt64("id")
3859
 					if item.Type == 3 && item.IsOut == 1 {
3883
 					if item.Type == 3 && item.IsOut == 1 {
3860
 						good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
3884
 						good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
3861
 						f_count, _ := strconv.ParseFloat(item.Count, 64)
3885
 						f_count, _ := strconv.ParseFloat(item.Count, 64)
3862
-						//good.Total = good.Total + f_count
3863
-						//service.UpdateGoodInfo(&good)
3886
+						good.Total = good.Total + f_count
3887
+						service.UpdateGoodInfo(&good)
3864
 						operation_time := time.Now().Unix()
3888
 						operation_time := time.Now().Unix()
3865
 						creater := c.GetAdminUserInfo().AdminUser.Id
3889
 						creater := c.GetAdminUserInfo().AdminUser.Id
3866
 						//创建退库单
3890
 						//创建退库单
3977
 								service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
4001
 								service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
3978
 								//出库数量减少
4002
 								//出库数量减少
3979
 								service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, total_count)
4003
 								service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, total_count)
3980
-
3981
-								//防止先出库 后开药的情况,查找当天是否出库完全
3982
-								numberList, _ := service.GetHisPrescriptionNumberList(item.ProjectId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
3983
-								if len(numberList) == 0 {
3984
-									infor, _ := service.GetWarehouseOutnfoByProjectId(item.ProjectId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
3985
-
3986
-									for _, item := range infor {
3987
-										//退库数量
3988
-										service.UpdateWarehouseInfoByProject(item.ProjectId, item.WarehouseInfotId, c.GetAdminUserInfo().CurrentOrgId, item.Count)
3989
-									}
3990
-
3991
-									//清空数据表
3992
-									service.UpdateWarehouseInfoByPatientId(item.ProjectId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
3993
-
3994
-								}
3995
 							}
4004
 							}
3996
 
4005
 
3997
 							if info.Count < total_count {
4006
 							if info.Count < total_count {
4098
 							//更新基础库库存
4107
 							//更新基础库库存
4099
 							service.UpdateGoodInfoSumCountSix(item.ProjectId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
4108
 							service.UpdateGoodInfoSumCountSix(item.ProjectId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
4100
 
4109
 
4101
-							//防止先出库 后开药的情况,查找当天是否出库完全
4102
-							numberList, _ := service.GetHisPrescriptionNumberList(item.ProjectId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
4103
-							if len(numberList) == 0 {
4104
-								infor, _ := service.GetWarehouseOutnfoByProjectId(item.ProjectId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
4105
-
4106
-								for _, item := range infor {
4107
-									//退库数量
4108
-									service.UpdateWarehouseInfoByProject(item.ProjectId, item.WarehouseInfotId, c.GetAdminUserInfo().CurrentOrgId, item.Count)
4109
-								}
4110
-
4111
-								//清空数据表
4112
-								service.UpdateWarehouseInfoByPatientId(item.ProjectId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
4113
-
4114
-							}
4115
 						}
4110
 						}
4116
 
4111
 
4117
 					}
4112
 					}
4168
 					for _, it := range goodList {
4163
 					for _, it := range goodList {
4169
 						flush_count += it.StockCount
4164
 						flush_count += it.StockCount
4170
 					}
4165
 					}
4171
-
4166
+					fmt.Println("历史出库数据", info.Count)
4167
+					fmt.Println("出库数量", total_count)
4172
 					if info.ID > 0 {
4168
 					if info.ID > 0 {
4173
 						cancelStockInfo := models.CancelStockInfo{
4169
 						cancelStockInfo := models.CancelStockInfo{
4174
 							GoodId:          item.ProjectId,
4170
 							GoodId:          item.ProjectId,
4214
 									flush_count_one += it.StockCount
4210
 									flush_count_one += it.StockCount
4215
 								}
4211
 								}
4216
 								//查询该批次是否有退库数据
4212
 								//查询该批次是否有退库数据
4213
+								//flow, _ := service.GetWarehouseStockFlow(it.WarehouseInfotId, it.GoodId, c.GetAdminUserInfo().CurrentOrgId, it.PatientId, it.SysRecordTime)
4217
 								creater := c.GetAdminUserInfo().AdminUser.Id
4214
 								creater := c.GetAdminUserInfo().AdminUser.Id
4218
 
4215
 
4219
 								flow := models.VmStockFlow{
4216
 								flow := models.VmStockFlow{
4251
 								}
4248
 								}
4252
 								service.CreateStockFlowOne(flow)
4249
 								service.CreateStockFlowOne(flow)
4253
 
4250
 
4251
+								//if flow.ID > 0 {
4252
+								//	service.AddCountFlowOne(it.WarehouseInfotId, it.GoodId, c.GetAdminUserInfo().CurrentOrgId, it.PatientId, it.Count, it.SysRecordTime, flush_count_one)
4253
+								//}
4254
 							}
4254
 							}
4255
 
4255
 
4256
 						}
4256
 						}
4257
 
4257
 
4258
+						//flow := models.VmStockFlow{
4259
+						//	WarehousingId:           info.WarehouseInfotId,
4260
+						//	GoodId:                  item.ProjectId,
4261
+						//	Number:                  info.Number,
4262
+						//	LicenseNumber:           info.LicenseNumber,
4263
+						//	Count:                   prescribingNumber,
4264
+						//	UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
4265
+						//	PatientId:               item.PatientId,
4266
+						//	SystemTime:              info.SysRecordTime,
4267
+						//	ConsumableType:          7,
4268
+						//	IsSys:                   0,
4269
+						//	WarehousingOrder:        "",
4270
+						//	WarehouseOutId:          info.WarehouseOutId,
4271
+						//	WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
4272
+						//	IsEdit:                  0,
4273
+						//	CancelStockId:           cancel.ID,
4274
+						//	CancelOrderNumber:       cancel.OrderNumber,
4275
+						//	Manufacturer:            manufacturer.ID,
4276
+						//	Dealer:                  0,
4277
+						//	Creator:                 c.GetAdminUserInfo().CurrentOrgId,
4278
+						//	UpdateCreator:           0,
4279
+						//	Status:                  1,
4280
+						//	Ctime:                   time.Now().Unix(),
4281
+						//	Mtime:                   0,
4282
+						//	Price:                   info.Price,
4283
+						//	WarehousingDetailId:     info.WarehouseInfotId,
4284
+						//	WarehouseOutDetailId:    info.ID,
4285
+						//	CancelOutDetailId:       cancelInfo.ID,
4286
+						//	ProductDate:             info.ProductDate,
4287
+						//	ExpireDate:              info.ExpiryDate,
4288
+						//	StorehouseId:            houseConfig.StorehouseOutInfo,
4289
+						//	OverCount:               flush_count,
4290
+						//}
4291
+						//service.CreateStockFlowOne(flow)
4292
+
4258
 						//退库数量增加
4293
 						//退库数量增加
4259
 						service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
4294
 						service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
4260
 						//出库数量减少
4295
 						//出库数量减少
4263
 						//查询已出库数量
4298
 						//查询已出库数量
4264
 						dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
4299
 						dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
4265
 
4300
 
4266
-						//如果当前处方数量 小于 出库数量
4267
 						if prescribingNumber < dialysisInfo.Count {
4301
 						if prescribingNumber < dialysisInfo.Count {
4268
 							//改变数量
4302
 							//改变数量
4269
 							service.UpdateAutoGood(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId, item.ID, prescribingNumber)
4303
 							service.UpdateAutoGood(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId, item.ID, prescribingNumber)
4270
 						}
4304
 						}
4271
 
4305
 
4272
-						//如果当前处方数量 大于或者等于出库数量
4273
 						if prescribingNumber >= dialysisInfo.Count {
4306
 						if prescribingNumber >= dialysisInfo.Count {
4274
 							//删除出库表
4307
 							//删除出库表
4275
 							service.DeleteAutoRedeceDetailTwenty(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId, item.ID)
4308
 							service.DeleteAutoRedeceDetailTwenty(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId, item.ID)
4283
 
4316
 
4284
 						//更新库存
4317
 						//更新库存
4285
 						msgerrkonde := service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, flush_count_one)
4318
 						msgerrkonde := service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, flush_count_one)
4286
-						fmt.Println("msgerrkonde", msgerrkonde)
4319
+						fmt.Println("msgerrkonde23332323", msgerrkonde)
4287
 
4320
 
4288
 						//更新基础库库存
4321
 						//更新基础库库存
4289
 						service.UpdateGoodInfoReduceSumCount(item.ProjectId, flush_count_one, c.GetAdminUserInfo().CurrentOrgId)
4322
 						service.UpdateGoodInfoReduceSumCount(item.ProjectId, flush_count_one, c.GetAdminUserInfo().CurrentOrgId)
6802
 	tmp_decimal := c.GetString("tmp_decimal")
6835
 	tmp_decimal := c.GetString("tmp_decimal")
6803
 
6836
 
6804
 	//last_order, _ := service.GetLastHisOrderThree(c.GetAdminUserInfo().CurrentOrgId)
6837
 	//last_order, _ := service.GetLastHisOrderThree(c.GetAdminUserInfo().CurrentOrgId)
6805
-	max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
6806
-	count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
6807
-	fmt.Println(count)
6808
-	var zero string
6809
-	number := count + 1
6810
-	if number >= 1000 {
6811
-		zero = "0000" + strconv.FormatInt(number, 10)
6812
-	} else if number >= 10000 {
6813
-		zero = "000" + strconv.FormatInt(number, 10)
6814
-	} else if number >= 100000 {
6815
-		zero = "00" + strconv.FormatInt(number, 10)
6816
-	} else if number >= 1000000 {
6817
-		zero = "0" + strconv.FormatInt(number, 10)
6818
-	} else {
6819
-		zero = strconv.FormatInt(number, 10)
6820
-	}
6821
-	fapiao_number = zero
6822
 
6838
 
6823
 	var decimal float64 //本次使用的押金
6839
 	var decimal float64 //本次使用的押金
6824
 	var errmsg error
6840
 	var errmsg error

+ 23 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Näytä tiedosto

437
 				newprescribe.DialysisDurationMinute = 0
437
 				newprescribe.DialysisDurationMinute = 0
438
 				newprescribe.BloodAccess = dialysisSolution.BloodAccess
438
 				newprescribe.BloodAccess = dialysisSolution.BloodAccess
439
 			}
439
 			}
440
+
441
+			if adminUserInfo.Org.Id == 10445 {
442
+				lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
443
+				newprescribe.Remark = lastDialysisPrescription.Remark
444
+			}
445
+
440
 			//插入透析处方
446
 			//插入透析处方
441
 			err := service.AddSigleRecord(&newprescribe)
447
 			err := service.AddSigleRecord(&newprescribe)
442
 
448
 
538
 					newprescribe.DialysisDurationMinute = 0
544
 					newprescribe.DialysisDurationMinute = 0
539
 					newprescribe.BloodAccess = dialysisSolution.BloodAccess
545
 					newprescribe.BloodAccess = dialysisSolution.BloodAccess
540
 				}
546
 				}
547
+
548
+				if adminUserInfo.Org.Id == 10445 {
549
+					lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
550
+					newprescribe.Remark = lastDialysisPrescription.Remark
551
+				}
541
 				err := service.AddSigleRecord(&newprescribe)
552
 				err := service.AddSigleRecord(&newprescribe)
542
 
553
 
543
 				//记录日志
554
 				//记录日志
629
 					newprescribe.DialysisDurationMinute = 0
640
 					newprescribe.DialysisDurationMinute = 0
630
 					newprescribe.BloodAccess = dialysisSolution.BloodAccess
641
 					newprescribe.BloodAccess = dialysisSolution.BloodAccess
631
 				}
642
 				}
643
+				if adminUserInfo.Org.Id == 10445 {
644
+					lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
645
+					newprescribe.Remark = lastDialysisPrescription.Remark
646
+				}
632
 				err := service.AddSigleRecord(&newprescribe)
647
 				err := service.AddSigleRecord(&newprescribe)
633
 
648
 
634
 				//记录日志
649
 				//记录日志
671
 				newprescribe.DewaterAmount = dewater_amount
686
 				newprescribe.DewaterAmount = dewater_amount
672
 				newprescribe.TargetUltrafiltration = dewater_amount
687
 				newprescribe.TargetUltrafiltration = dewater_amount
673
 				newprescribe.Status = 1
688
 				newprescribe.Status = 1
674
-
689
+				if adminUserInfo.Org.Id == 10445 {
690
+					lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
691
+					newprescribe.Remark = lastDialysisPrescription.Remark
692
+				}
675
 				err := service.AddSigleRecord(&newprescribe)
693
 				err := service.AddSigleRecord(&newprescribe)
676
 				//记录日志
694
 				//记录日志
677
 				byterequest, _ := json.Marshal(newprescribe)
695
 				byterequest, _ := json.Marshal(newprescribe)
713
 			if adminUserInfo.Org.Id == 10340 {
731
 			if adminUserInfo.Org.Id == 10340 {
714
 				dialysisPrescribe.TargetUltrafiltration = 0
732
 				dialysisPrescribe.TargetUltrafiltration = 0
715
 			}
733
 			}
734
+			if adminUserInfo.Org.Id == 10445 {
735
+				lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
736
+				dialysisPrescribe.Remark = lastDialysisPrescription.Remark
737
+			}
716
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
738
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
717
 			//记录日志
739
 			//记录日志
718
 			byterequest, _ := json.Marshal(dialysisPrescribe)
740
 			byterequest, _ := json.Marshal(dialysisPrescribe)

+ 3 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Näytä tiedosto

600
 	if remind_config.ID > 0 && remind_config.IsOpen == 1 {
600
 	if remind_config.ID > 0 && remind_config.IsOpen == 1 {
601
 		remind_lists, _ = service.GetAllInspectionRemind(adminInfo.Org.Id, patientID)
601
 		remind_lists, _ = service.GetAllInspectionRemind(adminInfo.Org.Id, patientID)
602
 	}
602
 	}
603
+
604
+	lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminInfo.Org.Id)
603
 	returnData := map[string]interface{}{
605
 	returnData := map[string]interface{}{
604
 		"patient":                        patient,
606
 		"patient":                        patient,
605
 		"schedual":                       schedual,
607
 		"schedual":                       schedual,
634
 		"prescription_open":              prescriptionConfig.IsOpen,
636
 		"prescription_open":              prescriptionConfig.IsOpen,
635
 		"lastOrder":                      lastOrder,
637
 		"lastOrder":                      lastOrder,
636
 		"remind_lists":                   remind_lists,
638
 		"remind_lists":                   remind_lists,
639
+		"lastDialysisPrescription":       lastDialysisPrescription,
637
 	}
640
 	}
638
 
641
 
639
 	this.ServeSuccessJSON(returnData)
642
 	this.ServeSuccessJSON(returnData)

+ 2 - 0
controllers/stock_in_api_controller.go Näytä tiedosto

1363
 			}
1363
 			}
1364
 		}
1364
 		}
1365
 	}
1365
 	}
1366
+	fmt.Println("warehouseOut_id", warehouseOut_id)
1366
 	if warehouseOut_id == 0 {
1367
 	if warehouseOut_id == 0 {
1367
 		//查询是否生成出库单
1368
 		//查询是否生成出库单
1368
 		_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1369
 		_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1370
 			service.AddSigleWarehouseOut(&warehouseOut)
1371
 			service.AddSigleWarehouseOut(&warehouseOut)
1371
 		}
1372
 		}
1372
 	}
1373
 	}
1374
+
1373
 	if warehouseOut_id > 0 {
1375
 	if warehouseOut_id > 0 {
1374
 		service.UpdateSingleWarehoseOut(warehouseOut_id, storehouse_id)
1376
 		service.UpdateSingleWarehoseOut(warehouseOut_id, storehouse_id)
1375
 	}
1377
 	}

+ 1 - 1
service/stock_service.go Näytä tiedosto

5553
 
5553
 
5554
 	err := XTWriteDB().Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5554
 	err := XTWriteDB().Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5555
 	//err = XTWriteDB().Model(models.DrugWarehouseOutInfo{}).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5555
 	//err = XTWriteDB().Model(models.DrugWarehouseOutInfo{}).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5556
-	//err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5556
+	err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5557
 	return err
5557
 	return err
5558
 }
5558
 }
5559
 
5559