Browse Source

add:术式

zoie 1 year ago
parent
commit
de36bb0c42

+ 1 - 1
Nats/NatsServer/NatsQiniu.go

@@ -58,6 +58,6 @@ func Qiniu_UploadFile(localFile string, name string) (string, bool) {
 		return "", false
 	}
 	fmt.Println(ret.Bucket, ret.Key, ret.Fsize, ret.Hash, ret.Name)
-	return Qiniu_Url + name, true
+	return Qiniu_Url + "/" + name, true
 
 }

+ 17 - 6
controllers/Patient.go

@@ -7,6 +7,7 @@ import (
 	"FollowUp_Notice/models/Account"
 	"FollowUp_Notice/models/Illness"
 	"FollowUp_Notice/models/Patient"
+	"FollowUp_Notice/models/Surgical"
 	"FollowUp_Notice/models/System"
 	"FollowUp_Notice/models/Tag"
 	"encoding/json"
@@ -47,8 +48,10 @@ func (c *PatientController) Patient_List() {
 	T_name := c.GetString("T_name")
 	// 标签
 	T_tag, _ := c.GetInt("T_tag")
-	// 疾病
+	// 诊断
 	T_illness, _ := c.GetInt("T_illness")
+	// 术式
+	T_surgical, _ := c.GetInt("T_surgical")
 	// 通知状态 1待通知 2已通知
 	T_notice, _ := c.GetInt("T_notice")
 	// 复诊状态 1正常 2超时
@@ -59,7 +62,8 @@ func (c *PatientController) Patient_List() {
 	T_next_time_sort, _ := c.GetInt("T_next_time_sort")
 	Tag.Read_Tag_All_Map()
 	Illness.Read_Illness_All_Map()
-	R_List, R_cnt := Patient.Read_Patient_List(c.User.Id, T_number, T_name, T_tag, T_illness, T_notice, T_follow_up, T_age_sort, T_next_time_sort, page, page_z)
+	Surgical.Read_Surgical_All_Map()
+	R_List, R_cnt := Patient.Read_Patient_List(c.User.Id, T_number, T_name, T_tag, T_illness, T_surgical, T_notice, T_follow_up, T_age_sort, T_next_time_sort, page, page_z)
 
 	var r_jsons lib.R_JSONS
 	r_jsons.Num = R_cnt
@@ -80,6 +84,7 @@ func (c *PatientController) Patient_Add() {
 	T_age, _ := c.GetInt("T_age")
 	T_tag := c.GetString("T_tag")
 	T_illness, _ := c.GetInt("T_illness")
+	T_surgical, _ := c.GetInt("T_surgical")
 	T_phone := c.GetString("T_phone")
 	T_notice_phone, _ := c.GetInt("T_notice_phone")
 	T_notice_message, _ := c.GetInt("T_notice_message")
@@ -93,6 +98,7 @@ func (c *PatientController) Patient_Add() {
 		T_age:             T_age,
 		T_tag:             T_tag,
 		T_illness:         T_illness,
+		T_surgical:        T_surgical,
 		T_phone:           T_phone,
 		T_notice_phone:    T_notice_phone,
 		T_notice_message:  T_notice_message,
@@ -299,7 +305,12 @@ func (c *PatientController) VoiceCall_Status() {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "json.Unmarshal is err:" + err.Error()}
 		c.ServeJSON()
 	}
-	if body.EventType == "disconnect" {
+	if body.EventType == "answer" {
+		c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+		c.ServeJSON()
+		return
+	}
+	if body.EventType == "disconnect" && body.StatusInfo.StateCode != "0" {
 		r, err := Patient.Read_PatientSend_ByT_id(body.StatusInfo.SessionId)
 		if err != nil {
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "SessionId Err!"}
@@ -327,7 +338,7 @@ func Cron_Patient() {
 	//创建一个定时任务对象
 	c := cron.New(cron.WithSeconds())
 	//给对象增加定时任务
-	//c.AddFunc("0 */1 * * * ?", Cron_Patient_Notice)
+	//c.AddFunc("0 */1 * * * ?", Cron_Patient_ChangeFollowUp)
 	c.AddFunc("@daily", Cron_Patient_ChangeFollowUp) // 修改复诊状态
 	c.AddFunc("0 0 8 * * *", Cron_Patient_Notice)    // 消息通知
 
@@ -348,7 +359,7 @@ func Cron_Patient_ChangeFollowUp() {
 	logs.Info("开始处理" + T_date + "患者通知状态")
 	// T_notice 通知状态 1待通知 2已通知
 	// T_follow_up 复诊状态 1正常 2超时
-	list, _ := Patient.Read_Patient_List(0, "", "", 0, 0, 2, 1, 0, 0, 0, 9999)
+	list, _ := Patient.Read_Patient_List(0, "", "", 0, 0, 0, 2, 1, 0, 0, 0, 9999)
 	for _, v := range list {
 		nextTime, _ := lib.DateStrToTime(v.T_next_time)
 		if nextTime.Before(time.Now()) {
@@ -378,7 +389,7 @@ func Cron_Patient_Notice() {
 		if (user.T_money <= 0 && user.T_arrears_notice == 2) || user.T_State == 2 {
 			continue
 		}
-		patientList, _ := Patient.Read_Patient_List(user.Id, "", "", 0, 0, 0, 1, 0, 0, 0, 9999)
+		patientList, _ := Patient.Read_Patient_List(user.Id, "", "", 0, 0, 0, 0, 1, 0, 0, 0, 9999)
 		for _, v := range patientList {
 			nextTime, _ := lib.DateStrToTime(v.T_next_time)
 			var success bool

+ 126 - 0
controllers/Surgical.go

@@ -0,0 +1,126 @@
+package controllers
+
+import (
+	"FollowUp_Notice/conf"
+	"FollowUp_Notice/models/Account"
+	"FollowUp_Notice/models/Surgical"
+	"FollowUp_Notice/models/System"
+	"git.baozhida.cn/ERP_libs/lib"
+	beego "github.com/beego/beego/v2/server/web"
+	"math"
+	"strconv"
+)
+
+type SurgicalController struct {
+	beego.Controller
+	User Account.User
+}
+
+func (c *SurgicalController) Prepare() {
+	c.User = *Account.User_r
+}
+
+// 疾病
+func (c *SurgicalController) Surgical_List() {
+
+	// 分页参数 初始化
+	page, _ := c.GetInt("page")
+	if page < 1 {
+		page = 1
+	}
+	page_z, _ := c.GetInt("page_z")
+	if page_z < 1 {
+		page_z = conf.Page_size
+	}
+
+	// 查询
+	T_name := c.GetString("T_name")
+
+	R_List, R_cnt := Surgical.Read_Surgical_List(c.User.Id, T_name, page, page_z)
+
+	var r_jsons lib.R_JSONS
+	r_jsons.Num = R_cnt
+	r_jsons.Data = R_List
+	r_jsons.Page = page
+	r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
+	c.ServeJSON()
+	return
+}
+func (c *SurgicalController) Surgical_Add() {
+
+	T_name := c.GetString("T_name")
+	T_sort, _ := c.GetInt("T_sort")
+
+	var_ := Surgical.Surgical{
+		T_name:  T_name,
+		T_sort:  T_sort,
+		T_State: 1,
+		T_uid:   c.User.Id,
+	}
+
+	Id, err := Surgical.Add_Surgical(var_)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
+		c.ServeJSON()
+		return
+	}
+
+	System.Add_UserLogs_T(c.User.T_uuid, "术式", "添加", var_)
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
+	c.ServeJSON()
+	return
+}
+func (c *SurgicalController) Surgical_Edit() {
+	T_id, _ := c.GetInt("T_id")
+	T_name := c.GetString("T_name")
+	T_sort, _ := c.GetInt("T_sort")
+
+	Surgical_r, err := Surgical.Read_Surgical_ById(T_id)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	if len(T_name) > 0 {
+		Surgical_r.T_name = T_name
+	}
+	Surgical_r.T_sort = T_sort
+
+	if err = Surgical.Update_Surgical(Surgical_r, "T_name", "T_sort"); err != nil {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
+		c.ServeJSON()
+		return
+	}
+
+	System.Add_UserLogs_T(c.User.T_uuid, "术式", "修改", Surgical_r)
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+}
+func (c *SurgicalController) Surgical_Del() {
+
+	T_id, _ := c.GetInt("T_id")
+	Surgical_r, err := Surgical.Read_Surgical_ById(T_id)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	if err = Surgical.Delete_Surgical(Surgical_r); err != nil {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
+		c.ServeJSON()
+		return
+	}
+
+	System.Add_UserLogs(c.User.T_uuid, "术式", "删除", strconv.Itoa(T_id))
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+}

+ 1 - 1
models/Illness/Illness.go

@@ -158,6 +158,6 @@ func Read_Illness_Get(Id int) string {
 	if ok {
 		return v.(string)
 	} else {
-		return "未知分类"
+		return ""
 	}
 }

+ 11 - 2
models/Patient/Patient.go

@@ -2,6 +2,7 @@ package Patient
 
 import (
 	"FollowUp_Notice/models/Illness"
+	"FollowUp_Notice/models/Surgical"
 	"FollowUp_Notice/models/Tag"
 	"fmt"
 	"git.baozhida.cn/ERP_libs/lib"
@@ -20,7 +21,8 @@ type Patient struct {
 	T_name            string    `orm:"size(256);null"`                                        // 姓名
 	T_age             int       `orm:"size(200);null"`                                        // 年轻
 	T_tag             string    `orm:"size(200);null"`                                        // 标签
-	T_illness         int       `orm:"size(200);null"`                                        // 疾病
+	T_illness         int       `orm:"size(200);null"`                                        // 诊断
+	T_surgical        int       `orm:"size(200);null"`                                        // 术式
 	T_phone           string    `orm:"size(256);null"`                                        // 电话号码
 	T_next_time       string    `orm:"size(200);null"`                                        // 下次复诊时间
 	T_notice_phone    int       `orm:"size(200);null"`                                        // 手机 1通知 0不通知
@@ -44,6 +46,8 @@ type Patient_R struct {
 	T_tag_List        []string // 标签
 	T_illness         int      // 疾病
 	T_illness_name    string   // 疾病名称
+	T_surgical        int      // 术式
+	T_surgical_name   string   // 术式名称
 	T_phone           string   // 电话号码
 	T_next_time       string   // 下次复诊时间
 	T_next_interval   int      // 下次复诊间隔天数
@@ -78,6 +82,8 @@ func PatientToPatient_R(r Patient) (m Patient_R) {
 	}
 	m.T_illness = r.T_illness
 	m.T_illness_name = Illness.Read_Illness_Get(r.T_illness)
+	m.T_surgical = r.T_surgical
+	m.T_surgical_name = Surgical.Read_Surgical_Get(r.T_surgical)
 	m.T_phone = r.T_phone
 	m.T_next_time = r.T_next_time
 	m.T_notice_phone = r.T_notice_phone
@@ -148,7 +154,7 @@ func Delete_Patient(v Patient) error {
 }
 
 // 获取列表
-func Read_Patient_List(T_uid int, T_number, T_name string, T_tag, T_illness, T_notice, T_follow_up, T_age_sort, T_next_time_sort, page, page_z int) (r_ []Patient_R, cnt int64) {
+func Read_Patient_List(T_uid int, T_number, T_name string, T_tag, T_illness, T_surgical, T_notice, T_follow_up, T_age_sort, T_next_time_sort, page, page_z int) (r_ []Patient_R, cnt int64) {
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
 	qs := o.QueryTable(new(Patient))
@@ -177,6 +183,9 @@ func Read_Patient_List(T_uid int, T_number, T_name string, T_tag, T_illness, T_n
 	if T_illness > 0 {
 		cond = cond.And("T_illness", T_illness)
 	}
+	if T_surgical > 0 {
+		cond = cond.And("T_surgical", T_surgical)
+	}
 	if T_notice > 0 {
 		cond = cond.And("T_notice", T_notice)
 	}

+ 164 - 0
models/Surgical/Surgical.go

@@ -0,0 +1,164 @@
+package Surgical
+
+import (
+	"git.baozhida.cn/ERP_libs/lib"
+	orm2 "github.com/beego/beego/v2/client/orm"
+	"sync"
+	"time"
+
+	"FollowUp_Notice/logs"
+	_ "github.com/astaxie/beego/cache/redis"
+	"github.com/beego/beego/v2/adapter/orm"
+	_ "github.com/go-sql-driver/mysql"
+)
+
+// 仓库
+type Surgical struct {
+	Id         int       `orm:"column(ID);size(11);auto;pk"`
+	T_uid      int       `orm:"size(200);default(1)"`                                  // 关联的用户id
+	T_name     string    `orm:"size(256);null"`                                        // 名称
+	T_State    int       `orm:"size(2);default(1)"`                                    // 0 删除(伪删除)   1 正常
+	T_sort     int       `orm:"size(20);default(0)"`                                   // 排序
+	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
+	UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"`     //auto_now 每次 model 保存时都会对时间自动更新
+}
+
+func (t *Surgical) TableName() string {
+	return "surgical"
+}
+
+var Surgical_list *sync.Map
+
+func init() {
+	//注册模型
+	orm.RegisterModel(new(Surgical))
+	Surgical_list = new(sync.Map)
+}
+
+type Surgical_R struct {
+	Id     int
+	T_name string // 名称
+	T_sort int
+}
+
+func SurgicalToSurgical_R(t Surgical) (r Surgical_R) {
+	r.Id = t.Id
+	r.T_name = t.T_name
+	r.T_sort = t.T_sort
+	return r
+}
+
+// 添加
+func Add_Surgical(r Surgical) (id int64, err error) {
+	o := orm.NewOrm()
+	id, err = o.Insert(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
+	return id, err
+}
+
+// 获取 ById
+func Read_Surgical_ById(Id int) (r Surgical, err error) {
+	o := orm.NewOrm()
+	qs := o.QueryTable(new(Surgical))
+	err = qs.Filter("Id", Id).One(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
+	return
+}
+
+// 修改
+func Update_Surgical(m Surgical, cols ...string) error {
+	o := orm.NewOrm()
+	_, err := o.Update(&m, cols...)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return err
+	}
+	return nil
+}
+
+// 删除
+func Delete_Surgical(v Surgical) error {
+	o := orm.NewOrm()
+	v.T_State = 0
+	_, err := o.Update(&v, "T_State")
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
+	return err
+}
+
+// 获取列表
+func Read_Surgical_List(uid int, T_name string, page, page_z int) (r_ []Surgical_R, cnt int64) {
+	o := orm.NewOrm()
+	// 也可以直接使用 Model 结构体作为表名
+	qs := o.QueryTable(new(Surgical))
+	var offset int64
+	if page <= 1 {
+		offset = 0
+	} else {
+		offset = int64((page - 1) * page_z)
+	}
+
+	// 过滤
+	cond := orm.NewCondition()
+	cond = cond.And("T_State", 1).And("T_uid", uid)
+
+	if len(T_name) > 0 {
+		cond = cond.And("T_name__icontains", T_name)
+	}
+
+	// 查询
+	var r []Surgical
+	var err error
+	if page_z == 9999 {
+		_, err = qs.SetCond((*orm2.Condition)(cond)).OrderBy("T_sort").All(&r)
+	} else {
+		_, err = qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond)).OrderBy("T_sort").All(&r)
+	}
+
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return
+	}
+
+	cnt, err = qs.SetCond((*orm2.Condition)(cond)).Count()
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return
+	}
+
+	for _, v := range r {
+		r_ = append(r_, SurgicalToSurgical_R(v))
+	}
+
+	return r_, cnt
+}
+
+// 获取疾病
+func Read_Surgical_All_Map() {
+	o := orm.NewOrm()
+	var r []Surgical
+	qs := o.QueryTable(new(Surgical))
+	_, err := qs.All(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
+
+	for _, v := range r {
+		Surgical_list.Store(v.Id, v.T_name)
+	}
+
+}
+func Read_Surgical_Get(Id int) string {
+	// 有先加入 给全部人发消息
+	v, ok := Surgical_list.Load(Id) /*如果确定是真实的,则存在,否则不存在 */
+	if ok {
+		return v.(string)
+	} else {
+		return ""
+	}
+}

+ 1 - 1
models/Tag/Tag.go

@@ -158,6 +158,6 @@ func Read_Tag_Get(Id int) string {
 	if ok {
 		return v.(string)
 	} else {
-		return "未知标签"
+		return ""
 	}
 }

+ 18 - 0
routers/Surgical.go

@@ -0,0 +1,18 @@
+package routers
+
+import (
+	"FollowUp_Notice/controllers"
+	beego "github.com/beego/beego/v2/server/web"
+)
+
+func init() {
+
+	illness := beego.NewNamespace("/Surgical",
+		beego.NSRouter("/List", &controllers.SurgicalController{}, "*:Surgical_List"), // 标签列表
+		beego.NSRouter("/Add", &controllers.SurgicalController{}, "*:Surgical_Add"),   // 获取标签
+		beego.NSRouter("/Edit", &controllers.SurgicalController{}, "*:Surgical_Edit"), // 添加标签
+		beego.NSRouter("/Del", &controllers.SurgicalController{}, "*:Surgical_Del"),   // 删除标签
+	)
+
+	beego.AddNamespace(illness)
+}