Browse Source

历史排班

28169 1 year ago
parent
commit
8de0d32b60

+ 9 - 3
controllers/his_api_controller.go View File

@@ -2033,9 +2033,7 @@ func (c *HisApiController) CreateHisPrescription() {
2033 2033
 								var batch_number_count int64
2034 2034
 								batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
2035 2035
 								batch_number_counts := strconv.FormatInt(batch_number_count, 10)
2036
-								fmt.Println("woowowowowowwowowo", advicelist.ID)
2037
-								fmt.Println("prescribing_number", prescribing_number)
2038
-								fmt.Println("totototootto", totals)
2036
+
2039 2037
 								//新增处方
2040 2038
 								if advicelist.ID == 0 {
2041 2039
 									all_count, _ := strconv.ParseFloat(totals, 64)
@@ -3351,6 +3349,7 @@ func (c *HisApiController) CreateHisPrescription() {
3351 3349
 					if drug.IsUse == 2 {
3352 3350
 						creater := adminInfo.AdminUser.Id
3353 3351
 						service.HisDrugsDelivery(item.UserOrgId, creater, item)
3352
+
3354 3353
 					}
3355 3354
 
3356 3355
 					//更新字典里面的库存
@@ -3367,6 +3366,10 @@ func (c *HisApiController) CreateHisPrescription() {
3367 3366
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
3368 3367
 					//剩余库存
3369 3368
 					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count)
3369
+
3370
+					over, _ := service.FindOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut)
3371
+					service.UpdateActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount)
3372
+
3370 3373
 				}
3371 3374
 			}
3372 3375
 		}
@@ -7410,6 +7413,9 @@ func (c *HisApiController) GetUploadInfo() {
7410 7413
 						}
7411 7414
 						service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7412 7415
 						service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
7416
+						over, _ := service.FindOverCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut)
7417
+						service.UpdateActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount)
7418
+
7413 7419
 					}
7414 7420
 
7415 7421
 				}

+ 4 - 5
controllers/pharmacy_controller.go View File

@@ -169,7 +169,7 @@ func (this *PharmacyController) IssuedDrug() {
169 169
 		etime = stime + 86399
170 170
 	}
171 171
 
172
-	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 || orgid == 10375 || orgid == 10480 {
172
+	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 || orgid == 10375 || orgid == 10480 || orgid == 10344 {
173 173
 
174 174
 		//获取排班班次
175 175
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
@@ -193,7 +193,7 @@ func (this *PharmacyController) IssuedDrug() {
193 193
 		})
194 194
 	}
195 195
 
196
-	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 && orgid != 10375 && orgid != 10480 {
196
+	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 && orgid != 10375 && orgid != 10480 && orgid == 10344 {
197 197
 		//查询表里当天的数据
198 198
 		var flist []*models.TmpPatient
199 199
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
@@ -249,7 +249,7 @@ func (this *PharmacyController) WaitingDrug() {
249 249
 		etime = stime + 86399
250 250
 	}
251 251
 
252
-	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 && orgid != 10375 && orgid != 10480 {
252
+	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 && orgid != 10375 && orgid != 10480 && orgid != 10344 {
253 253
 		//查询表里当天的数据
254 254
 		var flist []*models.TmpPatient
255 255
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
@@ -273,11 +273,10 @@ func (this *PharmacyController) WaitingDrug() {
273 273
 	}
274 274
 
275 275
 	//当天已发药的人数
276
-	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10387 || orgid == 10375 || orgid == 10480 {
276
+	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10387 || orgid == 10375 || orgid == 10480 || orgid == 10344 {
277 277
 
278 278
 		//获取排班班次
279 279
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
280
-		fmt.Println("schedule--------", schedule)
281 280
 		var ids []int64
282 281
 		for _, item := range schedule {
283 282
 			ids = append(ids, item.PatientId)

+ 28 - 0
controllers/sign_api_controller.go View File

@@ -8,6 +8,7 @@ import (
8 8
 	"fmt"
9 9
 	"github.com/astaxie/beego"
10 10
 	"github.com/jung-kurt/gofpdf"
11
+	"github.com/mozillazg/go-pinyin"
11 12
 	"io/ioutil"
12 13
 	"time"
13 14
 )
@@ -657,6 +658,33 @@ func (this *SignApiController) GetEnterPriseDetail() {
657 658
 
658 659
 func (this *SignApiController) UploadPrintOrder() {
659 660
 
661
+	list, _ := service.GetAllPatientNew(10188)
662
+	for _, item := range list {
663
+
664
+		hans := item.Name // 要转换的汉字字符串
665
+		// 创建一个拼音转换器
666
+		p := pinyin.NewArgs()
667
+
668
+		// 将汉字转为拼音
669
+		pinyinSlice := pinyin.Pinyin(hans, p)
670
+
671
+		// 输出拼音
672
+		fmt.Println("Pinyin:", pinyinSlice)
673
+
674
+		// 获取首字母
675
+		firstLetter := ""
676
+		for _, py := range pinyinSlice {
677
+			if len(py) > 0 {
678
+				firstLetter += string(py[0][0])
679
+			}
680
+		}
681
+
682
+		item.FirstLetter = firstLetter
683
+		service.UpdatePatientNew(item.ID, item.FirstLetter)
684
+		// 输出首字母
685
+		//fmt.Println("First Letter:", firstLetter)
686
+	}
687
+
660 688
 	//pdfg, _ := wkhtml.NewPDFGenerator()
661 689
 	//
662 690
 	//htmlStr := `<html><body><h1 style="color:red;">This is an html

+ 1 - 2
service/manage_center_service.go View File

@@ -2,7 +2,6 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
-	"fmt"
6 5
 	"github.com/jinzhu/gorm"
7 6
 	"strconv"
8 7
 	"strings"
@@ -450,7 +449,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
450 449
 		for _, its := range list {
451 450
 			//查询该批次病人该药品出库数据
452 451
 			infos, _ := GetDrugAutoWarehouseOutTen(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID, its.WarehouseInfoId)
453
-			fmt.Println("info2332323232332233223wo", infos.Count)
452
+
454 453
 			//查询该药品出库批次总入库数量
455 454
 			druginfo, _ := GetDrugInfoSix(its.WarehouseInfoId, infos.OrgId)
456 455
 

+ 39 - 5
service/new_warehouse_service.go View File

@@ -596,6 +596,23 @@ func AddDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count in
596 596
 	return err
597 597
 }
598 598
 
599
+func FindOverCount(drug_id int64, org_id int64, storehouse_id int64) (models.XtDrugStockCount, error) {
600
+
601
+	stockCount := models.XtDrugStockCount{}
602
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and storehouse_id=?", drug_id, org_id, storehouse_id).Find(&stockCount).Error
603
+	return stockCount, err
604
+}
605
+
606
+func UpdateActOut(id int64, sum_in_count int64, flush_count int64, sum_cancel_count int64) error {
607
+
608
+	var sum_out_count int64
609
+	sum_out_count = sum_in_count - flush_count
610
+	var sum_act_out_count int64
611
+	sum_act_out_count = sum_out_count + sum_cancel_count
612
+	err := XTWriteDB().Model(&models.XtDrugStockCount{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"sum_out_count": sum_out_count, "sum_act_out_count": sum_act_out_count}).Error
613
+	return err
614
+}
615
+
599 616
 func ReduceDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count int64) error {
600 617
 	ut := XTWriteDB().Begin()
601 618
 	err := ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id = ? and drug_id = ?", storehouse_id, org_id, drug_id).UpdateColumn("sum_out_count", gorm.Expr("sum_out_count - ?", out_count)).Error
@@ -1390,8 +1407,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1390 1407
 
1391 1408
 	}
1392 1409
 
1393
-	fmt.Println("库存数量2嚄噢嚄噢噢哦哦嚄噢嚄o", stock_number)
1394
-	fmt.Println("出库数咯哦我我我我嚄嚄嚄嚄", deliver_number)
1395 1410
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1396 1411
 	if stock_number >= deliver_number {
1397 1412
 
@@ -1603,6 +1618,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1603 1618
 		fmt.Println("退款数来的发阿道夫", cancel_count)
1604 1619
 
1605 1620
 		fmt.Println("查收嗖嗖嗖哦", deliver_number_one-(out_count-cancel_count))
1621
+
1606 1622
 		if deliver_number_one-(out_count-cancel_count) >= 0 {
1607 1623
 			if (deliver_number_one - out_count - cancel_count) != 0 {
1608 1624
 
@@ -1638,7 +1654,24 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1638 1654
 						AdviceId:                advice.ID,
1639 1655
 					}
1640 1656
 
1641
-					AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1657
+					errThreeThrtiy := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1658
+
1659
+					if errThreeThrtiy != nil {
1660
+						drugError := models.XtDrugError{
1661
+							UserOrgId:             orgID,
1662
+							DrugId:                advice.DrugId,
1663
+							RecordDate:            advice.AdviceDate,
1664
+							PatientId:             advice.PatientId,
1665
+							Remark:                "插入数据报错",
1666
+							Status:                1,
1667
+							Ctime:                 time.Now().Unix(),
1668
+							Mtime:                 0,
1669
+							SumCount:              0,
1670
+							Prescribingnumber:     advice.PrescribingNumber,
1671
+							PrescribingNumberUnit: advice.PrescribingNumberUnit,
1672
+						}
1673
+						CreateDrugError(drugError)
1674
+					}
1642 1675
 
1643 1676
 				}
1644 1677
 				lastDrugOutInfo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
@@ -1693,6 +1726,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1693 1726
 					}
1694 1727
 					CreateDrugError(drugError)
1695 1728
 				}
1729
+
1696 1730
 				//出库数量相加
1697 1731
 				errThreeTys := AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1698 1732
 
@@ -2160,8 +2194,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2160 2194
 			cancel_count += item.Count
2161 2195
 		}
2162 2196
 
2163
-		fmt.Println("deliver_nbumbwowowoowowow", deliver_number)
2164
-		fmt.Println("out_coutnwoowowowowowow", out_count)
2165 2197
 		//如果本次出库数据大于历史出库数据 新增1条流水
2166 2198
 		if deliver_number > (out_count - cancel_count) {
2167 2199
 
@@ -2200,6 +2232,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2200 2232
 			CreateDrugFlowOne(drugflow)
2201 2233
 			//出库数量相加
2202 2234
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
2235
+
2203 2236
 		}
2204 2237
 
2205 2238
 		if deliver_number < (out_count - cancel_count) {
@@ -3271,6 +3304,7 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
3271 3304
 			CreateDrugFlowOne(drugflow)
3272 3305
 			//出库数量相加
3273 3306
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
3307
+
3274 3308
 		}
3275 3309
 
3276 3310
 		if deliver_number < (out_count - cancel_count) {

+ 1 - 1
service/patientmanage_service.go View File

@@ -777,7 +777,7 @@ func SearchallPatient(keyword string, orgid int64) (patients []*models.XtPatient
777 777
 	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
778 778
 	if len(keyword) > 0 {
779 779
 		likeKey := "%" + keyword + "%"
780
-		db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ?", likeKey, likeKey)
780
+		db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ? OR x.first_letter=?", likeKey, likeKey, likeKey)
781 781
 	}
782 782
 	if orgid > 0 {
783 783
 		db = db.Where("x.user_org_id = ?", orgid)

+ 12 - 0
service/sign_service.go View File

@@ -2050,3 +2050,15 @@ func SingleImg2Pdf(pathStr string) {
2050 2050
 	err := pdf.OutputFileAndClose(fileStr)
2051 2051
 	fmt.Println(err)
2052 2052
 }
2053
+
2054
+func GetAllPatientNew(org_id int64) (new []*models.XtPatientsNew, err error) {
2055
+
2056
+	err = XTReadDB().Where("user_org_id = ? and status=1", org_id).Find(&new).Error
2057
+	return new, err
2058
+}
2059
+
2060
+func UpdatePatientNew(id int64, firstleterr string) error {
2061
+
2062
+	err := XTWriteDB().Model(models.XtPatientsNew{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
2063
+	return err
2064
+}

+ 11 - 7
service/stock_service.go View File

@@ -3259,13 +3259,17 @@ func UpdateStockOut(warehouseinfoid int64, info models.WarehousingInfo) error {
3259 3259
 }
3260 3260
 
3261 3261
 func AddSigleDrugWarehouseOutInfo(info *models.DrugWarehouseOutInfo) error {
3262
-	ut := writeDb.Begin()
3263
-	err := ut.Create(&info).Error
3264
-	if err != nil {
3265
-		ut.Rollback()
3266
-		return err
3267
-	}
3268
-	ut.Commit()
3262
+	//ut := writeDb.Begin()
3263
+	//err := ut.Create(&info).Error
3264
+	//if err != nil {
3265
+	//	ut.Rollback()
3266
+	//	return err
3267
+	//}
3268
+	//ut.Commit()
3269
+	//return err
3270
+
3271
+	err := writeDb.Create(&info).Error
3272
+
3269 3273
 	return err
3270 3274
 }
3271 3275