Commit 566e332b by lzy

Merge branch 'dev' of git.xmmakeit.com:huangjiay/iot-platform-server into dev

parents 70f98159 4086e9d9
Showing with 1527 additions and 230 deletions
...@@ -3,13 +3,17 @@ package com.makeit.controller.device; ...@@ -3,13 +3,17 @@ package com.makeit.controller.device;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.dto.platform.elder.PlatElderReportDTO; import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.global.aspect.tenant.TenantIdIgnore; import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.elder.PlatElderDayReportDayService; import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.*; import com.makeit.vo.platform.elder.report.day.PlatElderBehaviorDistributionVO;
import com.makeit.vo.platform.elder.report.day.PlatElderBehaviorExceptionRecordVO;
import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationRecordVO;
import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepDiagramVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -39,36 +43,38 @@ public class SaasDeviceReportDayController { ...@@ -39,36 +43,38 @@ public class SaasDeviceReportDayController {
@ApiOperation("睡眠评价") @ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation") @PostMapping("sleepEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.sleepEvaluation(platElderIdDTO));
} }
@ApiOperation("睡眠图表") @ApiOperation("睡眠图表")
@PostMapping("sleepDiagram") @PostMapping("sleepDiagram")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderSleepDiagramVO>> sleepDiagram(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderSleepDiagramVO>> sleepDiagram(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.sleepDiagram(platElderIdDTO));
} }
@ApiOperation("心率呼吸评价") @ApiOperation("心率呼吸评价")
@PostMapping("heartRespiratoryEvaluation") @PostMapping("heartRespiratoryEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.heartRespiratoryEvaluation(platElderIdDTO));
} }
@ApiOperation("心率异常记录") @ApiOperation("心率异常记录")
@PostMapping("heartExceptionRecordList") @PostMapping("heartExceptionRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.heartExceptionRecordList(platElderIdDTO));
} }
@ApiOperation("呼吸率异常记录") @ApiOperation("呼吸率异常记录")
@PostMapping("respiratoryExceptionRecordList") @PostMapping("respiratoryExceptionRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.respiratoryExceptionRecordList(platElderIdDTO));
} }
@ApiOperation("心率呼吸率") @ApiOperation("心率呼吸率")
......
...@@ -2,19 +2,24 @@ package com.makeit.controller.device; ...@@ -2,19 +2,24 @@ package com.makeit.controller.device;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderReportDTO; import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.global.aspect.tenant.TenantIdIgnore; import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.elder.PlatElderReportMonthService;
import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationVO; import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationVO;
import com.makeit.vo.platform.elder.report.day.PlatElderReportMonthVO; import com.makeit.vo.platform.elder.report.day.PlatElderReportMonthVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO; import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO;
import com.makeit.vo.platform.elder.report.week.PlatElderComprehensiveEvaluationVO; import com.makeit.vo.platform.elder.report.week.PlatElderComprehensiveEvaluationVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* <p> * <p>
* 长者基本信息 前端控制器 * 长者基本信息 前端控制器
...@@ -28,18 +33,23 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -28,18 +33,23 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/saas/device/report/month") @RequestMapping("/saas/device/report/month")
public class SaasDeviceReportMonthController { public class SaasDeviceReportMonthController {
@Autowired
private PlatElderReportMonthService platElderReportMonthService;
@ApiOperation("综合评价") @ApiOperation("综合评价")
@PostMapping("comprehensiveEvaluation") @PostMapping("comprehensiveEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderReportMonthService.comprehensiveEvaluation(platElderIdDTO));
} }
@ApiOperation("睡眠评价") @ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation") @PostMapping("sleepEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderReportMonthService.sleepEvaluation(platElderIdDTO));
} }
...@@ -47,14 +57,16 @@ public class SaasDeviceReportMonthController { ...@@ -47,14 +57,16 @@ public class SaasDeviceReportMonthController {
@PostMapping("heartRespiratoryEvaluation") @PostMapping("heartRespiratoryEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderReportMonthService.heartRespiratoryEvaluation(platElderIdDTO));
} }
@ApiOperation("月报表") @ApiOperation("月报表")
@PostMapping("reportMonth") @PostMapping("reportMonth")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderReportMonthVO> reportMonth(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderReportMonthVO>> reportMonth(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderReportMonthService.reportMonth(platElderIdDTO));
} }
......
...@@ -45,63 +45,68 @@ public class SaasDeviceReportWeekController { ...@@ -45,63 +45,68 @@ public class SaasDeviceReportWeekController {
@PostMapping("comprehensiveEvaluation") @PostMapping("comprehensiveEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.comprehensiveEvaluation(platElderIdDTO));
} }
@ApiOperation("睡眠评价") @ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation") @PostMapping("sleepEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.sleepEvaluation(platElderIdDTO));
} }
@ApiOperation("睡眠图表") @ApiOperation("睡眠图表")
@PostMapping("sleepDiagram") @PostMapping("sleepDiagram")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderSleepDiagramWeekVO>> sleepDiagram(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<PlatElderSleepDiagramWeekVO> sleepDiagram(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.sleepDiagram(platElderIdDTO));
} }
@ApiOperation("心率呼吸评价") @ApiOperation("心率呼吸评价")
@PostMapping("heartRespiratoryEvaluation") @PostMapping("heartRespiratoryEvaluation")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.heartRespiratoryEvaluation(platElderIdDTO));
} }
@ApiOperation("心率异常记录") @ApiOperation("心率异常记录")
@PostMapping("heartExceptionRecordList") @PostMapping("heartExceptionRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.heartExceptionRecordList(platElderIdDTO));
} }
@ApiOperation("呼吸率异常记录") @ApiOperation("呼吸率异常记录")
@PostMapping("respiratoryExceptionRecordList") @PostMapping("respiratoryExceptionRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.respiratoryExceptionRecordList(platElderIdDTO));
} }
@ApiOperation("心率呼吸率") @ApiOperation("心率呼吸率")
@PostMapping("heartRespiratory") @PostMapping("heartRespiratory")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<PlatElderRealTimeHeartRespiratoryWeekVO> heartRespiratory(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderRealTimeHeartRespiratoryWeekVO>> heartRespiratory(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.heartRespiratory(platElderIdDTO));
} }
@ApiOperation("行为异常记录") @ApiOperation("行为异常记录")
@PostMapping("behaviorExceptionRecordList") @PostMapping("behaviorExceptionRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.behaviorExceptionRecordList(platElderIdDTO));
} }
@ApiOperation("跌倒记录") @ApiOperation("跌倒记录")
@PostMapping("failRecordList") @PostMapping("failRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.failRecordList(platElderIdDTO));
} }
@ApiOperation("坐标记录") @ApiOperation("坐标记录")
...@@ -115,7 +120,8 @@ public class SaasDeviceReportWeekController { ...@@ -115,7 +120,8 @@ public class SaasDeviceReportWeekController {
@PostMapping("behaviorDistribution") @PostMapping("behaviorDistribution")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderReportDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.behaviorDistribution(platElderIdDTO));
} }
} }
......
...@@ -2,6 +2,7 @@ package com.makeit.controller.plat; ...@@ -2,6 +2,7 @@ package com.makeit.controller.plat;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.module.admin.dto.plat.PlatMenuDTOVO; import com.makeit.module.admin.dto.plat.PlatMenuDTOVO;
import com.makeit.module.admin.dto.plat.PlatMenuQueryDTO; import com.makeit.module.admin.dto.plat.PlatMenuQueryDTO;
import com.makeit.service.saas.PlatMenuService; import com.makeit.service.saas.PlatMenuService;
...@@ -26,6 +27,7 @@ public class PlatMenuController { ...@@ -26,6 +27,7 @@ public class PlatMenuController {
@ApiOperation("树形列表") @ApiOperation("树形列表")
@PostMapping("tree") @PostMapping("tree")
public ApiResponseEntity<List<PlatMenuDTOVO>> treeAuthIgnore(@RequestBody PlatMenuQueryDTO dto){ public ApiResponseEntity<List<PlatMenuDTOVO>> treeAuthIgnore(@RequestBody PlatMenuQueryDTO dto){
dto.setTenantId(TenantIdUtil.getTenantId());
return ApiResponseUtils.success(platMenuService.tree(dto)); return ApiResponseUtils.success(platMenuService.tree(dto));
} }
} }
...@@ -49,14 +49,14 @@ public class PlatRoleController { ...@@ -49,14 +49,14 @@ public class PlatRoleController {
@Autowired @Autowired
private PlatUserService platUserService; private PlatUserService platUserService;
@Action(module = "平台端-角色", name = "分页列表", code = "tnt:role:page") @Action(module = "平台端-角色", name = "分页列表", code = "plat:role:page")
@ApiOperation("分页列表") @ApiOperation("分页列表")
@PostMapping("page") @PostMapping("page")
public ApiResponseEntity<PageVO<PlatRoleDTOVO>> page(@RequestBody PageReqDTO<PlatRoleDTOVO> page) { public ApiResponseEntity<PageVO<PlatRoleDTOVO>> page(@RequestBody PageReqDTO<PlatRoleDTOVO> page) {
return ApiResponseUtils.success(platRoleService.page(page)); return ApiResponseUtils.success(platRoleService.page(page));
} }
@Action(module = "平台端-角色", name = "列表", code = "tnt:role:list") @Action(module = "平台端-角色", name = "列表", code = "plat:role:list")
@ApiOperation("列表") @ApiOperation("列表")
@PostMapping("list") @PostMapping("list")
public ApiResponseEntity<List<PlatRoleDTOVO>> list(@RequestBody PlatRoleDTOVO dto) { public ApiResponseEntity<List<PlatRoleDTOVO>> list(@RequestBody PlatRoleDTOVO dto) {
...@@ -75,14 +75,14 @@ public class PlatRoleController { ...@@ -75,14 +75,14 @@ public class PlatRoleController {
return ApiResponseUtils.success(platRoleService.list(dto)); return ApiResponseUtils.success(platRoleService.list(dto));
} }
@Action(module = "平台端-角色", name = "新增", code = "tnt:role:add") @Action(module = "平台端-角色", name = "新增", code = "plat:role:add")
@ApiOperation("新增") @ApiOperation("新增")
@PostMapping("add") @PostMapping("add")
public ApiResponseEntity<String> add(@Validated @RequestBody PlatRoleDTOVO dto) { public ApiResponseEntity<String> add(@Validated @RequestBody PlatRoleDTOVO dto) {
return ApiResponseUtils.success(platRoleService.add(dto)); return ApiResponseUtils.success(platRoleService.add(dto));
} }
@Action(module = "平台端-角色", name = "编辑", code = "tnt:role:edit") @Action(module = "平台端-角色", name = "编辑", code = "plat:role:edit")
@ApiOperation("编辑") @ApiOperation("编辑")
@PostMapping("edit") @PostMapping("edit")
public ApiResponseEntity<Void> edit(@Validated @RequestBody PlatRoleDTOVO dto) { public ApiResponseEntity<Void> edit(@Validated @RequestBody PlatRoleDTOVO dto) {
...@@ -90,14 +90,14 @@ public class PlatRoleController { ...@@ -90,14 +90,14 @@ public class PlatRoleController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "平台端-角色", name = "详情", code = "tnt:role:view") @Action(module = "平台端-角色", name = "详情", code = "plat:role:view")
@ApiOperation("详情") @ApiOperation("详情")
@PostMapping("view") @PostMapping("view")
public ApiResponseEntity<PlatRoleDTOVO> view(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<PlatRoleDTOVO> view(@RequestBody BaseIdDTO dto) {
return ApiResponseUtils.success(platRoleService.view(dto.getId())); return ApiResponseUtils.success(platRoleService.view(dto.getId()));
} }
@Action(module = "平台端-角色", name = "删除", code = "tnt:role:del") @Action(module = "平台端-角色", name = "删除", code = "plat:role:del")
@ApiOperation("删除") @ApiOperation("删除")
@PostMapping("del") @PostMapping("del")
public ApiResponseEntity<Void> del(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<Void> del(@RequestBody BaseIdDTO dto) {
...@@ -105,7 +105,7 @@ public class PlatRoleController { ...@@ -105,7 +105,7 @@ public class PlatRoleController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "平台端-角色", name = "改变状态", code = "tnt:role:changeStatus") @Action(module = "平台端-角色", name = "改变状态", code = "plat:role:changeStatus")
@ApiOperation("改变状态") @ApiOperation("改变状态")
@PostMapping("changeStatus") @PostMapping("changeStatus")
public ApiResponseEntity<Void> changeStatus(@RequestBody StatusDTO dto) { public ApiResponseEntity<Void> changeStatus(@RequestBody StatusDTO dto) {
...@@ -113,7 +113,7 @@ public class PlatRoleController { ...@@ -113,7 +113,7 @@ public class PlatRoleController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "平台端-角色", name = "分配用户", code = "tnt:role:assignUserList") @Action(module = "平台端-角色", name = "分配用户", code = "plat:role:assignUserList")
@ApiOperation("分配用户") @ApiOperation("分配用户")
@PostMapping("assignUserList") @PostMapping("assignUserList")
public ApiResponseEntity<Void> assignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {//参数要不要是一个对象里 有一个数组 public ApiResponseEntity<Void> assignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {//参数要不要是一个对象里 有一个数组
...@@ -121,7 +121,7 @@ public class PlatRoleController { ...@@ -121,7 +121,7 @@ public class PlatRoleController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "平台端-角色", name = "删除分配用户", code = "tnt:role:removeAssignUserList") @Action(module = "平台端-角色", name = "删除分配用户", code = "plat:role:removeAssignUserList")
@ApiOperation("删除分配用户") @ApiOperation("删除分配用户")
@PostMapping("removeAssignUserList") @PostMapping("removeAssignUserList")
public ApiResponseEntity<Void> removeAssignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) { public ApiResponseEntity<Void> removeAssignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {
...@@ -129,7 +129,7 @@ public class PlatRoleController { ...@@ -129,7 +129,7 @@ public class PlatRoleController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "平台端-角色", name = "分配菜单", code = "tnt:role:assignMenuList") @Action(module = "平台端-角色", name = "分配菜单", code = "plat:role:assignMenuList")
@ApiOperation("分配菜单") @ApiOperation("分配菜单")
@Deprecated @Deprecated
@PostMapping("assignMenuList") @PostMapping("assignMenuList")
...@@ -138,7 +138,7 @@ public class PlatRoleController { ...@@ -138,7 +138,7 @@ public class PlatRoleController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "平台端-角色", name = "获取分配菜单", code = "tnt:role:getAssignMenuList") @Action(module = "平台端-角色", name = "获取分配菜单", code = "plat:role:getAssignMenuList")
@ApiOperation("获取分配菜单") @ApiOperation("获取分配菜单")
@PostMapping("getAssignMenuList") @PostMapping("getAssignMenuList")
public ApiResponseEntity<List<PlatRoleMenu>> getAssignMenuList(@RequestBody BaseIdDTO baseIdDTO) { public ApiResponseEntity<List<PlatRoleMenu>> getAssignMenuList(@RequestBody BaseIdDTO baseIdDTO) {
...@@ -151,7 +151,7 @@ public class PlatRoleController { ...@@ -151,7 +151,7 @@ public class PlatRoleController {
return ApiResponseUtils.success(platUserService.getHotelList(deptDTO.getOrgId())); return ApiResponseUtils.success(platUserService.getHotelList(deptDTO.getOrgId()));
} }
@Action(module = "平台端-角色", name = "分配管理权限", code = "tnt:role:assignDeptList") @Action(module = "平台端-角色", name = "分配管理权限", code = "plat:role:assignDeptList")
@ApiOperation("分配管理权限") @ApiOperation("分配管理权限")
@PostMapping("assignDeptList") @PostMapping("assignDeptList")
public ApiResponseEntity<Void> assignDeptList(@RequestBody PlatRoleDeptDTOVO roleDeptDTO) { public ApiResponseEntity<Void> assignDeptList(@RequestBody PlatRoleDeptDTOVO roleDeptDTO) {
...@@ -159,14 +159,14 @@ public class PlatRoleController { ...@@ -159,14 +159,14 @@ public class PlatRoleController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "平台端-角色", name = "获取分配管理权限", code = "tnt:role:getDeptListByRoleId") @Action(module = "平台端-角色", name = "获取分配管理权限", code = "plat:role:getDeptListByRoleId")
@ApiOperation("获取分配管理权限") @ApiOperation("获取分配管理权限")
@PostMapping("getDeptListByRoleId") @PostMapping("getDeptListByRoleId")
public ApiResponseEntity<List<PlatRoleOrg>> getDeptListByRoleId(@RequestBody BaseIdDTO baseIdDTO) { public ApiResponseEntity<List<PlatRoleOrg>> getDeptListByRoleId(@RequestBody BaseIdDTO baseIdDTO) {
return ApiResponseUtils.success(platRoleService.getDeptListByRoleId(baseIdDTO.getId())); return ApiResponseUtils.success(platRoleService.getDeptListByRoleId(baseIdDTO.getId()));
} }
@Action(module = "平台端-角色", name = "复制角色及关联", code = "tnt:role:copyRole") @Action(module = "平台端-角色", name = "复制角色及关联", code = "plat:role:copyRole")
@ApiOperation("复制角色及关联") @ApiOperation("复制角色及关联")
@PostMapping("copyRole") @PostMapping("copyRole")
public ApiResponseEntity<Void> copyRole(@RequestBody BaseIdDTO baseIdDTO) { public ApiResponseEntity<Void> copyRole(@RequestBody BaseIdDTO baseIdDTO) {
......
package com.makeit.api.controller.external; package com.makeit.api.external.controller;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
......
package com.makeit.api.external.filter;
import org.apache.commons.io.IOUtils;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @Description: 解决request.getInputStream()只能读取一次的问题
* @PackageName: net.dlet.dhdemo.utils.dhutils
* @Name: MyRequestWrapper
* @Author: cure
* @CreateDate: 2020/09/06 4:44
* @ModifyUser:
* @ModifyDate:
* @ModifyDesc: 修改内容
* @DayNameFull: 星期日
* @ProjectName: dhdemo
* @Version: 1.0
**/
public class MyRequestWrapper extends HttpServletRequestWrapper {
private volatile byte[] body;
public MyRequestWrapper(HttpServletRequest request) throws IOException {
super(request);
body = IOUtils.toByteArray(super.getInputStream());
}
public byte[] getBody() {
return body;
}
public void setBody(byte[] body) {
this.body = body;
}
@Override
public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(getInputStream()));
}
@Override
public ServletInputStream getInputStream() throws IOException {
return new RequestBodyCachingInputStream(body);
}
private class RequestBodyCachingInputStream extends ServletInputStream {
private byte[] body;
private int lastIndexRetrieved = -1;
private ReadListener listener;
public RequestBodyCachingInputStream(byte[] body) {
this.body = body;
}
@Override
public int read() throws IOException {
if (isFinished()) {
return -1;
}
int i = body[lastIndexRetrieved + 1];
lastIndexRetrieved++;
if (isFinished() && listener != null) {
try {
listener.onAllDataRead();
} catch (IOException e) {
listener.onError(e);
throw e;
}
}
return i;
}
@Override
public boolean isFinished() {
return lastIndexRetrieved == body.length - 1;
}
@Override
public boolean isReady() {
return isFinished();
}
@Override
public void setReadListener(ReadListener listener) {
if (listener == null) {
throw new IllegalArgumentException("listener cann not be null");
}
if (this.listener != null) {
throw new IllegalArgumentException("listener has been set");
}
this.listener = listener;
if (!isFinished()) {
try {
listener.onAllDataRead();
} catch (IOException e) {
listener.onError(e);
}
} else {
try {
listener.onAllDataRead();
} catch (IOException e) {
listener.onError(e);
}
}
}
@Override
public int available() throws IOException {
return body.length - lastIndexRetrieved - 1;
}
@Override
public void close() throws IOException {
lastIndexRetrieved = body.length - 1;
body = null;
}
}
}
\ No newline at end of file
package com.makeit.api.external.filter;
import com.makeit.api.external.util.RSAUtils;
import com.makeit.utils.old.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@WebFilter(urlPatterns = { "/iot/external/*"})
public class SignAuthFilter implements Filter {
private static Logger logger = LoggerFactory.getLogger(SignAuthFilter.class);
@Override
public void init(FilterConfig filterConfig) {
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
try {
String sign = request.getHeader("sign");
if (StringUtils.isEmpty(sign)) {
response.sendError(403, "Forbidden");
return;
}
logger.info("getted Authorization is ---> " + sign);
// 获取客户端ip
/* String ip = IpUtil.getIpAddr(request);
logger.info("getted ip is ---> " + ip);*/
MyRequestWrapper requestWrapper = new MyRequestWrapper(request);
String bodyString = new String(requestWrapper.getBody(), StandardCharsets.UTF_8);
logger.info("getted requestbody data is ---> " + bodyString);
String decryptJson = RSAUtils.privateDecrypt(sign, RSAUtils.getPrivateKey(RSAUtils.PRIVATE_KEY), "UTF-8");
boolean couldPass = decryptJson.equals(bodyString);
if (couldPass) {
// 放行
chain.doFilter(requestWrapper, response);
return;
}
response.sendError(403, "Forbidden");
} catch (Exception e) {
logger.error("验证失败: -> " + e.getMessage(), e);
response.sendError(403, "Forbidden");
}
}
@Override
public void destroy() {
}
}
package com.makeit.api.external.util;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
/**
* 1、公钥加密,则用私钥解密
* 2、私钥加密,则用公钥解密
* 3、公钥签名,私钥验签
*/
public class RSAUtils {
public static final String CHARSET = "UTF-8";
public static final String RSA_ALGORITHM = "RSA";
public static final String RSA_ALGORITHM_SIGN = "SHA256WithRSA";
public static final String PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDEjW_RLCPPCeAPWzQWIAwMGNvHf1pat27oH6CZDCG5nLwxyDsUgxdF89IB2_rLURVTkkrB5tq_dcBk5Wi2pmu2yMn8Dpk2XYsm0LJwJe3gg2qqRXQm8DGbf9kvtHUqBLe_24PMHL88YavJdrcS6HNlwwth2YINmViroqMZgqW4bQnmV4t5X4BO1dl3gTB5y8pRXd1zoKsLNgjzbuVBgieA0-e99eMsdjJadZFPzETQW-BO9Q6Kbbx4fIjOkqxiS8KzsiDSvf3KXG9lfvoz67vuNez_QBFauA_MJsUP_bgHLXFV9-XzcjCE2fkDbKbNHPAP20o1IM1S3G43mGzRwAb5AgMBAAECggEAV_nOsNuG86bB6V2zRKv3eHqv9O2l7bDpLXDqm1Z4yfHDsqyi9R1wD1mBCGAEM3kJiKyUVZIVG1mDUiX05rw6vkfFUNLf9RuNq0QCenwfqzxnQ-tuf_dG3Qkul1G4l6Qg8vk4VuYPGuHE2JoQe6Ab9tKEh7mpopievcRAKKz3rEIn4NGGfg4tlTP2hoZ_EhCDMc02UTtjm2YXUux2T2KLZPXMeClbxU1vTMTxFNp9edWyB9syLbfJp34lrnrueKnqpBPUI4oldKj-3QsE4v3Ie8wLTp5leiowzKqZUXqTplWAvROpIvVfj9eeouBPAz_IQR_U77c3m22cisCh-5QT-QKBgQD764Um0miLVQQIrfM9GQiWpiiM75nzmt4QaRkjoNg896b-qjDelG9K_EQ3RjopFuQBKBf7xY304qtD6nY_5IFRlhdB58nrSgPgSxLaShAQ2yUkdDPr00rDBu_9cAT9GZxSRmDhds-87rnz21QMNIofg2cpKNpl1HQQfTcFN9OETwKBgQDHvFvQ0bizfkh4o71pfD0tiiWEeQzV7KMjuwQ3nnUBfgv2Rd1QkOUo3x_dLBTRzacIslQ3DFljXqoBJWJasRFUSAyikR1KUAven7z5D3u-rdye6MLofKkf0YY_qAlNQXEDh9hzhlWqifd4UJTcZujVQNvkuvjldGnMMTK1W49GNwKBgBUbZ52YFYBPEDZ19KJS3aBZrZ4ZWSnK-P4hACU3DccV7Nz7f3q2rxh2SHTlImxc6Z-bL1897yXsc_MNyviRebBPRgWUmRtoqSh6wcqeV_hBlDwYrFz-6A2tICB46UIXijxufyGE5eTrj5L59nHLWSNIzDTroljT0yGqjBiY09ULAoGAN339hGbACh5rxBi55zS9Som3Irb--fBk4uhyo4FCwMdkS2fdtSSMhm53S9uTbTbV0XS6MREdRJ5oXSklykyno-Lgn8nxeVQD-DYpKolCuBdV1FCW1kDMPCraQZVOAEjOPUzgtjf8VQU_3A2HTjTJO3ZpoYLQ4-8T9cc1b22gwMECgYBCq2CPsNMSf55_VCD23b2B_PuppnowWw-k_zl4MkZGLtLJx5qsLRp-hNRvqW2t81fFkOieDdGg_6s7DPinwKfjH8KNgv7ke3kv9euiJ-AmF8HQKlRNCsX_-J7JeB39BHZXU9WPRI4YT8dR6NzZS3D_ug_Coeiq9TIFa2Za6Q6mXg";
public static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxI1v0SwjzwngD1s0FiAMDBjbx39aWrdu6B-gmQwhuZy8Mcg7FIMXRfPSAdv6y1EVU5JKwebav3XAZOVotqZrtsjJ_A6ZNl2LJtCycCXt4INqqkV0JvAxm3_ZL7R1KgS3v9uDzBy_PGGryXa3EuhzZcMLYdmCDZlYq6KjGYKluG0J5leLeV-ATtXZd4EwecvKUV3dc6CrCzYI827lQYIngNPnvfXjLHYyWnWRT8xE0FvgTvUOim28eHyIzpKsYkvCs7Ig0r39ylxvZX76M-u77jXs_0ARWrgPzCbFD_24By1xVffl83IwhNn5A2ymzRzwD9tKNSDNUtxuN5hs0cAG-QIDAQAB";
public static void main(String[] args) throws Exception {
Map<String, String> keys = createKeys(2048);
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);
String decrypt = privateDecrypt(encrypt, privateKey, "UTF-8");
System.out.println(decrypt);
}
/**
* 初始化RSA算法密钥对
*
* @param keySize RSA1024已经不安全了,建议2048
* @return 经过Base64编码后的公私钥Map, 键名分别为publicKey和privateKey
*/
private static Map<String, String> createKeys(int keySize) {
//为RSA算法创建一个KeyPairGenerator对象
KeyPairGenerator kpg;
try {
kpg = KeyPairGenerator.getInstance(RSA_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException("No such algorithm-->[" + RSA_ALGORITHM + "]");
}
//初始化KeyPairGenerator对象,密钥长度
kpg.initialize(keySize);
//生成密匙对
KeyPair keyPair = kpg.generateKeyPair();
//得到公钥
Key publicKey = keyPair.getPublic();
String publicKeyStr = Base64.encodeBase64URLSafeString(publicKey.getEncoded());
//得到私钥
Key privateKey = keyPair.getPrivate();
String privateKeyStr = Base64.encodeBase64URLSafeString(privateKey.getEncoded());
Map<String, String> keyPairMap = new HashMap<String, String>();
keyPairMap.put("publicKey", publicKeyStr);
keyPairMap.put("privateKey", privateKeyStr);
return keyPairMap;
}
/**
* 得到公钥
* @param publicKey 密钥字符串(经过base64编码)
* @throws Exception
*/
public static RSAPublicKey getPublicKey(String publicKey) throws NoSuchAlgorithmException, InvalidKeySpecException {
//通过X509编码的Key指令获得公钥对象
KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM);
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(Base64.decodeBase64(publicKey));
RSAPublicKey key = (RSAPublicKey) keyFactory.generatePublic(x509KeySpec);
return key;
}
/**
* 得到私钥
* @param privateKey 密钥字符串(经过base64编码)
* @throws Exception
*/
public static RSAPrivateKey getPrivateKey(String privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException {
//通过PKCS#8编码的Key指令获得私钥对象
KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM);
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey));
RSAPrivateKey key = (RSAPrivateKey) keyFactory.generatePrivate(pkcs8KeySpec);
return key;
}
/**
* 公钥加密
* @param data
* @param publicKey
* @return
*/
public static String publicEncrypt(String data, RSAPublicKey publicKey, String encoding) {
if (StringUtils.isEmpty(encoding)) {
encoding = CHARSET;
}
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()));
} catch (Exception e) {
throw new RuntimeException("加密字符串[" + data + "]时遇到异常", e);
}
}
/**
* 私钥解密
* @param data
* @param privateKey
* @return
*/
public static String privateDecrypt(String data, RSAPrivateKey privateKey, String encoding) {
if (StringUtils.isEmpty(encoding)) {
encoding = CHARSET;
}
try {
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, privateKey);
return new String(rsaSplitCodec(cipher, Cipher.DECRYPT_MODE, Base64.decodeBase64(data), privateKey.getModulus().bitLength()), encoding);
} catch (Exception e) {
throw new RuntimeException("解密字符串[" + data + "]时遇到异常", e);
}
}
/**
* 私钥加密
* @param data
* @param privateKey
* @return
*/
public static String privateEncrypt(String data, RSAPrivateKey privateKey, String encoding) {
if (StringUtils.isEmpty(encoding)) {
encoding = CHARSET;
}
try {
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
return Base64.encodeBase64URLSafeString(rsaSplitCodec(cipher, Cipher.ENCRYPT_MODE, data.getBytes(encoding), privateKey.getModulus().bitLength()));
} catch (Exception e) {
throw new RuntimeException("加密字符串[" + data + "]时遇到异常", e);
}
}
/**
* 公钥解密
* @param data
* @param publicKey
* @return
*/
public static String publicDecrypt(String data, RSAPublicKey publicKey, String encoding) {
if (StringUtils.isEmpty(encoding)) {
encoding = CHARSET;
}
try {
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, publicKey);
return new String(rsaSplitCodec(cipher, Cipher.DECRYPT_MODE, Base64.decodeBase64(data), publicKey.getModulus().bitLength()), encoding);
} catch (Exception e) {
throw new RuntimeException("解密字符串[" + data + "]时遇到异常", e);
}
}
/**
* 私钥签名
* @param data 需要签名的数据
* @param privateKey 私钥
* @return
*/
public static String sign(String data, RSAPrivateKey privateKey, String encoding) {
if (StringUtils.isEmpty(encoding)) {
encoding = CHARSET;
}
try {
//sign
Signature signature = Signature.getInstance(RSA_ALGORITHM_SIGN);
signature.initSign(privateKey);
signature.update(data.getBytes(encoding));
return Base64.encodeBase64URLSafeString(signature.sign());
} catch (Exception e) {
throw new RuntimeException("签名字符串[" + data + "]时遇到异常", e);
}
}
/**
* 公钥验签
* @param data 需要验签的原始数据
* @param sign 签名
* @param publicKey 公钥
* @return
*/
public static boolean verify(String data, String sign, RSAPublicKey publicKey, String encoding) {
if (StringUtils.isEmpty(encoding)) {
encoding = CHARSET;
}
try {
Signature signature = Signature.getInstance(RSA_ALGORITHM_SIGN);
signature.initVerify(publicKey);
signature.update(data.getBytes(encoding));
return signature.verify(Base64.decodeBase64(sign));
} catch (Exception e) {
throw new RuntimeException("验签字符串[" + data + "]时遇到异常", e);
}
}
private static byte[] rsaSplitCodec(Cipher cipher, int opmode, byte[] datas, int keySize) {
int maxBlock = 0;
if (opmode == Cipher.DECRYPT_MODE) {
maxBlock = keySize / 8;
} else {
maxBlock = keySize / 8 - 11;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] buff;
int i = 0;
try {
while (datas.length > offSet) {
if (datas.length - offSet > maxBlock) {
buff = cipher.doFinal(datas, offSet, maxBlock);
} else {
buff = cipher.doFinal(datas, offSet, datas.length - offSet);
}
out.write(buff, 0, buff.length);
i++;
offSet = i * maxBlock;
}
} catch (Exception e) {
throw new RuntimeException("加解密阀值为[" + maxBlock + "]的数据时发生异常", e);
}
byte[] resultDatas = out.toByteArray();
IOUtils.closeQuietly(out);
return resultDatas;
}
}
\ No newline at end of file
...@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInt ...@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInt
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.makeit.config.mybatis.interceptor.EmptyListInterceptor; import com.makeit.config.mybatis.interceptor.EmptyListInterceptor;
import com.makeit.config.mybatis.tenant.DataScopeHandler;
import com.makeit.config.mybatis.tenant.DataScopeInterceptor;
import com.makeit.config.mybatis.tenant.FactoryTableProperties;
import com.makeit.config.mybatis.tenant.TenantIdHandler; import com.makeit.config.mybatis.tenant.TenantIdHandler;
import com.makeit.config.mybatis.tenant.TenantIdInterceptor; import com.makeit.config.mybatis.tenant.TenantIdInterceptor;
import com.makeit.config.mybatis.tenant.FactoryTableProperties;
import com.makeit.enums.CodeMessageEnum; import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.Const; import com.makeit.enums.Const;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
...@@ -43,14 +45,17 @@ public class MybatisPlusConfig { ...@@ -43,14 +45,17 @@ public class MybatisPlusConfig {
interceptor.addInnerInterceptor(new EmptyListInterceptor()); interceptor.addInnerInterceptor(new EmptyListInterceptor());
interceptor.addInnerInterceptor(tenantLineInnerInterceptor()); interceptor.addInnerInterceptor(new DataScopeInterceptor(new DataScopeHandler()));
interceptor.addInnerInterceptor(tenantLineInnerInterceptor());
interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor; return interceptor;
} }
...@@ -106,5 +111,4 @@ public class MybatisPlusConfig { ...@@ -106,5 +111,4 @@ public class MybatisPlusConfig {
public TenantLineInnerInterceptor tenantLineInnerInterceptor() { public TenantLineInnerInterceptor tenantLineInnerInterceptor() {
return new TenantIdInterceptor(tenantLineHandler()); return new TenantIdInterceptor(tenantLineHandler());
} }
} }
package com.makeit.config.mybatis.tenant;
import com.makeit.enums.Const;
import com.makeit.utils.request.RequestUtil;
import net.sf.jsqlparser.expression.Alias;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.HexValue;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
import net.sf.jsqlparser.expression.operators.relational.InExpression;
import net.sf.jsqlparser.expression.operators.relational.ItemsList;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.select.PlainSelect;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class DataScopeHandler {
/**
* 获取数据权限 SQL 片段
*
* @return JSqlParser 条件表达式
*/
public Expression getSqlSegment(PlainSelect plainSelect, String whereSegment){
Expression where = plainSelect.getWhere();
if (where == null) {
where = new HexValue(" 1 = 1 ");
}
Table fromItem = (Table) plainSelect.getFromItem();
// 有别名用别名,无别名用表名,防止字段冲突报错
Alias fromItemAlias = fromItem.getAlias();
String mainTableName = fromItemAlias == null ? fromItem.getName() : fromItemAlias.getName();
String dataScope = RequestUtil.getDataScope();
String[] orgIds = dataScope.split(Const.COMMON_SPLIT);
// 把集合转变为JSQLParser需要的元素列表
ItemsList orgIdList = new ExpressionList(Stream.of(orgIds).map(LongValue::new).collect(Collectors.toList()));
InExpression inExpression = new InExpression(new Column(mainTableName+".org_id"), orgIdList);
return new AndExpression(where, inExpression);
}
}
package com.makeit.config.mybatis.tenant;
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
import com.baomidou.mybatisplus.extension.parser.JsqlParserSupport;
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
import com.makeit.enums.Const;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.request.RequestUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.Select;
import net.sf.jsqlparser.statement.select.SelectBody;
import net.sf.jsqlparser.statement.select.SetOperationList;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Component
public class DataScopeInterceptor extends JsqlParserSupport implements InnerInterceptor {
private DataScopeHandler dataScopeHandler;
public DataScopeInterceptor(DataScopeHandler dataScopeHandler) {
this.dataScopeHandler = dataScopeHandler;
}
@Override
protected void processSelect(Select select, int index, String sql, Object obj) {
//platOrgId = plat_role.data_scope = org_id 逗号隔开
//请求头没有指定字段platOrgId跳过||platOrgId 为空 ||platOrgId = tenantId 跳过
String dataScope = RequestUtil.getDataScope();
String tenantId = RequestUtil.getTenantIdHeader();
if(StringUtils.isBlank(dataScope)||StringUtils.isBlank(tenantId)){
return;
}
String[] orgIds = dataScope.split(Const.COMMON_SPLIT);
List<String> orgIdList = Arrays.asList(orgIds);
if(orgIdList.contains(tenantId)){
return;
}
String tableName = ((Table) ((PlainSelect) select.getSelectBody()).getFromItem()).getName();
//没有org_id 表字段跳过
List<TableFieldInfo> fieldInfoList = TableInfoHelper.getTableInfo(tableName).getFieldList();
boolean existsOrgId = StreamUtil.anyMatch(fieldInfoList, e -> Const.ORG_ID.equals(e.getColumn()));
if(!existsOrgId){
return;
}
SelectBody selectBody = select.getSelectBody();
if (selectBody instanceof PlainSelect) {
this.setWhere((PlainSelect) selectBody, (String) obj);
} else if (selectBody instanceof SetOperationList) {
SetOperationList setOperationList = (SetOperationList) selectBody;
List<SelectBody> selectBodyList = setOperationList.getSelects();
selectBodyList.forEach(s -> this.setWhere((PlainSelect) s, (String) obj));
}
}
/**
* 设置 where 条件
*
* @param plainSelect 查询对象
* @param whereSegment 查询条件片段
*/
private void setWhere(PlainSelect plainSelect, String whereSegment) {
Expression sqlSegment = dataScopeHandler.getSqlSegment(plainSelect, whereSegment);
if (null != sqlSegment) {
plainSelect.setWhere(sqlSegment);
}
}
@Override
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
if (InterceptorIgnoreHelper.willIgnoreDataPermission(ms.getId())) {
return;
}
PluginUtils.MPBoundSql mpBs = PluginUtils.mpBoundSql(boundSql);
mpBs.sql(this.parserSingle(mpBs.sql(), ms.getId()));
}
}
...@@ -22,6 +22,8 @@ public class Const { ...@@ -22,6 +22,8 @@ public class Const {
public static final String FUTURE = "期货"; public static final String FUTURE = "期货";
public static final String FUTURE_ENG = "future"; public static final String FUTURE_ENG = "future";
public static final String ORG_ID = "org_id";
// 编码 // 编码
public static final String UTF8_CHAR_ENCODING = "utf-8"; public static final String UTF8_CHAR_ENCODING = "utf-8";
......
...@@ -18,6 +18,8 @@ public enum GlobalCodeMessageEnum { ...@@ -18,6 +18,8 @@ public enum GlobalCodeMessageEnum {
SYSTEM_ERROR_EXCEPTION(500, "system.error.exception"), SYSTEM_ERROR_EXCEPTION(500, "system.error.exception"),
// 请求方法不对 // 请求方法不对
SYSTEM_ERROR_NOT_ALLOWED(405, "system.error.method.not.allowed"), SYSTEM_ERROR_NOT_ALLOWED(405, "system.error.method.not.allowed"),
SYSTEM_ERROR_FORBIDDEN(403, "system.error.forbidden"),
// 未找到 // 未找到
SYSTEM_ERROR_NOT_FOUND(404, "system.error.not.found"), SYSTEM_ERROR_NOT_FOUND(404, "system.error.not.found"),
......
...@@ -22,4 +22,6 @@ public class HeaderConst { ...@@ -22,4 +22,6 @@ public class HeaderConst {
public static final String ZONE_ID = "zoneId"; public static final String ZONE_ID = "zoneId";
public static final String FEIGN_NO_REMOVE="feignNoRemove"; public static final String FEIGN_NO_REMOVE="feignNoRemove";
public static final String DATA_SCOPE = "data-scope";
} }
...@@ -35,6 +35,11 @@ public class ExceptionController implements ErrorController { ...@@ -35,6 +35,11 @@ public class ExceptionController implements ErrorController {
return ApiResponseUtils.fail(GlobalCodeMessageEnum.SYSTEM_ERROR_NOT_ALLOWED.getCode(), return ApiResponseUtils.fail(GlobalCodeMessageEnum.SYSTEM_ERROR_NOT_ALLOWED.getCode(),
GlobalCodeMessageEnum.SYSTEM_ERROR_NOT_ALLOWED.getMessage()); GlobalCodeMessageEnum.SYSTEM_ERROR_NOT_ALLOWED.getMessage());
} }
// 403
if (GlobalCodeMessageEnum.SYSTEM_ERROR_FORBIDDEN.getCode() == statusCode) {
return ApiResponseUtils.fail(GlobalCodeMessageEnum.SYSTEM_ERROR_FORBIDDEN.getCode(),
GlobalCodeMessageEnum.SYSTEM_ERROR_FORBIDDEN.getMessage());
}
return ApiResponseUtils.fail(GlobalCodeMessageEnum.SYSTEM_ERROR_EXCEPTION.getCode(), return ApiResponseUtils.fail(GlobalCodeMessageEnum.SYSTEM_ERROR_EXCEPTION.getCode(),
GlobalCodeMessageEnum.SYSTEM_ERROR_EXCEPTION.getMessage()); GlobalCodeMessageEnum.SYSTEM_ERROR_EXCEPTION.getMessage());
......
...@@ -44,4 +44,7 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable { ...@@ -44,4 +44,7 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable {
private String status; private String status;
@ApiModelProperty(value = "org_id列表 以逗号分隔 权限")
private String dataScope;
} }
package com.makeit.module.iot.service; package com.makeit.module.iot.service;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.makeit.module.iot.util.HttpRequest; import com.makeit.module.iot.util.HttpRequest;
import com.makeit.module.iot.util.SimpleHttpRequest;
import com.makeit.module.iot.vo.DeviceInstanceEntity; import com.makeit.module.iot.vo.DeviceInstanceEntity;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.module.iot.vo.ResponseMessage; import com.makeit.module.iot.vo.ResponseMessage;
import com.makeit.utils.data.convert.JsonUtil; import com.makeit.utils.data.convert.JsonUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -11,6 +14,7 @@ import org.springframework.scheduling.annotation.Async; ...@@ -11,6 +14,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -23,6 +27,23 @@ public class IotDevicePropertiesOperateService extends IotCommonService { ...@@ -23,6 +27,23 @@ public class IotDevicePropertiesOperateService extends IotCommonService {
public static final String DEVICE_PREFIX_URL = "/device-instance/"; public static final String DEVICE_PREFIX_URL = "/device-instance/";
public DeviceProperties deviceRead(String deviceId, String propertiesName) {
String url = iotUrl + "device/standard/" + deviceId + "/property/" + propertiesName;
HttpRequest request = new SimpleHttpRequest(url, httpClient);
request.headers(headerUtils.createHeadersOfParams(new HashMap<>()));
try {
ResponseMessage responseMessage = sendGet(url, request);
if (responseMessage.getStatus() == 200) {
return JSON.parseObject(responseMessage.getResult().toString(), DeviceProperties.class);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return null;
}
/** /**
* 把设备写入属性 * 把设备写入属性
*/ */
......
...@@ -262,7 +262,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -262,7 +262,7 @@ public class IotProductDeviceService extends IotCommonService {
try { try {
ResponseMessage responseMessage = sendPost(url, request); ResponseMessage responseMessage = sendPost(url, request);
if (responseMessage.getStatus() == 200) { if (responseMessage.getStatus() == 200 && responseMessage.getResult() != null) {
IotPagerResult pagerResult = JSON.parseObject(responseMessage.getResult().toString(), IotPagerResult.class); IotPagerResult pagerResult = JSON.parseObject(responseMessage.getResult().toString(), IotPagerResult.class);
List<DeviceOperationLogEntity> deviceOperationLogEntities = JSONArray.parseArray(pagerResult.getData().toString()).toJavaList(DeviceOperationLogEntity.class); List<DeviceOperationLogEntity> deviceOperationLogEntities = JSONArray.parseArray(pagerResult.getData().toString()).toJavaList(DeviceOperationLogEntity.class);
return deviceOperationLogEntities; return deviceOperationLogEntities;
......
package com.makeit.module.iot.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class DeviceProperties {
private Long createTime;
private String formatValue;
private Integer numberValue;
@ApiModelProperty("属性名称")
private String propertyName;
@ApiModelProperty("属性")
private String property;
private Long timestamp;
private String type;
@ApiModelProperty("属性值")
private Integer value;
}
package com.makeit.utils.data.convert; package com.makeit.utils.data.convert;
import com.makeit.enums.id.TreeConst; import com.makeit.enums.id.TreeConst;
import com.makeit.utils.old.StringUtils;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
...@@ -85,4 +84,37 @@ public class TreeUtil { ...@@ -85,4 +84,37 @@ public class TreeUtil {
} }
} }
public static String path(String path, List<String> idList) {
// if(StringUtils.isBlank(path)){
// return path;
// }
LinkedHashSet<String> list = new LinkedHashSet<>();
if (StringUtils.isNotBlank(path)) {
list = new LinkedHashSet<>(Arrays.asList(path.split(",")));
}
list.addAll(idList);
return StreamUtil.join(new ArrayList<>(list), Function.identity());
}
public static <T> void fillId(List<BiConsumer<T, String>> consumerList, T t, String path, int start) {
if (StringUtils.isBlank(path)) {
return;
}
String[] arr = path.split(",");
for (int i = start; i < arr.length; i++) {
consumerList.get(i - start).accept(t, arr[i - start]);
}
}
public static <T> void fillId(List<BiConsumer<T, String>> consumerList, T t, String path) {
fillId(consumerList, t, path, 0);
}
} }
...@@ -60,7 +60,9 @@ public class ConfigConverter implements Converter<String> { ...@@ -60,7 +60,9 @@ public class ConfigConverter implements Converter<String> {
String s = Arrays.stream(cellData.getStringValue().split(dictEnumFormat.split())).filter(StringUtils::isNotBlank).map(m::get).filter(StringUtils::isNotBlank).collect(Collectors.joining(",")); String s = Arrays.stream(cellData.getStringValue().split(dictEnumFormat.split())).filter(StringUtils::isNotBlank).map(m::get).filter(StringUtils::isNotBlank).collect(Collectors.joining(","));
if (StringUtils.isBlank(s)) { if (StringUtils.isBlank(s)) {
s = ""; //s = "";
s = cellData.getStringValue();
} }
return s; return s;
...@@ -86,10 +88,13 @@ public class ConfigConverter implements Converter<String> { ...@@ -86,10 +88,13 @@ public class ConfigConverter implements Converter<String> {
ConfigFormat dictEnumFormat = contentProperty.getField().getAnnotation(ConfigFormat.class); ConfigFormat dictEnumFormat = contentProperty.getField().getAnnotation(ConfigFormat.class);
String s = Arrays.stream(value.split(",")).filter(StringUtils::isNotBlank).map(m::get).filter(StringUtils::isNotBlank).collect(Collectors.joining(dictEnumFormat.split())); String s = Arrays.stream(value.split(",")).filter(StringUtils::isNotBlank).map(m::get).filter(StringUtils::isNotBlank).collect(Collectors.joining(dictEnumFormat.split().substring(dictEnumFormat.split().length() - 1)));
if (StringUtils.isBlank(s)) { if (StringUtils.isBlank(s)) {
s = ""; //s = "";
s = value;
} }
return new WriteCellData(s); return new WriteCellData(s);
......
...@@ -9,6 +9,6 @@ public @interface ConfigFormat { ...@@ -9,6 +9,6 @@ public @interface ConfigFormat {
String categoryCode(); String categoryCode();
String split() default "|"; String split() default "\\|";
} }
...@@ -105,4 +105,7 @@ public class RequestUtil { ...@@ -105,4 +105,7 @@ public class RequestUtil {
// } // }
// //
public static String getDataScope(){
return getHeader(HeaderConst.DATA_SCOPE);
}
} }
...@@ -33,7 +33,6 @@ public class PlatUserVO implements Serializable { ...@@ -33,7 +33,6 @@ public class PlatUserVO implements Serializable {
private String orgPath; private String orgPath;
public PlatUserVO() { public PlatUserVO() {
} }
...@@ -49,27 +48,25 @@ public class PlatUserVO implements Serializable { ...@@ -49,27 +48,25 @@ public class PlatUserVO implements Serializable {
} }
private boolean initFlag = false; private boolean initFlag = false;
public void init(){ public void init() {
if(initFlag){ if (initFlag) {
return; return;
} }
if(StringUtils.isBlank(orgPath)){ if (StringUtils.isBlank(orgPath)) {
return; return;
} }
List<BiConsumer<PlatUserVO,String>> list = Arrays.asList( List<BiConsumer<PlatUserVO, String>> list = Arrays.asList(
PlatUserVO::setCityOrgId, PlatUserVO::setCityOrgId,
PlatUserVO::setDistrictOrgId, PlatUserVO::setDistrictOrgId,
PlatUserVO::setStreetOrgId PlatUserVO::setStreetOrgId
); );
String[] split = orgPath.split(","); String[] split = orgPath.split(",");
for (int i = 1; i < split.length; i++) { for (int i = 1; i < split.length; i++) {
BiConsumer<PlatUserVO, String> e = list.get(i-1); BiConsumer<PlatUserVO, String> e = list.get(i - 1);
e.accept(this,split[i]); e.accept(this, split[i]);
} }
this.initFlag = true; this.initFlag = true;
} }
......
...@@ -61,7 +61,7 @@ SYSTEM.ERROR.TENANT.NOT.EXIST=该租户不存在或者被禁用 ...@@ -61,7 +61,7 @@ SYSTEM.ERROR.TENANT.NOT.EXIST=该租户不存在或者被禁用
SYSTEM.ERROR.DUPLICATE.REQUEST=请勿重复请求 SYSTEM.ERROR.DUPLICATE.REQUEST=请勿重复请求
#SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=该用户已经离职/冻结 #SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=该用户已经离职/冻结
SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=用户不存在/已冻结 SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=用户不存在
SYSTEM.ERROR.AUTH.USER.ACCOUNT.PASSWORD=账号或者密码错误! SYSTEM.ERROR.AUTH.USER.ACCOUNT.PASSWORD=账号或者密码错误!
SYSTEM.ERROR.AUTH.USER.PASSWORD=密码错误 SYSTEM.ERROR.AUTH.USER.PASSWORD=密码错误
SYSTEM.ERROR.AUTH.USER.OLD.PASSWORD=旧密码错误 SYSTEM.ERROR.AUTH.USER.OLD.PASSWORD=旧密码错误
......
...@@ -4,8 +4,10 @@ package com.makeit.module.controller.children.elder; ...@@ -4,8 +4,10 @@ package com.makeit.module.controller.children.elder;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.elder.add.PlatElderDTOVO; import com.makeit.dto.platform.elder.add.PlatElderDTOVO;
import com.makeit.service.platform.elder.PlatElderService; import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.vo.platform.elder.PlatElderListVO;
import com.makeit.vo.wechat.elder.PlatElderWechatSimpleVO; import com.makeit.vo.wechat.elder.PlatElderWechatSimpleVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -33,6 +35,12 @@ public class PlatElderChildrenController { ...@@ -33,6 +35,12 @@ public class PlatElderChildrenController {
@Autowired @Autowired
private PlatElderService platElderService; private PlatElderService platElderService;
@ApiOperation("列表")
@PostMapping("list")
public ApiResponseEntity<List<PlatElderListVO>> list(@RequestBody PlatElderQueryDTO dto) {
return ApiResponseUtils.success(platElderService.list(dto));
}
@ApiOperation("我的家庭") @ApiOperation("我的家庭")
@PostMapping("listMy") @PostMapping("listMy")
public ApiResponseEntity<List<PlatElderWechatSimpleVO>> listMy() { public ApiResponseEntity<List<PlatElderWechatSimpleVO>> listMy() {
......
...@@ -10,6 +10,7 @@ import io.swagger.annotations.Api; ...@@ -10,6 +10,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -37,14 +38,14 @@ public class PlatElderChildrenInfoChildrenController { ...@@ -37,14 +38,14 @@ public class PlatElderChildrenInfoChildrenController {
@ApiOperation("绑定") @ApiOperation("绑定")
@PostMapping("bind") @PostMapping("bind")
public ApiResponseEntity<?> bind(PlatElderIdDTO dto) { public ApiResponseEntity<?> bind(@RequestBody PlatElderIdDTO dto) {
platElderChildrenInfoService.bind(dto.getElderId()); platElderChildrenInfoService.bind(dto.getElderId());
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("解绑") @ApiOperation("解绑")
@PostMapping("unbind") @PostMapping("unbind")
public ApiResponseEntity<?> unbind(PlatElderIdDTO dto) { public ApiResponseEntity<?> unbind(@RequestBody PlatElderIdDTO dto) {
platElderChildrenInfoService.unbind(dto.getElderId()); platElderChildrenInfoService.unbind(dto.getElderId());
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
......
package com.makeit.module.controller.children.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RestController;
import java.util.List;
/**
* <p>
* 长者基本信息 前端控制器
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
@Api(tags = "子女端小程序-长者报告-日报")
@RestController
@RequestMapping("/children/elder/report/day")
public class PlatElderReportDayChildrenController {
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
@ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation")
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.sleepEvaluation(platElderIdDTO));
}
@ApiOperation("睡眠图表")
@PostMapping("sleepDiagram")
public ApiResponseEntity<List<PlatElderSleepDiagramVO>> sleepDiagram(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.sleepDiagram(platElderIdDTO));
}
@ApiOperation("心率呼吸评价")
@PostMapping("heartRespiratoryEvaluation")
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.heartRespiratoryEvaluation(platElderIdDTO));
}
@ApiOperation("心率异常记录")
@PostMapping("heartExceptionRecordList")
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.heartExceptionRecordList(platElderIdDTO));
}
@ApiOperation("呼吸率异常记录")
@PostMapping("respiratoryExceptionRecordList")
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.respiratoryExceptionRecordList(platElderIdDTO));
}
@ApiOperation("心率呼吸率")
@PostMapping("heartRespiratory")
public ApiResponseEntity<List<PlatElderRealTimeHeartRespiratoryVO>> heartRespiratory(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.heartRespiratory(platElderIdDTO));
}
@ApiOperation("行为异常记录")
@PostMapping("behaviorExceptionRecordList")
public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.behaviorExceptionRecordList(platElderIdDTO));
}
@ApiOperation("跌倒记录")
@PostMapping("failRecordList")
public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.failRecordList(platElderIdDTO));
}
@ApiOperation("坐标记录")
@PostMapping("coordinateList")
public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinateList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.coordinateList(platElderIdDTO));
}
@ApiOperation("行为辐射")
@PostMapping("behaviorDistribution")
public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.behaviorDistribution(platElderIdDTO));
}
}
package com.makeit.module.controller.children.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.service.platform.elder.PlatElderReportMonthService;
import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationVO;
import com.makeit.vo.platform.elder.report.day.PlatElderReportMonthVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO;
import com.makeit.vo.platform.elder.report.week.PlatElderComprehensiveEvaluationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RestController;
import java.util.List;
/**
* <p>
* 长者基本信息 前端控制器
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
@Api(tags = "子女端小程序-长者报告-月报")
@RestController
@RequestMapping("/children/elder/report/month")
public class PlatElderReportMonthChildrenController {
@Autowired
private PlatElderReportMonthService platElderReportMonthService;
@ApiOperation("综合评价")
@PostMapping("comprehensiveEvaluation")
public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderReportMonthService.comprehensiveEvaluation(platElderIdDTO));
}
@ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation")
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderReportMonthService.sleepEvaluation(platElderIdDTO));
}
@ApiOperation("心率呼吸评价")
@PostMapping("heartRespiratoryEvaluation")
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderReportMonthService.heartRespiratoryEvaluation(platElderIdDTO));
}
@ApiOperation("月报表")
@PostMapping("reportMonth")
public ApiResponseEntity<List<PlatElderReportMonthVO>> reportMonth(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderReportMonthService.reportMonth(platElderIdDTO));
}
}
package com.makeit.module.controller.children.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.service.platform.elder.PlatElderDayReportWeekService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.report.day.*;
import com.makeit.vo.platform.elder.report.week.PlatElderComprehensiveEvaluationVO;
import com.makeit.vo.platform.elder.report.week.PlatElderRealTimeHeartRespiratoryWeekVO;
import com.makeit.vo.platform.elder.report.week.PlatElderSleepDiagramWeekVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RestController;
import java.util.List;
/**
* <p>
* 长者基本信息 前端控制器
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
@Api(tags = "子女端小程序-长者报告-周报")
@RestController
@RequestMapping("/children/elder/report/week")
public class PlatElderReportWeekChildrenController {
@Autowired
private PlatElderDayReportWeekService platElderDayReportWeekService;
@ApiOperation("综合评价")
@PostMapping("comprehensiveEvaluation")
public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.comprehensiveEvaluation(platElderIdDTO));
}
@ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation")
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.sleepEvaluation(platElderIdDTO));
}
@ApiOperation("睡眠图表")
@PostMapping("sleepDiagram")
public ApiResponseEntity<PlatElderSleepDiagramWeekVO> sleepDiagram(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.sleepDiagram(platElderIdDTO));
}
@ApiOperation("心率呼吸评价")
@PostMapping("heartRespiratoryEvaluation")
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.heartRespiratoryEvaluation(platElderIdDTO));
}
@ApiOperation("心率异常记录")
@PostMapping("heartExceptionRecordList")
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.heartExceptionRecordList(platElderIdDTO));
}
@ApiOperation("呼吸率异常记录")
@PostMapping("respiratoryExceptionRecordList")
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.respiratoryExceptionRecordList(platElderIdDTO));
}
@ApiOperation("心率呼吸率")
@PostMapping("heartRespiratory")
public ApiResponseEntity<List<PlatElderRealTimeHeartRespiratoryWeekVO>> heartRespiratory(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.heartRespiratory(platElderIdDTO));
}
@ApiOperation("行为异常记录")
@PostMapping("behaviorExceptionRecordList")
public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.behaviorExceptionRecordList(platElderIdDTO));
}
@ApiOperation("跌倒记录")
@PostMapping("failRecordList")
public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.failRecordList(platElderIdDTO));
}
@ApiOperation("坐标记录")
@PostMapping("coordinateList")
public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinateList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.coordinateList(platElderIdDTO));
}
@ApiOperation("行为辐射")
@PostMapping("behaviorDistribution")
public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportWeekService.behaviorDistribution(platElderIdDTO));
}
}
...@@ -3,22 +3,24 @@ package com.makeit.module.controller.space; ...@@ -3,22 +3,24 @@ package com.makeit.module.controller.space;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.elder.PlatElderImportDTO; import com.makeit.dto.platform.elder.PlatElderImportDTO;
import com.makeit.dto.platform.space.PlatSpaceAddDTO; import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceImportDTO; import com.makeit.dto.platform.space.PlatSpaceImportDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO; import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceVO; import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.FileSuffixEnum; import com.makeit.enums.FileSuffixEnum;
import com.makeit.exception.BusinessException;
import com.makeit.global.annotation.Action;
import com.makeit.service.platform.space.PlatSpaceService; import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.excel.ExcelUtil; import com.makeit.utils.data.excel.ExcelUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
...@@ -92,6 +94,16 @@ public class PlatSpaceController { ...@@ -92,6 +94,16 @@ public class PlatSpaceController {
} }
@ApiOperation("批量导入")
@PostMapping("import")
public ApiResponseEntity<ExcelImportVo> importExcel(@RequestParam(value = "excelFile", required = false) MultipartFile excelFile){
if(excelFile == null ){
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_EXCEL_UPLOAD_EXIT);
}
ExcelImportVo excelImportVo = spaceService.importSpaceExcel(excelFile);
return ApiResponseUtils.success(excelImportVo);
}
@ApiOperation("树-上级空间") @ApiOperation("树-上级空间")
@PostMapping("parentListTree") @PostMapping("parentListTree")
public ApiResponseEntity<List<PlatSpaceVO>> parentListTree(@RequestBody PlatSpaceQueryDTO dto) { public ApiResponseEntity<List<PlatSpaceVO>> parentListTree(@RequestBody PlatSpaceQueryDTO dto) {
......
...@@ -10,6 +10,8 @@ import com.makeit.dto.platform.device.PlatDeviceQueryDTO; ...@@ -10,6 +10,8 @@ import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO; import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO; import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO; import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.vo.platform.device.PlatDeviceListVO; import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO; import com.makeit.vo.platform.device.PlatDeviceViewVO;
...@@ -22,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -22,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* <p> * <p>
* 设备 前端控制器 * 设备 前端控制器
...@@ -65,6 +69,12 @@ public class PlatDeviceWechatController { ...@@ -65,6 +69,12 @@ public class PlatDeviceWechatController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("读取设备属性")
@PostMapping("readDeviceProperties")
public ApiResponseEntity<List<DeviceProperties>> readDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
return ApiResponseUtils.success(platDeviceService.readDeviceProperties(dto));
}
@ApiOperation("编辑设备属性") @ApiOperation("编辑设备属性")
@PostMapping("editDeviceProperties") @PostMapping("editDeviceProperties")
public ApiResponseEntity<?> editDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) { public ApiResponseEntity<?> editDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
......
...@@ -97,7 +97,7 @@ public class PlatElderImportDTO extends BaseTenantDTO { ...@@ -97,7 +97,7 @@ public class PlatElderImportDTO extends BaseTenantDTO {
@ApiModelProperty(value = "性别 数据字典 1 男 2 女") @ApiModelProperty(value = "性别 数据字典 1 男 2 女")
private String sex; private String sex;
@ExcelProperty({BIG_TITLE, "老人姓名"}) @ExcelProperty({BIG_TITLE, "年龄"})
@ApiModelProperty(value = "年龄") @ApiModelProperty(value = "年龄")
private Integer age; private Integer age;
...@@ -109,7 +109,7 @@ public class PlatElderImportDTO extends BaseTenantDTO { ...@@ -109,7 +109,7 @@ public class PlatElderImportDTO extends BaseTenantDTO {
@NotBlank(message = "证件号不能为空") @NotBlank(message = "证件号不能为空")
@Size(max = 50, message = "证件号最长为50字符") @Size(max = 50, message = "证件号最长为50字符")
@ExcelProperty({BIG_TITLE, "证件号"}) @ExcelProperty({BIG_TITLE, "证件号*"})
@ApiModelProperty(value = "证件号码") @ApiModelProperty(value = "证件号码")
private String certificateNumber; private String certificateNumber;
......
package com.makeit.dto.platform.space;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PlatSpaceSplitDTO {
@ApiModelProperty(value = "空间id")
private String spaceId;
@ApiModelProperty(value = "小区/社区/街道空间id")
private String streetSpaceId;
@ApiModelProperty(value = "楼栋空间id")
private String buildingSpaceId;
@ApiModelProperty(value = "单元空间id")
private String unitSpaceId;
@ApiModelProperty(value = "楼层id")
private String floorSpaceId;
@ApiModelProperty(value = "房间id")
private String roomId;
@ApiModelProperty(value = "床位id")
private String bedId;
@ApiModelProperty(value = "空间-房间-床位路径")
private String spacePath;
}
...@@ -13,7 +13,7 @@ import lombok.Data; ...@@ -13,7 +13,7 @@ import lombok.Data;
* @since 2023-09-05 * @since 2023-09-05
*/ */
@Data @Data
@ApiModel(value = "PlatDeviceAttrWechatDTO对象", description = "设备属性") @ApiModel(value = "PlatDeviceAttrWechatDTO对象", description = "设备属性 跌倒:安装方式 安装高度 空间人体:安装方式 功能模式")
public class PlatDeviceAttrWechatDTO { public class PlatDeviceAttrWechatDTO {
@ApiModelProperty(value = "设备id") @ApiModelProperty(value = "设备id")
...@@ -30,5 +30,6 @@ public class PlatDeviceAttrWechatDTO { ...@@ -30,5 +30,6 @@ public class PlatDeviceAttrWechatDTO {
"进\":1,\"单位\":\"cm\"") "进\":1,\"单位\":\"cm\"")
private Integer radarHight; private Integer radarHight;
private String readProperties;
} }
package com.makeit.entity.platform.elder; package com.makeit.entity.platform.elder;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.makeit.common.entity.BaseBusEntity; import com.makeit.common.entity.BaseBusEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -21,6 +23,7 @@ public class PlatElderChildrenInfo extends BaseBusEntity { ...@@ -21,6 +23,7 @@ public class PlatElderChildrenInfo extends BaseBusEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableField(updateStrategy = FieldStrategy.IGNORED)
@ApiModelProperty(value = "长者id") @ApiModelProperty(value = "长者id")
private String elderId; private String elderId;
......
...@@ -72,7 +72,8 @@ public class BreathAlarm implements IAlarm { ...@@ -72,7 +72,8 @@ public class BreathAlarm implements IAlarm {
//计数 //计数
AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_BR_ID + deviceId); AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_BR_ID + deviceId);
if (StringUtils.equals(personState, CommonEnum.NO.getValue())) { //运动状态 0-无人 3-进入呼吸 跳过
if (StringUtils.equalsAny(personState, CommonEnum.NO.getValue(),"3")) {
RedisUtil.delete(RedisConst.ALARM_DEVICE_BR_ID + deviceId); RedisUtil.delete(RedisConst.ALARM_DEVICE_BR_ID + deviceId);
return; return;
} }
......
...@@ -47,16 +47,24 @@ public class FallAlarm implements IAlarm { ...@@ -47,16 +47,24 @@ public class FallAlarm implements IAlarm {
String deviceId = platDevice.getOriDeviceId(); String deviceId = platDevice.getOriDeviceId();
String personState = Convert.toStr(properties.get("personState")); String personState = Convert.toStr(properties.get("personState"));
AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_FALL_ID + deviceId); AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_FALL_ID + deviceId);
if(alarmRedisDTO==null){
alarmRedisDTO = new AlarmRedisDTO();
alarmRedisDTO.setAlarm(CommonEnum.NO.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_FALL_ID+ deviceId, alarmRedisDTO);
}
if (StringUtils.equals(personState, CommonEnum.YES.getValue())) { if (StringUtils.equals(personState, CommonEnum.YES.getValue())) {
if (StringUtils.equals(alarmRedisDTO.getAlarm(),CommonEnum.YES.getValue())){ if (StringUtils.equals(alarmRedisDTO.getAlarm(),CommonEnum.YES.getValue())){
log.error("长者跌倒,已告警过,设备iot_id:"+deviceId); log.error("长者跌倒,已告警过,设备iot_id:"+deviceId);
return;
} }
notice(platAlarmCheckDTO); notice(platAlarmCheckDTO);
alarmRedisDTO.setAlarm(CommonEnum.YES.getValue()); alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_FALL_ID, alarmRedisDTO); RedisUtil.set(RedisConst.ALARM_DEVICE_FALL_ID+ deviceId, alarmRedisDTO);
} else { } else {
alarmRedisDTO.setAlarm(CommonEnum.NO.getValue()); if(StringUtils.equals(alarmRedisDTO.getAlarm(),CommonEnum.YES.getValue())) {
RedisUtil.set(RedisConst.ALARM_DEVICE_FALL_ID, alarmRedisDTO); alarmRedisDTO.setAlarm(CommonEnum.NO.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_FALL_ID+ deviceId, alarmRedisDTO);
}
} }
} }
......
...@@ -63,7 +63,7 @@ public class HeartAlarm implements IAlarm { ...@@ -63,7 +63,7 @@ public class HeartAlarm implements IAlarm {
//计数 //计数
AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_HR_ID + deviceId); AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_HR_ID + deviceId);
if (StringUtils.equals(personState, CommonEnum.NO.getValue())) { if (StringUtils.equalsAny(personState, CommonEnum.NO.getValue(),"3")) {
RedisUtil.delete(RedisConst.ALARM_DEVICE_HR_ID + deviceId); RedisUtil.delete(RedisConst.ALARM_DEVICE_HR_ID + deviceId);
return; return;
} }
......
...@@ -91,7 +91,8 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe ...@@ -91,7 +91,8 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
updateById(alarmConfig); updateById(alarmConfig);
alarmConfigUtil.put(alarmConfig); PlatAlarmConfig entity = getById(dto.getId());
alarmConfigUtil.put(entity);
} }
...@@ -102,7 +103,8 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe ...@@ -102,7 +103,8 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
PlatAlarmConfig alarmConfig = BeanDtoVoUtils.convert(dto, PlatAlarmConfig.class); PlatAlarmConfig alarmConfig = BeanDtoVoUtils.convert(dto, PlatAlarmConfig.class);
updateById(alarmConfig); updateById(alarmConfig);
alarmConfigUtil.put(alarmConfig); PlatAlarmConfig entity = getById(dto.getId());
alarmConfigUtil.put(entity);
} }
......
...@@ -147,8 +147,13 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -147,8 +147,13 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
@Override @Override
public PlatAlarmRecordVO view(String recordId) { public PlatAlarmRecordVO view(String recordId) {
PlatAlarmRecord platAlarmRecord = getById(recordId); PlatAlarmRecord platAlarmRecord = getById(recordId);
if(platAlarmRecord == null ){
return null;
}
PlatAlarmRecordVO vo = BeanDtoVoUtils.convert(platAlarmRecord, PlatAlarmRecordVO.class); PlatAlarmRecordVO vo = BeanDtoVoUtils.convert(platAlarmRecord, PlatAlarmRecordVO.class);
JoinUtil.join(Arrays.asList(vo), platAlarmConfigService, PlatAlarmRecordVO::getAlarmId, BaseEntity::getId, (t, m) -> t.setNotifyRelation(m.getNotifyRelation())); if(StringUtils.isNotBlank(vo.getAlarmId())) {
JoinUtil.join(Arrays.asList(vo), platAlarmConfigService, PlatAlarmRecordVO::getAlarmId, BaseEntity::getId, (t, m) -> t.setNotifyRelation(m.getNotifyRelation()));
}
return vo; return vo;
} }
......
...@@ -11,6 +11,7 @@ import com.makeit.common.page.PageReqDTO; ...@@ -11,6 +11,7 @@ import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.auth.PlatOrgSplitDTO; import com.makeit.dto.platform.auth.PlatOrgSplitDTO;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleOrg; import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.entity.platform.auth.PlatUserRole; import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.entity.platform.space.PlatSpace; import com.makeit.entity.platform.space.PlatSpace;
...@@ -46,6 +47,7 @@ import java.util.HashSet; ...@@ -46,6 +47,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Function; import java.util.function.Function;
...@@ -305,7 +307,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -305,7 +307,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public void edit(PlatOrg dto) { public void edit(PlatOrg dto) {
check(dto); check(dto);
PlatOrg platOrg = this.getById(dto.getId()); PlatOrg platOrg = this.getById(dto.getId());
if (StringUtils.isBlank(dto.getParentId())||StringUtils.equals(dto.getParentId(),"1")) { if (StringUtils.isBlank(dto.getParentId())||StringUtils.equals(dto.getParentId(),TreeConst.TOP_LEVEL)) {
} else { } else {
PlatOrg parent = getById(dto.getParentId()); PlatOrg parent = getById(dto.getParentId());
dto.setPath(parent.getPath() + "," + parent.getId()); dto.setPath(parent.getPath() + "," + parent.getId());
...@@ -314,7 +316,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -314,7 +316,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
if(!StringUtils.equals(dto.getType(),platOrg.getType())){ if(!StringUtils.equals(dto.getType(),platOrg.getType())){
LambdaUpdateWrapper<PlatSpace> platSpaceLambdaUpdateWrapper = Wrappers.lambdaUpdate(PlatSpace.class) LambdaUpdateWrapper<PlatSpace> platSpaceLambdaUpdateWrapper = Wrappers.lambdaUpdate(PlatSpace.class)
.set(PlatSpace::getAttribute, dto.getType()) .set(PlatSpace::getAttribute, dto.getType())
.eq(PlatSpace::getOrgId, dto.getId()); .eq(PlatSpace::getOrgId, dto.getId())
.set(PlatSpace::getParentId,dto.getParentId())
;
platSpaceService.update(platSpaceLambdaUpdateWrapper); platSpaceService.update(platSpaceLambdaUpdateWrapper);
} }
...@@ -436,9 +440,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -436,9 +440,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
if (CollectionUtils.isEmpty(roleOrgList)) { if (CollectionUtils.isEmpty(roleOrgList)) {
return new HashSet<>(); return new HashSet<>();
} }
return roleOrgList.stream().map(PlatRoleOrg::getOrgId).collect(Collectors.toSet()); //return roleOrgList.stream().map(PlatRoleOrg::getOrgId).collect(Collectors.toSet());
// List<PlatRole> roleList = platRoleService.listByIds(roleOrgList.stream().map(PlatRoleOrg::getRoleId).collect(Collectors.toList())); List<PlatRole> roleList = platRoleService.listByIds(roleOrgList.stream().map(PlatRoleOrg::getRoleId).collect(Collectors.toList()));
// return roleList.stream().flatMap(vo -> Stream.of(Optional.ofNullable(vo.getDataScope()).orElse(new String()) .split(","))).collect(Collectors.toSet()); return roleList.stream().flatMap(vo -> Stream.of(Optional.ofNullable(vo.getDataScope()).orElse(new String()) .split(","))).collect(Collectors.toSet());
} }
/** /**
* 租户权限的组织树 * 租户权限的组织树
...@@ -593,7 +597,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -593,7 +597,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
vo.setChildren(parentMap.get(vo.getId())); vo.setChildren(parentMap.get(vo.getId()));
}); });
return orgList.stream().filter(vo->StringUtils.equals(vo.getParentId(),"1")).collect(Collectors.toList()); return orgList.stream().filter(vo->StringUtils.equals(vo.getParentId(),TreeConst.TOP_LEVEL)).collect(Collectors.toList());
} }
/** /**
......
...@@ -32,6 +32,7 @@ import com.makeit.enums.CodeMessageEnum; ...@@ -32,6 +32,7 @@ import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.enums.IsTenantAccountEnum; import com.makeit.enums.IsTenantAccountEnum;
import com.makeit.enums.biz.auth.SysEnum; import com.makeit.enums.biz.auth.SysEnum;
import com.makeit.enums.id.TreeConst;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdIgnore; import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.global.aspect.tenant.TenantIdUtil; import com.makeit.global.aspect.tenant.TenantIdUtil;
...@@ -368,9 +369,12 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -368,9 +369,12 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
PlatUser platUser = getOne(new QueryWrapper<PlatUser>().lambda() PlatUser platUser = getOne(new QueryWrapper<PlatUser>().lambda()
.eq(PlatUser::getAccount, loginDTO.getAccount()) .eq(PlatUser::getAccount, loginDTO.getAccount())
.or() //.or()
.eq(PlatUser::getMobile, loginDTO.getAccount()) //.eq(PlatUser::getMobile, loginDTO.getAccount())
); );
if(platUser == null ){
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_HAS_DISABLED);
}
checkTenantOrgStatus(platUser); checkTenantOrgStatus(platUser);
...@@ -423,8 +427,11 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -423,8 +427,11 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
} }
String path = platOrg.getPath(); String path = platOrg.getPath();
String[] split = StringUtils.split(path, ","); String[] split = StringUtils.split(path, ",");
ArrayList<String> orgIdList = new ArrayList<>();
orgIdList.addAll(Arrays.asList(split));
orgIdList.add(orgId);
LambdaQueryWrapper<PlatOrg> platOrgLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatOrg> platOrgLambdaQueryWrapper = new LambdaQueryWrapper<>();
platOrgLambdaQueryWrapper.in(BaseEntity::getId, split) platOrgLambdaQueryWrapper.in(BaseEntity::getId, orgIdList)
.eq(PlatOrg::getStatus, CommonEnum.NO.getValue()); .eq(PlatOrg::getStatus, CommonEnum.NO.getValue());
long count = platOrgService.count(platOrgLambdaQueryWrapper); long count = platOrgService.count(platOrgLambdaQueryWrapper);
if (count > 0) { if (count > 0) {
...@@ -657,6 +664,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -657,6 +664,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile()) .like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile())
.eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus()) .eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus())
.like(StringUtils.isNotBlank(dto.getEmail()),PlatUser::getEmail,dto.getEmail()) .like(StringUtils.isNotBlank(dto.getEmail()),PlatUser::getEmail,dto.getEmail())
.eq(StringUtils.isNotBlank(dto.getOrgId()),PlatUser::getOrgId,dto.getOrgId())
.eq(PlatUser::getTenantId, TenantIdUtil.getTenantId()); .eq(PlatUser::getTenantId, TenantIdUtil.getTenantId());
roleIdFilter(lambdaQueryWrapper, dto); roleIdFilter(lambdaQueryWrapper, dto);
...@@ -1056,7 +1064,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -1056,7 +1064,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
LambdaUpdateWrapper<PlatUser> updateWrapper = Wrappers.lambdaUpdate(PlatUser.class) LambdaUpdateWrapper<PlatUser> updateWrapper = Wrappers.lambdaUpdate(PlatUser.class)
.set(PlatUser::getTenantId, tenantId) .set(PlatUser::getTenantId, tenantId)
.set(PlatUser::getOrgId, tenantId) .set(PlatUser::getOrgId, tenantId)
.set(PlatUser::getOrgPath, tenantId) .set(PlatUser::getOrgPath, TreeConst.TOP_LEVEL+","+tenantId)
.eq(BaseEntity::getId, platUserId); .eq(BaseEntity::getId, platUserId);
this.update(updateWrapper); this.update(updateWrapper);
} }
......
...@@ -11,9 +11,12 @@ import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO; ...@@ -11,9 +11,12 @@ import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO; import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO; import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.vo.platform.device.PlatDeviceListVO; import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO; import com.makeit.vo.platform.device.PlatDeviceViewVO;
import java.util.List;
/** /**
* <p> * <p>
* 设备 服务类 * 设备 服务类
...@@ -55,4 +58,6 @@ public interface PlatDeviceService extends IService<PlatDevice> { ...@@ -55,4 +58,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
void saasEdit(PlatDeviceEditSaasDTO dto); void saasEdit(PlatDeviceEditSaasDTO dto);
void editDeviceProperties(PlatDeviceAttrWechatDTO dto); void editDeviceProperties(PlatDeviceAttrWechatDTO dto);
List<DeviceProperties> readDeviceProperties(PlatDeviceAttrWechatDTO dto);
} }
...@@ -2,8 +2,10 @@ package com.makeit.service.platform.device.impl; ...@@ -2,8 +2,10 @@ package com.makeit.service.platform.device.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.makeit.common.dto.BaseTenantDTO; import com.makeit.common.dto.BaseTenantDTO;
import com.makeit.common.entity.BaseBusEntity; import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity; import com.makeit.common.entity.BaseEntity;
...@@ -19,13 +21,16 @@ import com.makeit.dto.wechat.device.PlatDeviceSetupDTO; ...@@ -19,13 +21,16 @@ import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceOther; import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.entity.platform.space.PlatRegionSetting;
import com.makeit.enums.CodeMessageEnum; import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.device.PlatDeviceMapper; import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService; import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.device.PlatDeviceOtherService; import com.makeit.service.platform.device.PlatDeviceOtherService;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.service.saas.PlatTenantService; import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil; import com.makeit.utils.DeviceCacheUtil;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
...@@ -64,6 +69,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -64,6 +69,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private IotDevicePropertiesOperateService devicePropertiesOperateService; private IotDevicePropertiesOperateService devicePropertiesOperateService;
@Autowired @Autowired
private PlatTenantService platTenantService; private PlatTenantService platTenantService;
@Autowired
private PlatRegionSettingService platRegionSettingService;
@Override @Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) { public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
...@@ -196,6 +203,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -196,6 +203,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
deviceCacheUtil.put(db); deviceCacheUtil.put(db);
platDeviceOtherService.saveOrUpdate(other); platDeviceOtherService.saveOrUpdate(other);
//更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, other.getInstallation())
.eq(PlatRegionSetting::getDeviceId, other.getDeviceId()));
} }
@Override @Override
...@@ -234,6 +246,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -234,6 +246,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
deviceCacheUtil.put(db); deviceCacheUtil.put(db);
other.setOriDeviceId(db.getOriDeviceId());
platDeviceOtherService.saveOrUpdate(other); platDeviceOtherService.saveOrUpdate(other);
} }
...@@ -274,4 +287,21 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -274,4 +287,21 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
devicePropertiesOperateService.deviceWrite(dto.getDeviceId(),dto.getRadarMount(),dto.getRadarMode(),dto.getRadarHight()); devicePropertiesOperateService.deviceWrite(dto.getDeviceId(),dto.getRadarMount(),dto.getRadarMode(),dto.getRadarHight());
} }
@Override
public List<DeviceProperties> readDeviceProperties(PlatDeviceAttrWechatDTO dto) {
List<DeviceProperties> devicePropertiesList = Lists.newArrayList();
if (StringUtils.isNotEmpty(dto.getReadProperties())) {
String[] propertiesArr = dto.getReadProperties().split(",");
for (String s : propertiesArr) {
DeviceProperties deviceProperties = devicePropertiesOperateService.deviceRead(dto.getDeviceId(), s);
if (deviceProperties != null) {
deviceProperties.setProperty(s);
devicePropertiesList.add(deviceProperties);
}
}
}
return devicePropertiesList;
}
} }
...@@ -167,7 +167,7 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild ...@@ -167,7 +167,7 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
LinkedHashSet<String> linkedHashSet = new LinkedHashSet<>(list); LinkedHashSet<String> linkedHashSet = new LinkedHashSet<>(list);
linkedHashSet.add(elderId); linkedHashSet.add(elderId);
childrenInfo.setElderId(StreamUtil.join(new ArrayList<>(list), Function.identity())); childrenInfo.setElderId(StreamUtil.join(new ArrayList<>(linkedHashSet), Function.identity()));
updateById(childrenInfo); updateById(childrenInfo);
...@@ -185,7 +185,7 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild ...@@ -185,7 +185,7 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
LinkedHashSet<String> linkedHashSet = new LinkedHashSet<>(list); LinkedHashSet<String> linkedHashSet = new LinkedHashSet<>(list);
linkedHashSet.remove(elderId); linkedHashSet.remove(elderId);
childrenInfo.setElderId(StreamUtil.join(new ArrayList<>(list), Function.identity())); childrenInfo.setElderId(StreamUtil.join(new ArrayList<>(linkedHashSet), Function.identity()));
if (linkedHashSet.isEmpty()) { if (linkedHashSet.isEmpty()) {
childrenInfo.setElderId(null); childrenInfo.setElderId(null);
......
...@@ -366,6 +366,9 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -366,6 +366,9 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
vo.setX(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP)); vo.setX(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setY(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP)); vo.setY(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
return vo; return vo;
}) })
......
...@@ -367,15 +367,15 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -367,15 +367,15 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
String finalDeviceId = deviceId; String finalDeviceId = deviceId;
String finalOriDeviceId = oriDeviceId; String finalOriDeviceId = oriDeviceId;
lambdaQueryWrapper.and(qw -> { lambdaQueryWrapper.and(StringUtils.isNotBlank(platElderIdDTO.getElderId()) || StringUtils.isNotBlank(finalDeviceId) || StringUtils.isNotBlank(finalOriDeviceId), qw -> {
if (StringUtils.isNotBlank(platElderIdDTO.getElderId())) { if (StringUtils.isNotBlank(platElderIdDTO.getElderId())) {
lambdaQueryWrapper.eq(PlatElderBreatheDayStat::getElderId, platElderIdDTO.getElderId()); qw.eq(PlatElderBreatheDayStat::getElderId, platElderIdDTO.getElderId());
} }
if (StringUtils.isNotBlank(finalDeviceId)) { if (StringUtils.isNotBlank(finalDeviceId)) {
lambdaQueryWrapper.or().eq(PlatElderBreatheDayStat::getDeviceId, finalDeviceId); qw.or().eq(PlatElderBreatheDayStat::getDeviceId, finalDeviceId);
} }
if (StringUtils.isNotBlank(finalOriDeviceId)) { if (StringUtils.isNotBlank(finalOriDeviceId)) {
lambdaQueryWrapper.or().eq(PlatElderBreatheDayStat::getOriDeviceId, finalOriDeviceId); qw.or().eq(PlatElderBreatheDayStat::getOriDeviceId, finalOriDeviceId);
} }
}); });
......
...@@ -186,9 +186,13 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -186,9 +186,13 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
voList = StreamUtil.map(deviceInfoContentSpaceList, e -> { voList = StreamUtil.map(deviceInfoContentSpaceList, e -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO(); PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
vo.setX(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP)); vo.setX(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setY(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP)); vo.setY(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setDistance(e.getProperties().getDistance());
vo.setAngle(e.getProperties().getAngle());
return vo; return vo;
}); });
......
...@@ -14,6 +14,7 @@ import com.makeit.dto.platform.elder.PlatElderCheckOutDTO; ...@@ -14,6 +14,7 @@ import com.makeit.dto.platform.elder.PlatElderCheckOutDTO;
import com.makeit.dto.platform.elder.PlatElderImportDTO; import com.makeit.dto.platform.elder.PlatElderImportDTO;
import com.makeit.dto.platform.elder.PlatElderQueryDTO; import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.elder.add.*; import com.makeit.dto.platform.elder.add.*;
import com.makeit.dto.platform.space.PlatSpaceSplitDTO;
import com.makeit.dto.platform.space.TreeDTOVO; import com.makeit.dto.platform.space.TreeDTOVO;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
...@@ -108,7 +109,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -108,7 +109,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
.eq(StringUtils.isNotBlank(dto.getCertificateType()), PlatElder::getCertificateType, dto.getCertificateType()) .eq(StringUtils.isNotBlank(dto.getCertificateType()), PlatElder::getCertificateType, dto.getCertificateType())
.like(StringUtils.isNotBlank(dto.getCertificateNumber()), PlatElder::getCertificateNumber, dto.getCertificateNumber()) .like(StringUtils.isNotBlank(dto.getCertificateNumber()), PlatElder::getCertificateNumber, dto.getCertificateNumber())
.apply(StringUtils.isNotBlank(dto.getSpaceId()), "find_in_set('" + dto.getSpaceId() + "',space_path)") .apply(StringUtils.isNotBlank(dto.getSpaceId()), "find_in_set('" + dto.getSpaceId() + "',space_path)")
.apply(StringUtils.isNotBlank(dto.getOrgId()), "find_in_set('" + dto.getOrgId() + "',org_path)"); .apply(StringUtils.isNotBlank(dto.getOrgId()), "find_in_set('" + dto.getOrgId() + "',org_path)")
.orderByDesc(PlatElder::getId);
} }
@Override @Override
...@@ -204,6 +206,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -204,6 +206,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
} }
vo.setId(e.getId()); vo.setId(e.getId());
vo.setRemark(e.getRemark());
return vo; return vo;
}); });
...@@ -255,6 +258,12 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -255,6 +258,12 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
List<TreeDTOVO> treeList = BeanDtoVoUtils.listVo(spaceList, TreeDTOVO.class); List<TreeDTOVO> treeList = BeanDtoVoUtils.listVo(spaceList, TreeDTOVO.class);
treeList.forEach(e->{
if(StringUtils.isBlank(e.getParentId())){
e.setParentId(TreeConst.TOP_LEVEL);
}
});
List<PlatRoom> roomList = platRoomService.list(new QueryWrapper<PlatRoom>().lambda() List<PlatRoom> roomList = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getName, spaceNameList)); .in(PlatRoom::getName, spaceNameList));
...@@ -289,7 +298,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -289,7 +298,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
TreeDTOVO::getParentId, Collectors.toMap(TreeDTOVO::getName, Function.identity()) TreeDTOVO::getParentId, Collectors.toMap(TreeDTOVO::getName, Function.identity())
)); ));
ExcelImportVo excelImportVo = ExcelValidatorUtil.validateMain(list, l -> { ExcelImportVo excelImportVo = ExcelValidatorUtil.validateMain(3, list, l -> {
int start = 3; int start = 3;
List<ExcelErrorVo> errorVoList = new ArrayList<>(10); List<ExcelErrorVo> errorVoList = new ArrayList<>(10);
...@@ -415,7 +424,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -415,7 +424,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
spaceIdList = new ArrayList<>(10); spaceIdList = new ArrayList<>(10);
spaceIdList.add(lastSpaceId); spaceIdList.add(lastSpaceId);
for (int j = 0; j <= 2; j++) { for (int j = 0; j <= 1; j++) {
String id = null; String id = null;
Map<String, TreeDTOVO> nameAreaMap = parentIdName.get(spaceIdList.get(j)); Map<String, TreeDTOVO> nameAreaMap = parentIdName.get(spaceIdList.get(j));
...@@ -455,6 +464,20 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -455,6 +464,20 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
if (errorVoList.isEmpty()) { if (errorVoList.isEmpty()) {
List<PlatElder> platElderList = BeanDtoVoUtils.listVo(list, PlatElder.class); List<PlatElder> platElderList = BeanDtoVoUtils.listVo(list, PlatElder.class);
platElderList.forEach(e -> {
List<String> spaceIdList = new ArrayList<>(Arrays.asList(e.getStreetSpaceId(), e.getBuildingSpaceId(), e.getUnitSpaceId(), e.getFloorSpaceId()));
List<String> newSpaceIdList = new ArrayList<>(spaceIdList);
Collections.reverse(newSpaceIdList);
e.setSpaceId(newSpaceIdList.stream().filter(StringUtils::isNotBlank).findFirst().orElse(null));
spaceIdList.add(e.getRoomId());
spaceIdList.add(e.getBedId());
e.setSpacePath(spaceIdList.stream().filter(StringUtils::isNotBlank).collect(Collectors.joining(",")));
});
PlatUserVO platUserVO = PlatUserUtil.getUserVO(); PlatUserVO platUserVO = PlatUserUtil.getUserVO();
platElderList.forEach(e -> { platElderList.forEach(e -> {
...@@ -490,6 +513,25 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -490,6 +513,25 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
} }
private void fillSpace(PlatElder platElder) {
if (StringUtils.isBlank(platElder.getBedId())) {
return;
}
PlatSpaceSplitDTO platSpaceSplitDTO = platSpaceService.getSpaceSplitVO(platElder.getBedId());
platElder.setSpaceId(platSpaceSplitDTO.getSpaceId());
platElder.setStreetSpaceId(platSpaceSplitDTO.getStreetSpaceId());
platElder.setBuildingSpaceId(platSpaceSplitDTO.getBuildingSpaceId());
platElder.setUnitSpaceId(platSpaceSplitDTO.getUnitSpaceId());
platElder.setFloorSpaceId(platSpaceSplitDTO.getFloorSpaceId());
platElder.setRoomId(platSpaceSplitDTO.getRoomId());
//platElder.setBedId();
platElder.setSpacePath(platSpaceSplitDTO.getSpacePath());
}
@Override @Override
@Transactional @Transactional
public void add(PlatElderAddDTO dto) { public void add(PlatElderAddDTO dto) {
...@@ -498,6 +540,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -498,6 +540,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class); PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
fillSpace(platElder);
PlatUserVO userVO = PlatUserUtil.getUserVO(); PlatUserVO userVO = PlatUserUtil.getUserVO();
platElder.setOrgId(userVO.getOrgId()); platElder.setOrgId(userVO.getOrgId());
...@@ -521,6 +565,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -521,6 +565,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class); PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
fillSpace(platElder);
PlatUserVO userVO = PlatUserUtil.getUserVO(); PlatUserVO userVO = PlatUserUtil.getUserVO();
platElder.setOrgId(userVO.getOrgId()); platElder.setOrgId(userVO.getOrgId());
...@@ -600,6 +646,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -600,6 +646,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class); PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
fillSpace(platElder);
updateById(platElder); updateById(platElder);
addOrEditExt(dto); addOrEditExt(dto);
...@@ -611,6 +659,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -611,6 +659,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
} }
//@TenantIdIgnore
@Override @Override
public PlatElderDTOVO view(String id) { public PlatElderDTOVO view(String id) {
PlatElder platElder = getById(id); PlatElder platElder = getById(id);
...@@ -695,6 +744,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -695,6 +744,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder db = getById(dto.getId()); PlatElder db = getById(dto.getId());
BeanUtils.copyProperties(dto, db); BeanUtils.copyProperties(dto, db);
fillSpace(db);
db.setCheckInTime(LocalDateTime.now()); db.setCheckInTime(LocalDateTime.now());
updateById(db); updateById(db);
...@@ -741,7 +792,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -741,7 +792,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
platBedService.changeStatus(statusDTO); platBedService.changeStatus(statusDTO);
if (CommonEnum.YES.getValue().equals(dto.getDelRoomStatus())) { if (CommonEnum.YES.getValue().equals(dto.getDelRoomStatus())) {
platRoomService.delCascade(Arrays.asList(platBedService.getById(db.getBedId()).getRoomId())); platRoomService.delCascade(Arrays.asList(platBedService.getById(bedId).getRoomId()));
} }
} }
...@@ -808,6 +859,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -808,6 +859,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
return platRoomBedDeviceService.getFallDevice(platElder.getBedId()); return platRoomBedDeviceService.getFallDevice(platElder.getBedId());
} }
//@TenantIdIgnore
@Override @Override
public List<PlatElderWechatSimpleVO> listMy() { public List<PlatElderWechatSimpleVO> listMy() {
PlatElderChildrenInfoWechatVO childrenInfo = platElderChildrenInfoService.view(); PlatElderChildrenInfoWechatVO childrenInfo = platElderChildrenInfoService.view();
......
...@@ -143,6 +143,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -143,6 +143,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
continue; continue;
} }
String tenantId = elder.getTenantId(); String tenantId = elder.getTenantId();
String reportStartTime = "";
String reportEndTime = "";
for (String hourRange : dayHourRangeList) { for (String hourRange : dayHourRangeList) {
String[] hourRangeArray = hourRange.split("~"); String[] hourRangeArray = hourRange.split("~");
List<DeviceOperationLogEntity> deviceOperationLogEntities = productDeviceService.getDeviceLogByTimeRange(platRoomBedDevice.getDeviceId(), "reportProperty", 5000, hourRangeArray[0], hourRangeArray[1]); List<DeviceOperationLogEntity> deviceOperationLogEntities = productDeviceService.getDeviceLogByTimeRange(platRoomBedDevice.getDeviceId(), "reportProperty", 5000, hourRangeArray[0], hourRangeArray[1]);
...@@ -163,7 +165,13 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -163,7 +165,13 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
List<DeviceInfoContentBreathe> deviceInfoContentBreathes; List<DeviceInfoContentBreathe> deviceInfoContentBreathes;
// 统计每小时的体动和翻身 // 统计每小时的体动和翻身
Map<String, AnalysisVO> statisticsMap = Maps.newHashMap(); Map<String, AnalysisVO> statisticsMap = Maps.newHashMap();
for (Map.Entry<String, List<DeviceInfoContentBreathe>> entry : minuteMap.entrySet()) { for (Map.Entry<String, List<DeviceInfoContentBreathe>> entry : minuteMap.entrySet()) {
if (StringUtils.isEmpty(reportStartTime)) {
reportStartTime = entry.getKey();
}
reportEndTime = entry.getKey();
deviceInfoContentBreathes = entry.getValue(); deviceInfoContentBreathes = entry.getValue();
DeviceInfoContentBreathe.Properties breatheProperties; DeviceInfoContentBreathe.Properties breatheProperties;
Integer bodymove; Integer bodymove;
...@@ -453,12 +461,19 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -453,12 +461,19 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
} }
int timeHourRange = 24;
if (StringUtils.isNotEmpty(reportStartTime) && StringUtils.isNotEmpty(reportEndTime)) {
Long durationRange = getDurationRange(reportStartTime, reportEndTime);
timeHourRange = (int) (durationRange / 60);
}
// 判断是否满足配置的呼吸心率异常类型 // 判断是否满足配置的呼吸心率异常类型
BigDecimal dayBrStopRate = brStopCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(brStopCount), 2, RoundingMode.HALF_UP); BigDecimal dayBrStopRate = brStopCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(brStopCount), 2, RoundingMode.HALF_UP);
BigDecimal dayBrSlowRate = brSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(brSlowCount), 2, RoundingMode.HALF_UP); BigDecimal dayBrSlowRate = brSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(brSlowCount), 2, RoundingMode.HALF_UP);
BigDecimal dayBrFastRate = brFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(brFastCount), 2, RoundingMode.HALF_UP); BigDecimal dayBrFastRate = brFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(brFastCount), 2, RoundingMode.HALF_UP);
BigDecimal dayHrFastRate = hrFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(hrFastCount), 2, RoundingMode.HALF_UP); BigDecimal dayHrFastRate = hrFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(hrFastCount), 2, RoundingMode.HALF_UP);
BigDecimal dayHrSlowRate = hrSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(hrSlowCount), 2, RoundingMode.HALF_UP); BigDecimal dayHrSlowRate = hrSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(hrSlowCount), 2, RoundingMode.HALF_UP);
boolean brStopFlag = false; boolean brStopFlag = false;
boolean brFastFlag = false; boolean brFastFlag = false;
...@@ -537,8 +552,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -537,8 +552,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
// 插入呼吸分析表 // 插入呼吸分析表
PlatElderBreatheAnalysis platElderBreatheAnalysis = new PlatElderBreatheAnalysis(); PlatElderBreatheAnalysis platElderBreatheAnalysis = new PlatElderBreatheAnalysis();
platElderBreatheAnalysis.setElderId(elder.getId()); platElderBreatheAnalysis.setElderId(elder.getId());
platElderBreatheAnalysis.setAvgBreatheRate(String.valueOf(dayTotalBr / 86400)); platElderBreatheAnalysis.setAvgBreatheRate(String.valueOf(dayTotalBr / (timeHourRange * 60 * 60)));
platElderBreatheAnalysis.setAvgHeartRate(String.valueOf(dayTotalHr / 86400)); platElderBreatheAnalysis.setAvgHeartRate(String.valueOf(dayTotalHr / (timeHourRange * 60 * 60)));
platElderBreatheAnalysis.setBreatheScore(finalReport.getScore()); platElderBreatheAnalysis.setBreatheScore(finalReport.getScore());
platElderBreatheAnalysis.setHappenDate(currentDate); platElderBreatheAnalysis.setHappenDate(currentDate);
platElderBreatheAnalysis.setTenantId(tenantId); platElderBreatheAnalysis.setTenantId(tenantId);
......
...@@ -5,6 +5,7 @@ import com.makeit.common.dto.BaseIdDTO; ...@@ -5,6 +5,7 @@ import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.vo.ExcelImportVo; import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.space.PlatSpaceAddDTO; import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO; import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceSplitDTO;
import com.makeit.dto.platform.space.PlatSpaceVO; import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.entity.platform.space.PlatSpace; import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO; import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
...@@ -61,6 +62,8 @@ public interface PlatSpaceService extends IService<PlatSpace> { ...@@ -61,6 +62,8 @@ public interface PlatSpaceService extends IService<PlatSpace> {
*/ */
List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto); List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto);
PlatSpaceSplitDTO getSpaceSplitVO(String bedId);
List<PlatSpace> listChild(List<String> spaceIds); List<PlatSpace> listChild(List<String> spaceIds);
List<PlatSpaceAddDTO> oneLevelList(BaseIdDTO dto); List<PlatSpaceAddDTO> oneLevelList(BaseIdDTO dto);
...@@ -74,7 +77,7 @@ public interface PlatSpaceService extends IService<PlatSpace> { ...@@ -74,7 +77,7 @@ public interface PlatSpaceService extends IService<PlatSpace> {
* @param excelFile * @param excelFile
* @return * @return
*/ */
public ExcelImportVo importSpaceExcel(MultipartFile excelFile); ExcelImportVo importSpaceExcel(MultipartFile excelFile);
List<PlatSpaceVO> parentListTree(PlatSpaceQueryDTO dto); List<PlatSpaceVO> parentListTree(PlatSpaceQueryDTO dto);
} }
...@@ -22,6 +22,7 @@ import com.makeit.utils.data.convert.BeanDtoVoUtils; ...@@ -22,6 +22,7 @@ import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.JsonUtil; import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.data.validate.CollectionUtils; import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -103,7 +104,6 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM ...@@ -103,7 +104,6 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
List<PlatRegionSetting> list = list(queryWrapper); List<PlatRegionSetting> list = list(queryWrapper);
List<PlatRegionSettingDTO> data = BeanDtoVoUtils.listVo(list,PlatRegionSettingDTO.class); List<PlatRegionSettingDTO> data = BeanDtoVoUtils.listVo(list,PlatRegionSettingDTO.class);
if(!list.isEmpty()){ if(!list.isEmpty()){
List<String> listDeviceIds = data.stream().map(item->item.getDeviceId()).collect(Collectors.toList()); List<String> listDeviceIds = data.stream().map(item->item.getDeviceId()).collect(Collectors.toList());
LambdaQueryWrapper<PlatDevice> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatDevice> queryWrapper1 = new LambdaQueryWrapper<>();
...@@ -112,11 +112,15 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM ...@@ -112,11 +112,15 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
List<PlatDevice> devices = platDeviceService.list(queryWrapper1); List<PlatDevice> devices = platDeviceService.list(queryWrapper1);
Map<String,String> map = devices.stream().collect(Collectors.toMap(PlatDevice::getId,PlatDevice::getName,(k1,k2)->k1)); Map<String,String> map = devices.stream().collect(Collectors.toMap(PlatDevice::getId,PlatDevice::getName,(k1,k2)->k1));
Map<String,String> oriDeviceIdMap = devices.stream().collect(Collectors.toMap(PlatDevice::getId,PlatDevice::getOriDeviceId,(k1,k2)->k1)); Map<String,String> oriDeviceIdMap = devices.stream().collect(Collectors.toMap(PlatDevice::getId,PlatDevice::getOriDeviceId,(k1,k2)->k1));
List<String> deviceIds = devices.stream().map(PlatDevice::getId).collect(Collectors.toList());
data.forEach(item->{ data.forEach(item->{
item.setDeviceName(map.get(item.getDeviceId())); item.setDeviceName(map.get(item.getDeviceId()));
item.setOriDeviceId(oriDeviceIdMap.get(item.getDeviceId())); item.setOriDeviceId(oriDeviceIdMap.get(item.getDeviceId()));
}); });
//过滤删除的设备
data = data.stream().filter(t-> deviceIds.contains(t.getDeviceId())).collect(Collectors.toList());
} }
return data; return data;
} }
......
...@@ -21,6 +21,7 @@ import com.makeit.service.platform.space.PlatBedService; ...@@ -21,6 +21,7 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomService; import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService; import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.TreeUtil;
import com.makeit.utils.data.excel.ExcelUtil; import com.makeit.utils.data.excel.ExcelUtil;
import com.makeit.utils.user.TokenUtil; import com.makeit.utils.user.TokenUtil;
import com.makeit.utils.user.plat.PlatUserUtil; import com.makeit.utils.user.plat.PlatUserUtil;
...@@ -30,12 +31,14 @@ import jodd.util.StringUtil; ...@@ -30,12 +31,14 @@ import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.BiConsumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -53,18 +56,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -53,18 +56,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Autowired @Autowired
private PlatOrgService platOrgService; private PlatOrgService platOrgService;
private void check(PlatSpaceAddDTO dto){ private void check(PlatSpaceAddDTO dto) {
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatSpace::getName,dto.getName()); queryWrapper.eq(PlatSpace::getName, dto.getName());
queryWrapper.ne(StringUtil.isNotEmpty(dto.getId()), PlatSpace::getId,dto.getId()); queryWrapper.ne(StringUtil.isNotEmpty(dto.getId()), PlatSpace::getId, dto.getId());
if(StringUtil.isEmpty(dto.getParentId())){ if (StringUtil.isEmpty(dto.getParentId())) {
queryWrapper.isNull(PlatSpace::getParentId); queryWrapper.isNull(PlatSpace::getParentId);
}else{ } else {
queryWrapper.eq(PlatSpace::getParentId,dto.getParentId()); queryWrapper.eq(PlatSpace::getParentId, dto.getParentId());
} }
if(this.count(queryWrapper) > 0){ if (this.count(queryWrapper) > 0) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NAME_DUPLICATE); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NAME_DUPLICATE);
} }
} }
...@@ -75,17 +78,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -75,17 +78,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public void add(PlatSpaceAddDTO dto) { public void add(PlatSpaceAddDTO dto) {
check(dto); check(dto);
PlatSpace space = BeanDtoVoUtils.convert(dto, PlatSpace.class); PlatSpace space = BeanDtoVoUtils.convert(dto, PlatSpace.class);
if(StringUtil.isEmpty(dto.getParentId())){ if (StringUtil.isEmpty(dto.getParentId())) {
PlatUserVO userVO = PlatUserUtil.getUserVOCanNull(); PlatUserVO userVO = PlatUserUtil.getUserVOCanNull();
if(StringUtil.isEmpty(userVO.getOrgId())){ if (StringUtil.isEmpty(userVO.getOrgId())) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_USER_NOT_ADD); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_USER_NOT_ADD);
} }
space.setOrgId(userVO.getOrgId()); space.setOrgId(userVO.getOrgId());
PlatOrg org = platOrgService.getById(space.getOrgId()); PlatOrg org = platOrgService.getById(space.getOrgId());
if(org!=null){ if (org != null) {
space.setAttribute(org.getType()); space.setAttribute(org.getType());
} }
}else { } else {
//上级空间 //上级空间
PlatSpace parentSpace = getById(dto.getParentId()); PlatSpace parentSpace = getById(dto.getParentId());
space.setOrgId(parentSpace.getOrgId()); space.setOrgId(parentSpace.getOrgId());
...@@ -111,7 +114,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -111,7 +114,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
//上级空间 //上级空间
PlatSpace parentSpace = this.getById(dto.getParentId()); PlatSpace parentSpace = this.getById(dto.getParentId());
if(parentSpace.getParentPath().contains(dto.getId())){ if (parentSpace!=null && parentSpace.getParentPath().contains(dto.getId())) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL);
} }
...@@ -123,14 +126,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -123,14 +126,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public void del(String id) { public void del(String id) {
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatSpace::getParentId,id); queryWrapper.eq(PlatSpace::getParentId, id);
if(count(queryWrapper) > 0){ if (count(queryWrapper) > 0) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL);
} }
LambdaQueryWrapper<PlatRoom> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatRoom> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PlatRoom::getSpaceId,id); queryWrapper1.eq(PlatRoom::getSpaceId, id);
if(platRoomService.count(queryWrapper1) > 0){ if (platRoomService.count(queryWrapper1) > 0) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL); throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_DEL);
} }
...@@ -141,26 +144,26 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -141,26 +144,26 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public List<PlatSpaceVO> tree(PlatSpaceQueryDTO dto) { public List<PlatSpaceVO> tree(PlatSpaceQueryDTO dto) {
//查询用户权限组织id //查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg()); List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if(orgs.isEmpty()){ if (orgs.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList()); List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName()); queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatSpace::getName, dto.getName());
queryWrapper.in(PlatSpace::getOrgId, orgIds); queryWrapper.in(PlatSpace::getOrgId, orgIds);
List<PlatSpace> list = this.list(queryWrapper); List<PlatSpace> list = this.list(queryWrapper);
//父级 //父级
List<PlatSpace> listParent = list.stream().filter(item->StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList()); List<PlatSpace> listParent = list.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集 //子集
List<PlatSpace> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList()); List<PlatSpace> listChild = list.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId)); Map<String, List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
List<PlatSpaceVO> data = new ArrayList<>(); List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpace space:listParent){ for (PlatSpace space : listParent) {
PlatSpaceVO vo = convertToVO(space); PlatSpaceVO vo = convertToVO(space);
vo = child(vo,map); vo = child(vo, map);
data.add(vo); data.add(vo);
} }
return data; return data;
...@@ -169,7 +172,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -169,7 +172,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Override @Override
public PlatSpaceAddDTO view(String id) { public PlatSpaceAddDTO view(String id) {
PlatSpace space = getById(id); PlatSpace space = getById(id);
PlatSpaceAddDTO data = BeanDtoVoUtils.convert(space,PlatSpaceAddDTO.class); PlatSpaceAddDTO data = BeanDtoVoUtils.convert(space, PlatSpaceAddDTO.class);
return data; return data;
} }
...@@ -190,10 +193,10 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -190,10 +193,10 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PlatBed::getStatus, CommonEnum.YES.getValue()); queryWrapper1.eq(PlatBed::getStatus, CommonEnum.YES.getValue());
List<PlatBed> listBeds = platBedService.list(queryWrapper1); List<PlatBed> listBeds = platBedService.list(queryWrapper1);
Map<String,List<PlatBed>> mapBed = listBeds.stream().collect(Collectors.groupingBy(PlatBed::getRoomId)); Map<String, List<PlatBed>> mapBed = listBeds.stream().collect(Collectors.groupingBy(PlatBed::getRoomId));
List<PlatSpaceVO> listRoomVo = new ArrayList<>(); List<PlatSpaceVO> listRoomVo = new ArrayList<>();
listRoom.forEach(item->{ listRoom.forEach(item -> {
PlatSpaceVO vo = new PlatSpaceVO(); PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId()); vo.setId(item.getId());
vo.setName(item.getName()); vo.setName(item.getName());
...@@ -201,7 +204,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -201,7 +204,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
listRoomVo.add(vo); listRoomVo.add(vo);
}); });
listBeds.forEach(item->{ listBeds.forEach(item -> {
PlatSpaceVO vo = new PlatSpaceVO(); PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId()); vo.setId(item.getId());
vo.setName(item.getName()); vo.setName(item.getName());
...@@ -210,25 +213,25 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -210,25 +213,25 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}); });
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName()); queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatSpace::getName, dto.getName());
queryWrapper.eq(StringUtil.isNotEmpty(userVO.getOrgId()),PlatSpace::getOrgId,userVO.getOrgId()); queryWrapper.eq(StringUtil.isNotEmpty(userVO.getOrgId()), PlatSpace::getOrgId, userVO.getOrgId());
List<PlatSpace> list = this.list(queryWrapper); List<PlatSpace> list = this.list(queryWrapper);
List<PlatSpaceVO> listSpaceVo = BeanDtoVoUtils.listVo(list,PlatSpaceVO.class); List<PlatSpaceVO> listSpaceVo = BeanDtoVoUtils.listVo(list, PlatSpaceVO.class);
listSpaceVo.addAll(listRoomVo); listSpaceVo.addAll(listRoomVo);
//父级 //父级
List<PlatSpaceVO> listParent = listSpaceVo.stream().filter(item->StringUtil.isEmpty(item.getParentId())). List<PlatSpaceVO> listParent = listSpaceVo.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).
collect(Collectors.toList()); collect(Collectors.toList());
//子集 //子集
List<PlatSpaceVO> listChild = listSpaceVo.stream().filter(item->item.getParentId() != null).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)); Map<String, List<PlatSpaceVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceVO::getParentId));
List<PlatSpaceVO> data = new ArrayList<>(); List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpaceVO space:listParent){ for (PlatSpaceVO space : listParent) {
space = childVo(space,map); space = childVo(space, map);
data.add(space); data.add(space);
} }
return data; return data;
...@@ -236,6 +239,39 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -236,6 +239,39 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
@Override @Override
public PlatSpaceSplitDTO getSpaceSplitVO(String bedId) {
PlatBed platBed = platBedService.getById(bedId);
PlatRoom platRoom = platRoomService.getById(platBed.getRoomId());
PlatSpace platSpace = getById(platRoom.getSpaceId());
PlatSpaceSplitDTO platSpaceSplitDTO = new PlatSpaceSplitDTO();
platSpaceSplitDTO.setSpaceId(platSpace.getId());
List<BiConsumer<PlatSpaceSplitDTO, String>> list = Arrays.asList(
PlatSpaceSplitDTO::setStreetSpaceId,
PlatSpaceSplitDTO::setBuildingSpaceId,
PlatSpaceSplitDTO::setUnitSpaceId,
PlatSpaceSplitDTO::setFloorSpaceId
);
String[] split = TreeUtil.path(platSpace.getParentPath(), Arrays.asList(platSpace.getId())).split(",");
for (int i = 0; i < split.length; i++) {
BiConsumer<PlatSpaceSplitDTO, String> e = list.get(i);
e.accept(platSpaceSplitDTO, split[i]);
}
platSpaceSplitDTO.setRoomId(platRoom.getId());
platSpaceSplitDTO.setBedId(platBed.getId());
platSpaceSplitDTO.setSpacePath(TreeUtil.path(platSpace.getParentPath(), Arrays.asList(
platSpace.getId(),
platRoom.getId(),
platBed.getId()
)));
return platSpaceSplitDTO;
}
@Override
public List<PlatSpace> listChild(List<String> spaceIds) { public List<PlatSpace> listChild(List<String> spaceIds) {
return baseMapper.listChild(spaceIds); return baseMapper.listChild(spaceIds);
...@@ -250,7 +286,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -250,7 +286,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return BeanDtoVoUtils.listVo(spaces, PlatSpaceAddDTO.class); return BeanDtoVoUtils.listVo(spaces, PlatSpaceAddDTO.class);
} }
private PlatSpaceVO childVo(PlatSpaceVO vo,Map<String,List<PlatSpaceVO>> map) { private PlatSpaceVO childVo(PlatSpaceVO vo, Map<String, List<PlatSpaceVO>> map) {
if (!map.containsKey(vo.getId())) { if (!map.containsKey(vo.getId())) {
return vo; return vo;
...@@ -268,17 +304,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -268,17 +304,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Override @Override
public PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){ public PlatSpaceVO child(PlatSpaceVO vo, Map<String, List<PlatSpace>> map) {
if(!map.containsKey(vo.getId())){ if (!map.containsKey(vo.getId())) {
return vo; return vo;
} }
List<PlatSpace> list = map.get(vo.getId()); List<PlatSpace> list = map.get(vo.getId());
List<PlatSpaceVO> listChild = new ArrayList<>(); List<PlatSpaceVO> listChild = new ArrayList<>();
for(PlatSpace item:list){ for (PlatSpace item : list) {
PlatSpaceVO dto = convertToVO(item); PlatSpaceVO dto = convertToVO(item);
this.child(dto,map); this.child(dto, map);
listChild.add(dto); listChild.add(dto);
} }
vo.setChildren(listChild); vo.setChildren(listChild);
...@@ -286,7 +322,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -286,7 +322,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
@Override @Override
public PlatSpaceVO convertToVO(PlatSpace space){ public PlatSpaceVO convertToVO(PlatSpace space) {
PlatSpaceVO vo = new PlatSpaceVO(); PlatSpaceVO vo = new PlatSpaceVO();
vo.setName(space.getName()); vo.setName(space.getName());
...@@ -297,7 +333,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -297,7 +333,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public ExcelImportVo importSpaceExcel(MultipartFile excelFile) { public ExcelImportVo importSpaceExcel(MultipartFile excelFile) {
ExcelImportVo excelImportVo = new ExcelImportVo(); ExcelImportVo excelImportVo = new ExcelImportVo();
...@@ -305,18 +341,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -305,18 +341,18 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
try { try {
List<PlatSpace> listPlatSpace = list(new LambdaQueryWrapper<>()); 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 -> item.getParentId() == null).collect(Collectors.toList());
Map<String,String> firstSpaceNameMap = firstSpace.stream().collect(Collectors.toMap(PlatSpace::getName,PlatSpace::getId,(k1,k2)->k1)); 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 -> item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> childrenMap = listChildren.stream().collect(Collectors.groupingBy(PlatSpace::getParentId)); 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<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null,3,excelFile,PlatSpaceImportDTO.class); List<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null, 3, excelFile, PlatSpaceImportDTO.class);
List<ExcelErrorVo> errorVoList = new ArrayList<>(10); List<ExcelErrorVo> errorVoList = new ArrayList<>(10);
List<String> excelField = Arrays.asList("一级*","二级","三级","四级","房间名*","床位数量"); List<String> excelField = Arrays.asList("一级*", "二级", "三级", "四级", "房间名*", "床位数量");
int startRow = 3; int startRow = 3;
...@@ -331,75 +367,77 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -331,75 +367,77 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
Integer errorCount = 0; Integer errorCount = 0;
Integer successCount = 0; Integer successCount = 0;
boolean errorFlag = false; boolean errorFlag = false;
for(int i=0;i<list.size();i++){ for (int i = 0; i < list.size(); i++) {
PlatSpaceImportDTO item = list.get(i); PlatSpaceImportDTO item = list.get(i);
if(StringUtil.isEmpty(item.getCommunity())){ if (StringUtil.isEmpty(item.getCommunity())) {
errorVoList.add(new ExcelErrorVo(i+3,excelField.get(0),"第一层级必填")); errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "第一层级必填"));
errorFlag = true; errorFlag = true;
} }
if(StringUtil.isEmpty(item.getFloor())){ if (StringUtil.isEmpty(item.getRoomName())) {
errorVoList.add(new ExcelErrorVo(i+3,excelField.get(4),"房间名必填")); errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(4), "房间名必填"));
errorFlag = true; errorFlag = true;
} }
String key = item.getCommunity(); String key = item.getCommunity();
//第二层级 //第二层级
if(StringUtil.isNotEmpty(item.getBuilding())){ if (StringUtil.isNotEmpty(item.getBuilding())) {
key = key + "-" + item.getBuilding(); key = key + "-" + item.getBuilding();
} }
//第三层级 //第三层级
if(StringUtil.isNotEmpty(item.getUnit())){ if (StringUtil.isNotEmpty(item.getUnit())) {
key = key + "-" + item.getUnit(); key = key + "-" + item.getUnit();
} }
//第四层级 //第四层级
if(StringUtil.isNotEmpty(item.getFloor())){ if (StringUtil.isNotEmpty(item.getFloor())) {
key = key + "-" + item.getFloor(); key = key + "-" + item.getFloor();
} }
if(listKey.contains(key)){ if (listKey.contains(key)) {
errorVoList.add(new ExcelErrorVo(i+3,excelField.get(0),"该空间下,房间名已存在")); errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下,房间名已存在"));
errorFlag = true; errorFlag = true;
} }
if(errorFlag){ if (errorFlag) {
errorCount++; errorCount++;
}else{ } else {
successCount++; successCount++;
} }
} }
String orgId = TokenUtil.getTntUserDetail().getOrgId(); String orgId = TokenUtil.getTntUserDetail().getOrgId();
if(errorVoList.isEmpty()){ if (errorVoList.isEmpty()) {
for(int i=0;i<list.size();i++){ for (int i = 0; i < list.size(); i++) {
PlatSpaceImportDTO item = list.get(i); PlatSpaceImportDTO item = list.get(i);
String spacePath = null;
//第一层级 //第一层级
String firstId = null; String firstId = null;
if(!firstSpaceNameMap.containsKey(item.getCommunity())){ if (!firstSpaceNameMap.containsKey(item.getCommunity())) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getCommunity()); platSpace.setName(item.getCommunity());
platSpace.setType(PlatSpaceEnum.TypeEnum.COMMUNITY.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.COMMUNITY.getValue());
platSpace.setOrgId(orgId); platSpace.setOrgId(orgId);
save(platSpace); save(platSpace);
firstSpaceNameMap.put(platSpace.getName(),platSpace.getId()); firstSpaceNameMap.put(platSpace.getName(), platSpace.getId());
firstId = platSpace.getId(); firstId = platSpace.getId();
}else{ spacePath = firstId;
} else {
firstId = firstSpaceNameMap.get(item.getCommunity()); firstId = firstSpaceNameMap.get(item.getCommunity());
} }
//第二层级 //第二层级
String secondId = null; String secondId = null;
if(StringUtil.isNotEmpty(item.getBuilding())){ if (StringUtil.isNotEmpty(item.getBuilding())) {
String secondKey = firstId + "-" + item.getBuilding(); String secondKey = firstId + "-" + item.getBuilding();
if(!childrenIdMap.containsKey(secondKey)){ if (!childrenIdMap.containsKey(secondKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding()); platSpace.setName(item.getBuilding());
platSpace.setType(PlatSpaceEnum.TypeEnum.BUILDING.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.BUILDING.getValue());
...@@ -407,51 +445,54 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -407,51 +445,54 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
platSpace.setParentId(firstId); platSpace.setParentId(firstId);
platSpace.setParentPath(firstId); platSpace.setParentPath(firstId);
save(platSpace); save(platSpace);
childrenIdMap.put(secondKey,platSpace.getId()); childrenIdMap.put(secondKey, platSpace.getId());
secondId = platSpace.getId(); secondId = platSpace.getId();
}else{ } else {
secondId = childrenIdMap.get(secondKey); secondId = childrenIdMap.get(secondKey);
} }
spacePath = spacePath + "," + secondId;
} }
//第三级 //第三级
String threeId = null; String threeId = null;
if(StringUtil.isNotEmpty(item.getUnit())){ if (StringUtil.isNotEmpty(item.getUnit())) {
String threeKey = secondId + "-" + item.getUnit(); String threeKey = secondId + "-" + item.getUnit();
if(!childrenIdMap.containsKey(threeKey)){ if (!childrenIdMap.containsKey(threeKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding()); platSpace.setName(item.getBuilding());
platSpace.setType(PlatSpaceEnum.TypeEnum.UNIT.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.UNIT.getValue());
platSpace.setOrgId(orgId); platSpace.setOrgId(orgId);
platSpace.setParentId(secondId); platSpace.setParentId(secondId);
platSpace.setParentPath(firstId+","+secondId); platSpace.setParentPath(firstId + "," + secondId);
save(platSpace); save(platSpace);
childrenIdMap.put(threeKey,platSpace.getId()); childrenIdMap.put(threeKey, platSpace.getId());
threeId = platSpace.getId(); threeId = platSpace.getId();
}else{ } else {
threeId = childrenIdMap.get(threeKey); threeId = childrenIdMap.get(threeKey);
} }
spacePath = spacePath + "," + threeId;
} }
//第四级 //第四级
String fourId = null; String fourId = null;
if(StringUtil.isNotEmpty(item.getFloor())){ if (StringUtil.isNotEmpty(item.getFloor())) {
String fourKey = threeId + "-" + item.getFloor(); String fourKey = threeId + "-" + item.getFloor();
if(!childrenIdMap.containsKey(fourKey)){ if (!childrenIdMap.containsKey(fourKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding()); platSpace.setName(item.getBuilding());
platSpace.setType(PlatSpaceEnum.TypeEnum.FLOOR.getValue()); platSpace.setType(PlatSpaceEnum.TypeEnum.FLOOR.getValue());
platSpace.setOrgId(orgId); platSpace.setOrgId(orgId);
platSpace.setParentId(threeId); platSpace.setParentId(threeId);
platSpace.setParentPath(firstId+","+secondId + "," + threeId); platSpace.setParentPath(firstId + "," + secondId + "," + threeId);
save(platSpace); save(platSpace);
childrenIdMap.put(fourKey,platSpace.getId()); childrenIdMap.put(fourKey, platSpace.getId());
fourId = platSpace.getId(); fourId = platSpace.getId();
}else{ } else {
fourId = childrenIdMap.get(fourKey); fourId = childrenIdMap.get(fourKey);
} }
spacePath = spacePath + "," + fourId;
} }
//房间 //房间
...@@ -459,16 +500,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -459,16 +500,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
platRoomDTO.setName(item.getRoomName()); platRoomDTO.setName(item.getRoomName());
platRoomDTO.setBedNumber(item.getBedNumber()); platRoomDTO.setBedNumber(item.getBedNumber());
String spaceId = null; String spaceId = null;
if(firstId != null){ if (firstId != null) {
spaceId = firstId; spaceId = firstId;
}else if(secondId != null){ } else if (secondId != null) {
spaceId = secondId; spaceId = secondId;
}else if(threeId != null){ } else if (threeId != null) {
spaceId = threeId; spaceId = threeId;
}else if(fourId != null){ } else if (fourId != null) {
spaceId = fourId; spaceId = fourId;
} }
platRoomDTO.setSpaceId(spaceId); platRoomDTO.setSpaceId(spaceId);
platRoomDTO.setSpacePath(spacePath);
platRoomService.add(platRoomDTO); platRoomService.add(platRoomDTO);
} }
} }
...@@ -477,7 +519,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -477,7 +519,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
excelImportVo.setSuccessCount(successCount); excelImportVo.setSuccessCount(successCount);
excelImportVo.setList(errorVoList); excelImportVo.setList(errorVoList);
return excelImportVo; return excelImportVo;
}catch (Exception e){ } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
e.printStackTrace(); e.printStackTrace();
} }
...@@ -488,7 +531,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -488,7 +531,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
public List<PlatSpaceVO> parentListTree(PlatSpaceQueryDTO dto) { public List<PlatSpaceVO> parentListTree(PlatSpaceQueryDTO dto) {
//查询用户权限组织id //查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg()); List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if(orgs.isEmpty()){ if (orgs.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
//房间 //房间
...@@ -497,27 +540,27 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -497,27 +540,27 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList()); List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName()); queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatSpace::getName, dto.getName());
queryWrapper.in(PlatSpace::getOrgId, orgIds); queryWrapper.in(PlatSpace::getOrgId, orgIds);
if(!spaceIds.isEmpty()){ if (!spaceIds.isEmpty()) {
queryWrapper.notIn(PlatSpace::getId, spaceIds); queryWrapper.notIn(PlatSpace::getId, spaceIds);
} }
List<PlatSpace> list = this.list(queryWrapper); List<PlatSpace> list = this.list(queryWrapper);
list = list.stream() list = list.stream()
.filter(s->(StringUtil.isNotEmpty(s.getParentPath()) && s.getParentPath().split(",").length < 3) .filter(s -> (StringUtil.isNotEmpty(s.getParentPath()) && s.getParentPath().split(",").length < 3)
|| StringUtil.isEmpty(s.getParentPath())) || StringUtil.isEmpty(s.getParentPath()))
.collect(Collectors.toList()); .collect(Collectors.toList());
//父级 //父级
List<PlatSpace> listParent = list.stream().filter(item->StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList()); List<PlatSpace> listParent = list.stream().filter(item -> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集 //子集
List<PlatSpace> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList()); List<PlatSpace> listChild = list.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId)); Map<String, List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
List<PlatSpaceVO> data = new ArrayList<>(); List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpace space:listParent){ for (PlatSpace space : listParent) {
PlatSpaceVO vo = convertToVO(space); PlatSpaceVO vo = convertToVO(space);
vo = child(vo,map); vo = child(vo, map);
data.add(vo); data.add(vo);
} }
return data; return data;
...@@ -525,3 +568,5 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -525,3 +568,5 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
...@@ -160,7 +160,9 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -160,7 +160,9 @@ public class WorkStationServiceImpl implements WorkStationService {
if (spaces.isEmpty()) { if (spaces.isEmpty()) {
return new PageVO<>(); return new PageVO<>();
} }
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds); dto.setOrgIds(orgIds);
dto.setSpaceIds(spaceIds);
} else { } else {
//获取父级的所有子级空间 //获取父级的所有子级空间
spaces = platSpaceService.listChild(dto.getSpaceIds()); spaces = platSpaceService.listChild(dto.getSpaceIds());
...@@ -172,6 +174,7 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -172,6 +174,7 @@ public class WorkStationServiceImpl implements WorkStationService {
.eq(StringUtil.isNotEmpty(dto.getAlarmType()), PlatAlarmRecord::getAlarmType, dto.getAlarmType()) .eq(StringUtil.isNotEmpty(dto.getAlarmType()), PlatAlarmRecord::getAlarmType, dto.getAlarmType())
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue()) .eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds()) .in(PlatAlarmRecord::getOrgId, dto.getOrgIds())
.orderByDesc(PlatAlarmRecord::getAlarmDate)
); );
List<String> elderIds = alarmRecords.stream().filter(t -> StringUtil.isNotEmpty(t.getElderIds())) List<String> elderIds = alarmRecords.stream().filter(t -> StringUtil.isNotEmpty(t.getElderIds()))
.map(PlatAlarmRecord::getElderIds).collect(Collectors.toList()); .map(PlatAlarmRecord::getElderIds).collect(Collectors.toList());
...@@ -180,6 +183,9 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -180,6 +183,9 @@ public class WorkStationServiceImpl implements WorkStationService {
elderIdList.addAll(Arrays.asList(e.split(","))); elderIdList.addAll(Arrays.asList(e.split(",")));
}); });
if(StringUtil.isNotEmpty(dto.getAlarmType())){ if(StringUtil.isNotEmpty(dto.getAlarmType())){
if(elderIdList.isEmpty()){
return new PageVO<>();
}
dto.setElderIds(elderIdList); dto.setElderIds(elderIdList);
} }
...@@ -238,17 +244,22 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -238,17 +244,22 @@ public class WorkStationServiceImpl implements WorkStationService {
if(PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(a.getAlarmType()) if(PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(a.getAlarmType())
|| PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(a.getAlarmType()) || PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(a.getAlarmType())
){ ){
if(typeMap.containsKey(a.getAlarmType())){ if(!typeMap.containsKey(a.getAlarmType())){
if(StringUtil.isNotEmpty(a.getRemark())){
String remark = typeMap.get(a.getAlarmType())+","+a.getRemark();
typeMap.put(a.getAlarmType(),remark);
}
}else {
if(StringUtil.isNotEmpty(a.getRemark())){ if(StringUtil.isNotEmpty(a.getRemark())){
typeMap.put(a.getAlarmType(),a.getRemark()); typeMap.put(a.getAlarmType(),a.getRemark());
} }
} }
// if(typeMap.containsKey(a.getAlarmType())){
// if(StringUtil.isNotEmpty(a.getRemark())){
// String remark = typeMap.get(a.getAlarmType())+","+a.getRemark();
// typeMap.put(a.getAlarmType(),remark);
// }
//
// }else {
// if(StringUtil.isNotEmpty(a.getRemark())){
// typeMap.put(a.getAlarmType(),a.getRemark());
// }
// }
} else { } else {
typeMap.put(a.getAlarmType(),""); typeMap.put(a.getAlarmType(),"");
} }
...@@ -348,6 +359,8 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -348,6 +359,8 @@ public class WorkStationServiceImpl implements WorkStationService {
if (spaces.isEmpty()) { if (spaces.isEmpty()) {
return new PageVO<>(); return new PageVO<>();
} }
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
dto.setSpaceIds(spaceIds);
} else { } else {
//获取父级的所有子级空间 //获取父级的所有子级空间
spaces = platSpaceService.listChild(dto.getSpaceIds()); spaces = platSpaceService.listChild(dto.getSpaceIds());
...@@ -359,6 +372,7 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -359,6 +372,7 @@ public class WorkStationServiceImpl implements WorkStationService {
.eq(StringUtil.isNotEmpty(dto.getAlarmType()), PlatAlarmRecord::getAlarmType, dto.getAlarmType()) .eq(StringUtil.isNotEmpty(dto.getAlarmType()), PlatAlarmRecord::getAlarmType, dto.getAlarmType())
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue()) .eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds()) .in(PlatAlarmRecord::getOrgId, dto.getOrgIds())
.orderByDesc(PlatAlarmRecord::getAlarmDate)
); );
List<String> elderIds = alarmRecords.stream().filter(t -> StringUtil.isNotEmpty(t.getElderIds())) List<String> elderIds = alarmRecords.stream().filter(t -> StringUtil.isNotEmpty(t.getElderIds()))
.map(PlatAlarmRecord::getElderIds).collect(Collectors.toList()); .map(PlatAlarmRecord::getElderIds).collect(Collectors.toList());
...@@ -368,6 +382,9 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -368,6 +382,9 @@ public class WorkStationServiceImpl implements WorkStationService {
elderIdList.addAll(Arrays.asList(e.split(","))); elderIdList.addAll(Arrays.asList(e.split(",")));
}); });
if(StringUtil.isNotEmpty(dto.getAlarmType())){ if(StringUtil.isNotEmpty(dto.getAlarmType())){
if(elderIdList.isEmpty()){
return new PageVO<>();
}
dto.setElderIds(elderIdList); dto.setElderIds(elderIdList);
} }
......
...@@ -15,6 +15,7 @@ import com.makeit.entity.saas.PlatTenantMenu; ...@@ -15,6 +15,7 @@ import com.makeit.entity.saas.PlatTenantMenu;
import com.makeit.enums.CodeMessageEnum; import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.enums.IsTenantAccountEnum; import com.makeit.enums.IsTenantAccountEnum;
import com.makeit.enums.id.TreeConst;
import com.makeit.enums.redis.RedisConst; import com.makeit.enums.redis.RedisConst;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdIgnore; import com.makeit.global.aspect.tenant.TenantIdIgnore;
...@@ -315,9 +316,9 @@ public class PlatTenantServiceImpl extends ServiceImpl<PlatTenantMapper, PlatTen ...@@ -315,9 +316,9 @@ public class PlatTenantServiceImpl extends ServiceImpl<PlatTenantMapper, PlatTen
platOrg.setName(platTenant.getName()); platOrg.setName(platTenant.getName());
platOrg.setStatus(platTenant.getStatus()); platOrg.setStatus(platTenant.getStatus());
platOrg.setId(platTenant.getId()); platOrg.setId(platTenant.getId());
platOrg.setPath("1"); platOrg.setPath(TreeConst.TOP_LEVEL);
//租户没有父级 //租户没有父级
platOrg.setParentId("1"); platOrg.setParentId(TreeConst.TOP_LEVEL);
return platOrg; return platOrg;
} }
......
...@@ -78,6 +78,7 @@ public class PlatElderCenterWechatServiceImpl implements PlatElderCenterWechatSe ...@@ -78,6 +78,7 @@ public class PlatElderCenterWechatServiceImpl implements PlatElderCenterWechatSe
new QueryWrapper<PlatAlarmRecord>().lambda() new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue()) .eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.eq(PlatAlarmRecord::getOrgId, space.getOrgId()) .eq(PlatAlarmRecord::getOrgId, space.getOrgId())
.orderByDesc(PlatAlarmRecord::getAlarmDate)
); );
//长者对应的报警类型 //长者对应的报警类型
Map<String, Map<String,String>> elderAlarmTypeMap = workStationService.mapElderAlarmType(alarmRecords); Map<String, Map<String,String>> elderAlarmTypeMap = workStationService.mapElderAlarmType(alarmRecords);
...@@ -133,6 +134,7 @@ public class PlatElderCenterWechatServiceImpl implements PlatElderCenterWechatSe ...@@ -133,6 +134,7 @@ public class PlatElderCenterWechatServiceImpl implements PlatElderCenterWechatSe
new QueryWrapper<PlatAlarmRecord>().lambda() new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue()) .eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.eq(PlatAlarmRecord::getOrgId, space.getOrgId()) .eq(PlatAlarmRecord::getOrgId, space.getOrgId())
.orderByDesc(PlatAlarmRecord::getAlarmDate)
); );
WorkStationQueryDTO queryDTO = new WorkStationQueryDTO(); WorkStationQueryDTO queryDTO = new WorkStationQueryDTO();
queryDTO.setSpaceIds(spaceIds); queryDTO.setSpaceIds(spaceIds);
......
package com.makeit.service.wechat.impl; package com.makeit.service.wechat.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.auth.PlatOrgSplitDTO;
import com.makeit.entity.platform.elder.PlatElderChildrenInfo; import com.makeit.entity.platform.elder.PlatElderChildrenInfo;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.PlatElderChildrenInfoService; import com.makeit.service.platform.elder.PlatElderChildrenInfoService;
import com.makeit.service.wechat.PlatElderChildrenInfoUserLoginWechatService; import com.makeit.service.wechat.PlatElderChildrenInfoUserLoginWechatService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
...@@ -24,6 +26,9 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde ...@@ -24,6 +26,9 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde
@Autowired @Autowired
private PlatElderChildrenInfoService platElderChildrenInfoService; private PlatElderChildrenInfoService platElderChildrenInfoService;
@Autowired
private PlatOrgService platOrgService;
@Override @Override
@Transactional @Transactional
public WechatUserInfo login(WechatLoginPhoneDTO dto) { public WechatUserInfo login(WechatLoginPhoneDTO dto) {
...@@ -34,8 +39,19 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde ...@@ -34,8 +39,19 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde
.eq(PlatElderChildrenInfo::getOpenid, userInfo.getOpenId())); .eq(PlatElderChildrenInfo::getOpenid, userInfo.getOpenId()));
if (childrenInfo == null) { if (childrenInfo == null) {
childrenInfo = new PlatElderChildrenInfo(); childrenInfo = new PlatElderChildrenInfo();
childrenInfo.setOpenid(userInfo.getOpenId()); childrenInfo.setOpenid(userInfo.getOpenId());
childrenInfo.setName(userInfo.getNickName()); childrenInfo.setName(userInfo.getNickName());
PlatOrgSplitDTO vo = platOrgService.getOrgSplitVO(dto.getOrgId());
childrenInfo = new PlatElderChildrenInfo();
childrenInfo.setCityOrgId(vo.getCityOrgId());
childrenInfo.setDistrictOrgId(vo.getDistrictOrgId());
childrenInfo.setStreetOrgId(vo.getStreetOrgId());
childrenInfo.setOrgPath(vo.getOrgPath());
} }
childrenInfo.setPhone(userInfo.getPhoneNumber()); childrenInfo.setPhone(userInfo.getPhoneNumber());
......
...@@ -91,15 +91,6 @@ public class IotSyncTask { ...@@ -91,15 +91,6 @@ public class IotSyncTask {
} }
@Scheduled(cron = "0 0 */1 * * ?")
public void syncDeviceLog() {
log.info("开始同步设备日志");
log.info("同步设备日志结束");
}
private Collection<PlatDevice> convertToPlatDevice(List<DeviceInstanceEntity> iotDeviceList, List<PlatDevice> deviceList, String tenantId, Map<String, String> dicNameIdMap) { private Collection<PlatDevice> convertToPlatDevice(List<DeviceInstanceEntity> iotDeviceList, List<PlatDevice> deviceList, String tenantId, Map<String, String> dicNameIdMap) {
Map<String, PlatDevice> deviceMap = deviceList.stream().collect(Collectors.toMap(PlatDevice::getOriDeviceId, v -> v, (a, b) -> a)); Map<String, PlatDevice> deviceMap = deviceList.stream().collect(Collectors.toMap(PlatDevice::getOriDeviceId, v -> v, (a, b) -> a));
iotDeviceList.forEach(iotDevice -> { iotDeviceList.forEach(iotDevice -> {
......
...@@ -33,6 +33,7 @@ public class PlatAlarmRecordVO extends BaseTenantDTO { ...@@ -33,6 +33,7 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
private String alarmType; private String alarmType;
@ApiModelProperty(value = "告警时间") @ApiModelProperty(value = "告警时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime alarmDate; private LocalDateTime alarmDate;
@ApiModelProperty(value = "状态 0 待处理 1 已处理") @ApiModelProperty(value = "状态 0 待处理 1 已处理")
......
...@@ -42,6 +42,9 @@ public class PlatDeviceListVO extends BaseTenantDTO { ...@@ -42,6 +42,9 @@ public class PlatDeviceListVO extends BaseTenantDTO {
@ApiModelProperty(value = "状态 数据字典 1 在线 0离线") @ApiModelProperty(value = "状态 数据字典 1 在线 0离线")
private String status; private String status;
@ApiModelProperty(value = "设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达")
private String category;
@ApiModelProperty(value = "组织id") @ApiModelProperty(value = "组织id")
private String orgId; private String orgId;
...@@ -70,7 +73,11 @@ public class PlatDeviceListVO extends BaseTenantDTO { ...@@ -70,7 +73,11 @@ public class PlatDeviceListVO extends BaseTenantDTO {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createDate; private LocalDateTime createDate;
@ApiModelProperty(value = "有效时间-起", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDate; private LocalDateTime startDate;
@ApiModelProperty(value = "有效时间-止", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDate; private LocalDateTime endDate;
......
...@@ -51,6 +51,9 @@ public class PlatDeviceViewVO extends BaseTenantDTO { ...@@ -51,6 +51,9 @@ public class PlatDeviceViewVO extends BaseTenantDTO {
@ApiModelProperty(value = "状态 数据字典 1 在线 0离线") @ApiModelProperty(value = "状态 数据字典 1 在线 0离线")
private String status; private String status;
@ApiModelProperty(value = "设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达")
private String category;
@ApiModelProperty(value = "组织id") @ApiModelProperty(value = "组织id")
private String orgId; private String orgId;
......
...@@ -85,7 +85,7 @@ public class PlatElderExportVO extends BaseTenantDTO { ...@@ -85,7 +85,7 @@ public class PlatElderExportVO extends BaseTenantDTO {
@ApiModelProperty(value = "性别 数据字典 1 男 2 女") @ApiModelProperty(value = "性别 数据字典 1 男 2 女")
private String sex; private String sex;
@ExcelProperty(value = "老人姓名") @ExcelProperty(value = "老人年龄")
@ApiModelProperty(value = "年龄") @ApiModelProperty(value = "年龄")
private Integer age; private Integer age;
...@@ -224,7 +224,7 @@ public class PlatElderExportVO extends BaseTenantDTO { ...@@ -224,7 +224,7 @@ public class PlatElderExportVO extends BaseTenantDTO {
private Integer childrenQuantity; private Integer childrenQuantity;
@DictEnumFormat(em = PlatElderEnum.MedicalInsuranceEnum.class) @DictEnumFormat(em = PlatElderEnum.MedicalInsuranceEnum.class)
@ExcelProperty(value = "宗教信仰", converter = DictEnumConverter.class) @ExcelProperty(value = "医疗保险情况", converter = DictEnumConverter.class)
@ApiModelProperty(value = "医疗保险 数据字典 1 有 0 无") @ApiModelProperty(value = "医疗保险 数据字典 1 有 0 无")
private String medicalInsurance; private String medicalInsurance;
......
...@@ -14,4 +14,11 @@ public class PlatElderCoordinateVO { ...@@ -14,4 +14,11 @@ public class PlatElderCoordinateVO {
@ApiModelProperty("y") @ApiModelProperty("y")
private BigDecimal y; private BigDecimal y;
@ApiModelProperty("人体目标距离雷达位置 范围:0-1000,单位cm")
private Integer distance;
@ApiModelProperty("人体目标偏离雷达法线角度范围:±60,单位°")
private Integer angle;
} }
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<where> <where>
pb.del_flag = 0 and pb.status = 0 pb.del_flag = 0 and pb.status = 0
<if test="dto.elderName != null and dto.elderName != ''"> <if test="dto.elderName != null and dto.elderName != ''">
AND pe.naem LIKE CONCAT('%',#{dto.elderName},'%') AND pe.name LIKE CONCAT('%',#{dto.elderName},'%')
</if> </if>
<if test="dto.spaceIds != null and dto.spaceIds.size()>0 "> <if test="dto.spaceIds != null and dto.spaceIds.size()>0 ">
AND pm.space_id IN AND pm.space_id IN
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<where> <where>
pb.del_flag = 0 and pb.status = 0 pb.del_flag = 0 and pb.status = 0
<if test="dto.elderName != null and dto.elderName != ''"> <if test="dto.elderName != null and dto.elderName != ''">
AND pe.naem LIKE CONCAT('%',#{dto.elderName},'%') AND pe.name LIKE CONCAT('%',#{dto.elderName},'%')
</if> </if>
<if test="dto.spaceIds != null and dto.spaceIds.size()>0 "> <if test="dto.spaceIds != null and dto.spaceIds.size()>0 ">
AND pm.space_id IN AND pm.space_id IN
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
from plat_user_role pur from plat_user_role pur
left join plat_role pr on pur.role_id = pr.id left join plat_role pr on pur.role_id = pr.id
<where> <where>
pur.del_flag = 0
<if test="userIdList != null and userIdList.size()>0"> <if test="userIdList != null and userIdList.size()>0">
AND pur.user_id IN AND pur.user_id IN
<foreach collection="userIdList" item="item" separator="," open="(" close=")" index=""> <foreach collection="userIdList" item="item" separator="," open="(" close=")" index="">
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<where> <where>
pm.del_flag = 0 pm.del_flag = 0
<if test="dto.elderName != null and dto.elderName != ''"> <if test="dto.elderName != null and dto.elderName != ''">
AND pe.naem LIKE CONCAT('%',#{dto.elderName},'%') AND pe.name LIKE CONCAT('%',#{dto.elderName},'%')
</if> </if>
<if test="dto.spaceIds != null and dto.spaceIds.size()>0 "> <if test="dto.spaceIds != null and dto.spaceIds.size()>0 ">
AND pm.space_id IN AND pm.space_id IN
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<where> <where>
pm.del_flag = 0 pm.del_flag = 0
<if test="dto.elderName != null and dto.elderName != ''"> <if test="dto.elderName != null and dto.elderName != ''">
AND pe.naem LIKE CONCAT('%',#{dto.elderName},'%') AND pe.name LIKE CONCAT('%',#{dto.elderName},'%')
</if> </if>
<if test="dto.spaceIds != null and dto.spaceIds.size()>0 "> <if test="dto.spaceIds != null and dto.spaceIds.size()>0 ">
AND pm.space_id IN AND pm.space_id IN
......
...@@ -3,11 +3,13 @@ package com.makeit; ...@@ -3,11 +3,13 @@ package com.makeit;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling @EnableScheduling
@EnableAsync @EnableAsync
@ServletComponentScan
@MapperScan(basePackages = {"com.makeit.**.mapper"}) @MapperScan(basePackages = {"com.makeit.**.mapper"})
//@SpringBootApplication(scanBasePackages = {"com.makeit"}) //@SpringBootApplication(scanBasePackages = {"com.makeit"})
@SpringBootApplication @SpringBootApplication
......
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