Browse Source

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx 3 years ago
parent
commit
17aad5bde6

+ 76 - 14
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -4332,14 +4332,14 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4332 4332
 				}
4333 4333
 
4334 4334
 				good_id := int64(items["good_id"].(float64))
4335
-				fmt.Println("goood_id2222222222222222", good_id)
4335
+
4336 4336
 				if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
4337 4337
 					utils.ErrorLog("good_type_id")
4338 4338
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4339 4339
 					return
4340 4340
 				}
4341 4341
 				good_type_id := int64(items["good_type_id"].(float64))
4342
-				fmt.Println("goood_id2222222222222222", good_type_id)
4342
+
4343 4343
 				if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
4344 4344
 					utils.ErrorLog("count")
4345 4345
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -4347,7 +4347,7 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4347 4347
 				}
4348 4348
 
4349 4349
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
4350
-				fmt.Println("count22222222", count)
4350
+
4351 4351
 				adminUser := c.GetMobileAdminUserInfo()
4352 4352
 				prepare := &models.DialysisBeforePrepare{
4353 4353
 					UserOrgId:  adminUser.Org.Id,
@@ -4679,18 +4679,22 @@ func (c *DialysisAPIController) BathDeleteAdviceList() {
4679 4679
 
4680 4680
 	dataBody := make(map[string]interface{}, 0)
4681 4681
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
4682
-	idsInt := dataBody["ids"].([]interface{})
4683
-	ids := make([]int64, 0)
4684
-	for _, item := range idsInt {
4685
-		id, _ := strconv.ParseInt(item.(string), 10, 64)
4686
-		ids = append(ids, id)
4682
+	ids := c.GetString("ids")
4683
+	fmt.Println("dis22222222", ids)
4684
+	idArray := strings.Split(ids, ",")
4685
+	origin, _ := c.GetInt64("origin")
4686
+	if origin == 1 {
4687
+		err = service.BatchDeleteAdvice(idArray)
4688
+		fmt.Print("err", err)
4689
+		c.ServeSuccessJSON(map[string]interface{}{
4690
+			"msg": "批量删除成功",
4691
+		})
4692
+		return
4693
+	}
4694
+
4695
+	if origin == 2 {
4696
+		service.BatchDeleteHisAdvice(idArray)
4687 4697
 	}
4688
-	err = service.BatchDeleteAdvice(ids)
4689
-	fmt.Print("err", err)
4690
-	c.ServeSuccessJSON(map[string]interface{}{
4691
-		"msg": "批量删除成功",
4692
-	})
4693
-	return
4694 4698
 }
4695 4699
 
4696 4700
 func (c *DialysisAPIController) UpdateAutoReduceDetail() {
@@ -4718,3 +4722,61 @@ func (c *DialysisAPIController) DeleteAutoReduceDetail() {
4718 4722
 	})
4719 4723
 	return
4720 4724
 }
4725
+
4726
+func (c *DialysisAPIController) BatchAdviceCheck() {
4727
+
4728
+	ids := c.GetString("ids")
4729
+	fmt.Println("dis22222222", ids)
4730
+	idArray := strings.Split(ids, ",")
4731
+	creator, _ := c.GetInt64("creator")
4732
+	origin, _ := c.GetInt64("origin")
4733
+	if origin == 1 {
4734
+		err := service.BatchAdviceCheck(idArray, creator)
4735
+		fmt.Println(err)
4736
+		list, _ := service.GetAdviceExecutionById(idArray)
4737
+		c.ServeSuccessJSON(map[string]interface{}{
4738
+			"list": list,
4739
+		})
4740
+		return
4741
+	}
4742
+	if origin == 2 {
4743
+		service.BatchHisAdviceCheck(idArray, creator)
4744
+	}
4745
+
4746
+}
4747
+
4748
+func (c *DialysisAPIController) BatchAdviceExecution() {
4749
+
4750
+	ids := c.GetString("ids")
4751
+	fmt.Println("dis22222222", ids)
4752
+	idArray := strings.Split(ids, ",")
4753
+	executionTime := c.GetString("execution_time")
4754
+	fmt.Println("333333333", executionTime)
4755
+	creator, _ := c.GetInt64("creator")
4756
+	timeLayout := "2006-01-02 15:04:05"
4757
+	loc, _ := time.LoadLocation("Local")
4758
+
4759
+	theTime, _ := time.ParseInLocation(timeLayout, executionTime, loc)
4760
+
4761
+	orgin, _ := c.GetInt64("origin")
4762
+	if orgin == 1 {
4763
+		err := service.BatchAdviceExecution(idArray, creator, theTime.Unix())
4764
+		list, _ := service.GetAdviceExecutionById(idArray)
4765
+		fmt.Println(err)
4766
+		c.ServeSuccessJSON(map[string]interface{}{
4767
+			"list": list,
4768
+		})
4769
+		return
4770
+	}
4771
+
4772
+	if orgin == 2 {
4773
+		err := service.BatchAdviceExecution(idArray, creator, theTime.Unix())
4774
+		list, _ := service.GetHisAdviceExecutionById(idArray)
4775
+		fmt.Println(err)
4776
+		c.ServeSuccessJSON(map[string]interface{}{
4777
+			"list": list,
4778
+		})
4779
+		return
4780
+	}
4781
+
4782
+}

+ 8 - 1
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -140,7 +140,7 @@ func MobileAPIControllersRegisterRouters() {
140 140
 	beego.Router("/m/api/getmobileprintstockgood", &DialysisAPIController{}, "Get:GetMobilePrintStockGood")
141 141
 
142 142
 	//批量删除监测
143
-	beego.Router("/m/api/batchDeleteMonitor", &DialysisAPIController{}, "Get:BatchDeleteMonitor")
143
+	beego.Router("/m/api/batchdeletemonitor", &DialysisAPIController{}, "Get:BatchDeleteMonitor")
144 144
 	//获取单个患者1年的透析日期
145 145
 	beego.Router("/m/api/getPatientDialysisRecord", &DialysisAPIController{}, "Get:GetPatientDialysisRecordList")
146 146
 	//批量删除医嘱
@@ -149,4 +149,11 @@ func MobileAPIControllersRegisterRouters() {
149 149
 	beego.Router("/m/api/updateautoreducedetail", &DialysisAPIController{}, "Get:UpdateAutoReduceDetail")
150 150
 	//删除数据
151 151
 	beego.Router("/m/api/deleteautoreducedetail", &DialysisAPIController{}, "Get:DeleteAutoReduceDetail")
152
+
153
+	//医嘱批量核对
154
+	beego.Router("/m/api/batchadvicecheck", &DialysisAPIController{}, "Get:BatchAdviceCheck")
155
+
156
+	//医嘱批量执行
157
+	beego.Router("/m/api/batchadviceexecution", &DialysisAPIController{}, "Get:BatchAdviceExecution")
158
+
152 159
 }

+ 4 - 2
controllers/stock_api_controller.go View File

@@ -288,10 +288,12 @@ func (c *StockApiController) ModifyManufacturer() {
288 288
 		PinYin:           pinyin,
289 289
 	}
290 290
 
291
-	Manufacturer, _ := service.GetManufacturerName(adminUserInfo.CurrentOrgId, manufacturer_name)
291
+	_, errrcode := service.GetManufacturerName(adminUserInfo.CurrentOrgId, manufacturer_name)
292
+
293
+	if errrcode == nil {
292 294
 
293
-	if Manufacturer.ID > 0 && Manufacturer.ID != manufacturer.ID {
294 295
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIdCardNoExist)
296
+
295 297
 		return
296 298
 	}
297 299
 

+ 1 - 0
models/his_models.go View File

@@ -232,6 +232,7 @@ type HisDoctorAdviceInfo struct {
232 232
 	Day                   int64                  `gorm:"column:day" json:"day" form:"day"`
233 233
 	ChildDoctorAdvice     []*HisDoctorAdviceInfo `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"child"`
234 234
 	Drug                  Drug                   `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
235
+	Diagnosis             int64                  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
235 236
 }
236 237
 
237 238
 func (HisDoctorAdviceInfo) TableName() string {

+ 4 - 2
service/drug_stock_service.go View File

@@ -100,6 +100,7 @@ func FindAllDrugStockInfo(orgId int64, page int64, limit int64, keyword string,
100 100
 	}
101 101
 
102 102
 	if startTime > 0 {
103
+
103 104
 		db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
104 105
 			return db.Where("org_id = ? AND status = 1 and ctime >=?", orgId, startTime)
105 106
 		})
@@ -107,6 +108,7 @@ func FindAllDrugStockInfo(orgId int64, page int64, limit int64, keyword string,
107 108
 		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
108 109
 			return db.Where("org_id = ? AND status = 1 and sys_record_time>=?", orgId, startTime)
109 110
 		})
111
+
110 112
 		db = db.Preload("QueryCancelStockInfo", "org_id = ? AND status = 1 and ctime>=?", orgId, startTime)
111 113
 	} else {
112 114
 
@@ -122,11 +124,11 @@ func FindAllDrugStockInfo(orgId int64, page int64, limit int64, keyword string,
122 124
 
123 125
 	if endTime > 0 {
124 126
 		db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
125
-			return db.Where("org_id = ? AND status = 1 and ctime>=? and ctime <=?", orgId, startTime, endTime)
127
+			return db.Where("org_id = ? AND status = 1  and ctime <=?", orgId, startTime, endTime)
126 128
 		})
127 129
 		db = db.Preload("QuerySalesReturnInfo", "org_id = ? AND status = 1 and ctime>=? and ctime<=?", orgId, startTime, endTime)
128 130
 		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
129
-			return db.Where("org_id = ? AND status = 1 and sys_record_time<=?", orgId, endTime)
131
+			return db.Where("org_id = ? AND status = 1 and sys_record_time>=? and sys_record_time<=?", orgId, startTime, endTime)
130 132
 		})
131 133
 		db = db.Preload("QueryCancelStockInfo", "org_id = ? AND status = 1 and ctime >=? and ctime<=?", orgId, startTime, endTime)
132 134
 	} else {

+ 45 - 1
service/mobile_dialysis_service.go View File

@@ -291,6 +291,7 @@ type VMDoctorAdvice struct {
291 291
 	RecordDate     int64 `gorm:"column:record_date" json:"record_date"`
292 292
 	CheckTime      int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
293 293
 	CheckState     int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
294
+	ParentId       int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
294 295
 }
295 296
 
296 297
 func (VMDoctorAdvice) TableName() string {
@@ -1982,7 +1983,7 @@ func GetPatientDialysisRecordList(patientid int64, startime int64, endtime int64
1982 1983
 	return order, err
1983 1984
 }
1984 1985
 
1985
-func BatchDeleteAdvice(ids []int64) (err error) {
1986
+func BatchDeleteAdvice(ids []string) (err error) {
1986 1987
 
1987 1988
 	if len(ids) == 1 {
1988 1989
 		err = XTWriteDB().Model(&models.DoctorAdvice{}).Where("id=?", ids[0]).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
@@ -1994,6 +1995,17 @@ func BatchDeleteAdvice(ids []int64) (err error) {
1994 1995
 
1995 1996
 }
1996 1997
 
1998
+func BatchDeleteHisAdvice(ids []string) (err error) {
1999
+
2000
+	if len(ids) == 1 {
2001
+		err = XTWriteDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ?", ids[0]).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
2002
+	} else {
2003
+		err = XTWriteDB().Model(models.HisDoctorAdviceInfo{}).Where("id IN(?)", ids).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
2004
+	}
2005
+
2006
+	return
2007
+}
2008
+
1997 2009
 func UpdateAutoReduceDetail(good_id int64, count int64, record_time int64, patient_id int64) (models.AutomaticReduceDetail, error) {
1998 2010
 	detail := models.AutomaticReduceDetail{}
1999 2011
 	err := XTWriteDB().Model(&detail).Where("good_id = ? and status = 1 and record_time = ? and patient_id = ?", good_id, record_time, patient_id).Updates(map[string]interface{}{"count": count}).Error
@@ -2005,3 +2017,35 @@ func DeleteAutoReduceDetail(good_id int64, record_time int64, patient_id int64)
2005 2017
 	err := XTWriteDB().Model(&detail).Where("good_id = ? and status = 1 and record_time = ? and patient_id = ?", good_id, record_time, patient_id).Updates(map[string]interface{}{"status": 0}).Error
2006 2018
 	return err
2007 2019
 }
2020
+
2021
+func BatchAdviceCheck(ids []string, creator int64) error {
2022
+
2023
+	advice := models.XtDoctorAdvice{}
2024
+	err := XTWriteDB().Model(&advice).Where("id IN(?) and status = 1", ids).Updates(map[string]interface{}{"check_state": 1, "checker": creator, "check_time": time.Now().Unix()}).Error
2025
+	return err
2026
+}
2027
+
2028
+func BatchHisAdviceCheck(ids []string, creator int64) error {
2029
+	advice := models.HisDoctorAdviceInfo{}
2030
+	err := XTWriteDB().Model(&advice).Where("id IN(?) and status = 1", ids).Updates(map[string]interface{}{"check_state": 1, "checker": creator, "check_time": time.Now().Unix()}).Error
2031
+	return err
2032
+}
2033
+
2034
+func BatchAdviceExecution(ids []string, creator int64, execution_state int64) error {
2035
+
2036
+	advice := models.XtDoctorAdvice{}
2037
+	err := XTWriteDB().Model(&advice).Where("id IN(?) and status = 1", ids).Updates(map[string]interface{}{"execution_state": 1, "execution_staff": creator, "execution_time": execution_state}).Error
2038
+	return err
2039
+}
2040
+
2041
+func GetAdviceExecutionById(ids []string) (doctor []*models.XtDoctorAdvice, err error) {
2042
+
2043
+	err = XTReadDB().Model(&doctor).Where("id IN(?) AND status = 1", ids).Find(&doctor).Error
2044
+	return doctor, err
2045
+}
2046
+
2047
+func GetHisAdviceExecutionById(ids []string) (doctor []*models.HisDoctorAdviceInfo, err error) {
2048
+
2049
+	err = XTReadDB().Model(&doctor).Where("id IN(?) AND status = 1", ids).Find(&doctor).Error
2050
+	return doctor, err
2051
+}

+ 2 - 2
service/patient_service.go View File

@@ -1155,12 +1155,12 @@ func FindDoctorAdviceByIds(orgID int64, ids []string) (advice []models.DoctorAdv
1155 1155
 
1156 1156
 func BatchDeleteDoctorAdvice(ids []string, user_id int64) (err error) {
1157 1157
 	ut := writeDb.Begin()
1158
-	err = ut.Model(&models.DoctorAdvice{}).Where("status = 1   AND id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix(), "modifier": user_id}).Error
1158
+	err = ut.Model(&models.DoctorAdvice{}).Where("status = 1   AND id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix(), "modifier": user_id}).Error
1159 1159
 	if err != nil {
1160 1160
 		ut.Rollback()
1161 1161
 		return
1162 1162
 	}
1163
-	err = ut.Model(&models.DoctorAdvice{}).Where("status = 1   AND parent_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix(), "modifier": user_id}).Error
1163
+	err = ut.Model(&models.DoctorAdvice{}).Where("status = 1   AND parent_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix(), "modifier": user_id}).Error
1164 1164
 	if err != nil {
1165 1165
 		ut.Rollback()
1166 1166
 		return

+ 1 - 1
service/stock_service.go View File

@@ -1204,7 +1204,7 @@ func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, star
1204 1204
 	if endtime > 0 {
1205 1205
 
1206 1206
 		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1207
-			return db.Where("org_id = ? AND status = 1 and sys_record_time<=?", orgId, endtime)
1207
+			return db.Where("org_id = ? AND status = 1 and sys_record_time >=? and sys_record_time<=?", orgId, startime, endtime)
1208 1208
 		})
1209 1209
 	}
1210 1210