|
@@ -40,8 +40,6 @@ func TriggerCollect(c *gin.Context) {
|
|
|
if util.StringToInt(collectLimitPo.MonthCollectedNumber) < util.StringToInt(param.CollectLimitMonth) {
|
|
|
if util.StringToInt(collectLimitPo.WeekCollectedNumber) < util.StringToInt(param.CollectLimitWeek) {
|
|
|
if util.StringToInt(collectLimitPo.DayCollectedNumber) < util.StringToInt(param.CollectLimitDay) {
|
|
|
- // 所有值添加一
|
|
|
- mapper.UpdateCollectLimit(param.SnCode)
|
|
|
// 返回允许信号
|
|
|
c_log.GlobalLogger.Info("允许采集。")
|
|
|
c.JSON(http.StatusOK, commonEntity.Response{
|
|
@@ -66,6 +64,30 @@ func TriggerCollect(c *gin.Context) {
|
|
|
Msg: "不允许采集。",
|
|
|
})
|
|
|
}
|
|
|
-func CanCollectPlus(c *gin.Context) {
|
|
|
|
|
|
+// 给定设备sn,数据库中所有采集数(日、周、月、年)加一
|
|
|
+func CanCollectPlus(c *gin.Context) {
|
|
|
+ globalMutex.Lock()
|
|
|
+ defer globalMutex.Unlock()
|
|
|
+ param := new(CollectLimitPao)
|
|
|
+ // 映射到结构体
|
|
|
+ if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
+ c_log.GlobalLogger.Error("接收请求参数报错:", err)
|
|
|
+ c.JSON(http.StatusBadRequest, commonEntity.Response{Code: 500, Msg: "请求体解析失败。"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c_log.GlobalLogger.Info("请求体为:", param)
|
|
|
+ // 所有值添加一
|
|
|
+ err := mapper.UpdateCollectLimit(param.SnCode)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
+ Code: 400,
|
|
|
+ Msg: "设备采集数量更新失败。",
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
+ Code: 200,
|
|
|
+ Msg: "设备采集数量已更新。",
|
|
|
+ })
|
|
|
}
|