zoie 1 жил өмнө
parent
commit
aec8ae0bff

+ 22 - 19
controllers/Patient.go

@@ -151,6 +151,7 @@ func (c *PatientController) Patient_Edit() {
 	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")
@@ -184,17 +185,19 @@ func (c *PatientController) Patient_Edit() {
 		patient.T_age = T_age
 		cols = append(cols, "T_age")
 	}
-	if len(T_tag) > 0 {
-		patient.T_tag = T_tag
-		cols = append(cols, "T_tag")
-	}
-	if T_illness > 0 {
-		patient.T_illness = T_illness
-		cols = append(cols, "T_illness")
-	}
+
+	patient.T_tag = T_tag
+	cols = append(cols, "T_tag")
+
+	patient.T_illness = T_illness
+	cols = append(cols, "T_illness")
+
+	patient.T_surgical = T_surgical
+	cols = append(cols, "T_surgical")
+
 	if len(T_phone) > 0 {
 		patient.T_phone = T_phone
-		cols = append(cols, "T_name")
+		cols = append(cols, "T_phone")
 	}
 	patient.T_notice_phone = T_notice_phone
 	cols = append(cols, "T_notice_phone")
@@ -293,7 +296,7 @@ func (c *PatientController) VoiceCall_Status() {
 			Timestamp string `json:"timestamp"`
 			Caller    string `json:"caller"`
 			Called    string `json:"called"`
-			StateCode string `json:"stateCode"`
+			StateCode int    `json:"stateCode"`
 			StateDesc string `json:"stateDesc"`
 		} `json:"statusInfo"`
 	}
@@ -305,21 +308,20 @@ func (c *PatientController) VoiceCall_Status() {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "json.Unmarshal is err:" + err.Error()}
 		c.ServeJSON()
 	}
-	if body.EventType == "answer" {
-		c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
-		c.ServeJSON()
-		return
-	}
-	if body.EventType == "disconnect" && body.StatusInfo.StateCode != "0" {
+
+	if body.EventType == "disconnect" {
 		r, err := Patient.Read_PatientSend_ByT_id(body.StatusInfo.SessionId)
 		if err != nil {
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "SessionId Err!"}
 			c.ServeJSON()
 			return
 		}
-		r.T_State = 0
+		if body.StatusInfo.StateCode == 0 {
+			r.T_State = 1
+		}
+		r.T_code = body.StatusInfo.StateCode
 		r.T_remark = body.StatusInfo.StateDesc
-		err = Patient.Update_PatientSend(r, "T_State", "T_remark")
+		err = Patient.Update_PatientSend(r, "T_State", "T_remark", "T_code")
 		if err != nil {
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改发送状态失败!"}
 			c.ServeJSON()
@@ -438,6 +440,7 @@ func Send_Notice(nextTime time.Time, user Account.User_R, patient Patient.Patien
 			T_type:   1,
 			T_id:     res.Send_id,
 			T_remark: res.Status,
+			T_code:   res.Fee,
 			T_State:  1,
 		}
 		if res.Status == "error" {
@@ -466,7 +469,7 @@ func Send_Notice(nextTime time.Time, user Account.User_R, patient Patient.Patien
 			T_type:   2,
 			T_id:     res.SessionId,
 			T_remark: res.Resultdesc,
-			T_State:  1,
+			T_State:  0,
 		}
 		if res.Resultcode != "0" {
 			smsSend.T_State = 0

+ 9 - 1
controllers/Tag.go

@@ -3,12 +3,15 @@ package controllers
 import (
 	"FollowUp_Notice/conf"
 	"FollowUp_Notice/models/Account"
+	"FollowUp_Notice/models/Patient"
 	"FollowUp_Notice/models/System"
 	"FollowUp_Notice/models/Tag"
+	"fmt"
 	"git.baozhida.cn/ERP_libs/lib"
 	beego "github.com/beego/beego/v2/server/web"
 	"math"
 	"strconv"
+	"strings"
 )
 
 type TagController struct {
@@ -117,7 +120,12 @@ func (c *TagController) Tag_Del() {
 		c.ServeJSON()
 		return
 	}
-
+	PatientList, _ := Patient.Read_Patient_List(0, "", "", T_id, 0, 0, 0, 0, 0, 0, 0, 9999)
+	for _, r := range PatientList {
+		T_tag := strings.Replace(r.T_tag_str, fmt.Sprintf("|%d|", T_id), "", -1)
+		var_ := Patient.Patient{Id: r.Id, T_tag: T_tag}
+		Patient.Update_Patient(var_, "T_tag")
+	}
 	System.Add_UserLogs(c.User.T_uuid, "标签", "删除", strconv.Itoa(T_id))
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}

+ 85 - 0
controllers/User.go

@@ -697,6 +697,91 @@ func (c *UserController) Send_Excel() {
 
 }
 
+// 通知记录
+func (c *UserController) Send_Test() {
+	// 1 短信 2 电话
+	T_type, _ := c.GetInt("T_type")
+	T_phone := c.GetString("T_phone")
+	if c.User.Id != 1 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
+		c.ServeJSON()
+		return
+	}
+	//发送短信通知
+	if T_type == 1 {
+		res, err := http.SmsXSend("mDZSZ3", T_phone, "张三", time.Now().AddDate(0, 0, 1).Format("2006年01月02日"))
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 200, Msg: "短信发送失败!"}
+			c.ServeJSON()
+			return
+		}
+
+		// 保存短信发送记录
+		smsSend := Patient.PatientSend{
+			T_uid:    c.User.Id,
+			T_pid:    0,
+			T_phone:  T_phone,
+			T_type:   1,
+			T_id:     res.Send_id,
+			T_remark: res.Status,
+			T_code:   res.Fee,
+			T_State:  1,
+		}
+		if res.Status == "error" {
+			smsSend.T_State = 0
+		}
+		_, err = Patient.Add_PatientSend(smsSend)
+		if err != nil {
+			System.Add_SysLogs_T("复诊通知", "添加发送记录失败", smsSend)
+		}
+
+		if res.Status == "error" {
+			c.Data["json"] = lib.JSONS{Code: 200, Msg: "短信发送失败!"}
+			c.ServeJSON()
+			return
+		}
+
+	}
+
+	if T_type == 2 {
+		playInfoList := http.GetPlayInfoList(conf.VoiceCall_Template, []string{"某某医院消化内科", "张三", time.Now().AddDate(0, 0, 1).Format("2006/01/02")})
+		res, err := http.VoiceNotifyAPI(conf.VoiceCall_Phone, "+86"+T_phone, playInfoList)
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "电话通知失败!"}
+			c.ServeJSON()
+			return
+		}
+
+		// 保存短信发送记录
+		send := Patient.PatientSend{
+			T_uid:   c.User.Id,
+			T_pid:   0,
+			T_phone: T_phone,
+			T_type:  2,
+			T_id:    res.SessionId,
+			T_code:  -1,
+			T_State: 0,
+		}
+
+		_, err = Patient.Add_PatientSend(send)
+		if err != nil {
+			System.Add_SysLogs_T("复诊通知", "添加发送记录失败", send)
+		}
+
+		if res.Resultcode != "0" {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "电话通知失败!"}
+			c.ServeJSON()
+			return
+		}
+
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+
+}
+
 // 用户定时任务
 func Cron_User() {
 

+ 12 - 4
models/Patient/Patient.go

@@ -9,6 +9,8 @@ import (
 	"github.com/astaxie/beego/logs"
 	"github.com/beego/beego/v2/adapter/orm"
 	orm2 "github.com/beego/beego/v2/client/orm"
+	"strconv"
+	"strings"
 	"time"
 )
 
@@ -42,6 +44,7 @@ type Patient_R struct {
 	T_number          string   // 病历号
 	T_name            string   // 姓名
 	T_age             int      // 年轻
+	T_tag_str         string   // 标签
 	T_tag             []int    // 标签
 	T_tag_List        []string // 标签
 	T_illness         int      // 疾病
@@ -76,9 +79,14 @@ func PatientToPatient_R(r Patient) (m Patient_R) {
 	m.T_number = r.T_number
 	m.T_name = r.T_name
 	m.T_age = r.T_age
-	m.T_tag = lib.SplitStringToIntIds(r.T_tag, "T")
-	for _, v := range m.T_tag {
-		m.T_tag_List = append(m.T_tag_List, Tag.Read_Tag_Get(v))
+	m.T_tag_str = r.T_tag
+	if len(r.T_tag) > 0 {
+		T_tag := strings.Split(strings.Trim(r.T_tag, "|"), "|")
+		for _, v := range T_tag {
+			t, _ := strconv.Atoi(v)
+			m.T_tag = append(m.T_tag, t)
+			m.T_tag_List = append(m.T_tag_List, Tag.Read_Tag_Get(t))
+		}
 	}
 	m.T_illness = r.T_illness
 	m.T_illness_name = Illness.Read_Illness_Get(r.T_illness)
@@ -178,7 +186,7 @@ func Read_Patient_List(T_uid int, T_number, T_name string, T_tag, T_illness, T_s
 		cond = cond.And("T_name__icontains", T_name)
 	}
 	if T_tag > 0 {
-		cond = cond.And("T_tag__icontains", fmt.Sprintf("T%d|", T_tag))
+		cond = cond.And("T_tag__icontains", fmt.Sprintf("|%d|", T_tag))
 	}
 	if T_illness > 0 {
 		cond = cond.And("T_illness", T_illness)

+ 3 - 0
models/Patient/PatientSend.go

@@ -17,6 +17,7 @@ type PatientSend struct {
 	T_phone    string    `orm:"size(256);null"`                                        // 患者电话 18888888888
 	T_type     int       `orm:"index;size(4);null"`                                    // 1 短信 2 电话
 	T_id       string    `orm:"size(256);null"`                                        // 发送id
+	T_code     int       `orm:"size(256);null"`                                        // 错误码
 	T_remark   string    `orm:"size(256);null"`                                        // 备注
 	T_State    int       `orm:"size(200);default(1)"`                                  // 0失败 1正常
 	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
@@ -27,6 +28,7 @@ type PatientSend_R struct {
 	T_phone    string // 18888888888
 	T_type     int    // 1 短信   2 电话
 	T_id       string
+	T_code     int
 	T_remark   string // 备注
 	T_State    int
 	CreateTime string //auto_now_add 第一次保存时才设置时间
@@ -47,6 +49,7 @@ func PatientSendToPatientSend_R(r PatientSend) (m PatientSend_R) {
 	m.T_phone = r.T_phone
 	m.T_type = r.T_type
 	m.T_id = r.T_id
+	m.T_code = r.T_code
 	m.T_remark = r.T_remark
 	m.T_State = r.T_State
 	m.CreateTime = r.CreateTime.Format("2006-01-02 15:04:05")

+ 1 - 0
routers/Account.go

@@ -19,4 +19,5 @@ func init() {
 	beego.Router("/User/Info", &controllers.UserController{}, "*:Info")             // 个人信息
 	beego.Router("/User/Send", &controllers.UserController{}, "*:Send")             // 通知
 	beego.Router("/User/Send_Excel", &controllers.UserController{}, "*:Send_Excel") // 通知下载
+	beego.Router("/User/Send_Test", &controllers.UserController{}, "*:Send_Test")   // 测试通知
 }