| @@ -0,0 +1,35 @@ | |||
| package com.xueyi.system.api.staff.domain.dto; | |||
| import lombok.Data; | |||
| /** | |||
| * 熟人介绍的生人数据的 数据传输对象 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Data | |||
| public class DmStaffCommonDto { | |||
| public static final String TYPE_STRANGER = "6"; | |||
| private String staffName; | |||
| protected String staffType; | |||
| protected Integer gender; | |||
| private String staffBase64Img; | |||
| private String devId; | |||
| @Override | |||
| public String toString() { | |||
| return | |||
| "staffName:" + staffName + | |||
| "\nstaffType:" + staffType + | |||
| "\nstaffBase64Img:" + staffBase64Img + | |||
| "\ndevId:" + devId + | |||
| "\n"; | |||
| } | |||
| } | |||
| @@ -6,11 +6,15 @@ import com.xueyi.common.core.constant.basic.ServiceConstants; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | |||
| import com.xueyi.system.api.organize.feign.factory.RemoteUserFallbackFactory; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffCommonDto; | |||
| import com.xueyi.system.api.staff.domain.vo.DmStaffFeature; | |||
| import org.springframework.cloud.openfeign.FeignClient; | |||
| 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.RequestHeader; | |||
| import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import java.util.List; | |||
| @@ -22,15 +26,6 @@ import java.util.List; | |||
| @FeignClient(contextId = "remoteStaffService", value = ServiceConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class) | |||
| public interface RemoteStaffService { | |||
| /** | |||
| * 新增用户 | |||
| * | |||
| * @param user 用户对象 | |||
| * @param enterpriseId 企业Id | |||
| * @param sourceName 策略源 | |||
| * @param source 请求来源 | |||
| * @return 结果 | |||
| */ | |||
| @GetMapping("/staff/inner/{devId}/{timestamp}") | |||
| R<List<DmStaffFeature>> listInner(@RequestParam(value = "devId") String devId, @RequestParam(value = "timestamp") String timestamp, | |||
| @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @@ -41,4 +36,8 @@ public interface RemoteStaffService { | |||
| @GetMapping("/staff/inner/tenantId/{enterpriseName}") | |||
| public R<SysEnterpriseDto> tenantIdInner(@RequestParam(value = "enterpriseName") String enterpriseName) ; | |||
| @PostMapping(value = "/staff/inner-api/new-staff") | |||
| @ResponseBody | |||
| public com.alibaba.fastjson2.JSONObject addStaff(@RequestBody DmStaffCommonDto commonDto,@RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| } | |||
| @@ -153,6 +153,7 @@ public class DmBroadcastController extends BaseController<DmBroadcastQuery, DmBr | |||
| @RequiresPermissions(Auth.DM_BROADCAST_EDIT) | |||
| @Log(title = "播报管理", businessType = BusinessType.UPDATE) | |||
| public AjaxResult edit(@Validated({V_E.class}) @RequestBody DmBroadcastDto broadcast) { | |||
| broadcastManager.editBroadcastResourceMerge(broadcast.getId(), broadcast.getResourceList()); | |||
| return super.edit(broadcast); | |||
| } | |||
| @@ -164,8 +165,6 @@ public class DmBroadcastController extends BaseController<DmBroadcastQuery, DmBr | |||
| @RequiresPermissions(value = {Auth.DM_BROADCAST_EDIT, Auth.DM_BROADCAST_ES}, logical = Logical.OR) | |||
| @Log(title = "播报管理", businessType = BusinessType.UPDATE_STATUS) | |||
| public AjaxResult editStatus(@RequestBody DmBroadcastDto broadcast) { | |||
| broadcastManager.editBroadcastResourceMerge(broadcast.getId(), broadcast.getResourceList()); | |||
| return super.editStatus(broadcast); | |||
| } | |||
| @@ -15,6 +15,7 @@ import org.springframework.stereotype.Component; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * 播报管理 数据封装层处理 | |||
| @@ -27,9 +28,6 @@ public class DmBroadcastManager extends BaseManagerImpl<DmBroadcastQuery, DmBroa | |||
| private DmBroadcastResourceMergeMapper broadcastResourceMergeMapper; | |||
| @Override | |||
| public void addBroadcastResourceMerge(Long broadcastId, List<DmBroadcastResourceMerge> merges) { | |||
| List<DmBroadcastResourceMerge> broadcastResourceMerges = new ArrayList<DmBroadcastResourceMerge>(); | |||
| @@ -48,12 +46,22 @@ public class DmBroadcastManager extends BaseManagerImpl<DmBroadcastQuery, DmBroa | |||
| @Override | |||
| public void editBroadcastResourceMerge(Long broadcastId, List<DmBroadcastResourceMerge> merges) { | |||
| List<DmBroadcastResourceMerge> broadcastResourceMerges = new ArrayList<DmBroadcastResourceMerge>(); | |||
| List<DmBroadcastResourceMerge> mergeDtos = selectBroadcastResourceMerge(broadcastId); | |||
| if (merges != null && merges.size() > 0) { | |||
| for (DmBroadcastResourceMerge merge : merges) { | |||
| merge.setBroadcastId(broadcastId); | |||
| broadcastResourceMerges.add(merge); | |||
| } | |||
| } | |||
| List<Long> idList = mergeDtos.stream() | |||
| .map(DmBroadcastResourceMerge::getId) | |||
| .collect(Collectors.toList()); | |||
| List<Long> newList = broadcastResourceMerges.stream() | |||
| .map(DmBroadcastResourceMerge::getId) | |||
| .collect(Collectors.toList()); | |||
| idList.removeAll(newList); | |||
| broadcastResourceMergeMapper.deleteBatchIds(idList); | |||
| if (broadcastResourceMerges.size() > 0) { | |||
| broadcastResourceMergeMapper.updateBatch(broadcastResourceMerges); | |||
| @@ -1,9 +1,10 @@ | |||
| package com.xueyi.system.resource.service; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.web.entity.service.IBaseService; | |||
| import com.xueyi.system.api.resource.domain.po.DmResourcesPo; | |||
| import com.xueyi.system.resource.domain.query.DmResourcesQuery; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.common.web.entity.service.IBaseService; | |||
| import com.xueyi.system.resource.domain.query.DmResourcesQuery; | |||
| /** | |||
| * 静态资源管理 服务层 | |||
| @@ -15,4 +16,6 @@ public interface IDmResourcesService extends IBaseService<DmResourcesQuery, DmRe | |||
| Long addOne(DmResourcesPo dmResourcesPo); | |||
| Long initAdd(DmResourcesPo dto); | |||
| R addBase64Img(String base64Img, String name); | |||
| } | |||
| @@ -1,12 +1,19 @@ | |||
| package com.xueyi.system.resource.service.impl; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import cn.hutool.core.util.ObjectUtil; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | |||
| import com.xueyi.file.api.domain.SysFile; | |||
| import com.xueyi.file.api.feign.RemoteFileService; | |||
| import com.xueyi.system.api.resource.domain.po.DmResourcesPo; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.domain.query.DmResourcesQuery; | |||
| import com.xueyi.system.resource.manager.IDmResourcesManager; | |||
| import com.xueyi.system.resource.mapper.DmResourcesMapper; | |||
| import com.xueyi.system.resource.service.IDmResourcesService; | |||
| import com.xueyi.system.resource.manager.IDmResourcesManager; | |||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | |||
| import com.xueyi.system.utils.common.ImageUtil; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -22,6 +29,16 @@ public class DmResourcesServiceImpl extends BaseServiceImpl<DmResourcesQuery, Dm | |||
| @Autowired | |||
| DmResourcesMapper dmResourcesMapper; | |||
| @Autowired | |||
| private RemoteFileService fileService; | |||
| @Autowired | |||
| private FaceServiceImpl faceService; | |||
| @Autowired | |||
| private ImageUtil imageUtil; | |||
| /** | |||
| * 查询静态资源对象列表 | 数据权限 | |||
| * | |||
| @@ -43,4 +60,33 @@ public class DmResourcesServiceImpl extends BaseServiceImpl<DmResourcesQuery, Dm | |||
| public Long initAdd(DmResourcesPo po) { | |||
| return this.addOne(po); | |||
| } | |||
| @Override | |||
| public R addBase64Img(String base64Img, String name) { | |||
| DmResourcesDto dmResourcesDto = new DmResourcesDto(); | |||
| if (StringUtils.isNotEmpty(base64Img)) { | |||
| String imgBase64 = base64Img; | |||
| R<SysFile> fileResult = fileService.upload(imageUtil.base64ToMultipartFile(imgBase64)); | |||
| if (ObjectUtil.isNull(fileResult) || ObjectUtil.isNull(fileResult.getData())) | |||
| return R.fail(fileResult.getMsg()); | |||
| String url = fileResult.getData().getUrl(); | |||
| dmResourcesDto.setType(DmResourcesDto.TYPE_PIC); | |||
| dmResourcesDto.setUrl(url); | |||
| dmResourcesDto.setName(name); | |||
| com.alibaba.fastjson.JSONObject json = faceService.getFaceExtraction("", "", imgBase64); | |||
| if (0!=json.getInteger("status")) { | |||
| return R.fail(json.getString("errMsg")); | |||
| } else { | |||
| JSONArray obj = json.getJSONArray("result").getJSONObject(0).getJSONArray("faces").getJSONObject(0).getJSONArray("feature"); | |||
| dmResourcesDto.setFeature(obj.toJSONString()); | |||
| } | |||
| addOne(dmResourcesDto); | |||
| } | |||
| return R.ok(dmResourcesDto); | |||
| } | |||
| } | |||
| @@ -3,11 +3,14 @@ package com.xueyi.system.staff.controller.api; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.system.api.device.domain.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffCommonDto; | |||
| import com.xueyi.system.api.staff.feign.RemoteStaffService; | |||
| import com.xueyi.system.resource.controller.api.BaseApiController; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| 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.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @@ -31,4 +34,11 @@ public class DmStaffApiController extends BaseApiController { | |||
| return staffService.fetchStaff(staffId, vo.getTenantId(), vo.getSourceSlave(), SecurityConstants.INNER); | |||
| } | |||
| @PostMapping(value = "new-staff") | |||
| @ResponseBody | |||
| public com.alibaba.fastjson2.JSONObject newStaff(@RequestBody DmStaffCommonDto commonDto){ | |||
| DeviceTenantSourceMergeVo vo = super.getDeviceTenantSourceMergeVo(commonDto.getDevId()); | |||
| return staffService.addStaff(commonDto, vo.getTenantId(), vo.getSourceSlave(), SecurityConstants.INNER); | |||
| } | |||
| } | |||
| @@ -1,16 +1,29 @@ | |||
| package com.xueyi.system.staff.controller.api; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| 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.file.api.feign.RemoteFileService; | |||
| 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.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl; | |||
| import com.xueyi.system.resource.service.impl.FaceServiceImpl; | |||
| import com.xueyi.system.staff.mapper.DmStaffMapper; | |||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | |||
| import com.xueyi.system.utils.common.ImageUtil; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| 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.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @@ -27,6 +40,24 @@ public class DmStaffInnerApiController extends BaseApiController { | |||
| @Autowired | |||
| private DmStaffMapper dmStaffMapper; | |||
| @Autowired | |||
| private RemoteFileService fileService; | |||
| @Autowired | |||
| private FaceServiceImpl faceService; | |||
| @Autowired | |||
| private ImageUtil imageUtil; | |||
| @Autowired | |||
| private DmResourcesServiceImpl iDmResourcesService; | |||
| @Autowired | |||
| private DmVisitorsMapper dmVisitorsMapper; | |||
| @Autowired | |||
| private DmStaffMapper staffMapper; | |||
| @InnerAuth | |||
| @GetMapping(value = "selectOne/{staffId}") | |||
| @ResponseBody | |||
| @@ -38,4 +69,52 @@ public class DmStaffInnerApiController extends BaseApiController { | |||
| return output(ResponseCode.DATA_NOT_EXISTS,"指定ID的员工").toJSON(); | |||
| } | |||
| @InnerAuth | |||
| @PostMapping(value = "new-staff") | |||
| @ResponseBody | |||
| public com.alibaba.fastjson2.JSONObject newStaff(@RequestBody DmStaffCommonDto commonDto){ | |||
| //访客 | |||
| if (commonDto.getStaffType().equals(DmStaffCommonDto.TYPE_STRANGER)) { | |||
| DmVisitorsPo v = new DmVisitorsPo(); | |||
| v.setName(commonDto.getStaffName()); | |||
| v.setNickname(commonDto.getStaffName()); | |||
| v.setType(DmVisitorsDto.TYPE_NORMAL_VISITOR); | |||
| v.setGender(commonDto.getGender()); | |||
| //兼容熟人介绍生人,传递访客照片 | |||
| if (StringUtils.isNotEmpty(commonDto.getStaffBase64Img())) { | |||
| R r = iDmResourcesService.addBase64Img(commonDto.getStaffBase64Img(), "stranger-"+commonDto.getStaffName()); | |||
| if (r.getData() instanceof DmResourcesDto) { | |||
| DmResourcesDto dmResourcesDto = (DmResourcesDto) r.getData(); | |||
| v.setResourceId(dmResourcesDto.getId()); | |||
| } else { | |||
| return output(ResponseCode.FILE_UPLOAD_FAIL, r.getMsg()).toJSON(); | |||
| } | |||
| } | |||
| 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); | |||
| if (StringUtils.isNotEmpty(commonDto.getStaffBase64Img())) { | |||
| R r = iDmResourcesService.addBase64Img(commonDto.getStaffBase64Img(), "staff-"+commonDto.getStaffName()); | |||
| if (r.getData() instanceof DmResourcesDto) { | |||
| DmResourcesDto dmResourcesDto = (DmResourcesDto) r.getData(); | |||
| staffPo.setResourceId(dmResourcesDto.getId()); | |||
| } else { | |||
| return output(ResponseCode.FILE_UPLOAD_FAIL, r.getMsg()).toJSON(); | |||
| } | |||
| } | |||
| dmStaffMapper.insert(staffPo); | |||
| } | |||
| return outputSuccess().toJSON(); | |||
| } | |||
| } | |||
| @@ -9,13 +9,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> | |||
| select LAST_INSERT_ID() | |||
| </selectKey> | |||
| insert into dm_visitors(name,nickname,phone,visitor_company,type) values | |||
| insert into dm_visitors(name,nickname,phone,visitor_company,type,resource_id) values | |||
| ( | |||
| #{name}, | |||
| #{nickname}, | |||
| #{phone}, | |||
| #{visitorCompany}, | |||
| #{type} | |||
| #{type}, | |||
| #{resourceId} | |||
| ) | |||
| </insert > | |||
| </mapper> | |||