소스 검색

11月8日库存管理

XMLWAN 3 년 전
부모
커밋
9247aeb83e

+ 1 - 3
controllers/dialysis_record_api_controller.go 파일 보기

@@ -77,7 +77,7 @@ func (this *DialysisRecordAPIController) GetSchedules() {
77 77
 	redis := service.RedisClient()
78 78
 	defer redis.Close()
79 79
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
80
-
80
+	patients, _ := service.GetAllPcPatientListByListSeven(orgID)
81 81
 	scheduals_json_str, _ := redis.Get(key).Result()
82 82
 
83 83
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -89,8 +89,6 @@ func (this *DialysisRecordAPIController) GetSchedules() {
89 89
 		} else {
90 90
 			if len(scheduals) > 0 {
91 91
 
92
-				patients, _ := service.GetAllPcPatientListByListSeven(orgID)
93
-
94 92
 				dialysisOrders, _ := service.GetAllPcDialysisOrdersByList(orgID, date.Unix())
95 93
 
96 94
 				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())

+ 32 - 0
controllers/gobal_config_api_controller.go 파일 보기

@@ -112,6 +112,8 @@ func GobalConfigRegistRouters() {
112 112
 	beego.Router("/api/drug/getexportoutorderdruglist", &GobalConfigApiController{}, "Get:GetExportOutOrderDrugList")
113 113
 	beego.Router("/api/drug/getdrugflow", &GobalConfigApiController{}, "Get:GetDrugFlow")
114 114
 	beego.Router("/api/drug/getcancelstockdetail", &GobalConfigApiController{}, "Get:GetCancelStockDetail")
115
+
116
+	beego.Router("/api/changestocksetting/isopen", &GobalConfigApiController{}, "Get:ChangeStockSetting")
115 117
 }
116 118
 
117 119
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1557,9 +1559,11 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1557 1559
 	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1558 1560
 	_, project_config := service.FindXTHisProjectByOrgIdOne(adminUserInfo.CurrentOrgId)
1559 1561
 
1562
+	stockSetting, _ := service.FindStockSettingById(adminUserInfo.CurrentOrgId)
1560 1563
 	c.ServeSuccessJSON(map[string]interface{}{
1561 1564
 		"is_open_xt_his":         config.IsOpen,
1562 1565
 		"is_open_xt_his_project": project_config.IsOpen,
1566
+		"is_open_stock":          stockSetting.IsType,
1563 1567
 	})
1564 1568
 
1565 1569
 }
@@ -2331,3 +2335,31 @@ func (c *GobalConfigApiController) GetCancelStockDetail() {
2331 2335
 		"list": list,
2332 2336
 	})
2333 2337
 }
2338
+
2339
+func (c *GobalConfigApiController) ChangeStockSetting() {
2340
+
2341
+	is_type, _ := c.GetInt64("is_type")
2342
+
2343
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2344
+	setting := models.XtStockSetting{
2345
+		IsType:    is_type,
2346
+		UserOrgId: orgId,
2347
+		Status:    1,
2348
+		Ctime:     time.Now().Unix(),
2349
+		Mtime:     0,
2350
+	}
2351
+
2352
+	//查询机该机构是否已经配置
2353
+	_, errcode := service.GetStockSettingIsExsit(orgId)
2354
+	if errcode == gorm.ErrRecordNotFound {
2355
+		service.CreateStockSetting(setting)
2356
+		c.ServeSuccessJSON(map[string]interface{}{
2357
+			"msg": 1,
2358
+		})
2359
+	} else if errcode == nil {
2360
+		service.UpdateStockSetting(orgId, setting)
2361
+		c.ServeSuccessJSON(map[string]interface{}{
2362
+			"msg": 1,
2363
+		})
2364
+	}
2365
+}

+ 8 - 0
controllers/patient_api_controller.go 파일 보기

@@ -568,6 +568,14 @@ func (c *PatientApiController) EditPatient() {
568 568
 	//	//更新病人ID获取新表病人ID
569 569
 	err = service.UpdatepatientTwo(&patientsNew, id)
570 570
 
571
+	nowTimeUinx := time.Now()
572
+	today := nowTimeUinx.Format("2006-01-02")
573
+
574
+	redis := service.RedisClient()
575
+	defer redis.Close()
576
+	key := "scheduals_" + today + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
577
+	redis.Set(key, "", time.Second*60*60*18)
578
+
571 579
 	if len(record_date) > 0 {
572 580
 		var recordTime int64
573 581
 		timeLayout := "2006-01-02"

+ 78 - 20
controllers/secondary_order_api_contorller.go 파일 보기

@@ -40,25 +40,6 @@ func SecondaryOrderApiRegistRouters() {
40 40
 	beego.Router("/api/secondary/byliinit", &SecondaryOrderApiController{}, "get:Byliinit")                         //初始化旧数据
41 41
 	beego.Router("/api/secondary/getcreaterid", &SecondaryOrderApiController{}, "get:GetCreaterId")                 //获取当前登录的人的id
42 42
 
43
-	beego.Router("/api/secondary/getcode", &SecondaryOrderApiController{}, "get:GetStoreCode")                      //获取仓库编码
44
-	beego.Router("/api/secondary/updatestatus", &SecondaryOrderApiController{}, "get:UpdateStatus")                 //修改仓库状态
45
-	beego.Router("/api/secondary/deletestorehouse", &SecondaryOrderApiController{}, "get:DeleteStorehouse")         //删除仓库
46
-	beego.Router("/api/secondary/isstorehousename", &SecondaryOrderApiController{}, "get:IsStorehouseName")         //仓库名称是否重复
47
-	beego.Router("/api/secondary/isstorehouseaddress", &SecondaryOrderApiController{}, "get:IsStorehouseAddress")   //仓库地址是否重复
48
-	beego.Router("/api/secondary/storehouselist", &SecondaryOrderApiController{}, "get:StorehouseList")             //分页
49
-	beego.Router("/api/secondary/addstorehouse", &SecondaryOrderApiController{}, "post:AddStorehouse")              //新增仓库
50
-	beego.Router("/api/secondary/updatestorehouse", &SecondaryOrderApiController{}, "post:UpdateStorehouse")        //修改
51
-	beego.Router("/api/secondary/getonestorehouse", &SecondaryOrderApiController{}, "get:GetOneStorehouse")         //查一条仓库的信息
52
-	beego.Router("/api/secondary/getallstorehousename", &SecondaryOrderApiController{}, "get:GetAllStorehouseName") //获取当前机构的所有可用仓库名称
53
-	beego.Router("/api/secondary/findstorehouseconfig", &SecondaryOrderApiController{}, "get:FindStorehouseConfig") //查询该机构的仓库配置
54
-	beego.Router("/api/secondary/updateinfo", &SecondaryOrderApiController{}, "get:UpdateInfo")                     //更改耗材自动入库仓库
55
-	beego.Router("/api/secondary/updateoutinfo", &SecondaryOrderApiController{}, "get:UpdateOutInfo")               //更改耗材自动出库仓库
56
-	beego.Router("/api/secondary/updatedruginfo", &SecondaryOrderApiController{}, "get:UpdateDrugInfo")             //更改药品自动入库仓库
57
-	beego.Router("/api/secondary/updatedrugout", &SecondaryOrderApiController{}, "get:UpdateDrugOut")               //更改药品自动出库仓库
58
-	beego.Router("/api/secondary/getusername", &SecondaryOrderApiController{}, "get:GetuserName")                   //获取仓库管理员信息
59
-	beego.Router("/api/secondary/byliinit", &SecondaryOrderApiController{}, "get:Byliinit")                         //初始化旧数据
60
-	beego.Router("/api/secondary/getcreaterid", &SecondaryOrderApiController{}, "get:GetCreaterId")
61
-
62 43
 	beego.Router("/api/seconde/getsencondegoodlist", &SecondaryOrderApiController{}, "Get:GetSencondeGoodList")
63 44
 	beego.Router("/api/senconde/savesencondorder", &SecondaryOrderApiController{}, "Post:SaveSencondOrder")
64 45
 	beego.Router("/api/senconde/getallsecondeorderlist", &SecondaryOrderApiController{}, "Get:GetAllSecondeOrderList")
@@ -1538,7 +1519,7 @@ func (this *SecondaryOrderApiController) ReturnCheckSecondOrder() {
1538 1519
 				outList, _ := service.GetStoreWarehouseOutList(item.ProjectId, item.ID, item.UserOrgId)
1539 1520
 				for _, it := range outList {
1540 1521
 					//回退库存
1541
-					service.ModifyStoreWarehouseById(it.WarehouseInfotId, item.Count)
1522
+					service.ModifyStoreWarehouseById(it.WarehouseInfotId, it.Count)
1542 1523
 
1543 1524
 					//获取入库单
1544 1525
 					storeWareing, _ := service.GetStoreWarehouseById(item.WarehouseId, it.OrgId)
@@ -1785,6 +1766,22 @@ func (this *SecondaryOrderApiController) UpdateInfo() {
1785 1766
 	}
1786 1767
 	id, _ := this.GetInt64("id")
1787 1768
 	err = service.UpdateInfo(orgId, id)
1769
+
1770
+	//查询默认仓库
1771
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1772
+
1773
+	list, _ := service.GetAllGoodList(orgId)
1774
+	for _, item := range list {
1775
+		var sum_count int64
1776
+		var sum_in_count int64
1777
+		goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ID, orgId)
1778
+		for _, it := range goodList {
1779
+			sum_count += it.StockCount
1780
+			sum_in_count += it.WarehousingCount
1781
+		}
1782
+		service.UpdateGoodByGoodId(item.ID, sum_count, sum_in_count, orgId)
1783
+	}
1784
+
1788 1785
 	if err != nil {
1789 1786
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1790 1787
 		return
@@ -1809,6 +1806,22 @@ func (this *SecondaryOrderApiController) UpdateOutInfo() {
1809 1806
 	}
1810 1807
 	id, _ := this.GetInt64("id")
1811 1808
 	err = service.UpdateOutInfo(orgId, id)
1809
+
1810
+	//查询默认仓库
1811
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1812
+
1813
+	list, _ := service.GetAllGoodList(orgId)
1814
+	for _, item := range list {
1815
+		var sum_count int64
1816
+		var sum_in_count int64
1817
+		goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ID, orgId)
1818
+		for _, it := range goodList {
1819
+			sum_count += it.StockCount
1820
+			sum_in_count += it.WarehousingCount
1821
+		}
1822
+		service.UpdateGoodByGoodId(item.ID, sum_count, sum_in_count, orgId)
1823
+	}
1824
+
1812 1825
 	if err != nil {
1813 1826
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1814 1827
 		return
@@ -1832,7 +1845,30 @@ func (this *SecondaryOrderApiController) UpdateDrugInfo() {
1832 1845
 		return
1833 1846
 	}
1834 1847
 	id, _ := this.GetInt64("id")
1848
+
1835 1849
 	err = service.UpdateDrugInfo2(orgId, id)
1850
+
1851
+	//查询默认仓库
1852
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1853
+	baseDrug, _ := service.GetAllBaseDrugList(orgId)
1854
+
1855
+	for _, item := range baseDrug {
1856
+		var sum_drug_count int64
1857
+		var sum_drug_in_count int64
1858
+
1859
+		//查询默认仓库剩余多少库存
1860
+		list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, item.ID)
1861
+		for _, it := range list {
1862
+			if it.MaxUnit == item.MaxUnit {
1863
+				it.StockMaxNumber = it.StockMaxNumber * item.MinNumber
1864
+				it.WarehousingCount = it.WarehousingCount * item.MinNumber
1865
+			}
1866
+			sum_drug_count += it.StockMaxNumber + it.StockMinNumber
1867
+			sum_drug_in_count += it.WarehousingCount
1868
+		}
1869
+		service.UpdateMedicalSumCount(item.ID, sum_drug_count, sum_drug_in_count, orgId)
1870
+	}
1871
+
1836 1872
 	if err != nil {
1837 1873
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1838 1874
 		return
@@ -1857,6 +1893,28 @@ func (this *SecondaryOrderApiController) UpdateDrugOut() {
1857 1893
 	}
1858 1894
 	id, _ := this.GetInt64("id")
1859 1895
 	err = service.UpdateDrugOut(orgId, id)
1896
+
1897
+	//查询默认仓库
1898
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1899
+	baseDrug, _ := service.GetAllBaseDrugList(orgId)
1900
+
1901
+	for _, item := range baseDrug {
1902
+		var sum_drug_count int64
1903
+		var sum_drug_in_count int64
1904
+
1905
+		//查询默认仓库剩余多少库存
1906
+		list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, item.ID)
1907
+		for _, it := range list {
1908
+			if it.MaxUnit == item.MaxUnit {
1909
+				it.StockMaxNumber = it.StockMaxNumber * item.MinNumber
1910
+				it.WarehousingCount = it.WarehousingCount * item.MinNumber
1911
+			}
1912
+			sum_drug_count += it.StockMaxNumber + it.StockMinNumber
1913
+			sum_drug_in_count += it.WarehousingCount
1914
+		}
1915
+		service.UpdateMedicalSumCount(item.ID, sum_drug_count, sum_drug_in_count, orgId)
1916
+	}
1917
+
1860 1918
 	if err != nil {
1861 1919
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1862 1920
 		return

+ 13 - 0
models/stock_models.go 파일 보기

@@ -1332,3 +1332,16 @@ type BloodHisPrescriptionProject struct {
1332 1332
 func (BloodHisPrescriptionProject) TableName() string {
1333 1333
 	return "his_prescription_project"
1334 1334
 }
1335
+
1336
+type XtStockSetting struct {
1337
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1338
+	IsType    int64 `gorm:"column:is_type" json:"is_type" form:"is_type"`
1339
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1340
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1341
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1342
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1343
+}
1344
+
1345
+func (XtStockSetting) TableName() string {
1346
+	return "xt_stock_setting"
1347
+}

+ 33 - 0
service/stock_service.go 파일 보기

@@ -6435,3 +6435,36 @@ func GeAllGoodInformation(orgid int64) (good []*models.GoodInfo, err error) {
6435 6435
 	err = XTReadDB().Where("org_id =? and status = 1 and is_user = 1", orgid).Find(&good).Error
6436 6436
 	return good, err
6437 6437
 }
6438
+
6439
+func GetStockSettingIsExsit(orgid int64) (*models.XtStockSetting, error) {
6440
+
6441
+	setting := models.XtStockSetting{}
6442
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
6443
+	if err == gorm.ErrRecordNotFound {
6444
+		return nil, err
6445
+	}
6446
+	if err != nil {
6447
+		return nil, err
6448
+	}
6449
+	return &setting, nil
6450
+}
6451
+
6452
+func CreateStockSetting(setting models.XtStockSetting) error {
6453
+
6454
+	err := XTWriteDB().Create(&setting).Error
6455
+
6456
+	return err
6457
+}
6458
+
6459
+func UpdateStockSetting(orgid int64, setting models.XtStockSetting) error {
6460
+
6461
+	err := XTWriteDB().Model(&models.XtStockSetting{}).Where("user_org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_type": setting.IsType}).Error
6462
+	return err
6463
+}
6464
+
6465
+func FindStockSettingById(orgid int64) (models.XtStockSetting, error) {
6466
+
6467
+	setting := models.XtStockSetting{}
6468
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
6469
+	return setting, err
6470
+}