| @@ -0,0 +1,15 @@ | |||
| package com.xueyi.nlt.api.nlt.feign; | |||
| import com.xueyi.common.core.constant.basic.ServiceConstants; | |||
| import com.xueyi.common.core.web.result.AjaxResult; | |||
| import com.xueyi.nlt.api.nlt.feign.factory.RemoteSensitiveFallbackFactory; | |||
| import org.springframework.cloud.openfeign.FeignClient; | |||
| @FeignClient(contextId = "remoteSensitiveService", value = ServiceConstants.NLT_SERVICE, fallbackFactory = RemoteSensitiveFallbackFactory.class) | |||
| public interface RemoteSensitiveService { | |||
| AjaxResult checkSensitive(String content); | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package com.xueyi.nlt.api.nlt.feign.factory; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteSensitiveService; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.springframework.cloud.openfeign.FallbackFactory; | |||
| import org.springframework.stereotype.Component; | |||
| @Slf4j | |||
| @Component | |||
| public class RemoteSensitiveFallbackFactory implements FallbackFactory<RemoteSensitiveService> { | |||
| @Override | |||
| public RemoteSensitiveService create(Throwable cause) { | |||
| return null; | |||
| } | |||
| } | |||
| @@ -1,4 +1,5 @@ | |||
| com.xueyi.nlt.api.nlt.feign.factory.RemoteIntentFallbackFactory | |||
| com.xueyi.nlt.api.nlt.feign.factory.RemoteQAFallbackFactory | |||
| com.xueyi.nlt.api.nlt.feign.factory.RemoteLandingLlmFallbackFactory | |||
| com.xueyi.nlt.api.nlt.feign.factory.RemoteSeniverseFallbackFactory | |||
| com.xueyi.nlt.api.nlt.feign.factory.RemoteSeniverseFallbackFactory | |||
| com.xueyi.nlt.api.nlt.feign.factory.RemoteSensitiveFallbackFactory | |||
| @@ -33,4 +33,7 @@ public interface RemoteLoginService { | |||
| @GetMapping("/login/inner/loginByPhone/{phone}") | |||
| R<LoginUser> getLoginInfoInnerByPhone(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/login/inner/loginByTenant/{tenantId}") | |||
| R<LoginUser> getLoginInfoInnerByTenant(@PathVariable("tenantId") Long tenantId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| } | |||
| @@ -29,6 +29,11 @@ public class RemoteLoginFallbackFactory implements FallbackFactory<RemoteLoginSe | |||
| public R<LoginUser> getLoginInfoInnerByPhone(String phone, String source) { | |||
| return R.fail("获取登录信息失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public R<LoginUser> getLoginInfoInnerByTenant(Long tenantId, String source) { | |||
| return R.fail("获取登录信息失败:" + throwable.getMessage()); | |||
| } | |||
| }; | |||
| } | |||
| } | |||
| @@ -27,8 +27,8 @@ public class DmRecognizedMultiRecordsDto { | |||
| private String sign; | |||
| public final static Integer TYPE_STAFF = 1; | |||
| public final static Integer TYPE_STRANGER = 2; | |||
| public static final Integer TYPE_STAFF = 1; | |||
| public static final Integer TYPE_STRANGER = 2; | |||
| @Override | |||
| public String toString(){ | |||
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.constant.basic.ServiceConstants; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.TeTenantPo; | |||
| @@ -41,6 +42,12 @@ public interface RemoteTenantService { | |||
| @GetMapping("/tenant/one") | |||
| R<TeTenantPo> tenant(@RequestParam ("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/tenant/query-tenant-by-id") | |||
| R<TeTenantPo> selectById(@RequestParam ("tenantId") Long tenantId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/tenant/query-tenant-source") | |||
| DeviceTenantSourceMergeVo selectTenantSourceMerge(@RequestParam ("deviceId") String deviceId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/tenant/query-tenant-by-staff-phone") | |||
| R<TeTenantPo> queryTenantByStaffPhone(@RequestParam ("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @@ -2,6 +2,7 @@ package com.xueyi.tenant.api.tenant.feign.factory; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.TeTenantPo; | |||
| @@ -43,6 +44,16 @@ public class RemoteTenantFallbackFactory implements FallbackFactory<RemoteTenant | |||
| return R.fail("获取租户失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public R<TeTenantPo> selectById(Long tenantId, String source) { | |||
| return R.fail("获取租户失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public DeviceTenantSourceMergeVo selectTenantSourceMerge(String deviceId, String source) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public R<TeTenantPo> queryTenantByStaffPhone(String phone, String source) { | |||
| return null; | |||
| @@ -1,5 +1,6 @@ | |||
| package com.xueyi.auth.controller; | |||
| import com.alibaba.csp.sentinel.util.StringUtil; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.auth.form.LoginBody; | |||
| @@ -13,6 +14,7 @@ import com.xueyi.common.core.utils.core.ObjectUtil; | |||
| import com.xueyi.common.core.utils.core.StrUtil; | |||
| import com.xueyi.common.core.web.result.AjaxResult; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.common.redis.service.RedisService; | |||
| import com.xueyi.common.security.auth.AuthUtil; | |||
| import com.xueyi.common.security.service.TokenService; | |||
| @@ -99,6 +101,29 @@ public class TokenController { | |||
| return AjaxResult.success(map); | |||
| } | |||
| @PostMapping("deviceLogin") | |||
| public AjaxResult loginByDevice(@RequestBody Map<String, String> params) { | |||
| String deviceId = params.get("deviceId"); | |||
| if (StringUtil.isNotBlank(deviceId)) { | |||
| DeviceTenantSourceMergeVo vo = tenantService.selectTenantSourceMerge(deviceId, SecurityConstants.INNER);// 查询设备与租户、来源的关联关系 | |||
| if (null == vo || null == vo.getTenantId()) { | |||
| return AjaxResult.error("设备不正确,清查验"); | |||
| } | |||
| LoginUser userInfo = sysLoginService.loginByTenant(vo.getTenantId()); | |||
| if (null == userInfo) { | |||
| return AjaxResult.error("手机号不正确,清查验"); | |||
| } | |||
| // 获取登录token | |||
| Map<String, Object> map = tokenService.createToken(userInfo); | |||
| map.put("deviceId", deviceId);//塞入对应staffId | |||
| return AjaxResult.success(map); | |||
| } | |||
| return AjaxResult.error("设备号不正确,清查验"); | |||
| } | |||
| @DeleteMapping("logout") | |||
| public AjaxResult logout(HttpServletRequest request) { | |||
| String token = SecurityUtils.getToken(request); | |||
| @@ -170,16 +170,28 @@ public class SysLoginService { | |||
| remoteLogService.saveLoginInfo(loginInfo, enterpriseId, sourceName, SecurityConstants.INNER); | |||
| } | |||
| public LoginUser loginByPhone(String phone) { | |||
| logger.info("phone:{}", phone); | |||
| R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByPhone(phone, SecurityConstants.INNER); | |||
| if (ObjectUtil.isNull(loginInfoResult.getData())) { | |||
| AjaxResult.warn("手机号可能输错,请查证后重试!"); | |||
| } | |||
| return loginInfoResult.getData(); | |||
| } | |||
| public LoginUser loginByTenant(Long tenantId) { | |||
| logger.info("tenantId:{}", tenantId); | |||
| R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByTenant(tenantId, SecurityConstants.INNER); | |||
| if (ObjectUtil.isNull(loginInfoResult.getData())) { | |||
| AjaxResult.warn("租户号错误,请查证后重试!"); | |||
| } | |||
| return loginInfoResult.getData(); | |||
| } | |||
| } | |||
| @@ -9,6 +9,8 @@ import com.xueyi.common.core.utils.core.ObjectUtil; | |||
| import com.xueyi.common.core.utils.core.StrUtil; | |||
| import com.xueyi.common.security.auth.AuthUtil; | |||
| import com.xueyi.common.security.utils.SecurityUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.web.method.HandlerMethod; | |||
| import org.springframework.web.servlet.AsyncHandlerInterceptor; | |||
| @@ -22,6 +24,7 @@ import javax.servlet.http.HttpServletResponse; | |||
| * @author xueyi | |||
| */ | |||
| public class HeaderInterceptor implements AsyncHandlerInterceptor { | |||
| private Logger logger = LoggerFactory.getLogger(HeaderInterceptor.class); | |||
| @Override | |||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
| @@ -42,12 +45,14 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor { | |||
| String token = SecurityUtils.getToken(); | |||
| System.err.println(SecurityUtils.getAccountType()); | |||
| if (StrUtil.isNotEmpty(token)) { | |||
| SecurityContextHolder.setEnterpriseId(JwtUtil.getEnterpriseId(token)); | |||
| SecurityContextHolder.setSourceName(JwtUtil.getSourceName(token)); | |||
| SecurityContextHolder.setAccountType(JwtUtil.getAccountType(token)); | |||
| SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER); | |||
| logger.info("IsLessor:{}",JwtUtil.getIsLessor(token)); | |||
| if (!(("Y").equals(JwtUtil.getIsLessor(token))|| JwtUtil.getIsLessor(token).equals("1"))) {//如果是超管租户,则不执行以下 | |||
| SecurityContextHolder.setEnterpriseId(JwtUtil.getEnterpriseId(token)); | |||
| SecurityContextHolder.setSourceName(JwtUtil.getSourceName(token)); | |||
| SecurityContextHolder.setAccountType(JwtUtil.getAccountType(token)); | |||
| SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER); | |||
| } | |||
| TenantConstants.AccountType accountType = TenantConstants.AccountType.getByCode(SecurityUtils.getAccountType()); | |||
| if(ObjectUtil.isNotNull(accountType)) { | |||
| @@ -21,10 +21,10 @@ public class WebApiMvcConfig implements WebMvcConfigurer { | |||
| @Override | |||
| public void addInterceptors(InterceptorRegistry registry) { | |||
| System.err.println("WebMvcConfig.addInterceptors======================hshshkbb"); | |||
| System.err.println("===graphql======================addInterceptors==="); | |||
| registry.addInterceptor(getApiInterceptor()) | |||
| .addPathPatterns("/**/graphql/**") | |||
| .addPathPatterns("/**/api/**") | |||
| // .addPathPatterns("/**") | |||
| .excludePathPatterns(excludeUrls) | |||
| .order(1); | |||
| @@ -1,6 +1,6 @@ | |||
| package com.xueyi.common.web.entity.domain.provider; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.Map; | |||
| /** | |||
| * @author yk | |||
| @@ -8,7 +8,8 @@ import org.apache.ibatis.annotations.Param; | |||
| * @date 2023-11-25 11:15 | |||
| */ | |||
| public class DeviceTenantSqlProvider { | |||
| public String selectDeviceTenant(@Param("deviceId") String deviceId) { | |||
| return "SELECT ddtm.dev_id, ddtm.tenant_id, s.source_slave FROM dm_device_tenant_merge ddtm JOIN te_tenant t ON t.id=ddtm.tenant_id JOIN te_strategy s ON s.id=t.strategy_id AND dev_id= #{deviceId}"; | |||
| public String selectDeviceTenant(Map<String, Object> param) { | |||
| String deviceId = (String) param.get("deviceId"); | |||
| return "SELECT ddtm.dev_id, ddtm.tenant_id, s.source_slave FROM dm_device_tenant_merge ddtm JOIN te_tenant t ON t.id=ddtm.tenant_id JOIN te_strategy s ON s.id=t.strategy_id AND dev_id= '"+deviceId+"'"; | |||
| } | |||
| } | |||
| @@ -0,0 +1,40 @@ | |||
| package com.xueyi.nlt.nlt.config; | |||
| import lombok.Data; | |||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||
| import org.springframework.context.annotation.Configuration; | |||
| @Data | |||
| @Configuration | |||
| @ConfigurationProperties(prefix = "secret.spark") | |||
| public class XunFeiSensitiveConfig { | |||
| private String appId; | |||
| private String apiKey; | |||
| private String apiSecret; | |||
| private String sensitiveUrl; | |||
| private String sensitiveCheckUrl; | |||
| public static final String BLACK_LIB_NAME = "digimeta-black-lib"; | |||
| public static final String WHITE_LIB_NAME = "digimeta-white-lib"; | |||
| public static final String BLACK_LIB_ID = "2ee58a3c2d68411194d620bf846056af"; | |||
| public static final String WHITE_LIB_ID = "3d6f1dbc6cad4843a7d8fa502d16eb29"; | |||
| // 敏感词库 | |||
| /** | |||
| * pornDetection 色情 | |||
| * violentTerrorism 暴恐 | |||
| * political 涉政 | |||
| * lowQualityIrrigation 低质量灌水 | |||
| * contraband 违禁 | |||
| * advertisement 广告 | |||
| * uncivilizedLanguage 不文明用语 | |||
| **/ | |||
| public static final String SENSITIVE_TYPES_PORN_DETECTION = "pornDetection"; | |||
| public static final String SENSITIVE_TYPES_VIOLENT_TERRORISM = "violentTerrorism"; | |||
| public static final String SENSITIVE_TYPES_POLITICAL = "political"; | |||
| public static final String SENSITIVE_TYPES_LOW_QUALITY_IRRIGATION = "lowQualityIrrigation"; | |||
| public static final String SENSITIVE_TYPES_CONTRABAND = "contraband"; | |||
| public static final String SENSITIVE_TYPES_ADVERTISEMENT = "advertisement"; | |||
| public static final String SENSITIVE_TYPES_UNCIVILIZED_LANGUAGE = "uncivilizedLanguage"; | |||
| } | |||
| @@ -1,6 +1,8 @@ | |||
| package com.xueyi.nlt.nlt.controller; | |||
| import co.elastic.clients.elasticsearch.ElasticsearchClient; | |||
| import com.alibaba.druid.support.json.JSONUtils; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson2.JSONArray; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| @@ -33,6 +35,7 @@ import com.xueyi.nlt.api.nlt.feign.RemoteIntentService; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteLandingLlmService; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteQAService; | |||
| import com.xueyi.nlt.netty.client.WebSocketClientManager; | |||
| import com.xueyi.nlt.nlt.config.XunFeiSensitiveConfig; | |||
| import com.xueyi.nlt.nlt.context.TerminalSecurityContextHolder; | |||
| import com.xueyi.nlt.nlt.domain.LlmContext; | |||
| import com.xueyi.nlt.nlt.domain.LlmParam; | |||
| @@ -44,7 +47,9 @@ import com.xueyi.nlt.nlt.domain.vo.IntentTemplateVo; | |||
| import com.xueyi.nlt.nlt.domain.vo.MarkRecordVo; | |||
| import com.xueyi.nlt.nlt.mapper.DmRegularMapper; | |||
| import com.xueyi.nlt.nlt.service.IDmIntentService; | |||
| import com.xueyi.nlt.nlt.service.ISensitiveService; | |||
| import com.xueyi.nlt.nlt.service.ISysLlmService; | |||
| import com.xueyi.nlt.nlt.service.impl.XunFeiSensitiveSeviceImpl; | |||
| import com.xueyi.nlt.nlt.template.*; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmSkillDto; | |||
| @@ -69,6 +74,7 @@ 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.RequestParam; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import java.io.Serializable; | |||
| @@ -890,6 +896,53 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| return response; | |||
| } | |||
| @Autowired | |||
| private XunFeiSensitiveConfig xunFeiSensitiveConfig; | |||
| @Autowired | |||
| private ISensitiveService sensitiveService; | |||
| @GetMapping("/api/create-sensitive-lib") | |||
| public AjaxResult addSensitiveBlack(@RequestParam("name") String name, @RequestParam(value = "category" ,required = false) String category, @RequestParam("type") String type){ | |||
| try { | |||
| String res = ""; | |||
| if ("black".equals(type)) { | |||
| res = sensitiveService.createBlack(name, category); | |||
| } else { | |||
| res = sensitiveService.createWhite(name); | |||
| } | |||
| return AjaxResult.success(res); | |||
| } catch (Exception e) { | |||
| return AjaxResult.error(e.getMessage()); | |||
| } | |||
| } | |||
| @GetMapping("/api/add-sensitive-word") | |||
| public AjaxResult addSensitiveWord(@RequestParam("content") String content, @RequestParam("type") String type){ | |||
| try { | |||
| String res = ""; | |||
| if ("black".equals(type)) { | |||
| res = sensitiveService.addKeyWord(xunFeiSensitiveConfig.BLACK_LIB_ID, new String[]{content}); | |||
| } else { | |||
| res = sensitiveService.addKeyWord(xunFeiSensitiveConfig.WHITE_LIB_ID, new String[]{content}); | |||
| } | |||
| return AjaxResult.success(JSON.parse(res)); | |||
| } catch (Exception e) { | |||
| return AjaxResult.error(e.getMessage()); | |||
| } | |||
| } | |||
| @GetMapping("/api/check-sensitive-word") | |||
| public AjaxResult addSensitiveWhite(@RequestParam("content") String content, @RequestParam(value = "useLib", required = false) Integer useLib){ | |||
| String res = sensitiveService.checkSensitiveWord(content, useLib); | |||
| logger.info("check-sensitive-word ,content:{}, res:{}",content, res); | |||
| if (res.contains("suggest")){ | |||
| return AjaxResult.success(JSONObject.parse(res).getObject("data", JSONObject.class)); | |||
| } | |||
| return AjaxResult.error(res); | |||
| } | |||
| interface Auth { | |||
| /** 系统 - 意图管理 | |||
| @@ -0,0 +1,18 @@ | |||
| package com.xueyi.nlt.nlt.service; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-15 17:38 | |||
| */ | |||
| public interface ISensitiveService { | |||
| public String createWhite(String name) throws Exception ; | |||
| public String createBlack(String name, String category) throws Exception ; | |||
| public String checkSensitiveWord(String content, Integer useLib) ; | |||
| public String addKeyWord(String libId, String[] contents) throws Exception ; | |||
| } | |||
| @@ -0,0 +1,290 @@ | |||
| package com.xueyi.nlt.nlt.service.impl; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.nlt.nlt.config.XunFeiSensitiveConfig; | |||
| import com.xueyi.nlt.nlt.service.ISensitiveService; | |||
| import org.apache.http.client.methods.CloseableHttpResponse; | |||
| import org.apache.http.client.methods.HttpUriRequest; | |||
| import org.apache.http.client.methods.RequestBuilder; | |||
| import org.apache.http.entity.ContentType; | |||
| import org.apache.http.entity.StringEntity; | |||
| import org.apache.http.impl.client.CloseableHttpClient; | |||
| import org.apache.http.impl.client.HttpClients; | |||
| import org.apache.http.util.EntityUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Primary; | |||
| import org.springframework.stereotype.Service; | |||
| import javax.annotation.PostConstruct; | |||
| import javax.crypto.Mac; | |||
| import javax.crypto.spec.SecretKeySpec; | |||
| import java.io.IOException; | |||
| import java.net.URI; | |||
| import java.net.URLEncoder; | |||
| import java.nio.charset.StandardCharsets; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Base64; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Locale; | |||
| import java.util.Map; | |||
| import java.util.TimeZone; | |||
| import java.util.TreeMap; | |||
| import java.util.UUID; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-15 15:53 | |||
| */ | |||
| @Service | |||
| @Primary | |||
| public class XunFeiSensitiveSeviceImpl implements ISensitiveService { | |||
| Logger logger = LoggerFactory.getLogger(XunFeiSensitiveSeviceImpl.class); | |||
| private String appid; | |||
| private String APIKey; | |||
| private String APISecret; | |||
| @Autowired | |||
| private XunFeiSensitiveConfig sensitiveConfig; | |||
| @PostConstruct | |||
| public void init() { | |||
| this.appid = sensitiveConfig.getAppId(); | |||
| this.APIKey = sensitiveConfig.getApiKey(); | |||
| this.APISecret = sensitiveConfig.getApiSecret(); | |||
| } | |||
| /** | |||
| * 1.拼接鉴权 | |||
| */ | |||
| public Map<String, String> getAuth() throws Exception { | |||
| // 1.获取时间 | |||
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US); | |||
| format.setTimeZone(TimeZone.getTimeZone("GMT")); | |||
| String utc = format.format(new Date()); // 如果用postman验证,需要对utc进行urlEncode,然后发起请求 | |||
| // 2.控制台关键信息 | |||
| Map<String, String> urlParams = new HashMap<>(); | |||
| urlParams.put("appId", appid); | |||
| urlParams.put("accessKeyId", APIKey); | |||
| urlParams.put("utc", utc); | |||
| urlParams.put("uuid", UUID.randomUUID().toString()); // uuid有防重放的功能,如果调试,请注意更换uuid的值 | |||
| // 3.获取signature | |||
| String signature = this.signature(APISecret, urlParams); | |||
| urlParams.put("signature", signature); | |||
| return urlParams; | |||
| } | |||
| /** | |||
| * 2.获取鉴权 | |||
| */ | |||
| public String signature(String secret, Map<String, String> queryParam) throws Exception { | |||
| //排序 | |||
| TreeMap<String, String> treeMap = new TreeMap<>(queryParam); | |||
| //剔除不参与签名运算的 signature | |||
| treeMap.remove("signature"); | |||
| //生成 baseString | |||
| StringBuilder builder = new StringBuilder(); | |||
| for (Map.Entry<String, String> entry : treeMap.entrySet()) { | |||
| String value = entry.getValue(); | |||
| //参数值为空的不参与签名, | |||
| if (value != null && !value.isEmpty()) { | |||
| //参数值需要 URLEncode | |||
| String encode = URLEncoder.encode(value, StandardCharsets.UTF_8.name()); | |||
| builder.append(entry.getKey()).append("=").append(encode).append("&"); | |||
| } | |||
| } | |||
| //删除最后位的&符号 | |||
| if (builder.length() > 0) { | |||
| builder.deleteCharAt(builder.length() - 1); | |||
| } | |||
| String baseString = builder.toString(); | |||
| Mac mac = Mac.getInstance("HmacSHA1"); | |||
| SecretKeySpec keySpec = new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8.name()); | |||
| mac.init(keySpec); | |||
| //得到签名 byte[] | |||
| byte[] signBytes = mac.doFinal(baseString.getBytes(StandardCharsets.UTF_8)); | |||
| //将 byte[]base64 编码 | |||
| return Base64.getEncoder().encodeToString(signBytes); | |||
| } | |||
| /** | |||
| * 3.发起post请求 | |||
| */ | |||
| public String doPostJson(String url, Map<String, String> urlParams, String json) { | |||
| String resultString = ""; | |||
| try(CloseableHttpClient closeableHttpClient = HttpClients.createDefault()) { | |||
| CloseableHttpResponse closeableHttpResponse = null; | |||
| // 创建Http Post请求 | |||
| String asciiUrl = URI.create(url).toASCIIString(); | |||
| RequestBuilder builder = RequestBuilder.post(asciiUrl); | |||
| builder.setCharset(StandardCharsets.UTF_8); | |||
| if (urlParams != null) { | |||
| for (Map.Entry<String, String> entry : urlParams.entrySet()) { | |||
| builder.addParameter(entry.getKey(), entry.getValue()); | |||
| } | |||
| } | |||
| // 创建请求内容 | |||
| StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); | |||
| builder.setEntity(entity); | |||
| HttpUriRequest request = builder.build(); | |||
| // 执行http请求 | |||
| closeableHttpResponse = closeableHttpClient.execute(request); | |||
| resultString = EntityUtils.toString(closeableHttpResponse.getEntity(), StandardCharsets.UTF_8); | |||
| } catch (IOException e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| return resultString; | |||
| } | |||
| /** | |||
| * 4.黑白名单具体操作方法 | |||
| */ | |||
| public String deleteKeyWord(String libId, String[] wordList) throws Exception { | |||
| JSONObject jsonBody = new JSONObject(); | |||
| jsonBody.put("lib_id", libId); | |||
| jsonBody.put("word_list", wordList); | |||
| String json = JSONArray.toJSON(jsonBody).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/delWord", urlParams, json); | |||
| logger.info("删除关键词返回的结果:{}", returnResult); | |||
| return returnResult; | |||
| } | |||
| @Override | |||
| public String addKeyWord(String libId, String[] wordList) throws Exception { | |||
| JSONObject jsonBody = new JSONObject(); | |||
| jsonBody.put("lib_id", libId); | |||
| jsonBody.put("word_list", wordList); | |||
| String json = JSONArray.toJSON(jsonBody).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/addWord", urlParams, json); | |||
| logger.info("添加关键词返回的结果:{}" ,returnResult); | |||
| return returnResult; | |||
| } | |||
| public void deleteLibrary(String libId) throws Exception { | |||
| Map<String, String> bodyMap = new HashMap<>(); | |||
| bodyMap.put("lib_id", libId); | |||
| String json = JSONArray.toJSON(bodyMap).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/delete", urlParams, json); | |||
| logger.info("删除词库返回的结果:{}" , returnResult); | |||
| } | |||
| public String selectLibrary(String libId) throws Exception { | |||
| Map<String, String> bodyMap = new HashMap<>(); | |||
| bodyMap.put("lib_id", libId); | |||
| String json = JSONArray.toJSON(bodyMap).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/info", urlParams, json); | |||
| logger.info("查询词库返回的结果:{}" , returnResult); | |||
| return returnResult; | |||
| } | |||
| public String selectLibraryDetail(String libId) throws Exception { | |||
| Map<String, Object> bodyMap = new HashMap<>(); | |||
| bodyMap.put("lib_id", libId); | |||
| bodyMap.put("return_word", true); | |||
| String json = JSONArray.toJSON(bodyMap).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/info", urlParams, json); | |||
| logger.info("查询词库关键词返回的结果:{}" , returnResult); | |||
| return returnResult; | |||
| } | |||
| @Override | |||
| public String createWhite(String name) throws Exception { | |||
| Map<String, String> bodyMap = new HashMap<>(); | |||
| bodyMap.put("name", name); | |||
| String json = JSONArray.toJSON(bodyMap).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/createWhite", urlParams, json); | |||
| logger.info("创建白名单返回的结果:{}" , returnResult); | |||
| return returnResult; | |||
| } | |||
| @Override | |||
| public String createBlack(String name, String category) throws Exception { | |||
| Map<String, String> bodyMap = new HashMap<>(); | |||
| bodyMap.put("name", name); | |||
| bodyMap.put("suggestion", "block"); | |||
| bodyMap.put("category", category); | |||
| String json = JSONArray.toJSON(bodyMap).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/createBlack", urlParams, json); | |||
| logger.info("创建黑名单返回的结果:{}" , returnResult); | |||
| return returnResult; | |||
| } | |||
| @Override | |||
| public String checkSensitiveWord(String content, Integer useLib) { | |||
| String json = "{\n" + | |||
| " \"is_match_all\": 1,\n" + | |||
| " \"content\": \"" + content + "\"\n" + | |||
| "}"; | |||
| if (1 == useLib) {//用自定义库 | |||
| json = "{\n" + | |||
| " \"is_match_all\": 1,\n" + | |||
| " \"content\": \"" + content + "\",\n" + | |||
| " \"lib_ids\": [\n" + | |||
| " \"" + XunFeiSensitiveConfig.BLACK_LIB_ID + "\",\n" + | |||
| " \"" + XunFeiSensitiveConfig.WHITE_LIB_ID + "\"\n" + | |||
| " ],\n" + | |||
| " \"categories\": [\n" + | |||
| " \"pornDetection\",\n" + | |||
| " \"violentTerrorism\",\n" + | |||
| " \"political\",\n" + | |||
| " \"lowQualityIrrigation\",\n" + | |||
| " \"contraband\",\n" + | |||
| " \"advertisement\",\n" + | |||
| " \"uncivilizedLanguage\"\n" + | |||
| " ]\n" + | |||
| "}"; | |||
| } | |||
| // 获取鉴权 | |||
| Map<String, String> urlParams = null; | |||
| try { | |||
| urlParams = this.getAuth(); | |||
| return this.doPostJson(sensitiveConfig.getSensitiveCheckUrl(), urlParams, json); | |||
| } catch (Exception e) { | |||
| return e.getMessage(); | |||
| } | |||
| } | |||
| public void selectLibraryList() throws Exception { | |||
| Map<String, String> bodyMap = new HashMap<>(); | |||
| String json = JSONArray.toJSON(bodyMap).toString(); | |||
| // 鉴权 | |||
| Map<String, String> urlParams = this.getAuth(); | |||
| // 发起请求 | |||
| String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/list", urlParams, json); | |||
| logger.info("查询词库列表返回的结果:{}" , returnResult); | |||
| } | |||
| } | |||
| @@ -103,18 +103,8 @@ public class SysLoginController extends BasisController { | |||
| @Autowired | |||
| RemoteTenantService tenantService; | |||
| /** | |||
| * 获取登录信息 | 内部调用, 手机号登录 | |||
| */ | |||
| @InnerAuth | |||
| @GetMapping("/inner/loginByPhone/{phone}") | |||
| public R<LoginUser> getLoginInfoByMobile(@PathVariable("phone") String phone) { | |||
| log.info("获取登录信息 | 内部调用, 手机号登录 | phone: {}", phone); | |||
| R<TeTenantPo> po = tenantService.tenant(phone, SecurityConstants.INNER); | |||
| log.info("获取登录信息 | 内部调用, 手机号登录 | po:{}, {}, {}", po.getMsg(),po.getCode(),po.isFail()); | |||
| if (po.getData() == null) | |||
| return R.fail("指定手机号不存在记录"); | |||
| SysEnterpriseDto enterprise = loginService.loginByEnterpriseName(po.getData().getName()); | |||
| public R<LoginUser> getLoginInfo(String enterpriseName) { | |||
| SysEnterpriseDto enterprise = loginService.loginByEnterpriseName(enterpriseName); | |||
| // 不存在直接返回空数据 | 与网络调用错误区分 | |||
| if (ObjectUtil.isNull(enterprise)) | |||
| return R.ok(null, "企业账号不存在"); | |||
| @@ -133,7 +123,7 @@ public class SysLoginController extends BasisController { | |||
| loginUser.setIsLessor(enterprise.getIsLessor()); | |||
| loginUser.setSource(source); | |||
| loginUser.setSourceName(source.getMaster()); | |||
| SysUserDto user = loginService.loginByStaff(phone); | |||
| SysUserDto user = loginService.loginByTenantId(enterprise.getId()); | |||
| if (ObjectUtil.isNull(user)) | |||
| return R.ok(null, "用户账号不存在"); | |||
| @@ -165,4 +155,28 @@ public class SysLoginController extends BasisController { | |||
| loginUser.setRouteURL(routeMap); | |||
| return R.ok(loginUser); | |||
| } | |||
| /** | |||
| * 获取登录信息 | 内部调用, 手机号登录 | |||
| */ | |||
| @InnerAuth | |||
| @GetMapping("/inner/loginByPhone/{phone}") | |||
| public R<LoginUser> getLoginInfoByMobile(@PathVariable("phone") String phone) { | |||
| log.info("获取登录信息 | 内部调用, 手机号登录 | phone: {}", phone); | |||
| R<TeTenantPo> po = tenantService.tenant(phone, SecurityConstants.INNER); | |||
| log.info("获取登录信息 | 内部调用, 手机号登录 | po:{}, {}, {}", po.getMsg(),po.getCode(),po.isFail()); | |||
| if (po.getData() == null) | |||
| return R.fail("指定手机号不存在记录"); | |||
| return this.getLoginInfo(po.getData().getName()); | |||
| } | |||
| @GetMapping("/inner/loginByTenant/{tenantId}") | |||
| public R<LoginUser> getLoginInfoByTenant(@PathVariable("tenantId") Long tenantId) { | |||
| R<TeTenantPo> po = tenantService.selectById(tenantId, SecurityConstants.INNER); | |||
| log.info("获取登录信息 | 内部调用, 租户号登录 | po:{}, {}, {}", po.getMsg(),po.getCode(),po.isFail()); | |||
| if (po.getData() == null) | |||
| return R.fail("指定租户号不存在记录"); | |||
| return this.getLoginInfo(po.getData().getName()); | |||
| } | |||
| } | |||
| @@ -70,4 +70,6 @@ public interface ISysLoginService { | |||
| Map<String, String> getMenuRouteMap(Set<Long> roleIds, String userType); | |||
| SysUserDto loginByStaff(String phone); | |||
| SysUserDto loginByTenantId(Long tenantId); | |||
| } | |||
| @@ -247,8 +247,13 @@ public class SysLoginServiceImpl implements ISysLoginService { | |||
| if (po == null) { | |||
| return null; | |||
| } | |||
| SqlField field = new SqlField(SqlConstants.OperateType.EQ, "tenant_id", po.getTenantId()); | |||
| SysUserDto dto = sysUserConverter.mapperDto(userMapper.selectByField(field)) ; | |||
| return dto; | |||
| return loginByTenantId(po.getTenantId()); | |||
| } | |||
| @Override | |||
| public SysUserDto loginByTenantId(Long tenantId) { | |||
| SqlField field = new SqlField(SqlConstants.OperateType.EQ, "tenant_id", tenantId); | |||
| return sysUserConverter.mapperDto(userMapper.selectByField(field)) ; | |||
| } | |||
| } | |||
| @@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit; | |||
| @RestController | |||
| @RequestMapping("/meeting/orders") | |||
| public class DmMeetingOrdersController extends BaseController<DmMeetingOrdersQuery, DmMeetingOrdersDto, IDmMeetingOrdersService> { | |||
| private static final Logger logger = LoggerFactory.getLogger(DmMeetingOrdersController.class); | |||
| private static final Logger log = LoggerFactory.getLogger(DmMeetingOrdersController.class); | |||
| private static final String REDIS_KEY = "meeting:orders:"; | |||
| @Autowired | |||
| @@ -126,15 +126,15 @@ public class DmMeetingOrdersController extends BaseController<DmMeetingOrdersQue | |||
| MyResponse myResponse = new MyResponse(0,""); | |||
| List<DmMeetingOrdersDto> res = new ArrayList<>(); | |||
| if (RedisUtil.existed(REDIS_KEY+dateStr+":"+spaceId)) { | |||
| logger.info("===lists meeting orders from redis==="); | |||
| Object obj = redisService.getCacheObject(REDIS_KEY+dateStr+":"+spaceId); | |||
| if (!(obj instanceof String)) { | |||
| log.info("===lists meeting orders from redis==="); | |||
| res = redisService.getCacheList(REDIS_KEY+dateStr+":"+spaceId); | |||
| } else { | |||
| logger.info("===empty meeting orders from redis==="); | |||
| log.info("===empty meeting orders from redis==="); | |||
| } | |||
| } else { | |||
| logger.info("===lists meeting orders from db==="); | |||
| log.info("===lists meeting orders from db==="); | |||
| List<DmMeetingOrdersPo> list = dmMeetingOrdersMapper.findListByDate(dateStr, spaceId); | |||
| res = list.stream().map(t->{ | |||
| DmMeetingOrdersDto dto = dmMeetingOrdersConverter.mapperDto(t); | |||
| @@ -73,6 +73,13 @@ import java.util.stream.Collectors; | |||
| @RequestMapping("/meeting/inner-api") | |||
| public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| private static final String START_TIME_KEY = "startTime"; | |||
| private static final String ORDER_DATE_KEY = "orderDate"; | |||
| private static final String END_TIME_KEY = "endTime"; | |||
| private static final String ROBOT_NAME_KEY = "robotName"; | |||
| private static final String ROOM_ID_KEY = "roomId"; | |||
| private static final String ERR_MSG = "日期格式不正确"; | |||
| private static final Logger log = LoggerFactory.getLogger(DmMeetingInnerApiController.class); | |||
| @Autowired | |||
| private DmMeetingRoomsMapper dmMeetingRoomsMapper; | |||
| @@ -200,13 +207,12 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| JSONObject jsonObject = new JSONObject(); | |||
| jsonObject.put("dateStr", mms2); | |||
| jsonObject.put("name", dmStaffPo.getUserName()); | |||
| //TODO. 发送短信 后期需要获取数字人昵称 | |||
| DmDigitalmanPo dmDigitalmanPo = digitalmanMapper.selectByCode(digitalmanExtMapper.selectOne(Wrappers.<DmDigitalmanExtPo>query().lambda().eq(DmDigitalmanExtPo::getDeviceId, order.getDevId()).last(SqlConstants.LIMIT_ONE)).getManCode()); | |||
| if (null!= dmDigitalmanPo && StringUtils.isNotEmpty(dmDigitalmanPo.getName())) { | |||
| jsonObject.put("robotName", dmDigitalmanPo.getName()); | |||
| jsonObject.put(ROBOT_NAME_KEY, dmDigitalmanPo.getName()); | |||
| } else { | |||
| jsonObject.put("robotName", smsProperties.getRobotName()); | |||
| jsonObject.put(ROBOT_NAME_KEY, smsProperties.getRobotName()); | |||
| } | |||
| send.setDataMap(jsonObject.toJSONString()); | |||
| @@ -214,7 +220,7 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| } | |||
| } catch (Exception e) { | |||
| System.err.println(e.getMessage()); | |||
| log.info(e.getMessage()); | |||
| e.printStackTrace(); | |||
| } | |||
| // 埋点 预定会议室 | |||
| @@ -245,7 +251,7 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| @InnerAuth | |||
| @GetMapping(value = "/enableOrder/{roomId}/{dateStr}/{startTime}") | |||
| public JSONObject queryExist(@PathVariable(name = "roomId") Long roomId, @PathVariable(name = "dateStr") String dateStr, @PathVariable(name = "startTime") String startTime) { | |||
| public JSONObject queryExist(@PathVariable(name = ROOM_ID_KEY) Long roomId, @PathVariable(name = "dateStr") String dateStr, @PathVariable(name = START_TIME_KEY) String startTime) { | |||
| log.info("dateStr:{}", dateStr); | |||
| log.info("startTime:{}", startTime); | |||
| DmMeetingRoomsPo room = dmMeetingRoomsMapper.findById(roomId); | |||
| @@ -258,12 +264,13 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| if (StringUtils.isEmpty(startTime)) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| String sTime = startTime,eTime = ""; | |||
| String sTime = startTime; | |||
| String eTime = ""; | |||
| Date end = MyDateUtils.addMinutes(MyDateUtils.parseStrToDate(dateStr + " " + startTime, MyDateUtils.DEFAULT_NO_SECOND_DATE_PATTERN), 30); | |||
| eTime = MyDateUtils.formatDate(end, MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| List<DmMeetingOrdersPo> lists = dmMeetingOrdersMapper.queryByOrder(roomId, dateStr, sTime, eTime); | |||
| if (lists.size() > 0) { | |||
| if (!lists.isEmpty()) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| return outputSuccess().toJSON(); | |||
| @@ -271,7 +278,7 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| @InnerAuth | |||
| @GetMapping(value = "/enableOrder/{roomId}/{dateStr}/{startTime}/{duration}") | |||
| public JSONObject queryExistOrder(@PathVariable(name = "roomId") Long roomId, @PathVariable(name = "dateStr") String dateStr, @PathVariable(name = "startTime") String startTime, @PathVariable(name = "duration") Integer duration) { | |||
| public JSONObject queryExistOrder(@PathVariable(name = ROOM_ID_KEY) Long roomId, @PathVariable(name = "dateStr") String dateStr, @PathVariable(name = START_TIME_KEY) String startTime, @PathVariable(name = "duration") Integer duration) { | |||
| log.info("startTime:{}", startTime); | |||
| DmMeetingRoomsPo room = dmMeetingRoomsMapper.findById(roomId); | |||
| if (null == room) { | |||
| @@ -283,14 +290,15 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| if (StringUtils.isEmpty(startTime)) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| String sTime = startTime,eTime = ""; | |||
| String sTime = startTime; | |||
| String eTime = ""; | |||
| Date end = MyDateUtils.parseStrToDate(dateStr + " " + startTime, MyDateUtils.DEFAULT_NO_SECOND_DATE_PATTERN); | |||
| end = MyDateUtils.addMinutes(end, duration); | |||
| eTime = MyDateUtils.formatDate(end, MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| log.info("roomId:{} dateStr:{} startTime:{} endTime:{} duration:{}", roomId, dateStr, sTime, eTime, duration); | |||
| List<DmMeetingOrdersPo> lists = dmMeetingOrdersMapper.queryByOrder(roomId, dateStr, sTime, eTime); | |||
| if (lists.size() > 0) { | |||
| if (!lists.isEmpty()) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| return outputSuccess().toJSON(); | |||
| @@ -310,7 +318,6 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| DmMeetingRoomsPo meetingRoom = dmMeetingRoomsMapper.findById(mro.getSpaceId()); | |||
| String mms = dateFormat1.format(mro.getOrderDate()) + " " + dateFormat2.format(mro.getStartTime()) + "于" + meetingRoom.getName(); | |||
| //TODO. 发送短信 | |||
| DmStaffPo dmStaffPo = dmStaffMapper.selectById(mro.getOrderBy()); | |||
| SmsReqEntity send = new SmsReqEntity(); | |||
| @@ -322,7 +329,9 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| jsonObject.put("dateStr", mms); | |||
| jsonObject.put("name", dmStaffPo.getUserName()); | |||
| //TODO. 发送短信 后期需要获取数字人昵称 | |||
| jsonObject.put("robotName", smsProperties.getRobotName()); | |||
| jsonObject.put(ROBOT_NAME_KEY, smsProperties.getRobotName()); | |||
| send.setDataMap(jsonObject.toJSONString()); | |||
| remoteSmsService.sendSms(send); | |||
| } | |||
| @@ -357,7 +366,7 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| @PostMapping(value = "/date-lists") | |||
| public JSONObject listByDate(@RequestParam("dateStr") String dateStr) { | |||
| if (StringUtils.isEmpty(dateStr) || dateStr.length() < 9) { | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "日期格式不正确").toJSON(); | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, ERR_MSG).toJSON(); | |||
| } | |||
| List<DmMeetingOrdersPo> list = dmMeetingOrdersMapper.findListByDateStr(dateStr); | |||
| List<DmMeetingOrdersDto> res = new ArrayList<>(); | |||
| @@ -378,7 +387,7 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| @PostMapping(value = "/lists") | |||
| public JSONObject listInner(@RequestParam("dateStr") String dateStr, @RequestParam("spaceId") Long spaceId) { | |||
| if (StringUtils.isEmpty(dateStr) || dateStr.length() < 9) { | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "日期格式不正确").toJSON(); | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, ERR_MSG).toJSON(); | |||
| } | |||
| List<DmMeetingOrdersPo> list = dmMeetingOrdersMapper.findListByDate(dateStr, spaceId); | |||
| List<DmMeetingOrdersDto> res = new ArrayList<>(); | |||
| @@ -394,11 +403,11 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| @PostMapping(value = "/lists-all") | |||
| public JSONObject listAllInner(@RequestParam("dateStr") String dateStr, @RequestParam("spaceId") Long spaceId) { | |||
| if (StringUtils.isEmpty(dateStr) || dateStr.length() < 10) { | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "日期格式不正确").toJSON(); | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, ERR_MSG).toJSON(); | |||
| } | |||
| String date = dateStr.substring(0, 10); | |||
| String time = dateStr.substring(11); | |||
| System.err.println("date:"+date+"; time:"+time+";spaceId:"+spaceId); | |||
| log.info("date:{}; time:{};spaceId:{}", date, time, spaceId); | |||
| List<DmMeetingOrdersPo> list = dmMeetingOrdersMapper.findAllListByDate(date,time, spaceId); | |||
| List<DmMeetingOrdersDto> res = new ArrayList<>(); | |||
| list.forEach(item -> { | |||
| @@ -427,19 +436,19 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| /* | |||
| * 获取会议室最近的可用时间段 | |||
| * @Author yangkai | |||
| * @Description //TODO | |||
| * @Description | |||
| * @Date 2023/9/1 | |||
| * @Param [roomId, objects, currentTime] | |||
| * @return java.util.List | |||
| **/ | |||
| List freeTimePart (Long roomId, List<DmMeetingOrdersPo> objects, String currentTime) { | |||
| public List<JSONObject> freeTimePart (Long roomId, List<DmMeetingOrdersPo> objects, String currentTime) { | |||
| List<JSONObject> freeTimeList = new ArrayList<>(); | |||
| if (null == objects || objects.size() ==0) { | |||
| if (null == objects || objects.isEmpty()) { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", currentTime); | |||
| json.put("endTime", 0); | |||
| json.put("roomId", roomId); | |||
| json.put(START_TIME_KEY, currentTime); | |||
| json.put(END_TIME_KEY, 0); | |||
| json.put(ROOM_ID_KEY, roomId); | |||
| freeTimeList.add(json); | |||
| return freeTimeList; | |||
| } | |||
| @@ -447,30 +456,29 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| DmMeetingOrdersPo current = objects.get(0); | |||
| if (MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime) > 0 ) { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", currentTime); | |||
| json.put("endTime", MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put("roomId", roomId); | |||
| json.put(START_TIME_KEY, currentTime); | |||
| json.put(END_TIME_KEY, MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put(ROOM_ID_KEY, roomId); | |||
| freeTimeList.add(json); | |||
| } else { | |||
| if (MyDateUtils.formatDate(current.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime) > 0 ) { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", MyDateUtils.formatDate(current.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put("endTime", 0); | |||
| json.put("roomId", roomId); | |||
| json.put(START_TIME_KEY, MyDateUtils.formatDate(current.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put(END_TIME_KEY, 0); | |||
| json.put(ROOM_ID_KEY, roomId); | |||
| freeTimeList.add(json); | |||
| } else { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", currentTime); | |||
| json.put("endTime", 0); | |||
| json.put("roomId", roomId); | |||
| json.put(START_TIME_KEY, currentTime); | |||
| json.put(END_TIME_KEY, 0); | |||
| json.put(ROOM_ID_KEY, roomId); | |||
| freeTimeList.add(json); | |||
| } | |||
| } | |||
| return freeTimeList; | |||
| } | |||
| // DateTimeFormatter formatter = DateTimeFormatter.ofPattern(MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| objects = objects.stream().sorted(Comparator.comparing(po -> MyDateUtils.formatDate(po.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN))).collect(Collectors.toList()); | |||
| objects = objects.stream().sorted(Comparator.comparing(po -> MyDateUtils.formatDate(po.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN))).toList(); | |||
| for (int i = 0; i < objects.size() - 1; i++) { | |||
| DmMeetingOrdersPo current = objects.get(i); | |||
| DmMeetingOrdersPo next = objects.get(i + 1); | |||
| @@ -485,12 +493,12 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| if (i==objects.size() - 2) { | |||
| JSONObject json = new JSONObject(); | |||
| if (MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime)>0) { | |||
| json.put("startTime", MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put(START_TIME_KEY, MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| } else { | |||
| json.put("startTime", currentTime); | |||
| json.put(START_TIME_KEY, currentTime); | |||
| } | |||
| json.put("endTime", 0); | |||
| json.put("roomId", current.getSpaceId()); | |||
| json.put(END_TIME_KEY, 0); | |||
| json.put(ROOM_ID_KEY, current.getSpaceId()); | |||
| freeTimeList.add(json); | |||
| } | |||
| continue; | |||
| @@ -498,29 +506,29 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| if (i==0 && MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime) > 0 ) { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", currentTime); | |||
| json.put("endTime", MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put("roomId", roomId); | |||
| json.put(START_TIME_KEY, currentTime); | |||
| json.put(END_TIME_KEY, MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put(ROOM_ID_KEY, roomId); | |||
| freeTimeList.add(json); | |||
| } | |||
| if (freeStartTime.before(freeEndTime)) { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", freeStartTimeStr); | |||
| json.put("endTime", freeEndTimeStr); | |||
| json.put("roomId", roomId); | |||
| json.put(START_TIME_KEY, freeStartTimeStr); | |||
| json.put(END_TIME_KEY, freeEndTimeStr); | |||
| json.put(ROOM_ID_KEY, roomId); | |||
| freeTimeList.add(json); | |||
| } | |||
| if (i==objects.size() - 2) { | |||
| JSONObject json = new JSONObject(); | |||
| if (MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime)>0) { | |||
| json.put("startTime", MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put(START_TIME_KEY, MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| } else { | |||
| json.put("startTime", currentTime); | |||
| json.put(START_TIME_KEY, currentTime); | |||
| } | |||
| json.put("endTime", 0); | |||
| json.put("roomId", current.getSpaceId()); | |||
| json.put(END_TIME_KEY, 0); | |||
| json.put(ROOM_ID_KEY, current.getSpaceId()); | |||
| freeTimeList.add(json); | |||
| } | |||
| } | |||
| @@ -547,26 +555,26 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| } | |||
| Map<Long, String> finalRooms = rooms; | |||
| Map<Long, Integer> finalSorts = sorts; | |||
| arr = arr.stream().map(j->{j.put("roomName", finalRooms.get(j.getLong("roomId")));j.put("sort", finalSorts.get(j.getLong("roomId")));return j;}).sorted(Comparator.comparing(po -> po.getString("startTime"))).collect(Collectors.toList()); | |||
| arr = arr.stream().map(j->{j.put("roomName", finalRooms.get(j.getLong(ROOM_ID_KEY)));j.put("sort", finalSorts.get(j.getLong(ROOM_ID_KEY)));return j;}).sorted(Comparator.comparing(po -> po.getString(START_TIME_KEY))).toList(); | |||
| List<JSONObject> arr2 = new ArrayList<>(); | |||
| for (int i=0;i<arr.size();i++){ | |||
| JSONObject j = arr.get(i); | |||
| if (arr2.size() == 0 || arr2.get(0).getString("startTime").equals(j.getString("startTime"))) { | |||
| if (arr2.isEmpty() || arr2.get(0).getString(START_TIME_KEY).equals(j.getString(START_TIME_KEY))) { | |||
| arr2.add(j); | |||
| } else { | |||
| break; | |||
| } | |||
| } | |||
| return arr2.size()>0 ? arr2.stream().sorted(Comparator.comparing(po -> po.getInteger("sort"))).collect(Collectors.toList()).get(0) : null; | |||
| return !arr2.isEmpty() ? arr2.stream().sorted(Comparator.comparing(po -> po.getInteger("sort"))).toList().get(0) : null; | |||
| } | |||
| @InnerAuth | |||
| @GetMapping("/recent/{deptId}/{dateStr}") | |||
| @ResponseBody | |||
| public List<JSONObject> recent(@PathVariable(value = "deptId") Long deptId,@PathVariable(value = "dateStr") String dateStr,@RequestParam(value = "roomId", required = false) Long roomId,@RequestParam(value = "startTime", required = false) String startTime, HttpServletRequest request) { | |||
| public List<JSONObject> recent(@PathVariable(value = "deptId") Long deptId,@PathVariable(value = "dateStr") String dateStr,@RequestParam(value = ROOM_ID_KEY, required = false) Long roomId,@RequestParam(value = START_TIME_KEY, required = false) String startTime, HttpServletRequest request) { | |||
| List<DmMeetingOrdersPo> list = new ArrayList<>(); | |||
| List<DmMeetingOrdersPo> list ; | |||
| List<Long> ids = new ArrayList<>(); | |||
| Map<Long, String> rooms = new HashMap<>(); | |||
| if (null == roomId) { | |||
| @@ -585,7 +593,7 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| //过滤掉今天的已经过去的预约记录,并按开始时间进行排序 | |||
| list = list.stream().filter(t-> MyDateUtils.formatDate(t.getOrderDate(), MyDateUtils.DEFAULT_DATE_PATTERN).compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN))>0 || (MyDateUtils.formatDate(t.getOrderDate(), MyDateUtils.DEFAULT_DATE_PATTERN).compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN))==0 && MyDateUtils.formatDate(t.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_TIME_PATTERN))>0)).sorted(Comparator.comparing(po -> MyDateUtils.formatDate(po.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN))).collect(Collectors.toList()); | |||
| list = list.stream().filter(t-> MyDateUtils.formatDate(t.getOrderDate(), MyDateUtils.DEFAULT_DATE_PATTERN).compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN))>0 || (MyDateUtils.formatDate(t.getOrderDate(), MyDateUtils.DEFAULT_DATE_PATTERN).compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN))==0 && MyDateUtils.formatDate(t.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_TIME_PATTERN))>0)).sorted(Comparator.comparing(po -> MyDateUtils.formatDate(po.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN))).toList(); | |||
| //获得当前时间开始最近的整点,或者半点 | |||
| @@ -618,11 +626,10 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| List<JSONObject> arr = new ArrayList<>(); | |||
| for (int i=0;i<freeTime.keySet().size();i++){ | |||
| Long key = (Long) freeTime.keySet().toArray()[i]; | |||
| List<JSONObject> value = freeTime.get(key); | |||
| arr.addAll(freeTime.get(key)); | |||
| } | |||
| Map<Long, String> finalRooms = rooms; | |||
| arr = arr.stream().map(j->{j.put("roomName", finalRooms.get(j.getLong("roomId")));return j;}).sorted(Comparator.comparing(po -> po.getString("startTime"))).collect(Collectors.toList()); | |||
| arr = arr.stream().map(j->{j.put("roomName", finalRooms.get(j.getLong(ROOM_ID_KEY)));return j;}).sorted(Comparator.comparing(po -> po.getString(START_TIME_KEY))).collect(Collectors.toList()); | |||
| return arr; | |||
| } | |||
| @@ -634,10 +641,9 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| @ResponseBody | |||
| public List<JSONObject> recent(@PathVariable(value = "deptId") Long deptId) { | |||
| List<DmMeetingOrdersPo> list = new ArrayList<>(); | |||
| List<Long> ids = new ArrayList<>(); | |||
| Map<Long, String> rooms = new HashMap<>(); | |||
| Map<Long, Integer> sorts = new HashMap<>(); | |||
| List<Long> ids; | |||
| Map<Long, String> rooms; | |||
| Map<Long, Integer> sorts; | |||
| //当天 | |||
| String dateStr = MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| @@ -645,10 +651,10 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| dm.setDeptId(deptId); | |||
| List<DmMeetingRoomsPo> pos = dmMeetingRoomsMapper.selectRoomList(dm); | |||
| ids = pos.stream().map(DmMeetingRoomsPo::getId).collect(Collectors.toList()); | |||
| ids = pos.stream().map(DmMeetingRoomsPo::getId).toList(); | |||
| rooms = pos.stream().collect(Collectors.toMap(DmMeetingRoomsPo::getId, DmMeetingRoomsPo::getName)); | |||
| sorts = pos.stream().collect(Collectors.toMap(DmMeetingRoomsPo::getId, DmMeetingRoomsPo::getSort)); | |||
| log.info("ids:" + ids); | |||
| log.info("ids:{}" , ids); | |||
| //获得当前时间开始最近的整点,或者半点 | |||
| String currentStr = "08:00"; | |||
| @@ -666,8 +672,8 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| String nextDateStr = MyDateUtils.dateStrAdd(dateStr, 1); | |||
| Map<Long, List<DmMeetingOrdersPo>> nextGroupedByRoom = ordersService.selectOrderedList(deptId,nextDateStr); | |||
| JSONObject js1 = getList(currentStr, groupedByRoom, rooms, sorts, ids); | |||
| JSONObject js2 = new JSONObject(); | |||
| JSONObject js3 = new JSONObject(); | |||
| JSONObject js2 ; | |||
| JSONObject js3 ; | |||
| if (MyDateUtils.isAmPm().equals("am")) { | |||
| currentStr = "14:00"; | |||
| js2 = getList(currentStr, groupedByRoom, rooms, sorts, ids); | |||
| @@ -682,19 +688,19 @@ public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| } | |||
| List<JSONObject> arr = new ArrayList<>(); | |||
| if (ObjectUtil.isNotEmpty(js1)) { | |||
| js1.put("orderDate", dateStr); | |||
| js1.put(ORDER_DATE_KEY, dateStr); | |||
| arr.add(js1); | |||
| } | |||
| if (ObjectUtil.isNotEmpty(js2)) { | |||
| if (MyDateUtils.isAmPm().equals("am")) { | |||
| js2.put("orderDate", dateStr); | |||
| js2.put(ORDER_DATE_KEY, dateStr); | |||
| } else { | |||
| js2.put("orderDate", nextDateStr); | |||
| js2.put(ORDER_DATE_KEY, nextDateStr); | |||
| } | |||
| arr.add(js2); | |||
| } | |||
| if (ObjectUtil.isNotEmpty(js3)) { | |||
| js3.put("orderDate", nextDateStr); | |||
| js3.put(ORDER_DATE_KEY, nextDateStr); | |||
| arr.add(js3); | |||
| } | |||
| @@ -1,6 +1,5 @@ | |||
| package com.xueyi.system.meeting.mapper; | |||
| import com.baomidou.dynamic.datasource.annotation.DS; | |||
| import com.xueyi.common.datasource.annotation.Isolate; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.mapper.BaseMapper; | |||
| @@ -14,7 +14,6 @@ import com.xueyi.system.staff.service.impl.DmStaffServiceImpl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.ArrayList; | |||
| import java.util.Comparator; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @@ -27,6 +27,7 @@ import com.xueyi.system.digitalmans.service.IDmDigitalmanExtService; | |||
| import com.xueyi.system.digitalmans.service.impl.DmDigitalmanServiceImpl; | |||
| import com.xueyi.system.meeting.domain.query.DmMeetingRoomsQuery; | |||
| import com.xueyi.system.meeting.service.IDmMeetingRoomsService; | |||
| import com.xueyi.system.organize.domain.po.SysDeptExtPo; | |||
| import com.xueyi.system.organize.mapper.SysDeptExtMapper; | |||
| import com.xueyi.system.organize.service.ISysDeptService; | |||
| import com.xueyi.system.organize.service.ISysOrganizeService; | |||
| @@ -70,6 +71,9 @@ public class SysDeptController extends TreeController<SysDeptQuery, SysDeptDto, | |||
| @Autowired | |||
| private IDmMeetingRoomsService meetingRoomsService; | |||
| @Autowired | |||
| private SysDeptExtMapper deptExtMapper; | |||
| /** 定义节点名称 */ | |||
| @Override | |||
| protected String getNodeName() { | |||
| @@ -82,6 +86,12 @@ public class SysDeptController extends TreeController<SysDeptQuery, SysDeptDto, | |||
| @InnerAuth | |||
| @PostMapping("/inner/add") | |||
| public R<SysDeptDto> addInner(@RequestBody SysDeptDto dept) { | |||
| Long deptId = IdUtil.getSnowflakeNextId(); | |||
| dept.setId(deptId); | |||
| SysDeptExtPo deptExt = new SysDeptExtPo(); | |||
| deptExt.setDeptId(deptId); | |||
| deptExt.initData(); | |||
| deptExtMapper.insert(deptExt);//保存部门扩展表 | |||
| return baseService.addInner(dept) > 0 ? R.ok(dept) : R.fail(); | |||
| } | |||
| @@ -149,9 +159,6 @@ public class SysDeptController extends TreeController<SysDeptQuery, SysDeptDto, | |||
| } | |||
| @Autowired | |||
| protected SysDeptExtMapper deptExtMapper; | |||
| /** | |||
| * 部门新增 | |||
| */ | |||
| @@ -15,4 +15,5 @@ public class SysDeptExtDto extends SysDeptExtPo { | |||
| private static final long serialVersionUID = 1L; | |||
| protected String nickName; | |||
| } | |||
| @@ -43,4 +43,13 @@ public class SysDeptExtPo extends TBaseEntity { | |||
| protected String province; | |||
| protected String city; | |||
| //初始化上下班打卡时间 | |||
| public SysDeptExtPo initData() { | |||
| this.onDutyHourStart = "07:00:00"; | |||
| this.onDutyHourEnd = "09:00:00"; | |||
| this.offDutyHourStart = "17:00:00"; | |||
| this.offDutyHourEnd = "19:00:00"; | |||
| return this; | |||
| } | |||
| } | |||
| @@ -125,7 +125,7 @@ public class DmRecognizedRecordsInnerApiController extends MyBaseApiController { | |||
| } | |||
| if (StringUtils.isNotEmpty(imgBase64)) { | |||
| R<SysFile> fileResult = fileService.uploadTemp(imageUtil.convertToMultipartFile(imgBase64)); | |||
| R<SysFile> fileResult = fileService.uploadTemp(ImageUtil.convertToMultipartFile(imgBase64)); | |||
| if (ObjectUtil.isNull(fileResult) || ObjectUtil.isNull(fileResult.getData())) | |||
| return output(ResponseCode.FILE_SERVICE_ERROR).toJSON(); | |||
| String url = fileResult.getData().getUrl(); | |||
| @@ -133,7 +133,7 @@ public class DmRecognizedRecordsInnerApiController extends MyBaseApiController { | |||
| } | |||
| dmRecognizedRecordsMapper.insert(cr); | |||
| // recognizedRecordsService.saveToEs(recordsConverter.mapperDto(cr)); | |||
| // recognizedRecordsService.saveToEs(recordsConverter.mapperDto(cr));// | |||
| recognizedRecordsService.setRedisRecognizedCount(1); | |||
| @@ -146,8 +146,8 @@ public class DmRecognizedRecordsInnerApiController extends MyBaseApiController { | |||
| String deviceId = recognizedMultiRecordsDto.getDevId(); | |||
| BigDecimal timestamp = recognizedMultiRecordsDto.getTimestamp(); | |||
| String sign = recognizedMultiRecordsDto.getSign(); | |||
| logger.info("recognizedMultiRecordsDto :{}",recognizedMultiRecordsDto.toString()); | |||
| //去掉recognizedMultiRecordsDto输出日志 | |||
| // logger.info("recognizedMultiRecordsDto :{}",recognizedMultiRecordsDto); | |||
| MyResponse myResponse = commonCheck(deviceId, timestamp.doubleValue(), sign); | |||
| if (myResponse.getStatus() != 0) { | |||
| @@ -179,7 +179,7 @@ public class DmRecognizedRecordsInnerApiController extends MyBaseApiController { | |||
| } | |||
| } | |||
| if (StringUtils.isNotEmpty(imgBase64)) { | |||
| R<SysFile> fileResult = fileService.uploadTemp(imageUtil.convertToMultipartFile(imgBase64)); | |||
| R<SysFile> fileResult = fileService.uploadTemp(ImageUtil.convertToMultipartFile(imgBase64)); | |||
| if (ObjectUtil.isNull(fileResult) || ObjectUtil.isNull(fileResult.getData())) | |||
| return output(ResponseCode.FILE_SERVICE_ERROR).toJSON(); | |||
| String url = fileResult.getData().getUrl(); | |||
| @@ -113,5 +113,11 @@ public class DmEmpAttendancePo extends TBaseEntity { | |||
| '}'; | |||
| } | |||
| public DmEmpAttendancePo(){ | |||
| super(); | |||
| this.setWorkDuration(0); | |||
| this.setCreateTime(MyDateUtils.currentDateToLocalDateTime()); | |||
| this.setUpdateTime(MyDateUtils.currentDateToLocalDateTime()); | |||
| } | |||
| } | |||
| @@ -57,8 +57,7 @@ public class DmEmpAttendanceServiceImpl extends BaseServiceImpl<DmEmpAttendanceQ | |||
| @TenantIgnore(tenantLine = true) | |||
| public Integer selectCountIgnoreTenant() { | |||
| if (redisTemplate.hasKey("broadcast:attendance")) { | |||
| Integer attendance = (Integer) redisTemplate.opsForValue().get("broadcast:attendance"); | |||
| return attendance; | |||
| return (Integer) redisTemplate.opsForValue().get("broadcast:attendance"); | |||
| } else { | |||
| Long attendance = attendanceMapper.selectCount(new QueryWrapper<>()); | |||
| redisTemplate.opsForValue().set("dashboard:attendance", attendance); | |||
| @@ -81,7 +80,7 @@ public class DmEmpAttendanceServiceImpl extends BaseServiceImpl<DmEmpAttendanceQ | |||
| List<SysDictDataDto> dictDataDtos = DictUtil.getDictCache("dm_attendance_desc"); | |||
| Map<String, String> dictMap = dictDataDtos.stream().collect(Collectors.toMap(SysDictDataDto::getValue, SysDictDataDto::getLabel)); | |||
| List<LocalDate> dateRange = startDate.datesUntil(endDate.plusDays(1)).collect(Collectors.toList()); | |||
| List<LocalDate> dateRange = startDate.datesUntil(endDate.plusDays(1)).toList(); | |||
| return grouped.entrySet().stream() | |||
| .map(entry -> { | |||
| @@ -94,8 +93,7 @@ public class DmEmpAttendanceServiceImpl extends BaseServiceImpl<DmEmpAttendanceQ | |||
| row.add(status); | |||
| } | |||
| return row; | |||
| }) | |||
| .collect(Collectors.toList()); | |||
| }).toList(); | |||
| } | |||
| public void updRedisCount(){ | |||
| @@ -145,26 +145,31 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| } | |||
| } | |||
| public DmEmpAttendancePo newInit(LocalDateTime checkDateTime, String onDutyHourEnd) { | |||
| DmEmpAttendancePo ea = new DmEmpAttendancePo(); | |||
| Date checkDate = MyDateUtils.localDateTimeToDate(checkDateTime); | |||
| ea.setCheckInTime(checkDate); | |||
| logger.info("考勤打卡时间1:{}", JSON.toJSONString(checkDateTime)); | |||
| DmHolidayPo holidayPo = holidayService.isHoliday(checkDateTime.toLocalDate()); | |||
| if (MyDateUtils.formatDate(checkDate, MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(onDutyHourEnd) > 0) {//识别时间比考勤上班打卡最晚时间更晚 | |||
| ea.setDescStatus(ATTENDANCE_STATUS_BE_LATER); // 迟到 | |||
| if (holidayPo.getHoliday() == 1) { | |||
| ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); | |||
| } | |||
| } else {//识别时间比考勤上班打卡最晚时间早 | |||
| if (holidayPo.getHoliday() == 1) { | |||
| ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); | |||
| } | |||
| } | |||
| return ea; | |||
| } | |||
| public DmEmpAttendancePo judgeAttendanceDescStatus(DmEmpAttendancePo po, LocalDateTime checkDateTime){ | |||
| SysDeptExt ext = sysDeptExtMapper.selectWorkTimeByDeptId(po.getDeptId()); | |||
| public DmEmpAttendancePo judgeAttendanceDescStatus(DmEmpAttendancePo po, LocalDateTime checkDateTime, Long deptId){ | |||
| SysDeptExt ext = sysDeptExtMapper.selectWorkTimeByDeptId(deptId); | |||
| Date checkDate = MyDateUtils.localDateTimeToDate(checkDateTime); | |||
| if (null == po) { | |||
| DmEmpAttendancePo ea = new DmEmpAttendancePo(); | |||
| ea.setCheckInTime(checkDate); | |||
| logger.info("考勤打卡时间1:{}", JSON.toJSONString(checkDateTime)); | |||
| DmHolidayPo holidayPo = holidayService.isHoliday(checkDateTime.toLocalDate()); | |||
| if (MyDateUtils.formatDate(checkDate, MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOnDutyHourEnd()) > 0) {//识别时间比考勤上班打卡最晚时间更晚 | |||
| ea.setDescStatus(ATTENDANCE_STATUS_BE_LATER); // 迟到 | |||
| if (holidayPo.getHoliday() == 1) { | |||
| ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); | |||
| } | |||
| } else {//识别时间比考勤上班打卡最晚时间早 | |||
| if (holidayPo.getHoliday() == 1) { | |||
| ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); | |||
| } | |||
| } | |||
| return ea; | |||
| return newInit(checkDateTime, ext.getOnDutyHourEnd()); | |||
| } | |||
| logger.info("考勤打卡时间2:{}", JSON.toJSONString(checkDateTime)); | |||
| if (po.getCheckInTime() == null){ | |||
| @@ -213,32 +218,29 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| if (ObjectUtil.isNull(checkRecords.getUserId())) { | |||
| return ; | |||
| } | |||
| Long userId = checkRecords.getUserId(); | |||
| DmStaffPo emp = this.selectById(userId); | |||
| if (null == emp) { | |||
| return ; | |||
| } | |||
| LocalDateTime checkTime = checkRecords.getRecognizedTime(); | |||
| String checkTimeDateStr = LocalDateTimeUtil.format(checkTime, MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| if (StringUtils.isEmpty(checkTimeDateStr)) { | |||
| if (StringUtils.isEmpty(checkTimeDateStr)) {//无打卡时间 | |||
| return ; | |||
| } | |||
| Long userId = checkRecords.getUserId(); | |||
| DmStaffPo emp = this.selectById(userId); | |||
| if (null == emp) {//无对应员工 | |||
| return ; | |||
| } | |||
| DmEmpAttendancePo empAttendance = dmEmpAttendanceMapper.findByEmpAndDate(checkTimeDateStr, userId); | |||
| if (null != empAttendance) {//基本都会走这个控制段 | |||
| empAttendance = judgeAttendanceDescStatus(empAttendance, checkTime); | |||
| empAttendance = judgeAttendanceDescStatus(empAttendance, checkTime, emp.getDeptId()); | |||
| dmEmpAttendanceMapper.updateById(empAttendance); | |||
| } else { | |||
| DmEmpAttendancePo ea = judgeAttendanceDescStatus(empAttendance, checkTime); | |||
| DmEmpAttendancePo ea = judgeAttendanceDescStatus(empAttendance, checkTime, emp.getDeptId()); | |||
| ea.setDateStr(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN)); | |||
| ea.setUserId(userId); | |||
| ea.setUserName(emp.getUserName()); | |||
| ea.setUserType(Long.parseLong(emp.getUserType())); | |||
| ea.setDeptId(emp.getDeptId()); | |||
| ea.setWorkDuration(0); | |||
| ea.setCreateTime(MyDateUtils.currentDateToLocalDateTime()); | |||
| ea.setUpdateTime(MyDateUtils.currentDateToLocalDateTime()); | |||
| dmEmpAttendanceService.updRedisCount(); | |||
| dmEmpAttendanceMapper.insert(ea); | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.xueyi.tenant.tenant.controller; | |||
| import cn.hutool.core.text.CharSequenceUtil; | |||
| import com.alibaba.fastjson2.JSON; | |||
| import com.xueyi.common.core.constant.basic.BaseConstants; | |||
| import com.xueyi.common.core.constant.system.OrganizeConstants; | |||
| import com.xueyi.common.core.utils.core.CollUtil; | |||
| @@ -9,6 +10,7 @@ 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.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.common.log.annotation.Log; | |||
| import com.xueyi.common.log.enums.BusinessType; | |||
| import com.xueyi.common.security.annotation.InnerAuth; | |||
| @@ -17,6 +19,7 @@ import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.security.auth.Auth; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.common.web.entity.domain.mapper.DeviceTenantMergeMapper; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.TeTenantPo; | |||
| @@ -83,11 +86,30 @@ public class TeTenantController extends BaseController<TeTenantQuery, TeTenantDt | |||
| @InnerAuth | |||
| @GetMapping("/one") | |||
| R<TeTenantPo> tenant(@RequestParam("phone") String phone) { | |||
| log.info("tenant one方法,手机号查询SysEnterpriseStaff:{}", phone); | |||
| log.info("tenant one方法,tenant phone:{}", phone); | |||
| TeTenantPo po = enterpriseStaffMapper.selectTenantByPhone(phone); | |||
| log.info("tenant one方法,手机号查询SysEnterpriseStaff:{}", JSON.toJSONString(po)); | |||
| return R.ok(po); | |||
| } | |||
| @InnerAuth | |||
| @GetMapping("/query-tenant-by-id") | |||
| R<TeTenantPo> selectById(@RequestParam ("tenantId") Long tenantId) { | |||
| log.info("selectById方法,查询TeTenantPo:{}", tenantId); | |||
| TeTenantPo po = super.baseService.selectById(tenantId); | |||
| return R.ok(po); | |||
| } | |||
| @Autowired | |||
| private DeviceTenantMergeMapper mergeMapper; | |||
| @InnerAuth | |||
| @GetMapping("/query-tenant-source") | |||
| DeviceTenantSourceMergeVo selectTenantSourceMerge(@RequestParam ("deviceId") String deviceId) { | |||
| log.info("selectTenantSourceMerge方法,deviceId:{}", deviceId); | |||
| return mergeMapper.selectByDeviceId(deviceId); | |||
| } | |||
| @InnerAuth | |||
| @GetMapping("/query-tenant-by-staff-phone") | |||
| R<TeTenantPo> queryTenantByStaffPhone(@RequestParam("phone") String phone) { | |||