| @@ -76,4 +76,12 @@ public class DmVisitorsPo extends TBaseEntity { | |||||
| private Boolean flexVisit; | private Boolean flexVisit; | ||||
| public DmVisitorsPo() { | |||||
| } | |||||
| public DmVisitorsPo(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| } | } | ||||
| @@ -28,4 +28,5 @@ public class SysEnterpriseDto extends SysEnterprisePo { | |||||
| return StrUtil.equals(AuthorityConstants.TenantType.ADMIN.getCode(), isLessor); | return StrUtil.equals(AuthorityConstants.TenantType.ADMIN.getCode(), isLessor); | ||||
| } | } | ||||
| public Long defaultDeptId; | |||||
| } | } | ||||
| @@ -0,0 +1,7 @@ | |||||
| package com.xueyi.system.api.staff.domain.dto; | |||||
| import com.xueyi.system.api.staff.domain.po.DmPersonFeaturePo; | |||||
| public class DmPersonFeatureDto extends DmPersonFeaturePo { | |||||
| } | |||||
| @@ -1,7 +1,13 @@ | |||||
| package com.xueyi.system.api.staff.domain.dto; | package com.xueyi.system.api.staff.domain.dto; | ||||
| import com.fasterxml.jackson.annotation.JsonFormat; | |||||
| 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.po.DmStaffPo; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import java.util.Date; | |||||
| /** | /** | ||||
| * 熟人介绍的生人数据的 数据传输对象 | * 熟人介绍的生人数据的 数据传输对象 | ||||
| * | * | ||||
| @@ -20,8 +26,38 @@ public class DmStaffCommonDto { | |||||
| private String staffBase64Img; | private String staffBase64Img; | ||||
| private String faceFeature; | |||||
| @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||||
| private Date birthDate; | |||||
| @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||||
| private Date hireDate; | |||||
| private String devId; | private String devId; | ||||
| public DmStaffPo initStaff(Long id){ | |||||
| DmStaffPo staffPo = new DmStaffPo(id); | |||||
| staffPo.setNickName(this.getStaffName()); | |||||
| staffPo.setUserName(this.getStaffName()); | |||||
| staffPo.setUserType(this.getStaffType()); | |||||
| staffPo.setHireDate(this.getHireDate()); | |||||
| staffPo.setBirthDate(this.getBirthDate()); | |||||
| staffPo.setSex(this.getGender()!=null ? String.valueOf(this.getGender()):null); | |||||
| return staffPo; | |||||
| } | |||||
| public DmVisitorsPo initVisitor(Long id){ | |||||
| DmVisitorsPo v= new DmVisitorsPo(id); | |||||
| v.setName(this.getStaffName()); | |||||
| v.setNickname(this.getStaffName()); | |||||
| v.setType(DmVisitorsDto.TYPE_NORMAL_VISITOR); | |||||
| v.setGender(this.getGender()); | |||||
| v.setType(Long.parseLong(this.getStaffType())); | |||||
| return v; | |||||
| } | |||||
| @Override | @Override | ||||
| public String toString() { | public String toString() { | ||||
| @@ -0,0 +1,58 @@ | |||||
| package com.xueyi.system.api.staff.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.xueyi.common.core.annotation.Excel; | |||||
| import com.xueyi.common.core.web.tenant.base.TBaseEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import java.io.Serial; | |||||
| 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 xueyi | |||||
| */ | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| @TableName(value = "dm_person_feature", excludeProperty = { STATUS, UPDATE_BY, SORT, CREATE_BY, DEL_FLAG, CREATE_TIME, UPDATE_TIME, REMARK, NAME }) | |||||
| public class DmPersonFeaturePo extends TBaseEntity { | |||||
| public static final Integer PERSON_TYPE_STAFF = 1; | |||||
| public static final Integer PERSON_TYPE_VISITOR = 2; | |||||
| @Serial | |||||
| private static final long serialVersionUID = 1L; | |||||
| /** 用户编码 */ | |||||
| @Excel(name = "用户编码") | |||||
| protected Long id; | |||||
| /** 用户账号 */ | |||||
| @Excel(name = "用户类型") | |||||
| protected Integer type; | |||||
| /** 所属资源ID */ | |||||
| @Excel(name = "所属组织ID") | |||||
| protected String feature; | |||||
| public DmPersonFeaturePo(){ | |||||
| super(); | |||||
| } | |||||
| public DmPersonFeaturePo(Long id, Integer type, String feature){ | |||||
| this.id = id; | |||||
| this.type = type; | |||||
| this.feature = feature; | |||||
| } | |||||
| } | |||||
| @@ -94,4 +94,9 @@ public class DmStaffPo extends TBaseEntity { | |||||
| private Long tenantId; | private Long tenantId; | ||||
| public DmStaffPo() {} | |||||
| public DmStaffPo(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| } | } | ||||
| @@ -1,9 +1,7 @@ | |||||
| package com.xueyi.system.api.staff.domain.vo; | package com.xueyi.system.api.staff.domain.vo; | ||||
| import cn.hutool.core.date.DateTime; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | import lombok.NoArgsConstructor; | ||||
| import net.sf.jsqlparser.expression.DateTimeLiteralExpression; | |||||
| import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -18,4 +18,6 @@ public interface ISysEnterpriseService extends IBaseService<SysEnterpriseQuery, | |||||
| * @return 企业对象 | * @return 企业对象 | ||||
| */ | */ | ||||
| SysEnterpriseDto selectByName(String name); | SysEnterpriseDto selectByName(String name); | ||||
| Long selectDefaultDeptId(String devId); | |||||
| } | } | ||||
| @@ -1,10 +1,16 @@ | |||||
| package com.xueyi.system.organize.service.impl; | package com.xueyi.system.organize.service.impl; | ||||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||||
| import com.xueyi.common.core.context.SecurityContextHolder; | |||||
| import com.xueyi.common.core.web.result.R; | |||||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | ||||
| import com.xueyi.system.api.digitalmans.domain.po.DmDigitalmanExtPo; | |||||
| import com.xueyi.system.api.digitalmans.feign.RemoteDigitalmanService; | |||||
| import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | ||||
| import com.xueyi.system.api.organize.domain.query.SysEnterpriseQuery; | import com.xueyi.system.api.organize.domain.query.SysEnterpriseQuery; | ||||
| import com.xueyi.system.organize.manager.ISysEnterpriseManager; | import com.xueyi.system.organize.manager.ISysEnterpriseManager; | ||||
| import com.xueyi.system.organize.service.ISysEnterpriseService; | import com.xueyi.system.organize.service.ISysEnterpriseService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| /** | /** | ||||
| @@ -25,4 +31,13 @@ public class SysEnterpriseServiceImpl extends BaseServiceImpl<SysEnterpriseQuery | |||||
| public SysEnterpriseDto selectByName(String name) { | public SysEnterpriseDto selectByName(String name) { | ||||
| return baseManager.selectByName(name); | return baseManager.selectByName(name); | ||||
| } | } | ||||
| @Autowired | |||||
| private RemoteDigitalmanService digitalmanService; | |||||
| @Override | |||||
| public Long selectDefaultDeptId(String devId) { | |||||
| R<DmDigitalmanExtPo> extPo = digitalmanService.devInfo(devId, SecurityContextHolder.getEnterpriseId(), SecurityContextHolder.getSourceName(), SecurityConstants.INNER); | |||||
| return extPo.getData().getDeptId(); | |||||
| } | |||||
| } | } | ||||
| @@ -1,19 +1,23 @@ | |||||
| package com.xueyi.system.staff.controller.api; | package com.xueyi.system.staff.controller.api; | ||||
| import cn.hutool.core.util.IdUtil; | |||||
| import com.alibaba.fastjson2.JSONObject; | import com.alibaba.fastjson2.JSONObject; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | import com.baomidou.mybatisplus.core.toolkit.StringUtils; | ||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
| import com.xueyi.common.core.constant.basic.SqlConstants; | import com.xueyi.common.core.constant.basic.SqlConstants; | ||||
| import com.xueyi.common.core.web.result.R; | import com.xueyi.common.core.web.result.R; | ||||
| import com.xueyi.common.security.annotation.InnerAuth; | import com.xueyi.common.security.annotation.InnerAuth; | ||||
| import com.xueyi.common.web.constant.ResponseCode; | import com.xueyi.common.web.constant.ResponseCode; | ||||
| import com.xueyi.system.api.digitalmans.domain.dto.DmVisitorsDto; | |||||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitorsPo; | 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.dto.DmStaffCommonDto; | ||||
| import com.xueyi.system.api.staff.domain.po.DmPersonFeaturePo; | |||||
| import com.xueyi.system.api.staff.domain.po.DmStaffPo; | import com.xueyi.system.api.staff.domain.po.DmStaffPo; | ||||
| import com.xueyi.system.organize.service.impl.SysEnterpriseServiceImpl; | |||||
| import com.xueyi.system.resource.controller.api.MyBaseApiController; | import com.xueyi.system.resource.controller.api.MyBaseApiController; | ||||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | import com.xueyi.system.resource.domain.dto.DmResourcesDto; | ||||
| import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl; | import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl; | ||||
| import com.xueyi.system.staff.mapper.DmPersonFeatureMapper; | |||||
| import com.xueyi.system.staff.mapper.DmStaffMapper; | import com.xueyi.system.staff.mapper.DmStaffMapper; | ||||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | import com.xueyi.system.staff.mapper.DmVisitorsMapper; | ||||
| import com.xueyi.system.staff.service.impl.DmStaffServiceImpl; | import com.xueyi.system.staff.service.impl.DmStaffServiceImpl; | ||||
| @@ -83,19 +87,21 @@ public class DmStaffInnerApiController extends MyBaseApiController { | |||||
| return output(ResponseCode.DATA_NOT_EXISTS,"指定phone的员工").toJSON(); | return output(ResponseCode.DATA_NOT_EXISTS,"指定phone的员工").toJSON(); | ||||
| } | } | ||||
| @Autowired | |||||
| private DmPersonFeatureMapper featureMapper; | |||||
| @Autowired | |||||
| private SysEnterpriseServiceImpl enterpriseService; | |||||
| @InnerAuth | @InnerAuth | ||||
| @PostMapping(value = "new-staff") | @PostMapping(value = "new-staff") | ||||
| @ResponseBody | @ResponseBody | ||||
| public com.alibaba.fastjson2.JSONObject newStaff(@RequestBody DmStaffCommonDto commonDto){ | public com.alibaba.fastjson2.JSONObject newStaff(@RequestBody DmStaffCommonDto commonDto){ | ||||
| Long id = IdUtil.getSnowflakeNextId(); | |||||
| //访客 | //访客 | ||||
| if (commonDto.getStaffType().equals(DmStaffCommonDto.TYPE_STRANGER) || commonDto.getStaffType().equals(DmStaffCommonDto.TYPE_VIP_STRANGER)) { | if (commonDto.getStaffType().equals(DmStaffCommonDto.TYPE_STRANGER) || commonDto.getStaffType().equals(DmStaffCommonDto.TYPE_VIP_STRANGER)) { | ||||
| DmVisitorsPo v = new DmVisitorsPo(); | |||||
| v.setName(commonDto.getStaffName()); | |||||
| v.setNickname(commonDto.getStaffName()); | |||||
| v.setType(DmVisitorsDto.TYPE_NORMAL_VISITOR); | |||||
| v.setGender(commonDto.getGender()); | |||||
| v.setType(Long.parseLong(commonDto.getStaffType())); | |||||
| DmVisitorsPo v = commonDto.initVisitor(id); | |||||
| //兼容熟人介绍生人,传递访客照片 | //兼容熟人介绍生人,传递访客照片 | ||||
| if (StringUtils.isNotEmpty(commonDto.getStaffBase64Img())) { | if (StringUtils.isNotEmpty(commonDto.getStaffBase64Img())) { | ||||
| @@ -110,13 +116,20 @@ public class DmStaffInnerApiController extends MyBaseApiController { | |||||
| } | } | ||||
| } | } | ||||
| if (StringUtils.isNotEmpty(commonDto.getFaceFeature())) {//访客传递特征值 | |||||
| DmPersonFeaturePo featurePo = new DmPersonFeaturePo(id, DmPersonFeaturePo.PERSON_TYPE_VISITOR, commonDto.getFaceFeature()); | |||||
| featureMapper.insert(featurePo); | |||||
| } | |||||
| dmVisitorsMapper.addOne(v); | dmVisitorsMapper.addOne(v); | ||||
| } else {//员工 | } else {//员工 | ||||
| DmStaffPo staffPo = new DmStaffPo(); | |||||
| staffPo.setNickName(commonDto.getStaffName()); | |||||
| staffPo.setUserName(commonDto.getStaffName()); | |||||
| staffPo.setUserType(commonDto.getStaffType()); | |||||
| staffPo.setSex(commonDto.getGender()!=null ? String.valueOf(commonDto.getGender()):null); | |||||
| //判断员工是否已同步,按姓名来判断 | |||||
| DmStaffPo po = dmStaffMapper.selectOne(new QueryWrapper<DmStaffPo>().eq("user_name", commonDto.getStaffName()).last("limit 1")); | |||||
| if (po != null) { | |||||
| return output(ResponseCode.SAVE_FAILED, "该员工已被同步").toJSON(); | |||||
| } | |||||
| DmStaffPo staffPo = commonDto.initStaff(id); | |||||
| staffPo.setDeptId(enterpriseService.selectDefaultDeptId(commonDto.getDevId())); | |||||
| if (StringUtils.isNotEmpty(commonDto.getStaffBase64Img())) { | if (StringUtils.isNotEmpty(commonDto.getStaffBase64Img())) { | ||||
| R r = iDmResourcesService.addBase64Img(commonDto.getStaffBase64Img(), "staff-"+commonDto.getStaffName()); | R r = iDmResourcesService.addBase64Img(commonDto.getStaffBase64Img(), "staff-"+commonDto.getStaffName()); | ||||
| @@ -128,6 +141,12 @@ public class DmStaffInnerApiController extends MyBaseApiController { | |||||
| return output(ResponseCode.FILE_UPLOAD_FAIL, r.getMsg()).toJSON(); | return output(ResponseCode.FILE_UPLOAD_FAIL, r.getMsg()).toJSON(); | ||||
| } | } | ||||
| } | } | ||||
| if (StringUtils.isNotEmpty(commonDto.getFaceFeature())) {//人员传递特征值 | |||||
| DmPersonFeaturePo featurePo = new DmPersonFeaturePo(id, DmPersonFeaturePo.PERSON_TYPE_STAFF, commonDto.getFaceFeature()); | |||||
| featureMapper.insert(featurePo); | |||||
| } | |||||
| dmStaffMapper.insert(staffPo); | dmStaffMapper.insert(staffPo); | ||||
| } | } | ||||
| @@ -0,0 +1,20 @@ | |||||
| package com.xueyi.system.staff.domain.query; | |||||
| import com.xueyi.system.api.staff.domain.po.DmPersonFeaturePo; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import java.io.Serial; | |||||
| /** | |||||
| * 人员 脸部特征值表 | |||||
| * | |||||
| * @author xueyi | |||||
| */ | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class DmPersonFeatureQuery extends DmPersonFeaturePo { | |||||
| @Serial | |||||
| private static final long serialVersionUID = 1L; | |||||
| } | |||||
| @@ -0,0 +1,17 @@ | |||||
| package com.xueyi.system.staff.mapper; | |||||
| import com.xueyi.common.datasource.annotation.Isolate; | |||||
| import com.xueyi.common.web.entity.mapper.BaseMapper; | |||||
| import com.xueyi.system.api.staff.domain.dto.DmPersonFeatureDto; | |||||
| import com.xueyi.system.api.staff.domain.po.DmPersonFeaturePo; | |||||
| import com.xueyi.system.staff.domain.query.DmPersonFeatureQuery; | |||||
| /** | |||||
| * 人员人脸特征值 数据层 | |||||
| * | |||||
| * @author xueyi | |||||
| */ | |||||
| @Isolate | |||||
| public interface DmPersonFeatureMapper extends BaseMapper<DmPersonFeatureQuery, DmPersonFeatureDto, DmPersonFeaturePo> { | |||||
| } | |||||