Commit 30bb5321 by 杨伟程
parents e8aa2f25 9482ace1
Showing with 432 additions and 117 deletions
......@@ -13,6 +13,7 @@ import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.utils.old.StringUtils;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.elder.PlatElderListVO;
......@@ -45,6 +46,10 @@ public class IotPlatExternalController {
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PageVO<PlatElderListVO>> elderPage(@RequestBody PageReqDTO<PlatElderQueryDTO> page) {
PlatElderQueryDTO dto = page.getData();
if (dto == null || StringUtils.isEmpty(dto.getOrgId())) {
return ApiResponseUtils.success(new PageVO<>());
}
return ApiResponseUtils.success(platElderService.page(page));
}
......@@ -54,6 +59,10 @@ public class IotPlatExternalController {
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PageVO<PlatDeviceListVO>> devicePage(@RequestBody PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
PlatDeviceQueryDTO dto = pageReqDTO.getData();
if (dto == null || StringUtils.isEmpty(dto.getOrgId())) {
return ApiResponseUtils.success(new PageVO<>());
}
return ApiResponseUtils.success(platDeviceService.page(pageReqDTO));
}
......@@ -62,8 +71,12 @@ public class IotPlatExternalController {
@PostMapping("alarmRecordPage")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PageVO<PlatAlarmRecordVO>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
return ApiResponseUtils.success(platAlarmRecordService.page(dto));
public ApiResponseEntity<PageVO<PlatAlarmRecordVO>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> pageReqDTO) {
PlatAlarmRecordQueryDTO dto = pageReqDTO.getData();
if (dto == null || StringUtils.isEmpty(dto.getOrgId())) {
return ApiResponseUtils.success(new PageVO<>());
}
return ApiResponseUtils.success(platAlarmRecordService.page(pageReqDTO));
}
@ApiOperation("处理告警回调")
......
......@@ -38,11 +38,12 @@ public class RSAUtils {
System.out.println(keys);
RSAPublicKey publicKey = getPublicKey(keys.get("publicKey"));
RSAPrivateKey privateKey = getPrivateKey(keys.get("privateKey"));
String encrypt = publicEncrypt("{\"page\":1,\"limit\":10,\"data\":{}}", publicKey, "UTF-8");
System.out.println(encrypt);
RSAPrivateKey privateKey = getPrivateKey(keys.get("privateKey"));
String decrypt = privateDecrypt(encrypt, privateKey, "UTF-8");
System.out.println(decrypt);
......@@ -120,7 +121,8 @@ public class RSAUtils {
try {
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return Base64.encodeBase64URLSafeString(rsaSplitCodec(cipher, Cipher.ENCRYPT_MODE, data.getBytes(encoding), publicKey.getModulus().bitLength()));
return Base64.encodeBase64URLSafeString(rsaSplitCodec(cipher, Cipher.ENCRYPT_MODE, data.getBytes(encoding),
publicKey.getModulus().bitLength()));
} catch (Exception e) {
throw new RuntimeException("加密字符串[" + data + "]时遇到异常", e);
}
......
......@@ -107,13 +107,14 @@ public enum CodeMessageEnum {
PLATFORM_ERROR_SPACE_NOT_DEL(500, "PLATFORM.ERROR.SPACE.NOT.DEL"),
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT(500, "PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT"),
PLATFORM_ERROR_SPACE_USER_NOT_ADD(500, "PLATFORM.ERROR.SPACE.USER.NOT.ADD"),
PLATFORM_ERROR_ROOM_EXIT_BAD(500, "PLATFORM.ERROR.ROOM.EXIT.BAD"),
PLATFORM_ERROR_ROOM_BAD_NUMBER_NOT_AUTH(500, "PLATFORM.ERROR.ROOM.BAD.NUMBER.NOT.AUTH"),
PLATFORM_ERROR_ROOM_EXIT_BAD(500, "PLATFORM.ERROR.ROOM.EXIT.BED"),
PLATFORM_ERROR_ROOM_BAD_NUMBER_NOT_AUTH(500, "PLATFORM.ERROR.ROOM.BED.NUMBER.NOT.AUTH"),
PLATFORM_ERROR_ROOM_NAME_EXIT(500, "PLATFORM.ERROR.ROOM.NAME.EXIT"),
PLATFORM_ERROR_BAD_NAME_EXIT(500, "PLATFORM.ERROR.BAD.NAME.EXIT"),
PLATFORM_ERROR_BAD_NOT_DEL(500, "PLATFORM.ERROR.BAD.NOT.DEL"),
PLATFORM_ERROR_BAD_NAME_EXIT(500, "PLATFORM.ERROR.BED.NAME.EXIT"),
PLATFORM_ERROR_BAD_NOT_DEL(500, "PLATFORM.ERROR.BED.NOT.DEL"),
PLATFORM_ERROR_BED_NOT_BIND_ELDER(500,"PLATFORM.ERROR.BED.NOT.BIND.ELDER"),
PLATFORM_ERROR_ROOM_OTHER_USED_NOT_DEL(500, "PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL"),
PLATFORM_ERROR_BED_BIND_DEVICE_NOT_AUTH(500, "PLATFORM.ERROR.BED.BIND_DEVICE_NOT_AUTH"),
PLATFORM_ERROR_BED_BIND_DEVICE_NOT_AUTH(500, "PLATFORM.ERROR.BED.BIND.DEVICE.NOT.AUTH"),
PLATFORM_ERROR_ELDER_BED_CANT_DEL(500, "PLATFORM.ERROR.ELDER.BED.CANT.DEL"),
......
......@@ -24,4 +24,6 @@ public class HeaderConst {
public static final String FEIGN_NO_REMOVE="feignNoRemove";
public static final String DATA_SCOPE = "data-scope";
public static final String ROLE_ID = "role-id";
}
......@@ -24,7 +24,10 @@ import java.util.Set;
public class PlatAuthorizationInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//todo 按钮权限关闭
if(true){
return true;
}
Action annotation;
if (handler instanceof HandlerMethod) {
......
......@@ -54,6 +54,7 @@ public class PlatTenantDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "菜单id集合")
private List<String> menuIdList;
@Size(max = 20, message = "租户标识最长为20字符")
@ApiModelProperty(value = "租户标识")
private String code;
......
......@@ -72,6 +72,11 @@ public class PlatUserLoginVO implements Serializable {
private boolean initFlag = false;
/**
* 当前账号选择的右上角角色
*/
private String currentRoleId;
public void init(){
if(initFlag){
......
......@@ -14,6 +14,8 @@ import com.makeit.module.iot.vo.ResponseMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -47,6 +49,12 @@ public class IotCommonService {
ResponseMessage responseMessage = getResponseMessage(url, response);
return responseMessage;
}
public ResponseMessage sendPatch(String url, HttpRequest request) throws IOException {
Response response = request.patch();
ResponseMessage responseMessage = getResponseMessage(url, response);
return responseMessage;
}
public ResponseMessage sendGet(String url, HttpRequest request) throws IOException {
Response response = request.get();
ResponseMessage responseMessage = getResponseMessage(url, response);
......
......@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.makeit.module.iot.dto.IotQueryParam;
import com.makeit.module.iot.dto.IotSort;
import com.makeit.module.iot.dto.Term;
......@@ -23,12 +24,14 @@ 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.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
/**
* iot产品设备相关接口
......@@ -69,6 +72,30 @@ public class IotProductDeviceService extends IotCommonService {
return Lists.newArrayList();
}
@Async
public void syncUpdateDeviceInfo(String id, String name, String productId) {
String url = iotUrl + "/device-instance";
Map<String,Object> reqMap = Maps.newHashMap();
reqMap.put("id",id);
reqMap.put("name",name);
reqMap.put("productId",productId);
String body = JsonUtil.toJson(reqMap);
HttpRequest request = buildRequest(url, body);
request.encode("UTF-8");
request.contentType("application/json");
try {
ResponseMessage responseMessage = sendPatch(url, request);
if (responseMessage.getStatus() == 200) {
log.info("修改设备名称成功:{}",id);
} else {
log.error("获取设备接口失败:{}", responseMessage.getMessage());
}
} catch (IOException e) {
log.error("调用:{}接口异常:{}", url, e.getMessage());
}
}
/**
* 获取最新一条设备日志
*
......@@ -104,13 +131,13 @@ public class IotProductDeviceService extends IotCommonService {
}
DeviceInfoContentBreathe breathe = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentBreathe.class);
return breathe;
LocalDateTime time = LongTimestampUtil.toLocalDateTime(breathe.getTimestamp());
/* LocalDateTime time = LongTimestampUtil.toLocalDateTime(breathe.getTimestamp());
if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) {
return null;
}
}*/
return breathe;
}
......
......@@ -33,5 +33,7 @@ public class MsgSendDTO {
this.param = param;
}
private String alarmType;
}
......@@ -19,7 +19,6 @@ import java.net.URLEncoder;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.stream.Collectors;
@Component
@Slf4j
......@@ -49,25 +48,31 @@ public class SmsMsgSender implements IMsgSender{
Date now = new Date();
String time = String.valueOf(now.getTime());
Collection<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(","));
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiverJoin);
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
log.error("发送短信失败:"+jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code"));
}else {
log.info("发送短信成功");
for (String receiver : receiverList) {
try {
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiver);
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
log.error("发送短信失败:" + jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code"));
} else {
log.info("发送短信成功");
}
}catch (Exception e){
log.error("发送短信异常:",msgDTO,e);
}
}
}catch (Exception e){
log.error("发送短信异常:",msgDTO,e);
}
......
......@@ -21,7 +21,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
@Component
@Slf4j
......@@ -48,35 +47,62 @@ public class SmsVoiceSender implements IMsgSender{
if(CollectionUtils.isEmpty(msgDTO.getReceiverList())){
log.info("发送语音短信时,没有接收人,短信内容:"+msgDTO.getOriContent());
}
String alarmType = msgDTO.getAlarmType();
Date now = new Date();
//todo 支持同时发送多个老人
String time = String.valueOf(now.getTime());
Collection<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(","));
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsVoiceConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsVoiceConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiverJoin);
String[] param = msgDTO.getParam();
List<BiConsumer<HashMap<String,String>,String>> consumerList = Arrays.asList(
(t,v)->t.put("one",v),
(t,v)->t.put("two",v)
receiverList.forEach(
vo->{
try {
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsVoiceConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = null;
md16 = CryptoUtil.md5_16(smsVoiceConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", vo);
//告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常
if (StringUtils.equals(alarmType, "1")) {
paramMap.put("vid", "142");
}
if (StringUtils.equals(alarmType, "2")) {
paramMap.put("vid", "143");
}
if (StringUtils.equals(alarmType, "3")) {
paramMap.put("vid", "144");
}
if (StringUtils.equals(alarmType, "4")) {
paramMap.put("vid", "145");
}
String[] param = msgDTO.getParam();
List<BiConsumer<HashMap<String, String>, String>> consumerList = Arrays.asList(
(t, v) -> t.put("one", v),
(t, v) -> t.put("two", v)
);
for (int i = 0; i < param.length; i++) {
BiConsumer<HashMap<String, String>, String> biConsumer = consumerList.get(i);
biConsumer.accept(paramMap, param[i]);
}
String resStr = HttpClient.sendJSONPostRequest(smsVoiceConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
log.error("发送语音短信失败:" + jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code"));
}
log.info("发送语音短信成功");
}catch (Exception e){
log.error("发送语音异常:",vo,msgDTO,e);
}
}
);
for (int i = 0; i < param.length; i++) {
BiConsumer<HashMap<String, String>, String> biConsumer = consumerList.get(i);
biConsumer.accept(paramMap,param[i]);
}
String resStr = HttpClient.sendJSONPostRequest(smsVoiceConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
log.error("发送语音短信失败:"+jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code"));
}
log.info("发送语音短信成功");
}catch (Exception e){
log.error("发送语音异常:",msgDTO,e);
}
......
......@@ -21,7 +21,7 @@ public class CommonUserUtil {
WechatUserInfo wechatUserInfo = ThreadLocalUserUtil.getWechatUser();
if (wechatUserInfo != null) {
return new CommonUserVO(wechatUserInfo.getId(), wechatUserInfo.getName());
return new CommonUserVO(wechatUserInfo.getId(), wechatUserInfo.getUsername());
}
SaasUserLoginVO saasUser = ThreadLocalUserUtil.getSaasUser();
......@@ -54,7 +54,7 @@ public class CommonUserUtil {
if (StringUtils.isNotBlank(wechatToken)) {
WechatUserInfo wechatUserInfo = TokenUtil.getWechatUserDetail(wechatToken);
if (wechatUserInfo != null) {
return new CommonUserVO(wechatUserInfo.getId(), wechatUserInfo.getName());
return new CommonUserVO(wechatUserInfo.getId(), wechatUserInfo.getUsername());
}
}
......
......@@ -25,7 +25,7 @@ public class WechatUserInfo implements Serializable {
private String openid;
@ApiModelProperty(value = "姓名")
private String name;
private String username;
@ApiModelProperty(value = "手机号码")
private String phone;
......
......@@ -100,14 +100,15 @@ PLATFORM.ERROR.SPACE.NAME.DUPLICATE=同一层级,空间名称不能重复
PLATFORM.ERROR.SPACE.NOT.DEL=该空间下存在下级或者房间,不可删除
PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT=上级空间不能是自己的下级空间
PLATFORM.ERROR.SPACE.USER.NOT.ADD=当前用户没有所属组织,请先分配组织
PLATFORM.ERROR.ROOM.EXIT.BAD=房间中存在已入住的床位,不可删除
PLATFORM.ERROR.ROOM.EXIT.BED=房间中存在已入住的床位,不可删除
PLATFORM.ERROR.ROOM.NAME.EXIT=该房间名称已存在
PLATFORM.ERROR.ROOM.BAD.NUMBER.NOT.AUTH=床位数量不能改小
PLATFORM.ERROR.BAD.NAME.EXIT=床位名称已存在
PLATFORM.ERROR.BAD.NOT.DEL=床位已绑定长者或设备,不可删除
PLATFORM.ERROR.ROOM.BED.NUMBER.NOT.AUTH=床位数量不能改小
PLATFORM.ERROR.BED.NAME.EXIT=床位名称已存在
PLATFORM.ERROR.BED.NOT.DEL=床位已绑定长者或设备,不可删除
PLATFORM.ERROR.BED.NOT.BIND.ELDER=床位已入住长者,不可再次入住
PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=该房间下有床位有其他长者入住
PLATFORM.ERROR.BED.BIND_DEVICE_NOT_AUTH=该床位已绑定设备,请重新选择床位
PLATFORM.ERROR.BED.BIND.DEVICE.NOT.AUTH=该床位已绑定设备,请重新选择床位
PLATFORM.ERROR.ELDER.BED.CANT.DEL=含入住床位的老人,不可删除
......
......@@ -87,6 +87,13 @@ public class PlatSpaceController {
return ApiResponseUtils.success(data);
}
@ApiOperation("树-到床位(未住人床位)-根据老人组织")
@PostMapping("listTreeAuthIgnoreByElder")
public ApiResponseEntity<List<PlatSpaceVO>> listTreeAuthIgnoreByElder(@RequestBody PlatSpaceQueryDTO dto) {
List<PlatSpaceVO> data = spaceService.listBedTreeByElderGroup(dto,true);
return ApiResponseUtils.success(data);
}
@ApiOperation("树-到床位")
@PostMapping("listBedTree")
public ApiResponseEntity<List<PlatSpaceVO>> listBedTreeAuthIgnore(@RequestBody PlatSpaceQueryDTO dto) {
......@@ -97,7 +104,7 @@ public class PlatSpaceController {
@ApiOperation(value = "导出模板")
@PostMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
ExcelUtil.exportTemplate(response, "空间导入模板" + FileSuffixEnum.EXCEL.getSuffix(), PlatSpaceImportDTO.class);
ExcelUtil.exportTemplate(response, "空间导入模板" + FileSuffixEnum.EXCEL.getSuffix(), "空间导入模板", PlatSpaceImportDTO.class);
}
......
......@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Controller
*
......@@ -15,4 +17,7 @@ import lombok.Data;
public class PlatOrgDTO {
@ApiModelProperty(value = "类型 1-居家 2-机构")
private String type;
@ApiModelProperty(value = "组织ids")
private List<String> orgIds;
}
......@@ -15,4 +15,7 @@ public class PlatSpaceQueryDTO {
@ApiModelProperty("空间名称")
private String name;
@ApiModelProperty("长者ID")
private String elderId;
}
......@@ -28,6 +28,9 @@ public class PlatSpaceVO extends BaseIdDTO {
@ApiModelProperty("属性 1-居家 2-机构")
private String attribute;
@ApiModelProperty("上级路径")
private String patentPath;
@ApiModelProperty("子集")
private List<PlatSpaceVO> children;
}
......@@ -19,7 +19,7 @@ public class PlatRegionSetting extends BaseBusEntity {
/**
* 数据字典:device.install
*/
@ApiModelProperty("安装方式 0-顶装 1-侧装")
@ApiModelProperty("安装方式 1-顶装 0-侧装")
private String installType;
/**
......
......@@ -119,6 +119,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
return new PageVO<>();
}
String elderId = platElderChildrenInfo.getElderId();
if(StringUtils.isBlank(elderId)){
return new PageVO<>();
}
String[] split = elderId.split(",");
PlatAlarmRecordQueryDTO data = dto.getData();
data.setElderIdList(Arrays.asList(split));
......@@ -128,6 +131,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
private LambdaQueryWrapper<PlatAlarmRecord> getLambdaQueryWrapper(PlatAlarmRecordQueryDTO param) {
return new LambdaQueryWrapper<PlatAlarmRecord>().ge(Objects.nonNull(param.getCreateDateFrom()), BaseEntity::getCreateDate, param.getCreateDateFrom())
.eq(StringUtils.isNotBlank(param.getId()),BaseEntity::getId,param.getId())
.le(Objects.nonNull(param.getCreateDateTo()), BaseEntity::getCreateDate, param.getCreateDateTo())
.eq(StringUtils.isNotBlank(param.getAlarmType()), PlatAlarmRecord::getAlarmType, param.getAlarmType())
.eq(StringUtils.isNotBlank(param.getStatus()), PlatAlarmRecord::getStatus, param.getStatus())
......@@ -323,6 +327,21 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
msgSendDTO.setOriContent(alarmRecord.getContent());
msgSendDTO.setSubject(alarmRecord.getContent());
msgSendDTO.setParam(alarmRecord.getElderName());
String alarmType = alarmConfig.getAlarmType();
//告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常
if (StringUtils.equals(alarmType, "1")) {
msgSendDTO.setParam(alarmRecord.getElderName(),alarmRecord.getRegionName());
}
if (StringUtils.equals(alarmType, "2")) {
msgSendDTO.setParam(alarmRecord.getElderName(),alarmRecord.getRemark());
}
if (StringUtils.equals(alarmType, "3")) {
msgSendDTO.setParam(alarmRecord.getElderName(),alarmRecord.getRemark());
}
if (StringUtils.equals(alarmType, "4")) {
msgSendDTO.setParam(alarmRecord.getElderName(),alarmRecord.getRegionName());
}
msgSendDTO.setAlarmType(alarmConfig.getAlarmType());
//todo 小程序消息
msgUtil.send(msgSendDTO);
}
......
......@@ -30,6 +30,7 @@ import com.makeit.entity.saas.PlatTenant;
import com.makeit.entity.saas.PlatTenantMenu;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.HeaderConst;
import com.makeit.enums.IsTenantAccountEnum;
import com.makeit.enums.biz.auth.SysEnum;
import com.makeit.enums.id.TreeConst;
......@@ -61,6 +62,7 @@ import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.excel.ExcelUtil;
import com.makeit.utils.data.excel.ExcelValidatorUtil;
import com.makeit.utils.data.id.IdGen;
import com.makeit.utils.request.RequestUtil;
import com.makeit.utils.sql.groupby.DynamicQuery;
import com.makeit.utils.sql.groupby.SqlUtil;
import com.makeit.utils.sql.join.JoinUtil;
......@@ -537,9 +539,15 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
private List<PlatMenu> getMenuListByUserId(PlatUserLoginVO userLoginVO) {
String currentRoleId = userLoginVO.getCurrentRoleId();
List<String> roleIdList = new ArrayList<>();
if(StringUtils.isBlank(currentRoleId)) {
List<PlatRole> roleList = getRoleList(userLoginVO.getId());
roleIdList = StreamUtil.map(roleList, PlatRole::getId);
}else {
roleIdList.add(currentRoleId);
}
List<PlatRole> roleList = getRoleList(userLoginVO.getId());
List<String> roleIdList = StreamUtil.map(roleList, PlatRole::getId);
roleIdList.add(-1 + "");
List<PlatRoleMenu> roleMenuList = platRoleMenuService.list(new QueryWrapper<PlatRoleMenu>().lambda()
......@@ -554,7 +562,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.orderByAsc(PlatMenu::getCreateDate)
);
userLoginVO.setRoleList(BeanDtoVoUtils.listVo(roleList, PlatRoleDTOVO.class));
//userLoginVO.setRoleList(BeanDtoVoUtils.listVo(roleList, PlatRoleDTOVO.class));
if (StringUtils.isNotBlank(userLoginVO.getTenantId())) {
Set<String> menuIdSet = StreamUtil.mapToSet(getMenuListByTenantId(userLoginVO.getTenantId()), PlatMenu::getId);
......@@ -589,6 +597,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return userLoginVO;
}
userLoginVO.setCurrentRoleId(RequestUtil.getHeader(HeaderConst.ROLE_ID));
List<PlatMenu> menuList = getMenuListByUserId(userLoginVO);
fillMenuList(menuList, userLoginVO);
......
......@@ -26,6 +26,7 @@ import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.device.PlatDeviceOtherService;
......@@ -71,6 +72,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private PlatTenantService platTenantService;
@Autowired
private PlatRegionSettingService platRegionSettingService;
@Autowired
private IotProductDeviceService iotProductDeviceService;
@Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
......@@ -119,12 +122,13 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
check(dto);
PlatDevice db = getById(dto.getId());
BeanUtils.copyProperties(dto, db);
BeanUtils.copyProperties(dto, db,BaseBusEntity.Fields.tenantId);
updateById(db);
deviceCacheUtil.put(db);
// iotProductDeviceService.syncUpdateDeviceInfo(db.getOriDeviceId(),dto.getName(),db.getProductId());
}
@Override
......
......@@ -182,17 +182,20 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
.le(PlatElderSleepAnalysis::getHappenDate, dateTimeFormatter.format(weekEndDate))
);
if (CollectionUtils.isEmpty(sleepAnalysisList)) {
return null;
}
int score = 0;
int sleepDuration = 0;
int restDuration = 0;
if (CollectionUtils.isNotEmpty(sleepAnalysisList)) {
score = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getSleepScore() + ""), 0, Integer::sum) / sleepAnalysisList.size();
score = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getSleepScore() + ""), 0, Integer::sum) / sleepAnalysisList.size();
sleepDuration = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getSleepTime() + ""), 0, Integer::sum) / sleepAnalysisList.size();
sleepDuration = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getSleepTime() + ""), 0, Integer::sum) / sleepAnalysisList.size();
restDuration = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getRestTime() + ""), 0, Integer::sum) / sleepAnalysisList.size();
restDuration = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getRestTime() + ""), 0, Integer::sum) / sleepAnalysisList.size();
}
PlatElderSleepEvaluationVO platElderSleepEvaluationVO = new PlatElderSleepEvaluationVO();
platElderSleepEvaluationVO.setScore(score);
......
......@@ -102,6 +102,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
@Override
public PlatElderComprehensiveEvaluationVO comprehensiveEvaluation(PlatElderReportDTO platElderIdDTO) {
PlatElderSleepEvaluationVO platElderSleepEvaluationVO = sleepEvaluation(platElderIdDTO);
if (platElderSleepEvaluationVO == null) {
return new PlatElderComprehensiveEvaluationVO();
}
PlatElderHeartRespiratoryEvaluationVO platElderHeartRespiratoryEvaluationVO = heartRespiratoryEvaluation(platElderIdDTO);
return platElderDayReportWeekService.comprehensiveEvaluationInternal(platElderSleepEvaluationVO, platElderHeartRespiratoryEvaluationVO);
......
......@@ -520,6 +520,16 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
}
private void checkBed(PlatElderAddDTO dto) {
PlatBed platBed = platBedService.getById(dto.getBedId());
if (CommonEnum.NO.getValue().equals(platBed.getStatus())) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_BED_BIND_DEVICE_NOT_AUTH);
}
}
private void fillSpace(PlatElder platElder) {
if (StringUtils.isBlank(platElder.getBedId())) {
......@@ -544,6 +554,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
public void add(PlatElderAddDTO dto) {
check(dto);
checkBed(dto);
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
......
......@@ -98,7 +98,11 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
public void elderSleepSleepAnalysisTask() {
List<String> dayHourRangeList = getLastDayHourRange();
String currentDate = DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN);
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH, -1);
Date previousDate = calendar.getTime();
String currentDate = DateUtil.format(previousDate, DatePattern.NORM_DATE_PATTERN);
SaasSleepAnalysisModel analysisModel = saasSleepAnalysisModelService.getOne(new QueryWrapper<SaasSleepAnalysisModel>().lambda()
.orderByDesc(BaseEntity::getCreateBy)
......@@ -157,8 +161,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
continue;
}
String tenantId = elder.getTenantId();
/* String reportStartTime = "";
String reportEndTime = "";*/
String reportStartTime = "";
String reportEndTime = "";
for (String hourRange : dayHourRangeList) {
String[] hourRangeArray = hourRange.split("~");
List<DeviceOperationLogEntity> deviceOperationLogEntities = productDeviceService.getDeviceLogByTimeRange(platDevice.getOriDeviceId(), "reportProperty", 5000, hourRangeArray[0], hourRangeArray[1]);
......@@ -180,10 +184,10 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
Map<String, AnalysisVO> statisticsMap = Maps.newHashMap();
List<DeviceInfoContentBreathe> deviceInfoContentBreathes;
for (Map.Entry<String, List<DeviceInfoContentBreathe>> entry : minuteMap.entrySet()) {
/* if (StringUtils.isEmpty(reportStartTime)) {
if (StringUtils.isEmpty(reportStartTime)) {
reportStartTime = entry.getKey();
}
reportEndTime = entry.getKey();*/
reportEndTime = entry.getKey();
deviceInfoContentBreathes = entry.getValue();
DeviceInfoContentBreathe.Properties breatheProperties;
......@@ -500,10 +504,10 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
int timeHourRange = 24;
/* if (StringUtils.isNotEmpty(reportStartTime) && StringUtils.isNotEmpty(reportEndTime)) {
if (StringUtils.isNotEmpty(reportStartTime) && StringUtils.isNotEmpty(reportEndTime)) {
Long durationRange = getDurationRange(reportStartTime, reportEndTime);
timeHourRange = (int) (durationRange / 60);
}*/
}
// 判断是否满足配置的呼吸心率异常类型
BigDecimal dayBrStopRate = brStopCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(brStopCount), 2, RoundingMode.HALF_UP);
......@@ -610,7 +614,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
platElderBreatheAbnormal.setTenantId(tenantId);
platElderBreatheAbnormalList.add(platElderBreatheAbnormal);
}
// platElderBreatheAbnormalService.saveBatch(platElderBreatheAbnormalList);
//platElderBreatheAbnormalService.saveBatch(platElderBreatheAbnormalList);
int totalActionCount = 0;
......@@ -1030,7 +1034,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
elderSleep.setTenantId(tenantId);
}
// TODO 起床时间和入睡时间
//platElderSleepService.saveBatch(elderSleepList);
platElderSleepService.saveBatch(elderSleepList);
EvaluateReportVO elderReport = saasElderReportConfigService.getByScore(totalScore);
......@@ -1048,7 +1052,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
elderSleepAnalysis.setSleepResult(sleepReport.getResult());
elderSleepAnalysis.setTenantId(tenantId);
elderSleepAnalysis.setSleepEvaluate(elderReport == null ? "" : elderReport.getEvaluate());
// platElderSleepAnalysisService.save(elderSleepAnalysis);
platElderSleepAnalysisService.save(elderSleepAnalysis);
}
}
......
......@@ -82,4 +82,15 @@ public interface PlatSpaceService extends IService<PlatSpace> {
List<PlatSpaceVO> parentListTree(PlatSpaceQueryDTO dto);
List<PlatSpaceVO> listBedTree(PlatSpaceQueryDTO dto, boolean flag);
/**
* 根据老人组织过滤空间
* @param dto
* @param flag
* @return
*/
List<PlatSpaceVO> listBedTreeByElderGroup(PlatSpaceQueryDTO dto, boolean flag);
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.dto.platform.space.PlatRegionSettingDTO;
import com.makeit.dto.platform.space.PlatRegionSettingLocateDTO;
import com.makeit.dto.platform.space.PlatRegionSettingQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.entity.platform.space.PlatRegionSetting;
......@@ -66,7 +67,7 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
.in(PlatDeviceOther::getDeviceId,listDeviceId));
}
Map<String,String> map = platDeviceOthers.stream().collect(Collectors.toMap(PlatDeviceOther::getDeviceId,PlatDeviceOther::getInstallation));
Map<String,String> map = platDeviceOthers.stream().collect(Collectors.toMap(PlatDeviceOther::getDeviceId,PlatDeviceOther::getAttribute));
List<PlatRegionSetting> list = new ArrayList<>();
listDeviceId.forEach(item->{
......@@ -74,7 +75,9 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
platRegionSetting.setDeviceId(item);
platRegionSetting.setRoomId(roomId);
if(map.get(item)!=null){
platRegionSetting.setInstallType(map.get(item));
String attribute = map.get(item);
PlatDeviceAttrWechatDTO deviceAttrWechatDTO = JsonUtil.toObj(attribute,PlatDeviceAttrWechatDTO.class);
platRegionSetting.setInstallType(deviceAttrWechatDTO.getRadarMount()+"");
}
list.add(platRegionSetting);
});
......
......@@ -105,20 +105,24 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
list.forEach(item->{
if(!item.getRoomId().equals(dto.getRoomId())
|| (item.getRoomId().equals(dto.getRoomId()) && StringUtil.isEmpty(item.getBedId()))){
|| (item.getRoomId().equals(dto.getRoomId()) && StringUtil.isNotEmpty(item.getBedId()))){
list1.add(item);
}
});
}
List<String> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
List<String> listEquipmentIds = list1.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
String orgId = "";
if (StringUtil.isNotEmpty(dto.getRoomId())) {
PlatRoom platRoom = platRoomService.getById(dto.getRoomId());
PlatSpace platSpace = platSpaceService.getById(platRoom.getSpaceId());
orgId = platSpace.getOrgId();
if(platRoom != null){
PlatSpace platSpace = platSpaceService.getById(platRoom.getSpaceId());
if(platSpace != null){
orgId = platSpace.getOrgId();
}
}
}
......
......@@ -9,6 +9,7 @@ import com.makeit.common.vo.ExcelErrorVo;
import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.space.*;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatSpace;
......@@ -18,6 +19,7 @@ import com.makeit.enums.platform.space.PlatSpaceEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatSpaceMapper;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
......@@ -53,6 +55,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
private PlatBedService platBedService;
@Autowired
private PlatOrgService platOrgService;
@Autowired
private PlatElderService platElderService;
private void check(PlatSpaceAddDTO dto) {
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
......@@ -366,6 +370,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
vo.setParentId(space.getParentId());
vo.setId(space.getId());
vo.setAttribute(space.getAttribute());
vo.setPatentPath(space.getParentPath());
return vo;
}
......@@ -387,6 +392,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
List<PlatRoom> rooms = platRoomService.list();
Map<String,List<PlatRoom>> roomMap = rooms.stream().collect(Collectors.groupingBy(PlatRoom::getSpaceId));
List<String> lastSpaceIds = rooms.stream().filter(t->StringUtil.isNotEmpty(t.getSpaceId())).map(PlatRoom::getSpaceId).collect(Collectors.toList());
List<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null, 3, excelFile, PlatSpaceImportDTO.class);
......@@ -454,6 +460,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if (errorVoList.isEmpty()) {
for (int i = 0; i < list.size(); i++) {
boolean flag = false;
PlatSpaceImportDTO item = list.get(i);
......@@ -474,10 +481,19 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
spacePath = firstId;
}
if(lastSpaceIds.contains(firstId)){
flag = true;
}
//第二层级
String secondId = null;
if (StringUtil.isNotEmpty(item.getBuilding())) {
if(flag){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下存在房间,不允许添加下级空间"));
successCount--;
errorCount++;
continue;
}
String secondKey = firstId + "-" + item.getBuilding();
if (!childrenIdMap.containsKey(secondKey)) {
PlatSpace platSpace = new PlatSpace();
......@@ -493,12 +509,20 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
secondId = childrenIdMap.get(secondKey);
}
spacePath = spacePath + "," + secondId;
if(lastSpaceIds.contains(secondId)){
flag = true;
}
}
//第三级
String threeId = null;
if (StringUtil.isNotEmpty(item.getUnit())) {
if(flag){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(1), "该空间下存在房间,不允许添加下级空间"));
successCount--;
errorCount++;
continue;
}
String threeKey = secondId + "-" + item.getUnit();
if (!childrenIdMap.containsKey(threeKey)) {
PlatSpace platSpace = new PlatSpace();
......@@ -514,12 +538,20 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
threeId = childrenIdMap.get(threeKey);
}
spacePath = spacePath + "," + threeId;
if(lastSpaceIds.contains(secondId)){
flag = true;
}
}
//第四级
String fourId = null;
if (StringUtil.isNotEmpty(item.getFloor())) {
if(flag){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(2), "该空间下存在房间,不允许添加下级空间"));
successCount--;
errorCount++;
continue;
}
String fourKey = threeId + "-" + item.getFloor();
if (!childrenIdMap.containsKey(fourKey)) {
PlatSpace platSpace = new PlatSpace();
......@@ -540,7 +572,12 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
//房间
PlatRoomDTO platRoomDTO = new PlatRoomDTO();
platRoomDTO.setName(item.getRoomName());
platRoomDTO.setBedNumber(item.getBedNumber());
if(item.getBedNumber()!=null){
platRoomDTO.setBedNumber(item.getBedNumber());
}else {
platRoomDTO.setBedNumber(0);
}
String spaceId = null;
int j = 0;
if (fourId != null){
......@@ -707,6 +744,87 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
@Override
public List<PlatSpaceVO> listBedTreeByElderGroup(PlatSpaceQueryDTO dto, boolean flag) {
PlatElder platElder = platElderService.getById(dto.getElderId());
List<String> orgIds = new ArrayList<>();
orgIds.add("-1");
if(platElder != null){
orgIds.add(platElder.getOrgId());
}
//床位
LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>();
List<PlatBed> listBeds = platBedService.list(queryWrapper1);
if(flag){
PlatBed bed = null;
if(platElder != null && StringUtil.isNotEmpty(platElder.getBedId())){
bed = listBeds.stream().filter(item->item.getId().equals(platElder.getBedId())).collect(Collectors.toList()).get(0);
}
listBeds = listBeds.stream().filter(item->CommonEnum.YES.getValue().equals(item.getStatus())).collect(Collectors.toList());
if(bed != null){
listBeds.add(bed);
}
}
if(listBeds.isEmpty()){
return new ArrayList<>();
}
List<String> roomIds = listBeds.stream().map(PlatBed::getRoomId).collect(Collectors.toList());
List<PlatRoom> listRoom = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getId, roomIds));
List<String> spaceIds = listRoom.stream().map(PlatRoom::getSpacePath).collect(Collectors.toList());
Set<String> spaceIdList = new HashSet<>();
for(String spaceId : spaceIds){
spaceIdList.addAll(Arrays.asList(spaceId.split(",")));
}
spaceIdList.add("-1");
List<PlatSpaceVO> listRoomVo = new ArrayList<>();
listRoom.forEach(item -> {
PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId());
vo.setName(item.getName());
vo.setParentId(item.getSpaceId());
listRoomVo.add(vo);
});
listBeds.forEach(item -> {
PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId());
vo.setName(item.getName());
vo.setParentId(item.getRoomId());
listRoomVo.add(vo);
});
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatSpace::getName, dto.getName());
queryWrapper.in(PlatSpace::getId, spaceIdList);
queryWrapper.in(PlatSpace::getOrgId, orgIds);
List<PlatSpace> list = this.list(queryWrapper);
List<PlatSpaceVO> listSpaceVo = BeanDtoVoUtils.listVo(list, PlatSpaceVO.class);
listSpaceVo.addAll(listRoomVo);
//父级
List<PlatSpaceVO> listParent = listSpaceVo.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).
collect(Collectors.toList());
//子集
List<PlatSpaceVO> listChild = listSpaceVo.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
Map<String, List<PlatSpaceVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceVO::getParentId));
List<PlatSpaceVO> data = new ArrayList<>();
for (PlatSpaceVO space : listParent) {
space = childVo(space, map);
data.add(space);
}
return data;
}
}
......
......@@ -170,17 +170,20 @@ public class WorkStationServiceImpl implements WorkStationService {
public PageVO<WorkStationInstitutionRoomVO> institutionPage(PageReqDTO<WorkStationQueryDTO> page) {
WorkStationQueryDTO dto = page.getData();
List<PlatSpace> spaces = new ArrayList<>();
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
if (orgs.isEmpty()) {
return new PageVO<>();
if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
if (orgs.isEmpty()) {
return new PageVO<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
if (dto.getSpaceIds().isEmpty()) {
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds));
.in(PlatSpace::getOrgId, dto.getOrgIds()));
if (spaces.isEmpty()) {
return new PageVO<>();
}
......@@ -464,17 +467,20 @@ public class WorkStationServiceImpl implements WorkStationService {
public PageVO<WorkStationHomeBedVO> homePage(PageReqDTO<WorkStationQueryDTO> page) {
WorkStationQueryDTO dto = page.getData();
List<PlatSpace> spaces = new ArrayList<>();
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.HOME.getValue());
if (orgs.isEmpty()) {
return new PageVO<>();
if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.HOME.getValue());
if (orgs.isEmpty()) {
return new PageVO<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
if (dto.getSpaceIds().isEmpty()) {
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds));
.in(PlatSpace::getOrgId, dto.getOrgIds()));
if (spaces.isEmpty()) {
return new PageVO<>();
}
......@@ -555,6 +561,10 @@ public class WorkStationServiceImpl implements WorkStationService {
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
if(!dto.getOrgIds().isEmpty()){
orgIds = dto.getOrgIds();
}
List<PlatSpace> list = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds));
......
......@@ -431,15 +431,17 @@ public class PlatTenantServiceImpl extends ServiceImpl<PlatTenantMapper, PlatTen
private void checkCode(PlatTenantDTOVO dto) {
PlatTenant tntTenant = getOne(
List<PlatTenant> list = list(
new QueryWrapper<PlatTenant>().lambda()
.eq(PlatTenant::getCode, dto.getCode())
.ne(StringUtils.isNotBlank(dto.getId()), PlatTenant::getCode, dto.getCode())
.ne(StringUtils.isNotBlank(dto.getId()), PlatTenant::getId, dto.getId())
);
if (tntTenant != null && !tntTenant.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_TENANT_CODE_DUPLICATE);
for (PlatTenant platTenant : list) {
if (platTenant != null && !platTenant.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_TENANT_CODE_DUPLICATE);
}
}
}
@Override
......
......@@ -150,7 +150,7 @@ public class IotSyncTask {
/**
* 长者睡眠分析
*/
//@Scheduled(cron = "0 6 * * *")
@Scheduled(cron = "0 0 2 * * ?")
@TenantIdIgnore
public void elderSleepSleepAnalysisTask() {
log.info("开始定时分析长者睡眠质量");
......
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