28169 1 rok temu
rodzic
commit
8de0d32b60

+ 9 - 3
controllers/his_api_controller.go Wyświetl plik

2033
 								var batch_number_count int64
2033
 								var batch_number_count int64
2034
 								batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
2034
 								batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
2035
 								batch_number_counts := strconv.FormatInt(batch_number_count, 10)
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
 								if advicelist.ID == 0 {
2038
 								if advicelist.ID == 0 {
2041
 									all_count, _ := strconv.ParseFloat(totals, 64)
2039
 									all_count, _ := strconv.ParseFloat(totals, 64)
3351
 					if drug.IsUse == 2 {
3349
 					if drug.IsUse == 2 {
3352
 						creater := adminInfo.AdminUser.Id
3350
 						creater := adminInfo.AdminUser.Id
3353
 						service.HisDrugsDelivery(item.UserOrgId, creater, item)
3351
 						service.HisDrugsDelivery(item.UserOrgId, creater, item)
3352
+
3354
 					}
3353
 					}
3355
 
3354
 
3356
 					//更新字典里面的库存
3355
 					//更新字典里面的库存
3367
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
3366
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
3368
 					//剩余库存
3367
 					//剩余库存
3369
 					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count)
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
 						}
7413
 						}
7411
 						service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7414
 						service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7412
 						service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
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 Wyświetl plik

169
 		etime = stime + 86399
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
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
175
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
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
 		var flist []*models.TmpPatient
198
 		var flist []*models.TmpPatient
199
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
199
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
249
 		etime = stime + 86399
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
 		var flist []*models.TmpPatient
254
 		var flist []*models.TmpPatient
255
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
255
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
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
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
279
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
280
-		fmt.Println("schedule--------", schedule)
281
 		var ids []int64
280
 		var ids []int64
282
 		for _, item := range schedule {
281
 		for _, item := range schedule {
283
 			ids = append(ids, item.PatientId)
282
 			ids = append(ids, item.PatientId)

+ 28 - 0
controllers/sign_api_controller.go Wyświetl plik

8
 	"fmt"
8
 	"fmt"
9
 	"github.com/astaxie/beego"
9
 	"github.com/astaxie/beego"
10
 	"github.com/jung-kurt/gofpdf"
10
 	"github.com/jung-kurt/gofpdf"
11
+	"github.com/mozillazg/go-pinyin"
11
 	"io/ioutil"
12
 	"io/ioutil"
12
 	"time"
13
 	"time"
13
 )
14
 )
657
 
658
 
658
 func (this *SignApiController) UploadPrintOrder() {
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
 	//pdfg, _ := wkhtml.NewPDFGenerator()
688
 	//pdfg, _ := wkhtml.NewPDFGenerator()
661
 	//
689
 	//
662
 	//htmlStr := `<html><body><h1 style="color:red;">This is an html
690
 	//htmlStr := `<html><body><h1 style="color:red;">This is an html

+ 1 - 2
service/manage_center_service.go Wyświetl plik

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

+ 39 - 5
service/new_warehouse_service.go Wyświetl plik

596
 	return err
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
 func ReduceDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count int64) error {
616
 func ReduceDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count int64) error {
600
 	ut := XTWriteDB().Begin()
617
 	ut := XTWriteDB().Begin()
601
 	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
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
 
1407
 
1391
 	}
1408
 	}
1392
 
1409
 
1393
-	fmt.Println("库存数量2嚄噢嚄噢噢哦哦嚄噢嚄o", stock_number)
1394
-	fmt.Println("出库数咯哦我我我我嚄嚄嚄嚄", deliver_number)
1395
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1410
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1396
 	if stock_number >= deliver_number {
1411
 	if stock_number >= deliver_number {
1397
 
1412
 
1603
 		fmt.Println("退款数来的发阿道夫", cancel_count)
1618
 		fmt.Println("退款数来的发阿道夫", cancel_count)
1604
 
1619
 
1605
 		fmt.Println("查收嗖嗖嗖哦", deliver_number_one-(out_count-cancel_count))
1620
 		fmt.Println("查收嗖嗖嗖哦", deliver_number_one-(out_count-cancel_count))
1621
+
1606
 		if deliver_number_one-(out_count-cancel_count) >= 0 {
1622
 		if deliver_number_one-(out_count-cancel_count) >= 0 {
1607
 			if (deliver_number_one - out_count - cancel_count) != 0 {
1623
 			if (deliver_number_one - out_count - cancel_count) != 0 {
1608
 
1624
 
1638
 						AdviceId:                advice.ID,
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
 				lastDrugOutInfo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
1677
 				lastDrugOutInfo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
1693
 					}
1726
 					}
1694
 					CreateDrugError(drugError)
1727
 					CreateDrugError(drugError)
1695
 				}
1728
 				}
1729
+
1696
 				//出库数量相加
1730
 				//出库数量相加
1697
 				errThreeTys := AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1731
 				errThreeTys := AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1698
 
1732
 
2160
 			cancel_count += item.Count
2194
 			cancel_count += item.Count
2161
 		}
2195
 		}
2162
 
2196
 
2163
-		fmt.Println("deliver_nbumbwowowoowowow", deliver_number)
2164
-		fmt.Println("out_coutnwoowowowowowow", out_count)
2165
 		//如果本次出库数据大于历史出库数据 新增1条流水
2197
 		//如果本次出库数据大于历史出库数据 新增1条流水
2166
 		if deliver_number > (out_count - cancel_count) {
2198
 		if deliver_number > (out_count - cancel_count) {
2167
 
2199
 
2200
 			CreateDrugFlowOne(drugflow)
2232
 			CreateDrugFlowOne(drugflow)
2201
 			//出库数量相加
2233
 			//出库数量相加
2202
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
2234
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
2235
+
2203
 		}
2236
 		}
2204
 
2237
 
2205
 		if deliver_number < (out_count - cancel_count) {
2238
 		if deliver_number < (out_count - cancel_count) {
3271
 			CreateDrugFlowOne(drugflow)
3304
 			CreateDrugFlowOne(drugflow)
3272
 			//出库数量相加
3305
 			//出库数量相加
3273
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
3306
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
3307
+
3274
 		}
3308
 		}
3275
 
3309
 
3276
 		if deliver_number < (out_count - cancel_count) {
3310
 		if deliver_number < (out_count - cancel_count) {

+ 1 - 1
service/patientmanage_service.go Wyświetl plik

777
 	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
777
 	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
778
 	if len(keyword) > 0 {
778
 	if len(keyword) > 0 {
779
 		likeKey := "%" + keyword + "%"
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
 	if orgid > 0 {
782
 	if orgid > 0 {
783
 		db = db.Where("x.user_org_id = ?", orgid)
783
 		db = db.Where("x.user_org_id = ?", orgid)

+ 12 - 0
service/sign_service.go Wyświetl plik

2050
 	err := pdf.OutputFileAndClose(fileStr)
2050
 	err := pdf.OutputFileAndClose(fileStr)
2051
 	fmt.Println(err)
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 Wyświetl plik

3259
 }
3259
 }
3260
 
3260
 
3261
 func AddSigleDrugWarehouseOutInfo(info *models.DrugWarehouseOutInfo) error {
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
 	return err
3273
 	return err
3270
 }
3274
 }
3271
 
3275