2 Commits 25dc0c5130 ... 3f35517797

Tác giả SHA1 Thông báo Ngày
  sunmiao 3f35517797 featrue(mcs_api): 增加Makefile,方便编译 3 năm trước cách đây
  sunmiao 38c3c06613 featrue(mcs_api,sa_api): 用户管理可添加ID卡;首页显示设备类型调整 3 năm trước cách đây

+ 22 - 0
backend/src/dashoo.cn/mcs_api/Makefile

@@ -0,0 +1,22 @@
+.PHONY: build build-win clean help
+
+# const
+GO_CMD=go
+GO_BUILD=$(GO_CMD) build
+SERVICE_NAME=mcs_web_api
+OUTPUT_DIR=./bin/$(SERVICE_NAME)
+
+default: build
+
+build:
+	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO_BUILD) -o $(OUTPUT_DIR)
+
+build-win:
+	CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go $(GO_BUILD) -o $(OUTPUT_DIR).exe
+
+clean:
+	rm -rf $(OUTPUT_DIR)
+
+help:
+    @echo "make: compile packages"
+    @echo "build-win: compile packages under windows"

+ 2 - 2
backend/src/dashoo.cn/mcs_api/controllers/alerts.go

@@ -176,7 +176,7 @@ func (this *AlertsController) AddPost() {
 							svdevc := device.GetDeviceService(utils.DBE)
 							svceq := equipment.GetEquipmentService(utils.DBE)
 							eids := svceq.GetEquipmentidsByUid(this.User.Id)
-							where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_Sensor + ") "
+							where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_HomeList + ") "
 							where += " and a.Serial in (" + bindchannels + ")"
 							_, devices := svdevc.GetChannelsList(-1, -1, where, this.User.Id)
 							//报警器网关一体机下发数据
@@ -362,7 +362,7 @@ func (this *AlertsController) EditPost() {
 			svdevc := device.GetDeviceService(utils.DBE)
 			svceq := equipment.GetEquipmentService(utils.DBE)
 			eids := svceq.GetEquipmentidsByUid(this.User.Id)
-			where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_Sensor + ") "
+			where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_HomeList + ") "
 			where += " and a.Serial in (" + bindchannels + ")"
 			_, devices := svdevc.GetChannelsList(-1, -1, where, this.User.Id)
 			//报警器网关一体机下发数据

+ 2 - 2
backend/src/dashoo.cn/mcs_api/controllers/channels.go

@@ -115,7 +115,7 @@ func (this *ChannelsController) List() {
 	svceq := equipment.GetEquipmentService(utils.DBE)
 	eids := svceq.GetEquipmentidsByUid(this.User.Id)
 	Uid := this.User.Id
-	where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_Sensor + ") "
+	where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_HomeList + ") "
 
 	keyword := this.GetString("keyword")
 	if keyword != "" {
@@ -1098,7 +1098,7 @@ func (this *ChannelsController) ChannelManageview(client labsop.LabSopClient, co
 	case "29": //压力
 		queryGroupCommand = fmt.Sprintf("select max(pressure),min(pressure),MEAN(pressure) from %v where time > %vs and time < %vs", code, start, end)
 		if level == "0" {
-			queryCommand = fmt.Sprintf("select ots from %v where time > %vs and time < %vs", code, start, end)
+			queryCommand = fmt.Sprintf("select pressure from %v where time > %vs and time < %vs", code, start, end)
 		} else {
 			queryCommand = fmt.Sprintf("select MEDIAN(pressure) as pressure from %v where time > %vs and time < %vs group by time(%v) fill(none)", code, start, end, level)
 		}

+ 7 - 4
backend/src/dashoo.cn/mcs_api/controllers/common.go

@@ -210,11 +210,14 @@ func CoderGBKtoUTF8(str string) string {
 
 //设备类型汇总
 const (
-	Device_Box         = "0"                                                                                  //设备,普通box
-	Device_Alertor     = "4"                                                                                  //设备,报警器
-	ChannelItem_Sensor = "0,6,7,9,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36" //sensor 0:常温,6:深低温,7:o2,9:co2,10:特殊(隐藏湿度的常温),13:功率,14:外接设备1,15:外接液位设备,16:常温带定位,
-	// 17:氧气设备,18:风速,19:气压,20:二氧化氯,21:乙烯,22:氯气,23:臭氧,24:TVOC,25:乙炔,26:纯二氧化碳,27:电导率,28:二氧化硫,29:微压差(压力),30:位移,31:扫码智能锁,32:基点5传感器,33:人脸识别锁
+	Device_Box         = "0" //设备,普通box
+	Device_Alertor     = "4" //设备,报警器
+	ChannelItem_Sensor = "0,6,7,9,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36"
+	//传感器类型 0:常温,6:深低温,7:o2(带温湿度),9:co2(带温湿度),10:特殊(隐藏湿度的常温),13:功率,14:外接设备1,15:外接液位设备,16:常温带定位,17:氧气设备,18:风速,19:气压
+	// 20:二氧化氯,21:乙烯,22:氯气,23:臭氧,24:TVOC,25:乙炔,26:纯二氧化碳,27:电导率,28:二氧化硫,29:微压差(压力),30:位移,31:扫码智能锁,32:基点5传感器,33:人脸识别锁
 	// 34:视频摄像头,35:门禁一体机,36:仪器控制终端
+	// 首页中显示的传感器类型
+	ChannelItem_HomeList        = "0,6,7,9,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32"
 	ChannelItem_Report          = "0,6,7,9,10,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32" //sensor报表使用,不需要功率,常温,深低温,o2,co2,特殊(隐藏湿度的常温),外接设备1,外接液位设备,常温带定位,氧气设备
 	ChannelItem_Box             = "1"                                                                //sensor,box自身数据
 	ChannelItem_TAndH           = "0,14,16"                                                          //sensor,常温,显示温湿度

+ 8 - 5
backend/src/dashoo.cn/mcs_api/controllers/user.go

@@ -39,6 +39,7 @@ type UserModel struct {
 	Password       string `json:"password"`
 	DepartmentId   string `json:"departmentid"`
 	DepartmentName string `json:"departmentname"`
+	Code           string `json:"code"` //IC卡号
 }
 
 type Note struct {
@@ -202,6 +203,7 @@ func (this *UserController) AddUser() {
 	userentity.Mobile = model.Mobile
 	userentity.Description = model.Description
 	userentity.Photo = model.Photo
+	userentity.Code = model.Code
 
 	currentuser := this.User
 	userentity.Createuserid, _ = utils.StrTo(currentuser.Id).Int()
@@ -231,7 +233,7 @@ func (this *UserController) AddUser() {
 	err := svc.AddUser(&userentity)
 
 	if err == nil {
-		errinfo.Message = "添加用户成功,初始密码为123456"
+		errinfo.Message = "添加用户成功,初始密码为123456,请提醒用户登录后自行修改。"
 		errinfo.Code = 0
 		this.Data["json"] = &errinfo
 		this.ServeJSON()
@@ -246,8 +248,8 @@ func (this *UserController) AddUser() {
 
 }
 
-// @Title 创建用户
-// @Description 创建用户
+// @Title 编辑用户
+// @Description 编辑用户
 // @Param	id	path	string	true		"需要修改的传感器编号"
 // @Param	body	body	business.device.DeviceChannels	"传感器信息"
 // @Success	200	{object} controllers.Request
@@ -290,6 +292,7 @@ func (this *UserController) EditUser() {
 		userentity.Realname = model.Realname
 		userentity.Telephone = model.Telephone
 		userentity.Mobile = model.Mobile
+		userentity.Code = model.Code
 		userentity.Description = model.Description
 		userentity.Roleid = roleid
 		userentity.Modifieduserid, _ = utils.StrTo(this.User.Id).Int()
@@ -298,7 +301,7 @@ func (this *UserController) EditUser() {
 		userentity.Departmentname = model.DepartmentName
 		userentity.Photo = model.Photo
 
-		var cols []string = []string{"Realname", "Roleid", "Telephone", "Mobile", "Description", "Modifieduserid", "Modifiedby", "Departmentid", "Departmentname", "Photo"}
+		var cols []string = []string{"Realname", "Roleid", "Telephone", "Mobile", "Description", "Modifieduserid", "Modifiedby", "Departmentid", "Departmentname", "Photo", "Code"}
 
 		err := svc.UpdateEntityAndBackupByCols(id, &userentity, &userentityempty, cols, utils.ToStr(this.User.Id), this.User.Realname)
 
@@ -743,7 +746,7 @@ func sendFaceLockCheckMsg(userId, action string) {
 	if err != nil {
 		fmt.Println("初始化NsqProducer失败:", err)
 	}
-	err = w.Publish(topic, []byte(userId+ "|" + action))
+	err = w.Publish(topic, []byte(userId+"|"+action))
 	if err != nil {
 		fmt.Println("发送NSQ消息失败:", err)
 	}