| @@ -26,4 +26,6 @@ public class DmVisitRecordsDto extends DmVisitRecordsPo { | |||
| private String visitorName; | |||
| private DmVisitorsDto visitor; | |||
| } | |||
| @@ -7,6 +7,7 @@ import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.io.Serial; | |||
| import java.time.LocalDate; | |||
| import java.util.Date; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.NAME; | |||
| @@ -53,7 +54,7 @@ public class DmVisitRecordsPo extends TBaseEntity { | |||
| /** 邀约访问日期 */ | |||
| @Excel(name = "邀约访问日期") | |||
| protected Date visitDate; | |||
| protected LocalDate visitDate; | |||
| /** 邀约访问时间 */ | |||
| @Excel(name = "邀约访问时间") | |||
| @@ -71,5 +71,9 @@ public class DmVisitorsPo extends TBaseEntity { | |||
| @GraphQLField | |||
| protected Long resourceId; | |||
| private Boolean isBlock; | |||
| private Boolean isVip; | |||
| private Boolean flexVisit; | |||
| } | |||
| @@ -7,7 +7,7 @@ import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.io.Serial; | |||
| import java.util.Date; | |||
| import java.time.LocalDateTime; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.NAME; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.REMARK; | |||
| @@ -65,7 +65,7 @@ public class DmRecognizedRecordsPo extends TBaseEntity { | |||
| /** 识别时间 */ | |||
| @Excel(name = "识别时间") | |||
| protected Date recognizedTime; | |||
| protected LocalDateTime recognizedTime; | |||
| /** 所属组织ID */ | |||
| @Excel(name = "所属组织ID") | |||
| @@ -3,6 +3,8 @@ package com.xueyi.system.api.staff.domain.dto; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| /** | |||
| * 访客及数据的 数据传输对象 | |||
| * | |||
| @@ -36,6 +38,9 @@ public class DmVisitCommonDto { | |||
| private String visitorBase64Img; | |||
| public String toSmsJson(String code, String name, String companyName, String companyAddress, String parkInfo){ | |||
| JSONObject json = new JSONObject(); | |||
| json.put("code", code); | |||
| @@ -0,0 +1,25 @@ | |||
| package com.xueyi.system.api.staff.domain.dto; | |||
| import com.alibaba.fastjson2.JSON; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| /** | |||
| * 访客及数据的 数据传输对象 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Data | |||
| public class GraphqlVisitRecordInput { | |||
| private Date visitDate; | |||
| private Long visitorId; | |||
| @Override | |||
| public String toString() { | |||
| return JSON.toJSONString(this); | |||
| } | |||
| } | |||
| @@ -35,6 +35,9 @@ public interface RemoteStaffService { | |||
| @GetMapping("/staff/inner-api/selectOne/{staffId}") | |||
| JSONObject fetchStaff(@RequestParam(value = "staffId") String staffId, @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/staff/inner-api/selectByPhone") | |||
| JSONObject fetchStaffByPhone(@RequestParam(value = "phone") String phone, @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/staff/inner/tenantId/{enterpriseName}") | |||
| public R<SysEnterpriseDto> tenantIdInner(@RequestParam(value = "enterpriseName") String enterpriseName) ; | |||
| @@ -45,6 +48,9 @@ public interface RemoteStaffService { | |||
| @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/inner-api/init-attendance") | |||
| JSONObject initAttendance(@RequestParam(value = "tenantId") Long tenantId, @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(); | |||
| @@ -14,17 +14,19 @@ import java.io.Serial; | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| @TableName(value = "dm_enterprise_staff") | |||
| @TableName(value = "sys_enterprise_staff", excludeProperty = {"name","sort","createBy","createTime","updateBy","updateTime","remark","tenantId", "status"}) | |||
| public class SysEnterpriseStaff extends TBaseEntity { | |||
| @Serial | |||
| private static final long serialVersionUID = 1L; | |||
| protected Long id; | |||
| protected Long staffId; | |||
| protected String phone; | |||
| private Long tenantId; | |||
| private Long tId;//租户号 | |||
| private String openid; | |||
| } | |||
| @@ -42,11 +42,14 @@ public interface RemoteTenantService { | |||
| R<TeTenantPo> tenant(@RequestParam ("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/tenant/staff") | |||
| R<SysEnterpriseStaff> existStaff(@RequestParam ("phone") String phone, @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); | |||
| @GetMapping("/tenant/query-staff-by-phone") | |||
| R<SysEnterpriseStaff> queryStaff(@RequestParam ("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @PostMapping("/tenant/staff") | |||
| @PostMapping("/tenant/save-staff") | |||
| R<SysEnterpriseStaff> saveEnterpriseStaff(@RequestBody SysEnterpriseStaff staff, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| } | |||
| @@ -44,13 +44,19 @@ public class RemoteTenantFallbackFactory implements FallbackFactory<RemoteTenant | |||
| } | |||
| @Override | |||
| public R<SysEnterpriseStaff> existStaff(String phone, String source) { | |||
| public R<TeTenantPo> queryTenantByStaffPhone(String phone, String source) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public R<SysEnterpriseStaff> queryStaff(String phone, String source) { | |||
| return R.fail("验证用户手机号失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public R<SysEnterpriseStaff> saveEnterpriseStaff(SysEnterpriseStaff staff, String source) { | |||
| return null; | |||
| return R.fail("保存员工失败:" + throwable.getMessage()); | |||
| } | |||
| }; | |||
| } | |||
| @@ -73,7 +73,7 @@ public class TokenController { | |||
| private RedisTemplate<String, String> redisTemplate; | |||
| private final String REDIS_LOGIN_CODE_PIX = "saas:login:code:"; | |||
| private final static String REDIS_LOGIN_CODE_PIX = "saas:login:code:"; | |||
| @PostMapping("login") | |||
| public AjaxResult login(@RequestBody LoginBody form) { | |||
| @@ -139,8 +139,8 @@ public class TokenController { | |||
| @GetMapping("validCode") | |||
| public R validCode(@RequestParam String phone) { | |||
| R<SysEnterpriseStaff> staff = tenantService.existStaff(phone, SecurityConstants.INNER); | |||
| public R<String> validCode(@RequestParam String phone) { | |||
| R<SysEnterpriseStaff> staff = tenantService.queryStaff(phone, SecurityConstants.INNER); | |||
| if (staff.getData() == null) { | |||
| return R.fail("手机号不存在,请查验"); | |||
| } | |||
| @@ -1,5 +1,6 @@ | |||
| package com.xueyi.common.core.web.result; | |||
| import com.alibaba.fastjson2.JSON; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.common.core.constant.basic.Constants; | |||
| @@ -119,4 +120,9 @@ public class R<T> implements Serializable { | |||
| } | |||
| return json; | |||
| } | |||
| @Override | |||
| public String toString(){ | |||
| return JSON.toJSONString(this); | |||
| } | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.xueyi.common.security.interceptor; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.constant.basic.TenantConstants; | |||
| import com.xueyi.common.core.context.SecurityContextHolder; | |||
| import com.xueyi.common.core.utils.JwtUtil; | |||
| import com.xueyi.common.core.utils.ServletUtil; | |||
| import com.xueyi.common.core.utils.core.ObjectUtil; | |||
| import com.xueyi.common.core.utils.core.StrUtil; | |||
| @@ -43,6 +44,11 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor { | |||
| 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); | |||
| TenantConstants.AccountType accountType = TenantConstants.AccountType.getByCode(SecurityUtils.getAccountType()); | |||
| if(ObjectUtil.isNotNull(accountType)) { | |||
| AuthUtil.verifyLoginUserExpire(token, accountType); | |||
| @@ -24,7 +24,7 @@ public class WebApiMvcConfig implements WebMvcConfigurer { | |||
| System.err.println("WebMvcConfig.addInterceptors======================hshshkbb"); | |||
| registry.addInterceptor(getApiInterceptor()) | |||
| .addPathPatterns("/8888") | |||
| .addPathPatterns("/**/graphql/**") | |||
| // .addPathPatterns("/**") | |||
| .excludePathPatterns(excludeUrls) | |||
| .order(1); | |||
| @@ -1,13 +1,11 @@ | |||
| package com.xueyi.common.web.interceptor; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.alibaba.csp.sentinel.util.StringUtil; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.context.SecurityContextHolder; | |||
| import com.xueyi.common.core.utils.DecodeRequestUtils; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.common.web.entity.domain.mapper.DeviceTenantMergeMapper; | |||
| import com.xueyi.system.api.device.feign.RemoteDeviceTenantMergeService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -41,22 +39,29 @@ public class ApiRequestInterceptor implements HandlerInterceptor { | |||
| return true; | |||
| } | |||
| String str = DecodeRequestUtils.getRequestPostStr(request); | |||
| String deviceId = request.getHeader("deviceId"); | |||
| logger.info("请求头参数:deviceId={}", deviceId); | |||
| String token = request.getHeader("Authorization"); | |||
| logger.info("请求头参数:Authorization={}", token); | |||
| /* String str = DecodeRequestUtils.getRequestPostStr(request); | |||
| logger.info("请求参数:{}", str); | |||
| JSONObject jsonObject = null; | |||
| if (str.indexOf("{")>-1) { | |||
| jsonObject = JSONObject.parseObject(str);// 解析请求参数 | |||
| } | |||
| }*/ | |||
| if ((request.getParameterMap().containsKey("deviceId")||request.getParameterMap().containsKey("devId")) || (jsonObject!=null && (jsonObject.containsKey("deviceId")||jsonObject.containsKey("devId")))) { | |||
| String devId = request.getParameter("deviceId"); | |||
| // if ((request.getParameterMap().containsKey("deviceId")||request.getParameterMap().containsKey("devId")) || (jsonObject!=null && (jsonObject.containsKey("deviceId")||jsonObject.containsKey("devId")))) { | |||
| if (StringUtil.isNotBlank(deviceId)) { | |||
| /*String devId = request.getParameter("deviceId"); | |||
| devId = StringUtils.isEmpty(devId) ? request.getParameter("devId") : devId; | |||
| if (StringUtils.isEmpty(devId) && jsonObject != null) { | |||
| devId = jsonObject.getString("deviceId"); | |||
| devId = StringUtils.isEmpty(devId) ? jsonObject.getString("devId") : devId; | |||
| } | |||
| }*/ | |||
| /*DeviceTenantSourceMergeVo vo = null; | |||
| if (RedisUtil.existed("saas:source:device:" + devId)) { | |||
| @@ -66,7 +71,7 @@ public class ApiRequestInterceptor implements HandlerInterceptor { | |||
| RedisUtil.setVal("saas:source:device:" + devId, vo); | |||
| }*/ | |||
| DeviceTenantSourceMergeVo vo = mergeMapper.selectByDeviceId(devId);// 查询设备与租户、来源的关联关系 | |||
| DeviceTenantSourceMergeVo vo = mergeMapper.selectByDeviceId(deviceId);// 查询设备与租户、来源的关联关系 | |||
| SecurityContextHolder.setEnterpriseId(vo.getTenantId().toString());// 设置企业ID | |||
| SecurityContextHolder.setSourceName(vo.getSourceSlave());// 设置数据源名称 | |||
| SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER);// 设置数据来源 | |||
| @@ -16,8 +16,14 @@ import java.util.Date; | |||
| import java.util.GregorianCalendar; | |||
| import java.util.List; | |||
| public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| public DateUtils() { | |||
| public class MyDateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| public static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss"; | |||
| public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd"; | |||
| public static final String DEFAULT_NO_SECOND_DATE_PATTERN = "yyyy-MM-dd HH:mm"; | |||
| public static final String DEFAULT_TIME_PATTERN = "HH:mm"; | |||
| public static final String DEFAULT_FULL_TIME_PATTERN = "HH:mm:ss"; | |||
| public MyDateUtils() { | |||
| super(); | |||
| } | |||
| public static Date getPushForwardDate(Date date, Integer num) { | |||
| @@ -94,7 +100,7 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| } | |||
| public static Date getFirstDayOfMonth(Date date) { | |||
| new SimpleDateFormat("yyyy-MM-dd "); | |||
| new SimpleDateFormat(DEFAULT_DATE_PATTERN); | |||
| GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance(); | |||
| gcLast.setTime(date); | |||
| gcLast.set(Calendar.DAY_OF_MONTH, 1); | |||
| @@ -123,7 +129,7 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| calendar.setTime(dNow); | |||
| calendar.add(5, -1); | |||
| Date dBefore = calendar.getTime(); | |||
| SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |||
| SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_PATTERN); | |||
| return sdf.format(dBefore); | |||
| } | |||
| @@ -134,7 +140,7 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| * @return java.lang.String | |||
| **/ | |||
| public static String dateToWeek(String datetime) { | |||
| SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); | |||
| SimpleDateFormat f = new SimpleDateFormat(DEFAULT_DATE_PATTERN); | |||
| String[] weekDays = new String[]{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}; | |||
| Calendar cal = Calendar.getInstance(); | |||
| Date datet = null; | |||
| @@ -157,11 +163,9 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| public static String getDatePoor(Date endDate, Date nowDate) { | |||
| long nd = 86400000L; | |||
| long nh = 3600000L; | |||
| long nm = 60000L; | |||
| long diff = endDate.getTime() - nowDate.getTime(); | |||
| long day = diff / nd; | |||
| long hour = diff % nd / nh; | |||
| long min = diff % nd % nh / nm; | |||
| return day + ":" + hour; | |||
| } | |||
| @@ -185,7 +189,7 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| for (int i = 0; i < nearlyDays; ++i) { | |||
| calendar.add(5, i == 0 ? 0 : -1); | |||
| dateStringList.add(formatDate(calendar.getTime(), "yyyy-MM-dd")); | |||
| dateStringList.add(formatDate(calendar.getTime(), DEFAULT_DATE_PATTERN)); | |||
| } | |||
| return dateStringList; | |||
| @@ -261,7 +265,7 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| Calendar calendar = Calendar.getInstance(); | |||
| calendar.setTimeInMillis(dateLong); | |||
| Date date = calendar.getTime(); | |||
| return formatDate(date, "yyyy-MM-dd HH:mm:ss"); | |||
| return formatDate(date, DEFAULT_PATTERN); | |||
| } | |||
| public static String getMillsSecondsDouble() { | |||
| @@ -286,15 +290,14 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| //形如yyyy-MM-dd格式的时间串,赠加或减少几天 | |||
| //如2022-06-06 增加一天 返回 2022-06-07 | |||
| public static String dateStrAdd(String dateStr, int addDays) { | |||
| Date date1 = DateUtils.parseStrToDate(dateStr, "yyyy-MM-dd"); | |||
| Date date2 = DateUtils.addDays(date1, addDays); | |||
| String dateStr2 = DateUtils.formatDate(date2, "yyyy-MM-dd"); | |||
| return dateStr2; | |||
| Date date1 = parseStrToDate(dateStr, DEFAULT_DATE_PATTERN); | |||
| Date date2 = org.apache.commons.lang3.time.DateUtils.addDays(date1, addDays); | |||
| return MyDateUtils.formatDate(date2, DEFAULT_DATE_PATTERN); | |||
| } | |||
| public static int dateStrDiff(String startDateStr, String endDateStr) { | |||
| Date date1 = DateUtils.parseStrToDate(startDateStr, "yyyy-MM-dd"); | |||
| Date date2 = DateUtils.parseStrToDate(endDateStr, "yyyy-MM-dd"); | |||
| Date date1 = parseStrToDate(startDateStr, DEFAULT_DATE_PATTERN); | |||
| Date date2 = parseStrToDate(endDateStr, DEFAULT_DATE_PATTERN); | |||
| Calendar cal1 = Calendar.getInstance(); | |||
| cal1.setTime(date1); | |||
| @@ -331,11 +334,20 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| public static LocalDateTime dateToLocalDateTime(Date date) { | |||
| LocalDateTime ldt = date.toInstant() | |||
| return date.toInstant() | |||
| .atZone(ZoneId.systemDefault()) | |||
| .toLocalDateTime(); | |||
| return ldt; | |||
| } | |||
| public static Date localDateToDate(LocalDate date) { | |||
| LocalDateTime ldt = date.atStartOfDay(); | |||
| return localDateTimeToDate(ldt); | |||
| } | |||
| public static Date localDateTimeToDate(LocalDateTime date) { | |||
| return Date.from(date.atZone(ZoneId.systemDefault()).toInstant()); | |||
| } | |||
| public static String isAmPm() { | |||
| @@ -350,7 +362,7 @@ public class DateUtils extends org.apache.commons.lang.time.DateUtils { | |||
| } | |||
| public static String getChineseWeek(Date date) { | |||
| int week = LocalDate.parse(new SimpleDateFormat("yyyy-MM-dd").format(date)).getDayOfWeek().getValue(); | |||
| int week = LocalDate.parse(new SimpleDateFormat(DEFAULT_DATE_PATTERN).format(date)).getDayOfWeek().getValue(); | |||
| switch (week) { | |||
| case 1: | |||
| return "周一"; | |||
| @@ -1,12 +1,18 @@ | |||
| package com.xueyi.job.task; | |||
| import com.alibaba.fastjson2.JSON; | |||
| import com.xueyi.common.cache.utils.SourceUtil; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.utils.core.StrUtil; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.security.service.TokenService; | |||
| import com.xueyi.system.api.digitalmans.feign.RemoteManDeviceService; | |||
| import com.xueyi.system.api.model.Source; | |||
| import com.xueyi.system.api.staff.feign.RemoteStaffService; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import org.antlr.runtime.Token; | |||
| import org.slf4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| @@ -19,6 +25,7 @@ import java.util.List; | |||
| */ | |||
| @Component("dgmanTask") | |||
| public class DgmanTask { | |||
| Logger log = org.slf4j.LoggerFactory.getLogger(DgmanTask.class); | |||
| @Autowired | |||
| RemoteTenantService tenantService; | |||
| @@ -26,23 +33,24 @@ public class DgmanTask { | |||
| @Autowired | |||
| RemoteManDeviceService remoteManDeviceService; | |||
| @Autowired | |||
| RemoteStaffService staffService; | |||
| public void ryParams(String params) { | |||
| System.out.println(StrUtil.format("执行有参方法:参数{}", params)); | |||
| log.info(StrUtil.format("执行有参方法:参数{}", params)); | |||
| } | |||
| public void dgmanMonitor() { | |||
| R<List<TeTenantDto>> listR = tenantService.tenantList(); | |||
| if (listR.isFail()) { | |||
| System.out.println("租户列表获取失败"); | |||
| log.info("租户列表获取失败"); | |||
| return; | |||
| } | |||
| listR.getData().forEach(item->{ | |||
| // 获取数据源 | |||
| Source source = SourceUtil.getSourceCache(item.getStrategyId()); | |||
| // 更新租户内数字人信息 | |||
| remoteManDeviceService.manDeviceListInnerSync(item.getId()); | |||
| }); | |||
| System.out.println("监控心跳执行完成"); | |||
| log.info("监控心跳执行完成"); | |||
| } | |||
| @@ -53,4 +61,26 @@ public class DgmanTask { | |||
| public void dgmanDeviceOnlineState() { | |||
| remoteManDeviceService.syncNumbersOfOnline(); | |||
| } | |||
| public void initStaffAttendances() { | |||
| log.info("=======考勤数据初始化开始。。。。========"); | |||
| R<List<TeTenantDto>> listR = tenantService.tenantList(); | |||
| if (listR.isFail()) { | |||
| log.info("租户列表获取失败"); | |||
| return; | |||
| } | |||
| listR.getData().forEach(item->{ | |||
| // 获取数据源 | |||
| Source source = SourceUtil.getSourceCache(item.getStrategyId()); | |||
| log.info("souce id:{}", JSON.toJSONString(source)); | |||
| // 更新租户内数字人信息 | |||
| log.info("=======初始化考勤数据,租户id:{},getSourceName:{} ========", item.getId(), source.getMaster()); | |||
| staffService.initAttendance(item.getId(), item.getId(), source.getMaster(), SecurityConstants.INNER); | |||
| }); | |||
| log.info("=======考勤数据初始化完成。。。========"); | |||
| } | |||
| } | |||
| @@ -11,7 +11,7 @@ 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.utils.RedisUtil; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.message.api.transfer.domain.vo.DmActiveVo; | |||
| import com.xueyi.message.api.transfer.domain.vo.DmDeviceVo; | |||
| import com.xueyi.message.transfer.service.impl.MessageQueueServiceImpl; | |||
| @@ -353,8 +353,8 @@ public class ApiController { | |||
| 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"); | |||
| Date date = MyDateUtils.addDays(new Date(), -i); | |||
| String dateStr2 = MyDateUtils.formatDate(date, MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| JSONObject json2 = new JSONObject(); | |||
| json2.put("date", dateStr2); | |||
| json2.put("serviceTimes", RedisUtil.getNumberVal("dashboard:server-chart:"+dateStr2)); | |||
| @@ -135,10 +135,10 @@ public class WebSocketClient extends WebSocketListener { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public void sendMsg(List<String> messages){ | |||
| this.sendMsg(messages,false, null); | |||
| public WebSocketClient sendMsg(List<String> messages){ | |||
| return this.sendMsg(messages,false, "null"); | |||
| } | |||
| public void sendMsg(List<String> messages,boolean stream,String userId){ | |||
| public WebSocketClient sendMsg(List<String> messages,boolean stream,String userId){ | |||
| this.stream = stream; | |||
| this.curUserId = userId; | |||
| if (messages.size() / 2 > 0) { | |||
| @@ -164,9 +164,10 @@ public class WebSocketClient extends WebSocketListener { | |||
| ServerConfig.currentTraceMap.put(curUserId,wsc.traceId); | |||
| System.out.println("wocket客户端:" + wsc.hashCode()); | |||
| webSocket = okHttpClient.newWebSocket(request,wsc); | |||
| return wsc; | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| return null; | |||
| } | |||
| } | |||
| //鉴权url | |||
| @@ -283,148 +284,155 @@ public class WebSocketClient extends WebSocketListener { | |||
| return; | |||
| } | |||
| } | |||
| ResponseData responseData = json.fromJson(text,ResponseData.class); | |||
| try { | |||
| // System.out.println("code:\n" + responseData.getHeader().get("code")); | |||
| if (0 == responseData.getHeader().get("code").getAsInt()) { | |||
| System.out.println("###########"); | |||
| System.out.println("getStatus: " + responseData.getHeader().get("status").getAsInt()); | |||
| if (2 != responseData.getHeader().get("status").getAsInt()) { | |||
| System.out.println("****************"); | |||
| Payload pl = json.fromJson(responseData.getPayload(), Payload.class); | |||
| JsonArray temp = (JsonArray) pl.getChoices().get("text"); | |||
| JsonObject jo = (JsonObject) temp.get(0); | |||
| answer += jo.get("content").getAsString(); | |||
| answerBuf += jo.get("content").getAsString(); | |||
| synchronized (this) { | |||
| ResponseData responseData = json.fromJson(text,ResponseData.class); | |||
| try { | |||
| // System.out.println("code:\n" + responseData.getHeader().get("code")); | |||
| if (0 == responseData.getHeader().get("code").getAsInt()) { | |||
| System.out.println("###########"); | |||
| System.out.println("getStatus: " + responseData.getHeader().get("status").getAsInt()); | |||
| if (2 != responseData.getHeader().get("status").getAsInt()) { | |||
| System.out.println("****************"); | |||
| Payload pl = json.fromJson(responseData.getPayload(), Payload.class); | |||
| JsonArray temp = (JsonArray) pl.getChoices().get("text"); | |||
| JsonObject jo = (JsonObject) temp.get(0); | |||
| answer += jo.get("content").getAsString(); | |||
| answerBuf += jo.get("content").getAsString(); | |||
| // System.out.println(answer); | |||
| } else { | |||
| Payload pl1 = json.fromJson(responseData.getPayload(), Payload.class); | |||
| JsonObject jsonObject = (JsonObject) pl1.getUsage().get("text"); | |||
| int prompt_tokens = jsonObject.get("prompt_tokens").getAsInt(); | |||
| JsonArray temp1 = (JsonArray) pl1.getChoices().get("text"); | |||
| JsonObject jo = (JsonObject) temp1.get(0); | |||
| answer += jo.get("content").getAsString(); | |||
| answerBuf += jo.get("content").getAsString(); | |||
| System.out.println("返回结果为:\n" + answer); | |||
| if (INSTANCE.redisTemplate.hasKey("gpt:websocket:1")) { | |||
| DmWebSocketMessageVo message = (DmWebSocketMessageVo) INSTANCE.redisTemplate.opsForValue().get("gpt:websocket:1"); | |||
| if (message != null && 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 (message!= null && 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()); | |||
| } else { | |||
| Payload pl1 = json.fromJson(responseData.getPayload(), Payload.class); | |||
| JsonObject jsonObject = (JsonObject) pl1.getUsage().get("text"); | |||
| int prompt_tokens = jsonObject.get("prompt_tokens").getAsInt(); | |||
| JsonArray temp1 = (JsonArray) pl1.getChoices().get("text"); | |||
| JsonObject jo = (JsonObject) temp1.get(0); | |||
| answer += jo.get("content").getAsString(); | |||
| answerBuf += jo.get("content").getAsString(); | |||
| System.out.println("返回结果为:\n" + answer); | |||
| if (INSTANCE.redisTemplate.hasKey("gpt:websocket:1")) { | |||
| DmWebSocketMessageVo message = (DmWebSocketMessageVo) INSTANCE.redisTemplate.opsForValue().get("gpt:websocket:1"); | |||
| if (message != null && 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"); | |||
| this.notifyAll(); | |||
| return; | |||
| } | |||
| if (message!= null && 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"); | |||
| this.notifyAll(); | |||
| return; | |||
| } | |||
| if (message != null) { | |||
| JSONObject preWebsocketJo = message.getFormat(); | |||
| JSONObject meetingJo = new JSONObject(); | |||
| meetingJo.put("timestamp",preWebsocketJo.get("timestamp")); | |||
| meetingJo.put("content",answer); | |||
| INSTANCE.stringRedisTemplate.opsForHash().put("group:nlp" + ":" + preWebsocketJo.getString("orderId"), "meeting", meetingJo.toString()); | |||
| this.notifyAll(); | |||
| return; | |||
| } | |||
| INSTANCE.redisTemplate.delete("gpt:websocket:1"); | |||
| return; | |||
| // 清除systemRole | |||
| systemRole = ""; | |||
| }else { | |||
| // 添加上下文 | |||
| INSTANCE.redisTemplate.opsForList().rightPush("group:nlp:null:-1", questions.get(questions.size() - 1)); | |||
| INSTANCE.redisTemplate.opsForList().rightPush("group:nlp:null:-1", answer); | |||
| // 添加缓存 | |||
| INSTANCE.stringRedisTemplate.opsForValue().set("group:websocket:content", answer); | |||
| } | |||
| if (message != null) { | |||
| JSONObject preWebsocketJo = message.getFormat(); | |||
| JSONObject meetingJo = new JSONObject(); | |||
| meetingJo.put("timestamp",preWebsocketJo.get("timestamp")); | |||
| meetingJo.put("content",answer); | |||
| INSTANCE.stringRedisTemplate.opsForHash().put("group:nlp" + ":" + preWebsocketJo.getString("orderId"), "meeting", meetingJo.toString()); | |||
| this.notifyAll(); | |||
| // webSocket.close(3,"客户端主动断开链接"); | |||
| //webSocket.close(1000,"客户端主动断开链接"); | |||
| } | |||
| if (this.stream && !StringUtils.isEmpty(curUserId)) { | |||
| Channel ch = ServerConfig.sessionMap.get(curUserId); | |||
| logger.info("当前ch:{}",ch.id().asLongText()); | |||
| if (ch != null) { | |||
| List<String> ttsList = new ArrayList<>(); | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",traceId); | |||
| //去除转义符 | |||
| answerBuf = answerBuf.replaceAll("[\\r\\n]", ""); | |||
| //去除引号 | |||
| answerBuf = answerBuf.replaceAll("\"", ""); | |||
| // 处理answer,如果包含"。",则将"。"之前的内容发送给前端 | |||
| while(answerBuf.contains("。") || answerBuf.contains("?") || answerBuf.contains("!") || | |||
| answerBuf.contains("?") || answerBuf.contains("!")) { | |||
| String[] temp = answerBuf.split("。|?|!|\\?|\\!"); | |||
| ttsList.add(temp[0] + answerBuf.charAt(temp[0].length())); | |||
| answerBuf = answerBuf.substring(temp[0].length() + 1); | |||
| } | |||
| if (2 == responseData.getHeader().get("status").getAsInt() && CollectionUtils.isEmpty(ttsList)) { | |||
| jo.put("tts",answerBuf); | |||
| jo.put("status",2); | |||
| logger.info("发送到client:{},id:{},内容:{}",curUserId,ch.id().asLongText(),jo.toJSONString()); | |||
| ch.writeAndFlush(new TextWebSocketFrame(jo.toJSONString())); | |||
| } else { | |||
| for (int i = 0;i <ttsList.size();i++) { | |||
| if (2 == responseData.getHeader().get("status").getAsInt() && i == ttsList.size() - 1) { | |||
| jo.put("status",2); | |||
| } else { | |||
| jo.put("status",1); | |||
| } | |||
| jo.put("tts",ttsList.get(i)); | |||
| String str = jo.toJSONString(); | |||
| logger.info("发送到client:{},id:{},内容:{}",curUserId,ch.id().asLongText(),jo.toJSONString()); | |||
| ch.writeAndFlush(new TextWebSocketFrame(str)); | |||
| } | |||
| } | |||
| } | |||
| INSTANCE.redisTemplate.delete("gpt:websocket:1"); | |||
| // 清除systemRole | |||
| systemRole = ""; | |||
| }else { | |||
| // 添加上下文 | |||
| INSTANCE.redisTemplate.opsForList().rightPush("group:nlp:null:-1", questions.get(questions.size() - 1)); | |||
| INSTANCE.redisTemplate.opsForList().rightPush("group:nlp:null:-1", answer); | |||
| // 添加缓存 | |||
| INSTANCE.stringRedisTemplate.opsForValue().set("group:websocket:content", answer); | |||
| } | |||
| // webSocket.close(3,"客户端主动断开链接"); | |||
| //webSocket.close(1000,"客户端主动断开链接"); | |||
| } | |||
| if (this.stream && !StringUtils.isEmpty(curUserId)) { | |||
| Channel ch = ServerConfig.sessionMap.get(curUserId); | |||
| logger.info("当前ch:{}",ch.id().asLongText()); | |||
| if (ch != null) { | |||
| List<String> ttsList = new ArrayList<>(); | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",traceId); | |||
| //去除转义符 | |||
| answerBuf = answerBuf.replaceAll("[\\r\\n]", ""); | |||
| //去除引号 | |||
| answerBuf = answerBuf.replaceAll("\"", ""); | |||
| // 处理answer,如果包含"。",则将"。"之前的内容发送给前端 | |||
| while(answerBuf.contains("。") || answerBuf.contains("?") || answerBuf.contains("!") || | |||
| answerBuf.contains("?") || answerBuf.contains("!")) { | |||
| String[] temp = answerBuf.split("。|?|!|\\?|\\!"); | |||
| ttsList.add(temp[0] + answerBuf.charAt(temp[0].length())); | |||
| answerBuf = answerBuf.substring(temp[0].length() + 1); | |||
| } | |||
| if (2 == responseData.getHeader().get("status").getAsInt() && CollectionUtils.isEmpty(ttsList)) { | |||
| jo.put("tts",answerBuf); | |||
| } else { | |||
| // 添加缓存 | |||
| INSTANCE.stringRedisTemplate.opsForValue().set("group:websocket:content", "-1"); | |||
| // 判断流式则返回结束状态 | |||
| if (stream == true) { | |||
| Channel ch = ServerConfig.sessionMap.get(curUserId); | |||
| if (ch != null) { | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",traceId); | |||
| jo.put("status",2); | |||
| jo.put("tts","抱歉,您的问题我无法解答。"); | |||
| String str = jo.toJSONString(); | |||
| logger.info("发送到client:{},id:{},内容:{}",curUserId,ch.id().asLongText(),jo.toJSONString()); | |||
| ch.writeAndFlush(new TextWebSocketFrame(jo.toJSONString())); | |||
| } else { | |||
| for (int i = 0;i <ttsList.size();i++) { | |||
| if (2 == responseData.getHeader().get("status").getAsInt() && i == ttsList.size() - 1) { | |||
| jo.put("status",2); | |||
| } else { | |||
| jo.put("status",1); | |||
| } | |||
| jo.put("tts",ttsList.get(i)); | |||
| String str = jo.toJSONString(); | |||
| logger.info("发送到client:{},id:{},内容:{}",curUserId,ch.id().asLongText(),jo.toJSONString()); | |||
| ch.writeAndFlush(new TextWebSocketFrame(str)); | |||
| } | |||
| ch.writeAndFlush(new TextWebSocketFrame(str)); | |||
| } | |||
| } | |||
| System.out.println("返回结果错误:\n" + responseData.getHeader().get("code") + responseData.getHeader().get("message")); | |||
| this.notifyAll(); | |||
| } | |||
| } else { | |||
| // 添加缓存 | |||
| INSTANCE.stringRedisTemplate.opsForValue().set("group:websocket:content", "-1"); | |||
| // 判断流式则返回结束状态 | |||
| if (stream == true) { | |||
| } catch (Exception e) { | |||
| if (StringUtils.isNotEmpty(curUserId)) { | |||
| Channel ch = ServerConfig.sessionMap.get(curUserId); | |||
| if (ch != null) { | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",traceId); | |||
| jo.put("status",2); | |||
| jo.put("tts","抱歉,您的问题我无法解答。"); | |||
| String str = jo.toJSONString(); | |||
| logger.info("发送到client:{},id:{},内容:{}",curUserId,ch.id().asLongText(),jo.toJSONString()); | |||
| ch.writeAndFlush(new TextWebSocketFrame(str)); | |||
| } | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",traceId); | |||
| jo.put("status",2); | |||
| jo.put("tts","大模型出现异常,请稍后重试。"); | |||
| String str = jo.toJSONString(); | |||
| logger.info("发生异常client:{},内容:{}",curUserId,jo.toJSONString()); | |||
| ch.writeAndFlush(new TextWebSocketFrame(str)); | |||
| } | |||
| System.out.println("返回结果错误:\n" + responseData.getHeader().get("code") + responseData.getHeader().get("message")); | |||
| LOCK.notifyAll(); | |||
| } | |||
| } catch (Exception e) { | |||
| if (StringUtils.isNotEmpty(curUserId)) { | |||
| Channel ch = ServerConfig.sessionMap.get(curUserId); | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",traceId); | |||
| jo.put("status",2); | |||
| jo.put("tts","大模型出现异常,请稍后重试。"); | |||
| String str = jo.toJSONString(); | |||
| logger.info("发生异常client:{},内容:{}",curUserId,jo.toJSONString()); | |||
| ch.writeAndFlush(new TextWebSocketFrame(str)); | |||
| e.printStackTrace(); | |||
| this.notifyAll(); | |||
| } | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| @@ -11,6 +11,7 @@ import com.xueyi.common.core.constant.digitalman.SkillConstants.SkillType; | |||
| import com.xueyi.common.core.context.SecurityContextHolder; | |||
| import com.xueyi.common.core.utils.DateUtil; | |||
| import com.xueyi.common.core.utils.core.IdUtil; | |||
| import com.xueyi.common.core.utils.core.SpringUtils; | |||
| 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; | |||
| @@ -34,6 +35,9 @@ import com.xueyi.nlt.api.nlt.feign.RemoteLandingLlmService; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteQAService; | |||
| import com.xueyi.nlt.netty.client.WebSocketClient; | |||
| import com.xueyi.nlt.nlt.context.TerminalSecurityContextHolder; | |||
| import com.xueyi.nlt.nlt.domain.LlmContext; | |||
| import com.xueyi.nlt.nlt.domain.LlmParam; | |||
| import com.xueyi.nlt.nlt.domain.LlmResponse; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmIntentDto; | |||
| import com.xueyi.nlt.nlt.domain.po.DmRegularPo; | |||
| import com.xueyi.nlt.nlt.domain.query.DmIntentQuery; | |||
| @@ -41,6 +45,7 @@ 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.ISysLlmService; | |||
| import com.xueyi.nlt.nlt.template.*; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmSkillDto; | |||
| @@ -160,6 +165,9 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| @Autowired | |||
| private FlightMessageTemplate flightMessageTemplate; | |||
| @Autowired | |||
| private ISysLlmService sysLlmService; | |||
| /** | |||
| * 意图请求 | |||
| 列表 | |||
| @@ -271,7 +279,8 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| System.out.println("timestamp:" + jo.get("timestamp")); | |||
| System.out.println("currenttime:" + System.currentTimeMillis()); | |||
| if(jo.containsKey("timestamp") && | |||
| Double.valueOf(String.valueOf(jo.get("timestamp"))) - System.currentTimeMillis() < 1800000) { | |||
| (Double.valueOf(String.valueOf(jo.get("timestamp"))) - System.currentTimeMillis() < 1800000 && | |||
| Double.valueOf(String.valueOf(jo.get("timestamp"))) - System.currentTimeMillis() > 0)) { | |||
| joResult.put("msg",jo.get("content")); | |||
| joResult.put("target",1); | |||
| redisTemplate.opsForHash().delete("group:nlp" + ":" + recognition.getPersonId(), "meeting"); | |||
| @@ -415,6 +424,16 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| response.setH5(joImage); | |||
| } | |||
| } | |||
| } else if (resultJson.get("status").equals("failed")) { | |||
| response.setMsg("大模型出现异常,请稍后重试。"); | |||
| JSONObject joImage = new JSONObject(); | |||
| joImage.put("msg","抱歉,您的问题我无法解答。"); | |||
| response.setH5(joImage); | |||
| } else if (resultJson.get("status").equals("disallowed")) { | |||
| response.setMsg("抱歉,您的问题我无法解答。"); | |||
| JSONObject joImage = new JSONObject(); | |||
| joImage.put("msg","抱歉,您的问题我无法解答。"); | |||
| response.setH5(joImage); | |||
| } | |||
| return AjaxResult.success(response); | |||
| } | |||
| @@ -567,7 +586,6 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| @PostMapping("/inner/sendMessage") | |||
| @ResponseBody | |||
| public R<Object> sendMessage(@RequestBody DmWebSocketMessageVo message) { | |||
| log.info("websocket sendMessage:{}", message); | |||
| if (message == null || message.getFormat() == null) { | |||
| return R.fail("参数为空"); | |||
| @@ -579,23 +597,34 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| 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); | |||
| LlmContext context = new LlmContext(prefix); | |||
| LlmResponse response = sysLlmService.chat(context, new LlmParam()); | |||
| JSONObject birthdayJo = new JSONObject(); | |||
| birthdayJo.put("content", response.getContent()); | |||
| birthdayJo.put("timestamp", message.getFormat().get("timestamp")); | |||
| redisTemplate.opsForHash().put("group:nlp" + ":" + message.getFormat().getString("orderId"), "birthday", birthdayJo.toString()); | |||
| 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); | |||
| LlmContext context = new LlmContext(prefix); | |||
| LlmResponse response = sysLlmService.chat(context, new LlmParam()); | |||
| JSONObject hireDateJo = new JSONObject(); | |||
| hireDateJo.put("content", response.getContent()); | |||
| hireDateJo.put("timestamp", message.getFormat().get("timestamp")); | |||
| redisTemplate.opsForHash().put("group:nlp" + ":" + message.getFormat().getString("orderId"), "hireDate", hireDateJo.toString()); | |||
| return R.ok(); | |||
| } | |||
| Date date = new Date(timestamp.longValue()); | |||
| if (message.getSkillCode().equals("1")) { | |||
| String prefix = "假设你是一名公司前台,你看到在你们公司工作的\\"+ jo.getString("orderName")+ "\\,请你从个人角度提醒他参加\\" + | |||
| dateFormat4.format(timestamp) + "\\在\\" + meetingRoom + "\\的会,要求语气友好。输出只包含你要对他说的话,在20字左右。"; | |||
| webSocketClient.sendMsg(prefix); | |||
| // 设置缓存 | |||
| redisTemplate2.opsForValue().set("gpt:websocket" + ":" + "1", message); | |||
| LlmContext context = new LlmContext(prefix); | |||
| LlmResponse response = sysLlmService.chat(context, new LlmParam()); | |||
| JSONObject meetingJo = new JSONObject(); | |||
| meetingJo.put("content", response.getContent()); | |||
| meetingJo.put("timestamp", message.getFormat().get("timestamp")); | |||
| redisTemplate.opsForHash().put("group:nlp" + ":" + message.getFormat().getString("orderId"), "meeting", meetingJo.toString()); | |||
| } | |||
| return R.ok(); | |||
| } | |||
| @@ -1,5 +1,6 @@ | |||
| package com.xueyi.nlt.nlt.service.impl; | |||
| import com.xueyi.common.core.utils.core.SpringUtils; | |||
| import com.xueyi.nlt.netty.client.WebSocketClient; | |||
| import com.xueyi.nlt.nlt.domain.LlmContent; | |||
| import com.xueyi.nlt.nlt.domain.LlmContext; | |||
| @@ -27,16 +28,18 @@ public class SparkServiceImpl implements ISysLlmService { | |||
| @Override | |||
| public LlmResponse chat(LlmContext context, LlmParam param) { | |||
| List<String> contentArr = context.getContentList().stream().map(LlmContent::getContent).collect(Collectors.toList()); | |||
| synchronized (WebSocketClient.LOCK) { | |||
| webSocketClient.sendMsg(contentArr); | |||
| WebSocketClient socketClient = SpringUtils.getBean(WebSocketClient.class); | |||
| webSocketClient = socketClient.sendMsg(contentArr); | |||
| synchronized (webSocketClient) { | |||
| try { | |||
| WebSocketClient.LOCK.wait(); | |||
| webSocketClient.wait(); | |||
| } catch (InterruptedException e) { | |||
| e.printStackTrace(); | |||
| Thread.currentThread().interrupt(); | |||
| } | |||
| String result = redisTemplate.opsForValue().get("group:websocket:content"); | |||
| result = webSocketClient.answer; | |||
| LlmResponse response = new LlmResponse(); | |||
| response.setContent(result); | |||
| return response; | |||
| @@ -138,12 +138,13 @@ | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.graphql-java</groupId> | |||
| <artifactId>graphql-java</artifactId> | |||
| <version>11.0</version> | |||
| <groupId>com.graphql-java-kickstart</groupId> | |||
| <artifactId>graphql-spring-boot-starter</artifactId> | |||
| <version>14.0.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.alibaba</groupId> | |||
| <artifactId>easyexcel</artifactId> | |||
| @@ -151,11 +152,7 @@ | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.binarywang</groupId> | |||
| <artifactId>weixin-java-miniapp</artifactId> | |||
| <version>4.6.0</version> | |||
| </dependency> | |||
| </dependencies> | |||
| @@ -19,7 +19,7 @@ import com.xueyi.common.log.enums.BusinessType; | |||
| import com.xueyi.common.security.annotation.InnerAuth; | |||
| import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.file.api.feign.RemoteFileService; | |||
| import com.xueyi.message.api.transfer.feign.RemoteTransferService; | |||
| import com.xueyi.system.api.device.feign.RemoteDeviceTenantMergeService; | |||
| @@ -322,7 +322,7 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm | |||
| } | |||
| try { | |||
| occurTime = DateUtils.formatDate(DateUtils.parseLongToDate(timestamp),"HH:mm"); | |||
| occurTime = MyDateUtils.formatDate(MyDateUtils.parseLongToDate(timestamp),"HH:mm"); | |||
| } catch (ParseException e) { | |||
| e.printStackTrace(); | |||
| throw new RuntimeException(e); | |||
| @@ -373,7 +373,7 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm | |||
| exceptionLogDto.setManCode(devicePo.getManCode()); | |||
| exceptionLogDto.setTId(devicePo.getTId()); | |||
| exceptionLogDto.setOccurTime(DateUtils.dateToLocalDateTime(DateUtils.parseLongToDate(timestamp))); | |||
| exceptionLogDto.setOccurTime(MyDateUtils.dateToLocalDateTime(MyDateUtils.parseLongToDate(timestamp))); | |||
| // 上传类型为崩溃上传时,插入异常日志 | |||
| if (uploadType == EmcsUploadType.getTypeCrackUpload()) { | |||
| exceptionLogMapper.insert(exceptionLogDto); | |||
| @@ -403,7 +403,7 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm | |||
| if (!redisTemplate.hasKey("exceptionLog:dingTalk:" + devId + ":" + type)) { | |||
| //设置当前时间格式为yyyy-MM-dd HH:mm:ss | |||
| LocalDateTime localDateTime = LocalDateTime.now(); | |||
| DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |||
| DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(MyDateUtils.DEFAULT_PATTERN); | |||
| String format = localDateTime.format(dateTimeFormatter); | |||
| DingdingReqEntity entity = new DingdingReqEntity(); | |||
| @@ -6,7 +6,7 @@ import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmScreenIconDto; | |||
| import com.xueyi.system.api.digitalmans.feign.RemoteModelService; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -20,7 +20,7 @@ import java.util.List; | |||
| @RestController | |||
| @RequestMapping("/api/menu/") | |||
| public class DmMenuApiController extends BaseApiController { | |||
| public class DmMenuApiController extends MyBaseApiController { | |||
| private static final Logger log = LoggerFactory.getLogger(DmMenuApiController.class); | |||
| @@ -8,6 +8,7 @@ import com.xueyi.common.core.web.result.AjaxResult; | |||
| import com.xueyi.common.mqtt.connection.MqttTemplate; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.message.api.transfer.domain.vo.DmActiveVo; | |||
| import com.xueyi.message.api.transfer.feign.RemoteTransferService; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; | |||
| @@ -148,7 +149,7 @@ public class DmManDeviceServiceImpl extends BaseServiceImpl<DmManDeviceQuery, Dm | |||
| LocalDateTime currentDate = LocalDateTime.now(); | |||
| LocalDateTime sevenDaysAgo =currentDate.minusDays(7).withHour(0).withMinute(0).withSecond(0); | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern(MyDateUtils.DEFAULT_PATTERN); | |||
| vo.setAlertNear7Days(exceptionLogMapper.selectList(Wrappers.<DmExceptionLogPo>query().lambda() | |||
| .ge(DmExceptionLogPo::getCreateTime,sevenDaysAgo.format(formatter))).size()); | |||
| // 当前未解除预警数 | |||
| @@ -10,6 +10,7 @@ import com.xueyi.common.log.enums.BusinessType; | |||
| import com.xueyi.common.mqtt.connection.MqttTemplate; | |||
| import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.api.digitalmans.domain.vo.NumberOfAlertToChartVo; | |||
| import com.xueyi.system.emcs.domain.dto.DmExceptionLogDto; | |||
| import com.xueyi.system.emcs.domain.dto.RedisBaseDto; | |||
| @@ -205,7 +206,7 @@ public class DmExceptionLogController extends BaseController<DmExceptionLogQuery | |||
| JSONObject jsonObject = new JSONObject(); | |||
| List<NumberOfAlertToChartVo> rangeBy5Weeks = new ArrayList<>(); | |||
| // select nearly 5 weeks alerts from dm_exception_log | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern(MyDateUtils.DEFAULT_PATTERN); | |||
| LocalDateTime startL = LocalDateTime.now(); | |||
| LocalDateTime endL = null; | |||
| for (int i = 0;i < 5;i++) { | |||
| @@ -265,7 +266,7 @@ public class DmExceptionLogController extends BaseController<DmExceptionLogQuery | |||
| YearMonth currentYearMonth = YearMonth.now(); | |||
| int currentYear = currentYearMonth.getYear(); | |||
| int currentMonth = currentYearMonth.getMonthValue(); | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern(MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| // 遍历每个月 | |||
| for (Month month : Month.values()) { | |||
| int monthValue = month.getValue(); | |||
| @@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.mqtt.service.MqttMessageHandler; | |||
| import com.xueyi.common.redis.service.RedisService; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.emcs.domain.dto.RedisBaseDto; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -43,7 +43,7 @@ public class HeartBeatMessageHandler implements MqttMessageHandler { | |||
| String memory = (Double.valueOf(memoryTotal) - memoryFree) / Double.valueOf(memoryTotal) * 100 + ""; | |||
| String occurTime = ""; | |||
| occurTime = DateUtils.formatDate(DateUtils.parseLongToDate(timestamp),"HH:mm"); | |||
| occurTime = MyDateUtils.formatDate(MyDateUtils.parseLongToDate(timestamp),"HH:mm"); | |||
| if (StringUtils.isNotEmpty(devId)) { | |||
| @@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
| import com.xueyi.common.core.constant.basic.SqlConstants; | |||
| import com.xueyi.common.mqtt.service.MqttMessageHandler; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmManDevicePo; | |||
| import com.xueyi.system.digitalmans.mapper.DmManDeviceMapper; | |||
| import com.xueyi.system.emcs.constant.EmcsUploadType; | |||
| @@ -59,7 +59,7 @@ public class LogUploadMessageHandler implements MqttMessageHandler { | |||
| exceptionLogDto.setManCode(devicePo.getManCode()); | |||
| exceptionLogDto.setTId(devicePo.getTId()); | |||
| exceptionLogDto.setOccurTime(DateUtils.dateToLocalDateTime(DateUtils.parseLongToDate(timestamp))); | |||
| exceptionLogDto.setOccurTime(MyDateUtils.dateToLocalDateTime(MyDateUtils.parseLongToDate(timestamp))); | |||
| // 上传类型为崩溃上传时,插入异常日志 | |||
| if (uploadType == EmcsUploadType.getTypeCrackUpload()) { | |||
| exceptionLogMapper.insert(exceptionLogDto); | |||
| @@ -0,0 +1,64 @@ | |||
| package com.xueyi.system.intercepts; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.context.SecurityContextHolder; | |||
| import com.xueyi.common.core.utils.JwtUtil; | |||
| import com.xueyi.common.security.service.TokenService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.stereotype.Component; | |||
| import org.springframework.web.filter.OncePerRequestFilter; | |||
| import javax.servlet.FilterChain; | |||
| import javax.servlet.ServletException; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.IOException; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-04 22:40 | |||
| */ | |||
| @Component | |||
| public class GraphqlRequestFilter extends OncePerRequestFilter { | |||
| Logger logger = LoggerFactory.getLogger(GraphqlRequestFilter.class); | |||
| @Override | |||
| protected void doFilterInternal( | |||
| HttpServletRequest request, | |||
| HttpServletResponse response, | |||
| FilterChain filterChain | |||
| ) throws ServletException, IOException { | |||
| // 获取请求路径 | |||
| String requestURI = request.getRequestURI(); | |||
| logger.info("Request URI: {}", requestURI); | |||
| // 判断是否是 GraphQL 请求 | |||
| if (requestURI != null && requestURI.contains("/graphql")) { | |||
| String token = request.getHeader("Authorization"); | |||
| logger.info("token: {}", token); | |||
| token = token.replace("Bearer ", ""); | |||
| logger.error("enterpriseId: {}, sourceName:{}, enterpriseName:{}, accountType:{}", JwtUtil.getEnterpriseId(token), JwtUtil.getSourceName(token), JwtUtil.getEnterpriseName(token), JwtUtil.getAccountType(token)); | |||
| SecurityContextHolder.setEnterpriseId(JwtUtil.getEnterpriseId(token)); | |||
| SecurityContextHolder.setSourceName(JwtUtil.getSourceName(token)); | |||
| SecurityContextHolder.setAccountType(JwtUtil.getAccountType(token)); | |||
| SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER); | |||
| logger.error("getAccountType:{}",SecurityContextHolder.getAccountType()); | |||
| logger.info("Authorization: {}", token); | |||
| // 在这里进行鉴权等处理 | |||
| // ... | |||
| // 继续处理 GraphQL 请求 | |||
| filterChain.doFilter(request, response); | |||
| } else { | |||
| // 不是 GraphQL 请求,继续处理其他请求 | |||
| filterChain.doFilter(request, response); | |||
| } | |||
| } | |||
| } | |||
| @@ -16,7 +16,7 @@ import com.xueyi.system.api.pass.feign.RemoteRecognizedRecordsService; | |||
| import com.xueyi.system.digitalmans.service.IDmDigitalmanService; | |||
| import com.xueyi.system.meeting.domain.model.DmMeetingRoomsConverter; | |||
| import com.xueyi.system.meeting.mapper.DmMeetingRoomsMapper; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import com.xueyi.system.utils.common.ImageUtil; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -42,7 +42,7 @@ import java.util.List; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/meeting/api") | |||
| public class DmMeetingApiController extends BaseApiController { | |||
| public class DmMeetingApiController extends MyBaseApiController { | |||
| private static final Logger log = LoggerFactory.getLogger(DmMeetingApiController.class); | |||
| @Autowired | |||
| @@ -13,7 +13,7 @@ import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.security.annotation.InnerAuth; | |||
| import com.xueyi.common.sms.configure.SmsProperties; | |||
| import com.xueyi.common.web.constant.ResponseCode; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.nlt.api.netty.domain.vo.DmWebSocketMessageVo; | |||
| import com.xueyi.nlt.api.netty.feign.RemoteWebsocketService; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteIntentService; | |||
| @@ -37,7 +37,7 @@ import com.xueyi.system.meeting.mapper.DmMeetingOrdersMapper; | |||
| import com.xueyi.system.meeting.mapper.DmMeetingRoomsMapper; | |||
| import com.xueyi.system.meeting.service.impl.DmMeetingOrdersServiceImpl; | |||
| import com.xueyi.system.meeting.service.impl.DmMeetingRoomsServiceImpl; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import com.xueyi.system.staff.mapper.DmStaffMapper; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -71,7 +71,7 @@ import java.util.stream.Collectors; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/meeting/inner-api") | |||
| public class DmMeetingInnerApiController extends BaseApiController { | |||
| public class DmMeetingInnerApiController extends MyBaseApiController { | |||
| private static final Logger log = LoggerFactory.getLogger(DmMeetingInnerApiController.class); | |||
| @Autowired | |||
| @@ -145,8 +145,8 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| } | |||
| List<DmMeetingOrdersPo> list = new ArrayList<>(); | |||
| StringBuilder mms = new StringBuilder(); | |||
| SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); | |||
| SimpleDateFormat dateFormat2 = new SimpleDateFormat("HH:mm"); | |||
| SimpleDateFormat dateFormat1 = new SimpleDateFormat(MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| SimpleDateFormat dateFormat2 = new SimpleDateFormat(MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| DmMeetingRoomsPo meetingRoom = dmMeetingRoomsService.selectById(order.getSpaceId().toString()); | |||
| if (null == meetingRoom){ | |||
| @@ -160,8 +160,8 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| String times = (String) timeStr; | |||
| String[] timeAry = times.split("-"); | |||
| Date orderDate = DateUtils.parseStrToDate(date + " " + timeAry[0], "yyyy-MM-dd HH:mm"); | |||
| Date endDate = DateUtils.parseStrToDate(date + " " + timeAry[1], "yyyy-MM-dd HH:mm"); | |||
| Date orderDate = MyDateUtils.parseStrToDate(date + " " + timeAry[0], MyDateUtils.DEFAULT_NO_SECOND_DATE_PATTERN); | |||
| Date endDate = MyDateUtils.parseStrToDate(date + " " + timeAry[1], MyDateUtils.DEFAULT_NO_SECOND_DATE_PATTERN); | |||
| Long duration1 = orderDate.getTime(); | |||
| Long duration2 = endDate.getTime(); | |||
| Integer duration = Math.toIntExact(duration2 - duration1); | |||
| @@ -252,15 +252,15 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| if (null == room) { | |||
| return output(ResponseCode.DATA_NOT_EXISTS, "会议室").toJSON(); | |||
| } | |||
| if (DateUtils.formatDate(new Date(), "yyyy-MM-dd").compareTo(dateStr) > 0) { | |||
| if (MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN).compareTo(dateStr) > 0) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| if (StringUtils.isEmpty(startTime)) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| String sTime = startTime,eTime = ""; | |||
| Date end = DateUtils.addMinutes(DateUtils.parseStrToDate(dateStr + " " + startTime, "yyyy-MM-dd HH:mm"), 30); | |||
| eTime = DateUtils.formatDate(end, "HH:mm"); | |||
| 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) { | |||
| @@ -277,16 +277,16 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| if (null == room) { | |||
| return output(ResponseCode.DATA_NOT_EXISTS, "会议室").toJSON(); | |||
| } | |||
| if (DateUtils.formatDate(new Date(), "yyyy-MM-dd").compareTo(dateStr) > 0) { | |||
| if (MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN).compareTo(dateStr) > 0) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| if (StringUtils.isEmpty(startTime)) { | |||
| return output(ResponseCode.MEETING_ORDER_TIME_ERROR).toJSON(); | |||
| } | |||
| String sTime = startTime,eTime = ""; | |||
| Date end = DateUtils.parseStrToDate(dateStr + " " + startTime, "yyyy-MM-dd HH:mm"); | |||
| end = DateUtils.addMinutes(end, duration); | |||
| eTime = DateUtils.formatDate(end, "HH:mm"); | |||
| 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); | |||
| @@ -305,8 +305,8 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| return output(ResponseCode.MEETING_RECORD_NOT_FOUND, null).toJSON(); | |||
| } | |||
| SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); | |||
| SimpleDateFormat dateFormat2 = new SimpleDateFormat("HH:mm"); | |||
| SimpleDateFormat dateFormat1 = new SimpleDateFormat(MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| SimpleDateFormat dateFormat2 = new SimpleDateFormat(MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| DmMeetingRoomsPo meetingRoom = dmMeetingRoomsMapper.findById(mro.getSpaceId()); | |||
| String mms = dateFormat1.format(mro.getOrderDate()) + " " + dateFormat2.format(mro.getStartTime()) + "于" + meetingRoom.getName(); | |||
| @@ -445,16 +445,16 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| } | |||
| if (objects.size() ==1) { | |||
| DmMeetingOrdersPo current = objects.get(0); | |||
| if (DateUtils.formatDate(current.getStartTime(), "HH:mm").compareTo(currentTime) > 0 ) { | |||
| if (MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime) > 0 ) { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", currentTime); | |||
| json.put("endTime", DateUtils.formatDate(current.getStartTime(), "HH:mm")); | |||
| json.put("endTime", MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put("roomId", roomId); | |||
| freeTimeList.add(json); | |||
| } else { | |||
| if (DateUtils.formatDate(current.getEndTime(), "HH:mm").compareTo(currentTime) > 0 ) { | |||
| if (MyDateUtils.formatDate(current.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime) > 0 ) { | |||
| JSONObject json = new JSONObject(); | |||
| json.put("startTime", DateUtils.formatDate(current.getEndTime(), "HH:mm")); | |||
| json.put("startTime", MyDateUtils.formatDate(current.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put("endTime", 0); | |||
| json.put("roomId", roomId); | |||
| freeTimeList.add(json); | |||
| @@ -469,8 +469,8 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| } | |||
| return freeTimeList; | |||
| } | |||
| // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |||
| objects = objects.stream().sorted(Comparator.comparing(po -> DateUtils.formatDate(po.getStartTime(), "HH:mm"))).collect(Collectors.toList()); | |||
| // 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()); | |||
| for (int i = 0; i < objects.size() - 1; i++) { | |||
| DmMeetingOrdersPo current = objects.get(i); | |||
| DmMeetingOrdersPo next = objects.get(i + 1); | |||
| @@ -478,14 +478,14 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| Date freeStartTime = current.getEndTime(); | |||
| Date freeEndTime = next.getStartTime(); | |||
| String freeStartTimeStr = DateUtils.formatDate(current.getEndTime(), "HH:mm"); | |||
| String freeEndTimeStr = DateUtils.formatDate(next.getStartTime(), "HH:mm"); | |||
| String freeStartTimeStr = MyDateUtils.formatDate(current.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| String freeEndTimeStr = MyDateUtils.formatDate(next.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| if (DateUtils.formatDate(current.getStartTime(), "HH:mm").compareTo(currentTime) < 0) { | |||
| if (MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime) < 0) { | |||
| if (i==objects.size() - 2) { | |||
| JSONObject json = new JSONObject(); | |||
| if (DateUtils.formatDate(next.getEndTime(), "HH:mm").compareTo(currentTime)>0) { | |||
| json.put("startTime", DateUtils.formatDate(next.getEndTime(), "HH:mm")); | |||
| if (MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime)>0) { | |||
| json.put("startTime", MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| } else { | |||
| json.put("startTime", currentTime); | |||
| } | |||
| @@ -496,10 +496,10 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| continue; | |||
| } | |||
| if (i==0 && DateUtils.formatDate(current.getStartTime(), "HH:mm").compareTo(currentTime) > 0 ) { | |||
| 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", DateUtils.formatDate(current.getStartTime(), "HH:mm")); | |||
| json.put("endTime", MyDateUtils.formatDate(current.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| json.put("roomId", roomId); | |||
| freeTimeList.add(json); | |||
| } | |||
| @@ -514,8 +514,8 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| if (i==objects.size() - 2) { | |||
| JSONObject json = new JSONObject(); | |||
| if (DateUtils.formatDate(next.getEndTime(), "HH:mm").compareTo(currentTime)>0) { | |||
| json.put("startTime", DateUtils.formatDate(next.getEndTime(), "HH:mm")); | |||
| if (MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(currentTime)>0) { | |||
| json.put("startTime", MyDateUtils.formatDate(next.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| } else { | |||
| json.put("startTime", currentTime); | |||
| } | |||
| @@ -585,7 +585,7 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| //过滤掉今天的已经过去的预约记录,并按开始时间进行排序 | |||
| list = list.stream().filter(t->DateUtils.formatDate(t.getOrderDate(), "yyyy-MM-dd").compareTo(DateUtils.formatDate(new Date(), "yyyy-MM-dd"))>0 || (DateUtils.formatDate(t.getOrderDate(), "yyyy-MM-dd").compareTo(DateUtils.formatDate(new Date(), "yyyy-MM-dd"))==0 && DateUtils.formatDate(t.getStartTime(), "HH:mm").compareTo(DateUtils.formatDate(new Date(), "HH:mm"))>0)).sorted(Comparator.comparing(po -> DateUtils.formatDate(po.getStartTime(), "HH:mm"))).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))).collect(Collectors.toList()); | |||
| //获得当前时间开始最近的整点,或者半点 | |||
| @@ -594,7 +594,7 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| currentStr = startTime; | |||
| } | |||
| if (dateStr.compareTo(DateUtils.formatDate(new Date(), "yyyy-MM-dd")) == 0) { | |||
| if (dateStr.compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN)) == 0) { | |||
| LocalTime currentTime = LocalTime.now(); | |||
| if (currentTime.getMinute() >= 30) { | |||
| currentTime = currentTime.plusHours(1).withMinute(0).withSecond(0); | |||
| @@ -602,7 +602,7 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| currentTime = currentTime.withMinute(30).withSecond(0); | |||
| } | |||
| currentStr = currentTime.format(DateTimeFormatter.ofPattern("HH:mm")); | |||
| currentStr = currentTime.format(DateTimeFormatter.ofPattern(MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| } | |||
| Map<Long, List<DmMeetingOrdersPo>> groupedByRoom = list.stream() | |||
| @@ -639,7 +639,7 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| Map<Long, String> rooms = new HashMap<>(); | |||
| Map<Long, Integer> sorts = new HashMap<>(); | |||
| //当天 | |||
| String dateStr = DateUtils.formatDate(new Date(), "yyyy-MM-dd"); | |||
| String dateStr = MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| DmMeetingRoomsPo dm = new DmMeetingRoomsPo(); | |||
| dm.setDeptId(deptId); | |||
| @@ -652,23 +652,23 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| //获得当前时间开始最近的整点,或者半点 | |||
| String currentStr = "08:00"; | |||
| if (dateStr.compareTo(DateUtils.formatDate(new Date(), "yyyy-MM-dd")) == 0) { | |||
| if (dateStr.compareTo(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN)) == 0) { | |||
| LocalTime currentTime = LocalTime.now(); | |||
| if (currentTime.getMinute() >= 30) { | |||
| currentTime = currentTime.plusHours(1).withMinute(0).withSecond(0); | |||
| } else { | |||
| currentTime = currentTime.withMinute(30).withSecond(0); | |||
| } | |||
| currentStr = currentTime.format(DateTimeFormatter.ofPattern("HH:mm")); | |||
| currentStr = currentTime.format(DateTimeFormatter.ofPattern(MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| } | |||
| Map<Long, List<DmMeetingOrdersPo>> groupedByRoom = ordersService.selectOrderedList(deptId,dateStr); | |||
| String nextDateStr = DateUtils.dateStrAdd(dateStr, 1); | |||
| 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(); | |||
| if (DateUtils.isAmPm().equals("am")) { | |||
| if (MyDateUtils.isAmPm().equals("am")) { | |||
| currentStr = "14:00"; | |||
| js2 = getList(currentStr, groupedByRoom, rooms, sorts, ids); | |||
| currentStr = "09:00"; | |||
| @@ -686,7 +686,7 @@ public class DmMeetingInnerApiController extends BaseApiController { | |||
| arr.add(js1); | |||
| } | |||
| if (ObjectUtil.isNotEmpty(js2)) { | |||
| if (DateUtils.isAmPm().equals("am")) { | |||
| if (MyDateUtils.isAmPm().equals("am")) { | |||
| js2.put("orderDate", dateStr); | |||
| } else { | |||
| js2.put("orderDate", nextDateStr); | |||
| @@ -1,7 +1,7 @@ | |||
| package com.xueyi.system.meeting.service.impl; | |||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.api.meeting.domain.dto.DmMeetingOrdersDto; | |||
| import com.xueyi.system.api.meeting.domain.po.DmMeetingOrdersPo; | |||
| import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| @@ -52,11 +52,13 @@ public class DmMeetingOrdersServiceImpl extends BaseServiceImpl<DmMeetingOrdersQ | |||
| public void fixColumns(DmMeetingOrdersDto dto) { | |||
| DmStaffPo sm = dmStaffService.selectById(dto.getOrderBy()); | |||
| if (null != sm) | |||
| dto.setOrderByEmp(sm.getUserName()); | |||
| { | |||
| dto.setOrderByEmp(sm.getUserName()); | |||
| } | |||
| dto.setStartTimeStr(DateUtils.formatDate(dto.getStartTime(), "HH:mm")); | |||
| dto.setOrderDateStr(DateUtils.formatDate(dto.getOrderDate(), "YYYY-MM-dd")); | |||
| dto.setEndTimeStr(DateUtils.formatDate(dto.getEndTime(), "HH:mm")); | |||
| dto.setStartTimeStr(MyDateUtils.formatDate(dto.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| dto.setOrderDateStr(MyDateUtils.formatDate(dto.getOrderDate(), MyDateUtils.DEFAULT_DATE_PATTERN)); | |||
| dto.setEndTimeStr(MyDateUtils.formatDate(dto.getEndTime(), MyDateUtils.DEFAULT_TIME_PATTERN)); | |||
| } | |||
| @@ -68,20 +70,18 @@ public class DmMeetingOrdersServiceImpl extends BaseServiceImpl<DmMeetingOrdersQ | |||
| @Override | |||
| public Map<Long, List<DmMeetingOrdersPo>> selectOrderedList(Long deptId, String dateStr) { | |||
| List<DmMeetingOrdersPo> list = new ArrayList<>(); | |||
| //当天 | |||
| String curDateStr = DateUtils.formatDate(new Date(), "yyyy-MM-dd"); | |||
| list = dmMeetingOrdersMapper.findListByDateStr(dateStr); | |||
| String curDateStr = MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| List<DmMeetingOrdersPo> list = dmMeetingOrdersMapper.findListByDateStr(dateStr); | |||
| //过滤掉今天的已经过去的预约记录,并按开始时间进行排序 | |||
| if (curDateStr.equals(dateStr)) { | |||
| list = list.stream().filter(t->DateUtils.formatDate(t.getOrderDate(), "yyyy-MM-dd").compareTo(DateUtils.formatDate(new Date(), "yyyy-MM-dd"))>0 || (DateUtils.formatDate(t.getOrderDate(), "yyyy-MM-dd").compareTo(DateUtils.formatDate(new Date(), "yyyy-MM-dd"))==0 && DateUtils.formatDate(t.getStartTime(), "HH:mm").compareTo(DateUtils.formatDate(new Date(), "HH:mm"))>0)).sorted(Comparator.comparing(po -> DateUtils.formatDate(po.getStartTime(), "HH:mm"))).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(); | |||
| } else { | |||
| list = list.stream().sorted(Comparator.comparing(po -> DateUtils.formatDate(po.getStartTime(), "HH:mm"))).collect(Collectors.toList()); | |||
| list = list.stream().sorted(Comparator.comparing(po -> MyDateUtils.formatDate(po.getStartTime(), MyDateUtils.DEFAULT_TIME_PATTERN))).toList(); | |||
| } | |||
| Map<Long, List<DmMeetingOrdersPo>> groupedByRoom = list.stream() | |||
| return list.stream() | |||
| .collect(Collectors.groupingBy(DmMeetingOrdersPo::getSpaceId)); | |||
| return groupedByRoom; | |||
| } | |||
| } | |||
| @@ -6,7 +6,7 @@ import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.system.api.organize.domain.vo.SysDeptExt; | |||
| import com.xueyi.system.api.organize.feign.RemoteDeptService; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.PathVariable; | |||
| @@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/dept/api") | |||
| public class SysDeptApiController extends BaseApiController { | |||
| public class SysDeptApiController extends MyBaseApiController { | |||
| @Autowired | |||
| private RemoteDeptService deptService; | |||
| @@ -24,7 +24,7 @@ import com.xueyi.system.api.pass.domain.po.DmRecognizedRecordsPo; | |||
| import com.xueyi.system.api.pass.feign.RemoteRecognizedRecordsService; | |||
| import com.xueyi.system.pass.mapper.DmRecognizedRecordsMapper; | |||
| import com.xueyi.system.pass.service.impl.DmRecognizedRecordsServiceImpl; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -47,7 +47,7 @@ import java.util.stream.Collectors; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/pass/api") | |||
| public class DmRecognizedRecordsApiController extends BaseApiController { | |||
| public class DmRecognizedRecordsApiController extends MyBaseApiController { | |||
| private static final Logger log = LoggerFactory.getLogger(DmRecognizedRecordsApiController.class); | |||
| @Autowired | |||
| private RemoteRecognizedRecordsService recognizedRecordsFeign; | |||
| @@ -1,5 +1,6 @@ | |||
| package com.xueyi.system.pass.controller.api; | |||
| import cn.hutool.core.date.LocalDateTimeUtil; | |||
| import cn.hutool.core.util.IdUtil; | |||
| import cn.hutool.core.util.ObjectUtil; | |||
| import co.elastic.clients.elasticsearch.ElasticsearchClient; | |||
| @@ -9,7 +10,7 @@ import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.security.annotation.InnerAuth; | |||
| import com.xueyi.common.web.constant.ResponseCode; | |||
| import com.xueyi.common.web.response.MyResponse; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.file.api.domain.SysFile; | |||
| import com.xueyi.file.api.feign.RemoteFileService; | |||
| import com.xueyi.system.api.pass.domain.dto.DmRecognizedMultiRecordsDto; | |||
| @@ -19,7 +20,7 @@ import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| import com.xueyi.system.pass.domain.model.DmRecognizedRecordsConverter; | |||
| import com.xueyi.system.pass.mapper.DmRecognizedRecordsMapper; | |||
| import com.xueyi.system.pass.service.impl.DmRecognizedRecordsServiceImpl; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl; | |||
| import com.xueyi.system.resource.service.impl.FaceServiceImpl; | |||
| @@ -45,7 +46,7 @@ import java.util.List; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/pass/inner-api") | |||
| public class DmRecognizedRecordsInnerApiController extends BaseApiController { | |||
| public class DmRecognizedRecordsInnerApiController extends MyBaseApiController { | |||
| @Autowired | |||
| private DmStaffMapper dmStaffMapper; | |||
| @@ -94,7 +95,7 @@ public class DmRecognizedRecordsInnerApiController extends BaseApiController { | |||
| DmRecognizedRecordsPo cr = recordsConverter.mapperPo(recognizedRecordsDto); | |||
| try { | |||
| cr.setRecognizedTime(DateUtils.parseLongToDate(timestamp.longValue())); | |||
| cr.setRecognizedTime(LocalDateTimeUtil.of(MyDateUtils.parseLongToDate(timestamp.longValue()))); | |||
| } catch (ParseException e) { | |||
| e.printStackTrace(); | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "timestamp").toJSON(); | |||
| @@ -147,7 +148,7 @@ public class DmRecognizedRecordsInnerApiController extends BaseApiController { | |||
| DmRecognizedRecordsPo cr = recordsConverter.mapperPo(recognizedRecordsDto); | |||
| try { | |||
| cr.setRecognizedTime(DateUtils.parseLongToDate(timestamp.longValue())); | |||
| cr.setRecognizedTime(LocalDateTimeUtil.of(MyDateUtils.parseLongToDate(timestamp.longValue()))); | |||
| } catch (ParseException e) { | |||
| e.printStackTrace(); | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "timestamp").toJSON(); | |||
| @@ -1,113 +0,0 @@ | |||
| package com.xueyi.system.resource.controller.api; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.fasterxml.jackson.core.type.TypeReference; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.xueyi.common.web.constant.ResponseCode; | |||
| import com.xueyi.common.web.response.MyResponse; | |||
| import com.xueyi.system.digitalmans.mapper.DmDigitalmanMapper; | |||
| import com.xueyi.system.digitalmans.service.impl.DmDigitalmanServiceImpl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.io.BufferedReader; | |||
| import java.io.IOException; | |||
| import java.util.Map; | |||
| import java.util.TreeMap; | |||
| public class BaseApiController extends com.xueyi.common.web.controller.BaseApiController { | |||
| @Autowired | |||
| private DmDigitalmanServiceImpl dmDigitalmanService; | |||
| @Autowired | |||
| private DmDigitalmanMapper dmDigitalmanMapper; | |||
| public MyResponse commonCheck(String devId, Double timestamp, String sign) { | |||
| String regexZS = "[0-9A-Za-z_-]+"; | |||
| if (!(StringUtils.isNotEmpty(devId) && devId.matches(regexZS))) { | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "devId"); | |||
| } | |||
| if (!(StringUtils.isNotEmpty(sign) && sign.matches(regexZS))) { | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "sign"); | |||
| } | |||
| // dmDigitalmanService.selectById() | |||
| /*DmDigitalmanDto dmDigitalmanDto = dmDigitalmanMapper.selectByCode(devId); | |||
| System.err.println(dmDigitalmanDto);*/ | |||
| /* Device device = deviceService.findByDevId(devId); | |||
| if (!ObjectUtils.isNotNull(device)) { | |||
| return output(ResponseCode.PARAM_ID_NOT_EXIST_RECORD, devId); | |||
| } | |||
| System.err.println("----------sign check start----------"); | |||
| String singStr = devId + device.getBindDeviceSn() + timestamp + device.getAuthCode(); | |||
| System.err.println(singStr); | |||
| String signStr = DigestUtils.md5DigestAsHex(singStr.getBytes()); | |||
| System.err.println(signStr); | |||
| System.err.println("----------sign check end----------"); | |||
| if (!sign.equals(signStr)) { | |||
| return output(ResponseCode.AUTH_NOT_PASS, null); | |||
| }*/ | |||
| return output(ResponseCode.SUCCESS, null); | |||
| } | |||
| /*/** | |||
| * @Author yangkai | |||
| * @Description //TODO | |||
| * @Date 2023/4/19 | |||
| * @Param [request] | |||
| * @Param [type] 1,application/json方式请求;2,form-data方式请求 | |||
| * | |||
| * @return com.alibaba.fastjson2.JSONObject | |||
| **/ | |||
| public JSONObject genSign(HttpServletRequest request, Integer type){ | |||
| if (1 == type) { | |||
| Map<String, String[]> paramMap = request.getParameterMap(); | |||
| // 將參數轉換為TreeMap並按照key排序 | |||
| TreeMap<String, String> sortedParamMap = new TreeMap<>(); | |||
| for (Map.Entry<String, String[]> entry : paramMap.entrySet()) { | |||
| String key = entry.getKey(); | |||
| String[] valueArray = entry.getValue(); | |||
| String value = (valueArray.length > 0) ? valueArray[0] : ""; | |||
| sortedParamMap.put(key, value); | |||
| } | |||
| return JSONObject.from(sortedParamMap); | |||
| } else { | |||
| BufferedReader reader = null; | |||
| try { | |||
| reader = request.getReader(); | |||
| StringBuilder stringBuilder = new StringBuilder(); | |||
| String line = null; | |||
| while ((line = reader.readLine()) != null) { | |||
| stringBuilder.append(line); | |||
| } | |||
| String requestBody = stringBuilder.toString(); | |||
| ObjectMapper objectMapper = new ObjectMapper(); | |||
| Map<String, String[]> requestMap = objectMapper.readValue(requestBody, new TypeReference<Map<String, String[]>>(){}); | |||
| TreeMap<String, String> sortedParamMap = new TreeMap<>(); | |||
| for (Map.Entry<String, String[]> entry : requestMap.entrySet()) { | |||
| String key = entry.getKey(); | |||
| String[] valueArray = entry.getValue(); | |||
| String value = (valueArray.length > 0) ? valueArray[0] : ""; | |||
| sortedParamMap.put(key, value); | |||
| } | |||
| return JSONObject.from(sortedParamMap); | |||
| } catch (IOException e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1,19 +1,14 @@ | |||
| package com.xueyi.system.resource.controller.api; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.web.constant.ResponseCode; | |||
| import com.xueyi.common.web.response.MyResponse; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestMethod; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.text.NumberFormat; | |||
| import java.text.ParseException; | |||
| /** | |||
| * 静态资源管理 业务处理 | |||
| @@ -23,7 +18,7 @@ import java.text.ParseException; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/api/resources") | |||
| public class DmResourcesCommonApiController extends BaseApiController{ | |||
| public class DmResourcesCommonApiController extends MyBaseApiController { | |||
| @RequestMapping(value = "/sync-face", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") | |||
| public Object syncFace(@RequestBody JSONObject map, HttpServletRequest request) { | |||
| @@ -0,0 +1,62 @@ | |||
| package com.xueyi.system.resource.controller.api; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.fasterxml.jackson.core.type.TypeReference; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.xueyi.common.web.constant.ResponseCode; | |||
| import com.xueyi.common.web.response.MyResponse; | |||
| import com.xueyi.system.digitalmans.mapper.DmDigitalmanMapper; | |||
| import com.xueyi.system.digitalmans.service.impl.DmDigitalmanServiceImpl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.io.BufferedReader; | |||
| import java.io.IOException; | |||
| import java.util.Map; | |||
| import java.util.TreeMap; | |||
| public class MyBaseApiController extends com.xueyi.common.web.controller.BaseApiController { | |||
| @Autowired | |||
| private DmDigitalmanServiceImpl dmDigitalmanService; | |||
| @Autowired | |||
| private DmDigitalmanMapper dmDigitalmanMapper; | |||
| public MyResponse commonCheck(String devId, Double timestamp, String sign) { | |||
| String regexZS = "[0-9A-Za-z_-]+"; | |||
| if (!(StringUtils.isNotEmpty(devId) && devId.matches(regexZS))) { | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "devId"); | |||
| } | |||
| if (!(StringUtils.isNotEmpty(sign) && sign.matches(regexZS))) { | |||
| return output(ResponseCode.ILLEGAL_PARAMETER, "sign"); | |||
| } | |||
| // dmDigitalmanService.selectById() | |||
| /*DmDigitalmanDto dmDigitalmanDto = dmDigitalmanMapper.selectByCode(devId); | |||
| System.err.println(dmDigitalmanDto);*/ | |||
| /* Device device = deviceService.findByDevId(devId); | |||
| if (!ObjectUtils.isNotNull(device)) { | |||
| return output(ResponseCode.PARAM_ID_NOT_EXIST_RECORD, devId); | |||
| } | |||
| System.err.println("----------sign check start----------"); | |||
| String singStr = devId + device.getBindDeviceSn() + timestamp + device.getAuthCode(); | |||
| System.err.println(singStr); | |||
| String signStr = DigestUtils.md5DigestAsHex(singStr.getBytes()); | |||
| System.err.println(signStr); | |||
| System.err.println("----------sign check end----------"); | |||
| if (!sign.equals(signStr)) { | |||
| return output(ResponseCode.AUTH_NOT_PASS, null); | |||
| }*/ | |||
| return output(ResponseCode.SUCCESS, null); | |||
| } | |||
| } | |||
| @@ -19,7 +19,7 @@ import com.xueyi.common.log.annotation.Log; | |||
| import com.xueyi.common.log.enums.BusinessType; | |||
| import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.organize.mapper.SysDeptMapper; | |||
| import com.xueyi.system.staff.domain.dto.DmEmpAttendanceDto; | |||
| import com.xueyi.system.staff.domain.model.DmEmpAttendanceConverter; | |||
| @@ -100,13 +100,13 @@ public class DmEmpAttendanceController extends BaseController<DmEmpAttendanceQue | |||
| Date start = null; | |||
| Date end = null; | |||
| try { | |||
| start = DateUtils.parseLongToDate(query.getSTimestamp()); | |||
| end = DateUtils.parseLongToDate(query.getETimestamp()); | |||
| start = MyDateUtils.parseLongToDate(query.getSTimestamp()); | |||
| end = MyDateUtils.parseLongToDate(query.getETimestamp()); | |||
| } catch (ParseException e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| String sTime = DateUtils.formatDate(start,"yyyy-MM-dd"); | |||
| String eTime = DateUtils.formatDate(end,"yyyy-MM-dd"); | |||
| String sTime = MyDateUtils.formatDate(start,MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| String eTime = MyDateUtils.formatDate(end,MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| wrapper.between("date_str",sTime, eTime); | |||
| } | |||
| if (query != null && query.getDeptId() !=null && query.getDeptId() > 0) { | |||
| @@ -181,13 +181,13 @@ public class DmEmpAttendanceController extends BaseController<DmEmpAttendanceQue | |||
| try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build()) { | |||
| QueryWrapper<DmEmpAttendancePo> query = new QueryWrapper<>(); | |||
| if (dmEmpAttendance != null && dmEmpAttendance.getETimestamp() != null &&dmEmpAttendance.getETimestamp()>0) { | |||
| start = DateUtils.parseLongToDate(dmEmpAttendance.getSTimestamp()); | |||
| end = DateUtils.parseLongToDate(dmEmpAttendance.getETimestamp()); | |||
| String sTime = DateUtils.formatDate(start,"yyyy-MM-dd"); | |||
| String eTime = DateUtils.formatDate(end,"yyyy-MM-dd"); | |||
| start = MyDateUtils.parseLongToDate(dmEmpAttendance.getSTimestamp()); | |||
| end = MyDateUtils.parseLongToDate(dmEmpAttendance.getETimestamp()); | |||
| String sTime = MyDateUtils.formatDate(start,MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| String eTime = MyDateUtils.formatDate(end,MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| query.between("date_str",sTime, eTime); | |||
| } else { | |||
| start = DateUtils.addDays(new Date(), -30); | |||
| start = MyDateUtils.addDays(new Date(), -30); | |||
| end = new Date(); | |||
| } | |||
| if (dmEmpAttendance != null && dmEmpAttendance.getDeptId() !=null && dmEmpAttendance.getDeptId() > 0) { | |||
| @@ -28,9 +28,13 @@ 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.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.service.IDmResourcesService; | |||
| import com.xueyi.system.staff.domain.query.DmStaffQuery; | |||
| import com.xueyi.system.api.staff.domain.vo.DmStaffFeature; | |||
| import com.xueyi.system.staff.service.IDmStaffService; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.validation.annotation.Validated; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @@ -65,6 +69,13 @@ public class DmStaffController extends BaseController<DmStaffQuery, DmStaffDto, | |||
| @Autowired | |||
| ISysEnterpriseService enterpriseService; | |||
| @Autowired | |||
| IDmResourcesService resourcesService; | |||
| @Autowired | |||
| RemoteTenantService tenantService; | |||
| /** 定义节点名称 */ | |||
| @Override | |||
| protected String getNodeName() { | |||
| @@ -124,7 +135,17 @@ public class DmStaffController extends BaseController<DmStaffQuery, DmStaffDto, | |||
| Long tenantId = Long.parseLong(String.valueOf(SecurityContextHolder.getLocalMap().get("enterprise_id"))); | |||
| SysEnterpriseDto enterpriseDto = enterpriseService.selectById(tenantId); | |||
| Source source = SourceUtil.getSourceCache(enterpriseDto.getStrategyId()); | |||
| if (dmStaff.getResourceId() != null) { | |||
| DmResourcesDto dto = resourcesService.selectById(dmStaff.getResourceId()); | |||
| if (dto != null) { | |||
| dmStaff.setAvatar(dto.getUrl()); | |||
| } | |||
| SysEnterpriseStaff enterpriseStaff = new SysEnterpriseStaff(); | |||
| enterpriseStaff.setPhone(dmStaff.getPhone()); | |||
| enterpriseStaff.setStaffId(dmStaff.getId()); | |||
| enterpriseStaff.setTId(SecurityContextHolder.getEnterpriseId()); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| } | |||
| AjaxResult result = super.add(dmStaff); | |||
| if (dmStaff.getBirthDate() != null) { | |||
| DmWebSocketMessageVo vo = new DmWebSocketMessageVo(); | |||
| @@ -16,7 +16,7 @@ import com.xueyi.system.api.pass.domain.po.DmRecognizedRecordsPo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffCommonDto; | |||
| import com.xueyi.system.api.staff.feign.RemoteStaffService; | |||
| import com.xueyi.system.pass.mapper.DmRecognizedRecordsMapper; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| 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; | |||
| @@ -43,7 +43,7 @@ import java.util.List; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/staff/api") | |||
| public class DmStaffApiController extends BaseApiController { | |||
| public class DmStaffApiController extends MyBaseApiController { | |||
| private static final Logger log = LoggerFactory.getLogger(DmStaffApiController.class); | |||
| @@ -12,7 +12,7 @@ import com.xueyi.system.api.digitalmans.domain.dto.DmVisitorsDto; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitorsPo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffCommonDto; | |||
| import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl; | |||
| import com.xueyi.system.resource.service.impl.FaceServiceImpl; | |||
| @@ -26,6 +26,7 @@ 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.RequestParam; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @@ -36,7 +37,7 @@ import org.springframework.web.bind.annotation.RestController; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/staff/inner-api") | |||
| public class DmStaffInnerApiController extends BaseApiController { | |||
| public class DmStaffInnerApiController extends MyBaseApiController { | |||
| @Autowired | |||
| private DmStaffMapper dmStaffMapper; | |||
| @@ -68,11 +69,35 @@ public class DmStaffInnerApiController extends BaseApiController { | |||
| public JSONObject fetchStaff(@PathVariable("staffId") String staffId){ | |||
| DmStaffPo dmStaff = dmStaffMapper.selectOne(Wrappers.<DmStaffPo>lambdaQuery().eq(DmStaffPo::getId, staffId).last(SqlConstants.LIMIT_ONE)); | |||
| if (dmStaff!= null) { | |||
| if (dmStaff.getResourceId() != null) { | |||
| DmResourcesDto dto = iDmResourcesService.selectById(dmStaff.getResourceId()); | |||
| if (dto != null) { | |||
| dmStaff.setAvatar(dto.getUrl()); | |||
| } | |||
| } | |||
| return outputSuccess(dmStaff).toJSON(); | |||
| } | |||
| return output(ResponseCode.DATA_NOT_EXISTS,"指定ID的员工").toJSON(); | |||
| } | |||
| @InnerAuth | |||
| @GetMapping(value = "selectByPhone") | |||
| @ResponseBody | |||
| public JSONObject fetchStaffByPhone(@RequestParam(value = "phone") String phone){ | |||
| DmStaffPo dmStaff = dmStaffMapper.selectOne(Wrappers.<DmStaffPo>lambdaQuery().eq(DmStaffPo::getPhone, phone).last(SqlConstants.LIMIT_ONE)); | |||
| if (dmStaff!= null) { | |||
| if (dmStaff.getResourceId() != null) { | |||
| DmResourcesDto dto = iDmResourcesService.selectById(dmStaff.getResourceId()); | |||
| if (dto != null) { | |||
| dmStaff.setAvatar(dto.getUrl()); | |||
| } | |||
| } | |||
| return outputSuccess(dmStaff).toJSON(); | |||
| } | |||
| return output(ResponseCode.DATA_NOT_EXISTS,"指定phone的员工").toJSON(); | |||
| } | |||
| @InnerAuth | |||
| @PostMapping(value = "new-staff") | |||
| @ResponseBody | |||
| @@ -132,4 +157,12 @@ public class DmStaffInnerApiController extends BaseApiController { | |||
| return outputSuccess(count).toJSON(); | |||
| } | |||
| @InnerAuth | |||
| @GetMapping(value = "init-attendance") | |||
| @ResponseBody | |||
| public JSONObject initAttendance(@RequestParam("tenantId") Long tenantId){ | |||
| dmStaffService.initEmpAttendances(tenantId); | |||
| return outputSuccess("初始化当天考勤数据成功").toJSON(); | |||
| } | |||
| } | |||
| @@ -5,7 +5,7 @@ import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmVisitCommonDto; | |||
| import com.xueyi.system.api.staff.feign.RemoteVisitorService; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import com.xueyi.system.staff.mapper.DmStaffMapper; | |||
| import com.xueyi.system.staff.mapper.DmVisitRecordsMapper; | |||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | |||
| @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/visit/api") | |||
| public class DmVisitorApiController extends BaseApiController { | |||
| public class DmVisitorApiController extends MyBaseApiController { | |||
| @Autowired | |||
| @@ -1,5 +1,6 @@ | |||
| package com.xueyi.system.staff.controller.api; | |||
| import cn.hutool.core.date.LocalDateTimeUtil; | |||
| import cn.hutool.core.util.ObjectUtil; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| @@ -14,7 +15,7 @@ import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.security.annotation.InnerAuth; | |||
| import com.xueyi.common.sms.configure.SmsProperties; | |||
| import com.xueyi.common.web.constant.ResponseCode; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.file.api.domain.SysFile; | |||
| import com.xueyi.file.api.feign.RemoteFileService; | |||
| import com.xueyi.system.api.dict.domain.dto.SysDictDataDto; | |||
| @@ -34,7 +35,7 @@ import com.xueyi.system.digitalmans.mapper.DmDigitalmanMapper; | |||
| import com.xueyi.system.meeting.constant.VisitRecordStatus; | |||
| import com.xueyi.system.receiver.domain.po.DmTenantReceiverPo; | |||
| import com.xueyi.system.receiver.mapper.DmTenantReceiverMapper; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl; | |||
| import com.xueyi.system.resource.service.impl.FaceServiceImpl; | |||
| @@ -69,7 +70,7 @@ import java.util.stream.Collectors; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/visit/inner-api") | |||
| public class DmVisitorInnerApiController extends BaseApiController { | |||
| public class DmVisitorInnerApiController extends MyBaseApiController { | |||
| @Autowired | |||
| @@ -151,7 +152,7 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| } | |||
| v.setRecordStatus(DmVisitRecordsDto.STATUS_VISITED); | |||
| v.setUpdateTime(DateUtils.dateToLocalDateTime(new Date())); | |||
| v.setUpdateTime(MyDateUtils.dateToLocalDateTime(new Date())); | |||
| dmVisitRecordsMapper.updateById(v); | |||
| return outputSuccess(json).toJSON(); | |||
| @@ -217,7 +218,7 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| visitRecords.setDeptId(emp.getDeptId()); | |||
| visitRecords.setVisitorId(v.getId()); | |||
| if (StringUtils.isNotEmpty(commonDto.getVisitDate())) { | |||
| visitRecords.setVisitDate(DateUtils.parseStrToDate(commonDto.getVisitDate(), "yyyy-MM-dd")); | |||
| visitRecords.setVisitDate(LocalDateTimeUtil.of(MyDateUtils.parseStrToDate(commonDto.getVisitDate(), MyDateUtils.DEFAULT_DATE_PATTERN)).toLocalDate()); | |||
| } | |||
| visitRecords.setUserId(commonDto.getEmpId()); | |||
| visitRecords.setRecordStatus(VisitRecordStatus.getRecordStatusStart()); | |||
| @@ -323,7 +324,7 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| d.setVisitorName(visitorsPo.getName()); | |||
| } | |||
| if (null != item.getVisitDate()) { | |||
| d.setVisitDateStr(DateUtils.formatDate(item.getVisitDate(), "yyyy-MM-dd")); | |||
| d.setVisitDateStr(LocalDateTimeUtil.format(item.getVisitDate(), MyDateUtils.DEFAULT_DATE_PATTERN)); | |||
| } | |||
| dtos.add(d); | |||
| }); | |||
| @@ -353,7 +354,7 @@ public class DmVisitorInnerApiController extends BaseApiController { | |||
| d.setVisitorName(visitorsPo.getName()); | |||
| } | |||
| if (null != item.getVisitDate()) { | |||
| d.setVisitDateStr(DateUtils.formatDate(item.getVisitDate(), "yyyy-MM-dd")); | |||
| d.setVisitDateStr(LocalDateTimeUtil.format(item.getVisitDate(), MyDateUtils.DEFAULT_DATE_PATTERN)); | |||
| } | |||
| dtos.add(d); | |||
| } | |||
| @@ -1,13 +1,10 @@ | |||
| package com.xueyi.system.staff.domain.dto; | |||
| import com.xueyi.common.core.annotation.Excel; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.system.api.organize.domain.po.SysDeptPo; | |||
| import com.xueyi.system.organize.mapper.SysDeptMapper; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.staff.domain.po.DmEmpAttendancePo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import java.io.Serial; | |||
| @@ -36,11 +33,11 @@ public class DmEmpAttendanceDto extends DmEmpAttendancePo { | |||
| public DmEmpAttendanceDto fixExcel(){ | |||
| if (this.checkInTime != null){ | |||
| this.sTime = DateUtils.formatDate(this.checkInTime, "HH:mm"); | |||
| this.sTime = MyDateUtils.formatDate(this.checkInTime, MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| } | |||
| if (this.checkOutTime != null) { | |||
| this.eTime = DateUtils.formatDate(this.checkOutTime, "HH:mm"); | |||
| this.eTime = MyDateUtils.formatDate(this.checkOutTime, MyDateUtils.DEFAULT_TIME_PATTERN); | |||
| } | |||
| @@ -10,7 +10,7 @@ import com.alibaba.excel.enums.poi.FillPatternTypeEnum; | |||
| import com.alibaba.excel.util.ListUtils; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.xueyi.common.core.web.tenant.base.TBaseEntity; | |||
| import com.xueyi.common.web.utils.DateUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.staff.domain.converter.DurationConverter; | |||
| import com.xueyi.system.staff.domain.converter.UserTypeConverter; | |||
| import lombok.Data; | |||
| @@ -82,21 +82,23 @@ public class DmEmpAttendancePo extends TBaseEntity { | |||
| // @ExcelProperty(value = "考勤状态", converter = DescTypeConverter.class) | |||
| protected Integer descStatus; | |||
| protected Long tenantId; | |||
| public static List<List<String>> head(Date startDate, Date endDate) { | |||
| List<String> base = Arrays.asList("考勤记录", DateUtils.formatDate(startDate,"yyyy年MM月dd日")+" 到 "+DateUtils.formatDate(endDate,"yyyy年MM月dd日")); | |||
| List<String> base = Arrays.asList("考勤记录", MyDateUtils.formatDate(startDate,"yyyy年MM月dd日")+" 到 "+ MyDateUtils.formatDate(endDate,"yyyy年MM月dd日")); | |||
| List<List<String>> head = ListUtils.newArrayList(); | |||
| List<String> _headRow = ListUtils.newArrayList(base); | |||
| _headRow.add(DateUtils.formatDate(startDate, "姓名")); | |||
| _headRow.add(MyDateUtils.formatDate(startDate, "姓名")); | |||
| head.add(_headRow); | |||
| //从startDate到endDate开始循环 | |||
| while (startDate.compareTo(endDate) <= 0) { | |||
| List<String> headRow = ListUtils.newArrayList(base); | |||
| headRow.add(DateUtils.formatDate(startDate, "MM月dd日")); | |||
| headRow.add(MyDateUtils.formatDate(startDate, "MM月dd日")); | |||
| List<String> headRow2 = ListUtils.newArrayList(headRow); | |||
| headRow2.add(DateUtils.getChineseWeek(startDate)); | |||
| headRow2.add(MyDateUtils.getChineseWeek(startDate)); | |||
| head.add(headRow2); | |||
| startDate = DateUtils.addDays(startDate, 1); | |||
| startDate = MyDateUtils.addDays(startDate, 1); | |||
| } | |||
| return head; | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| package com.xueyi.system.staff.graphql; | |||
| import cn.hutool.core.date.LocalDateTimeUtil; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.api.pass.domain.dto.DmRecognizedRecordsDto; | |||
| import com.xueyi.system.api.pass.domain.po.DmRecognizedRecordsPo; | |||
| import com.xueyi.system.pass.domain.model.DmRecognizedRecordsConverter; | |||
| import com.xueyi.system.pass.mapper.DmRecognizedRecordsMapper; | |||
| import graphql.kickstart.tools.GraphQLQueryResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| import java.time.LocalDate; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| /* | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-12-25 19:55 | |||
| */ | |||
| @Component | |||
| class PassRecordsGraphQLQueryResolver implements GraphQLQueryResolver { | |||
| @Autowired | |||
| private DmRecognizedRecordsMapper mapper; | |||
| @Autowired | |||
| private DmRecognizedRecordsConverter converter; | |||
| public DmRecognizedRecordsDto passRecord(Long id) { | |||
| return converter.mapperDto(mapper.selectById(id)); | |||
| } | |||
| public List<DmRecognizedRecordsDto> passRecords(String userName, Long userId, Integer type, LocalDate startDate, LocalDate endDate){ | |||
| QueryWrapper<DmRecognizedRecordsPo> query = new QueryWrapper<>(); | |||
| if (StringUtils.isNotEmpty(userName)) { | |||
| query.like("user_name", userName); | |||
| } | |||
| if (null != userId) { | |||
| query.eq("user_id", userId); | |||
| } | |||
| if (null != type) { | |||
| query.eq("type", type); | |||
| } | |||
| if (null != startDate && null != endDate){ | |||
| query.between("recognized_time", LocalDateTimeUtil.format(startDate, MyDateUtils.DEFAULT_DATE_PATTERN),LocalDateTimeUtil.format(endDate, MyDateUtils.DEFAULT_DATE_PATTERN)); | |||
| } | |||
| return mapper.selectList(query).stream().map(t->converter.mapperDto(t)).collect(Collectors.toList()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,46 @@ | |||
| package com.xueyi.system.staff.graphql; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A; | |||
| import com.xueyi.common.core.utils.core.IdUtil; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitRecordsPo; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitorsPo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmVisitCommonDto; | |||
| import com.xueyi.system.api.staff.domain.dto.GraphqlVisitRecordInput; | |||
| import com.xueyi.system.staff.domain.model.DmVisitRecordsConverter; | |||
| import com.xueyi.system.staff.domain.model.DmVisitorsConverter; | |||
| import com.xueyi.system.staff.domain.query.DmVisitRecordsQuery; | |||
| import com.xueyi.system.staff.mapper.DmVisitRecordsMapper; | |||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | |||
| import graphql.kickstart.tools.GraphQLMutationResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.Date; | |||
| /* | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-12-25 19:55 | |||
| */ | |||
| @Component | |||
| class VisitRecordGraphQLMutationResolver implements GraphQLMutationResolver { | |||
| @Autowired | |||
| private DmVisitRecordsMapper mapper; | |||
| @Autowired | |||
| private DmVisitorsMapper visitorsMapper; | |||
| @Autowired | |||
| private DmVisitRecordsConverter converter; | |||
| public boolean saveVisitRecord(DmVisitRecordsPo input){ | |||
| return mapper.insert(input) > 0; | |||
| } | |||
| public Boolean deleteVisitRecord(Long id){ | |||
| return mapper.deleteById(id) > 0; | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| package com.xueyi.system.staff.graphql; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmVisitRecordsDto; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitRecordsPo; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitorsPo; | |||
| import com.xueyi.system.staff.domain.model.DmVisitRecordsConverter; | |||
| import com.xueyi.system.staff.domain.model.DmVisitorsConverter; | |||
| import com.xueyi.system.staff.domain.query.DmVisitRecordsQuery; | |||
| import com.xueyi.system.staff.mapper.DmVisitRecordsMapper; | |||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | |||
| import graphql.kickstart.tools.GraphQLQueryResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| /* | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-12-25 19:55 | |||
| */ | |||
| @Component | |||
| class VisitRecordsGraphQLQueryResolver implements GraphQLQueryResolver { | |||
| @Autowired | |||
| private DmVisitRecordsMapper mapper; | |||
| @Autowired | |||
| private DmVisitorsMapper visitorsMapper; | |||
| @Autowired | |||
| private DmVisitRecordsConverter converter; | |||
| @Autowired | |||
| private DmVisitorsConverter visitorsConverter; | |||
| public DmVisitRecordsDto visitRecord(Long id) { | |||
| return converter.mapperDto(mapper.selectById(id)); | |||
| } | |||
| public List<DmVisitRecordsDto> visitRecords(String receiverName, String receiverPhone, Long visitorId){ | |||
| QueryWrapper<DmVisitRecordsPo> query = new QueryWrapper<>(); | |||
| if (StringUtils.isNotEmpty(receiverName)) { | |||
| query.like("receiver_name", receiverName); | |||
| } | |||
| if (StringUtils.isNotEmpty(receiverPhone)) { | |||
| query.eq("receiver_phone", receiverPhone); | |||
| } | |||
| if (null != visitorId) { | |||
| query.eq("visitor_id", visitorId); | |||
| } | |||
| return mapper.selectList(query).stream().map( | |||
| t -> { | |||
| DmVisitorsPo po = visitorsMapper.selectById(t.getVisitorId()); | |||
| DmVisitRecordsDto dto = converter.mapperDto(t); | |||
| dto.setVisitor(visitorsConverter.mapperDto(po)); | |||
| return dto; | |||
| } | |||
| ).collect(Collectors.toList()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,58 @@ | |||
| package com.xueyi.system.staff.graphql; | |||
| import com.alibaba.excel.util.BooleanUtils; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitorsPo; | |||
| import com.xueyi.system.api.resource.domain.po.DmResourcesPo; | |||
| import com.xueyi.system.resource.mapper.DmResourcesMapper; | |||
| import com.xueyi.system.staff.domain.model.DmVisitorsConverter; | |||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | |||
| import graphql.kickstart.tools.GraphQLMutationResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| /* | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-12-25 19:55 | |||
| */ | |||
| @Component | |||
| class VisitorGraphQLMutationResolver implements GraphQLMutationResolver { | |||
| @Autowired | |||
| private DmVisitorsMapper mapper; | |||
| @Autowired | |||
| private DmVisitorsConverter converter; | |||
| @Autowired | |||
| private DmResourcesMapper resourcesMapper; | |||
| public boolean saveVisitor(String name, String nickname, String phone, Boolean isVip, Boolean flexVisit, Boolean isBlock, Long resourceId){ | |||
| DmVisitorsPo dto =new DmVisitorsPo(); | |||
| dto.setPhone(phone); | |||
| dto.setNickname(nickname); | |||
| dto.setName(name); | |||
| dto.setIsVip(isVip); | |||
| if (BooleanUtils.isTrue(isVip)) { | |||
| dto.setType(9L); | |||
| } else { | |||
| dto.setType(8L); | |||
| } | |||
| dto.setFlexVisit(flexVisit); | |||
| dto.setIsBlock(isBlock); | |||
| dto.setResourceId(resourceId); | |||
| if (null != resourceId) { | |||
| DmResourcesPo resourcesPo = resourcesMapper.selectById(resourceId); | |||
| if (null != resourcesPo) { | |||
| dto.setAvatar(resourcesPo.getUrl()); | |||
| } | |||
| } | |||
| return mapper.updateById(dto) > 0; | |||
| } | |||
| public Boolean deleteVisitor(Long id){ | |||
| return mapper.deleteById(id) > 0; | |||
| } | |||
| } | |||
| @@ -1,24 +1,24 @@ | |||
| /* | |||
| package com.xueyi.system.staff.graphql; | |||
| import com.coxautodev.graphql.tools.GraphQLQueryResolver; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmVisitorsDto; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitorsPo; | |||
| import com.xueyi.system.staff.domain.model.DmVisitorsConverter; | |||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | |||
| import graphql.kickstart.tools.GraphQLQueryResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| */ | |||
| /** | |||
| /* | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-12-25 19:55 | |||
| *//* | |||
| */ | |||
| @Service | |||
| @Component | |||
| class VisitorGraphQLQueryResolver implements GraphQLQueryResolver { | |||
| @Autowired | |||
| private DmVisitorsMapper mapper; | |||
| @@ -26,12 +26,29 @@ class VisitorGraphQLQueryResolver implements GraphQLQueryResolver { | |||
| @Autowired | |||
| private DmVisitorsConverter converter; | |||
| public DmVisitorsPo findOneVisitor(Long id){ | |||
| return mapper.selectById(id); | |||
| public DmVisitorsDto visitor(Long id){ | |||
| return converter.mapperDto(mapper.selectById(id)); | |||
| } | |||
| public List<DmVisitorsPo> getVisitorList(){ | |||
| return mapper.selectList(null).stream().map(t->converter.mapperDto(t)).collect(Collectors.toList()); | |||
| public List<DmVisitorsDto> visitors(Long id, String name, Integer type, String phone){ | |||
| QueryWrapper<DmVisitorsPo> query = new QueryWrapper<>(); | |||
| if (null != id) { | |||
| query.eq("id", id); | |||
| } | |||
| if (StringUtils.isNotEmpty(name)) { | |||
| query.like("name", name); | |||
| } | |||
| if (null != type) { | |||
| query.eq("type", type); | |||
| } | |||
| if (StringUtils.isNotEmpty(phone)) { | |||
| query.eq("phone", phone); | |||
| } | |||
| return mapper.selectList(query).stream().map(t->converter.mapperDto(t)).toList(); | |||
| } | |||
| } | |||
| */ | |||
| @@ -0,0 +1,89 @@ | |||
| package com.xueyi.system.staff.graphql.config; | |||
| import graphql.ExecutionResult; | |||
| import graphql.GraphQL; | |||
| import graphql.GraphQLContext; | |||
| import graphql.execution.instrumentation.ExecutionStrategyInstrumentationContext; | |||
| import graphql.execution.instrumentation.Instrumentation; | |||
| import graphql.execution.instrumentation.InstrumentationContext; | |||
| import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperationParameters; | |||
| import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters; | |||
| import graphql.execution.instrumentation.parameters.InstrumentationExecutionStrategyParameters; | |||
| import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters; | |||
| import graphql.execution.instrumentation.parameters.InstrumentationFieldParameters; | |||
| import graphql.execution.instrumentation.parameters.InstrumentationValidationParameters; | |||
| import graphql.kickstart.autoconfigure.tools.GraphQLJavaToolsAutoConfiguration; | |||
| import graphql.kickstart.tools.GraphQLResolver; | |||
| import graphql.kickstart.tools.SchemaParser; | |||
| import graphql.language.Document; | |||
| import graphql.schema.GraphQLSchema; | |||
| import graphql.validation.ValidationError; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.context.annotation.Import; | |||
| import java.util.List; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-04 22:03 | |||
| */ | |||
| @Configuration | |||
| @Import(GraphQLJavaToolsAutoConfiguration.class) | |||
| public class GraphQLConfig { | |||
| @Bean | |||
| public GraphQL graphQL(List<GraphQLResolver<?>> resolvers, List<SchemaParser> schemaParsers, GraphQLSchema graphQLSchema) { | |||
| return GraphQL.newGraphQL(graphQLSchema) | |||
| .instrumentation(new SimpleAuthInstrumentation()) | |||
| .build(); | |||
| } | |||
| private static class SimpleAuthInstrumentation implements Instrumentation { | |||
| Logger logger = LoggerFactory.getLogger(SimpleAuthInstrumentation.class); | |||
| @Override | |||
| public InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public InstrumentationContext<List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters) { | |||
| GraphQLContext context = parameters.getExecutionContext().getGraphQLContext(); | |||
| // 从上下文中获取请求头中的token | |||
| String token = context.get("Authorization"); | |||
| logger.error("token: {}", token); | |||
| return null; | |||
| } | |||
| @Override | |||
| public ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public InstrumentationContext<ExecutionResult> beginField(InstrumentationFieldParameters parameters) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public InstrumentationContext<Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters) { | |||
| return null; | |||
| } | |||
| } | |||
| } | |||
| @@ -4,7 +4,7 @@ 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.common.web.utils.MyDateUtils; | |||
| import com.xueyi.system.api.organize.domain.vo.SysDeptExt; | |||
| import com.xueyi.system.api.pass.domain.po.DmRecognizedRecordsPo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffDto; | |||
| @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import javax.annotation.PostConstruct; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| @@ -120,6 +121,35 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| return totalCount.longValue(); | |||
| } | |||
| public void initEmpAttendance(DmStaffPo po) { | |||
| // 初始化员工考勤信息 | |||
| DmEmpAttendancePo attendancePo = new DmEmpAttendancePo(); | |||
| attendancePo.setUserId(po.getId()); | |||
| attendancePo.setUserName(po.getUserName()); | |||
| attendancePo.setDateStr(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN)); | |||
| dmEmpAttendanceMapper.insert(attendancePo); | |||
| } | |||
| @TenantIgnore(tenantLine = true) | |||
| public void initEmpAttendances(Long tenantId) { | |||
| List<DmStaffPo> lists = staffMapper.selectList(new QueryWrapper<DmStaffPo>().eq("tenant_id", tenantId)); | |||
| List<DmEmpAttendancePo> attendancePos = new ArrayList<>(); | |||
| for (DmStaffPo po : lists) { | |||
| if (po != null && po.getId() != null) { | |||
| DmEmpAttendancePo attendancePo = new DmEmpAttendancePo(); | |||
| attendancePo.setUserId(po.getId()); | |||
| attendancePo.setUserName(po.getUserName()); | |||
| attendancePo.setTenantId(po.getTenantId()); | |||
| attendancePo.setDescStatus(3); | |||
| attendancePo.setDateStr(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN)); | |||
| attendancePos.add(attendancePo); | |||
| } | |||
| } | |||
| if (attendancePos.size() > 0) { | |||
| dmEmpAttendanceMapper.insertBatch(attendancePos); | |||
| } | |||
| } | |||
| public void updateOrInsertAttendance(DmRecognizedRecordsPo checkRecords) { | |||
| if (null == checkRecords.getUserId()) { | |||
| @@ -131,8 +161,8 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| return ; | |||
| } | |||
| Date checkTime = checkRecords.getRecognizedTime(); | |||
| String checkTimeDateStr = DateUtils.formatDate(checkTime, "yyyy-MM-dd"); | |||
| Date checkTime = MyDateUtils.localDateTimeToDate(checkRecords.getRecognizedTime()); | |||
| String checkTimeDateStr = MyDateUtils.formatDate(checkTime, MyDateUtils.DEFAULT_DATE_PATTERN); | |||
| if (StringUtils.isEmpty(checkTimeDateStr)) { | |||
| return ; | |||
| } | |||
| @@ -154,11 +184,11 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| if (null!=empAttendance.getCheckInTime() && null != empAttendance.getCheckOutTime()) { | |||
| Date cin = empAttendance.getCheckInTime(); | |||
| Date cout = empAttendance.getCheckOutTime(); | |||
| Integer diffMin = DateUtils.dateDiffMin(cin, cout); | |||
| Integer diffMin = MyDateUtils.dateDiffMin(cin, cout); | |||
| empAttendance.setWorkDuration(diffMin); | |||
| } | |||
| if (DateUtils.formatDate(checkTime, "HH:mm").compareTo(ext.getOffDutyHourStart()) < 0) { | |||
| if (MyDateUtils.formatDate(checkTime, MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOffDutyHourStart()) < 0) { | |||
| if (statusMap.get("NORMAL") == empAttendance.getDescStatus()) { | |||
| empAttendance.setDescStatus(statusMap.get("LEAVE_EARLY")); | |||
| } else if (statusMap.get("BE_LATER") == empAttendance.getDescStatus()){ | |||
| @@ -177,10 +207,10 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| } else { | |||
| DmEmpAttendancePo ea = new DmEmpAttendancePo(); | |||
| Date checkDate = DateUtils.parseStrToDate(DateUtils.formatDate(checkTime, "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd HH:mm:ss"); | |||
| Date checkDate = checkTime; | |||
| ea.setCheckInTime(checkDate); | |||
| DmHolidayPo holidayPo = holidayService.isHoliday(checkDate); | |||
| if (DateUtils.formatDate(checkDate, "HH:mm").compareTo(ext.getOnDutyHourEnd()) > 0) { | |||
| if (MyDateUtils.formatDate(checkDate, MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOnDutyHourEnd()) > 0) { | |||
| ea.setDescStatus(statusMap.get("BE_LATER")); // 迟到 | |||
| if (holidayPo.getHoliday() == 1) { | |||
| ea.setDescStatus(statusMap.get("OVERTIME")); | |||
| @@ -191,14 +221,14 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| } | |||
| } | |||
| ea.setDateStr(DateUtils.formatDate(new Date(), "yyyy-MM-dd")); | |||
| 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(DateUtils.currentDateToLocalDateTime()); | |||
| ea.setUpdateTime(DateUtils.currentDateToLocalDateTime()); | |||
| ea.setCreateTime(MyDateUtils.currentDateToLocalDateTime()); | |||
| ea.setUpdateTime(MyDateUtils.currentDateToLocalDateTime()); | |||
| dmEmpAttendanceService.updRedisCount(); | |||
| dmEmpAttendanceMapper.insert(ea); | |||
| @@ -1,128 +0,0 @@ | |||
| package com.xueyi.system.wechat.controller; | |||
| import com.baomidou.dynamic.datasource.toolkit.CryptoUtils; | |||
| import com.fasterxml.jackson.core.JsonProcessingException; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.utils.core.CryptoUtil; | |||
| import com.xueyi.common.core.utils.core.ObjectUtil; | |||
| import com.xueyi.common.core.web.result.AjaxResult; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.security.service.TokenService; | |||
| import com.xueyi.system.api.authority.feign.RemoteLoginService; | |||
| import com.xueyi.system.api.model.LoginUser; | |||
| import com.xueyi.system.wechat.domain.bean.WeChatSessionResponse; | |||
| import com.xueyi.system.wechat.domain.bean.WeChatSignUpReq; | |||
| import com.xueyi.system.wechat.domain.po.WeChatUserInfo; | |||
| import com.xueyi.system.wechat.service.WeChatService; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| 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.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestMethod; | |||
| import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-02 12:42 | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/api/wechat") | |||
| public class WeChatController { | |||
| Logger log = LoggerFactory.getLogger(WeChatController.class); | |||
| @Autowired | |||
| private WeChatService weChatService; | |||
| @Autowired | |||
| RemoteTenantService tenantService; | |||
| @Autowired | |||
| RemoteLoginService remoteLoginService; | |||
| @Autowired | |||
| TokenService tokenService; | |||
| @RequestMapping(value = "/login", method = {RequestMethod.GET}) | |||
| public AjaxResult login(@RequestParam("code") String code, HttpServletResponse response) { | |||
| // 根据code获取微信用户信息 | |||
| WeChatSessionResponse weChatUserInfo = null; | |||
| try { | |||
| weChatUserInfo = weChatService.getUserInfo(code); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| response.setStatus(500); | |||
| return AjaxResult.error("微信服务器请求openid失败"); | |||
| } | |||
| log.info("微信login返回信息:{}", weChatUserInfo); | |||
| R<SysEnterpriseStaff> staff = tenantService.existStaff(weChatUserInfo.getOpenid(), SecurityConstants.INNER); | |||
| Map<String, Object> map = new HashMap<>(); | |||
| try { | |||
| map.put("wechat_auth", CryptoUtil.encrypt(weChatUserInfo.toString())); | |||
| if (staff.getData() != null) { | |||
| R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByPhone(staff.getData().getPhone(), SecurityConstants.INNER); | |||
| map.putAll(tokenService.createToken(loginInfoResult.getData())); | |||
| return AjaxResult.success(map); | |||
| } | |||
| return AjaxResult.success(map); | |||
| } catch (Exception e){ | |||
| e.printStackTrace(); | |||
| response.setStatus(500); | |||
| return AjaxResult.error("服务器异常"); | |||
| } | |||
| } | |||
| @PostMapping("/signup") | |||
| public AjaxResult signup(@RequestBody WeChatSignUpReq signUpReq, HttpServletResponse response) { | |||
| String decodeStr = weChatService.decrypt(signUpReq.getEncryptedData(), signUpReq.getIv(), signUpReq.getWeappAuth()); | |||
| ObjectMapper objectMapper = new ObjectMapper(); | |||
| WeChatUserInfo userInfo = null; | |||
| try { | |||
| userInfo = objectMapper.readValue(decodeStr, WeChatUserInfo.class); | |||
| } catch (JsonProcessingException e) { | |||
| response.setStatus(500); | |||
| // throw new RuntimeException(e); | |||
| return AjaxResult.error("解析错误"); | |||
| } | |||
| R<SysEnterpriseStaff> staff = tenantService.existStaff(userInfo.getPhoneNumber(), SecurityConstants.INNER); | |||
| String phone = null; | |||
| if (staff.getData() == null) { | |||
| SysEnterpriseStaff staff1 = new SysEnterpriseStaff(); | |||
| // staff1.setOpenid(userInfo.get); | |||
| staff1.setPhone(userInfo.getPhoneNumber()); | |||
| tenantService.saveEnterpriseStaff(staff1, SecurityConstants.INNER); | |||
| phone = userInfo.getPhoneNumber(); | |||
| } else { | |||
| phone = staff.getData().getPhone(); | |||
| } | |||
| R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByPhone(phone, SecurityConstants.INNER); | |||
| log.info("根据手机号获取用户信息返回:{}", loginInfoResult.getData().getEnterpriseName()); | |||
| if (ObjectUtil.isNull(loginInfoResult.getData())) { | |||
| response.setStatus(500); | |||
| return AjaxResult.error("手机号可能错误,请查证后重试!", signUpReq); | |||
| } else { | |||
| Map<String, Object> map = tokenService.createToken(loginInfoResult.getData()); | |||
| // map.put("openid", signUpReq.getOpenid()); | |||
| return AjaxResult.success(map); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,190 @@ | |||
| package com.xueyi.system.wechat.controller; | |||
| import com.alibaba.fastjson2.JSON; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.utils.JwtUtil; | |||
| import com.xueyi.common.core.utils.core.CryptoUtil; | |||
| import com.xueyi.common.core.utils.core.ObjectUtil; | |||
| import com.xueyi.common.core.web.result.AjaxResult; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.security.service.TokenService; | |||
| import com.xueyi.common.security.utils.SecurityUtils; | |||
| import com.xueyi.system.api.authority.feign.RemoteLoginService; | |||
| import com.xueyi.system.api.model.LoginUser; | |||
| import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| import com.xueyi.system.api.staff.feign.RemoteStaffService; | |||
| import com.xueyi.system.wechat.domain.bean.WeappSessionResponse; | |||
| import com.xueyi.system.wechat.domain.bean.WeappSignUpReq; | |||
| import com.xueyi.system.wechat.domain.po.WeappUserInfo; | |||
| import com.xueyi.system.wechat.service.WeappService; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| 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.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestMethod; | |||
| import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-02 12:42 | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/api/weapp") | |||
| public class WeappController { | |||
| Logger log = LoggerFactory.getLogger(WeappController.class); | |||
| @Autowired | |||
| private WeappService weappService; | |||
| @Autowired | |||
| RemoteTenantService tenantService; | |||
| @Autowired | |||
| RemoteLoginService remoteLoginService; | |||
| @Autowired | |||
| RemoteStaffService staffService; | |||
| @Autowired | |||
| TokenService tokenService; | |||
| @RequestMapping(value = "/login", method = {RequestMethod.GET}) | |||
| public AjaxResult login(@RequestParam("code") String code, HttpServletResponse response) { | |||
| // 根据code获取微信用户信息 | |||
| WeappSessionResponse weChatUserInfo = null; | |||
| try { | |||
| weChatUserInfo = weappService.getUserInfo(code); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| response.setStatus(500); | |||
| return AjaxResult.error("微信服务器请求openid失败"); | |||
| } | |||
| log.info("微信login返回信息:{}", weChatUserInfo); | |||
| R<SysEnterpriseStaff> staffR = tenantService.queryStaff(weChatUserInfo.getOpenid(), SecurityConstants.INNER); | |||
| Map<String, Object> map = new HashMap<>(); | |||
| try { | |||
| map.put("weappAuth", CryptoUtil.encrypt(weChatUserInfo.toString())); | |||
| SysEnterpriseStaff staff = staffR.getData(); | |||
| log.info("login staff:{}", staff); | |||
| if (staff != null) { | |||
| log.info("login phone:{}", staff.getPhone()); | |||
| R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByPhone(staff.getPhone(), SecurityConstants.INNER); | |||
| map.putAll(tokenService.createToken(loginInfoResult.getData())); | |||
| String token = (String)map.get("access_token"); | |||
| log.info("信息,token:{}, enterpriseName:{}, source:{}", token, JwtUtil.getEnterpriseName(token),JwtUtil.getSourceName(token)); | |||
| JSONObject json = staffService.fetchStaffByPhone(staff.getPhone(), Long.valueOf(JwtUtil.getEnterpriseId(token)), JwtUtil.getSourceName(token), SecurityConstants.INNER); | |||
| map.put("enterpriseName", loginInfoResult.getData().getEnterpriseName()); | |||
| map.put("staff", json.get("data")); | |||
| return AjaxResult.success(map); | |||
| } | |||
| return AjaxResult.success(map); | |||
| } catch (Exception e){ | |||
| e.printStackTrace(); | |||
| response.setStatus(500); | |||
| return AjaxResult.error("服务器异常"); | |||
| } | |||
| } | |||
| @PostMapping("/signup") | |||
| public AjaxResult signup(@RequestBody WeappSignUpReq signUpReq, HttpServletResponse response) { | |||
| log.info("微信注册请求信息:{}", signUpReq); | |||
| if (signUpReq == null || StringUtils.isEmpty(signUpReq.getWeappAuth())) { | |||
| response.setStatus(500); | |||
| return AjaxResult.error("请求参数错误"); | |||
| } | |||
| String decodeStr = null; | |||
| WeappSessionResponse obj = null; | |||
| try { | |||
| String str = CryptoUtil.decrypt(signUpReq.getWeappAuth()); | |||
| obj = JSON.parseObject(str, WeappSessionResponse.class); | |||
| decodeStr = weappService.decrypt(signUpReq.getEncryptedData(), signUpReq.getIv(), obj); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| response.setStatus(500); | |||
| return AjaxResult.error("微信数据解析错误"); | |||
| } | |||
| WeappUserInfo userInfo = null; | |||
| try { | |||
| userInfo = JSON.parseObject(decodeStr, WeappUserInfo.class); | |||
| // userInfo = objectMapper.readValue(decodeStr, WeChatUserInfo.class); | |||
| } catch (Exception e) { | |||
| response.setStatus(500); | |||
| // throw new RuntimeException(e); | |||
| return AjaxResult.error("WeChatUserInfo解析错误"); | |||
| } | |||
| String phone = userInfo.getPurePhoneNumber(); | |||
| log.info("微信用户信息:{}, phone:{}", userInfo, phone); | |||
| R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByPhone(phone, SecurityConstants.INNER); | |||
| if (ObjectUtil.isNull(loginInfoResult.getData()) || loginInfoResult.isFail()) { | |||
| log.info("根据手机号获取用户信息返回:{}", loginInfoResult); | |||
| response.setStatus(401); | |||
| return AjaxResult.error("手机号无对应员工,请查证后重试!"); | |||
| } else { | |||
| Map<String, Object> map = tokenService.createToken(loginInfoResult.getData()); | |||
| R<SysEnterpriseStaff> enterpriseStaffR = tenantService.queryStaff(phone, SecurityConstants.INNER); | |||
| log.info("根据手机号查询员工返回:{}", enterpriseStaffR); | |||
| if (!enterpriseStaffR.isFail() && enterpriseStaffR.getData() != null){ | |||
| SysEnterpriseStaff enterpriseStaff = enterpriseStaffR.getData(); | |||
| enterpriseStaff.setOpenid(obj.getOpenid()); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| } | |||
| String token = (String)map.get("access_token"); | |||
| log.info("信息,token:{}, enterpriseName:{}, source:{}", token, JwtUtil.getEnterpriseName(token),JwtUtil.getSourceName(token)); | |||
| JSONObject json = staffService.fetchStaffByPhone(phone, Long.valueOf(JwtUtil.getEnterpriseId(token)), JwtUtil.getSourceName(token), SecurityConstants.INNER); | |||
| map.put("enterpriseName", loginInfoResult.getData().getEnterpriseName()); | |||
| map.put("staff", json.get("data")); | |||
| return AjaxResult.success(map); | |||
| } | |||
| } | |||
| @PostMapping("/signout") | |||
| public AjaxResult signout(@RequestBody WeappSignUpReq signUpReq, HttpServletResponse response) { | |||
| log.info("微信登出请求信息:{}", signUpReq); | |||
| if (signUpReq == null || StringUtils.isEmpty(signUpReq.getWeappAuth())) { | |||
| response.setStatus(500); | |||
| return AjaxResult.error("请求参数错误"); | |||
| } | |||
| try { | |||
| String str = CryptoUtil.decrypt(signUpReq.getWeappAuth()); | |||
| WeappSessionResponse obj = JSON.parseObject(str, WeappSessionResponse.class); | |||
| R<SysEnterpriseStaff> enterpriseStaffR = tenantService.queryStaff(obj.getOpenid(), SecurityConstants.INNER); | |||
| log.info("根据手机号查询员工返回:{}", enterpriseStaffR); | |||
| if (!enterpriseStaffR.isFail() && enterpriseStaffR.getData() != null){ | |||
| SysEnterpriseStaff enterpriseStaff = enterpriseStaffR.getData(); | |||
| enterpriseStaff.setOpenid(null); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| } | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| response.setStatus(500); | |||
| return AjaxResult.error("服务器出错,登出失败"); | |||
| } | |||
| return AjaxResult.success(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.xueyi.system.wechat.domain.bean; | |||
| import lombok.Data; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-04 11:04 | |||
| */ | |||
| @Data | |||
| public class Watermark { | |||
| private Long timestamp; | |||
| private String appid; | |||
| } | |||
| @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; | |||
| import lombok.Data; | |||
| @Data | |||
| public class WeChatSessionResponse { | |||
| public class WeappSessionResponse { | |||
| @JsonProperty("openid") | |||
| private String openid; | |||
| @@ -9,13 +9,16 @@ import lombok.Data; | |||
| * @date 2024-01-02 16:47 | |||
| */ | |||
| @Data | |||
| public class WeChatSignUpReq { | |||
| public class WeappSignUpReq { | |||
| private String iv; | |||
| private String encryptedData; | |||
| private JSONObject rawData; | |||
| private String signature; | |||
| private String weappAuth; | |||
| @Override | |||
| public String toString(){ | |||
| return JSONObject.toJSONString(this); | |||
| } | |||
| } | |||
| @@ -1,49 +0,0 @@ | |||
| package com.xueyi.system.wechat.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.xueyi.common.core.web.tenant.base.TBaseEntity; | |||
| import lombok.Data; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.CREATE_BY; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.CREATE_TIME; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.DEL_FLAG; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.NAME; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.REMARK; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.SORT; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.STATUS; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.UPDATE_BY; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.UPDATE_TIME; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-02 12:47 | |||
| */ | |||
| @Data | |||
| @TableName(value = "sys_wechat_user",excludeProperty = {STATUS, UPDATE_BY, SORT, CREATE_BY, DEL_FLAG, CREATE_TIME, UPDATE_TIME, REMARK, NAME }) | |||
| public class WeChatUserInfo extends TBaseEntity { | |||
| private String openId; | |||
| private String nickName; | |||
| private int gender; | |||
| private String city; | |||
| private String province; | |||
| private String country; | |||
| private String avatarUrl; | |||
| private String unionId; | |||
| private Watermark watermark; | |||
| private String phoneNumber; | |||
| // Getters and Setters | |||
| @Data | |||
| public static class Watermark { | |||
| private long timestamp; | |||
| private String appid; | |||
| // Getters and Setters | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.xueyi.system.wechat.domain.po; | |||
| import com.alibaba.fastjson2.JSON; | |||
| import com.xueyi.system.wechat.domain.bean.Watermark; | |||
| import lombok.Data; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-02 12:47 | |||
| */ | |||
| @Data | |||
| public class WeappUserInfo { | |||
| private String openId; | |||
| private String countryCode; | |||
| private Watermark watermark; | |||
| private String phoneNumber; | |||
| private String purePhoneNumber; | |||
| // Getters and Setters | |||
| @Override | |||
| public String toString(){ | |||
| return JSON.toJSONString(this); | |||
| } | |||
| } | |||
| @@ -1,16 +1,15 @@ | |||
| package com.xueyi.system.wechat.service; | |||
| import com.alibaba.fastjson2.JSON; | |||
| import com.xueyi.common.core.utils.core.CryptoUtil; | |||
| import com.xueyi.common.redis.utils.RedisUtil; | |||
| import com.xueyi.system.wechat.domain.bean.WeChatSessionResponse; | |||
| import com.xueyi.system.wechat.domain.bean.WeappSessionResponse; | |||
| import org.slf4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.http.converter.StringHttpMessageConverter; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.web.client.RestClientException; | |||
| import org.springframework.web.client.RestTemplate; | |||
| import org.springframework.web.client.UnknownContentTypeException; | |||
| import javax.crypto.Cipher; | |||
| import javax.crypto.SecretKey; | |||
| @@ -24,8 +23,8 @@ import java.util.Base64; | |||
| * @date 2024-01-02 12:43 | |||
| */ | |||
| @Service | |||
| public class WeChatService { | |||
| Logger log = org.slf4j.LoggerFactory.getLogger(WeChatService.class); | |||
| public class WeappService { | |||
| Logger log = org.slf4j.LoggerFactory.getLogger(WeappService.class); | |||
| public static final String WECHAT_REDIS_SESSION_KEY = "wechat:session_key:"; | |||
| @@ -38,7 +37,7 @@ public class WeChatService { | |||
| @Autowired | |||
| private RestTemplate restTemplate; | |||
| public WeChatSessionResponse getUserInfo(String code) { | |||
| public WeappSessionResponse getUserInfo(String code) { | |||
| log.info("appId: {}, appSecret: {}, code: {}",appId, appSecret, code); | |||
| // 向微信服务器发送请求,获取用户的openid和session_key | |||
| String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appId + | |||
| @@ -51,7 +50,7 @@ public class WeChatService { | |||
| // WeChatSessionResponse sessionResponse = restTemplate.getForObject(url, WeChatSessionResponse.class); | |||
| String str = restTemplate.getForObject(url, String.class); | |||
| log.info("sessionResponse: str {}", str); | |||
| WeChatSessionResponse sessionResponse = JSON.parseObject(str, WeChatSessionResponse.class); | |||
| WeappSessionResponse sessionResponse = JSON.parseObject(str, WeappSessionResponse.class); | |||
| log.info("sessionResponse: {}", sessionResponse); | |||
| RedisUtil.setVal(WECHAT_REDIS_SESSION_KEY+sessionResponse.getOpenid(), sessionResponse.getSessionKey()); | |||
| log.info("sessionResponse: {}", sessionResponse); | |||
| @@ -61,28 +60,26 @@ public class WeChatService { | |||
| } | |||
| public String decrypt(String encryptedData, String iv, String sessionKey) { | |||
| try { | |||
| // Base64 解码 | |||
| byte[] sessionKeyBytes = Base64.getDecoder().decode(sessionKey); | |||
| byte[] encryptedDataBytes = Base64.getDecoder().decode(encryptedData); | |||
| byte[] ivBytes = Base64.getDecoder().decode(iv); | |||
| public String decrypt(String encryptedData, String iv, WeappSessionResponse obj) throws Exception{ | |||
| // 创建 AES 密钥对象 | |||
| SecretKey secretKey = new SecretKeySpec(sessionKeyBytes, "AES"); | |||
| // 创建 AES 解密器 | |||
| Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); | |||
| cipher.init(Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(ivBytes)); | |||
| // Base64 解码 | |||
| byte[] sessionKeyBytes = Base64.getDecoder().decode(obj.getSessionKey()); | |||
| byte[] encryptedDataBytes = Base64.getDecoder().decode(encryptedData); | |||
| byte[] ivBytes = Base64.getDecoder().decode(iv); | |||
| // 解密 | |||
| byte[] decryptedBytes = cipher.doFinal(encryptedDataBytes); | |||
| String decoded = new String(decryptedBytes, "UTF-8"); | |||
| // 创建 AES 密钥对象 | |||
| SecretKey secretKey = new SecretKeySpec(sessionKeyBytes, "AES"); | |||
| // 创建 AES 解密器 | |||
| Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); | |||
| cipher.init(Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(ivBytes)); | |||
| // 解密 | |||
| byte[] decryptedBytes = cipher.doFinal(encryptedDataBytes); | |||
| String decoded = new String(decryptedBytes, "UTF-8"); | |||
| return decoded; | |||
| return decoded; | |||
| } catch (Exception e) { | |||
| throw new IllegalArgumentException("Illegal Buffer", e); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| extend type Query { | |||
| passRecords( | |||
| userName:String | |||
| userId:Long | |||
| type:Int | |||
| startDate:Date | |||
| endDate:Date | |||
| ): [PassRecord!] | |||
| passRecord(id:Long!): PassRecord | |||
| } | |||
| type PassRecord { | |||
| id: Long | |||
| userName: String | |||
| userId: Long | |||
| faceUrl: String | |||
| recognizedTime: Date | |||
| type: Int | |||
| } | |||
| @@ -1,13 +0,0 @@ | |||
| schema { | |||
| query: Query | |||
| mutation: Mutation | |||
| } | |||
| type Query{ | |||
| } | |||
| type Mutation{ | |||
| } | |||
| @@ -1,4 +0,0 @@ | |||
| type R{ | |||
| code: Int! | |||
| msg: String | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| scalar Long | |||
| scalar DateTime | |||
| scalar Date | |||
| type Query { | |||
| } | |||
| type Mutation { | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| extend type Query { | |||
| visitRecords( | |||
| receiverName:String | |||
| receiverPhone:String | |||
| visitorId:Long | |||
| ): [VisitRecord!] | |||
| visitRecord(id:Long!): VisitRecord | |||
| } | |||
| input VisitRecordInput { | |||
| visitorId: Long! | |||
| visitDate: Date! | |||
| userId: Long | |||
| receiverName: String | |||
| receiverPhone: String | |||
| } | |||
| extend type Mutation { | |||
| saveVisitRecord( | |||
| input:VisitRecordInput! | |||
| ): Boolean | |||
| deleteVisitRecord(id:Long): Boolean | |||
| } | |||
| type VisitRecord { | |||
| id: Long | |||
| visitorId: Long | |||
| userId: Long | |||
| receiverName: String | |||
| receiverPhone: String | |||
| recordStatus: Int | |||
| visitDate: Date | |||
| visitorCode: String | |||
| visitor: Visitor | |||
| } | |||
| @@ -1,3 +0,0 @@ | |||
| extend type Query{ | |||
| getVisitorList() | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| extend type Query { | |||
| visitors( | |||
| id: Long | |||
| name: String | |||
| type: Int | |||
| phone: String | |||
| ): [Visitor!] | |||
| visitor(id: Long): Visitor | |||
| } | |||
| extend type Mutation { | |||
| saveVisitor( | |||
| name: String! | |||
| nickname: String | |||
| phone: String | |||
| isVip:Boolean | |||
| flexVisit:Boolean | |||
| isBlock:Boolean | |||
| resourceId: Long | |||
| ): Boolean | |||
| deleteVisitor(id: Long!): Boolean | |||
| } | |||
| type Visitor { | |||
| id: String | |||
| age: String | |||
| name: String | |||
| nickname: String | |||
| phone: String | |||
| type: Int | |||
| visitorCompany: String | |||
| avatar: String | |||
| isVip:Boolean | |||
| flexVisit:Boolean | |||
| isBlock:Boolean | |||
| resourceId: Long | |||
| } | |||
| @@ -15,6 +15,7 @@ import com.xueyi.common.security.annotation.InnerAuth; | |||
| import com.xueyi.common.security.annotation.Logical; | |||
| 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.system.api.organize.domain.dto.SysEnterpriseDto; | |||
| import com.xueyi.system.api.organize.domain.po.SysEnterprisePo; | |||
| @@ -86,22 +87,33 @@ public class TeTenantController extends BaseController<TeTenantQuery, TeTenantDt | |||
| @GetMapping("/one") | |||
| R<TeTenantPo> tenant(@RequestParam("phone") String phone) { | |||
| log.info("tenant one方法,手机号查询SysEnterpriseStaff:{}", phone); | |||
| TeTenantPo po = enterpriseStaffMapper.selectByPhone(phone); | |||
| TeTenantPo po = enterpriseStaffMapper.selectTenantByPhone(phone); | |||
| return R.ok(po); | |||
| } | |||
| @InnerAuth | |||
| @GetMapping("/query-tenant-by-staff-phone") | |||
| R<TeTenantPo> queryTenantByStaffPhone(@RequestParam("phone") String phone) { | |||
| TeTenantPo po = staffMapper.selectTenantByPhone(phone); | |||
| return R.ok(po); | |||
| } | |||
| @InnerAuth | |||
| @GetMapping("/staff") | |||
| R<TeTenantPo> staff(@RequestParam("phone") String phone) { | |||
| TeTenantPo po = staffMapper.selectByPhone(phone); | |||
| @GetMapping("/query-staff-by-phone") | |||
| R<SysEnterpriseStaff> queryStaff(@RequestParam("phone") String phone) { | |||
| SysEnterpriseStaff po = staffMapper.selectStaffByPhone(phone); | |||
| return R.ok(po); | |||
| } | |||
| @InnerAuth | |||
| @PostMapping("/staff") | |||
| @PostMapping("/save-staff") | |||
| @TenantIgnore(tenantLine = true) | |||
| R<SysEnterpriseStaff> staff(@RequestBody SysEnterpriseStaff staff) { | |||
| staffMapper.insert(staff); | |||
| if (staff.getId() != null) { | |||
| staffMapper.updateById(staff); | |||
| } else { | |||
| staffMapper.insert(staff); | |||
| } | |||
| return R.ok(staff); | |||
| } | |||
| /** | |||
| @@ -17,7 +17,10 @@ import org.apache.ibatis.annotations.Param; | |||
| @Master | |||
| public interface SysEnterpriseStaffMapper extends BaseMapper<SysEnterpriseStaffQuery, SysEnterpriseStaffDto, SysEnterpriseStaff> { | |||
| @TenantIgnore(tenantLine = true) | |||
| TeTenantPo selectByPhone(@Param("phone") String phone); | |||
| TeTenantPo selectTenantByPhone(@Param("phone") String phone); | |||
| @TenantIgnore(tenantLine = true) | |||
| SysEnterpriseStaff selectStaffByPhone(@Param("phone") String phone); | |||
| @TenantIgnore(tenantLine = true) | |||
| void updateEntity(SysEnterpriseStaff po); | |||
| @@ -4,8 +4,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.xueyi.tenant.tenant.mapper.SysEnterpriseStaffMapper"> | |||
| <select id="selectByPhone" resultType="com.xueyi.tenant.api.tenant.domain.po.TeTenantPo" parameterType="Object"> | |||
| select * from te_tenant where id = (select tenant_id from sys_enterprise_staff where (phone = #{phone} or openid = #{phone}) and del_flag = 0 limit 1) | |||
| <select id="selectTenantByPhone" resultType="com.xueyi.tenant.api.tenant.domain.po.TeTenantPo" parameterType="Object"> | |||
| select * from te_tenant where id = (select t_id from sys_enterprise_staff where (phone = #{phone} or openid = #{phone}) and del_flag = 0 limit 1) | |||
| </select> | |||
| <select id="selectStaffByPhone" resultType="com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff" parameterType="Object"> | |||
| select * from sys_enterprise_staff where (phone = #{phone} or openid = #{phone}) and del_flag = 0 limit 1 | |||
| </select> | |||
| <update id="updateEntity" parameterType="com.xueyi.tenant.api.tenant.domain.dto.SysEnterpriseStaffDto"> | |||