Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
3d1486cbff

+ 59 - 60
controllers/base_api_controller.go View File

@@ -2,7 +2,6 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
-	"XT_New/models"
6 5
 	"XT_New/service"
7 6
 	"fmt"
8 7
 	"strconv"
@@ -70,36 +69,36 @@ type BaseAuthAPIController struct {
70 69
 func (this *BaseAuthAPIController) Prepare() {
71 70
 	this.BaseAPIController.Prepare()
72 71
 	if this.GetAdminUserInfo() == nil {
73
-		var userAdmin models.AdminUser
74
-		userAdmin.Id = 1448
75
-		userAdmin.Mobile = "13318599895"
76
-
77
-		userAdmin.Id = 597
78
-		userAdmin.Mobile = "19874122664"
79
-		userAdmin.IsSuperAdmin = false
80
-		userAdmin.Status = 1
81
-		userAdmin.CreateTime = 1530786071
82
-		userAdmin.ModifyTime = 1530786071
83
-		var subscibe models.ServeSubscibe
84
-		subscibe.ID = 1
85
-		subscibe.OrgId = 9675
86
-		subscibe.PeriodStart = 1538035409
87
-		subscibe.PeriodEnd = 1569571409
88
-		subscibe.State = 1
89
-		subscibe.Status = 1
90
-		subscibe.CreatedTime = 1538035409
91
-		subscibe.UpdatedTime = 1538035409
92
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
-		subscibes[4] = &subscibe
94
-		var adminUserInfo service.AdminUserInfo
95
-		adminUserInfo.CurrentOrgId = 9675
96
-		adminUserInfo.CurrentAppId = 4
97
-		adminUserInfo.AdminUser = &userAdmin
98
-		adminUserInfo.Subscibes = subscibes
99
-		this.SetSession("admin_user_info", &adminUserInfo)
100
-
101
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
102
-		//this.StopRun()
72
+		//var userAdmin models.AdminUser
73
+		//userAdmin.Id = 1448
74
+		//userAdmin.Mobile = "13318599895"
75
+		//
76
+		//userAdmin.Id = 597
77
+		//userAdmin.Mobile = "19874122664"
78
+		//userAdmin.IsSuperAdmin = false
79
+		//userAdmin.Status = 1
80
+		//userAdmin.CreateTime = 1530786071
81
+		//userAdmin.ModifyTime = 1530786071
82
+		//var subscibe models.ServeSubscibe
83
+		//subscibe.ID = 1
84
+		//subscibe.OrgId = 9675
85
+		//subscibe.PeriodStart = 1538035409
86
+		//subscibe.PeriodEnd = 1569571409
87
+		//subscibe.State = 1
88
+		//subscibe.Status = 1
89
+		//subscibe.CreatedTime = 1538035409
90
+		//subscibe.UpdatedTime = 1538035409
91
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
+		//subscibes[4] = &subscibe
93
+		//var adminUserInfo service.AdminUserInfo
94
+		//adminUserInfo.CurrentOrgId = 9675
95
+		//adminUserInfo.CurrentAppId = 4
96
+		//adminUserInfo.AdminUser = &userAdmin
97
+		//adminUserInfo.Subscibes = subscibes
98
+		//this.SetSession("admin_user_info", &adminUserInfo)
99
+
100
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
+		this.StopRun()
103 102
 
104 103
 	}
105 104
 
@@ -316,35 +315,35 @@ type BaseServeAPIController struct {
316 315
 func (this *BaseServeAPIController) Prepare() {
317 316
 	this.BaseAPIController.Prepare()
318 317
 	if this.GetAdminUserInfo() == nil {
319
-		var userAdmin models.AdminUser
320
-		userAdmin.Id = 1448
321
-		userAdmin.Mobile = "13318599895"
322
-
323
-		userAdmin.Id = 597
324
-		userAdmin.Mobile = "19874122664"
325
-		userAdmin.IsSuperAdmin = false
326
-		userAdmin.Status = 1
327
-		userAdmin.CreateTime = 1530786071
328
-		userAdmin.ModifyTime = 1530786071
329
-		var subscibe models.ServeSubscibe
330
-		subscibe.ID = 1
331
-		subscibe.OrgId = 9675
332
-		subscibe.PeriodStart = 1538035409
333
-		subscibe.PeriodEnd = 1569571409
334
-		subscibe.State = 1
335
-		subscibe.Status = 1
336
-		subscibe.CreatedTime = 1538035409
337
-		subscibe.UpdatedTime = 1538035409
338
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
-		subscibes[4] = &subscibe
340
-		var adminUserInfo service.AdminUserInfo
341
-		adminUserInfo.CurrentOrgId = 9675
342
-		adminUserInfo.CurrentAppId = 4
343
-		adminUserInfo.AdminUser = &userAdmin
344
-		adminUserInfo.Subscibes = subscibes
345
-		this.SetSession("admin_user_info", &adminUserInfo)
346
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
-		//this.StopRun()
318
+		//var userAdmin models.AdminUser
319
+		//userAdmin.Id = 1448
320
+		//userAdmin.Mobile = "13318599895"
321
+		//
322
+		//userAdmin.Id = 597
323
+		//userAdmin.Mobile = "19874122664"
324
+		//userAdmin.IsSuperAdmin = false
325
+		//userAdmin.Status = 1
326
+		//userAdmin.CreateTime = 1530786071
327
+		//userAdmin.ModifyTime = 1530786071
328
+		//var subscibe models.ServeSubscibe
329
+		//subscibe.ID = 1
330
+		//subscibe.OrgId = 9675
331
+		//subscibe.PeriodStart = 1538035409
332
+		//subscibe.PeriodEnd = 1569571409
333
+		//subscibe.State = 1
334
+		//subscibe.Status = 1
335
+		//subscibe.CreatedTime = 1538035409
336
+		//subscibe.UpdatedTime = 1538035409
337
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
+		//subscibes[4] = &subscibe
339
+		//var adminUserInfo service.AdminUserInfo
340
+		//adminUserInfo.CurrentOrgId = 9675
341
+		//adminUserInfo.CurrentAppId = 4
342
+		//adminUserInfo.AdminUser = &userAdmin
343
+		//adminUserInfo.Subscibes = subscibes
344
+		//this.SetSession("admin_user_info", &adminUserInfo)
345
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
+		this.StopRun()
348 347
 	}
349 348
 
350 349
 	//if adminUserInfo.AppRole != nil {

+ 4 - 2
controllers/gobal_config_api_controller.go View File

@@ -1969,13 +1969,15 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
1969 1969
 	limit, _ := c.GetInt64("limit")
1970 1970
 	page, _ := c.GetInt64("page")
1971 1971
 	detail, total, err := service.GetBatchOrderDetail(drug_id, orgId, page, limit)
1972
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
1972 1973
 	if err != nil {
1973 1974
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1974 1975
 		return
1975 1976
 	}
1976 1977
 	c.ServeSuccessJSON(map[string]interface{}{
1977
-		"detail": detail,
1978
-		"total":  total,
1978
+		"detail":           detail,
1979
+		"total":            total,
1980
+		"manufacturerList": manufacturerList,
1979 1981
 	})
1980 1982
 }
1981 1983
 

+ 253 - 253
controllers/public_api_controller.go View File

@@ -1777,258 +1777,258 @@ func (c *PublicApiController) Handle10215() {
1777 1777
 	//service.GetAllInfo(10215,2284)
1778 1778
 	//service.GetAllInfo(10215,2277)
1779 1779
 
1780
-	his, _ := service.GetAllPT(10215)
1781
-	for _, item := range his {
1782
-
1783
-		info := &models.HisPrescriptionInfoTemplate{
1784
-			UserOrgId:   item.UserOrgId,
1785
-			RecordDate:  0,
1786
-			PatientId:   item.PatientId,
1787
-			Status:      1,
1788
-			Ctime:       time.Now().Unix(),
1789
-			Mtime:       time.Now().Unix(),
1790
-			Type:        2,
1791
-			Creator:     0,
1792
-			Modifier:    0,
1793
-			PType:       0,
1794
-			PTemplateId: item.ID,
1795
-			MedType:     "14",
1796
-		}
1797
-		service.CreateHisPrescriptionInfoTemplate(info)
1798
-
1799
-		pro := &models.HisPrescriptionProjectTemplate{
1800
-			ProjectId:          1750,
1801
-			Price:              6.00,
1802
-			UserOrgId:          10215,
1803
-			Status:             1,
1804
-			Ctime:              time.Now().Unix(),
1805
-			Mtime:              time.Now().Unix(),
1806
-			PatientId:          item.PatientId,
1807
-			RecordDate:         0,
1808
-			Count:              1,
1809
-			FeedetlSn:          "",
1810
-			MedListCodg:        "",
1811
-			SingleDose:         "1",
1812
-			DeliveryWay:        "",
1813
-			ExecutionFrequency: "",
1814
-			Day:                "1",
1815
-			Remark:             "",
1816
-			Unit:               "",
1817
-			Type:               2,
1818
-			PrescriptionId:     info.ID,
1819
-			FrequencyType:      1,
1820
-			DayCount:           0,
1821
-			WeekDay:            "",
1822
-		}
1823
-		service.CreateHisPrescriptionProjectTemplate(pro)
1824
-
1825
-		pro2 := &models.HisPrescriptionProjectTemplate{
1826
-			ProjectId:          2462,
1827
-			Price:              4.94,
1828
-			UserOrgId:          10215,
1829
-			Status:             1,
1830
-			Ctime:              time.Now().Unix(),
1831
-			Mtime:              time.Now().Unix(),
1832
-			PatientId:          item.PatientId,
1833
-			RecordDate:         0,
1834
-			Count:              1,
1835
-			FeedetlSn:          "",
1836
-			MedListCodg:        "",
1837
-			SingleDose:         "1",
1838
-			DeliveryWay:        "",
1839
-			ExecutionFrequency: "",
1840
-			Day:                "1",
1841
-			Remark:             "",
1842
-			Unit:               "",
1843
-			Type:               3,
1844
-			PrescriptionId:     info.ID,
1845
-			FrequencyType:      1,
1846
-			DayCount:           0,
1847
-			WeekDay:            "",
1848
-		}
1849
-		service.CreateHisPrescriptionProjectTemplate(pro2)
1850
-		//
1851
-		//
1852
-		infos, _ := service.GetAllPTInfo(10215, item.ID)
1853
-		//	// fmt.Println(infos)
1854
-		for _, subItem := range infos {
1855
-
1856
-			if len(subItem.HisPrescriptionAdviceTemplate) > 0 && len(subItem.HisPrescriptionProjectTemplate) == 0 {
1857
-
1858
-				for _, ssubItem := range subItem.HisPrescriptionAdviceTemplate {
1859
-
1860
-					if ssubItem.DrugId == 1234 {
1861
-						pro := &models.HisPrescriptionProjectTemplate{
1862
-							ProjectId:          2326,
1863
-							Price:              0.86,
1864
-							UserOrgId:          ssubItem.UserOrgId,
1865
-							Status:             1,
1866
-							Ctime:              time.Now().Unix(),
1867
-							Mtime:              time.Now().Unix(),
1868
-							PatientId:          ssubItem.PatientId,
1869
-							RecordDate:         ssubItem.AdviceDate,
1870
-							Count:              1,
1871
-							FeedetlSn:          "",
1872
-							MedListCodg:        "",
1873
-							SingleDose:         "1",
1874
-							DeliveryWay:        "",
1875
-							ExecutionFrequency: "",
1876
-							Day:                "1",
1877
-							Remark:             "",
1878
-							Unit:               "",
1879
-							Type:               3,
1880
-							PrescriptionId:     info.ID,
1881
-							FrequencyType:      ssubItem.FrequencyType,
1882
-							DayCount:           ssubItem.DayCount,
1883
-							WeekDay:            ssubItem.WeekDay,
1884
-						}
1885
-						service.CreateHisPrescriptionProjectTemplate(pro)
1886
-
1887
-					}
1888
-					if ssubItem.DrugId == 1288 {
1889
-
1890
-						pro := &models.HisPrescriptionProjectTemplate{
1891
-							ProjectId:          2326,
1892
-							Price:              0.86,
1893
-							UserOrgId:          ssubItem.UserOrgId,
1894
-							Status:             1,
1895
-							Ctime:              time.Now().Unix(),
1896
-							Mtime:              time.Now().Unix(),
1897
-							PatientId:          ssubItem.PatientId,
1898
-							RecordDate:         ssubItem.AdviceDate,
1899
-							Count:              1,
1900
-							FeedetlSn:          "",
1901
-							MedListCodg:        "",
1902
-							SingleDose:         "1",
1903
-							DeliveryWay:        "",
1904
-							ExecutionFrequency: "",
1905
-							Day:                "1",
1906
-							Remark:             "",
1907
-							Unit:               "",
1908
-							Type:               3,
1909
-							PrescriptionId:     info.ID,
1910
-							FrequencyType:      ssubItem.FrequencyType,
1911
-							DayCount:           ssubItem.DayCount,
1912
-							WeekDay:            ssubItem.WeekDay,
1913
-						}
1914
-						service.CreateHisPrescriptionProjectTemplate(pro)
1915
-
1916
-					}
1917
-					if ssubItem.DrugId == 1306 {
1918
-
1919
-						pro := &models.HisPrescriptionProjectTemplate{
1920
-							ProjectId:          2325,
1921
-							Price:              1.11,
1922
-							UserOrgId:          ssubItem.UserOrgId,
1923
-							Status:             1,
1924
-							Ctime:              time.Now().Unix(),
1925
-							Mtime:              time.Now().Unix(),
1926
-							PatientId:          ssubItem.PatientId,
1927
-							RecordDate:         ssubItem.AdviceDate,
1928
-							Count:              1,
1929
-							FeedetlSn:          "",
1930
-							MedListCodg:        "",
1931
-							SingleDose:         "1",
1932
-							DeliveryWay:        "",
1933
-							ExecutionFrequency: "",
1934
-							Day:                "1",
1935
-							Remark:             "",
1936
-							Unit:               "",
1937
-							Type:               3,
1938
-							PrescriptionId:     info.ID,
1939
-							FrequencyType:      ssubItem.FrequencyType,
1940
-							DayCount:           ssubItem.DayCount,
1941
-							WeekDay:            ssubItem.WeekDay,
1942
-						}
1943
-						service.CreateHisPrescriptionProjectTemplate(pro)
1944
-
1945
-						pro2 := &models.HisPrescriptionProjectTemplate{
1946
-							ProjectId:          1727,
1947
-							Price:              2.50,
1948
-							UserOrgId:          ssubItem.UserOrgId,
1949
-							Status:             1,
1950
-							Ctime:              time.Now().Unix(),
1951
-							Mtime:              time.Now().Unix(),
1952
-							PatientId:          ssubItem.PatientId,
1953
-							RecordDate:         ssubItem.AdviceDate,
1954
-							Count:              1,
1955
-							FeedetlSn:          "",
1956
-							MedListCodg:        "",
1957
-							SingleDose:         "1",
1958
-							DeliveryWay:        "",
1959
-							ExecutionFrequency: "",
1960
-							Day:                "1",
1961
-							Remark:             "",
1962
-							Unit:               "",
1963
-							Type:               2,
1964
-							PrescriptionId:     info.ID,
1965
-							FrequencyType:      ssubItem.FrequencyType,
1966
-							DayCount:           ssubItem.DayCount,
1967
-							WeekDay:            ssubItem.WeekDay,
1968
-						}
1969
-						service.CreateHisPrescriptionProjectTemplate(pro2)
1970
-
1971
-					}
1972
-					if ssubItem.DrugId == 1291 {
1973
-
1974
-						pro := &models.HisPrescriptionProjectTemplate{
1975
-							ProjectId:          2322,
1976
-							Price:              0.68,
1977
-							UserOrgId:          ssubItem.UserOrgId,
1978
-							Status:             1,
1979
-							Ctime:              time.Now().Unix(),
1980
-							Mtime:              time.Now().Unix(),
1981
-							PatientId:          ssubItem.PatientId,
1982
-							RecordDate:         ssubItem.AdviceDate,
1983
-							Count:              1,
1984
-							FeedetlSn:          "",
1985
-							MedListCodg:        "",
1986
-							SingleDose:         "1",
1987
-							DeliveryWay:        "",
1988
-							ExecutionFrequency: "",
1989
-							Day:                "1",
1990
-							Remark:             "",
1991
-							Unit:               "",
1992
-							Type:               3,
1993
-							PrescriptionId:     info.ID,
1994
-							FrequencyType:      ssubItem.FrequencyType,
1995
-							DayCount:           ssubItem.DayCount,
1996
-							WeekDay:            ssubItem.WeekDay,
1997
-						}
1998
-						service.CreateHisPrescriptionProjectTemplate(pro)
1999
-
2000
-						pro2 := &models.HisPrescriptionProjectTemplate{
2001
-							ProjectId:          1727,
2002
-							Price:              2.50,
2003
-							UserOrgId:          ssubItem.UserOrgId,
2004
-							Status:             1,
2005
-							Ctime:              time.Now().Unix(),
2006
-							Mtime:              time.Now().Unix(),
2007
-							PatientId:          ssubItem.PatientId,
2008
-							RecordDate:         ssubItem.AdviceDate,
2009
-							Count:              1,
2010
-							FeedetlSn:          "",
2011
-							MedListCodg:        "",
2012
-							SingleDose:         "1",
2013
-							DeliveryWay:        "",
2014
-							ExecutionFrequency: "",
2015
-							Day:                "1",
2016
-							Remark:             "",
2017
-							Unit:               "",
2018
-							Type:               2,
2019
-							PrescriptionId:     info.ID,
2020
-							FrequencyType:      ssubItem.FrequencyType,
2021
-							DayCount:           ssubItem.DayCount,
2022
-							WeekDay:            ssubItem.WeekDay,
2023
-						}
2024
-						service.CreateHisPrescriptionProjectTemplate(pro2)
2025
-					}
2026
-				}
2027
-
2028
-			}
2029
-
2030
-		}
2031
-
2032
-	}
1780
+	//his, _ := service.GetAllPT(10215)
1781
+	//for _, item := range his {
1782
+	//
1783
+	//	info := &models.HisPrescriptionInfoTemplate{
1784
+	//		UserOrgId:   item.UserOrgId,
1785
+	//		RecordDate:  0,
1786
+	//		PatientId:   item.PatientId,
1787
+	//		Status:      1,
1788
+	//		Ctime:       time.Now().Unix(),
1789
+	//		Mtime:       time.Now().Unix(),
1790
+	//		Type:        2,
1791
+	//		Creator:     0,
1792
+	//		Modifier:    0,
1793
+	//		PType:       0,
1794
+	//		PTemplateId: item.ID,
1795
+	//		MedType:     "14",
1796
+	//	}
1797
+	//	service.CreateHisPrescriptionInfoTemplate(info)
1798
+	//
1799
+	//	pro := &models.HisPrescriptionProjectTemplate{
1800
+	//		ProjectId:          1750,
1801
+	//		Price:              6.00,
1802
+	//		UserOrgId:          10215,
1803
+	//		Status:             1,
1804
+	//		Ctime:              time.Now().Unix(),
1805
+	//		Mtime:              time.Now().Unix(),
1806
+	//		PatientId:          item.PatientId,
1807
+	//		RecordDate:         0,
1808
+	//		Count:              1,
1809
+	//		FeedetlSn:          "",
1810
+	//		MedListCodg:        "",
1811
+	//		SingleDose:         "1",
1812
+	//		DeliveryWay:        "",
1813
+	//		ExecutionFrequency: "",
1814
+	//		Day:                "1",
1815
+	//		Remark:             "",
1816
+	//		Unit:               "",
1817
+	//		Type:               2,
1818
+	//		PrescriptionId:     info.ID,
1819
+	//		FrequencyType:      1,
1820
+	//		DayCount:           0,
1821
+	//		WeekDay:            "",
1822
+	//	}
1823
+	//	service.CreateHisPrescriptionProjectTemplate(pro)
1824
+	//
1825
+	//	pro2 := &models.HisPrescriptionProjectTemplate{
1826
+	//		ProjectId:          2462,
1827
+	//		Price:              4.94,
1828
+	//		UserOrgId:          10215,
1829
+	//		Status:             1,
1830
+	//		Ctime:              time.Now().Unix(),
1831
+	//		Mtime:              time.Now().Unix(),
1832
+	//		PatientId:          item.PatientId,
1833
+	//		RecordDate:         0,
1834
+	//		Count:              1,
1835
+	//		FeedetlSn:          "",
1836
+	//		MedListCodg:        "",
1837
+	//		SingleDose:         "1",
1838
+	//		DeliveryWay:        "",
1839
+	//		ExecutionFrequency: "",
1840
+	//		Day:                "1",
1841
+	//		Remark:             "",
1842
+	//		Unit:               "",
1843
+	//		Type:               3,
1844
+	//		PrescriptionId:     info.ID,
1845
+	//		FrequencyType:      1,
1846
+	//		DayCount:           0,
1847
+	//		WeekDay:            "",
1848
+	//	}
1849
+	//	service.CreateHisPrescriptionProjectTemplate(pro2)
1850
+	//	//
1851
+	//	//
1852
+	//	infos, _ := service.GetAllPTInfo(10215, item.ID)
1853
+	//	//	// fmt.Println(infos)
1854
+	//	for _, subItem := range infos {
1855
+	//
1856
+	//		if len(subItem.HisPrescriptionAdviceTemplate) > 0 && len(subItem.HisPrescriptionProjectTemplate) == 0 {
1857
+	//
1858
+	//			for _, ssubItem := range subItem.HisPrescriptionAdviceTemplate {
1859
+	//
1860
+	//				if ssubItem.DrugId == 1234 {
1861
+	//					pro := &models.HisPrescriptionProjectTemplate{
1862
+	//						ProjectId:          2326,
1863
+	//						Price:              0.86,
1864
+	//						UserOrgId:          ssubItem.UserOrgId,
1865
+	//						Status:             1,
1866
+	//						Ctime:              time.Now().Unix(),
1867
+	//						Mtime:              time.Now().Unix(),
1868
+	//						PatientId:          ssubItem.PatientId,
1869
+	//						RecordDate:         ssubItem.AdviceDate,
1870
+	//						Count:              1,
1871
+	//						FeedetlSn:          "",
1872
+	//						MedListCodg:        "",
1873
+	//						SingleDose:         "1",
1874
+	//						DeliveryWay:        "",
1875
+	//						ExecutionFrequency: "",
1876
+	//						Day:                "1",
1877
+	//						Remark:             "",
1878
+	//						Unit:               "",
1879
+	//						Type:               3,
1880
+	//						PrescriptionId:     info.ID,
1881
+	//						FrequencyType:      ssubItem.FrequencyType,
1882
+	//						DayCount:           ssubItem.DayCount,
1883
+	//						WeekDay:            ssubItem.WeekDay,
1884
+	//					}
1885
+	//					service.CreateHisPrescriptionProjectTemplate(pro)
1886
+	//
1887
+	//				}
1888
+	//				if ssubItem.DrugId == 1288 {
1889
+	//
1890
+	//					pro := &models.HisPrescriptionProjectTemplate{
1891
+	//						ProjectId:          2326,
1892
+	//						Price:              0.86,
1893
+	//						UserOrgId:          ssubItem.UserOrgId,
1894
+	//						Status:             1,
1895
+	//						Ctime:              time.Now().Unix(),
1896
+	//						Mtime:              time.Now().Unix(),
1897
+	//						PatientId:          ssubItem.PatientId,
1898
+	//						RecordDate:         ssubItem.AdviceDate,
1899
+	//						Count:              1,
1900
+	//						FeedetlSn:          "",
1901
+	//						MedListCodg:        "",
1902
+	//						SingleDose:         "1",
1903
+	//						DeliveryWay:        "",
1904
+	//						ExecutionFrequency: "",
1905
+	//						Day:                "1",
1906
+	//						Remark:             "",
1907
+	//						Unit:               "",
1908
+	//						Type:               3,
1909
+	//						PrescriptionId:     info.ID,
1910
+	//						FrequencyType:      ssubItem.FrequencyType,
1911
+	//						DayCount:           ssubItem.DayCount,
1912
+	//						WeekDay:            ssubItem.WeekDay,
1913
+	//					}
1914
+	//					service.CreateHisPrescriptionProjectTemplate(pro)
1915
+	//
1916
+	//				}
1917
+	//				if ssubItem.DrugId == 1306 {
1918
+	//
1919
+	//					pro := &models.HisPrescriptionProjectTemplate{
1920
+	//						ProjectId:          2325,
1921
+	//						Price:              1.11,
1922
+	//						UserOrgId:          ssubItem.UserOrgId,
1923
+	//						Status:             1,
1924
+	//						Ctime:              time.Now().Unix(),
1925
+	//						Mtime:              time.Now().Unix(),
1926
+	//						PatientId:          ssubItem.PatientId,
1927
+	//						RecordDate:         ssubItem.AdviceDate,
1928
+	//						Count:              1,
1929
+	//						FeedetlSn:          "",
1930
+	//						MedListCodg:        "",
1931
+	//						SingleDose:         "1",
1932
+	//						DeliveryWay:        "",
1933
+	//						ExecutionFrequency: "",
1934
+	//						Day:                "1",
1935
+	//						Remark:             "",
1936
+	//						Unit:               "",
1937
+	//						Type:               3,
1938
+	//						PrescriptionId:     info.ID,
1939
+	//						FrequencyType:      ssubItem.FrequencyType,
1940
+	//						DayCount:           ssubItem.DayCount,
1941
+	//						WeekDay:            ssubItem.WeekDay,
1942
+	//					}
1943
+	//					service.CreateHisPrescriptionProjectTemplate(pro)
1944
+	//
1945
+	//					pro2 := &models.HisPrescriptionProjectTemplate{
1946
+	//						ProjectId:          1727,
1947
+	//						Price:              2.50,
1948
+	//						UserOrgId:          ssubItem.UserOrgId,
1949
+	//						Status:             1,
1950
+	//						Ctime:              time.Now().Unix(),
1951
+	//						Mtime:              time.Now().Unix(),
1952
+	//						PatientId:          ssubItem.PatientId,
1953
+	//						RecordDate:         ssubItem.AdviceDate,
1954
+	//						Count:              1,
1955
+	//						FeedetlSn:          "",
1956
+	//						MedListCodg:        "",
1957
+	//						SingleDose:         "1",
1958
+	//						DeliveryWay:        "",
1959
+	//						ExecutionFrequency: "",
1960
+	//						Day:                "1",
1961
+	//						Remark:             "",
1962
+	//						Unit:               "",
1963
+	//						Type:               2,
1964
+	//						PrescriptionId:     info.ID,
1965
+	//						FrequencyType:      ssubItem.FrequencyType,
1966
+	//						DayCount:           ssubItem.DayCount,
1967
+	//						WeekDay:            ssubItem.WeekDay,
1968
+	//					}
1969
+	//					service.CreateHisPrescriptionProjectTemplate(pro2)
1970
+	//
1971
+	//				}
1972
+	//				if ssubItem.DrugId == 1291 {
1973
+	//
1974
+	//					pro := &models.HisPrescriptionProjectTemplate{
1975
+	//						ProjectId:          2322,
1976
+	//						Price:              0.68,
1977
+	//						UserOrgId:          ssubItem.UserOrgId,
1978
+	//						Status:             1,
1979
+	//						Ctime:              time.Now().Unix(),
1980
+	//						Mtime:              time.Now().Unix(),
1981
+	//						PatientId:          ssubItem.PatientId,
1982
+	//						RecordDate:         ssubItem.AdviceDate,
1983
+	//						Count:              1,
1984
+	//						FeedetlSn:          "",
1985
+	//						MedListCodg:        "",
1986
+	//						SingleDose:         "1",
1987
+	//						DeliveryWay:        "",
1988
+	//						ExecutionFrequency: "",
1989
+	//						Day:                "1",
1990
+	//						Remark:             "",
1991
+	//						Unit:               "",
1992
+	//						Type:               3,
1993
+	//						PrescriptionId:     info.ID,
1994
+	//						FrequencyType:      ssubItem.FrequencyType,
1995
+	//						DayCount:           ssubItem.DayCount,
1996
+	//						WeekDay:            ssubItem.WeekDay,
1997
+	//					}
1998
+	//					service.CreateHisPrescriptionProjectTemplate(pro)
1999
+	//
2000
+	//					pro2 := &models.HisPrescriptionProjectTemplate{
2001
+	//						ProjectId:          1727,
2002
+	//						Price:              2.50,
2003
+	//						UserOrgId:          ssubItem.UserOrgId,
2004
+	//						Status:             1,
2005
+	//						Ctime:              time.Now().Unix(),
2006
+	//						Mtime:              time.Now().Unix(),
2007
+	//						PatientId:          ssubItem.PatientId,
2008
+	//						RecordDate:         ssubItem.AdviceDate,
2009
+	//						Count:              1,
2010
+	//						FeedetlSn:          "",
2011
+	//						MedListCodg:        "",
2012
+	//						SingleDose:         "1",
2013
+	//						DeliveryWay:        "",
2014
+	//						ExecutionFrequency: "",
2015
+	//						Day:                "1",
2016
+	//						Remark:             "",
2017
+	//						Unit:               "",
2018
+	//						Type:               2,
2019
+	//						PrescriptionId:     info.ID,
2020
+	//						FrequencyType:      ssubItem.FrequencyType,
2021
+	//						DayCount:           ssubItem.DayCount,
2022
+	//						WeekDay:            ssubItem.WeekDay,
2023
+	//					}
2024
+	//					service.CreateHisPrescriptionProjectTemplate(pro2)
2025
+	//				}
2026
+	//			}
2027
+	//
2028
+	//		}
2029
+	//
2030
+	//	}
2031
+	//
2032
+	//}
2033 2033
 
2034 2034
 }

+ 33 - 12
controllers/self_drug_api_congtroller.go View File

@@ -1452,6 +1452,8 @@ func (this *SelfDrugApiController) GetDrugDamageList() {
1452 1452
 	limit, _ := this.GetInt64("limit")
1453 1453
 	page, _ := this.GetInt64("page")
1454 1454
 	list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page)
1455
+
1456
+	damagelist, _ := service.GetDrugDamageByOrgId(orgId)
1455 1457
 	doctorList, err := service.GetAllDoctorThree(orgId)
1456 1458
 	if err != nil {
1457 1459
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
@@ -1461,6 +1463,7 @@ func (this *SelfDrugApiController) GetDrugDamageList() {
1461 1463
 	this.ServeSuccessJSON(map[string]interface{}{
1462 1464
 		"total":      total,
1463 1465
 		"list":       list,
1466
+		"damagelist": damagelist,
1464 1467
 		"doctorList": doctorList,
1465 1468
 	})
1466 1469
 }
@@ -2455,6 +2458,8 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2455 2458
 
2456 2459
 			orgId := this.GetAdminUserInfo().CurrentOrgId
2457 2460
 
2461
+			type_id := int64(items["type"].(float64))
2462
+
2458 2463
 			if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
2459 2464
 				utils.ErrorLog("expiry_date")
2460 2465
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -2463,24 +2468,39 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2463 2468
 			expiry_date := int64(items["expiry_date"].(float64))
2464 2469
 
2465 2470
 			manufacturer := int64(items["manufacturer"].(float64))
2466
-
2471
+			timeLayout := "2006-01-02"
2472
+			loc, _ := time.LoadLocation("Local")
2473
+			timeNow := time.Now().Format("2006-01-02")
2474
+			locationTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeNow+" 00:00:00", loc)
2467 2475
 			var consumable_type int64
2476
+			var consumable_count int64
2468 2477
 			var ord_total int64
2469 2478
 			var new_total int64
2470 2479
 			ord_total = stock_max_number*min_number + stock_min_number
2471 2480
 			new_total = last_stock_max_number*min_number + last_stock_min_number
2481
+
2472 2482
 			if ord_total > new_total {
2473 2483
 				consumable_type = 11
2484
+				consumable_count = ord_total - new_total
2474 2485
 			}
2475 2486
 			if ord_total < new_total {
2476 2487
 				consumable_type = 10
2488
+				consumable_count = new_total - ord_total
2489
+			}
2490
+
2491
+			//改变库存
2492
+			info := models.DrugWarehouseInfo{
2493
+				DrugId:         drug_id,
2494
+				StockMaxNumber: last_stock_max_number,
2495
+				StockMinNumber: last_stock_min_number,
2477 2496
 			}
2478 2497
 
2498
+			err = service.ModifyDrugWarehouseInfo(&info, id)
2479 2499
 			inventory := models.XtDrugInventory{
2480 2500
 				DrugName:           drug_name,
2481 2501
 				SpecificationName:  specification_name,
2482 2502
 				WarehousingUnit:    max_unit,
2483
-				Count:              0,
2503
+				Count:              consumable_count,
2484 2504
 				LastPrice:          price,
2485 2505
 				RetailPrice:        0,
2486 2506
 				NewPrice:           0,
@@ -2494,7 +2514,7 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2494 2514
 				Status:             1,
2495 2515
 				WarehousingOrder:   warehousing_order,
2496 2516
 				LicenseNumber:      "",
2497
-				StartTime:          0,
2517
+				StartTime:          locationTime.Unix(),
2498 2518
 				Creater:            this.GetAdminUserInfo().AdminUser.Id,
2499 2519
 				Checker:            0,
2500 2520
 				CheckerStatus:      0,
@@ -2513,6 +2533,8 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2513 2533
 				MinUnit:            min_unit,
2514 2534
 				LastStockMaxNumber: last_stock_max_number,
2515 2535
 				LastStockMinNumber: last_stock_min_number,
2536
+				InventoryType:      consumable_type,
2537
+				Type:               type_id,
2516 2538
 			}
2517 2539
 
2518 2540
 			err = service.CreateDrugInventory(inventory)
@@ -2522,10 +2544,10 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2522 2544
 				DrugId:                  drug_id,
2523 2545
 				Number:                  "",
2524 2546
 				BatchNumber:             batch_number,
2525
-				Count:                   0,
2547
+				Count:                   consumable_count,
2526 2548
 				UserOrgId:               orgId,
2527 2549
 				PatientId:               0,
2528
-				SystemTime:              time.Now().Unix(),
2550
+				SystemTime:              locationTime.Unix(),
2529 2551
 				ConsumableType:          consumable_type,
2530 2552
 				IsSys:                   1,
2531 2553
 				WarehousingOrder:        warehousing_order,
@@ -2553,15 +2575,14 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2553 2575
 
2554 2576
 			service.CreateDrugFlowOne(flow)
2555 2577
 
2556
-			//改变库存
2557
-			info := models.DrugWarehouseInfo{
2558
-				DrugId:         drug_id,
2559
-				StockMaxNumber: last_stock_max_number,
2560
-				StockMinNumber: last_stock_min_number,
2578
+			if err != nil {
2579
+				this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2580
+				return
2561 2581
 			}
2562 2582
 
2563
-			err = service.ModifyDrugWarehouseInfo(&info, drug_id)
2564
-			fmt.Println(err)
2583
+			this.ServeSuccessJSON(map[string]interface{}{
2584
+				"inventory": inventory,
2585
+			})
2565 2586
 		}
2566 2587
 	}
2567 2588
 }

+ 2 - 2
main.go View File

@@ -16,8 +16,8 @@ func main() {
16 16
 	//service.BeginAutoCreatePlanJob()
17 17
 	//service.AutoClearSchedules()
18 18
 	//service.BeginAutoCreateStaffScheduleJob()
19
-	service.BeginAutoCreateDrugJob()
20
-	service.BeginAutoCreateStockJob()
19
+	//service.BeginAutoCreateDrugJob()
20
+	//service.BeginAutoCreateStockJob()
21 21
 	beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 60
22 22
 	beego.Run()
23 23
 }

+ 38 - 36
models/drug_stock.go View File

@@ -327,42 +327,44 @@ type StDrugWarehouseOutInfo struct {
327 327
 }
328 328
 
329 329
 type DrugFlow struct {
330
-	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
331
-	WarehousingId           int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
332
-	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
333
-	Number                  string  `gorm:"column:number" json:"number" form:"number"`
334
-	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
335
-	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
336
-	UserOrgId               int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
337
-	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
338
-	SystemTime              int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
339
-	ConsumableType          int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
340
-	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
341
-	WarehousingOrder        string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
342
-	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
343
-	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
344
-	IsEdit                  int64   `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
345
-	CancelStockId           int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
346
-	CancelOrderNumber       string  `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
347
-	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
348
-	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
349
-	Creator                 int64   `gorm:"column:creator" json:"creator" form:"creator"`
350
-	UpdateCreator           int64   `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
351
-	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
352
-	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
353
-	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
354
-	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
355
-	WarehousingDetailId     int64   `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
356
-	WarehouseOutDetailId    int64   `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
357
-	CancelOutDetailId       int64   `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
358
-	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
359
-	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
360
-	MaxUnit                 string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
361
-	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
362
-	StockMaxNumber          int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
363
-	StockMinNumber          int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
364
-	LastStockMaxNumber      int64   `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
365
-	LastStockMinNumber      int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
330
+	ID                      int64                `gorm:"column:id" json:"id" form:"id"`
331
+	WarehousingId           int64                `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
332
+	DrugId                  int64                `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
333
+	Number                  string               `gorm:"column:number" json:"number" form:"number"`
334
+	BatchNumber             string               `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
335
+	Count                   int64                `gorm:"column:count" json:"count" form:"count"`
336
+	UserOrgId               int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
337
+	PatientId               int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
338
+	SystemTime              int64                `gorm:"column:system_time" json:"system_time" form:"system_time"`
339
+	ConsumableType          int64                `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
340
+	IsSys                   int64                `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
341
+	WarehousingOrder        string               `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
342
+	WarehouseOutId          int64                `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
343
+	WarehouseOutOrderNumber string               `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
344
+	IsEdit                  int64                `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
345
+	CancelStockId           int64                `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
346
+	CancelOrderNumber       string               `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
347
+	Manufacturer            int64                `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
348
+	Dealer                  int64                `gorm:"column:dealer" json:"dealer" form:"dealer"`
349
+	Creator                 int64                `gorm:"column:creator" json:"creator" form:"creator"`
350
+	UpdateCreator           int64                `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
351
+	Status                  int64                `gorm:"column:status" json:"status" form:"status"`
352
+	Ctime                   int64                `gorm:"column:ctime" json:"ctime" form:"ctime"`
353
+	Mtime                   int64                `gorm:"column:mtime" json:"mtime" form:"mtime"`
354
+	Price                   float64              `gorm:"column:price" json:"price" form:"price"`
355
+	WarehousingDetailId     int64                `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
356
+	WarehouseOutDetailId    int64                `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
357
+	CancelOutDetailId       int64                `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
358
+	ExpireDate              int64                `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
359
+	ProductDate             int64                `gorm:"column:product_date" json:"product_date" form:"product_date"`
360
+	MaxUnit                 string               `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
361
+	MinUnit                 string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
362
+	StockMaxNumber          int64                `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
363
+	StockMinNumber          int64                `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
364
+	LastStockMaxNumber      int64                `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
365
+	LastStockMinNumber      int64                `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
366
+	DrugWarehouseInfo       []*DrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" `
367
+	BaseDrugLib             BaseDrugLib          `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
366 368
 }
367 369
 
368 370
 func (DrugFlow) TableName() string {

+ 42 - 33
models/self_drug_models.go View File

@@ -805,6 +805,8 @@ type XtDrugInventory struct {
805 805
 	MinUnit            string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
806 806
 	LastStockMaxNumber int64   `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
807 807
 	LastStockMinNumber int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
808
+	InventoryType      int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
809
+	Type               int64   `gorm:"column:type" json:"type" form:"type"`
808 810
 }
809 811
 
810 812
 func (XtDrugInventory) TableName() string {
@@ -812,39 +814,46 @@ func (XtDrugInventory) TableName() string {
812 814
 }
813 815
 
814 816
 type VmDrugInventory struct {
815
-	ID                int64   `gorm:"column:id" json:"id" form:"id"`
816
-	DrugName          string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
817
-	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
818
-	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
819
-	Count             int64   `gorm:"column:count" json:"count" form:"count"`
820
-	LastPrice         float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
821
-	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
822
-	NewPrice          float64 `gorm:"column:new_price" json:"new_price" form:"new_price"`
823
-	Manufacturer      string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
824
-	Dealer            string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
825
-	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
826
-	DrugId            int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
827
-	UserOrgId         int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
828
-	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
829
-	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
830
-	Status            int64   `gorm:"column:status" json:"status" form:"status"`
831
-	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
832
-	Number            string  `gorm:"column:number" json:"number" form:"number"`
833
-	StartTime         int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
834
-	Creater           int64   `gorm:"column:creater" json:"creater" form:"creater"`
835
-	Checker           int64   `gorm:"column:checker" json:"checker" form:"checker"`
836
-	CheckerStatus     int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
837
-	CheckerTime       int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
838
-	MinNumber         int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
839
-	Dose              float64 `gorm:"column:dose" json:"dose" form:"dose"`
840
-	DoseUnit          string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
841
-	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
842
-	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
843
-	MinCount          int64   `gorm:"column:min_count" json:"min_count" form:"min_count"`
844
-	Total             string  `gorm:"column:total" json:"total" form:"total"`
845
-	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
846
-	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
847
-	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
817
+	ID                 int64              `gorm:"column:id" json:"id" form:"id"`
818
+	DrugName           string             `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
819
+	SpecificationName  string             `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
820
+	WarehousingUnit    string             `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
821
+	Count              int64              `gorm:"column:count" json:"count" form:"count"`
822
+	LastPrice          float64            `gorm:"column:last_price" json:"last_price" form:"last_price"`
823
+	RetailPrice        float64            `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
824
+	NewPrice           float64            `gorm:"column:new_price" json:"new_price" form:"new_price"`
825
+	Manufacturer       string             `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
826
+	Dealer             string             `gorm:"column:dealer" json:"dealer" form:"dealer"`
827
+	Remark             string             `gorm:"column:remark" json:"remark" form:"remark"`
828
+	DrugId             int64              `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
829
+	UserOrgId          int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
830
+	Ctime              int64              `gorm:"column:ctime" json:"ctime" form:"ctime"`
831
+	Mtime              int64              `gorm:"column:mtime" json:"mtime" form:"mtime"`
832
+	Status             int64              `gorm:"column:status" json:"status" form:"status"`
833
+	WarehousingOrder   string             `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
834
+	Number             string             `gorm:"column:number" json:"number" form:"number"`
835
+	StartTime          int64              `gorm:"column:start_time" json:"start_time" form:"start_time"`
836
+	Creater            int64              `gorm:"column:creater" json:"creater" form:"creater"`
837
+	Checker            int64              `gorm:"column:checker" json:"checker" form:"checker"`
838
+	CheckerStatus      int64              `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
839
+	CheckerTime        int64              `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
840
+	MinNumber          int64              `gorm:"column:min_number" json:"min_number" form:"min_number"`
841
+	Dose               float64            `gorm:"column:dose" json:"dose" form:"dose"`
842
+	DoseUnit           string             `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
843
+	MaxUnit            string             `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
844
+	MinUnit            string             `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
845
+	MinCount           int64              `gorm:"column:min_count" json:"min_count" form:"min_count"`
846
+	Total              string             `gorm:"column:total" json:"total" form:"total"`
847
+	ExpiryDate         int64              `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
848
+	ProductDate        int64              `gorm:"column:product_date" json:"product_date" form:"product_date"`
849
+	DrugOriginPlace    string             `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
850
+	LastStockMaxNumber int64              `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
851
+	LastStockMinNumber int64              `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
852
+	InventoryType      int64              `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
853
+	StockMaxNumber     int64              `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
854
+	StockMinNumber     int64              `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
855
+	WarehouseInfoId    int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
856
+	Children           []*XtDrugInventory `gorm:"column:children" json:"children" form:"children"`
848 857
 }
849 858
 
850 859
 type SgjDrugWarehouseOutInfo struct {

+ 2 - 2
service/auto_create_stock.go View File

@@ -14,8 +14,8 @@ var createStockCronJob *cron.Cron
14 14
 func init() {
15 15
 	utils.InfoLog("开启自动更新耗材库存定时任务")
16 16
 	createStockCronJob = cron.New()
17
-	spec := "0 */5 * * * ?" // 每1分钟执行一次
18
-	//spec := "0 55 23 * * ?" // 每天23点55执行一次
17
+	//spec := "0 */5 * * * ?" // 每1分钟执行一次
18
+	spec := "0 55 23 * * ?" // 每天23点55执行一次
19 19
 	//spec := "0 0 0 ? * Sun"
20 20
 	createStockCronJob.AddFunc(spec, func() {
21 21
 		AutoCreateStockJob()

+ 11 - 3
service/schedule_service.go View File

@@ -715,9 +715,17 @@ func FindSchedualTemplateExportLog(org_id int64, export_time int64) (errLogs []*
715 715
 	return
716 716
 }
717 717
 
718
-func GetDialysisOrderByBedId(orgID, start, bed_id int64, schedule_type int64) (schedule models.DialysisOrder, err error) {
719
-	err = readDb.Model(&models.DialysisOrder{}).Where("user_org_id=?  and dialysis_date=? and bed_id=? and status=1 AND schedual_type = ?", orgID, start, bed_id, schedule_type).First(&schedule).Error
720
-	return
718
+func GetDialysisOrderByBedId(orgID, start, bed_id int64, schedule_type int64) (*models.DialysisOrder, error) {
719
+	order := models.DialysisOrder{}
720
+	err = readDb.Model(&order).Where("user_org_id=?  and dialysis_date=? and bed_id=? and status=1 AND schedual_type = ?", orgID, start, bed_id, schedule_type).Find(&order).Error
721
+	if err == gorm.ErrRecordNotFound {
722
+		return nil, err
723
+	}
724
+	if err != nil {
725
+		return nil, err
726
+	}
727
+	return &order, nil
728
+
721 729
 }
722 730
 
723 731
 type VMDeviceNumber struct {

+ 10 - 5
service/self_drug_service.go View File

@@ -876,10 +876,10 @@ func CreateDrugDamage(damage models.XtDrugDamage) error {
876 876
 	return err
877 877
 }
878 878
 
879
-func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.XtDrugDamage, total int64, err error) {
879
+func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugInventory, total int64, err error) {
880 880
 	likeKey := "%" + keyword + "%"
881 881
 	offset := (page - 1) * limit
882
-	db := XTReadDB().Table("xt_drug_damage as x").Where("x.status = 1")
882
+	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and inventory_type = 10")
883 883
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
884 884
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
885 885
 	fmt.Println(table, tab)
@@ -895,10 +895,15 @@ func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword strin
895 895
 	if endtime > 0 {
896 896
 		db = db.Where("x.ctime <=?", endtime)
897 897
 	}
898
-	err = db.Group("x.id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number,x.drug_origin_place,x.warehousing_info_id,x.batch_number,x.stock_max_number,x.stock_min_number").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
898
+	err = db.Group("x.drug_id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number,x.drug_origin_place,x.warehouse_info_id,x.batch_number,x.stock_max_number,x.stock_min_number").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
899 899
 	return adjust, total, err
900 900
 }
901 901
 
902
+func GetDrugDamageByOrgId(orgid int64) (list []*models.XtDrugInventory, err error) {
903
+	err = XTReadDB().Model(&list).Where("user_org_id = ? and inventory_type = 10 and status = 1", orgid).Find(&list).Error
904
+	return list, err
905
+}
906
+
902 907
 func UpdateDrugDamage(ids []string, damage models.XtDrugDamage) error {
903 908
 
904 909
 	err := XTWriteDB().Model(&damage).Where("id in(?)", ids).Updates(map[string]interface{}{"checker": damage.Checker, "checker_status": damage.CheckerStatus, "checker_time": damage.CheckerTime}).Error
@@ -1077,12 +1082,12 @@ func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid i
1077 1082
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
1078 1083
 	fmt.Println(table, tab)
1079 1084
 	if len(keyword) > 0 {
1080
-		db = db.Where("x.warehousing_order = ? or r.user_name like ?", keyword, likeKey)
1085
+		db = db.Where("x.warehousing_order = ? or r.user_name like ? or t.drug_name like ?", keyword, likeKey, likeKey)
1081 1086
 	}
1082 1087
 	if orgid > 0 {
1083 1088
 		db = db.Where("x.user_org_id = ?", orgid)
1084 1089
 	}
1085
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,t.dose,t.dose_unit,t.max_unit,x.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1090
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,t.dose,t.dose_unit,t.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.last_stock_max_number,x.last_stock_min_number,x.inventory_type").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1086 1091
 	return list, total, err
1087 1092
 }
1088 1093
 

+ 8 - 1
service/stock_service.go View File

@@ -4201,8 +4201,15 @@ func GetDrugFlow(drugid int64, orgid int64, limit int64, page int64, startTime i
4201 4201
 		if stock_type == 4 {
4202 4202
 			db = db.Where("consumable_type = 4")
4203 4203
 		}
4204
+		if stock_type == 10 {
4205
+			db = db.Where("consumable_type = 10")
4206
+		}
4207
+		if stock_type == 11 {
4208
+			db = db.Where("consumable_type = 11")
4209
+		}
4210
+
4204 4211
 	}
4205
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&drug_flow).Error
4212
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("BaseDrugLib", "status = 1").Preload("DrugWarehouseInfo", "status = 1").Find(&drug_flow).Error
4206 4213
 	return drug_flow, total, err
4207 4214
 }
4208 4215