瀏覽代碼

历史排班

28169 1 年之前
父節點
當前提交
7719ac70bd

+ 1 - 1
controllers/gobal_config_api_controller.go 查看文件

2387
 	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2387
 	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2388
 
2388
 
2389
 	drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids, admin.CurrentOrgId)
2389
 	drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids, admin.CurrentOrgId)
2390
-	fmt.Println("drug_warhouse_out9999999", drug_warhouse_out)
2390
+
2391
 	c.ServeSuccessJSON(map[string]interface{}{
2391
 	c.ServeSuccessJSON(map[string]interface{}{
2392
 		"info":              info,
2392
 		"info":              info,
2393
 		"warehousing":       warehousing,
2393
 		"warehousing":       warehousing,

+ 6 - 0
controllers/his_project_api_controller.go 查看文件

87
 	beego.Router("/api/hispatient/getmaintemplatebyid", &HisProjectApiController{}, "Get:GetMainTemplateById")
87
 	beego.Router("/api/hispatient/getmaintemplatebyid", &HisProjectApiController{}, "Get:GetMainTemplateById")
88
 	beego.Router("/api/hispatient/updatemaintemplate", &HisProjectApiController{}, "Get:UpdateMainTemplate")
88
 	beego.Router("/api/hispatient/updatemaintemplate", &HisProjectApiController{}, "Get:UpdateMainTemplate")
89
 	beego.Router("/api/hispatient/deletemaintemplate", &HisProjectApiController{}, "Get:DeleteMainTemplate")
89
 	beego.Router("/api/hispatient/deletemaintemplate", &HisProjectApiController{}, "Get:DeleteMainTemplate")
90
+
90
 }
91
 }
91
 
92
 
92
 func (this *HisProjectApiController) SaveProject() {
93
 func (this *HisProjectApiController) SaveProject() {
1268
 	prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1269
 	prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1269
 	//advicePrint, err := service.GetPre(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
1270
 	//advicePrint, err := service.GetPre(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
1270
 	hisPatient, _ := service.GetHisPatientInfoFour(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, his_patient_id)
1271
 	hisPatient, _ := service.GetHisPatientInfoFour(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, his_patient_id)
1272
+	hisPatient_two, _ := service.GetHisPatientInfoTen(adminUserInfo.CurrentOrgId, patient_id, recordDateTime)
1273
+	if hisPatient.ID == 0 {
1274
+		hisPatient = hisPatient_two
1275
+	}
1276
+
1271
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1277
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1272
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1278
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1273
 
1279
 

+ 5 - 0
service/his_service.go 查看文件

297
 	return
297
 	return
298
 }
298
 }
299
 
299
 
300
+func GetHisPatientInfoTen(org_id int64, patient_id int64, record_date int64) (info models.HisPatient, err error) {
301
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Last(&info).Error
302
+	return
303
+}
304
+
300
 func GetHisPatientInfoFour(org_id int64, patient_id int64, record_date int64, his_patient_id int64) (info models.HisPatient, err error) {
305
 func GetHisPatientInfoFour(org_id int64, patient_id int64, record_date int64, his_patient_id int64) (info models.HisPatient, err error) {
301
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND id = ?", org_id, record_date, patient_id, his_patient_id).First(&info).Error
306
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND id = ?", org_id, record_date, patient_id, his_patient_id).First(&info).Error
302
 	return
307
 	return

+ 62 - 37
service/new_warehouse_service.go 查看文件

813
 		}
813
 		}
814
 
814
 
815
 		//如果本次出库数据大于历史出库数据 新增1条流水
815
 		//如果本次出库数据大于历史出库数据 新增1条流水
816
+
816
 		if deliver_number > (out_count - cancel_count) {
817
 		if deliver_number > (out_count - cancel_count) {
817
 			drugflow := models.DrugFlow{
818
 			drugflow := models.DrugFlow{
818
 				WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
819
 				WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
1262
 }
1263
 }
1263
 
1264
 
1264
 // 药品自动出库 递归方式
1265
 // 药品自动出库 递归方式
1265
-func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo) (err error) {
1266
+func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo, hisprescribingNumber float64) (err error) {
1266
 
1267
 
1267
 	drugError := models.XtDrugError{
1268
 	drugError := models.XtDrugError{
1268
 		UserOrgId:             orgID,
1269
 		UserOrgId:             orgID,
1280
 	CreateDrugError(drugError)
1281
 	CreateDrugError(drugError)
1281
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
1282
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
1282
 	var deliver_number int64 = 0
1283
 	var deliver_number int64 = 0
1284
+	var deliver_number_one int64 = 0
1283
 	var stock_number int64 = 0
1285
 	var stock_number int64 = 0
1284
 
1286
 
1285
 	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
1287
 	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
1286
 	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1288
 	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1287
 
1289
 
1290
+	prescribingNumber_temp_one := strconv.FormatFloat(math.Abs(hisprescribingNumber), 'f', 0, 64)
1291
+	countone, _ := strconv.ParseInt(prescribingNumber_temp_one, 10, 64)
1292
+
1288
 	var drug_price float64
1293
 	var drug_price float64
1289
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
1294
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
1290
 		deliver_number = count * drup.MinNumber
1295
 		deliver_number = count * drup.MinNumber
1294
 
1299
 
1295
 	}
1300
 	}
1296
 
1301
 
1302
+	if advice.PrescribingNumberUnit == drup.MaxUnit {
1303
+		deliver_number_one = countone * drup.MinNumber
1304
+
1305
+	} else {
1306
+		deliver_number_one = countone
1307
+
1308
+	}
1309
+
1310
+	fmt.Println(deliver_number_one)
1311
+
1297
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
1312
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
1298
 		drug_price = drup.RetailPrice
1313
 		drug_price = drup.RetailPrice
1299
 	}
1314
 	}
1320
 
1335
 
1321
 			ChangeMaxNumber(lastWarehouse.ID, stockMax)
1336
 			ChangeMaxNumber(lastWarehouse.ID, stockMax)
1322
 			UpdateMinNumber(lastWarehouse.ID, stockMin)
1337
 			UpdateMinNumber(lastWarehouse.ID, stockMin)
1338
+
1323
 		}
1339
 		}
1324
 	}
1340
 	}
1325
 
1341
 
1543
 			}
1559
 			}
1544
 		}
1560
 		}
1545
 		if lastDrugOutInfo.ID > 0 {
1561
 		if lastDrugOutInfo.ID > 0 {
1546
-			var his_count int64
1547
-			if lastDrugOutInfo.CountUnit == drup.MaxUnit {
1548
-				his_count = lastDrugOutInfo.Count * drup.MinNumber
1549
-			}
1550
-			if lastDrugOutInfo.CountUnit == drup.MinUnit {
1551
-				his_count = lastDrugOutInfo.Count
1552
-			}
1553
-			if deliver_number != his_count {
1554
-				errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
1555
-				if errThree != nil {
1556
-					drugError := models.XtDrugError{
1557
-						UserOrgId:             orgID,
1558
-						DrugId:                advice.DrugId,
1559
-						RecordDate:            advice.AdviceDate,
1560
-						PatientId:             advice.PatientId,
1561
-						Remark:                "更新出库单失败",
1562
-						Status:                1,
1563
-						Ctime:                 time.Now().Unix(),
1564
-						Mtime:                 0,
1565
-						SumCount:              0,
1566
-						Prescribingnumber:     advice.PrescribingNumber,
1567
-						PrescribingNumberUnit: advice.PrescribingNumberUnit,
1568
-					}
1569
-					CreateDrugError(drugError)
1570
-					return errThree
1571
-				}
1572
-			}
1562
+
1563
+			//删除在新增
1564
+			UpdateDrugWarehouseOutInfoTen(lastDrugOutInfo.PatientId, lastDrugOutInfo.SysRecordTime, advice.ID)
1565
+
1566
+			AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1567
+
1568
+			//var his_count int64
1569
+			//if lastDrugOutInfo.CountUnit == drup.MaxUnit {
1570
+			//	his_count = lastDrugOutInfo.Count * drup.MinNumber
1571
+			//}
1572
+			//if lastDrugOutInfo.CountUnit == drup.MinUnit {
1573
+			//	his_count = lastDrugOutInfo.Count
1574
+			//}
1575
+			//fmt.Println("deliver_number", deliver_number)
1576
+			//fmt.Println("his_countwowowoowow", his_count)
1577
+			//if deliver_number != his_count {
1578
+			//	errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
1579
+			//	if errThree != nil {
1580
+			//		drugError := models.XtDrugError{
1581
+			//			UserOrgId:             orgID,
1582
+			//			DrugId:                advice.DrugId,
1583
+			//			RecordDate:            advice.AdviceDate,
1584
+			//			PatientId:             advice.PatientId,
1585
+			//			Remark:                "更新出库单失败",
1586
+			//			Status:                1,
1587
+			//			Ctime:                 time.Now().Unix(),
1588
+			//			Mtime:                 0,
1589
+			//			SumCount:              0,
1590
+			//			Prescribingnumber:     advice.PrescribingNumber,
1591
+			//			PrescribingNumberUnit: advice.PrescribingNumberUnit,
1592
+			//		}
1593
+			//		CreateDrugError(drugError)
1594
+			//		return errThree
1595
+			//	}
1596
+			//}
1573
 		}
1597
 		}
1574
 
1598
 
1575
 		var out_count int64
1599
 		var out_count int64
1586
 			cancel_count += item.Count
1610
 			cancel_count += item.Count
1587
 		}
1611
 		}
1588
 
1612
 
1589
-		//如果本次出库数据大于历史出库数据 新增1条流水
1590
-		//fmt.Println("deliver_number233233223232wi", deliver_number)
1591
-		//fmt.Println("out_coutn23333333333333333", out_count)
1592
-		//fmt.Println("cancel_coutn099992ow", cancel_count)
1593
-		if deliver_number >= (out_count - cancel_count) {
1613
+		if deliver_number_one-(out_count-cancel_count) >= 0 {
1594
 			if (deliver_number - out_count - cancel_count) != 0 {
1614
 			if (deliver_number - out_count - cancel_count) != 0 {
1595
 				drugflow := models.DrugFlow{
1615
 				drugflow := models.DrugFlow{
1596
 					WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
1616
 					WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
1599
 					Number:                  warehouse.Number,
1619
 					Number:                  warehouse.Number,
1600
 					ProductDate:             warehouse.ProductDate,
1620
 					ProductDate:             warehouse.ProductDate,
1601
 					ExpireDate:              warehouse.ExpiryDate,
1621
 					ExpireDate:              warehouse.ExpiryDate,
1602
-					Count:                   deliver_number - (out_count - cancel_count), //按最小单位计算,
1622
+					Count:                   deliver_number_one - (out_count - cancel_count), //按最小单位计算,
1603
 					Price:                   warehouse.RetailPrice,
1623
 					Price:                   warehouse.RetailPrice,
1604
 					Status:                  1,
1624
 					Status:                  1,
1605
 					Ctime:                   advice.AdviceDate,
1625
 					Ctime:                   advice.AdviceDate,
1667
 		}
1687
 		}
1668
 
1688
 
1669
 		//如果本次出库数据小于历史出库数据 新增1条退库流水
1689
 		//如果本次出库数据小于历史出库数据 新增1条退库流水
1670
-		if deliver_number < (out_count - cancel_count) {
1690
+		if deliver_number_one-(out_count-cancel_count) < 0 {
1671
 
1691
 
1672
 			operation_time := time.Now().Unix()
1692
 			operation_time := time.Now().Unix()
1673
 
1693
 
2340
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
2360
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
2341
 		advice.PrescribingNumberUnit = drup.MinUnit
2361
 		advice.PrescribingNumberUnit = drup.MinUnit
2342
 
2362
 
2343
-		BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice)
2363
+		BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice, hisprescribingNumber)
2344
 	}
2364
 	}
2345
 
2365
 
2346
 	return
2366
 	return
3935
 		utils.ErrorLog("事务失败,原因为: %v", err)
3955
 		utils.ErrorLog("事务失败,原因为: %v", err)
3936
 		tx.Rollback()
3956
 		tx.Rollback()
3937
 	} else {
3957
 	} else {
3938
-		fmt.Println("err-----------------------", err)
3939
 		tx.Commit()
3958
 		tx.Commit()
3940
 	}
3959
 	}
3941
 	var deliver_number int64 = 0
3960
 	var deliver_number int64 = 0
4513
 
4532
 
4514
 	return nil
4533
 	return nil
4515
 }
4534
 }
4535
+
4536
+func UpdateDrugWarehouseOutInfoTen(patient_id int64, sys_record_time int64, advice_id int64) error {
4537
+
4538
+	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time  = ? and status=1 and advice_id = ?", patient_id, sys_record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
4539
+	return err
4540
+}

+ 1 - 1
service/warhouse_service.go 查看文件

619
 		if drup.ID > 0 {
619
 		if drup.ID > 0 {
620
 			prescribingNumber := advice.PrescribingNumber
620
 			prescribingNumber := advice.PrescribingNumber
621
 
621
 
622
-			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice)
622
+			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber)
623
 
623
 
624
 		} else {
624
 		} else {
625
 			return errors.New("药品信息不存在")
625
 			return errors.New("药品信息不存在")