Jianghan há 1 ano atrás
pai
commit
d70d1dd1e4

+ 0 - 2
src/filter/sessfilter.go

@@ -3,7 +3,6 @@ package filter
 import (
 	"github.com/go-xweb/xweb"
 	"net/http"
-	qu "qfw/util"
 	"regexp"
 )
 
@@ -33,7 +32,6 @@ func (s *sessfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 		}
 		break
 	}
-	qu.Debug("1")
 	if !b {
 		s.App.Redirect(w, requestPath, "/")
 	}

+ 4 - 2
src/service/app.go

@@ -56,8 +56,9 @@ func (app *App) AppCreate() {
 			leader := qu.ObjToString(pg["leader"])
 			mail := qu.ObjToString(pg["mail"])
 			timing := qu.ObjToString(pg["timing"])
+			stype := qu.IntAll(pg["stype"])
 
-			save := bson.M{"name": name, "ip": ip_port[0], "port": qu.IntAll(ip_port[1]), "leader": leader, "mail": mail, "timing": timing}
+			save := bson.M{"name": name, "ip": ip_port[0], "port": qu.IntAll(ip_port[1]), "leader": leader, "mail": mail, "timing": timing, "stype": stype}
 			save["del"] = false
 			save["updatetime"] = now
 			save["status"] = 1
@@ -85,8 +86,9 @@ func (app *App) AppEdit() {
 			mail := qu.ObjToString(pg["mail"])
 			timing := qu.ObjToString(pg["timing"])
 			status := qu.IntAll(pg["status"])
+			stype := qu.IntAll(pg["stype"])
 
-			save := bson.M{"name": name, "ip": ip_port[0], "port": qu.IntAll(ip_port[1]), "leader": leader, "mail": mail, "timing": timing}
+			save := bson.M{"name": name, "ip": ip_port[0], "port": qu.IntAll(ip_port[1]), "leader": leader, "mail": mail, "timing": timing, "stype": stype}
 			save["updatetime"] = now
 			save["status"] = status
 			util.Mgo.UpdateById("app_list", id, bson.M{"$set": save})

+ 10 - 0
src/service/repair_service.go

@@ -257,6 +257,14 @@ func (jy *RepairRule) RepairPub() {
 			v = strings.Replace(qu.ObjToString(v), "&#60;", "<", -1)
 			v = strings.Replace(qu.ObjToString(v), "&#62;", ">", -1)
 			save[k] = v
+		} else if k == "budget" || k == "bidamount" {
+			save[k] = qu.Float64All(v)
+		} else if k == "winner" {
+			save["s_winner"] = qu.ObjToString(v)
+			cid := companyFun(save)
+			if len(cid) > 0 {
+				save["entidlist"] = cid
+			}
 		} else {
 			save[k] = v
 		}
@@ -460,6 +468,8 @@ func (jy *RepairRule) RepairDelete() {
 		JyEs.DelById(EsIndex, id)
 		JyEs1.DelById(EsIndex, id)
 		JyEs1.DelById("bidding_temp", id)
+		JyEs1.DelById("bidding_year", id)
+		JyEs1.DelById("bidding_free", id)
 		//  fmt.Sprintf("jypcdetail_%s_%s_%s_%v_%v_%v_%s", userId, stype, sid, isVip, isEntniche, isMember, nodeStr)
 		//删除redis 指定key
 		delName1 := RedisDelKey1 + "*_" + "*_" + id

+ 35 - 2
src/util/timetask.go

@@ -28,12 +28,18 @@ func Task() {
 		port := qu.IntAll(m["port"])
 		mail := qu.ObjToString(m["mail"])
 		timing := qu.ObjToString(m["timing"])
+		stype := qu.IntAll(m["stype"])
 
 		now := time.Now().Unix()
 		t := TimeDis(timing)
 		if t > 0 && (now-qu.Int64All(m["checktime"]) >= t) {
-			udpNode(ip, name, mail, port, now)
-			Mgo.UpdateById("app_list", m["_id"], bson.M{"$set": bson.M{"checktime": now}})
+			if stype == 1 {
+				udpNode(ip, name, mail, port, now)
+				Mgo.UpdateById("app_list", m["_id"], bson.M{"$set": bson.M{"checktime": now}})
+			} else {
+				tcpWork(name, fmt.Sprintf("%s:%d", ip, port), mail, time.Now().Unix())
+				Mgo.UpdateById("app_list", m["_id"], bson.M{"$set": bson.M{"checktime": now}})
+			}
 		}
 	}
 }
@@ -105,3 +111,30 @@ func MailWork() {
 		time.Sleep(60 * time.Second)
 	}
 }
+
+func tcpWork(name, address, to string, timestamp int64) {
+	jkmail, _ := Sysconfig["jkmail"].(map[string]interface{})
+	netry := 0
+	for {
+		conn, err := net.DialTimeout("tcp", address, 5*time.Second)
+		if err != nil {
+			netry++
+			if netry == 3 {
+				t := fmt.Sprintf("剑鱼维护平台异常监控通知--%s", name)
+				b := fmt.Sprintf("服务:%s,ip-port:%s,监控通信未成功,检测异常时间%s,请负责人检查服务并处理。",
+					name, address, qu.FormatDateByInt64(&timestamp, qu.Date_Time_Layout))
+				res, err1 := http.Get(fmt.Sprintf("%s?to=%s&title=%s&body=%s", qu.ObjToString(jkmail["api"]), to, t, b))
+				if err1 == nil {
+					defer res.Body.Close()
+					read, _ := io.ReadAll(res.Body)
+					qu.Debug("send mail ...", name, to, string(read))
+				}
+				break
+			}
+		} else {
+			_ = conn.Close()
+			break
+		}
+	}
+
+}

+ 29 - 1
src/web/templates/app/app_list.html

@@ -28,6 +28,7 @@
                                 <th>编号</th>
                                 <th>应用名称</th>
                                 <th>地址&端口</th>
+                                <th>类型</th>
                                 <th>定时时间</th>
                                 <th>负责人</th>
                                 <th>邮箱</th>
@@ -72,6 +73,15 @@
                                         <input type="text" class="form-control" id="ip-port" placeholder="服务器&端口" required>
                                     </div>
                                 </div>
+                                <div class="form-group margin-bottom">
+                                    <label class="col-sm-3 control-label"><span style="color:red;">* </span>服务类型</label>
+                                    <div class="col-sm-8">
+                                        <select class="form-control selectpicker" id="stype">
+                                            <option value = 1 selected>程序</option>
+                                            <option value = 2 >中间件</option>
+                                        </select>
+                                    </div>
+                                </div>
                                 <div class="form-group margin-bottom">
                                     <label class="col-sm-3 control-label"><span style="color:red;">* </span>定时时间</label>
                                     <div class="col-sm-8">
@@ -145,6 +155,15 @@
                                         <input type="text" class="form-control" id="edit-ip-port" placeholder="服务器&端口" required>
                                     </div>
                                 </div>
+                                <div class="form-group margin-bottom">
+                                    <label class="col-sm-3 control-label"><span style="color:red;">* </span>服务类型</label>
+                                    <div class="col-sm-8">
+                                        <select class="form-control selectpicker" id="edit-stype">
+                                            <option value = 1 selected>程序</option>
+                                            <option value = 2 >中间件</option>
+                                        </select>
+                                    </div>
+                                </div>
                                 <div class="form-group margin-bottom">
                                     <label class="col-sm-3 control-label"><span style="color:red;">* </span>定时时间</label>
                                     <div class="col-sm-8">
@@ -238,6 +257,13 @@
                         str = row["ip"] + ":" + row["port"]
                         return str
                     }, width: "10%",},
+                {"data": "stype", width: "4%", render: function (val) {
+                        if (val === 1) {
+                            return "程序"
+                        } else {
+                            return "中间件"
+                        }
+                    }},
                 {"data": "timing", width: "10%"},
                 {"data": "leader", width: "10%"},
                 {"data": "mail", width: "20%"},
@@ -270,6 +296,7 @@
         const leader = $("#leader").val()
         const mail = $("#email").val()
         const timing = $("#timing option:selected").text()
+        const stype = $("#stype option:selected").val()
 
         const app = {}
         if (name === "" || ip_port === "" || leader === "" || mail === "") {
@@ -281,6 +308,7 @@
         app['leader'] = leader
         app['mail'] = mail
         app['timing'] = timing
+        app['stype'] = stype
         $.ajax({
             url: "/service/app/monitor/create",
             type: 'POST',
@@ -346,7 +374,7 @@
         app['ip_port'] = ip_port
         app['leader'] = leader
         app['mail'] = mail
-        app['timing'] = timing
+        app["stype"] = $("#edit-stype option:selected").val()
         app["timing"] = $("#edit-timing option:selected").text()
         app["status"]= $("input[name='status']:checked").val()
         $.ajax({