导出时长
This commit is contained in:
parent
8bf845a823
commit
bcb952ad28
@ -76,7 +76,7 @@ public class AsyncAiAnalyse {
|
||||
for (SystemUser systemUser : systemUserList) {
|
||||
noticeService.addUserNotice(systemUser.getUserId(), title, msg, "8");
|
||||
}
|
||||
sendAppNotice(record.getProjectSn(), title, msg, systemUserList, "/pages/potentialRisk/potentialRisk?id=" + record.getId());
|
||||
// sendAppNotice(record.getProjectSn(), title, msg, systemUserList, "/pages/potentialRisk/potentialRisk?id=" + record.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("error:", e);
|
||||
|
||||
@ -1,17 +1,23 @@
|
||||
package com.zhgd.xmgl.modules.safetyhat.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.vo.WorkerNumByRegionVo;
|
||||
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.util.DateUtils;
|
||||
import com.zhgd.xmgl.util.RundeSafeyHatUtils;
|
||||
import io.loadkit.Res;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -23,6 +29,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -43,6 +54,9 @@ public class SafetyHatDataController {
|
||||
@Autowired
|
||||
private ISafetyHatDataService safetyHatDataService;
|
||||
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
@ -210,4 +224,41 @@ public class SafetyHatDataController {
|
||||
return Result.success(safetyHatDataService.countWorkerNumByRegion(param));
|
||||
}
|
||||
|
||||
@OperLog(operModul = "智能安全帽实时数据管理", operType = "查询", operDesc = "导出帽子在线使用时长")
|
||||
@ApiOperation(value = "导出帽子在线使用时长", notes = "导出帽子在线使用时长", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
})
|
||||
@GetMapping(value = "/exportUseHistory")
|
||||
public void exportUseHistory(@ApiIgnore @RequestParam Map<String, Object> param, HttpServletResponse response) throws Exception {
|
||||
ProjectInfoExtVo project = projectService.getProjectInfoBySn(MapUtils.getString(param, "projectSn"));
|
||||
JSONObject token = RundeSafeyHatUtils.getToken(project.getHelmetUser(), project.getHelmetPassword());
|
||||
String stime = MapUtils.getString(param, "stime");
|
||||
String etime = MapUtils.getString(param, "etime");
|
||||
JSONObject pJo = new JSONObject();
|
||||
pJo.put("admin_id", "13997");
|
||||
pJo.put("token", token.getString("token"));
|
||||
pJo.put("stime", DateUtil.date(DateUtil.parseDate(stime)).getTime() / 1000);
|
||||
pJo.put("etime", DateUtil.date(DateUtil.parseDate(etime)).getTime() / 1000);
|
||||
pJo.put("user_id", MapUtils.getString(param, "userId"));
|
||||
String json = pJo.toJSONString();
|
||||
InputStream in = HttpRequest.post("https://caps.runde.pro/api/index.php?ctl=device&act=export")
|
||||
.body(json)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().bodyStream();
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode("在线统计时长.xlsx", "UTF-8"));
|
||||
response.setContentType("application/octet-stream");// 定义输出类型
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
int len = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while ((len = in.read(buffer)) > 0){
|
||||
out.write(buffer,0,len);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(DateUtil.parseDateTime("2024-09-23 00:00:00").getTime());
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,8 +11,11 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.config.SafetyHatWSClient;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
||||
@ -20,13 +23,20 @@ import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDataMapper;
|
||||
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDevMapper;
|
||||
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService;
|
||||
import com.zhgd.xmgl.util.RundeSafeyHatUtils;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.websocket.DeploymentException;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
@ -35,6 +45,7 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
@ -288,5 +299,58 @@ public class SafetyHatTask {
|
||||
return client;
|
||||
}
|
||||
|
||||
@OperLog(operModul = "智能安全帽设备管理", operType = "查询", operDesc = "文字转语音")
|
||||
@ApiOperation(value = "文字转语音并发送", notes = "文字转语音", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "content", value = "文字", paramType = "query", required = true, dataType = "String")
|
||||
@PostMapping(value = "/textToAudio")
|
||||
public void textToAudio(@ApiIgnore @RequestBody Map<String, Object> param) {
|
||||
ProjectInfoExtVo project = projectService.getProjectInfoBySn(MapUtils.getString(param, "projectSn"));
|
||||
JSONObject token = RundeSafeyHatUtils.getToken(project.getHelmetUser(), project.getHelmetPassword());
|
||||
String content = MapUtils.getString(param, "content");
|
||||
JSONObject pJo = new JSONObject();
|
||||
pJo.put("token", token.getString("token"));
|
||||
pJo.put("content", content);
|
||||
String json = pJo.toJSONString();
|
||||
String rs = HttpRequest.post("https://caps.runde.pro/api/index.php?ctl=aibroadcast&act=send_broadcast_to_cat")
|
||||
.body(json)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
String id = null;
|
||||
if (StringUtils.isNotBlank(rs)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(rs);
|
||||
id = jsonObject.getJSONObject("data").getString("message");
|
||||
}
|
||||
SafetyHatWSClient client = SafetyHatWSClient.clientMap.get(project.getHelmetUser());
|
||||
String userId = MapUtils.getString(param, "userId");
|
||||
String message = "{\"act\":\"ma_sending_message\",\"message\":\"" + id + "\",\"user_id\":\"" + userId + "\"}";
|
||||
client.send(message);
|
||||
log.info("安全帽发送消息:{},content:{}", userId, content);
|
||||
}
|
||||
|
||||
@OperLog(operModul = "智能安全帽设备管理", operType = "查询", operDesc = "文字转语音")
|
||||
@ApiOperation(value = "文字转语音并发送", notes = "文字转语音", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", required = true, dataType = "String")
|
||||
@PostMapping(value = "/messageRecord")
|
||||
public Result<Object> messageRecord(@ApiIgnore @RequestBody Map<String, Object> param) {
|
||||
ProjectInfoExtVo project = projectService.getProjectInfoBySn(MapUtils.getString(param, "projectSn"));
|
||||
JSONObject token = RundeSafeyHatUtils.getToken(project.getHelmetUser(), project.getHelmetPassword());
|
||||
String userId = MapUtils.getString(param, "userId");
|
||||
JSONObject pJo = new JSONObject();
|
||||
pJo.put("admin_id", "13997");
|
||||
pJo.put("user_id", userId);
|
||||
pJo.put("act", "get_user_msg_list");
|
||||
pJo.put("ctl", "msg");
|
||||
String json = pJo.toJSONString();
|
||||
String rs = HttpRequest.post("https://caps.runde.pro/api/index.php")
|
||||
.header("authentication", token.getString(SESSION_ID))
|
||||
.body(json)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (StringUtils.isNotBlank(rs)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(rs);
|
||||
jsonArray = jsonObject.getJSONObject("data").getJSONArray("list");
|
||||
}
|
||||
return Result.success(jsonArray);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user