Browse Source

Merge pull request 'dev' (#153) from dev into main

Reviewed-on: http://39.105.23.186:3000/develop/digimeta-MultiSaas/pulls/153
tags/B.2.1.6_20231017_release
bogemail 2 years ago
parent
commit
4f8dc1ac22
15 changed files with 188 additions and 144 deletions
  1. +3
    -0
      xueyi-api/xueyi-api-system/src/main/java/com/xueyi/system/api/resource/feign/RemoteH5ConfigService.java
  2. +4
    -0
      xueyi-api/xueyi-api-system/src/main/java/com/xueyi/system/api/resource/feign/factory/RemoteH5ConfigFallbackFactory.java
  3. +6
    -0
      xueyi-api/xueyi-api-system/src/main/java/com/xueyi/system/api/staff/feign/RemoteStaffService.java
  4. +8
    -0
      xueyi-common/xueyi-common-redis/src/main/java/com/xueyi/common/redis/utils/RedisUtil.java
  5. +6
    -3
      xueyi-modules/xueyi-file/src/main/java/com/xueyi/file/service/MinioSysFileServiceImpl.java
  6. +26
    -16
      xueyi-modules/xueyi-message/src/main/java/com/xueyi/message/transfer/controller/ApiController.java
  7. +0
    -87
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/digitalmans/controller/DmDigitalmanController.java
  8. +11
    -1
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/file/controller/SysFileController.java
  9. +23
    -31
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/resource/service/impl/DmH5ConfigServiceImpl.java
  10. +57
    -0
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/controller/api/DmStaffApiController.java
  11. +12
    -0
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/controller/api/DmStaffInnerApiController.java
  12. +7
    -3
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/mapper/DmStaffMapper.java
  13. +2
    -0
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/service/IDmStaffService.java
  14. +15
    -3
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/service/impl/DmStaffServiceImpl.java
  15. +8
    -0
      xueyi-modules/xueyi-system/src/main/resources/mapper/staff/DmStaffMapper.xml

+ 3
- 0
xueyi-api/xueyi-api-system/src/main/java/com/xueyi/system/api/resource/feign/RemoteH5ConfigService.java View File

@@ -11,4 +11,7 @@ public interface RemoteH5ConfigService {

@GetMapping("/h5config/inner/syncH5Config")
R<String> syncH5Config(@RequestParam(value = "tId",required = false) String tId);

@GetMapping("/h5config/inner/syncH5Config")
public R<String> syncH5Config(@RequestParam(value = "tId", required = false) String tId, @RequestParam(value = "manCode", required = false) String manCode);
}

+ 4
- 0
xueyi-api/xueyi-api-system/src/main/java/com/xueyi/system/api/resource/feign/factory/RemoteH5ConfigFallbackFactory.java View File

@@ -16,6 +16,10 @@ public class RemoteH5ConfigFallbackFactory implements FallbackFactory<RemoteH5Co
public R<String> syncH5Config(String tId) {
return R.fail("同步配置文件失败");
}

public R<String> syncH5Config(String tId, String manCode) {
return R.fail("同步配置文件失败");
}
};
}
}

+ 6
- 0
xueyi-api/xueyi-api-system/src/main/java/com/xueyi/system/api/staff/feign/RemoteStaffService.java View File

@@ -40,4 +40,10 @@ public interface RemoteStaffService {
@PostMapping(value = "/staff/inner-api/new-staff")
@ResponseBody
public com.alibaba.fastjson2.JSONObject addStaff(@RequestBody DmStaffCommonDto commonDto,@RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

@GetMapping("/staff/api/broadcast-staff-count")
JSONObject queryStaffCount(@RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

@GetMapping("/staff/api/staff-count")
JSONObject staffCount();
}

+ 8
- 0
xueyi-common/xueyi-common-redis/src/main/java/com/xueyi/common/redis/utils/RedisUtil.java View File

@@ -48,6 +48,10 @@ public class RedisUtil {
return redisTemplate.opsForList().range(key, 0, -1);
}

public static List<Object> getObjectList(String key) {
return redisTemplate.opsForHash().values(key);
}

public static Long getListCount(String key) {
return redisTemplate.opsForList().size(key);
}
@@ -89,4 +93,8 @@ public class RedisUtil {
}


public static Object getHashChildItem(String key, String childKey){
return redisTemplate.opsForHash().get(key, childKey);
}

}

+ 6
- 3
xueyi-modules/xueyi-file/src/main/java/com/xueyi/file/service/MinioSysFileServiceImpl.java View File

@@ -68,9 +68,12 @@ public class MinioSysFileServiceImpl implements ISysFileService {

@Override
public String uploadExactFile(MultipartFile file, String extension) throws Exception {
String fileName = FileUploadUtils.extractFilename(file);

fileName += extension;
String fileName = FileUploadUtils.extractFilename(file).replaceAll(extension, "");
if (fileName.charAt(fileName.length() - 1) == '.') {
fileName += extension;
} else {
fileName += "." + extension;
}
//fileName = URLEncoder.encode(fileName, "UTF-8");
log.info("Minio filename: {}" , fileName);
PutObjectArgs args = PutObjectArgs.builder()


+ 26
- 16
xueyi-modules/xueyi-message/src/main/java/com/xueyi/message/transfer/controller/ApiController.java View File

@@ -44,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
@@ -225,7 +226,7 @@ public class ApiController {
// jsObject.put("msg","success");
return AjaxResult.success(receptionVo.getData());
case 4:
R<String> propertyR = remoteH5ConfigService.syncH5Config(manDeviceDtoR.getData().getTId().toString());
R<String> propertyR = remoteH5ConfigService.syncH5Config(manDeviceDtoR.getData().getTId().toString(), manDeviceDtoR.getData().getManCode().toString());
if (propertyR.isFail()) {
return AjaxResult.warn("配置同步失败,请检查");
}
@@ -293,15 +294,15 @@ public class ApiController {
return AjaxResult.success(System.currentTimeMillis() - Long.parseLong(timestamp) > 10 * 60 * 1000 ? InitConstants.DEVICE_ACTIVATE_STATUS_OFFLINE : InitConstants.DEVICE_ACTIVATE_STATUS_ONLINE);
}

@RequestMapping(value = "/test", method = {RequestMethod.GET} )
@ResponseBody
public R<JSONObject> test(HttpServletRequest request) {
return mansInfo();
}

public R<JSONObject> mansInfo() {

Long serviceTimeCount = 0L;
/*List<DmManDeviceDto> dtos = dmManDeviceService.selectList(new DmManDeviceQuery());
List<DmManDeviceDto> dtos2 = dtos.stream().filter(dto -> StringUtils.isNotEmpty(dto.getDeviceId())).collect(Collectors.toList());;*/
//当前时间和activateTime时间的差值,activateTime类型是Date,差值返回的单位是小时
/*for (DmManDeviceDto dto : dtos2) {
serviceTimeCount += (System.currentTimeMillis() - dto.getActivateTime().getTime())/3600000;
}*/

Integer meetingServiceCount = RedisUtil.getNumberVal("dashboard:meeting");
Integer serverTimes = RedisUtil.getNumberVal("dashboard:server");
@@ -331,13 +332,20 @@ public class ApiController {
//取值后清除缓存list,5秒后过期
// RedisUtil.expire("dashboard:skill-consume", 5);
}
Long onlineCount = 4L;
/*if (RedisUtil.existed(MessageConstants.REDIS_GROUP_DEVICE_HEADER)) {
List<Object> manDeviceDtos = (List<Object>)redisTemplate.opsForHash().values(MessageConstants.REDIS_GROUP_DEVICE_HEADER);
onlineCount = manDeviceDtos.stream().filter(item->(!((DmManDeviceDto)item).getOnlineStatus().isEmpty()) &&
((DmManDeviceDto)item).getOnlineStatus().equalsIgnoreCase("1")).count();
log.info("devs:{}, onlineCount:{}",manDeviceDtos.size(), onlineCount);
}*/
Long onlineCount = 0L;
if (RedisUtil.existed(MessageConstants.REDIS_GROUP_DEVICE_HEADER)) {
List<Object> hashVals = RedisUtil.getObjectList(MessageConstants.REDIS_GROUP_DEVICE_HEADER);
List<DmManDeviceDto> dtos = hashVals.stream().map(item->(DmManDeviceDto)item).collect(Collectors.toList());
onlineCount = dtos.stream().filter(item->(!item.getOnlineStatus().isEmpty()) &&
item.getOnlineStatus().equalsIgnoreCase("1")).count();

List<DmManDeviceDto> dtos2 = dtos.stream().filter(item->item.getActivateTime() != null).collect(Collectors.toList());
for(DmManDeviceDto item:dtos2) {
serviceTimeCount += (System.currentTimeMillis() - item.getActivateTime().getTime())/3600000;
}

log.info("devs:{}, onlineCount:{}",dtos.size(), onlineCount);
}

JSONArray jsonArray = new JSONArray();
// 最近三十天的数据,服务人次,知识库增量
@@ -356,7 +364,7 @@ public class ApiController {
json.put("manOnlineCount",onlineCount);//数字人数
json.put("recognizedPersonCount", recognition);//注册人员总数
json.put("serviceTimeCount",serviceTimeCount);//总服务时间
json.put("staffTotalCount",1062);//总服务时间
json.put("staffTotalCount",remoteStaffService.staffCount().getLongValue("data"));//总服务时间
json.put("chatTimes",conversationTimes);//对话次数
json.put("chatDurationCount",conversationDuration);//对话时长

@@ -421,10 +429,12 @@ public class ApiController {
// 根据设备id获取租户信息
R<DmManDeviceDto> manDeviceDtoR = manDeviceService.manDeviceInfoInner(deviceId);
String tenantId = null;
String manCode = null;
if (manDeviceDtoR.isOk() && manDeviceDtoR.getData() != null) {
tenantId = manDeviceDtoR.getData().getTId().toString();
manCode = manDeviceDtoR.getData().getManCode().toString();
}
R<String> propertyR = remoteH5ConfigService.syncH5Config(tenantId);
R<String> propertyR = remoteH5ConfigService.syncH5Config(tenantId, manCode);
if (propertyR.isFail()) {
return AjaxResult.warn("配置同步失败,请检查");
}


+ 0
- 87
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/digitalmans/controller/DmDigitalmanController.java View File

@@ -1,6 +1,5 @@
package com.xueyi.system.digitalmans.controller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -12,10 +11,8 @@ import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.core.web.result.R;
import com.xueyi.common.core.web.validate.V_A;
import com.xueyi.common.core.web.validate.V_E;
import com.xueyi.common.datasource.annotation.Master;
import com.xueyi.common.log.annotation.Log;
import com.xueyi.common.log.enums.BusinessType;
import com.xueyi.common.redis.utils.RedisUtil;
import com.xueyi.common.security.annotation.InnerAuth;
import com.xueyi.common.security.annotation.RequiresPermissions;
import com.xueyi.common.web.entity.controller.BaseController;
@@ -35,7 +32,6 @@ import com.xueyi.system.digitalmans.domain.dto.DmDigitalmanExtDto;
import com.xueyi.system.digitalmans.domain.model.DmDigitalmanExtConverter;
import com.xueyi.system.digitalmans.domain.query.DmDigitalmanExtQuery;
import com.xueyi.system.digitalmans.domain.query.DmDigitalmanQuery;
import com.xueyi.system.digitalmans.domain.query.DmManDeviceQuery;
import com.xueyi.system.digitalmans.mapper.DmManDeviceMapper;
import com.xueyi.system.digitalmans.service.IDmDigitalmanExtService;
import com.xueyi.system.digitalmans.service.IDmDigitalmanService;
@@ -67,10 +63,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
import java.text.ParseException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
* 数字人基础管理 业务处理
@@ -395,86 +388,6 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm
DmManDeviceServiceImpl dmManDeviceService;


@GetMapping("/api/mansInfo")
@Master
public R<JSONObject> mansInfo() {

List<DmManDeviceDto> dtos = dmManDeviceService.selectList(new DmManDeviceQuery());
List<DmManDeviceDto> dtos2 = dtos.stream().filter(dto -> StringUtils.isNotEmpty(dto.getDeviceId())).collect(Collectors.toList());;
Long serviceTimeCount = 0L;
//当前时间和activateTime时间的差值,activateTime类型是Date,差值返回的单位是小时
for (DmManDeviceDto dto : dtos2) {
serviceTimeCount += (System.currentTimeMillis() - dto.getActivateTime().getTime())/3600000;
}

Integer meetingServiceCount = RedisUtil.getNumberVal("dashboard:meeting");
Integer serverTimes = RedisUtil.getNumberVal("dashboard:server");
Integer recognition = RedisUtil.getNumberVal("dashboard:recognition");
Integer receptionCount = RedisUtil.getNumberVal("dashboard:create_visitor_info");
Integer visitorCount = RedisUtil.getNumberVal("dashboard:register_visitor");
Integer attendanceCount = RedisUtil.getNumberVal("dashboard:attendance");
Integer openDoorCount = RedisUtil.getNumberVal("dashboard:open_door");
Integer conversationDuration = RedisUtil.getNumberVal("dashboard:conversation-duration");
Integer conversationTimes = RedisUtil.getNumberVal("dashboard:conversation-times");
Integer broadcastCount = RedisUtil.getNumberVal("dashboard:broadcast-count");
List<JSONObject> knowledgeList = new ArrayList<>();
if (RedisUtil.existed("dashboard:knowledge-consume")) {
knowledgeList = RedisUtil.getJsonList("dashboard:knowledge-consume");
//取值后清除缓存list,5秒后过期
// RedisUtil.expire("dashboard:knowledge-consume", 5);
}
List<JSONObject> skillList = new ArrayList<>();
if (RedisUtil.existed("dashboard:skill-consume")) {
skillList = RedisUtil.getJsonList("dashboard:skill-consume");
//取值后清除缓存list,5秒后过期
// RedisUtil.expire("dashboard:skill-consume", 5);
}
Long onlineCount = 0L;
if (RedisUtil.existed(MessageConstants.REDIS_GROUP_DEVICE_HEADER)) {
List<Object> manDeviceDtos = (List<Object>)redisTemplate.opsForHash().values(MessageConstants.REDIS_GROUP_DEVICE_HEADER);
onlineCount = manDeviceDtos.stream().filter(item->(!((DmManDeviceDto)item).getOnlineStatus().isEmpty()) &&
((DmManDeviceDto)item).getOnlineStatus().equalsIgnoreCase("1")).count();
log.info("devs:{}, onlineCount:{}",manDeviceDtos.size(), onlineCount);
}

JSONArray jsonArray = new JSONArray();
// 最近三十天的数据,服务人次,知识库增量
for (int i = 0; i < 30; i++) {
Date date = DateUtils.addDays(new Date(), -i);
String dateStr2 = DateUtils.formatDate(date, "yyyy-MM-dd");
JSONObject json2 = new JSONObject();
json2.put("date", dateStr2);
json2.put("serviceTimes", RedisUtil.getNumberVal("dashboard:server-chart:"+dateStr2));
json2.put("knowledgeNums", RedisUtil.getNumberVal("dashboard:server-chart:"+dateStr2));
jsonArray.add(json2);
}

JSONObject json = new JSONObject();
json.put("manCount",dtos2.size());//数字人数
json.put("manOnlineCount",onlineCount);//数字人数
json.put("recognizedPersonCount", recognition);//注册人员总数
json.put("serviceTimeCount",serviceTimeCount);//总服务时间
json.put("chatTimes",conversationTimes);//对话次数
json.put("chatDurationCount",conversationDuration);//对话时长

json.put("servicePerCount",serverTimes);//用户使用频次?改成服务人次
json.put("serviceTotal",meetingServiceCount+receptionCount+visitorCount+attendanceCount+openDoorCount+broadcastCount);

json.put("meetingServiceCount", meetingServiceCount);//会议
json.put("receptionCount",receptionCount);//接待
json.put("visitorCount",visitorCount);//访客
json.put("attendanceCount",attendanceCount);//考勤
json.put("openDoorCount",openDoorCount);//门禁
json.put("broadcastCount",broadcastCount);//播报

json.put("knowledgeConsume",knowledgeList);//实时知识库调用
json.put("skillConsume",skillList);//实时技能调用
json.put("serverCharts",jsonArray);//
log.info(json.toJSONString());
return R.ok(json);
}


@GetMapping("/api/devInfo/{devId}")
public R<DmDigitalmanExtPo> devInfo(@PathVariable(required = true) String devId) {
if (StringUtils.isNotEmpty(devId)){


+ 11
- 1
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/file/controller/SysFileController.java View File

@@ -13,8 +13,15 @@ import com.xueyi.common.web.entity.controller.BaseController;
import com.xueyi.system.file.domain.dto.SysFileDto;
import com.xueyi.system.file.domain.query.SysFileQuery;
import com.xueyi.system.file.service.ISysFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
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;

@@ -27,6 +34,8 @@ import java.util.List;
@RequestMapping("/file")
public class SysFileController extends BaseController<SysFileQuery, SysFileDto, ISysFileService> {

private static final Logger log = LoggerFactory.getLogger(SysFileController.class);

/** 定义节点名称 */
@Override
protected String getNodeName() {
@@ -39,6 +48,7 @@ public class SysFileController extends BaseController<SysFileQuery, SysFileDto,
@InnerAuth
@PostMapping
public AjaxResult addInner(@Validated({V_A.class}) @RequestBody SysFileDto file) {
logger.info("file size:{}", file.getSize());
return toAjax(StrUtil.isEmpty(BaseSecurityUtils.getSourceName()) ? baseService.insertToMaster(file) : baseService.insert(file));
}



+ 23
- 31
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/resource/service/impl/DmH5ConfigServiceImpl.java View File

@@ -5,22 +5,17 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.exception.NacosException;
import com.aliyun.tea.utils.StringUtils;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.xueyi.common.core.constant.nacos.NacosConstants;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto;
import com.xueyi.system.digitalmans.domain.dto.DmDigitalmanDto;
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.manager.IDmDigitalmanExtManager;
import com.xueyi.system.digitalmans.manager.IDmManDeviceManager;
import com.xueyi.system.digitalmans.service.IDmManDeviceService;
import com.xueyi.system.resource.domain.dto.DmH5ConfigDto;
import com.xueyi.system.resource.domain.query.DmH5ConfigQuery;
import com.xueyi.system.resource.manager.IDmH5ConfigManager;
import com.xueyi.system.resource.manager.impl.DmH5ConfigManager;
import com.xueyi.system.resource.service.IDmH5ConfigService;
import com.xueyi.system.resource.manager.IDmH5ConfigManager;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +24,6 @@ import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
@@ -78,9 +72,9 @@ public class DmH5ConfigServiceImpl extends BaseServiceImpl<DmH5ConfigQuery, DmH5
try {
String property = nacosConfigManager.getConfigService().getConfig(item.getName(), NacosConstants.DEFAULT_GROUP, 5000);
JSONObject jo = JSON.parseObject(property);
if (jo.containsKey("system")) {
if (jo != null && jo.containsKey("system")) {
JSONObject sys = jo.getJSONObject("system");
if (sys.containsKey("H5")) {
if (sys != null && sys.containsKey("H5")) {
JSONObject H5 = sys.getJSONObject("H5");
H5.put("streamUrl", streamUrl);
}
@@ -144,9 +138,9 @@ public class DmH5ConfigServiceImpl extends BaseServiceImpl<DmH5ConfigQuery, DmH5
try {
String property = nacosConfigManager.getConfigService().getConfig(dto.getName(), NacosConstants.DEFAULT_GROUP, 5000);
JSONObject jo = JSON.parseObject(property);
if (jo.containsKey("system")) {
if (jo != null && jo.containsKey("system")) {
JSONObject sys = jo.getJSONObject("system");
if (sys.containsKey("H5")) {
if (sys != null && sys.containsKey("H5")) {
JSONObject H5 = sys.getJSONObject("H5");
String streamUrl = H5.getString("streamUrl");
target.setStreamUrl(streamUrl);
@@ -178,20 +172,16 @@ public class DmH5ConfigServiceImpl extends BaseServiceImpl<DmH5ConfigQuery, DmH5
List<DmManDeviceDto> mdList = dmManDeviceManager.selectList(query);
if (mdList != null && mdList.size() > 0) {
DmManDeviceDto target = mdList.get(0);
try {
String property = nacosConfigManager.getConfigService().getConfig(dto.getName(), NacosConstants.DEFAULT_GROUP, 5000);
JSONObject jo = JSON.parseObject(property);
if (jo.containsKey("system")) {
JSONObject sys = jo.getJSONObject("system");
if (sys.containsKey("H5")) {
JSONObject H5 = sys.getJSONObject("H5");
String streamUrl = H5.getString("streamUrl");
target.setStreamUrl(streamUrl);
dmManDeviceManager.update(target);
}
String property = dto.getProperty();
JSONObject jo = JSON.parseObject(property);
if (jo != null && jo.containsKey("system")) {
JSONObject sys = jo.getJSONObject("system");
if (sys != null && sys.containsKey("H5")) {
JSONObject H5 = sys.getJSONObject("H5");
String streamUrl = H5.getString("streamUrl");
target.setStreamUrl(streamUrl);
dmManDeviceManager.update(target);
}
} catch (NacosException ne) {
log.error("H5配置表上传nacos-更新配置文件失败:{}", ne.getMessage());
}
}
return super.update(dto);
@@ -226,14 +216,15 @@ public class DmH5ConfigServiceImpl extends BaseServiceImpl<DmH5ConfigQuery, DmH5
return null;
}
JSONObject jo = JSON.parseObject(result);
if (jo.containsKey("system")) {
if (jo != null && jo.containsKey("system")) {
JSONObject sys = jo.getJSONObject("system");
if (sys.containsKey("H5")) {
if (sys != null && sys.containsKey("H5")) {
JSONObject H5 = sys.getJSONObject("H5");
H5.put("streamUrl", streamUrl);
}
}
result = jo.toString();
if (jo != null)
result = jo.toString();
dto.setProperty(result);
}
return dto;
@@ -268,14 +259,15 @@ public class DmH5ConfigServiceImpl extends BaseServiceImpl<DmH5ConfigQuery, DmH5
String streamUrl = extList.get(0).getStreamUrl();
if (!StringUtils.isEmpty(streamUrl)) {
JSONObject jo = JSON.parseObject(result);
if (jo.containsKey("system")) {
if (jo != null && jo.containsKey("system")) {
JSONObject sys = jo.getJSONObject("system");
if (sys.containsKey("H5")) {
if (sys != null && sys.containsKey("H5")) {
JSONObject H5 = sys.getJSONObject("H5");
H5.put("streamUrl", streamUrl);
}
}
result = jo.toString();
if (jo != null)
result = jo.toString();
return result;
} else {
return result;


+ 57
- 0
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/controller/api/DmStaffApiController.java View File

@@ -1,11 +1,22 @@
package com.xueyi.system.staff.controller.api;

import com.alibaba.fastjson2.JSONObject;
import com.xueyi.common.cache.utils.SourceUtil;
import com.xueyi.common.core.constant.basic.SecurityConstants;
import com.xueyi.common.core.context.SecurityContextHolder;
import com.xueyi.common.core.web.result.R;
import com.xueyi.common.redis.utils.RedisUtil;
import com.xueyi.common.web.annotation.TenantIgnore;
import com.xueyi.system.api.device.domain.vo.DeviceTenantSourceMergeVo;
import com.xueyi.system.api.model.Source;
import com.xueyi.system.api.staff.domain.dto.DmStaffCommonDto;
import com.xueyi.system.api.staff.feign.RemoteStaffService;
import com.xueyi.system.resource.controller.api.BaseApiController;
import com.xueyi.system.staff.service.impl.DmStaffServiceImpl;
import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto;
import com.xueyi.tenant.api.tenant.feign.RemoteTenantService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -15,6 +26,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* 员工管理 API业务处理
*
@@ -24,9 +37,17 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/staff/api")
public class DmStaffApiController extends BaseApiController {

private static final Logger log = LoggerFactory.getLogger(DmStaffApiController.class);

@Autowired
private RemoteStaffService staffService;

@Autowired
private DmStaffServiceImpl dmStaffService;

@Autowired
private RemoteTenantService tenantService;

@GetMapping(value = "fetchOne/{devId}/{staffId}")
@ResponseBody
public JSONObject fetchStaff(@PathVariable("devId") String devId, @PathVariable("staffId") String staffId){
@@ -41,4 +62,40 @@ public class DmStaffApiController extends BaseApiController {
DeviceTenantSourceMergeVo vo = super.getDeviceTenantSourceMergeVo(commonDto.getDevId());
return staffService.addStaff(commonDto, vo.getTenantId(), vo.getSourceSlave(), SecurityConstants.INNER);
}

@GetMapping(value = "broadcast-staff-count")
@ResponseBody
@TenantIgnore(tenantLine = true)
public JSONObject queryStaff(){
SecurityContextHolder.set("sourceName", "slave");
Long count = dmStaffService.selectStaffAndVisitorCount();
return outputSuccess(count).toJSON();
}

@GetMapping(value = "staff-count")
@ResponseBody
public JSONObject staffCount(){
if (RedisUtil.existed("saas:staff:totalCountAndVisitor")){
String str = RedisUtil.getVal("saas:staff:totalCountAndVisitor").toString();
log.info("staff-count res:{}", str);
return JSONObject.parse(str);
}

R<List<TeTenantDto>> listR = tenantService.tenantList();
if (listR.isFail()) {
System.out.println("租户列表获取失败");
return null;
}
List<TeTenantDto> res = listR.getData();
TeTenantDto teTenantDto = res.get(0);
if (teTenantDto != null) {
Source source = SourceUtil.getSourceCache(teTenantDto.getStrategyId());
JSONObject countJson = staffService.queryStaffCount(teTenantDto.getId(), source.getMaster(), SecurityConstants.INNER);
RedisUtil.setVal("saas:staff:totalCountAndVisitor", countJson.toJSONString(), 60);
return countJson;
}


return outputSuccess().toJSON();
}
}

+ 12
- 0
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/controller/api/DmStaffInnerApiController.java View File

@@ -18,6 +18,7 @@ import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl;
import com.xueyi.system.resource.service.impl.FaceServiceImpl;
import com.xueyi.system.staff.mapper.DmStaffMapper;
import com.xueyi.system.staff.mapper.DmVisitorsMapper;
import com.xueyi.system.staff.service.impl.DmStaffServiceImpl;
import com.xueyi.system.utils.common.ImageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -58,6 +59,9 @@ public class DmStaffInnerApiController extends BaseApiController {
@Autowired
private DmStaffMapper staffMapper;

@Autowired
private DmStaffServiceImpl dmStaffService;

@InnerAuth
@GetMapping(value = "selectOne/{staffId}")
@ResponseBody
@@ -120,4 +124,12 @@ public class DmStaffInnerApiController extends BaseApiController {
return outputSuccess().toJSON();
}

@InnerAuth
@GetMapping(value = "broadcast-staff-count")
@ResponseBody
public JSONObject queryStaff(){
Long count = dmStaffService.selectStaffAndVisitorCount();
return outputSuccess(count).toJSON();
}

}

+ 7
- 3
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/mapper/DmStaffMapper.java View File

@@ -1,11 +1,11 @@
package com.xueyi.system.staff.mapper;

import com.xueyi.common.datasource.annotation.Isolate;
import com.xueyi.common.web.entity.mapper.BaseMapper;
import com.xueyi.system.api.staff.domain.dto.DmStaffDto;
import com.xueyi.system.api.staff.domain.po.DmStaffPo;
import com.xueyi.system.staff.domain.query.DmStaffQuery;
import com.xueyi.common.web.entity.mapper.BaseMapper;
import com.xueyi.common.datasource.annotation.Isolate;
import com.xueyi.system.api.staff.domain.vo.DmStaffFeature;
import com.xueyi.system.staff.domain.query.DmStaffQuery;
import org.apache.ibatis.annotations.Param;

import java.util.List;
@@ -21,4 +21,8 @@ public interface DmStaffMapper extends BaseMapper<DmStaffQuery, DmStaffDto, DmSt

public List<DmStaffFeature> selectStaffFeaturesList(@Param("devId")String devId,@Param("timestamp") String timestamp);
public List<DmStaffFeature> selectVisitorFeaturesList(@Param("devId")String devId,@Param("timestamp") String timestamp);

public Integer getStaffCount();

public Integer getVisitorCount();
}

+ 2
- 0
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/service/IDmStaffService.java View File

@@ -20,4 +20,6 @@ public interface IDmStaffService extends IBaseService<DmStaffQuery, DmStaffDto>
Long selectTenantId(DmStaffPo staff);

List<DmStaffFeature> selectStaffListByTimestamp(String devId,String tempstamp);

Long selectStaffAndVisitorCount();
}

+ 15
- 3
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/staff/service/impl/DmStaffServiceImpl.java View File

@@ -3,18 +3,18 @@ package com.xueyi.system.staff.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.xueyi.common.web.annotation.TenantIgnore;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.common.web.utils.DateUtils;
import com.xueyi.system.api.pass.domain.po.DmRecognizedRecordsPo;
import com.xueyi.system.api.staff.domain.dto.DmStaffDto;
import com.xueyi.system.api.staff.domain.po.DmStaffPo;
import com.xueyi.system.api.staff.domain.vo.DmStaffFeature;
import com.xueyi.system.staff.domain.po.DmEmpAttendancePo;
import com.xueyi.system.staff.mapper.DmEmpAttendanceMapper;
import com.xueyi.system.staff.domain.query.DmStaffQuery;
import com.xueyi.system.api.staff.domain.vo.DmStaffFeature;
import com.xueyi.system.staff.manager.IDmStaffManager;
import com.xueyi.system.staff.mapper.DmEmpAttendanceMapper;
import com.xueyi.system.staff.mapper.DmStaffMapper;
import com.xueyi.system.staff.service.IDmStaffService;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@@ -49,6 +49,8 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto
return baseManager.selectList(dmStaff);
}



@Override
@TenantIgnore(tenantLine = true)
public List<DmStaffPo> selectStaffList(DmStaffPo staff) {
@@ -76,6 +78,16 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto
return staffFeatures;
}

@Override
@TenantIgnore(tenantLine = true)
public Long selectStaffAndVisitorCount() {
Integer staffCount = staffMapper.getStaffCount();
Integer visitorCount = staffMapper.getStaffCount();
Integer totalCount = staffCount + visitorCount;

return totalCount.longValue();
}


public void updateOrInsertAttendance(DmRecognizedRecordsPo checkRecords) {
if (null == checkRecords.getUserId()) {


+ 8
- 0
xueyi-modules/xueyi-system/src/main/resources/mapper/staff/DmStaffMapper.xml View File

@@ -33,4 +33,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select s.id, s.name ,s.type as user_type, s.update_time,s.nickname as nick_name, s.del_flag, r.feature from dm_visitors s left join dm_resources as r on s.resource_id = r.id
where (UNIX_TIMESTAMP(s.update_time) * 1000 > #{timestamp} or UNIX_TIMESTAMP(s.create_time) * 1000 > #{timestamp} )and r.feature is not null
</select>
<select id="getStaffCount" resultType="java.lang.Integer">
select count(*) from dm_staff where del_flag = 0
</select>
<select id="getVisitorCount" resultType="java.lang.Integer">
select count(*) from dm_visitors where del_flag = 0
</select>
</mapper>

Loading…
Cancel
Save