|
|
|
@@ -1,19 +1,23 @@ |
|
|
|
package com.xueyi.system.staff.controller.api; |
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
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.Wrappers; |
|
|
|
import com.xueyi.common.core.constant.basic.SqlConstants; |
|
|
|
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.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.DmPersonFeaturePo; |
|
|
|
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.domain.dto.DmResourcesDto; |
|
|
|
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.DmVisitorsMapper; |
|
|
|
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(); |
|
|
|
} |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DmPersonFeatureMapper featureMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysEnterpriseServiceImpl enterpriseService; |
|
|
|
|
|
|
|
@InnerAuth |
|
|
|
@PostMapping(value = "new-staff") |
|
|
|
@ResponseBody |
|
|
|
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)) { |
|
|
|
|
|
|
|
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())) { |
|
|
|
@@ -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); |
|
|
|
} 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())) { |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(commonDto.getFaceFeature())) {//人员传递特征值 |
|
|
|
DmPersonFeaturePo featurePo = new DmPersonFeaturePo(id, DmPersonFeaturePo.PERSON_TYPE_STAFF, commonDto.getFaceFeature()); |
|
|
|
featureMapper.insert(featurePo); |
|
|
|
} |
|
|
|
|
|
|
|
dmStaffMapper.insert(staffPo); |
|
|
|
} |
|
|
|
|
|
|
|
|