Commit 1960b971 by 杨伟程
parents 6f8e08f2 a7818924
Showing with 604 additions and 37 deletions
package com.makeit.controller.sys;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.module.system.dto.SysFileDTOVO;
import com.makeit.module.system.entity.SysFile;
import com.makeit.module.system.service.SysFileService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.storage.AccessoryRepository;
import com.makeit.utils.storage.DataWithMeta;
import com.makeit.utils.sys.FileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.List;
@Api(tags = "saas-文件")
@RestController
@RequestMapping("/saas/sys/file")
public class SaasFileController {
@Autowired
public AccessoryRepository accessoryRepository;
@Autowired
private SysFileService sysFileService;
@ApiOperation("获取文件临时路径路径")
@PostMapping("getFileTmp")
public ApiResponseEntity<SysFileDTOVO> getFileTmp(@RequestBody BaseIdDTO baseIdDTO) {
SysFileDTOVO sysFileDTOVO = BeanDtoVoUtils.convert(sysFileService.getById(baseIdDTO.getId()), SysFileDTOVO.class);
sysFileDTOVO.setFullUrl(accessoryRepository.getTmpURL(sysFileDTOVO.getUrl()));
return ApiResponseUtils.success(sysFileDTOVO);
}
@ApiOperation("获取文件路径")
@PostMapping("getFile")
public ApiResponseEntity<List<SysFileDTOVO>> getFile(@RequestBody BaseIdDTO baseIdDTO) {
return ApiResponseUtils.success(FileUtil.convertMultiply(Arrays.asList(baseIdDTO.getId())).get(0));
}
@ApiOperation("获取文件路径集合")
@PostMapping("getFileList")
public ApiResponseEntity<List<List<SysFileDTOVO>>> getFile(@RequestBody List<String> list) {
return ApiResponseUtils.success(FileUtil.convertMultiply(list));
}
//这种方式可以 只是不能设置下载文件名
// @ApiOperation("下载文件")
// @PostMapping("downloadFile")
// public byte[] downloadFile(@RequestBody BaseIdDTO baseIdDTO) {
// return aliyunOSSRepository.getBytes(UriUtils.decode(StringUtils.substringAfter(sysFileService.getById(baseIdDTO.getId()).getUrl(), "oss/"), "UTF-8"));
// }
void downloadFile(HttpServletResponse response, String id) throws IOException {
SysFile sysFile = sysFileService.getById(id);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/octet-stream");
// 设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(sysFile.getFileName(), "UTF-8"));
OutputStream outputStream = response.getOutputStream();
outputStream.write(accessoryRepository.getBytes(UriUtils.decode(StringUtils.substringAfter(sysFile.getUrl(), "oss/"), "UTF-8")));
}
//这样是可以
// private void previewFile(HttpServletResponse response, String id) throws IOException {
//
// SysFile sysFile = sysFileService.getById(id);
//
// response.setCharacterEncoding("UTF-8");
// response.setContentType("application/octet-stream");
// // 设置文件头:最后一个参数是设置下载文件名
// response.setHeader("Content-disposition", "inline;filename=" + URLEncoder.encode(sysFile.getFileName(), "UTF-8"));
//
// String suffix = sysFile.getUrl().substring(sysFile.getUrl().lastIndexOf("."));
//
// Map<String, String> map = new HashMap<>(16);
// map.put(".pdf", "application/pdf");
// map.put(".png", "image/png");
// map.put(".jpg", "image/jpg");
// map.put(".jpeg", "image/jpeg");
//
// String contentType = map.get(suffix);
// if (StringUtils.isNotBlank(contentType)) {
// response.setContentType(contentType);
// }
//
// OutputStream outputStream = response.getOutputStream();
// outputStream.write(aliyunOSSRepository.getBytes(UriUtils.decode(StringUtils.substringAfter(sysFile.getUrl(), "oss/"), "UTF-8")));
// outputStream.close();
// }
private void previewFile(HttpServletResponse response, String id) throws IOException {
SysFile sysFile = sysFileService.getById(id);
response.setCharacterEncoding("UTF-8");
// 设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "inline;filename=" + URLEncoder.encode(sysFile.getFileName(), "UTF-8"));
DataWithMeta dataWithMeta = accessoryRepository.getDataWithMeta(UriUtils.decode(StringUtils.substringAfter(sysFile.getUrl(), "oss/"), "UTF-8"));
response.setContentType(dataWithMeta.getContentType());
OutputStream outputStream = response.getOutputStream();
outputStream.write(dataWithMeta.getBytes());
outputStream.close();
}
@ApiOperation("下载文件(json id)")
@RequestMapping(value = "downloadFile", method = {RequestMethod.GET, RequestMethod.POST})
public void downloadFile(HttpServletResponse response, @RequestBody BaseIdDTO baseIdDTO) throws IOException {
downloadFile(response, baseIdDTO.getId());
}
@ApiOperation("预览文件(json id)")
@RequestMapping(value = "previewFile", method = {RequestMethod.GET, RequestMethod.POST})
public void previewFile(HttpServletResponse response, @RequestBody BaseIdDTO baseIdDTO) throws IOException {
previewFile(response, baseIdDTO.getId());
}
@ApiOperation("下载文件")
@RequestMapping(value = "downloadFileParam", method = {RequestMethod.GET, RequestMethod.POST})
public void downloadFileParam(HttpServletResponse response, String id) throws IOException {
downloadFile(response, id);
}
@ApiOperation("预览文件")
@RequestMapping(value = "previewFileParam", method = {RequestMethod.GET, RequestMethod.POST})
public void previewFileParam(HttpServletResponse response, String id) throws IOException {
previewFile(response, id);
}
@ApiOperation("批量保存")
@PostMapping("addList")
public ApiResponseEntity<?> addList(@RequestBody List<SysFileDTOVO> list) {
List<SysFile> fileList = BeanDtoVoUtils.listVo(list, SysFile.class);
sysFileService.saveBatch(fileList);
return ApiResponseUtils.success(StreamUtil.map(fileList, SysFile::getId));
}
}
package com.makeit.controller.sys;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.module.system.dto.SysFileDTOVO;
import com.makeit.module.system.dto.UploadKeyDTO;
import com.makeit.module.system.entity.SysFile;
import com.makeit.module.system.service.SysFileService;
import com.makeit.utils.contract.word.WordConverterUtil;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.storage.HwObsRepository;
import com.makeit.utils.storage.PostSignature;
import com.makeit.utils.sys.FileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author liuhb
* @date 2021/12/14
*/
@Api(tags = "saas-文件")
@RestController
@RequestMapping("/saas/storage")
public class SaasUploadController extends BaseController {
@Autowired
private SysFileService sysFileService;
private static final Logger logger = LoggerFactory.getLogger(SaasUploadController.class);
// @ApiOperation(value = "获取key")
// @PostMapping("getKey")
// public String getKey(@ApiParam(value = "originalFilename") String originalFilename) {
// String fullPath = getFullPath(null, originalFilename);
// return getUri(accessoryRepository.getKey(fullPath));
// }
@ApiOperation(value = "获取key")
@PostMapping("getKey")
public SysFileDTOVO getKey(@RequestBody UploadKeyDTO dto) {
SysFileDTOVO sysFile = new SysFileDTOVO();
sysFile.setFileName(dto.getOriginalFilename());
String fullPath = getFullPath(null, dto.getOriginalFilename());
sysFile.setUrl(getUri(HwObsRepository.APIURI + accessoryRepository.getKey(fullPath)));
sysFile.setKey(accessoryRepository.getKey(fullPath));
return sysFile;
}
@ApiOperation(value = "获取签名")
@PostMapping("getSignature")
public PostSignature getPostSignature() {
return accessoryRepository.getPostSignature();
}
private String replaceSuffix(String name) {
int index = name.lastIndexOf(".");
return name.substring(0, index) + ".pdf";
}
private List<SysFile> uploadInternal(List<MultipartFile> files, String convertToPdf) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<SysFile> sysFileList = StreamUtil.map(files, e -> {
try {
SysFile sysFile = new SysFile();
sysFile.setFileName(e.getOriginalFilename());
String fullPath = getFullPath(null, e.getOriginalFilename());
sysFile.setUrl(getUri(storageRepository("1").save(e.getBytes(), fullPath)));
if ("1".equals(convertToPdf)) {
fullPath = getFullPath(null, replaceSuffix(e.getOriginalFilename()));
sysFile.setPdfUrl(getUri(storageRepository("1").save(WordConverterUtil.convert(e.getInputStream()), fullPath)));
}
sysFile.setMime(e.getContentType());
return sysFile;
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
sysFileService.saveBatch(sysFileList);
stopWatch.stop();
logger.info("文件上传耗时:{} ms", stopWatch.getLastTaskTimeMillis());
return sysFileList;
}
private List<SysFile> convertAndUploadInternal(List<MultipartFile> files) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<SysFile> sysFileList = StreamUtil.map(files, e -> {
try {
SysFile sysFile = new SysFile();
sysFile.setFileName(replaceSuffix(e.getOriginalFilename()));
String fullPath = getFullPath(null, replaceSuffix(e.getOriginalFilename()));
sysFile.setUrl(getUri(storageRepository("1").save(WordConverterUtil.convert(e.getInputStream()), fullPath)));
sysFile.setMime(e.getContentType());
return sysFile;
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
sysFileService.saveBatch(sysFileList);
stopWatch.stop();
logger.info("文件上传耗时:{} ms", stopWatch.getLastTaskTimeMillis());
return sysFileList;
}
@ApiOperation(value = "统一文件上传")
@PostMapping("uploadFile")
public ApiResponseEntity<List<String>> uploadFile(
@ApiParam(value = "convertToPdf") @RequestParam(defaultValue = "0") String convertToPdf,
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = uploadInternal(files, convertToPdf);
return ApiResponseUtils.success(StreamUtil.map(sysFileList, SysFile::getId));
}
@ApiOperation(value = "统一文件上传返回路径")
@PostMapping("uploadFileUrl")
public ApiResponseEntity<List<SysFileDTOVO>> uploadFileUrl(
@ApiParam(value = "convertToPdf") @RequestParam(defaultValue = "0") String convertToPdf,
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = uploadInternal(files, convertToPdf);
List<SysFileDTOVO> voList = BeanDtoVoUtils.listVo(sysFileList, SysFileDTOVO.class);
FileUtil.fillFullUrl(voList);
FileUtil.fillPdfFullUrl(voList);
return ApiResponseUtils.success(voList);
}
@ApiOperation(value = "统一转换为pdf后上传")
@PostMapping("convertAndUploadFile")
public ApiResponseEntity<List<String>> convertAndUploadFile(
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = convertAndUploadInternal(files);
return ApiResponseUtils.success(StreamUtil.map(sysFileList, SysFile::getId));
}
@ApiOperation(value = "统一转换为pdf后上传返回路径")
@PostMapping("convertAndUploadFileUrl")
public ApiResponseEntity<List<SysFileDTOVO>> convertAndUploadFileUrl(
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = convertAndUploadInternal(files);
List<SysFileDTOVO> voList = BeanDtoVoUtils.listVo(sysFileList, SysFileDTOVO.class);
FileUtil.fillFullUrl(voList);
//FileUtil.fillPdfFullUrl(voList);
return ApiResponseUtils.success(voList);
}
//下面两个的作用
//返回给前端的路径 要基于下面两个转发
@ApiOperation("获取oss文件")
@RequestMapping(value = "oss/**", method = RequestMethod.GET)
public void getOssFile(HttpServletRequest req, HttpServletResponse resp) throws Exception {
// String filepath = req.getRequestURI();
// filepath = UriUtils.decode(StringUtils.substringAfter(filepath, "oss"), "UTF-8");
// //.toString().split("\\?")[0];
// resp.sendRedirect(accessoryRepository.getPermanentURL(filepath));
resp.sendRedirect(accessoryRepository.getPermanentURL(req.getRequestURI()));
}
@ApiOperation("获取oss文件(临时路径)")
@RequestMapping(value = "tmp/oss/**", method = RequestMethod.GET)
public void getOssFileTmpPath(HttpServletRequest req, HttpServletResponse resp) throws Exception {
// String filepath = req.getRequestURI();
// filepath = UriUtils.decode(StringUtils.substringAfter(filepath, "tmp/oss"), "UTF-8");
// //.toString().split("\\?")[0];
// resp.sendRedirect(accessoryRepository.getTmpURL(filepath));
resp.sendRedirect(accessoryRepository.getTmpURL(req.getRequestURI()));
}
//private String name;
// private String nameOrigin;
// private String extName;
// private Long fileSize;
// private String storeType;//video audio img pdf等
// private String relativePath;
}
......@@ -172,7 +172,7 @@
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:alibabacloud-gateway-spi:0.0.1" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:openapiutil:0.1.14" level="project" />
<orderEntry type="library" name="Maven: com.huaweicloud:esdk-obs-java-bundle:3.23.5" level="project" />
<orderEntry type="library" name="Maven: com.huaweicloud:esdk-obs-java-bundle:3.23.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.14.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.14.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
......
......@@ -28,6 +28,8 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable {
@ApiModelProperty(value = "部门名称")
private String deptName;
private String orgPath;
@TableField(exist = false)
@ApiModelProperty(value = "角色名称集合")
private List<String> nameList;
......
......@@ -83,9 +83,20 @@ public class IotCommonService {
* ]
* @return
*/
public static IotQueryParam buildQueryParam(int pageSize) {
public static IotQueryParam buildQueryParam(int pageIndex,int pageSize) {
IotQueryParam iotQueryParam = new IotQueryParam();
iotQueryParam.setPageIndex(0);
iotQueryParam.setPageIndex(pageIndex);
iotQueryParam.setPageSize(pageSize);
iotQueryParam.setSorts(buildSort("timestamp"));
iotQueryParam.setTerms(Lists.newArrayList());
return iotQueryParam;
}
public static IotQueryParam buildQueryParamByPageIndex(int pageIndex,int pageSize) {
IotQueryParam iotQueryParam = new IotQueryParam();
iotQueryParam.setPageIndex(pageIndex);
iotQueryParam.setPageSize(pageSize);
iotQueryParam.setSorts(buildSort("timestamp"));
......
package com.makeit.module.iot.service;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;
......@@ -20,14 +22,13 @@ import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;
/**
* iot产品设备相关接口
......@@ -40,6 +41,7 @@ public class IotProductDeviceService extends IotCommonService {
public static final String REPORT_PROPERTY = "reportProperty";
private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
/**
* 获取设备信息
*/
......@@ -47,7 +49,7 @@ public class IotProductDeviceService extends IotCommonService {
String url = iotUrl + DEVICE_PREFIX_URL + "_query";
// 条件可以自己改
IotQueryParam iotQueryParam = buildQueryParam(10);
IotQueryParam iotQueryParam = buildQueryParam(0,10);
String body = JsonUtil.toJson(iotQueryParam);
......@@ -129,14 +131,68 @@ public class IotProductDeviceService extends IotCommonService {
}
public List<String> getLastDayHourRange(LocalDateTime startDateTime) {
int count = 24;
List<String> list = Lists.newArrayList();
String startTime;
String endTime;
for (int i = count; i > 0; i--) {
startTime = DateUtil.format(startDateTime.minusHours(i), DatePattern.NORM_DATETIME_PATTERN);
endTime = DateUtil.format(startDateTime.minusHours(i - 1), DatePattern.NORM_DATETIME_PATTERN);
list.add(startTime + "~" + endTime);
}
return list;
}
public List<DeviceInfoContentBreathe> getDeviceLogByTimeRangeBreathe(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<String> lastDayHourRange = getLastDayHourRange(startTime);
for (String hour : lastDayHourRange) {
String[] hourRangeArray = hour.split("~");
List<DeviceOperationLogEntity> deviceOperationLogEntities = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, 5000, hourRangeArray[0], hourRangeArray[1]);
List<DeviceInfoContentBreathe> deviceInfoContentBreatheList = StreamUtil.map(deviceOperationLogEntities, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentBreathe.class));
}
long minute = 1440;
List<DeviceInfoContentBreathe> breatheList = Lists.newArrayList();
DeviceInfoContentBreathe deviceInfoContentBreathe;
for (long i = 1; i <= minute; i++) {
int brRandomLong = RandomUtils.nextInt(11,28);
int hrRandomLong = RandomUtils.nextInt(55,125);
int movebodyRandomLong = RandomUtils.nextInt(40,90);
deviceInfoContentBreathe = new DeviceInfoContentBreathe();
LocalDateTime localDateTime = startTime.plusMinutes(i);
long timeStamp = localDateTime.toInstant(ZoneOffset.UTC).toEpochMilli();
deviceInfoContentBreathe.setTimestamp(timeStamp);
DeviceInfoContentBreathe.Properties properties = new DeviceInfoContentBreathe.Properties();
properties.setBr(brRandomLong);
properties.setHr(hrRandomLong);
properties.setBodymove(movebodyRandomLong);
deviceInfoContentBreathe.setProperties(properties);
breatheList.add(deviceInfoContentBreathe);
}
/*
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentBreathe> deviceInfoContentBreatheList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentBreathe.class));
List<DeviceInfoContentBreathe> deviceInfoContentBreatheList = deviceOperationLogEntityList.stream()
.filter(deviceOperationLogEntity -> deviceOperationLogEntity.getType().contains(REPORT_PROPERTY))
.map(deviceOperationLogEntity -> {
DeviceInfoContentBreathe deviceInfoContentBreathe = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentBreathe.class);
deviceInfoContentBreathe.setReportTime(formatLongTime(deviceInfoContentBreathe.getTimestamp()));
return deviceInfoContentBreathe;
})
.collect(Collectors.toList());
Map<String, List<DeviceInfoContentBreathe>> minuteMap = StreamUtil.groupBy(deviceInfoContentBreatheList, DeviceInfoContentBreathe::getReportTime);
for (Map.Entry<String, List<DeviceInfoContentBreathe>> entry : minuteMap.entrySet()) {
}*/
return breatheList;
}
return deviceInfoContentBreatheList;
public static String formatLongTime(long time) {
return DEFAULT_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()));
}
public List<DeviceInfoContentSpace> getDeviceLogByTimeRangeSpace(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
......@@ -217,7 +273,7 @@ public class IotProductDeviceService extends IotCommonService {
* @return
*/
public List<DeviceOperationLogEntity> getDeviceLogByTimeRange(String deviceId, String typeValue, int pageSize, String startTime, String endTime) {
IotQueryParam iotQueryParam = buildQueryParam(pageSize);
IotQueryParam iotQueryParam = buildQueryParam(0,pageSize);
List<Term> terms = Lists.newArrayList();
Term term1 = Term.builder()
......@@ -283,7 +339,7 @@ public class IotProductDeviceService extends IotCommonService {
*/
public List<DeviceOperationLogEntity> getDeviceLog(String deviceId, int pageSize, String typeValue) {
String url = iotUrl + DEVICE_PREFIX_URL + deviceId + "/logs";
IotQueryParam iotQueryParam = buildQueryParam(pageSize);
IotQueryParam iotQueryParam = buildQueryParam(0,pageSize);
if (StringUtils.isNotEmpty(typeValue)) {
List<Term> terms = Lists.newArrayList();
Term term = Term.builder()
......
......@@ -7,8 +7,12 @@ public class AnalysisVO {
private Integer totalHr;
private Integer avgHr;
private Integer maxHr;
private Integer minHr;
private Integer totalBr;
private Integer avgBr;
private Integer maxBr;
private Integer minBr;
private Integer actionCount = 0; // 体动次数
private Integer turnedCount = 0; // 翻身次数
......
......@@ -3,6 +3,7 @@ package com.makeit.utils.msg.sender;
import com.makeit.utils.msg.SendTypeEnum;
import com.makeit.utils.msg.dto.MsgSendDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
......@@ -10,6 +11,8 @@ import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
import javax.mail.internet.MimeMessage;
import java.util.Collection;
import java.util.Objects;
@Component
@Slf4j
......@@ -35,7 +38,12 @@ public class MailMsgSender implements IMsgSender {
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from);
helper.setTo(msgDTO.getEmailSet().toArray(new String[msgDTO.getReceiverList().size()]));
Collection<String> emailSet = msgDTO.getEmailSet();
emailSet.removeIf(Objects::isNull);
if(CollectionUtils.isEmpty(emailSet)){
return;
}
helper.setTo(emailSet.toArray(new String[emailSet.size()]));
helper.setSubject(msgDTO.getSubject());
helper.setText(msgDTO.getOriContent(), false);
mailSender.send(message);
......
......@@ -172,7 +172,7 @@
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:alibabacloud-gateway-spi:0.0.1" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:openapiutil:0.1.14" level="project" />
<orderEntry type="library" name="Maven: com.huaweicloud:esdk-obs-java-bundle:3.23.5" level="project" />
<orderEntry type="library" name="Maven: com.huaweicloud:esdk-obs-java-bundle:3.23.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.14.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.14.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
......
......@@ -36,5 +36,12 @@ public class PlatAlarmRecordChildrenController {
public ApiResponseEntity<PlatAlarmRecordVO> view(@RequestBody BaseIdDTO dto) {
return ApiResponseUtils.success(platAlarmRecordService.view(dto.getId()));
}
@ApiOperation("已读")
@PostMapping("read")
public ApiResponseEntity<Void> read(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.read(dto.getId());
return ApiResponseUtils.success();
}
}
......@@ -5,6 +5,7 @@ import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.elder.PlatElderSleepService;
import com.makeit.task.IotSyncTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -28,6 +29,8 @@ public class PlatElderSleepController {
@Autowired
private IotSyncTask iotSyncTask;
@Autowired
private PlatElderSleepService platElderSleepService;
@ApiOperation("测试")
@PostMapping("test")
......@@ -38,6 +41,15 @@ public class PlatElderSleepController {
return ApiResponseUtils.success();
}
@ApiOperation("测试")
@PostMapping("test1")
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<Void> test1() {
platElderSleepService.test1();
return ApiResponseUtils.success();
}
}
......
......@@ -58,6 +58,11 @@ public class PlatAlarmRecordQueryDTO extends BaseTenantDTO {
//子女关联的老人id
private List<String> elderIdList;
/**
* 通知家属状态 0 未通知 1 已通知
*/
private String noticeStatus;
}
......@@ -86,6 +86,9 @@ public class PlatAlarmRecord extends BaseBusEntity {
@ApiModelProperty("区域名称")
private String regionName;
@ApiModelProperty(value = "0-未读 1-已读")
private String readFlag;
}
......
......@@ -6,10 +6,12 @@ import lombok.Data;
/**
* 租户端角色部门关联表
* 角色和所属部门 一对一
* @TableName plat_role_org
*/
@TableName(value ="plat_role_org")
@Data
@Deprecated
public class PlatRoleOrg extends BaseBusEntity {
/**
......
......@@ -61,4 +61,6 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
void getElderListByDeviceId(PlatAlarmCheckDTO platAlarmCheckDTO);
void dealAlarm(BaseIdDTO dto);
void read(String id);
}
package com.makeit.service.platform.alarm.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.dto.BaseIdDTO;
......@@ -120,6 +122,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
String[] split = elderId.split(",");
PlatAlarmRecordQueryDTO data = dto.getData();
data.setElderIdList(Arrays.asList(split));
data.setNoticeStatus(CommonEnum.YES.getValue());
return page(dto);
}
......@@ -139,6 +142,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
qw.or().apply("find_in_set('" + elderId + "',elder_ids)");
}
})
.eq(StringUtils.isNotBlank(param.getNoticeStatus()),PlatAlarmRecord::getNoticeStatus,param.getNoticeStatus())
.orderByDesc(BaseEntity::getCreateDate)
;
}
......@@ -304,6 +308,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
*/
private void noticeByChannel(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord, Set<String> phoneSet,Set<String> emailSet, List<SendTypeEnum> notifyChannelList) {
String notifyChannel = alarmConfig.getNotifyChannel();
if(StringUtils.isEmpty(notifyChannel)){
return;
}
String[] split = notifyChannel.split(",");
for (String sendType : split) {
SendTypeEnum sendTypeEnum = SendTypeEnum.getByValue(sendType);
......@@ -347,6 +354,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
platAlarmRecord.setRemark(platAlarmCheckDTO.getRemark());
platAlarmRecord.setAbnormalValue(platAlarmCheckDTO.getAbnormalValue());
platAlarmRecord.setRegionName(platElder.getRegionName());
platAlarmRecord.setReadFlag(CommonEnum.NO.getValue());
return platAlarmRecord;
}
......@@ -454,4 +463,13 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
platAlarmRecord.setDealDate(LocalDateTime.now());
updateById(platAlarmRecord);
}
@Override
@Transactional
public void read(String id) {
LambdaUpdateWrapper<PlatAlarmRecord> recordLambdaUpdateWrapper = Wrappers.lambdaUpdate(PlatAlarmRecord.class)
.eq(BaseEntity::getId, id)
.set(PlatAlarmRecord::getReadFlag, CommonEnum.YES.getValue());
update(recordLambdaUpdateWrapper);
}
}
......@@ -186,7 +186,10 @@ implements PlatRoleService {
PlatRoleDTOVO vo = BeanDtoVoUtils.convert(getById(id), PlatRoleDTOVO.class);
JoinUtil.join(Arrays.asList(vo), platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> r.setDeptName(e.getName()));
JoinUtil.join(Arrays.asList(vo), platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) ->{
r.setDeptName(e.getName());
r.setOrgPath(e.getPath()+","+e.getId());
} );
List<PlatMenuDTOVO> assignMenuDTO = getAssignMenuDTO(id);
List<PlatMenuDTOVO> tree = tree(assignMenuDTO);
......
......@@ -14,4 +14,6 @@ import com.makeit.entity.platform.elder.PlatElderSleep;
public interface PlatElderSleepService extends IService<PlatElderSleep> {
void elderSleepSleepAnalysisTask();
void test1();
}
......@@ -97,12 +97,21 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
PlatSpaceDeviceQueryDTO dto = pageReqDTO.getData();
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(PlatRoomBedDevice::getDeviceId);
// queryWrapper1.select(PlatRoomBedDevice::getDeviceId);
List<PlatRoomBedDevice> list = list(queryWrapper1);
List<PlatRoomBedDevice> list1 = new ArrayList<>();
if (CommonEnum.NO.getValue().equals(dto.getIsRoom())) {
queryWrapper1.isNotNull(PlatRoomBedDevice::getBedId);
queryWrapper1.eq(PlatRoomBedDevice::getRoomId, dto.getRoomId());
list.forEach(item->{
if(!item.getRoomId().equals(dto.getRoomId())
|| (item.getRoomId().equals(dto.getRoomId()) && StringUtil.isEmpty(item.getBedId()))){
list1.add(item);
}
List<PlatRoomBedDevice> list = list(queryWrapper1);
});
}
List<String> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
String orgId = "";
......
......@@ -107,12 +107,16 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
space.setAddress(dto.getAddress());
space.setLatitude(dto.getLatitude());
space.setLongitude(dto.getLongitude());
space.setParentId(dto.getParentId());
if(StringUtil.isEmpty(dto.getParentPath())){
space.setParentPath(null);
}else {
space.setParentPath(dto.getParentPath());
}
if(StringUtil.isEmpty(dto.getParentId())){
space.setParentId(null);
}else {
space.setParentId(dto.getParentId());
}
//上级空间
PlatSpace parentSpace = this.getById(dto.getParentId());
......@@ -177,6 +181,10 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
.in(PlatSpace::getId, parentIds));
if (CollectionUtils.isNotEmpty(arrayList)) {
spaceList.addAll(arrayList);
spaceList = spaceList.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(PlatSpace::getId))), ArrayList::new));
}
}else {
spaceList = list;
......@@ -370,12 +378,15 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
try {
List<PlatSpace> listPlatSpace = list(new LambdaQueryWrapper<>());
List<PlatSpace> firstSpace = listPlatSpace.stream().filter(item -> item.getParentId() == null).collect(Collectors.toList());
List<PlatSpace> firstSpace = listPlatSpace.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
Map<String, String> firstSpaceNameMap = firstSpace.stream().collect(Collectors.toMap(PlatSpace::getName, PlatSpace::getId, (k1, k2) -> k1));
List<PlatSpace> listChildren = listPlatSpace.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
List<PlatSpace> listChildren = listPlatSpace.stream().filter(item -> StringUtil.isNotEmpty(item.getParentId())).collect(Collectors.toList());
Map<String, List<PlatSpace>> childrenMap = listChildren.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
Map<String, String> childrenIdMap = listChildren.stream().collect(Collectors.toMap(item -> item.getParentId() + item.getName(), item -> item.getId(), (k1, k2) -> k1));
Map<String, String> childrenIdMap = listChildren.stream().collect(Collectors.toMap(item -> item.getParentId() + "-"+item.getName(), item -> item.getId(), (k1, k2) -> k1));
List<PlatRoom> rooms = platRoomService.list();
Map<String,List<PlatRoom>> roomMap = rooms.stream().collect(Collectors.groupingBy(PlatRoom::getSpaceId));
List<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null, 3, excelFile, PlatSpaceImportDTO.class);
......@@ -426,10 +437,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
key = key + "-" + item.getFloor();
}
if (listKey.contains(key)) {
if (listKey.contains(key+"-"+item.getRoomName())) {
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下,房间名已存在"));
errorFlag = true;
}
listKey.add(key+"-"+item.getRoomName());
if (errorFlag) {
errorCount++;
......@@ -530,19 +542,48 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
platRoomDTO.setName(item.getRoomName());
platRoomDTO.setBedNumber(item.getBedNumber());
String spaceId = null;
if (firstId != null) {
spaceId = firstId;
} else if (secondId != null) {
spaceId = secondId;
} else if (threeId != null) {
spaceId = threeId;
} else if (fourId != null) {
int j = 0;
if (fourId != null){
spaceId = fourId;
j = 3;
} else if (threeId !=null){
spaceId = threeId;
j = 2;
} else if (secondId !=null){
spaceId = secondId;
j = 1;
} else if (firstId !=null){
spaceId = firstId;
}
//判断该层级是否最后一级
List<PlatSpace> childSpaes = list(new QueryWrapper<PlatSpace>().lambda()
.eq(PlatSpace::getParentId, spaceId));
if(!childSpaes.isEmpty()){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(j), "该空间存在下级空间,不允许添加房间"));
successCount--;
errorCount++;
continue;
}
platRoomDTO.setSpaceId(spaceId);
platRoomDTO.setSpacePath(spacePath);
platRoomService.add(platRoomDTO);
PlatRoom platRoom = BeanDtoVoUtils.convert(platRoomDTO, PlatRoom.class);
if(roomMap.get(spaceId)!=null ){
List<PlatRoom> roomList = roomMap.get(spaceId);
List<String> roomNames = roomList.stream().map(PlatRoom::getName).collect(Collectors.toList());
if(roomNames.contains(platRoom.getName())){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下,房间名已存在"));
successCount--;
errorCount++;
continue;
}
}
platRoomService.save(platRoom);
platBedService.add(platRoom);
}
}
if(!errorVoList.isEmpty()){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
excelImportVo.setTotalCount(list.size());
excelImportVo.setErrorCount(errorCount);
......
......@@ -59,5 +59,8 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createDate;
@ApiModelProperty(value = "0-未读 1-已读")
private String readFlag;
}
......@@ -7,10 +7,10 @@
<select id="getHealthConfigList" resultType="com.makeit.dto.platform.alarm.PlatHealthConfigDTO">
select pehi.elder_id as platElderId,
pehi.respiratory_rate as heartRateStr,
pehi.respiratory_exception_time as heartDuration,
pehi.heart_rate as breathRateStr,
pehi.heart_exception_time as breathDuration
pehi.respiratory_rate as breathRateStr,
pehi.respiratory_exception_time as breathDuration,
pehi.heart_rate as heartRateStr,
pehi.heart_exception_time as heartDuration
from plat_elder_health_info pehi
left join plat_elder pe on pe.id = pehi.elder_id
where pehi.del_flag = 0
......
......@@ -165,7 +165,7 @@
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:alibabacloud-gateway-spi:0.0.1" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:openapiutil:0.1.14" level="project" />
<orderEntry type="library" name="Maven: com.huaweicloud:esdk-obs-java-bundle:3.23.5" level="project" />
<orderEntry type="library" name="Maven: com.huaweicloud:esdk-obs-java-bundle:3.23.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.14.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.14.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi:5.2.2" level="project" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment