| @@ -10,4 +10,6 @@ public class DmWebSocketMessageVo { | |||
| String devId; | |||
| String skillCode; | |||
| JSONObject format; | |||
| String template; | |||
| String operator; | |||
| } | |||
| @@ -87,4 +87,12 @@ public class DmStaffPo extends TBaseEntity { | |||
| @Excel(name = "所属组织ID") | |||
| protected Long resourceId; | |||
| /** 生日日期 */ | |||
| @Excel(name = "生日日期") | |||
| protected Date birthDate; | |||
| /** 入职日期 */ | |||
| @Excel(name = "入职日期") | |||
| protected Date hireDate; | |||
| } | |||
| @@ -232,6 +232,22 @@ public class WebSocketClient extends WebSocketListener { | |||
| if (INSTANCE.redisTemplate.hasKey("gpt:websocket:1")) { | |||
| DmWebSocketMessageVo message = (DmWebSocketMessageVo) INSTANCE.redisTemplate.opsForValue().get("gpt:websocket:1"); | |||
| if (StringUtils.isNotEmpty(message.getTemplate()) && message.getTemplate().equals("birthday")) { | |||
| JSONObject birthdayJo = new JSONObject(); | |||
| birthdayJo.put("content", answer); | |||
| birthdayJo.put("timestamp", message.getFormat().get("timestamp")); | |||
| INSTANCE.stringRedisTemplate.opsForHash().put("group:nlp" + ":" + message.getFormat().getString("orderId"), "birthday", birthdayJo.toString()); | |||
| INSTANCE.redisTemplate.delete("gpt:websocket:1"); | |||
| return; | |||
| } | |||
| if (StringUtils.isNotEmpty(message.getTemplate()) && message.getTemplate().equals("hireDate")) { | |||
| JSONObject birthdayJo = new JSONObject(); | |||
| birthdayJo.put("content", answer); | |||
| birthdayJo.put("timestamp", message.getFormat().get("timestamp")); | |||
| INSTANCE.stringRedisTemplate.opsForHash().put("group:nlp" + ":" + message.getFormat().getString("orderId"), "hireDate", birthdayJo.toString()); | |||
| INSTANCE.redisTemplate.delete("gpt:websocket:1"); | |||
| return; | |||
| } | |||
| JSONObject preWebsocketJo = message.getFormat(); | |||
| JSONObject meetingJo = new JSONObject(); | |||
| meetingJo.put("timestamp",preWebsocketJo.get("timestamp")); | |||
| @@ -1,6 +1,7 @@ | |||
| package com.xueyi.nlt.netty.controller; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.cache.utils.SourceUtil; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.web.result.AjaxResult; | |||
| @@ -53,6 +54,18 @@ public class DmWebsocketController { | |||
| SimpleDateFormat dateFormat3 = new SimpleDateFormat("MM-dd"); | |||
| Double timestamp = Double.valueOf((String)jo.get("timestamp")); | |||
| String meetingRoom = jo.getString("meetingRoom"); | |||
| if (StringUtils.isNotEmpty(message.getTemplate()) && message.getTemplate().equals("birthday")) { | |||
| String prefix = "假设你是一名公司前台,你看到" + message.getFormat().get("name")+ "已知今天是他的生日。请你从个人角度输出给他的生日贺词。要求待人平和,具有人情味,用词正式,内容与工作无关。输出只包含你要对他说的话,在20字以内。"; | |||
| webSocketClient.sendMsg(prefix); | |||
| redisTemplate.opsForValue().set("gpt:websocket" + ":" + "1", message); | |||
| return R.ok(); | |||
| } | |||
| if (StringUtils.isNotEmpty(message.getTemplate()) && message.getTemplate().equals("hiredate")) { | |||
| String prefix = "假设你是一名公司前台,你看到"+ message.getFormat().get("name")+ ",已知今天是他入职1周年,请你从个人角度说出对他入职周年的祝贺。要求具有人情味,有特色,字数在25字左右,不要提到生日,要带人名。输出只包含你要对他说的话。"; | |||
| webSocketClient.sendMsg(prefix); | |||
| redisTemplate.opsForValue().set("gpt:websocket" + ":" + "1", message); | |||
| return R.ok(); | |||
| } | |||
| Date date = new Date(timestamp.longValue()); | |||
| if (message.getSkillCode().equals("1")) { | |||
| String prefix = "假设你是一名公司前台,你看到在你们公司工作的\\"+ jo.getString("orderName")+ "\\,请你从个人角度提醒他参加\\" + | |||
| @@ -40,6 +40,7 @@ import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | |||
| import com.xueyi.system.api.organize.feign.RemoteEnterpriseService; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import org.apache.commons.lang.time.DateUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -50,8 +51,12 @@ import org.springframework.web.bind.annotation.*; | |||
| import com.xueyi.common.core.constant.digitalman.SkillConstants.SkillType; | |||
| import java.io.Serializable; | |||
| import java.text.DateFormat; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Arrays; | |||
| import java.time.Instant; | |||
| import java.time.LocalDateTime; | |||
| import java.time.ZoneId; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -182,6 +187,11 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| redisTemplate.opsForHash().delete("group:nlp" + ":" + recognition.getPersonId(), "meeting"); | |||
| } | |||
| } else { | |||
| JSONObject jo = JSONObject.parseObject(value); | |||
| JSONObject joresult = addNotificaion(String.valueOf(key),recognition.getPersonId(),jo); | |||
| if (joresult!= null) { | |||
| return AjaxResult.success(joresult); | |||
| } | |||
| joResult.put("msg",value); | |||
| redisTemplate.opsForValue().increment("dashboard:conversation-duration", value.toString().length() / 4); | |||
| joResult.put("target",1); | |||
| @@ -301,6 +311,18 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| SimpleDateFormat dateFormat3 = new SimpleDateFormat("MM-dd"); | |||
| Double timestamp = Double.valueOf((String)jo.get("timestamp")); | |||
| String meetingRoom = jo.getString("meetingRoom"); | |||
| if (StringUtils.isNotEmpty(message.getTemplate()) && message.getTemplate().equals("birthday")) { | |||
| String prefix = "假设你是一名公司前台,你看到" + message.getFormat().get("name")+ "已知今天是他的生日。请你从个人角度输出给他的生日贺词。要求待人平和,具有人情味,用词正式,内容与工作无关。输出只包含你要对他说的话,在20字以内。"; | |||
| webSocketClient.sendMsg(prefix); | |||
| redisTemplate2.opsForValue().set("gpt:websocket" + ":" + "1", message); | |||
| return R.ok(); | |||
| } | |||
| if (StringUtils.isNotEmpty(message.getTemplate()) && message.getTemplate().equals("hireDate")) { | |||
| String prefix = "假设你是一名公司前台,你看到"+ message.getFormat().get("name")+ ",已知今天是他入职" + message.getFormat().get("years")+"周年,请你从个人角度说出对他入职周年的祝贺。要求具有人情味,有特色,字数在25字左右,不要提到生日,要带人名。输出只包含你要对他说的话。"; | |||
| webSocketClient.sendMsg(prefix); | |||
| redisTemplate2.opsForValue().set("gpt:websocket" + ":" + "1", message); | |||
| return R.ok(); | |||
| } | |||
| Date date = new Date(timestamp.longValue()); | |||
| if (message.getSkillCode().equals("1")) { | |||
| String prefix = "假设你是一名公司前台,你看到在你们公司工作的\\"+ jo.getString("orderName")+ "\\,请你从个人角度提醒他参加\\" + | |||
| @@ -446,6 +468,24 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| } | |||
| private JSONObject addNotificaion(String key,Long personId,JSONObject jo) { | |||
| JSONObject joResult = new JSONObject(); | |||
| if (String.valueOf(key).equals("birthday") || String.valueOf(key).equals("hireDate")) { | |||
| // 获取value中的timestamp,判断是否是当天 | |||
| if (jo.containsKey("timestamp")) { | |||
| // 判断jo.get("timestamp")的月份是否与当天相同 | |||
| DateFormat dateFormat = new SimpleDateFormat("MM-dd"); | |||
| if (dateFormat.format(new Date(Long.valueOf(String.valueOf(jo.get("timestamp"))))).equals(dateFormat.format(new Date()))) { | |||
| joResult.put("msg", jo.get("content")); | |||
| joResult.put("target", 1); | |||
| redisTemplate.opsForHash().delete("group:nlp" + ":" + personId, "birthday"); | |||
| redisTemplate.opsForValue().increment("dashboard:conversation-duration", jo.get("content").toString().length() / 4); | |||
| return joResult; | |||
| } | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| interface Auth { | |||
| /** 系统 - 意图管理 | |||
| @@ -1,5 +1,9 @@ | |||
| package com.xueyi.system.staff.controller; | |||
| 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.utils.core.ObjectUtil; | |||
| import com.xueyi.common.core.utils.core.StrUtil; | |||
| import com.xueyi.common.core.utils.file.FileTypeUtil; | |||
| @@ -16,10 +20,14 @@ import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.file.api.domain.SysFile; | |||
| import com.xueyi.file.api.feign.RemoteFileService; | |||
| import com.xueyi.nlt.api.netty.domain.vo.DmWebSocketMessageVo; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteIntentService; | |||
| import com.xueyi.system.api.model.Source; | |||
| import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffDto; | |||
| import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| import com.xueyi.system.authority.service.ISysLoginService; | |||
| import com.xueyi.system.organize.service.ISysEnterpriseService; | |||
| import com.xueyi.system.staff.domain.query.DmStaffQuery; | |||
| import com.xueyi.system.api.staff.domain.vo.DmStaffFeature; | |||
| import com.xueyi.system.staff.service.IDmStaffService; | |||
| @@ -30,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.Serializable; | |||
| import java.util.Arrays; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| /** | |||
| @@ -49,6 +58,13 @@ public class DmStaffController extends BaseController<DmStaffQuery, DmStaffDto, | |||
| @Autowired | |||
| private RemoteFileService remoteFileService; | |||
| @Autowired | |||
| private RemoteIntentService remoteIntentService; | |||
| @Autowired | |||
| ISysEnterpriseService enterpriseService; | |||
| /** 定义节点名称 */ | |||
| @Override | |||
| protected String getNodeName() { | |||
| @@ -105,7 +121,36 @@ public class DmStaffController extends BaseController<DmStaffQuery, DmStaffDto, | |||
| @RequiresPermissions(Auth.DM_STAFF_ADD) | |||
| @Log(title = "人员管理", businessType = BusinessType.INSERT) | |||
| public AjaxResult add(@Validated({V_A.class}) @RequestBody DmStaffDto dmStaff) { | |||
| return super.add(dmStaff); | |||
| Long tenantId = Long.parseLong(String.valueOf(SecurityContextHolder.getLocalMap().get("enterprise_id"))); | |||
| SysEnterpriseDto enterpriseDto = enterpriseService.selectById(tenantId); | |||
| Source source = SourceUtil.getSourceCache(enterpriseDto.getStrategyId()); | |||
| AjaxResult result = super.add(dmStaff); | |||
| if (dmStaff.getBirthDate() != null) { | |||
| DmWebSocketMessageVo vo = new DmWebSocketMessageVo(); | |||
| JSONObject birthJson = new JSONObject(); | |||
| birthJson.put("name",dmStaff.getUserName()); | |||
| birthJson.put("orderId",dmStaff.getId()); | |||
| birthJson.put("years",new Date().getYear() - dmStaff.getBirthDate().getYear()); | |||
| birthJson.put("timestamp",dmStaff.getBirthDate().getTime()); | |||
| vo.setTemplate("birthday"); | |||
| vo.setFormat(birthJson); | |||
| System.out.println(birthJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| if (dmStaff.getHireDate() != null) { | |||
| DmWebSocketMessageVo vo2 = new DmWebSocketMessageVo(); | |||
| JSONObject hireJson = new JSONObject(); | |||
| hireJson.put("name",dmStaff.getUserName()); | |||
| hireJson.put("orderId",dmStaff.getId()); | |||
| hireJson.put("years",new Date().getYear() - dmStaff.getHireDate().getYear()); | |||
| hireJson.put("timestamp",dmStaff.getHireDate().getTime()); | |||
| vo2.setTemplate("hireDate"); | |||
| vo2.setFormat(hireJson); | |||
| System.out.println(hireJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo2,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||