diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java index f761ea6..9d32a5a 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java @@ -100,7 +100,7 @@ public class AppAuthController { */ @PostMapping("/logout") public R logout() { -// loginService.logout(); + loginService.logout(); return R.ok("退出成功"); } diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceController.java index 1344160..c88a40e 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceController.java @@ -1,16 +1,19 @@ package com.fuyuanshen.app.controller; +import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo; import com.fuyuanshen.app.domain.dto.APPReNameDTO; import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo; -import com.fuyuanshen.app.service.equipment.APPDeviceService; +import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo; +import com.fuyuanshen.app.service.AppDeviceBizService; import com.fuyuanshen.common.core.domain.R; +import com.fuyuanshen.common.core.validate.AddGroup; import com.fuyuanshen.common.mybatis.core.page.PageQuery; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; import com.fuyuanshen.common.web.core.BaseController; import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria; import com.fuyuanshen.equipment.domain.vo.AppDeviceVo; -import com.fuyuanshen.equipment.service.DeviceService; +import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -18,7 +21,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; /** - * APP 设备信息管理 + * APP设备信息管理 */ @Validated @RequiredArgsConstructor @@ -26,18 +29,16 @@ import java.util.List; @RequestMapping("/app/device") public class AppDeviceController extends BaseController { - private final DeviceService deviceService; + private final AppDeviceBizService appDeviceService; - private final APPDeviceService appDeviceService; - /** * 查询设备列表 */ @GetMapping("/list") public TableDataInfo list(DeviceQueryCriteria bo, PageQuery pageQuery) { - return deviceService.queryAppDeviceList(bo,pageQuery); + return appDeviceService.queryAppDeviceList(bo,pageQuery); } /** @@ -45,7 +46,7 @@ public class AppDeviceController extends BaseController { */ @PostMapping("/bind") public R bind(@RequestBody AppDeviceBo bo) { - return toAjax(deviceService.bindDevice(bo)); + return toAjax(appDeviceService.bindDevice(bo)); } @@ -54,7 +55,7 @@ public class AppDeviceController extends BaseController { */ @DeleteMapping("/unBind") public R unBind(Long id) { - return toAjax(deviceService.unBindDevice(id)); + return toAjax(appDeviceService.unBindDevice(id)); } /** @@ -76,4 +77,31 @@ public class AppDeviceController extends BaseController { appDeviceService.reName(reNameDTO); return R.ok("重命名成功!!!"); } + + /** + * 获取设备详细信息 + * + * @param id 主键 + */ + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(appDeviceService.getInfo(id)); + } + + /** + * 人员信息登记 + */ + @PostMapping(value = "/registerPersonInfo") + public R registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) { + return toAjax(appDeviceService.registerPersonInfo(bo)); + } + + /** + * 发送信息 + */ + @PostMapping(value = "/sendMessage") + public R sendMessage(@RequestBody AppDeviceBo bo) { + return toAjax(appDeviceService.sendMessage(bo)); + } } diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java new file mode 100644 index 0000000..60620f6 --- /dev/null +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java @@ -0,0 +1,110 @@ +package com.fuyuanshen.app.controller; + +import cn.dev33.satoken.annotation.SaIgnore; +import cn.hutool.core.util.RandomUtil; +import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; +import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo; +import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.app.service.AppDeviceShareService; +import com.fuyuanshen.app.service.IAppDeviceShareService; +import com.fuyuanshen.common.core.constant.Constants; +import com.fuyuanshen.common.core.domain.R; +import com.fuyuanshen.common.core.validate.AddGroup; +import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit; +import com.fuyuanshen.common.mybatis.core.page.PageQuery; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +import com.fuyuanshen.common.ratelimiter.annotation.RateLimiter; +import com.fuyuanshen.common.redis.utils.RedisUtils; +import com.fuyuanshen.common.web.core.BaseController; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import org.dromara.sms4j.api.SmsBlend; +import org.dromara.sms4j.api.entity.SmsResponse; +import org.dromara.sms4j.core.factory.SmsFactory; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.time.Duration; +import java.util.LinkedHashMap; + +import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_CODES_KEY; + +/** + * APP 设备分享 + * + * @author Lion Li + * @date 2025-07-16 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/app/deviceShare") +public class AppDeviceShareController extends BaseController { + + private final IAppDeviceShareService deviceShareService; + + private final AppDeviceShareService appDeviceShareService; + + /** + * 分享管理列表 + */ + @GetMapping("/deviceShareList") + public TableDataInfo list(AppDeviceShareBo bo, PageQuery pageQuery) { + return deviceShareService.queryPageList(bo, pageQuery); + } + + /** + * 获取设备分享详细信息 + * + * @param id 主键 + */ + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(appDeviceShareService.getInfo(id)); + } + + /** + * 新增设备分享 + */ + @RepeatSubmit() + @PostMapping("/deviceShare") + public R deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) { + return toAjax(appDeviceShareService.deviceShare(bo)); + } + + /** + * 移除分享用户 + * + * @param ids 主键串 + */ + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(appDeviceShareService.remove(ids)); + } + + /** + * 短信验证码 + * + * @param phonenumber 用户手机号 + */ + @SaIgnore + @RateLimiter(key = "#phonenumber", time = 60, count = 1) + @GetMapping("/sms/code") + public R smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) { + String key = DEVICE_SHARE_CODES_KEY + phonenumber; + String code = RandomUtil.randomNumbers(4); + RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); + LinkedHashMap map = new LinkedHashMap<>(1); + map.put("code", code); + SmsBlend smsBlend = SmsFactory.getSmsBlend("config1"); + SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, map); + if (!smsResponse.isSuccess()) { + return R.fail(smsResponse.getData().toString()); + } + return R.ok(); + } +} diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceBizService.java b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceBizService.java new file mode 100644 index 0000000..35a897e --- /dev/null +++ b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceBizService.java @@ -0,0 +1,167 @@ +package com.fuyuanshen.app.service; + +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.fuyuanshen.app.domain.AppPersonnelInfo; +import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo; +import com.fuyuanshen.app.domain.dto.APPReNameDTO; +import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo; +import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo; +import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo; +import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper; +import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper; +import com.fuyuanshen.common.core.utils.MapstructUtils; +import com.fuyuanshen.common.mybatis.core.page.PageQuery; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +import com.fuyuanshen.common.satoken.utils.AppLoginHelper; +import com.fuyuanshen.equipment.domain.Device; +import com.fuyuanshen.equipment.domain.DeviceType; +import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; +import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria; +import com.fuyuanshen.equipment.domain.vo.AppDeviceVo; +import com.fuyuanshen.equipment.enums.BindingStatusEnum; +import com.fuyuanshen.equipment.enums.CommunicationModeEnum; +import com.fuyuanshen.equipment.mapper.DeviceMapper; +import com.fuyuanshen.equipment.mapper.DeviceTypeMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + + +@Slf4j +@Service +@RequiredArgsConstructor +public class AppDeviceBizService { + + private final APPDeviceMapper appDeviceMapper; + private final DeviceMapper deviceMapper; + private final AppPersonnelInfoMapper appPersonnelInfoMapper; + private final DeviceTypeMapper deviceTypeMapper; + + + public List getTypeList() { + Long userId = AppLoginHelper.getUserId(); + return appDeviceMapper.getTypeList(userId); + } + + public void reName(APPReNameDTO reNameDTO) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", reNameDTO.getId()) + .eq("binding_user_id", AppLoginHelper.getUserId()) + .set("device_name", reNameDTO.getDeviceName()); + deviceMapper.update(updateWrapper); + } + + + public int sendMessage(AppDeviceBo bo) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", bo.getDeviceId()) + .eq("binding_user_id", AppLoginHelper.getUserId()) + .set("send_msg", bo.getSendMsg()); + return deviceMapper.update(updateWrapper); + } + + + public TableDataInfo queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) { + if (bo.getBindingUserId() == null) { + Long userId = AppLoginHelper.getUserId(); + bo.setBindingUserId(userId); + } + Page result = deviceMapper.queryAppBindDeviceList(pageQuery.build(), bo); + return TableDataInfo.build(result); + } + + public int bindDevice(AppDeviceBo bo) { + Integer mode = bo.getCommunicationMode(); + Long userId = AppLoginHelper.getUserId(); + if (mode == CommunicationModeEnum.FOUR_G.getValue()) { + + String deviceImei = bo.getDeviceImei(); + QueryWrapper qw = new QueryWrapper() + .eq("device_imei", deviceImei); + List devices = deviceMapper.selectList(qw); + if (devices.isEmpty()) { + throw new RuntimeException("请先将设备入库!!!"); + } + Device device = devices.get(0); + if (device.getBindingStatus() != null && device.getBindingStatus() == BindingStatusEnum.BOUND.getCode()) { + throw new RuntimeException("设备已绑定"); + } + UpdateWrapper deviceUpdateWrapper = new UpdateWrapper<>(); + deviceUpdateWrapper.eq("id", device.getId()) + .set("binding_status", BindingStatusEnum.BOUND.getCode()) + .set("binding_user_id", userId) + .set("binding_time", new Date()); + + + return deviceMapper.update(null, deviceUpdateWrapper); + } else if (mode == CommunicationModeEnum.BLUETOOTH.getValue()) { + String deviceMac = bo.getDeviceMac(); + QueryWrapper qw = new QueryWrapper() + .eq("device_mac", deviceMac); + List devices = deviceMapper.selectList(qw); + if (devices.isEmpty()) { + throw new RuntimeException("请先将设备入库!!!"); + } + Device device = devices.get(0); + if (device.getBindingStatus() != null && device.getBindingStatus() == BindingStatusEnum.BOUND.getCode()) { + throw new RuntimeException("设备已绑定"); + } + UpdateWrapper deviceUpdateWrapper = new UpdateWrapper<>(); + deviceUpdateWrapper.eq("id", device.getId()) + .set("binding_status", BindingStatusEnum.BOUND.getCode()) + .set("binding_user_id", userId) + .set("binding_time", new Date()); + return deviceMapper.update(null, deviceUpdateWrapper); + } else { + throw new RuntimeException("通讯方式错误"); + } + + } + + public int unBindDevice(Long id) { + Device device = deviceMapper.selectById(id); + if (device == null) { + throw new RuntimeException("请先将设备入库!!!"); + } + UpdateWrapper deviceUpdateWrapper = new UpdateWrapper<>(); + deviceUpdateWrapper.eq("id", device.getId()) + .set("binding_status", BindingStatusEnum.UNBOUND.getCode()) + .set("binding_user_id", null) + .set("binding_time", null); + return deviceMapper.update(null, deviceUpdateWrapper); + } + + public AppDeviceDetailVo getInfo(Long id) { + Device device = deviceMapper.selectById(id); + AppDeviceDetailVo vo = new AppDeviceDetailVo(); + vo.setDeviceId(device.getId()); + vo.setDeviceName(device.getDeviceName()); + vo.setDevicePic(device.getDevicePic()); + vo.setDeviceImei(device.getDeviceImei()); + vo.setDeviceMac(device.getDeviceMac()); + vo.setDeviceStatus(device.getDeviceStatus()); + DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType()); + if(deviceType!=null){ + vo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode())); + vo.setTypeName(deviceType.getTypeName()); + } + vo.setBluetoothName(device.getBluetoothName()); + + AppPersonnelInfo appPersonnelInfo = appPersonnelInfoMapper.selectById(device.getId()); + if(appPersonnelInfo != null){ + AppPersonnelInfoVo personnelInfoVo = MapstructUtils.convert(appPersonnelInfo, AppPersonnelInfoVo.class); + vo.setPersonnelInfo(personnelInfoVo); + } + return vo; + } + + public boolean registerPersonInfo(AppPersonnelInfoBo bo) { + AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class); + return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo); + } +} diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java new file mode 100644 index 0000000..82dcaa9 --- /dev/null +++ b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java @@ -0,0 +1,132 @@ +package com.fuyuanshen.app.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.fuyuanshen.app.domain.AppDeviceShare; +import com.fuyuanshen.app.domain.AppPersonnelInfo; +import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; +import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo; +import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo; +import com.fuyuanshen.app.mapper.AppDeviceShareMapper; +import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper; +import com.fuyuanshen.common.core.constant.Constants; +import com.fuyuanshen.common.core.constant.GlobalConstants; +import com.fuyuanshen.common.core.exception.ServiceException; +import com.fuyuanshen.common.core.exception.user.CaptchaExpireException; +import com.fuyuanshen.common.core.utils.MessageUtils; +import com.fuyuanshen.common.core.utils.StringUtils; +import com.fuyuanshen.common.redis.utils.RedisUtils; +import com.fuyuanshen.common.satoken.utils.AppLoginHelper; +import com.fuyuanshen.equipment.domain.Device; +import com.fuyuanshen.equipment.domain.DeviceType; +import com.fuyuanshen.equipment.mapper.DeviceMapper; +import com.fuyuanshen.equipment.mapper.DeviceTypeMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + + +@RequiredArgsConstructor +@Slf4j +@Service +public class AppDeviceShareService { + + private final AppDeviceShareMapper appDeviceShareMapper; + + private final DeviceMapper deviceMapper; + + private final DeviceTypeMapper deviceTypeMapper; + + private final AppPersonnelInfoMapper appPersonnelInfoMapper; + + public AppDeviceShareDetailVo getInfo(Long id) { + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AppDeviceShare::getDeviceId, id); + List appDeviceShareVos = appDeviceShareMapper.selectVoList(queryWrapper); + if(appDeviceShareVos==null || appDeviceShareVos.isEmpty()){ + return null; + } + + AppDeviceShareVo shareVo = appDeviceShareVos.get(0); + AppDeviceShareDetailVo shareDetailVo = new AppDeviceShareDetailVo(); + shareDetailVo.setId(shareVo.getId()); + shareDetailVo.setDeviceId(shareVo.getDeviceId()); + shareDetailVo.setPhonenumber(shareVo.getPhonenumber()); + shareDetailVo.setPermission(shareVo.getPermission()); + + Device device = deviceMapper.selectById(shareVo.getDeviceId()); + shareDetailVo.setDeviceName(device.getDeviceName()); + shareDetailVo.setDeviceImei(device.getDeviceImei()); + shareDetailVo.setDeviceMac(device.getDeviceMac()); + + DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType()); + if(deviceType!=null){ + shareDetailVo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode())); + } + shareDetailVo.setDevicePic(device.getDevicePic()); + shareDetailVo.setTypeName(deviceType.getTypeName()); + shareDetailVo.setBluetoothName(device.getBluetoothName()); + shareDetailVo.setDeviceStatus(device.getDeviceStatus()); + shareDetailVo.setSendMsg(device.getSendMsg()); + + LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); + qw.eq(AppPersonnelInfo::getDeviceId, device.getId()); + List appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw); + if(appPersonnelInfoVos!=null && !appPersonnelInfoVos.isEmpty()){ + shareDetailVo.setPersonnelInfo(appPersonnelInfoVos.get(0)); + } + + return shareDetailVo; + } + /** + * 校验短信验证码 + */ + private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) { + String code = RedisUtils.getCacheObject(GlobalConstants.DEVICE_SHARE_CODES_KEY + phonenumber); + if (StringUtils.isBlank(code)) { + throw new ServiceException("验证码失效"); + } + return code.equals(smsCode); + } + public int deviceShare(AppDeviceShareBo bo) { + validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode()); + + Device device = deviceMapper.selectById(bo.getDeviceId()); + if(device==null){ + throw new ServiceException("设备不存在"); + } + Long userId = AppLoginHelper.getUserId(); + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId()); + lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber()); + Long count = appDeviceShareMapper.selectCount(lqw); + if(count>0){ + + UpdateWrapper uw = new UpdateWrapper<>(); + uw.eq("device_id", bo.getDeviceId()); + uw.eq("phonenumber", bo.getPhonenumber()); + uw.set("permission", bo.getPermission()); + uw.set("update_by", userId); + uw.set("update_time", new Date()); + + return appDeviceShareMapper.update(uw); + }else { + AppDeviceShare appDeviceShare = new AppDeviceShare(); + appDeviceShare.setDeviceId(bo.getDeviceId()); + appDeviceShare.setPhonenumber(bo.getPhonenumber()); + appDeviceShare.setPermission(bo.getPermission()); + appDeviceShare.setCreateBy(userId); + return appDeviceShareMapper.insert(appDeviceShare); + } + } + + public int remove(Long[] ids) { + return appDeviceShareMapper.deleteByIds(Arrays.asList(ids)); + } +} diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/CaptchaController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/CaptchaController.java index bb066b9..30d7106 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/CaptchaController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/CaptchaController.java @@ -63,11 +63,12 @@ public class CaptchaController { String code = RandomUtil.randomNumbers(4); RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); // 验证码模板id 自行处理 (查数据库或写死均可) - String templateId = ""; + String templateId = "SMS_322180518"; LinkedHashMap map = new LinkedHashMap<>(1); map.put("code", code); SmsBlend smsBlend = SmsFactory.getSmsBlend("config1"); - SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map); +// SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map); + SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, map); if (!smsResponse.isSuccess()) { log.error("验证码短信发送异常 => {}", smsResponse); return R.fail(smsResponse.getData().toString()); diff --git a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/GlobalConstants.java b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/GlobalConstants.java index 18257d9..ccec371 100644 --- a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/GlobalConstants.java +++ b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/GlobalConstants.java @@ -17,6 +17,11 @@ public interface GlobalConstants { */ String CAPTCHA_CODE_KEY = GLOBAL_REDIS_KEY + "captcha_codes:"; + /** + * 设备分享验证码 redis key + */ + String DEVICE_SHARE_CODES_KEY = GLOBAL_REDIS_KEY + "device_share_codes:"; + /** * 防重提交 redis key */ diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java new file mode 100644 index 0000000..c74a548 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java @@ -0,0 +1,105 @@ +//package com.fuyuanshen.app.controller; +// +//import java.util.List; +// +//import lombok.RequiredArgsConstructor; +//import jakarta.servlet.http.HttpServletResponse; +//import jakarta.validation.constraints.*; +//import cn.dev33.satoken.annotation.SaCheckPermission; +//import org.springframework.web.bind.annotation.*; +//import org.springframework.validation.annotation.Validated; +//import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit; +//import com.fuyuanshen.common.log.annotation.Log; +//import com.fuyuanshen.common.web.core.BaseController; +//import com.fuyuanshen.common.mybatis.core.page.PageQuery; +//import com.fuyuanshen.common.core.domain.R; +//import com.fuyuanshen.common.core.validate.AddGroup; +//import com.fuyuanshen.common.core.validate.EditGroup; +//import com.fuyuanshen.common.log.enums.BusinessType; +//import com.fuyuanshen.common.excel.utils.ExcelUtil; +//import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +//import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; +//import com.fuyuanshen.app.service.IAppDeviceShareService; +//import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +// +///** +// * 设备分享 +// * +// * @author Lion Li +// * @date 2025-07-16 +// */ +//@Validated +//@RequiredArgsConstructor +//@RestController +//@RequestMapping("/app/deviceShare") +//public class AppDeviceShareController extends BaseController { +// +// private final IAppDeviceShareService appDeviceShareService; +// +// /** +// * 查询设备分享列表 +// */ +// @SaCheckPermission("app:deviceShare:list") +// @GetMapping("/list") +// public TableDataInfo list(AppDeviceShareBo bo, PageQuery pageQuery) { +// return appDeviceShareService.queryPageList(bo, pageQuery); +// } +// +// /** +// * 导出设备分享列表 +// */ +// @SaCheckPermission("app:deviceShare:export") +// @Log(title = "设备分享", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(AppDeviceShareBo bo, HttpServletResponse response) { +// List list = appDeviceShareService.queryList(bo); +// ExcelUtil.exportExcel(list, "设备分享", AppDeviceShareVo.class, response); +// } +// +// /** +// * 获取设备分享详细信息 +// * +// * @param id 主键 +// */ +// @SaCheckPermission("app:deviceShare:query") +// @GetMapping("/{id}") +// public R getInfo(@NotNull(message = "主键不能为空") +// @PathVariable Long id) { +// return R.ok(appDeviceShareService.queryById(id)); +// } +// +// /** +// * 新增设备分享 +// */ +// @SaCheckPermission("app:deviceShare:add") +// @Log(title = "设备分享", businessType = BusinessType.INSERT) +// @RepeatSubmit() +// @PostMapping() +// public R add(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) { +// return toAjax(appDeviceShareService.insertByBo(bo)); +// } +// +// /** +// * 修改设备分享 +// */ +// @SaCheckPermission("app:deviceShare:edit") +// @Log(title = "设备分享", businessType = BusinessType.UPDATE) +// @RepeatSubmit() +// @PutMapping() +// public R edit(@Validated(EditGroup.class) @RequestBody AppDeviceShareBo bo) { +// return toAjax(appDeviceShareService.updateByBo(bo)); +// } +// +// /** +// * 删除设备分享 +// * +// * @param ids 主键串 +// */ +// @SaCheckPermission("app:deviceShare:remove") +// @Log(title = "设备分享", businessType = BusinessType.DELETE) +// @DeleteMapping("/{ids}") +// public R remove(@NotEmpty(message = "主键不能为空") +// @PathVariable Long[] ids) { +// return toAjax(appDeviceShareService.deleteWithValidByIds(List.of(ids), true)); +// } +//} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/equipment/APPDeviceController.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/equipment/APPDeviceController.java index 39b2503..099dca0 100644 --- a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/equipment/APPDeviceController.java +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/equipment/APPDeviceController.java @@ -3,7 +3,6 @@ package com.fuyuanshen.app.controller.equipment; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuyuanshen.app.domain.APPDevice; import com.fuyuanshen.app.domain.APPDeviceType; -import com.fuyuanshen.app.domain.dto.APPUnbindDTO; import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria; import com.fuyuanshen.app.service.equipment.APPDeviceService; import com.fuyuanshen.common.core.domain.R; diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppDeviceShare.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppDeviceShare.java new file mode 100644 index 0000000..2217855 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppDeviceShare.java @@ -0,0 +1,51 @@ +package com.fuyuanshen.app.domain; + +import com.fuyuanshen.common.tenant.core.TenantEntity; +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 设备分享对象 app_device_share + * + * @author Lion Li + * @date 2025-07-16 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("app_device_share") +public class AppDeviceShare extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + private Long id; + + /** + * 设备ID + */ + private Long deviceId; + + /** + * 手机号 + */ + private String phonenumber; + + /** + * 功能权限(1:灯光模式;2:激光模式;3:开机画面;4:人员信息登记;5:发送信息;6:产品信息) +以逗号分隔 + */ + private String permission; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppPersonnelInfo.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppPersonnelInfo.java index 0ce717b..afd0072 100644 --- a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppPersonnelInfo.java +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppPersonnelInfo.java @@ -36,11 +36,6 @@ public class AppPersonnelInfo extends TenantEntity { */ private String name; - /** - * 部门名称 - */ - private String deptName; - /** * 单位名称 */ diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/bo/AppDeviceShareBo.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/bo/AppDeviceShareBo.java new file mode 100644 index 0000000..07fe7e0 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/bo/AppDeviceShareBo.java @@ -0,0 +1,49 @@ +package com.fuyuanshen.app.domain.bo; + +import com.fuyuanshen.app.domain.AppDeviceShare; +import com.fuyuanshen.common.mybatis.core.domain.BaseEntity; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; +import jakarta.validation.constraints.*; + +/** + * 设备分享业务对象 app_device_share + * + * @author Lion Li + * @date 2025-07-16 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = AppDeviceShare.class, reverseConvertGenerate = false) +public class AppDeviceShareBo extends BaseEntity { + + /** + * 主键id + */ + private Long id; + + /** + * 设备ID + */ + private Long deviceId; + + /** + * 手机号 + */ + private String phonenumber; + + /** + * 功能权限(1:灯光模式;2:激光模式;3:开机画面;4:人员信息登记;5:发送信息;6:产品信息) +以逗号分隔 + */ + private String permission; + + /** + * 备注 + */ + private String remark; + + + private String smsCode; +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceDetailVo.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceDetailVo.java new file mode 100644 index 0000000..5d4cc20 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceDetailVo.java @@ -0,0 +1,72 @@ +package com.fuyuanshen.app.domain.vo; + +import cn.idev.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.io.Serial; + +@Data +public class AppDeviceDetailVo { + @Serial + private static final long serialVersionUID = 1L; + + /** + * 设备ID + */ + @ExcelProperty(value = "设备ID") + private Long deviceId; + + /** + * 手机号 + */ + @ExcelProperty(value = "手机号") + private String phonenumber; + + /** + * 设备名称 + */ + private String deviceName; + + /** + * 设备IMEI + */ + private String deviceImei; + + /** + * 设备MAC + */ + private String deviceMac; + + /** + * 通讯方式 0:4G;1:蓝牙 + */ + private Integer communicationMode; + + /** + * 设备图片 + */ + private String devicePic; + + /** + * 设备类型 + */ + private String typeName; + + /** + * 蓝牙名称 + */ + private String bluetoothName; + + /** + * 设备状态 + * 0 失效 + * 1 正常 + */ + private Integer deviceStatus; + + + /** + * 人员信息 + */ + private AppPersonnelInfoVo personnelInfo; +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareDetailVo.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareDetailVo.java new file mode 100644 index 0000000..d11d657 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareDetailVo.java @@ -0,0 +1,107 @@ +package com.fuyuanshen.app.domain.vo; + +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import com.fuyuanshen.app.domain.AppDeviceShare; +import com.fuyuanshen.common.excel.annotation.ExcelDictFormat; +import com.fuyuanshen.common.excel.convert.ExcelDictConvert; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + + +/** + * 设备分享视图对象 app_device_share + * + * @author Lion Li + * @date 2025-07-16 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = AppDeviceShare.class) +public class AppDeviceShareDetailVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + @ExcelProperty(value = "主键id") + private Long id; + + /** + * 设备ID + */ + @ExcelProperty(value = "设备ID") + private Long deviceId; + + /** + * 手机号 + */ + @ExcelProperty(value = "手机号") + private String phonenumber; + + /** + * 功能权限(1:灯光模式;2:激光模式;3:开机画面;4:人员信息登记;5:发送信息;6:产品信息) +以逗号分隔 + */ + @ExcelProperty(value = "功能权限", converter = ExcelDictConvert.class) + @ExcelDictFormat(readConverterExp = "1=:灯光模式;2:激光模式;3:开机画面;4:人员信息登记;5:发送信息;6:产品信息") + private String permission; + + /** + * 设备名称 + */ + private String deviceName; + + /** + * 设备IMEI + */ + private String deviceImei; + + /** + * 设备MAC + */ + private String deviceMac; + + /** + * 通讯方式 0:4G;1:蓝牙 + */ + private Integer communicationMode; + + /** + * 设备图片 + */ + private String devicePic; + + /** + * 设备类型 + */ + private String typeName; + + /** + * 蓝牙名称 + */ + private String bluetoothName; + + /** + * 设备状态 + * 0 失效 + * 1 正常 + */ + private Integer deviceStatus; + + + /** + * 人员信息 + */ + private AppPersonnelInfoVo personnelInfo; + + /** + * 发送信息 + */ + private String sendMsg; +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareVo.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareVo.java new file mode 100644 index 0000000..3b554a3 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/vo/AppDeviceShareVo.java @@ -0,0 +1,72 @@ +package com.fuyuanshen.app.domain.vo; + +import com.fuyuanshen.app.domain.AppDeviceShare; +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import com.fuyuanshen.common.excel.annotation.ExcelDictFormat; +import com.fuyuanshen.common.excel.convert.ExcelDictConvert; +import io.github.linpeilie.annotations.AutoMapper; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + + +/** + * 设备分享视图对象 app_device_share + * + * @author Lion Li + * @date 2025-07-16 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = AppDeviceShare.class) +public class AppDeviceShareVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + @ExcelProperty(value = "主键id") + private Long id; + + /** + * 设备ID + */ + @ExcelProperty(value = "设备ID") + private Long deviceId; + + /** + * 设备名称 + */ + @ExcelProperty(value = "设备名称") + private String deviceName; + + /** + * 手机号 + */ + @ExcelProperty(value = "手机号") + private String phonenumber; + + /** + * 功能权限(1:灯光模式;2:激光模式;3:开机画面;4:人员信息登记;5:发送信息;6:产品信息) +以逗号分隔 + */ + @ExcelProperty(value = "功能权限", converter = ExcelDictConvert.class) + @ExcelDictFormat(readConverterExp = "1=:灯光模式;2:激光模式;3:开机画面;4:人员信息登记;5:发送信息;6:产品信息") + private String permission; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + // 设备图片 + private String devicePic; +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/mapper/AppDeviceShareMapper.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/mapper/AppDeviceShareMapper.java new file mode 100644 index 0000000..8bf8360 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/mapper/AppDeviceShareMapper.java @@ -0,0 +1,15 @@ +package com.fuyuanshen.app.mapper; + +import com.fuyuanshen.app.domain.AppDeviceShare; +import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus; + +/** + * 设备分享Mapper接口 + * + * @author Lion Li + * @date 2025-07-16 + */ +public interface AppDeviceShareMapper extends BaseMapperPlus { + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/IAppDeviceShareService.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/IAppDeviceShareService.java new file mode 100644 index 0000000..84dfb27 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/IAppDeviceShareService.java @@ -0,0 +1,68 @@ +package com.fuyuanshen.app.service; + +import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +import com.fuyuanshen.common.mybatis.core.page.PageQuery; + +import java.util.Collection; +import java.util.List; + +/** + * 设备分享Service接口 + * + * @author Lion Li + * @date 2025-07-16 + */ +public interface IAppDeviceShareService { + + /** + * 查询设备分享 + * + * @param id 主键 + * @return 设备分享 + */ + AppDeviceShareVo queryById(Long id); + + /** + * 分页查询设备分享列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 设备分享分页列表 + */ + TableDataInfo queryPageList(AppDeviceShareBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的设备分享列表 + * + * @param bo 查询条件 + * @return 设备分享列表 + */ + List queryList(AppDeviceShareBo bo); + + /** + * 新增设备分享 + * + * @param bo 设备分享 + * @return 是否新增成功 + */ + Boolean insertByBo(AppDeviceShareBo bo); + + /** + * 修改设备分享 + * + * @param bo 设备分享 + * @return 是否修改成功 + */ + Boolean updateByBo(AppDeviceShareBo bo); + + /** + * 校验并批量删除设备分享信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/IAppPersonnelInfoService.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/IAppPersonnelInfoService.java index 6f7805b..66ea877 100644 --- a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/IAppPersonnelInfoService.java +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/IAppPersonnelInfoService.java @@ -4,6 +4,7 @@ import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo; import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; import com.fuyuanshen.common.mybatis.core.page.PageQuery; +import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; import java.util.Collection; import java.util.List; @@ -65,4 +66,6 @@ public interface IAppPersonnelInfoService { * @return 是否删除成功 */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + boolean registerPersonInfo(AppPersonnelInfoBo bo); } diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/equipment/APPDeviceService.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/equipment/APPDeviceService.java index eb5ff1c..cc72e8a 100644 --- a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/equipment/APPDeviceService.java +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/equipment/APPDeviceService.java @@ -8,7 +8,9 @@ import com.fuyuanshen.app.domain.dto.APPReNameDTO; import com.fuyuanshen.app.domain.dto.APPUnbindDTO; import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria; import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo; +import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria; import java.util.List; @@ -73,4 +75,5 @@ public interface APPDeviceService extends IService { TableDataInfo queryAppDeviceList(DeviceQueryCriteria criteria); + int sendMessage(AppDeviceBo bo); } diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppDeviceShareServiceImpl.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppDeviceShareServiceImpl.java new file mode 100644 index 0000000..89178ca --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppDeviceShareServiceImpl.java @@ -0,0 +1,149 @@ +package com.fuyuanshen.app.service.impl; + +import com.fuyuanshen.common.core.utils.MapstructUtils; +import com.fuyuanshen.common.core.utils.StringUtils; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +import com.fuyuanshen.common.mybatis.core.page.PageQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.fuyuanshen.common.satoken.utils.AppLoginHelper; +import com.fuyuanshen.equipment.domain.Device; +import com.fuyuanshen.equipment.mapper.DeviceMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; +import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.app.domain.AppDeviceShare; +import com.fuyuanshen.app.mapper.AppDeviceShareMapper; +import com.fuyuanshen.app.service.IAppDeviceShareService; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 设备分享Service业务层处理 + * + * @author Lion Li + * @date 2025-07-16 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class AppDeviceShareServiceImpl implements IAppDeviceShareService { + + private final AppDeviceShareMapper baseMapper; + + private final DeviceMapper deviceMapper; + + /** + * 查询设备分享 + * + * @param id 主键 + * @return 设备分享 + */ + @Override + public AppDeviceShareVo queryById(Long id){ + return baseMapper.selectVoById(id); + } + + /** + * 分页查询设备分享列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 设备分享分页列表 + */ + @Override + public TableDataInfo queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) { + Long userId = AppLoginHelper.getUserId(); + bo.setCreateBy(userId); + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + List records = result.getRecords(); + records.forEach(r -> { + Device device = deviceMapper.selectById(r.getDeviceId()); + if(device != null){ + r.setDevicePic(device.getDevicePic()); + r.setDeviceName(device.getDeviceName()); + } + }); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的设备分享列表 + * + * @param bo 查询条件 + * @return 设备分享列表 + */ + @Override + public List queryList(AppDeviceShareBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(AppDeviceShareBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.eq(bo.getDeviceId() != null, AppDeviceShare::getDeviceId, bo.getDeviceId()); + lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), AppDeviceShare::getPhonenumber, bo.getPhonenumber()); + lqw.eq(StringUtils.isNotBlank(bo.getPermission()), AppDeviceShare::getPermission, bo.getPermission()); + lqw.eq(bo.getCreateBy()!=null, AppDeviceShare::getCreateBy, bo.getCreateBy()); + return lqw; + } + + /** + * 新增设备分享 + * + * @param bo 设备分享 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(AppDeviceShareBo bo) { + AppDeviceShare add = MapstructUtils.convert(bo, AppDeviceShare.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改设备分享 + * + * @param bo 设备分享 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(AppDeviceShareBo bo) { + AppDeviceShare update = MapstructUtils.convert(bo, AppDeviceShare.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(AppDeviceShare entity){ + //TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除设备分享信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppPersonnelInfoServiceImpl.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppPersonnelInfoServiceImpl.java index 55f07c3..388d917 100644 --- a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppPersonnelInfoServiceImpl.java +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppPersonnelInfoServiceImpl.java @@ -1,5 +1,6 @@ package com.fuyuanshen.app.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fuyuanshen.common.core.utils.MapstructUtils; import com.fuyuanshen.common.core.utils.StringUtils; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; @@ -7,6 +8,8 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.fuyuanshen.equipment.domain.Device; +import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -75,7 +78,6 @@ public class AppPersonnelInfoServiceImpl implements IAppPersonnelInfoService { LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.eq(bo.getDeviceId() != null, AppPersonnelInfo::getDeviceId, bo.getDeviceId()); lqw.like(StringUtils.isNotBlank(bo.getName()), AppPersonnelInfo::getName, bo.getName()); - lqw.like(StringUtils.isNotBlank(bo.getDeptName()), AppPersonnelInfo::getDeptName, bo.getDeptName()); lqw.like(StringUtils.isNotBlank(bo.getUnitName()), AppPersonnelInfo::getUnitName, bo.getUnitName()); lqw.eq(StringUtils.isNotBlank(bo.getSendMsg()), AppPersonnelInfo::getSendMsg, bo.getSendMsg()); return lqw; @@ -132,4 +134,13 @@ public class AppPersonnelInfoServiceImpl implements IAppPersonnelInfoService { } return baseMapper.deleteByIds(ids) > 0; } + + + @Override + public boolean registerPersonInfo(AppPersonnelInfoBo bo) { + + AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class); + + return baseMapper.insertOrUpdate(appPersonnelInfo); + } } diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/equipment/APPDeviceServiceImpl.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/equipment/APPDeviceServiceImpl.java index f631805..1a462a5 100644 --- a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/equipment/APPDeviceServiceImpl.java +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/equipment/APPDeviceServiceImpl.java @@ -23,8 +23,8 @@ import com.fuyuanshen.common.satoken.utils.AppLoginHelper; import com.fuyuanshen.common.satoken.utils.LoginHelper; import com.fuyuanshen.equipment.domain.Device; import com.fuyuanshen.equipment.domain.DeviceType; +import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria; -import com.fuyuanshen.equipment.domain.vo.AppDeviceVo; import com.fuyuanshen.equipment.enums.BindingStatusEnum; import com.fuyuanshen.equipment.enums.CommunicationModeEnum; import com.fuyuanshen.equipment.mapper.DeviceMapper; @@ -227,5 +227,14 @@ public class APPDeviceServiceImpl extends ServiceImpl updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", bo.getDeviceId()) + .eq("binding_user_id", AppLoginHelper.getUserId()) + .set("send_msg", bo.getSendMsg()); + return deviceMapper.update(updateWrapper); + } + } diff --git a/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml b/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml new file mode 100644 index 0000000..2bdb85f --- /dev/null +++ b/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java index 6fe3024..8ed93ad 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java @@ -118,4 +118,6 @@ public class Device extends TenantEntity { private Long bindingUserId; private Date bindingTime; + + private String sendMsg; } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/dto/AppDeviceBo.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/dto/AppDeviceBo.java index 716d937..0ca4b7f 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/dto/AppDeviceBo.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/dto/AppDeviceBo.java @@ -28,4 +28,7 @@ public class AppDeviceBo { @NotNull(message = "通讯方式不能为空", groups = { EditGroup.class }) private Integer communicationMode; + private String sendMsg; + + private String deviceId; }