You've already forked FrameTour-BE
Merge remote-tracking branch 'origin/master'
This commit is contained in:
21
src/main/java/com/ycwl/basic/config/FaceDetectConfig.java
Normal file
21
src/main/java/com/ycwl/basic/config/FaceDetectConfig.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.ycwl.basic.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云OSS配置
|
||||||
|
*
|
||||||
|
* @author songmingsong
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
public class FaceDetectConfig {
|
||||||
|
@Value("${aliYunFace.accessKeyId}")
|
||||||
|
private String accessKeyId;
|
||||||
|
@Value("${aliYunFace.accessKeySecret}")
|
||||||
|
private String accessKeySecret;
|
||||||
|
@Value("${aliYunFace.region}")
|
||||||
|
private String region;
|
||||||
|
}
|
@ -21,4 +21,6 @@ public interface DeviceMapper {
|
|||||||
int deleteById(Long id);
|
int deleteById(Long id);
|
||||||
int update(DeviceAddOrUpdateReq deviceReqQuery);
|
int update(DeviceAddOrUpdateReq deviceReqQuery);
|
||||||
int updateStatus(Long id);
|
int updateStatus(Long id);
|
||||||
|
|
||||||
|
List<DeviceRespVO> listByScenicId(Long scenicId);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.ycwl.basic.mapper.pc;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ScenicAccountMapper {
|
||||||
|
ScenicAccountEntity getByAccount(String account);
|
||||||
|
int add(ScenicAccountEntity scenicAccount);
|
||||||
|
ScenicAccountEntity getSuperAccountOfScenic(Long scenicId);
|
||||||
|
int update(ScenicAccountEntity scenicAccount);
|
||||||
|
int deleteById(Long id);
|
||||||
|
int updateStatus(Long id);
|
||||||
|
int deleteByScenicId(Long scenicId);
|
||||||
|
}
|
@ -20,6 +20,7 @@ public class BrokerEntity {
|
|||||||
* 推客名称
|
* 推客名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
private String phone;
|
||||||
/**
|
/**
|
||||||
* 专属优惠码,新建时生成
|
* 专属优惠码,新建时生成
|
||||||
*/
|
*/
|
||||||
@ -30,4 +31,8 @@ public class BrokerEntity {
|
|||||||
private Integer status;
|
private Integer status;
|
||||||
private Date createAt;
|
private Date createAt;
|
||||||
private Date updateAt;
|
private Date updateAt;
|
||||||
|
private Integer brokerOrderCount;
|
||||||
|
private Integer brokerOrderAmount;
|
||||||
|
private Date firstBrokerDate;
|
||||||
|
private Date lastBrokerDate;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ public class BrokerReqQuery extends BaseQueryParameterReq {
|
|||||||
private Long id;
|
private Long id;
|
||||||
@ApiModelProperty("推客名称")
|
@ApiModelProperty("推客名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
private String phone;
|
||||||
@ApiModelProperty("专属优惠码")
|
@ApiModelProperty("专属优惠码")
|
||||||
private String promoCode;
|
private String promoCode;
|
||||||
@ApiModelProperty("状态,0禁用,1启用")
|
@ApiModelProperty("状态,0禁用,1启用")
|
||||||
|
@ -16,6 +16,10 @@ import java.util.Date;
|
|||||||
public class FaceEntity {
|
public class FaceEntity {
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 人脸得分
|
||||||
|
*/
|
||||||
|
private float score;
|
||||||
/**
|
/**
|
||||||
* 会员id
|
* 会员id
|
||||||
*/
|
*/
|
||||||
|
@ -15,10 +15,19 @@ import java.util.Date;
|
|||||||
public class FaceSampleEntity {
|
public class FaceSampleEntity {
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 景区ID
|
||||||
|
*/
|
||||||
|
private Long scenicId;
|
||||||
/**
|
/**
|
||||||
* 来源设备
|
* 来源设备
|
||||||
*/
|
*/
|
||||||
private Long deviceId;
|
private Long deviceId;
|
||||||
|
/**
|
||||||
|
* 样本ID
|
||||||
|
*/
|
||||||
|
private Long sourceId;
|
||||||
|
private float score;
|
||||||
/**
|
/**
|
||||||
* 人脸照片
|
* 人脸照片
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +16,11 @@ import java.util.Date;
|
|||||||
@Data
|
@Data
|
||||||
@ApiModel("人脸样本查询参数")
|
@ApiModel("人脸样本查询参数")
|
||||||
public class FaceSampleReqQuery extends BaseQueryParameterReq {
|
public class FaceSampleReqQuery extends BaseQueryParameterReq {
|
||||||
|
/**
|
||||||
|
* 景区ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("景区ID")
|
||||||
|
private Long scenicId;
|
||||||
/**
|
/**
|
||||||
* 来源设备
|
* 来源设备
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +16,11 @@ import java.util.Date;
|
|||||||
@ApiModel("人脸样本响应参数")
|
@ApiModel("人脸样本响应参数")
|
||||||
public class FaceSampleRespVO {
|
public class FaceSampleRespVO {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 景区ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("景区ID")
|
||||||
|
private Long scenicId;
|
||||||
/**
|
/**
|
||||||
* 来源设备
|
* 来源设备
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.ycwl.basic.model.pc.scenic.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("scenic_account")
|
||||||
|
public class ScenicAccountEntity {
|
||||||
|
private Long id;
|
||||||
|
private Long scenicId;
|
||||||
|
private Integer isSuper;
|
||||||
|
private String name;
|
||||||
|
private String account;
|
||||||
|
private String password;
|
||||||
|
private Date createTime;
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
@ -22,6 +22,11 @@ public class ScenicAddOrUpdateReq {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("景区名称")
|
@ApiModelProperty("景区名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
/**
|
||||||
|
* 景区电话
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("联系电话")
|
||||||
|
private String phone;
|
||||||
/**
|
/**
|
||||||
* 景区介绍
|
* 景区介绍
|
||||||
*/
|
*/
|
||||||
@ -75,4 +80,9 @@ public class ScenicAddOrUpdateReq {
|
|||||||
private ScenicConfigEntity scenicConfig;
|
private ScenicConfigEntity scenicConfig;
|
||||||
@ApiModelProperty("景区源素材价格,元")
|
@ApiModelProperty("景区源素材价格,元")
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty("账号")
|
||||||
|
private String account;
|
||||||
|
@ApiModelProperty("密码")
|
||||||
|
private String password;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,16 @@ public class ScenicRespVO {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("景区名称")
|
@ApiModelProperty("景区名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
/**
|
||||||
|
* 账号
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("账号")
|
||||||
|
private String account;
|
||||||
|
/**
|
||||||
|
* 联系电话
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("联系电话")
|
||||||
|
private String phone;
|
||||||
/**
|
/**
|
||||||
* 景区介绍
|
* 景区介绍
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.ycwl.basic.model.task.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddFaceRespVo {
|
||||||
|
private float score;
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.ycwl.basic.model.task.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SearchFaceRespVo {
|
||||||
|
private float score;
|
||||||
|
private List<Long> sampleListIds;
|
||||||
|
}
|
@ -8,6 +8,7 @@ import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
|
|||||||
import com.ycwl.basic.service.pc.RenderWorkerService;
|
import com.ycwl.basic.service.pc.RenderWorkerService;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -44,6 +45,10 @@ public class RenderWorkerServiceImpl implements RenderWorkerService {
|
|||||||
@Override
|
@Override
|
||||||
public ApiResponse<Integer> add(RenderWorkerEntity renderWorker) {
|
public ApiResponse<Integer> add(RenderWorkerEntity renderWorker) {
|
||||||
renderWorker.setId(SnowFlakeUtil.getLongId());
|
renderWorker.setId(SnowFlakeUtil.getLongId());
|
||||||
|
if (StringUtils.isEmpty(renderWorker.getAccessKey())) {
|
||||||
|
renderWorker.setAccessKey(SnowFlakeUtil.getId());
|
||||||
|
}
|
||||||
|
renderWorker.setStatus(0);
|
||||||
int add = renderWorkerMapper.add(renderWorker);
|
int add = renderWorkerMapper.add(renderWorker);
|
||||||
if (add == 0) {
|
if (add == 0) {
|
||||||
return ApiResponse.fail("渲染机添加失败");
|
return ApiResponse.fail("渲染机添加失败");
|
||||||
|
@ -2,7 +2,9 @@ package com.ycwl.basic.service.impl.pc;
|
|||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.ycwl.basic.mapper.pc.ScenicAccountMapper;
|
||||||
import com.ycwl.basic.mapper.pc.ScenicMapper;
|
import com.ycwl.basic.mapper.pc.ScenicMapper;
|
||||||
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||||
import com.ycwl.basic.model.pc.scenic.req.ScenicAddOrUpdateReq;
|
import com.ycwl.basic.model.pc.scenic.req.ScenicAddOrUpdateReq;
|
||||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||||
@ -10,6 +12,7 @@ import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
|||||||
import com.ycwl.basic.service.pc.ScenicService;
|
import com.ycwl.basic.service.pc.ScenicService;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -24,6 +27,8 @@ import java.util.List;
|
|||||||
public class ScenicServiceImpl implements ScenicService {
|
public class ScenicServiceImpl implements ScenicService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ScenicMapper scenicMapper;
|
private ScenicMapper scenicMapper;
|
||||||
|
@Autowired
|
||||||
|
private ScenicAccountMapper scenicAccountMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<PageInfo<ScenicRespVO>> pageQuery(ScenicReqQuery scenicReqQuery) {
|
public ApiResponse<PageInfo<ScenicRespVO>> pageQuery(ScenicReqQuery scenicReqQuery) {
|
||||||
@ -46,9 +51,21 @@ public class ScenicServiceImpl implements ScenicService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApiResponse<Boolean> add(ScenicAddOrUpdateReq scenicAddReq) {
|
public ApiResponse<Boolean> add(ScenicAddOrUpdateReq scenicAddReq) {
|
||||||
|
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicAddReq.getAccount());
|
||||||
|
if (scenicAccount != null) {
|
||||||
|
return ApiResponse.fail("账号已存在");
|
||||||
|
}
|
||||||
Long scenicId = SnowFlakeUtil.getLongId();
|
Long scenicId = SnowFlakeUtil.getLongId();
|
||||||
scenicAddReq.setId(scenicId);
|
scenicAddReq.setId(scenicId);
|
||||||
int add = scenicMapper.add(scenicAddReq);
|
int add = scenicMapper.add(scenicAddReq);
|
||||||
|
ScenicAccountEntity account = new ScenicAccountEntity();
|
||||||
|
account.setId(SnowFlakeUtil.getLongId());
|
||||||
|
account.setScenicId(scenicId);
|
||||||
|
account.setName(scenicAddReq.getName() + "管理员");
|
||||||
|
account.setAccount(scenicAddReq.getAccount());
|
||||||
|
account.setPassword(scenicAddReq.getPassword());
|
||||||
|
account.setIsSuper(1);
|
||||||
|
scenicAccountMapper.add(account);
|
||||||
if (add > 0) {
|
if (add > 0) {
|
||||||
return ApiResponse.success(true);
|
return ApiResponse.success(true);
|
||||||
}else {
|
}else {
|
||||||
@ -62,6 +79,7 @@ public class ScenicServiceImpl implements ScenicService {
|
|||||||
int i = scenicMapper.deleteById(id);
|
int i = scenicMapper.deleteById(id);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
scenicMapper.deleteConfigByscenicId(id);
|
scenicMapper.deleteConfigByscenicId(id);
|
||||||
|
scenicAccountMapper.deleteByScenicId(id);
|
||||||
return ApiResponse.success(true);
|
return ApiResponse.success(true);
|
||||||
}else {
|
}else {
|
||||||
return ApiResponse.fail("景区删除失败");
|
return ApiResponse.fail("景区删除失败");
|
||||||
@ -70,6 +88,29 @@ public class ScenicServiceImpl implements ScenicService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<Boolean> update(ScenicAddOrUpdateReq scenicUpdateReq) {
|
public ApiResponse<Boolean> update(ScenicAddOrUpdateReq scenicUpdateReq) {
|
||||||
|
if (StringUtils.isNotBlank(scenicUpdateReq.getAccount()) && StringUtils.isNotBlank(scenicUpdateReq.getPassword())) {
|
||||||
|
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicUpdateReq.getAccount());
|
||||||
|
if (scenicAccount != null) {
|
||||||
|
if (!scenicAccount.getScenicId().equals(scenicUpdateReq.getId())) {
|
||||||
|
return ApiResponse.fail("账号已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ScenicAccountEntity account = scenicAccountMapper.getSuperAccountOfScenic(scenicUpdateReq.getId());
|
||||||
|
if (account != null) {
|
||||||
|
account.setAccount(scenicUpdateReq.getAccount());
|
||||||
|
account.setPassword(scenicUpdateReq.getPassword());
|
||||||
|
scenicAccountMapper.update(account);
|
||||||
|
} else {
|
||||||
|
account = new ScenicAccountEntity();
|
||||||
|
account.setId(SnowFlakeUtil.getLongId());
|
||||||
|
account.setScenicId(scenicUpdateReq.getId());
|
||||||
|
account.setName(scenicUpdateReq.getName() + "管理员");
|
||||||
|
account.setAccount(scenicUpdateReq.getAccount());
|
||||||
|
account.setPassword(scenicUpdateReq.getPassword());
|
||||||
|
account.setIsSuper(1);
|
||||||
|
scenicAccountMapper.add(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
int i = scenicMapper.update(scenicUpdateReq);
|
int i = scenicMapper.update(scenicUpdateReq);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
return ApiResponse.success(true);
|
return ApiResponse.success(true);
|
||||||
|
@ -0,0 +1,152 @@
|
|||||||
|
package com.ycwl.basic.service.impl.task;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.aliyuncs.exceptions.ClientException;
|
||||||
|
import com.aliyuncs.facebody.model.v20191230.AddFaceEntityRequest;
|
||||||
|
import com.aliyuncs.facebody.model.v20191230.AddFaceRequest;
|
||||||
|
import com.aliyuncs.facebody.model.v20191230.AddFaceResponse;
|
||||||
|
import com.aliyuncs.facebody.model.v20191230.DeleteFaceEntityRequest;
|
||||||
|
import com.aliyuncs.facebody.model.v20191230.SearchFaceRequest;
|
||||||
|
import com.aliyuncs.facebody.model.v20191230.SearchFaceResponse;
|
||||||
|
import com.ycwl.basic.config.FaceDetectConfig;
|
||||||
|
import com.ycwl.basic.mapper.pc.DeviceMapper;
|
||||||
|
import com.ycwl.basic.mapper.pc.FaceMapper;
|
||||||
|
import com.ycwl.basic.mapper.pc.FaceSampleMapper;
|
||||||
|
import com.ycwl.basic.mapper.pc.ScenicMapper;
|
||||||
|
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||||
|
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||||
|
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
||||||
|
import com.ycwl.basic.model.pc.faceSample.req.FaceSampleReqQuery;
|
||||||
|
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||||
|
import com.ycwl.basic.model.task.resp.AddFaceRespVo;
|
||||||
|
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||||
|
import com.ycwl.basic.service.task.TaskFaceService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.aliyuncs.DefaultAcsClient;
|
||||||
|
import com.aliyuncs.IAcsClient;
|
||||||
|
import com.aliyuncs.profile.DefaultProfile;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TaskFaceServiceImpl implements TaskFaceService {
|
||||||
|
@Autowired
|
||||||
|
private FaceMapper faceMapper;
|
||||||
|
@Autowired
|
||||||
|
private FaceSampleMapper faceSampleMapper;
|
||||||
|
@Autowired
|
||||||
|
private ScenicMapper scenicMapper;
|
||||||
|
private static final String DATE_FORMAT="yyyyMMddHHmmssSSS";
|
||||||
|
@Autowired
|
||||||
|
private DeviceMapper deviceMapper;
|
||||||
|
@Autowired
|
||||||
|
private FaceDetectConfig faceDetectConfig;
|
||||||
|
|
||||||
|
private IAcsClient getClient() {
|
||||||
|
DefaultProfile profile = DefaultProfile.getProfile(
|
||||||
|
faceDetectConfig.getRegion(),faceDetectConfig.getAccessKeyId(), faceDetectConfig.getAccessKeySecret());
|
||||||
|
IAcsClient client = new DefaultAcsClient(profile);
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public SearchFaceRespVo searchFace(Long scenicId, Long faceId) {
|
||||||
|
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
||||||
|
IAcsClient client = getClient();
|
||||||
|
SearchFaceRequest request = new SearchFaceRequest();
|
||||||
|
request.setDbName(scenicId.toString());
|
||||||
|
request.setImageUrl(faceRespVO.getFaceUrl());
|
||||||
|
request.setLimit(100);
|
||||||
|
request.setQualityScoreThreshold(80F);
|
||||||
|
try {
|
||||||
|
SearchFaceResponse response = client.getAcsResponse(request);
|
||||||
|
List<SearchFaceResponse.Data.MatchListItem> matchList = response.getData().getMatchList();
|
||||||
|
if (matchList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
SearchFaceRespVo respVo = new SearchFaceRespVo();
|
||||||
|
FaceEntity faceEntity = new FaceEntity();
|
||||||
|
faceEntity.setId(faceId);
|
||||||
|
faceEntity.setMatchResult(JSON.toJSONString(matchList));
|
||||||
|
faceEntity.setScore(matchList.get(0).getQualitieScore());
|
||||||
|
List<SearchFaceResponse.Data.MatchListItem.FaceItemsItem> faceItems = matchList.get(0).getFaceItems().stream()
|
||||||
|
.filter(faceItemsItem -> faceItemsItem.getConfidence() > 50).collect(Collectors.toList());
|
||||||
|
List<Long> faceSampleIds = faceItems.stream()
|
||||||
|
.map(SearchFaceResponse.Data.MatchListItem.FaceItemsItem::getExtraData)
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
faceEntity.setMatchSampleIds(StringUtils.joinWith(",", faceSampleIds));
|
||||||
|
faceMapper.update(faceEntity);
|
||||||
|
respVo.setSampleListIds(faceSampleIds);
|
||||||
|
respVo.setScore(matchList.get(0).getQualitieScore());
|
||||||
|
return respVo;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AddFaceRespVo addFaceSample(Long faceSampleId) {
|
||||||
|
FaceSampleRespVO faceSampleRespVO = faceSampleMapper.getById(faceSampleId);
|
||||||
|
AddFaceEntityRequest request = new AddFaceEntityRequest();
|
||||||
|
request.setDbName(faceSampleRespVO.getScenicId().toString());
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
||||||
|
String entityId = faceSampleRespVO.getDeviceId().toString() + "_" + sdf.format(faceSampleRespVO.getCreateAt());
|
||||||
|
request.setEntityId(entityId);
|
||||||
|
IAcsClient client = getClient();
|
||||||
|
try {
|
||||||
|
client.getAcsResponse(request);
|
||||||
|
} catch (ClientException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
AddFaceRequest addFaceRequest = new AddFaceRequest();
|
||||||
|
addFaceRequest.setDbName(faceSampleRespVO.getScenicId().toString());
|
||||||
|
addFaceRequest.setEntityId(entityId);
|
||||||
|
addFaceRequest.setImageUrl(faceSampleRespVO.getFaceUrl());
|
||||||
|
addFaceRequest.setExtraData(faceSampleId.toString());
|
||||||
|
AddFaceRespVo respVo = new AddFaceRespVo();
|
||||||
|
try {
|
||||||
|
AddFaceResponse acsResponse = client.getAcsResponse(addFaceRequest);
|
||||||
|
FaceSampleEntity faceSampleEntity = new FaceSampleEntity();
|
||||||
|
faceSampleEntity.setId(faceSampleId);
|
||||||
|
faceSampleEntity.setScore(acsResponse.getData().getQualitieScore());
|
||||||
|
faceSampleEntity.setUpdateAt(new Date());
|
||||||
|
faceSampleMapper.update(faceSampleEntity);
|
||||||
|
respVo.setScore(acsResponse.getData().getQualitieScore());
|
||||||
|
} catch (ClientException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return respVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void batchDeleteFace(Long scenicId) {
|
||||||
|
FaceSampleReqQuery query = new FaceSampleReqQuery();
|
||||||
|
query.setDeviceId(scenicId);
|
||||||
|
faceSampleMapper.list(query);
|
||||||
|
Date thatDay = DateUtil.offsetDay(new Date(), -3);
|
||||||
|
Date dayStart = DateUtil.beginOfDay(thatDay);
|
||||||
|
Date dayEnd = DateUtil.endOfDay(thatDay);
|
||||||
|
query.setStartTime(dayStart);
|
||||||
|
query.setEndTime(dayEnd);
|
||||||
|
IAcsClient client = getClient();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
||||||
|
faceSampleMapper.list(query).forEach(faceSampleEntity -> {
|
||||||
|
String entityId = faceSampleEntity.getDeviceId().toString() + "_" + sdf.format(faceSampleEntity.getCreateAt());
|
||||||
|
DeleteFaceEntityRequest request = new DeleteFaceEntityRequest();
|
||||||
|
request.setDbName(scenicId.toString());
|
||||||
|
request.setEntityId(entityId);
|
||||||
|
try {
|
||||||
|
client.getAcsResponse(request);
|
||||||
|
} catch (ClientException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.ycwl.basic.service.task;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.task.resp.AddFaceRespVo;
|
||||||
|
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||||
|
|
||||||
|
public interface TaskFaceService {
|
||||||
|
|
||||||
|
SearchFaceRespVo searchFace(Long scenicId, Long faceId);
|
||||||
|
|
||||||
|
AddFaceRespVo addFaceSample(Long faceSampleId);
|
||||||
|
|
||||||
|
void batchDeleteFace(Long scenicId);
|
||||||
|
}
|
@ -90,10 +90,15 @@ wx:
|
|||||||
|
|
||||||
#阿里云OSS
|
#阿里云OSS
|
||||||
aliYunOss:
|
aliYunOss:
|
||||||
endpoint: "https://oss-cn-chengdu.aliyuncs.com"
|
endpoint: "https://oss-cn-shanghai.aliyuncs.com"
|
||||||
accessKeyId: "LTAI5t5cydpGpHfYqf31mEJA"
|
accessKeyId: "LTAI5tCa641QdNHH9Ybg9u7V"
|
||||||
accessKeySecret: "xdFzlwzmE8QPPstbcZY82tU3xj7G0R"
|
accessKeySecret: "RRVIgekoqx96Fgm2Gs7eQshMShcEpk"
|
||||||
bucketName: "scwzzn-file"
|
bucketName: "frametour-assets"
|
||||||
objectName: "image/"
|
objectName: "user-faces/"
|
||||||
url: "https://scwzzn-file.oss-cn-chengdu.aliyuncs.com/"
|
url: "https://frametour-assets.oss-cn-shanghai.aliyuncs.com/"
|
||||||
region: "cn-hangzhou"
|
region: "cn-shanghai"
|
||||||
|
#阿里云人脸检测
|
||||||
|
aliYunFace:
|
||||||
|
accessKeyId: "LTAI5tMwrmxVcUEKoH5QzLHx"
|
||||||
|
accessKeySecret: "ZCIP8aKx1jwX1wkeYIPQEDZ8fPtN1c"
|
||||||
|
region: "cn-shanghai"
|
@ -23,12 +23,20 @@
|
|||||||
delete from broker where id = #{id}
|
delete from broker where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
<select id="list" resultType="com.ycwl.basic.model.pc.broker.entity.BrokerEntity">
|
<select id="list" resultType="com.ycwl.basic.model.pc.broker.entity.BrokerEntity">
|
||||||
select id, `name`, promo_code, status, create_at, update_at
|
select id, `name`, phone, promo_code, status,
|
||||||
|
(select count(1) from `order` where broker_id = broker.id) as broker_order_count,
|
||||||
|
(select sum(pay_price) from `order` where broker_id = broker.id) as broker_order_amount,
|
||||||
|
(select create_at from `order` where broker_id = broker.id and status = 1 order by create_at desc limit 1) as last_broker_date,
|
||||||
|
(select create_at from `order` where broker_id = broker.id and status = 1 order by create_at asc limit 1) as first_broker_date,
|
||||||
|
create_at, update_at
|
||||||
from broker
|
from broker
|
||||||
<where>
|
<where>
|
||||||
<if test="name!= null and name!= ''">
|
<if test="name!= null and name!= ''">
|
||||||
and `name` like concat('%', #{name}, '%')
|
and `name` like concat('%', #{name}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="phone!= null and phone!= ''">
|
||||||
|
and `phone` like concat('%', #{phone}, '%')
|
||||||
|
</if>
|
||||||
<if test="promoCode!= null and promoCode!= ''">
|
<if test="promoCode!= null and promoCode!= ''">
|
||||||
and promo_code like concat('%', #{promoCode}, '%')
|
and promo_code like concat('%', #{promoCode}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -53,4 +53,9 @@
|
|||||||
left join scenic s on d.scenic_id = s.id
|
left join scenic s on d.scenic_id = s.id
|
||||||
where d.id = #{id}
|
where d.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listByScenicId" resultType="com.ycwl.basic.model.pc.device.resp.DeviceRespVO">
|
||||||
|
select d.id, d.name, no, d.status, create_at, d.update_at
|
||||||
|
from device d
|
||||||
|
where d.scenic_id = #{scenicId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -2,8 +2,8 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.ycwl.basic.mapper.pc.FaceMapper">
|
<mapper namespace="com.ycwl.basic.mapper.pc.FaceMapper">
|
||||||
<insert id="add">
|
<insert id="add">
|
||||||
insert into face(id, member_id, face_url, match_sample_ids, first_match_rate, match_result)
|
insert into face(id, score, member_id, face_url, match_sample_ids, first_match_rate, match_result)
|
||||||
values (#{id}, #{memberId}, #{faceUrl}, #{matchSampleIds}, #{firstMatchRate}, #{matchResult})
|
values (#{id}, #{score}, #{memberId}, #{faceUrl}, #{matchSampleIds}, #{firstMatchRate}, #{matchResult})
|
||||||
</insert>
|
</insert>
|
||||||
<update id="update">
|
<update id="update">
|
||||||
update face
|
update face
|
||||||
@ -11,6 +11,9 @@
|
|||||||
<if test="memberId!= null ">
|
<if test="memberId!= null ">
|
||||||
member_id = #{memberId},
|
member_id = #{memberId},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="score!= null ">
|
||||||
|
score = #{score},
|
||||||
|
</if>
|
||||||
<if test="faceUrl!= null and faceUrl!= ''">
|
<if test="faceUrl!= null and faceUrl!= ''">
|
||||||
face_url = #{faceUrl},
|
face_url = #{faceUrl},
|
||||||
</if>
|
</if>
|
||||||
|
@ -42,9 +42,12 @@
|
|||||||
</if>
|
</if>
|
||||||
</delete>
|
</delete>
|
||||||
<select id="list" resultType="com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO">
|
<select id="list" resultType="com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO">
|
||||||
select id, device_id, face_url, match_sample_ids, first_match_rate, match_result,`status`
|
select id, scenic_id, device_id, face_url, match_sample_ids, first_match_rate, match_result,`status`
|
||||||
from face_sample
|
from face_sample
|
||||||
<where>
|
<where>
|
||||||
|
<if test="scenicId!= null and scenicId!= ''">
|
||||||
|
and device_id = #{deviceId}
|
||||||
|
</if>
|
||||||
<if test="deviceId!= null and deviceId!= ''">
|
<if test="deviceId!= null and deviceId!= ''">
|
||||||
and device_id = #{deviceId}
|
and device_id = #{deviceId}
|
||||||
</if>
|
</if>
|
||||||
@ -69,7 +72,7 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<select id="getById" resultType="com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO">
|
<select id="getById" resultType="com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO">
|
||||||
select id, device_id, face_url, match_sample_ids, first_match_rate, match_result,`status`
|
select id, scenic_id, device_id, face_url, match_sample_ids, first_match_rate, match_result,`status`
|
||||||
from face_sample
|
from face_sample
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
52
src/main/resources/mapper/pc/ScenicAccountMapper.xml
Normal file
52
src/main/resources/mapper/pc/ScenicAccountMapper.xml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.ycwl.basic.mapper.pc.ScenicAccountMapper">
|
||||||
|
<insert id="add">
|
||||||
|
insert into scenic_account(id, scenic_id, is_super, name, account, password, create_time, update_time)
|
||||||
|
values (#{id}, #{scenicId}, #{isSuper}, #{name}, #{account}, #{password}, now(), now())
|
||||||
|
</insert>
|
||||||
|
<update id="update">
|
||||||
|
update scenic_account
|
||||||
|
<set>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="account != null and account != ''">
|
||||||
|
account = #{account},
|
||||||
|
</if>
|
||||||
|
<if test="password != null and password != ''">
|
||||||
|
password = #{password},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<update id="updateStatus">
|
||||||
|
update scenic_account
|
||||||
|
set status = (CASE
|
||||||
|
WHEN status = 1 THEN
|
||||||
|
0
|
||||||
|
WHEN status = 0 THEN
|
||||||
|
1
|
||||||
|
ELSE null
|
||||||
|
END)
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<delete id="deleteById">
|
||||||
|
delete from scenic_account where id = #{id}
|
||||||
|
</delete>
|
||||||
|
<delete id="deleteByScenicId">
|
||||||
|
delete from scenic_account where scenic_id = #{scenicId}
|
||||||
|
</delete>
|
||||||
|
<select id="getSuperAccountOfScenic"
|
||||||
|
resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
|
||||||
|
select id, scenic_id, is_super, name, account, password, create_time, update_time
|
||||||
|
from scenic_account
|
||||||
|
where scenic_id = #{scenicId} and is_super = 1
|
||||||
|
</select>
|
||||||
|
<select id="getByAccount" resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
|
||||||
|
select id, scenic_id, is_super, name, account, password, create_time, update_time
|
||||||
|
from scenic_account
|
||||||
|
where account = #{account}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -16,6 +16,9 @@
|
|||||||
<if test="name!=null and name!=''">
|
<if test="name!=null and name!=''">
|
||||||
`name`=#{name},
|
`name`=#{name},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="phone!=null and phone!=''">
|
||||||
|
`phone`=#{phone},
|
||||||
|
</if>
|
||||||
<if test="introduction!=null and introduction!=''">
|
<if test="introduction!=null and introduction!=''">
|
||||||
introduction=#{introduction},
|
introduction=#{introduction},
|
||||||
</if>
|
</if>
|
||||||
@ -77,8 +80,10 @@
|
|||||||
delete from scenic_config where scenic_id = #{scenicId}
|
delete from scenic_config where scenic_id = #{scenicId}
|
||||||
</delete>
|
</delete>
|
||||||
<select id="list" resultMap="scenicAndConfig">
|
<select id="list" resultMap="scenicAndConfig">
|
||||||
select s.id, `name`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
|
select s.id, `name`, `phone`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
|
||||||
c.start_time, c.end_time, c.is_default, c.create_time
|
c.start_time, c.end_time,
|
||||||
|
(select scenic_account.account from scenic_account where scenic_account.scenic_id = s.id and scenic_account.is_super = 1 limit 1) as account,
|
||||||
|
c.is_default, c.create_time
|
||||||
from scenic s
|
from scenic s
|
||||||
left join scenic_config c on s.id = c.id
|
left join scenic_config c on s.id = c.id
|
||||||
<where>
|
<where>
|
||||||
@ -106,7 +111,7 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<select id="getById" resultMap="scenicAndConfig">
|
<select id="getById" resultMap="scenicAndConfig">
|
||||||
select s.id, `name`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
|
select s.id, `name`, `phone`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
|
||||||
c.start_time, c.end_time, c.is_default, c.create_time,s.price
|
c.start_time, c.end_time, c.is_default, c.create_time,s.price
|
||||||
from scenic s
|
from scenic s
|
||||||
left join scenic_config c on s.id = c.id
|
left join scenic_config c on s.id = c.id
|
||||||
@ -114,8 +119,10 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<resultMap id="scenicAndConfig" type="com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO">
|
<resultMap id="scenicAndConfig" type="com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO">
|
||||||
<id property="id" column="s.id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="name" column="name"/>
|
<result property="name" column="name"/>
|
||||||
|
<result property="account" column="account"/>
|
||||||
|
<result property="phone" column="phone"/>
|
||||||
<result property="introduction" column="introduction"/>
|
<result property="introduction" column="introduction"/>
|
||||||
<result property="longitude" column="longitude"/>
|
<result property="longitude" column="longitude"/>
|
||||||
<result property="latitude" column="latitude"/>
|
<result property="latitude" column="latitude"/>
|
||||||
|
Reference in New Issue
Block a user