Explorar el Código

led屏完成对接边缘

sixian hace 2 años
padre
commit
613348385f

+ 9 - 4
app/data/controller/calcTask.go

@@ -7,6 +7,7 @@ import (
 	"io/ioutil"
 	"iot_manager_service/app/data/model"
 	"iot_manager_service/app/data/service"
+	controller "iot_manager_service/app/device/controller"
 	device "iot_manager_service/app/device/service"
 	system "iot_manager_service/app/system/dao"
 	warnService "iot_manager_service/app/warn/service"
@@ -49,14 +50,18 @@ func CalcTask() {
 		warnService.TaskWarnService.HandlingAlarms()
 	})
 
-	//每天早上07:10同步亮度与音量
+	//【led信息屏】每天早上07:10同步亮度与音量
 	c.AddFunc("0 10 7 * * ?", func() {
 		//c.AddFunc("*/10 * * * * ?", func() {
-		device.InfoBoardService.CronSyncBrightnessAndMusicvolume()
+		controller.InfoBoard.CronSyncBrightnessAndMusicvolume()
 	})
-	//每天晚上18:10同步亮度与音量
+	//【led信息屏】每天晚上18:10同步亮度与音量
 	c.AddFunc("0 10 18 * * ?", func() {
-		//device.InfoBoardService.CronSyncBrightnessAndMusicvolume()
+		controller.InfoBoard.CronSyncBrightnessAndMusicvolume()
+	})
+	//【led信息屏】播放节目同步
+	c.AddFunc("*/10 * * * * ?", func() {
+		//controller.InfoBoard.CronSyncLedPaying(0)
 	})
 	c.Start()
 }

+ 56 - 0
app/device/controller/infoBoardController.go

@@ -1,11 +1,14 @@
 package controller
 
 import (
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/device/service"
 	"iot_manager_service/app/middleware"
+	service2 "iot_manager_service/app/multimedia/service"
+	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
 	"math"
 	"net/http"
@@ -142,6 +145,59 @@ func (c *infoBoardCtl) EdgeCmd(ctx *gin.Context) {
 		req2.Condition = req.Condition
 		service.InfoBoardService.CreateOrUpdate(claims.UserId, claims.TenantId, req2)
 	}
+	//更新排程
+	if req.Directive == 4 {
+		c.CronSyncLedPaying(req.Id)
+	}
 	service.InfoBoardService.EdgeCmd(strconv.Itoa(claims.TenantId), req.InfoSn, req.Directive, req.Id)
 	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
 }
+
+// CronSyncBrightnessAndMusicvolume 同步亮度与音量
+func (s *infoBoardCtl) CronSyncBrightnessAndMusicvolume() {
+	board := dao.InfoBoard{}
+	list, err := board.GetAllDevicesNotTenant()
+	if err != nil {
+		fmt.Printf("err = %v \n", err)
+		return
+	}
+	//fmt.Printf("list = %v \n", list)
+	for _, led := range list {
+		_, retState := cache.GetDeviceState(led.Sn)
+		//fmt.Printf("retState = %v \n", retState)
+		if retState == "1" {
+			service.InfoBoardService.EdgeCmd(strconv.Itoa(led.TenantId), led.Sn, 101, led.ID)
+		}
+	}
+}
+
+// CronSyncLedPaying 同步播放当前节目
+func (s *infoBoardCtl) CronSyncLedPaying(id int) {
+	board := dao.InfoBoard{}
+	if id > 0 {
+		board.ID = id
+	}
+	list, err := board.GetAllDevicesNotTenant()
+	if err != nil {
+		fmt.Printf("CronSyncLedPaying err = %v \n", err)
+		return
+	}
+	for _, led := range list {
+		_, retState := cache.GetDeviceState(led.Sn)
+		currPaying := cache.GetDeviceLedData(led.Sn)
+		if retState == "1" {
+
+			playing := currPaying["playing"].(string) //得到当前正播放的节目
+			fmt.Printf("led信息屏设备Sn = %v 当前正在播放[%v]", led.Sn, playing)
+			playJson := service2.PublishLibrariesService.LedPaying(led.ID, playing)
+			if playJson != "" {
+				service.InfoBoardService.EdgePushLedProgram(strconv.Itoa(led.TenantId), led.Sn, playJson)
+				fmt.Printf("需要更新\n")
+			} else {
+				fmt.Printf("无需更新\n")
+			}
+		} else {
+			//fmt.Printf("led设备不在线Sn = %v \n", led.Sn)
+		}
+	}
+}

+ 5 - 1
app/device/dao/infoBoardDao.go

@@ -106,7 +106,11 @@ func (c InfoBoard) GetAllDevices() ([]*InfoBoard, error) {
 
 func (c InfoBoard) GetAllDevicesNotTenant() ([]*InfoBoard, error) {
 	var devices []*InfoBoard
-	err := Db.Debug().Model(&c).Where("is_deleted = 0 ").Scan(&devices).Error
+	db := Db.Debug().Model(&c)
+	if c.ID > 0 {
+		db.Where("id=?", c.ID)
+	}
+	err := db.Where("is_deleted = 0 ").Scan(&devices).Error
 	return devices, err
 }
 

+ 6 - 3
app/device/edge_service/cltLedControlService.go

@@ -16,7 +16,7 @@ type CltLedControlService struct{}
 
 type CltLedControlReqPost struct {
 	Codes []string    `json:"codes"`
-	Param interface{} `param`
+	Param interface{} `json:"param"`
 }
 type CltLedControlReq struct {
 	Tenant   string `json:"tenant"`
@@ -33,12 +33,13 @@ func (f CltLedControlService) RequestApi(reqData CltLedControlReq) {
 	cfg := config.Instance()
 	reqId := uuid.New().String()
 	url := fmt.Sprintf("%v/cltled/v1/%v/%v/%v", cfg.Foreign.IotEdgeUrl, reqData.Tenant, reqData.Action, reqId)
-	//fmt.Printf("RequestApi url = %v \n", url)
-	//fmt.Printf("reqData = %v \n", reqData)
+
 	method := "POST"
 
 	client := &http.Client{}
 	marshal, _ := json.Marshal(reqData.PostData)
+	fmt.Printf("playJson = %v \n", string(marshal))
+
 	req, err := http.NewRequest(method, url, strings.NewReader(string(marshal)))
 	if err != nil {
 		logger.Logger.Errorf("CltLedControlService NewRequest %v", err.Error())
@@ -64,6 +65,8 @@ func (f CltLedControlService) RequestApi(reqData CltLedControlReq) {
 		return
 	}
 	if cltLedControlRes.Code != 0 {
+		fmt.Printf("RequestApi url = %v \n", url)
+		fmt.Printf("reqData = %v \n", reqData)
 		logger.Logger.Errorf("CltLedControlService cltLedControlRes %v", cltLedControlRes.Msg)
 		return
 	}

+ 9 - 18
app/device/service/infoBoardService.go

@@ -267,6 +267,15 @@ func (s *infoBoardService) reqEdge(tenant string, edgePost edge_service.CltLedCo
 	edge_service.CltLedControlService{}.RequestApi(req)
 }
 
+// 发布led信息屏节目
+func (s *infoBoardService) EdgePushLedProgram(tenant, sn, playJson string) {
+	var edgePost edge_service.CltLedControlReqPost
+	edgePost.Codes = []string{sn}
+	param := make(map[string]interface{})
+	json.Unmarshal([]byte(playJson), &param)
+	s.reqEdge(tenant, edgePost, param, "spgms")
+}
+
 // 判断是否晚上
 func isEight() bool {
 	now := time.Now()
@@ -279,21 +288,3 @@ func isEight() bool {
 		return false
 	}
 }
-
-// CronSyncBrightnessAndMusicvolume 同步亮度与音量
-func (s *infoBoardService) CronSyncBrightnessAndMusicvolume() {
-	board := dao.InfoBoard{}
-	list, err := board.GetAllDevicesNotTenant()
-	if err != nil {
-		fmt.Printf("err = %v \n", err)
-		return
-	}
-	//fmt.Printf("list = %v \n", list)
-	for _, led := range list {
-		_, retState := cache.GetDeviceState(led.Sn)
-		//fmt.Printf("retState = %v \n", retState)
-		if retState == "1" {
-			s.EdgeCmd(strconv.Itoa(led.TenantId), led.Sn, 101, led.ID)
-		}
-	}
-}

+ 13 - 0
app/multimedia/controller/publishLibrariesController.go

@@ -112,3 +112,16 @@ func (c *PublishLibrariesCtl) UpdateStatus(ctx *gin.Context) {
 	}
 	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, nil))
 }
+
+func (c *PublishLibrariesCtl) Remove(ctx *gin.Context) {
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+
+	ids, _ := strconv.Atoi(ctx.Query("ids"))
+	err := service.PublishLibrariesService.Remove(claims.UserId, claims.TenantId, ids)
+	if err != nil {
+		ctx.JSON(http.StatusOK, err)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
+}

+ 1 - 1
app/multimedia/dao/programDao.go

@@ -46,7 +46,7 @@ func (c *Program) GetPrograms(offset, limit int) ([]Program, int64, error) {
 
 	db = db.Where("is_deleted = 0 and tenant_id = ?", c.TenantId)
 	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&Programs).Error
+	err := db.Offset(offset).Limit(limit).Order("id desc").Find(&Programs).Error
 	return Programs, count, err
 }
 

+ 1 - 0
app/multimedia/dao/programRelationDao.go

@@ -4,6 +4,7 @@ type ProgramRelation struct {
 	ID        int `gorm:"primary_key" json:"id"`               //编号
 	ProgramId int `gorm:"type:int" json:"programId"`           //节目单ID
 	LibraryId int `gorm:"type:int" json:"libraryId"`           //素材ID
+	Duration  int `gorm:"type:int" json:"duration"`            //时长
 	OrderNo   int `gorm:"type:int" json:"orderNo"`             //排序位置
 	TenantId  int `gorm:"type:int" json:"tenantId"`            //租户ID
 	IsDeleted int `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除

+ 39 - 27
app/multimedia/dao/publishLibrariesDao.go

@@ -7,32 +7,32 @@ import (
 )
 
 type PublishLibraries struct {
-	ID               int64       `gorm:"column:id;type:int(10) unsigned;primary_key;AUTO_INCREMENT;comment:编号" json:"id" :"ID"`                             // 编号
-	Name             string      `gorm:"column:name;type:varchar(64);comment:名称" json:"name" :"Name"`                                                       // 名称
-	Resolution       int         `gorm:"column:resolution;type:int(11);comment:分辨率" json:"resolution" :"Resolution"`                                        // 分辨率
-	Duration         int64       `gorm:"column:duration;type:bigint(20);default:0;comment:统计文件时长" json:"duration" :"Duration"`                              // 统计文件时长
-	FileSize         int64       `gorm:"column:file_size;type:bigint(20);default:0;comment:统计文件大小" json:"fileSize" :"FileSize"`                             // 统计文件大小
-	InfoId           string      `gorm:"column:info_id;type:varchar(4000);comment:信息屏ID 组合" json:"infoId" :"InfoId"`                                        // 信息屏ID 组合
-	ImgDuration      int         `gorm:"column:img_duration;type:int(11);default:0;comment:图片播放时长(毫秒)" json:"imgDuration" :"ImgDuration"`                   // 图片播放时长(毫秒)
-	StartTime        common.Time `gorm:"column:start_time;type:date;comment:播放开始时间" json:"startTime" :"StartTime"`                                          // 播放开始时间
-	EndTime          common.Time `gorm:"column:end_time;type:date;comment:播放结束时间" json:"endTime" :"EndTime"`                                                // 播放结束时间
-	NotificationType string      `gorm:"column:notification_type;type:varchar(60);comment:通知类型 组合1短信2邮件3电话4微信" json:"notificationType" :"NotificationType"` // 通知类型 组合1短信2邮件3电话4微信
-	CreateTime       time.Time   `gorm:"column:create_time;type:datetime;comment:新增时间" json:"createTime" :"CreateTime"`                                     // 新增时间
-	CreateUser       int64       `gorm:"column:create_user;type:varchar(60);comment:增记录操作用户ID" json:"createUser" :"CreateUser"`                             // 新增记录操作用户ID
-	CreateName       string      `gorm:"column:create_name;type:varchar(64);comment:新增用户姓名" json:"createName" :"CreateName"`                                // 新增用户姓名
-	UpdateTime       time.Time   `gorm:"column:update_time;type:datetime;comment:修改时间" json:"updateTime" :"UpdateTime"`                                     // 修改时间
-	UpdateUser       string      `gorm:"column:update_user;type:varchar(60);comment:修改用户" json:"updateUser" :"UpdateUser"`                                  // 修改用户
-	IsDeleted        int         `gorm:"column:is_deleted;type:int(11);default:0;comment:是否删除 0=未删除,1=删除" json:"isDeleted" :"IsDeleted"`                    // 是否删除 0=未删除,1=删除
-	Status           int         `gorm:"column:status;type:int(11);comment:状态 0审核1播放2暂停3取消4过期5审核不通过" json:"status" :"Status"`                               // 状态 0审核1播放2暂停3取消4过期5审核不通过
-	TenantId         int         `gorm:"column:tenant_id;type:int(11);comment:租户ID" json:"tenantTd" :"TenantId"`                                            // 租户ID
-	Remarks          string      `gorm:"column:remarks;type:varchar(4000);comment:系统类型:0-多媒体系统,1-广播系统" json:"remarks" :"Remarks"`                           // 备注
-	SysType          int         `gorm:"column:sys_type;type:int(11);default:0;comment:编号" json:"sysStype" :"SysType"`                                      // 系统类型:0-多媒体系统,1-广播系统
-	KsTime           string      `gorm:"column:ks_time;type:varchar(50);comment:播放开始时间" json:"ksTime" :"KsTime"`                                            // 播放开始时间
-	JsTime           string      `gorm:"column:js_time;type:varchar(50);comment:播放结束时间" json:"jsTime" :"JsTime"`                                            // 播放结束时间
-	FileId           int         `gorm:"column:file_id;type:int(11);comment:文件ID,系统类型为广播系统时使用" json:"fileId" :"FileId"`                                     // 文件ID,系统类型为广播系统时使用
-	TaskId           int         `gorm:"column:task_id;type:int(11);comment:任务ID,发布后才有用于控制启动与停止" json:"taskId" :"TaskId"`                                   // 任务ID,发布后才有用于控制启动与停止
-	PlayTime         int         `gorm:"column:play_time;type:int(11);default:1;comment:播放次数(1-100)" json:"playTime" :"PlayTime"`                           // 播放次数(1-100)
-	PlayInterval     int         `gorm:"column:play_interval;type:int(11);default:0;comment: 播放间隔(0-360秒)" json:"playInterval" :"PlayInterval"`             // 播放间隔(0-360秒)
+	ID               int64       `gorm:"column:id;type:int(10) unsigned;primary_key;AUTO_INCREMENT;comment:编号" json:"id"`
+	Name             string      `gorm:"column:name;type:varchar(64);comment:名称" json:"name"`                                           // 名称
+	Resolution       int         `gorm:"column:resolution;type:int(11);comment:分辨率" json:"resolution"`                                  // 分辨率
+	Duration         int64       `gorm:"column:duration;type:bigint(20);default:0;comment:统计文件时长" json:"duration"`                      // 统计文件时长
+	FileSize         int64       `gorm:"column:file_size;type:bigint(20);default:0;comment:统计文件大小" json:"fileSize"`                     // 统计文件大小
+	InfoId           string      `gorm:"column:info_id;type:varchar(4000);comment:信息屏ID 组合" json:"infoId"`                              // 信息屏ID 组合
+	ImgDuration      int         `gorm:"column:img_duration;type:int(11);default:0;comment:图片播放时长(毫秒)" json:"imgDuration"`              // 图片播放时长(毫秒)
+	StartTime        common.Time `gorm:"column:start_time;type:date;comment:播放开始时间" json:"startTime"`                                   // 播放开始时间
+	EndTime          common.Time `gorm:"column:end_time;type:date;comment:播放结束时间" json:"endTime"`                                       // 播放结束时间
+	NotificationType string      `gorm:"column:notification_type;type:varchar(60);comment:通知类型 组合1短信2邮件3电话4微信" json:"notificationType"` // 通知类型 组合1短信2邮件3电话4微信
+	CreateTime       time.Time   `gorm:"column:create_time;type:datetime;comment:新增时间" json:"createTime"`                               // 新增时间
+	CreateUser       int64       `gorm:"column:create_user;type:varchar(60);comment:增记录操作用户ID" json:"createUser"`                       // 新增记录操作用户ID
+	CreateName       string      `gorm:"column:create_name;type:varchar(64);comment:新增用户姓名" json:"createName"`                          // 新增用户姓名
+	UpdateTime       time.Time   `gorm:"column:update_time;type:datetime;comment:修改时间" json:"updateTime"`                               // 修改时间
+	UpdateUser       string      `gorm:"column:update_user;type:varchar(60);comment:修改用户" json:"updateUser"`                            // 修改用户
+	IsDeleted        int         `gorm:"column:is_deleted;type:int(11);default:0;comment:是否删除 0=未删除,1=删除" json:"isDeleted"`             // 是否删除 0=未删除,1=删除
+	Status           int         `gorm:"column:status;type:int(11);comment:状态 0审核1播放2暂停3取消4过期5审核不通过" json:"status"`                     // 状态 0审核1播放2暂停3取消4过期5审核不通过
+	TenantId         int         `gorm:"column:tenant_id;type:int(11);comment:租户ID" json:"tenantTd"`                                    // 租户ID
+	Remarks          string      `gorm:"column:remarks;type:varchar(4000);comment:系统类型:0-多媒体系统,1-广播系统" json:"remarks"`                  // 备注
+	SysType          int         `gorm:"column:sys_type;type:int(11);default:0;comment:编号" json:"sysStype"`                             // 系统类型:0-多媒体系统,1-广播系统
+	KsTime           string      `gorm:"column:ks_time;type:varchar(50);comment:播放开始时间" json:"ksTime"`                                  // 播放开始时间
+	JsTime           string      `gorm:"column:js_time;type:varchar(50);comment:播放结束时间" json:"jsTime"`                                  // 播放结束时间
+	FileId           int         `gorm:"column:file_id;type:int(11);comment:文件ID,系统类型为广播系统时使用" json:"fileId"`                           // 文件ID,系统类型为广播系统时使用
+	TaskId           int         `gorm:"column:task_id;type:int(11);comment:任务ID,发布后才有用于控制启动与停止" json:"taskId"`                         // 任务ID,发布后才有用于控制启动与停止
+	PlayTime         int         `gorm:"column:play_time;type:int(11);default:1;comment:播放次数(1-100)" json:"playTime"`                   // 播放次数(1-100)
+	PlayInterval     int         `gorm:"column:play_interval;type:int(11);default:0;comment: 播放间隔(0-360秒)" json:"playInterval"`         // 播放间隔(0-360秒)
 
 	PlayPeriod     string `gorm:"-"  json:"playPeriod"`              //播放期间
 	ResolutionName string `gorm:"-" json:"resolutionName"`           //分辨率
@@ -48,7 +48,7 @@ func (c *PublishLibraries) GetList(offset int, limit int) ([]PublishLibraries, i
 	var count int64
 	db := Db.Debug().Model(&c).Where("tenant_id = ? and sys_type=? and is_deleted = 0", c.TenantId, c.SysType)
 	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&list).Error
+	err := db.Offset(offset).Limit(limit).Order("id desc").Find(&list).Error
 	return list, count, err
 }
 
@@ -66,3 +66,15 @@ func (c *PublishLibraries) GetProgram() (int, error) {
 	err := Db.Debug().Model(&c).Where("id = ?", c.ID).First(&librarie).Error
 	return librarie.FileId, err
 }
+
+// GetProgramByLedId 取led信息屏当前播放的节目 ID
+func (c *PublishLibraries) GetProgramByLedId(ledId int) (PublishLibraries, error) {
+	var librarie PublishLibraries
+	err := Db.Debug().Model(&c).Where("info_id IN (?) and is_deleted = 0 and status = 1 and sys_type = 0 and start_time <= CURDATE()", ledId).Order("id desc").First(&librarie).Error
+	return librarie, err
+}
+
+func (c PublishLibraries) Delete() error {
+	return Db.Debug().Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
+		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
+}

+ 5 - 0
app/multimedia/model/publishLibrary.go

@@ -9,3 +9,8 @@ type RsqPublishLibrariesList struct {
 	Pages   int                    `json:"pages"`   //总页数
 	Total   int                    `json:"total"`   //总数
 }
+
+type RsqPublishLibrariesRemove struct {
+	IDs int `json:"ids"` //分组编码
+
+}

+ 5 - 1
app/multimedia/service/programService.go

@@ -121,6 +121,7 @@ func (s *programService) Submit(tenantId int, userId int64, req model.ReqProgram
 			OrderNo:   index + 1,
 			TenantId:  tenantId,
 			IsDeleted: 0,
+			Duration:  req.ImgDuration,
 		}
 		err := relation.Save()
 		if err != nil {
@@ -155,9 +156,12 @@ func (s *programService) GetLibraryList(tenantId, programId int) ([]dao.Library,
 	library := &dao.Library{TenantId: tenantId}
 	libraries, err := library.GetLibrariesByIds(libraryIds)
 	for i, librarie := range libraries {
+		//fmt.Printf("relations = %v \n", relations)
+		//fmt.Printf("librarie = %v \n", librarie)
 		if librarie.LibDuration == 0 {
-			libraries[i].LibDuration = 3000 //图片默认给个3秒
+			libraries[i].LibDuration = 3 //图片默认给个3秒
 		}
+		libraries[i].LibDuration = libraries[i].LibDuration * 1000
 	}
 	if err != nil {
 		logger.Logger.Errorf("GetLibrariesByIds err = %s \n", err.Error())

+ 97 - 0
app/multimedia/service/publishLibrariesService.go

@@ -1,11 +1,14 @@
 package service
 
 import (
+	"encoding/json"
 	"fmt"
 	"iot_manager_service/app/multimedia/dao"
 	"iot_manager_service/app/multimedia/model"
+	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/common"
 	"iot_manager_service/util/logger"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -122,3 +125,97 @@ func (s *publishLibrariesService) UpdateStatus(tenantId int, id int, status int,
 	}
 	return true, nil
 }
+
+func (s *publishLibrariesService) Remove(userId int64, tenantId int, id int) *common.Errors {
+	// 创建查询实例
+	device := &dao.PublishLibraries{
+		ID:         int64(id),
+		IsDeleted:  1,
+		UpdateUser: strconv.Itoa(int(userId)),
+		UpdateTime: time.Now(),
+	}
+	err := device.Delete()
+	if err != nil {
+		return common.FailResponse(err.Error(), nil)
+	}
+	service.OperationHisService.Save(userId, tenantId, common.OperationRemove, common.DeviceTypeInfoBoard,
+		common.DeviceTypeBridge, common.GetDeviceObject(int(device.ID), device.Name), common.OperationSuccess)
+	return nil
+}
+
+type CltLedLibraries struct {
+	Type      string    `json:"type"`      //文件类型 2:图片3:视频5:文本27:网页
+	Name      string    `json:"name"`      //节目名字
+	Imageinfo Imageinfo `json:"imageinfo"` //图片或视频信息
+}
+type InEffect struct {
+	Type string `json:"Type"` //翻页类型 2
+	Time string `json:"Time"` ///翻页花费时间 1000为1秒
+}
+type Imageinfo struct {
+	Urls     []string `json:"urls"`
+	Duration string   `json:"duration"`
+	InEffect InEffect `json:"inEffect"`
+}
+
+// LedPaying 组装当前led屏要播放的节目json
+func (s *publishLibrariesService) LedPaying(ledId int, playing string) string {
+	libraries := dao.PublishLibraries{}
+	librarie, err := libraries.GetProgramByLedId(ledId)
+	if err != nil {
+		logger.Logger.Errorf("LedPaying err = %v \n", err)
+		return ""
+	}
+	//fmt.Printf("librarie = %v \n", librarie)
+	program, _ := s.GetProgram(int(librarie.ID))
+	relation := &dao.ProgramRelation{
+		ProgramId: program,
+		TenantId:  librarie.TenantId,
+	}
+	relations, err := relation.GetByProgram()
+	if err != nil {
+		logger.Logger.Errorf("LedPaying err = %s \n", err.Error())
+		return ""
+	}
+	var libraryIds []int
+	for _, relation := range relations {
+		libraryIds = append(libraryIds, relation.LibraryId)
+	}
+	//fmt.Printf("libraryIds = %v \n", libraryIds)
+	library := &dao.Library{TenantId: librarie.TenantId}
+	getLibrariesByIds, _ := library.GetLibrariesByIds(libraryIds)
+	if len(getLibrariesByIds) < 1 {
+		logger.Logger.Errorf("无素材")
+		return ""
+	}
+	var cltLedLibraries CltLedLibraries
+	cltLedLibraries.Name = fmt.Sprintf("%v-%v", librarie.Name, librarie.ID)
+	if strings.EqualFold(cltLedLibraries.Name, strings.ReplaceAll(playing, ".vsn", "")) {
+		logger.Logger.Errorf("节目相同无需要更新")
+		return ""
+	}
+	cltLedLibraries.Type = "2"
+	if strings.Contains(getLibrariesByIds[0].MaterialAddress, "mp4") {
+		cltLedLibraries.Type = "3"
+	}
+	var urls []string
+	for _, getLibrariesById := range getLibrariesByIds {
+		urls = append(urls, getLibrariesById.MaterialAddress)
+	}
+	cltLedLibraries.Imageinfo.Duration = strconv.Itoa(int(librarie.Duration))
+	cltLedLibraries.Imageinfo.Urls = urls
+	cltLedLibraries.Imageinfo.InEffect.Type = "2"
+	//cltLedLibraries.Imageinfo.InEffect.Time = strconv.Itoa(relations[0].Duration)
+	cltLedLibraries.Imageinfo.InEffect.Time = "1500"
+
+	marshal, err := json.Marshal(cltLedLibraries)
+	if err != nil {
+		fmt.Printf("LedPaying err = %v \n", err)
+		return ""
+	}
+	fmt.Printf("cltLedLibraries = %v \n", string(marshal))
+
+	str := string(marshal)
+	//fmt.Printf("str = %v \n", str)
+	return str
+}

+ 1 - 0
router/router.go

@@ -537,6 +537,7 @@ func InitRouter(engine *gin.Engine) {
 		publishLibraries.POST("/getLibraryList", multimedia.PublishLibraries.GetLibraryList)
 		publishLibraries.GET("/affiliate-equipment", multimedia.PublishLibraries.AffiliateEquipment)
 		publishLibraries.POST("/updateStatus", multimedia.PublishLibraries.UpdateStatus)
+		publishLibraries.POST("/remove", multimedia.PublishLibraries.Remove)
 	}
 
 	operationGroup := engine.Group("/api/longchi/operation")