Reviewed-on: http://39.105.23.186:3000/develop/digimeta-MultiSaas/pulls/1tags/v0.8.0a
| @@ -27,6 +27,10 @@ public class DmVisitRecordsPo extends TBaseEntity { | |||
| @Serial | |||
| private static final long serialVersionUID = 1L; | |||
| public static final Integer STATUS_VISITING = 0; | |||
| public static final Integer STATUS_VISITED = 8; | |||
| public static final Integer STATUS_EXPIRED = 9; | |||
| /** 访客ID */ | |||
| @Excel(name = "访客ID") | |||
| protected Long visitorId; | |||
| @@ -63,4 +67,8 @@ public class DmVisitRecordsPo extends TBaseEntity { | |||
| @Excel(name = "所属组织ID") | |||
| protected Long deptId; | |||
| public String toString(){ | |||
| return new StringBuilder("VisitorId: ").append(visitorId).append(", UserId: ").append(userId).append(", VisitDate: ").append(visitDate).append(", VisitTime: ").append(visitTime).append(", Duration: ").append(duration).append(", RecordStatus: ").append(recordStatus).append(", DeptId: ").append(deptId).append(", Num: ").append(num).toString(); | |||
| } | |||
| } | |||
| @@ -29,6 +29,9 @@ public interface RemoteManDeviceService { | |||
| @GetMapping("/manDevice/inner/info/{devId}") | |||
| R<DmManDeviceDto> manDeviceInfoInner(@RequestParam(value = "devId") String devId); | |||
| @PostMapping(value = "/manDevice/inner/sync") | |||
| R<Integer> manDeviceListInnerSync(@RequestParam(value = "tenantId") Long tenantId); | |||
| @PutMapping(value = "/manDevice/inner/info") | |||
| R<Integer> manDeviceInfoInnerUpdate(@RequestBody DmActiveVo vo); | |||
| @@ -20,6 +20,7 @@ | |||
| <module>xueyi-common-datascope</module> | |||
| <module>xueyi-common-datasource</module> | |||
| <module>xueyi-common-sms</module> | |||
| <module>xueyi-common-mqtt</module> | |||
| </modules> | |||
| <artifactId>xueyi-common</artifactId> | |||
| @@ -0,0 +1,34 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <parent> | |||
| <groupId>com.xueyi</groupId> | |||
| <artifactId>xueyi-common</artifactId> | |||
| <version>2.5.0</version> | |||
| </parent> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <artifactId>xueyi-common-mqtt</artifactId> | |||
| <description> | |||
| xueyi-common-mqtt通信服务 | |||
| </description> | |||
| <dependencies> | |||
| <!-- SpringBoot Boot Mqtt --> | |||
| <dependency> | |||
| <groupId>org.eclipse.paho</groupId> | |||
| <artifactId>org.eclipse.paho.client.mqttv3</artifactId> | |||
| <version>1.2.5</version> | |||
| </dependency> | |||
| <!-- XueYi Common Core--> | |||
| <dependency> | |||
| <groupId>com.xueyi</groupId> | |||
| <artifactId>xueyi-common-core</artifactId> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -0,0 +1,50 @@ | |||
| package com.xueyi.common.mqtt.configure; | |||
| import lombok.Data; | |||
| import org.eclipse.paho.client.mqttv3.MqttClient; | |||
| import org.eclipse.paho.client.mqttv3.MqttConnectOptions; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.cache.annotation.EnableCaching; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| /** | |||
| * mqtt配置 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Configuration | |||
| @EnableCaching | |||
| @Data | |||
| public class MqttConfig { | |||
| @Value("${emqx.brokerUrl}") | |||
| private String brokerUrl; | |||
| @Value("${emqx.clientId}") | |||
| private String clientId; | |||
| @Value("${emqx.username}") | |||
| private String username; | |||
| @Value("${emqx.password}") | |||
| private String password; | |||
| @Value("${emqx.topics}") | |||
| private String topics; | |||
| @Value("${emqx.fetchLogTopic}") | |||
| private String fetchLogTopic; | |||
| @Bean | |||
| public MqttClient mqttClient() throws Exception { | |||
| MqttConnectOptions options = new MqttConnectOptions(); | |||
| options.setCleanSession(true); | |||
| options.setUserName(username); | |||
| options.setPassword(password.toCharArray()); | |||
| MqttClient client = new MqttClient(brokerUrl, clientId); | |||
| client.connect(options); | |||
| return client; | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| package com.xueyi.common.mqtt.service; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-05-10 19:05 | |||
| */ | |||
| public interface MqttMessageHandler { | |||
| void handleMessage(String topic, String message); | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| package com.xueyi.common.mqtt.service; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-05-10 19:19 | |||
| */ | |||
| public class MqttMessageHandlerService{ | |||
| private final MqttService mqttService; | |||
| private final MqttMessageHandler mqttMessageHandler; | |||
| public MqttMessageHandlerService(MqttService mqttService, MqttMessageHandler mqttMessageHandler) { | |||
| this.mqttService = mqttService; | |||
| this.mqttMessageHandler = mqttMessageHandler; | |||
| init(); | |||
| } | |||
| private void init() { | |||
| mqttService.addObserver(mqttMessageHandler); | |||
| } | |||
| } | |||
| @@ -0,0 +1,84 @@ | |||
| package com.xueyi.common.mqtt.service; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.mqtt.configure.MqttConfig; | |||
| import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; | |||
| import org.eclipse.paho.client.mqttv3.MqttCallback; | |||
| import org.eclipse.paho.client.mqttv3.MqttClient; | |||
| import org.eclipse.paho.client.mqttv3.MqttException; | |||
| import org.eclipse.paho.client.mqttv3.MqttMessage; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| import javax.annotation.PostConstruct; | |||
| import java.nio.charset.StandardCharsets; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| /** | |||
| * spring mqtt 工具类 | |||
| * | |||
| * @author xueyi | |||
| **/ | |||
| @Component | |||
| @SuppressWarnings(value = {"unchecked", "rawtypes"}) | |||
| public class MqttService implements MqttCallback{ | |||
| private List<MqttMessageHandler> observers = new ArrayList<>(); | |||
| public void addObserver(MqttMessageHandler observer) { | |||
| observers.add(observer); | |||
| } | |||
| public void removeObserver(MqttMessageHandler observer) { | |||
| observers.remove(observer); | |||
| } | |||
| @Autowired | |||
| private MqttClient mqttClient; | |||
| @Autowired | |||
| private MqttConfig mqttConfig; | |||
| /** | |||
| * 发布消息到指定 topic | |||
| * | |||
| * @param topic 消息主题 | |||
| * @param message 消息内容 | |||
| */ | |||
| public void sendMessage(String topic, Object message) throws MqttException { | |||
| MqttMessage msg = new MqttMessage(); | |||
| msg.setPayload(message.toString().getBytes()); | |||
| mqttClient.publish(topic, msg); | |||
| System.out.println("发送消息到 topic: " + topic); | |||
| System.out.println("消息内容: " + message); | |||
| } | |||
| @PostConstruct | |||
| public void subscribe() throws MqttException { | |||
| mqttClient.setCallback(this); | |||
| for (String topic : Arrays.stream(mqttConfig.getTopics().split(",")).toList()) { | |||
| if (StringUtils.isNotEmpty(topic)) { | |||
| mqttClient.subscribe(topic, 0); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public void connectionLost(Throwable throwable) { | |||
| } | |||
| @Override | |||
| public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { | |||
| for (MqttMessageHandler observer : observers) { | |||
| observer.handleMessage(s, new String(mqttMessage.getPayload(), StandardCharsets.UTF_8)); | |||
| } | |||
| } | |||
| @Override | |||
| public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { | |||
| } | |||
| } | |||
| @@ -0,0 +1,2 @@ | |||
| com.xueyi.common.mqtt.configure.MqttConfig | |||
| com.xueyi.common.mqtt.service.MqttService | |||
| @@ -3,6 +3,8 @@ package com.xueyi.job.task; | |||
| import com.xueyi.common.cache.utils.SourceUtil; | |||
| import com.xueyi.common.core.utils.core.StrUtil; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.message.api.transfer.feign.RemoteTransferService; | |||
| import com.xueyi.system.api.digitalmans.feign.RemoteManDeviceService; | |||
| import com.xueyi.system.api.model.Source; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| @@ -22,6 +24,9 @@ public class DgmanTask { | |||
| @Autowired | |||
| RemoteTenantService tenantService; | |||
| @Autowired | |||
| RemoteManDeviceService remoteManDeviceService; | |||
| public void ryParams(String params) { | |||
| System.out.println(StrUtil.format("执行有参方法:参数{}", params)); | |||
| } | |||
| @@ -36,7 +41,7 @@ public class DgmanTask { | |||
| // 获取数据源 | |||
| Source source = SourceUtil.getSourceCache(item.getStrategyId()); | |||
| // 更新租户内数字人信息 | |||
| remoteManDeviceService.manDeviceListInnerSync(item.getId()); | |||
| }); | |||
| System.out.println("监控心跳执行完成"); | |||
| } | |||
| @@ -75,6 +75,12 @@ | |||
| <artifactId>xueyi-common-sms</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.xueyi</groupId> | |||
| <artifactId>xueyi-common-mqtt</artifactId> | |||
| <version>2.5.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.konghq</groupId> | |||
| @@ -14,6 +14,7 @@ import com.xueyi.common.security.annotation.Logical; | |||
| import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.message.api.transfer.domain.vo.DmActiveVo; | |||
| import com.xueyi.message.api.transfer.feign.RemoteTransferService; | |||
| import com.xueyi.system.api.device.domain.dto.DmDeviceTenantMergeDto; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; | |||
| import com.xueyi.system.api.digitalmans.feign.RemoteDigitalmanService; | |||
| @@ -21,7 +22,10 @@ import com.xueyi.system.api.model.Source; | |||
| import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | |||
| import com.xueyi.system.device.service.IDmDeviceTenantMergeService; | |||
| import com.xueyi.system.dict.service.ISysDictDataService; | |||
| import com.xueyi.system.digitalmans.domain.dto.DmDigitalmanExtDto; | |||
| import com.xueyi.system.digitalmans.domain.query.DmDigitalmanExtQuery; | |||
| import com.xueyi.system.digitalmans.domain.query.DmManDeviceQuery; | |||
| import com.xueyi.system.digitalmans.service.IDmDigitalmanExtService; | |||
| import com.xueyi.system.digitalmans.service.IDmDigitalmanService; | |||
| import com.xueyi.system.digitalmans.service.IDmManDeviceService; | |||
| import com.xueyi.system.organize.service.ISysEnterpriseService; | |||
| @@ -52,6 +56,9 @@ public class DmManDeviceController extends BaseController<DmManDeviceQuery, DmMa | |||
| @Autowired | |||
| IDmDigitalmanService digitalmanService; | |||
| @Autowired | |||
| IDmDigitalmanExtService digitalmanExtService; | |||
| @Autowired | |||
| RemoteDigitalmanService remoteDigitalmanService; | |||
| @@ -64,6 +71,9 @@ public class DmManDeviceController extends BaseController<DmManDeviceQuery, DmMa | |||
| @Autowired | |||
| ISysDictDataService sysDictDataService; | |||
| @Autowired | |||
| RemoteTransferService remoteTransferService; | |||
| /** 定义节点名称 */ | |||
| @Override | |||
| @@ -84,6 +94,25 @@ public class DmManDeviceController extends BaseController<DmManDeviceQuery, DmMa | |||
| return R.ok(dto); | |||
| } | |||
| @PostMapping(value = "/inner/sync") | |||
| R<Integer> manDeviceListInnerSync(@RequestParam(value = "tenantId") Long tenantId) { | |||
| DmManDeviceQuery query = new DmManDeviceQuery(); | |||
| query.setTId(tenantId); | |||
| //根据租户id获取设备列表 | |||
| List<DmManDeviceDto> list = super.baseService.manDeviceListNotNull(); | |||
| list.forEach(item->{ | |||
| AjaxResult ar = remoteTransferService.getDeviceOnlineStatus(item.getDeviceId()); | |||
| DmDigitalmanExtQuery query1 = new DmDigitalmanExtQuery(); | |||
| query1.setDeviceId(item.getDeviceId()); | |||
| List<DmDigitalmanExtDto> extList = digitalmanExtService.selectListByDeviceId(query1); | |||
| if (extList != null && extList.size() > 0) { | |||
| extList.get(0).setIsOnline(Integer.parseInt(ar.get("msg").toString())); | |||
| digitalmanExtService.update(extList.get(0)); | |||
| } | |||
| }); | |||
| return R.ok(); | |||
| } | |||
| @PutMapping(value = "/inner/info") | |||
| R<Integer> manDeviceInfoInnerUpdate(@RequestBody DmActiveVo vo) { | |||
| return R.ok(super.baseService.manDeviceInfoInnerUpdate(vo)); | |||
| @@ -18,4 +18,5 @@ public interface IDmManDeviceManager extends IBaseManager<DmManDeviceQuery, DmMa | |||
| Integer updateInfoByManual(DmManDeviceDto dto); | |||
| List<DmManDeviceDto> selectListByManual(DmManDeviceQuery query); | |||
| List<DmManDeviceDto> selectManDeviceListNotNull(); | |||
| } | |||
| @@ -51,4 +51,9 @@ public class DmManDeviceManager extends BaseManagerImpl<DmManDeviceQuery, DmManD | |||
| public List<DmManDeviceDto> selectListByManual(DmManDeviceQuery query) { | |||
| return mapperDto(manDeviceMapper.selectListByManual(query)); | |||
| } | |||
| @Override | |||
| public List<DmManDeviceDto> selectManDeviceListNotNull() { | |||
| return mapperDto(manDeviceMapper.selectListByManualDeviceIdNotNull()); | |||
| } | |||
| } | |||
| @@ -16,6 +16,7 @@ import java.util.List; | |||
| @Master | |||
| public interface DmManDeviceMapper extends BaseMapper<DmManDeviceQuery, DmManDeviceDto, DmManDevicePo> { | |||
| List<DmManDevicePo> selectListByManual(DmManDevicePo po); | |||
| List<DmManDevicePo> selectListByManualDeviceIdNotNull(); | |||
| DmManDevicePo getOne(String devId); | |||
| @@ -6,6 +6,8 @@ import com.xueyi.system.api.digitalmans.domain.po.DmManDevicePo; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; | |||
| import com.xueyi.system.digitalmans.domain.query.DmManDeviceQuery; | |||
| import java.util.List; | |||
| /** | |||
| * 数字人设备管理管理 服务层 | |||
| * | |||
| @@ -15,5 +17,6 @@ public interface IDmManDeviceService extends IBaseService<DmManDeviceQuery, DmMa | |||
| DmManDeviceDto manDeviceInfoInner(String devId); | |||
| Integer manDeviceInfoInnerUpdate(DmActiveVo vo); | |||
| List<DmManDeviceDto> manDeviceListNotNull(); | |||
| DmManDevicePo getOne(String devId); | |||
| } | |||
| @@ -109,4 +109,10 @@ public class DmManDeviceServiceImpl extends BaseServiceImpl<DmManDeviceQuery, Dm | |||
| public DmManDevicePo getOne(String devId) { | |||
| return manDeviceMapper.getOne(devId); | |||
| } | |||
| @Override | |||
| public List<DmManDeviceDto> manDeviceListNotNull() { | |||
| return super.baseManager.selectManDeviceListNotNull(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,159 @@ | |||
| package com.xueyi.system.exception.controller; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.common.core.web.result.AjaxResult; | |||
| import com.xueyi.common.core.web.validate.V_A; | |||
| import com.xueyi.common.core.web.validate.V_E; | |||
| import com.xueyi.common.log.annotation.Log; | |||
| import com.xueyi.common.log.enums.BusinessType; | |||
| import com.xueyi.common.mqtt.configure.MqttConfig; | |||
| import com.xueyi.common.mqtt.service.MqttMessageHandlerService; | |||
| import com.xueyi.common.mqtt.service.MqttService; | |||
| import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.system.exception.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.system.exception.domain.query.DmExceptionLogQuery; | |||
| import com.xueyi.system.exception.service.IDmExceptionLogService; | |||
| import com.xueyi.system.exception.service.LogMqttMessageHandler; | |||
| import org.eclipse.paho.client.mqttv3.MqttException; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.validation.annotation.Validated; | |||
| import org.springframework.web.bind.annotation.DeleteMapping; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.PathVariable; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.PutMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.annotation.PostConstruct; | |||
| import java.io.Serializable; | |||
| import java.util.List; | |||
| /** | |||
| * 数字人状态事件上报日志管理 业务处理 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/log") | |||
| public class DmExceptionLogController extends BaseController<DmExceptionLogQuery, DmExceptionLogDto, IDmExceptionLogService> { | |||
| @Autowired | |||
| private MqttService mqttService; | |||
| @Autowired | |||
| private LogMqttMessageHandler logMqttMessageHandler; | |||
| @Autowired | |||
| private MqttConfig mqttConfig; | |||
| /** 定义节点名称 */ | |||
| @Override | |||
| protected String getNodeName() { | |||
| return "数字人状态事件上报日志" ; | |||
| } | |||
| @PostConstruct | |||
| private void init() { | |||
| System.err.println(System.nanoTime()+"-------heelo"); | |||
| MqttMessageHandlerService mqttMessageHandlerService = new MqttMessageHandlerService(mqttService, logMqttMessageHandler); | |||
| } | |||
| /** | |||
| * 查询数字人状态事件上报日志列表 | |||
| */ | |||
| @Override | |||
| @GetMapping("/list") | |||
| @RequiresPermissions(Auth.DM_EXCEPTION_LOG_LIST) | |||
| public AjaxResult list(DmExceptionLogQuery exceptionLog) { | |||
| return super.list(exceptionLog); | |||
| } | |||
| /** | |||
| * 查询数字人状态事件上报日志详细 | |||
| */ | |||
| @Override | |||
| @GetMapping(value = "/{id}") | |||
| @RequiresPermissions(Auth.DM_EXCEPTION_LOG_SINGLE) | |||
| public AjaxResult getInfo(@PathVariable Serializable id) { | |||
| return super.getInfo(id); | |||
| } | |||
| /** | |||
| * 数字人状态事件上报日志新增 | |||
| */ | |||
| @Override | |||
| @PostMapping | |||
| @RequiresPermissions(Auth.DM_EXCEPTION_LOG_ADD) | |||
| @Log(title = "数字人状态事件上报日志管理", businessType = BusinessType.INSERT) | |||
| public AjaxResult add(@Validated({V_A.class}) @RequestBody DmExceptionLogDto exceptionLog) { | |||
| return super.add(exceptionLog); | |||
| } | |||
| /** | |||
| * 数字人状态事件上报日志修改 | |||
| */ | |||
| @Override | |||
| @PutMapping | |||
| @RequiresPermissions(Auth.DM_EXCEPTION_LOG_EDIT) | |||
| @Log(title = "数字人状态事件上报日志管理", businessType = BusinessType.UPDATE) | |||
| public AjaxResult edit(@Validated({V_E.class}) @RequestBody DmExceptionLogDto exceptionLog) { | |||
| return super.edit(exceptionLog); | |||
| } | |||
| /** | |||
| * 数字人状态事件上报日志批量删除 | |||
| */ | |||
| @Override | |||
| @DeleteMapping("/batch/{idList}") | |||
| @RequiresPermissions(Auth.DM_EXCEPTION_LOG_DEL) | |||
| @Log(title = "数字人状态事件上报日志管理", businessType = BusinessType.DELETE) | |||
| public AjaxResult batchRemove(@PathVariable List<Long> idList) { | |||
| return super.batchRemove(idList); | |||
| } | |||
| /* | |||
| * @Author yangkai | |||
| * @Description //主动拉取日志操作 | |||
| * @Date 2023/5/10 | |||
| * @Param [devId, uploadType] | |||
| * @return com.xueyi.common.core.web.result.AjaxResult | |||
| **/ | |||
| @PostMapping("/fetch-log") | |||
| public AjaxResult sendMqttMsgToDev(@RequestBody JSONObject json){ | |||
| JSONObject jsonObject = new JSONObject(); | |||
| jsonObject.put("device_id", "12345"); | |||
| try { | |||
| mqttService.sendMessage(mqttConfig.getFetchLogTopic(), jsonObject.toJSONString()); | |||
| } catch (MqttException e) { | |||
| e.printStackTrace(); | |||
| return error(e.getMessage()); | |||
| } | |||
| return success("操作成功"); | |||
| } | |||
| /** | |||
| * 获取数字人状态事件上报日志选择框列表 | |||
| */ | |||
| @Override | |||
| @GetMapping("/option") | |||
| public AjaxResult option() { | |||
| return super.option(); | |||
| } | |||
| interface Auth { | |||
| /** 系统 - 数字人状态事件上报日志管理 - 列表 */ | |||
| String DM_EXCEPTION_LOG_LIST = "log:log:list"; | |||
| /** 系统 - 数字人状态事件上报日志管理 - 详情 */ | |||
| String DM_EXCEPTION_LOG_SINGLE = "log:log:single"; | |||
| /** 系统 - 数字人状态事件上报日志管理 - 新增 */ | |||
| String DM_EXCEPTION_LOG_ADD = "log:log:add"; | |||
| /** 系统 - 数字人状态事件上报日志管理 - 修改 */ | |||
| String DM_EXCEPTION_LOG_EDIT = "log:log:edit"; | |||
| /** 系统 - 数字人状态事件上报日志管理 - 删除 */ | |||
| String DM_EXCEPTION_LOG_DEL = "log:log:delete"; | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package com.xueyi.system.exception.domain.dto; | |||
| import com.xueyi.system.exception.domain.po.DmExceptionLogPo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.io.Serial; | |||
| /** | |||
| * 数字人状态事件上报日志 数据传输对象 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class DmExceptionLogDto extends DmExceptionLogPo { | |||
| @Serial | |||
| private static final long serialVersionUID = 1L; | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.xueyi.system.exception.domain.model; | |||
| import com.xueyi.common.core.web.entity.model.BaseConverter; | |||
| import com.xueyi.system.exception.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.system.exception.domain.po.DmExceptionLogPo; | |||
| import com.xueyi.system.exception.domain.query.DmExceptionLogQuery; | |||
| import org.mapstruct.Mapper; | |||
| import org.mapstruct.MappingConstants; | |||
| /** | |||
| * 数字人状态事件上报日志 对象映射器 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) | |||
| public interface DmExceptionLogConverter extends BaseConverter<DmExceptionLogQuery, DmExceptionLogDto, DmExceptionLogPo> { | |||
| } | |||
| @@ -0,0 +1,69 @@ | |||
| package com.xueyi.system.exception.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.fasterxml.jackson.annotation.JsonFormat; | |||
| import com.xueyi.common.core.annotation.Excel; | |||
| import com.xueyi.common.core.web.entity.base.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.io.Serial; | |||
| import java.time.LocalDateTime; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.NAME; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.REMARK; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.SORT; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.STATUS; | |||
| /** | |||
| * 数字人状态事件上报日志 持久化对象 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| @TableName(value = "dm_exception_log", excludeProperty = { STATUS, SORT, REMARK, NAME }) | |||
| public class DmExceptionLogPo extends BaseEntity { | |||
| @Serial | |||
| private static final long serialVersionUID = 1L; | |||
| /** 数字人ID */ | |||
| @Excel(name = "数字人ID") | |||
| protected Long manId; | |||
| /** 故障类型(重启,摄像头故障等) */ | |||
| @Excel(name = "故障类型(重启,摄像头故障等)") | |||
| protected Integer type; | |||
| /** 故障等级 */ | |||
| @Excel(name = "故障等级") | |||
| protected Integer level; | |||
| /** 故障发生时间 */ | |||
| @Excel(name = "故障发生时间") | |||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
| protected LocalDateTime occurTime; | |||
| /** 故障结束时间 */ | |||
| @Excel(name = "故障结束时间") | |||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
| protected LocalDateTime endTime; | |||
| /** 事件名 */ | |||
| @Excel(name = "事件名") | |||
| protected String exceptionName; | |||
| /** 报警状态(0预警中 1已解除 ) */ | |||
| @Excel(name = "报警状态(0预警中 1已解除 )") | |||
| protected Integer alertStatus; | |||
| /** 所属组织ID */ | |||
| @Excel(name = "所属组织ID") | |||
| protected Long deptId; | |||
| /** 租户Id */ | |||
| @Excel(name = "租户Id") | |||
| protected Long tId; | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| package com.xueyi.system.exception.domain.query; | |||
| import com.xueyi.system.exception.domain.po.DmExceptionLogPo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.io.Serial; | |||
| /** | |||
| * 数字人状态事件上报日志 数据查询对象 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class DmExceptionLogQuery extends DmExceptionLogPo { | |||
| @Serial | |||
| private static final long serialVersionUID = 1L; | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| package com.xueyi.system.exception.manager; | |||
| import com.xueyi.system.exception.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.system.exception.domain.query.DmExceptionLogQuery; | |||
| import com.xueyi.common.web.entity.manager.IBaseManager; | |||
| /** | |||
| * 数字人状态事件上报日志管理 数据封装层 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| public interface IDmExceptionLogManager extends IBaseManager<DmExceptionLogQuery, DmExceptionLogDto> { | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| package com.xueyi.system.exception.manager.impl; | |||
| import com.xueyi.common.web.entity.manager.impl.BaseManagerImpl; | |||
| import com.xueyi.system.exception.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.system.exception.domain.model.DmExceptionLogConverter; | |||
| import com.xueyi.system.exception.domain.po.DmExceptionLogPo; | |||
| import com.xueyi.system.exception.domain.query.DmExceptionLogQuery; | |||
| import com.xueyi.system.exception.manager.IDmExceptionLogManager; | |||
| import com.xueyi.system.exception.mapper.DmExceptionLogMapper; | |||
| import org.springframework.stereotype.Component; | |||
| /** | |||
| * 数字人状态事件上报日志管理 数据封装层处理 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Component | |||
| public class DmExceptionLogManager extends BaseManagerImpl<DmExceptionLogQuery, DmExceptionLogDto, DmExceptionLogPo, DmExceptionLogMapper, DmExceptionLogConverter> implements IDmExceptionLogManager { | |||
| } | |||
| @@ -0,0 +1,16 @@ | |||
| package com.xueyi.system.exception.mapper; | |||
| import com.xueyi.common.datasource.annotation.Master; | |||
| import com.xueyi.common.web.entity.mapper.BaseMapper; | |||
| import com.xueyi.system.exception.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.system.exception.domain.po.DmExceptionLogPo; | |||
| import com.xueyi.system.exception.domain.query.DmExceptionLogQuery; | |||
| /** | |||
| * 数字人状态事件上报日志管理 数据层 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Master | |||
| public interface DmExceptionLogMapper extends BaseMapper<DmExceptionLogQuery, DmExceptionLogDto, DmExceptionLogPo> { | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| package com.xueyi.system.exception.service; | |||
| import com.xueyi.system.exception.domain.query.DmExceptionLogQuery; | |||
| import com.xueyi.system.exception.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.common.web.entity.service.IBaseService; | |||
| /** | |||
| * 数字人状态事件上报日志管理 服务层 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| public interface IDmExceptionLogService extends IBaseService<DmExceptionLogQuery, DmExceptionLogDto> { | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| package com.xueyi.system.exception.service; | |||
| import com.xueyi.common.mqtt.service.MqttMessageHandler; | |||
| import org.springframework.stereotype.Service; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-05-10 19:08 | |||
| */ | |||
| @Service | |||
| public class LogMqttMessageHandler implements MqttMessageHandler { | |||
| @Override | |||
| public void handleMessage(String topic, String message) { | |||
| // 处理消息的业务逻辑 | |||
| System.out.println("收到主题eee:" + topic + ",消息内容eee:" + message); | |||
| } | |||
| } | |||
| @@ -0,0 +1,32 @@ | |||
| package com.xueyi.system.exception.service.impl; | |||
| import com.xueyi.system.exception.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.system.exception.domain.query.DmExceptionLogQuery; | |||
| import com.xueyi.system.exception.service.IDmExceptionLogService; | |||
| import com.xueyi.system.exception.manager.IDmExceptionLogManager; | |||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.List; | |||
| /** | |||
| * 数字人状态事件上报日志管理 服务层处理 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Service | |||
| public class DmExceptionLogServiceImpl extends BaseServiceImpl<DmExceptionLogQuery, DmExceptionLogDto, IDmExceptionLogManager> implements IDmExceptionLogService { | |||
| /** | |||
| * 查询数字人状态事件上报日志对象列表 | 数据权限 | |||
| * | |||
| * @param exceptionLog 数字人状态事件上报日志对象 | |||
| * @return 数字人状态事件上报日志对象集合 | |||
| */ | |||
| @Override | |||
| //@DataScope(userAlias = "createBy", mapperScope = {"DmExceptionLogMapper"}) | |||
| public List<DmExceptionLogDto> selectListScope(DmExceptionLogQuery exceptionLog) { | |||
| return baseManager.selectList(exceptionLog); | |||
| } | |||
| } | |||
| @@ -62,7 +62,6 @@ public class DmVisitorApiController extends BaseApiController { | |||
| @ResponseBody | |||
| public JSONObject newVisit(@RequestBody DmVisitCommonDto commonDto){ | |||
| DeviceTenantSourceMergeVo vo = super.getDeviceTenantSourceMergeVo(commonDto.getDevId()); | |||
| return visitorService.newVisit(commonDto, vo.getTenantId(), vo.getSourceSlave(), SecurityConstants.INNER); | |||
| } | |||
| @@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| @@ -75,16 +76,33 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| JSONObject json = new JSONObject(); | |||
| if (null == v) { | |||
| return output(ResponseCode.NOT_FOUND_VISITOR).toJSON(); | |||
| } else { | |||
| v.setRecordStatus(DmVisitRecordsDto.STATUS_VISITED); | |||
| v.setUpdateTime(DateUtils.dateToLocalDateTime(new Date())); | |||
| dmVisitRecordsMapper.updateById(v); | |||
| json.put("empId", v.getUserId()); | |||
| json.put("visitorName", visitorName); | |||
| DmStaffPo e = dmStaffMapper.selectById(v.getUserId()); | |||
| if (null != e){ | |||
| json.put("phone", e.getPhone()); | |||
| json.put("visitorId", v.getVisitorId()); | |||
| //给访问对象发送短信 | |||
| SmsReqEntity send = new SmsReqEntity(); | |||
| try { | |||
| if (StringUtils.isNotEmpty(e.getPhone())) { | |||
| send.setPhone(e.getPhone()); | |||
| send.setTemplate(smsProperties.getDefaultRemindTemplate()); | |||
| remoteSmsService.sendSms(send); | |||
| } | |||
| } catch (Exception ee) { | |||
| ee.printStackTrace(); | |||
| } | |||
| } | |||
| return outputSuccess(json).toJSON(); | |||
| } | |||
| json.put("id", v.getId()); | |||
| json.put("empId", v.getUserId()); | |||
| DmStaffPo e = dmStaffMapper.selectById(v.getUserId()); | |||
| json.put("phone", e.getPhone()); | |||
| json.put("visitorName", visitorName); | |||
| json.put("visitorId", v.getVisitorId()); | |||
| // DictUtil.getDictCache() | |||
| return outputSuccess(json).toJSON(); | |||
| } | |||
| @InnerAuth | |||
| @@ -96,7 +114,7 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| Wrappers.<DmVisitorsPo>query().lambda() | |||
| .eq(DmVisitorsPo::getPhone, commonDto.getVisitorTel()).last(SqlConstants.LIMIT_ONE)); | |||
| } | |||
| if (v ==null) { | |||
| if (v == null) { | |||
| v = new DmVisitorsPo(); | |||
| v.setName(commonDto.getVisitorName()); | |||
| v.setNickname(commonDto.getVisitorNickName()); | |||
| @@ -107,7 +125,6 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| } | |||
| DmVisitRecordsPo visitRecords = new DmVisitRecordsPo(); | |||
| DmStaffPo emp = dmStaffMapper.selectOne( | |||
| Wrappers.<DmStaffPo>query().lambda() | |||
| .eq(DmStaffPo::getId, commonDto.getEmpId()).last(SqlConstants.LIMIT_ONE)); | |||
| @@ -119,11 +136,16 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| dmStaffMapper.update(emp, wrapper); | |||
| visitRecords.setDeptId(emp.getDeptId()); | |||
| visitRecords.setVisitorId(v.getId()); | |||
| System.err.println(commonDto); | |||
| if (StringUtils.isNotEmpty(commonDto.getVisitDate())) { | |||
| visitRecords.setVisitDate(DateUtils.parseStrToDate(commonDto.getVisitDate(), "yyyy-MM-dd HH:mm:ss")); | |||
| System.err.println("exec in"); | |||
| System.err.println(commonDto.getVisitDate()); | |||
| System.err.println(DateUtils.parseStrToDate(commonDto.getVisitDate(), "yyyy-MM-dd")); | |||
| visitRecords.setVisitDate(DateUtils.parseStrToDate(commonDto.getVisitDate(), "yyyy-MM-dd")); | |||
| } | |||
| visitRecords.setUserId(commonDto.getEmpId()); | |||
| visitRecords.setRecordStatus(VisitRecordStatus.getRecordStatusStart()); | |||
| System.err.println(visitRecords); | |||
| dmVisitRecordsMapper.insert(visitRecords); | |||
| } else { | |||
| return output(ResponseCode.DATA_NOT_EXISTS, "员工").toJSON(); | |||
| @@ -34,6 +34,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| </where> | |||
| </select> | |||
| <select id="selectListByManualDeviceIdNotNull" resultMap="DmManDeviceResult"> | |||
| select * from dm_man_device as s | |||
| where device_id is not null | |||
| </select> | |||
| <select id="getOne" parameterType="String" resultType="DmManDevicePo"> | |||
| select * from dm_man_device where device_id = #{devId} Limit 1 | |||
| </select> | |||
| @@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.xueyi.system.staff.mapper.DmVisitRecordsMapper"> | |||
| <select id="findByName" parameterType="Object" resultType="DmVisitRecordsPo"> | |||
| select * from dm_visit_records u where u.visitor_id in (select id from dm_visitors where name = #{visitorName}) limit 1 | |||
| select * from dm_visit_records u where u.visit_date = CURRENT_DATE AND u.visitor_id in (select id from dm_visitors where name = #{visitorName}) limit 1 | |||
| </select> | |||
| <select id="findByEmp" parameterType="Object" resultType="DmVisitRecordsPo"> | |||