Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
61281f2fd1

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 6 - 2
controllers/device_api_controller.go View File

@@ -772,6 +772,7 @@ func (this *DeviceAPIController) CreateNumber() {
772 772
 	num := this.GetString("number")
773 773
 	zoneID, _ := this.GetInt64("zone")
774 774
 	groupID, _ := this.GetInt64("group")
775
+	sort, _ := this.GetInt64("sort")
775 776
 	if len(num) == 0 || zoneID <= 0 || groupID <= 0 {
776 777
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
777 778
 		return
@@ -800,7 +801,7 @@ func (this *DeviceAPIController) CreateNumber() {
800 801
 
801 802
 	_, errcode := service.GetCreateDeviceNumber(num, adminInfo.CurrentOrgId)
802 803
 	if errcode == gorm.ErrRecordNotFound {
803
-		number, createErr := service.CreateDeviceNumber(adminInfo.CurrentOrgId, num, zoneID, groupID)
804
+		number, createErr := service.CreateDeviceNumber(adminInfo.CurrentOrgId, num, zoneID, groupID, sort)
804 805
 		if createErr != nil {
805 806
 			this.ErrorLog("创建机号失败:%v", createErr)
806 807
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
@@ -813,6 +814,7 @@ func (this *DeviceAPIController) CreateNumber() {
813 814
 			"group_id":   number.GroupID,
814 815
 			"zone_name":  zone.Name,
815 816
 			"group_name": group.Name,
817
+			"sort":       number.Sort,
816 818
 		}
817 819
 		this.ServeSuccessJSON(map[string]interface{}{
818 820
 			"number": numberJson,
@@ -834,7 +836,7 @@ func (this *DeviceAPIController) ModifyNumber() {
834 836
 	num := this.GetString("number")
835 837
 	zoneID, _ := this.GetInt64("zone")
836 838
 	groupID, _ := this.GetInt64("group")
837
-
839
+	sort, _ := this.GetInt64("sort")
838 840
 	if id <= 0 || len(num) == 0 || zoneID <= 0 || groupID <= 0 {
839 841
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
840 842
 		return
@@ -874,6 +876,7 @@ func (this *DeviceAPIController) ModifyNumber() {
874 876
 	number.Number = num
875 877
 	number.ZoneID = zoneID
876 878
 	number.GroupID = groupID
879
+	number.Sort = sort
877 880
 	byName, _ := service.GetDeviceNumberByName(num, adminInfo.CurrentOrgId)
878 881
 	if byName.ID > 0 && byName.ID != id {
879 882
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -893,6 +896,7 @@ func (this *DeviceAPIController) ModifyNumber() {
893 896
 		"group_id":   number.GroupID,
894 897
 		"zone_name":  zone.Name,
895 898
 		"group_name": group.Name,
899
+		"sort":       number.Sort,
896 900
 	}
897 901
 	this.ServeSuccessJSON(map[string]interface{}{
898 902
 		"number": numberJson,

+ 4 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -1711,7 +1711,7 @@ func (this *DialysisAPIController) StartDialysis() {
1711 1711
 	}
1712 1712
 
1713 1713
 	//只针对广慈医院
1714
-	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 {
1714
+	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 {
1715 1715
 		// 查询病人是否有透前评估数据
1716 1716
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1717 1717
 		//如果有数据就插入
@@ -3090,7 +3090,9 @@ func (c *DialysisAPIController) CreateConsumables() {
3090 3090
 
3091 3091
 			}
3092 3092
 		}
3093
+		//去重
3093 3094
 		updateBeforePrepares = RemoveRepeatedGood(updateBeforePrepares)
3095
+
3094 3096
 		if len(updateBeforePrepares) > 0 {
3095 3097
 			for _, item := range updateBeforePrepares {
3096 3098
 				errs = service.UpdateDialysisBeforePrepareTwo(item)
@@ -4119,6 +4121,7 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4119 4121
 
4120 4122
 	consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
4121 4123
 
4124
+	//去重
4122 4125
 	consumables = RemoveRepeatedGood(consumables)
4123 4126
 
4124 4127
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)

+ 25 - 20
controllers/stock_good_api_controller.go View File

@@ -39,6 +39,8 @@ func (c *StockGoodApiController) CreateGoodType() {
39 39
 	remark := c.GetString("remark")
40 40
 	out_stock := c.GetString("out_stock")
41 41
 	outStockInt, _ := strconv.ParseInt(out_stock, 10, 64)
42
+	stock_attribute := c.GetString("stock_attribute")
43
+	stockAttribute, _ := strconv.ParseInt(stock_attribute, 10, 64)
42 44
 	adminUserInfo := c.GetAdminUserInfo()
43 45
 	totals := service.FindGoodTypeByName(type_name, adminUserInfo.CurrentOrgId)
44 46
 	if totals > 0 {
@@ -50,15 +52,16 @@ func (c *StockGoodApiController) CreateGoodType() {
50 52
 	code := strconv.FormatInt(total+1, 10)
51 53
 	code = "34000000" + code
52 54
 	goodType := models.GoodsType{
53
-		TypeCode: code,
54
-		TypeName: type_name,
55
-		Remark:   remark,
56
-		Ctime:    time.Now().Unix(),
57
-		Mtime:    time.Now().Unix(),
58
-		OrgId:    adminUserInfo.CurrentOrgId,
59
-		Creater:  adminUserInfo.AdminUser.Id,
60
-		Status:   1,
61
-		OutStock: outStockInt,
55
+		TypeCode:       code,
56
+		TypeName:       type_name,
57
+		Remark:         remark,
58
+		Ctime:          time.Now().Unix(),
59
+		Mtime:          time.Now().Unix(),
60
+		OrgId:          adminUserInfo.CurrentOrgId,
61
+		Creater:        adminUserInfo.AdminUser.Id,
62
+		Status:         1,
63
+		OutStock:       outStockInt,
64
+		StockAttribute: stockAttribute,
62 65
 	}
63 66
 	err, types := service.AddSigleGoodType(&goodType)
64 67
 	if err == nil {
@@ -78,7 +81,8 @@ func (c *StockGoodApiController) ModifyGoodType() {
78 81
 	out_stock := c.GetString("out_stock")
79 82
 	outStockInt, _ := strconv.ParseInt(out_stock, 10, 64)
80 83
 	adminUserInfo := c.GetAdminUserInfo()
81
-
84
+	stock_attribute := c.GetString("stock_attribute")
85
+	stockAttribute, _ := strconv.ParseInt(stock_attribute, 10, 64)
82 86
 	//totals := service.FindGoodTypeByName(type_name, adminUserInfo.CurrentOrgId)
83 87
 	//if totals > 0 {
84 88
 	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodTypeNameExistError)
@@ -86,16 +90,17 @@ func (c *StockGoodApiController) ModifyGoodType() {
86 90
 	//}
87 91
 
88 92
 	goodType := models.GoodsType{
89
-		ID:       id,
90
-		TypeCode: good_type_code,
91
-		TypeName: type_name,
92
-		Remark:   remark,
93
-		Ctime:    time.Now().Unix(),
94
-		Mtime:    time.Now().Unix(),
95
-		OrgId:    adminUserInfo.CurrentOrgId,
96
-		Modifier: adminUserInfo.AdminUser.Id,
97
-		Status:   1,
98
-		OutStock: outStockInt,
93
+		ID:             id,
94
+		TypeCode:       good_type_code,
95
+		TypeName:       type_name,
96
+		Remark:         remark,
97
+		Ctime:          time.Now().Unix(),
98
+		Mtime:          time.Now().Unix(),
99
+		OrgId:          adminUserInfo.CurrentOrgId,
100
+		Modifier:       adminUserInfo.AdminUser.Id,
101
+		Status:         1,
102
+		OutStock:       outStockInt,
103
+		StockAttribute: stockAttribute,
99 104
 	}
100 105
 	err, types := service.ModifyGoodType(&goodType)
101 106
 	if err == nil {

+ 1 - 0
models/device_models.go View File

@@ -148,6 +148,7 @@ type DeviceNumber struct {
148 148
 	Status     int8   `json:"-"`
149 149
 	CreateTime int64  `gorm:"column:ctime" json:"-"`
150 150
 	ModifyTime int64  `gorm:"column:mtime" json:"-"`
151
+	Sort       int64  `gorm:"column:sort" json:"sort" form:"sort"`
151 152
 }
152 153
 
153 154
 func (DeviceNumber) TableName() string {

+ 14 - 13
models/good_models.go View File

@@ -1,19 +1,20 @@
1 1
 package models
2 2
 
3 3
 type GoodsType struct {
4
-	ID       int64  `gorm:"column:id" json:"id"`
5
-	TypeCode string `gorm:"column:type_code" json:"type_code"`
6
-	TypeName string `gorm:"column:type_name" json:"type_name"`
7
-	Remark   string `gorm:"column:remark" json:"remark"`
8
-	Ctime    int64  `gorm:"column:ctime" json:"ctime"`
9
-	Mtime    int64  `gorm:"column:mtime" json:"mtime"`
10
-	Creater  int64  `gorm:"column:creater" json:"creater"`
11
-	Modifier int64  `gorm:"column:modifier" json:"modifier"`
12
-	OrgId    int64  `gorm:"column:org_id" json:"org_id"`
13
-	Status   int64  `gorm:"column:status" json:"status"`
14
-	Type     int64  `gorm:"column:type" json:"type"`
15
-	Number   int64  `gorm:"column:number" json:"number"`
16
-	OutStock int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
4
+	ID             int64  `gorm:"column:id" json:"id"`
5
+	TypeCode       string `gorm:"column:type_code" json:"type_code"`
6
+	TypeName       string `gorm:"column:type_name" json:"type_name"`
7
+	Remark         string `gorm:"column:remark" json:"remark"`
8
+	Ctime          int64  `gorm:"column:ctime" json:"ctime"`
9
+	Mtime          int64  `gorm:"column:mtime" json:"mtime"`
10
+	Creater        int64  `gorm:"column:creater" json:"creater"`
11
+	Modifier       int64  `gorm:"column:modifier" json:"modifier"`
12
+	OrgId          int64  `gorm:"column:org_id" json:"org_id"`
13
+	Status         int64  `gorm:"column:status" json:"status"`
14
+	Type           int64  `gorm:"column:type" json:"type"`
15
+	Number         int64  `gorm:"column:number" json:"number"`
16
+	OutStock       int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
17
+	StockAttribute int64  `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
17 18
 }
18 19
 
19 20
 func (GoodsType) TableName() string {

+ 3 - 2
service/device_service.go View File

@@ -459,7 +459,7 @@ func GetCreateDeviceNumber(num string, orgid int64) (*models.DeviceNumber, error
459 459
 	return &number, nil
460 460
 }
461 461
 
462
-func CreateDeviceNumber(orgID int64, number string, zoneID int64, groupID int64) (*models.DeviceNumber, error) {
462
+func CreateDeviceNumber(orgID int64, number string, zoneID int64, groupID int64, sort int64) (*models.DeviceNumber, error) {
463 463
 	now := time.Now().Unix()
464 464
 	numberModel := models.DeviceNumber{
465 465
 		OrgID:      orgID,
@@ -469,6 +469,7 @@ func CreateDeviceNumber(orgID int64, number string, zoneID int64, groupID int64)
469 469
 		Status:     1,
470 470
 		CreateTime: now,
471 471
 		ModifyTime: now,
472
+		Sort:       sort,
472 473
 	}
473 474
 	err := writeDb.Model(&models.DeviceNumber{}).Create(&numberModel).Error
474 475
 	if err != nil {
@@ -492,7 +493,7 @@ func UpdateDeviceNumber(number *models.DeviceNumber) error {
492 493
 		tx.Rollback()
493 494
 		return updateNumberErr
494 495
 	}
495
-	updateDeviceErr := tx.Model(&models.Device{}).Where("org_id = ? AND device_number_id = ?", number.OrgID, number.ID).Updates(map[string]interface{}{"device_number": number.Number}).Error
496
+	updateDeviceErr := tx.Model(&models.Device{}).Where("org_id = ? AND device_number_id = ?", number.OrgID, number.ID).Updates(map[string]interface{}{"device_number": number.Number, "sort": number.Sort}).Error
496 497
 	if updateDeviceErr != nil {
497 498
 		tx.Rollback()
498 499
 		return updateDeviceErr

+ 1 - 1
service/mobile_dialysis_service.go View File

@@ -1354,7 +1354,7 @@ func GetDialysisCountByPatientId(startime int64, endtime int64, patientid int64,
1354 1354
 }
1355 1355
 
1356 1356
 func FindConsumablesByDate(orgID int64, patient_id int64, recordDate int64) (consumables []*models.DialysisBeforePrepare, err error) {
1357
-	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1", orgID, patient_id, recordDate).Find(&consumables).Error
1357
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 AND count<>0", orgID, patient_id, recordDate).Find(&consumables).Error
1358 1358
 	return
1359 1359
 }
1360 1360
 

+ 6 - 5
service/stock_service.go View File

@@ -129,11 +129,12 @@ func AddSigleGoodType(goodType *models.GoodsType) (error, *models.GoodsType) {
129 129
 
130 130
 func ModifyGoodType(goodType *models.GoodsType) (error, *models.GoodsType) {
131 131
 	err := writeDb.Model(&models.GoodsType{}).Where("id = ? AND status = 1", goodType.ID).Updates(map[string]interface{}{
132
-		"modifier":  goodType.Modifier,
133
-		"mtime":     time.Now().Unix(),
134
-		"remark":    goodType.Remark,
135
-		"type_name": goodType.TypeName,
136
-		"out_stock": goodType.OutStock,
132
+		"modifier":        goodType.Modifier,
133
+		"mtime":           time.Now().Unix(),
134
+		"remark":          goodType.Remark,
135
+		"type_name":       goodType.TypeName,
136
+		"out_stock":       goodType.OutStock,
137
+		"stock_attribute": goodType.StockAttribute,
137 138
 	}).Error
138 139
 	return err, goodType
139 140