bug
This commit is contained in:
parent
9c1d979bd8
commit
02548a3028
@ -4,11 +4,13 @@ import com.ycwl.basic.mapper.FaceMapper;
|
|||||||
import com.ycwl.basic.mapper.VideoMapper;
|
import com.ycwl.basic.mapper.VideoMapper;
|
||||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||||
import com.ycwl.basic.model.mobile.order.PriceObj;
|
import com.ycwl.basic.model.mobile.order.PriceObj;
|
||||||
|
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||||
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.entity.ScenicEntity;
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
||||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||||
|
import com.ycwl.basic.repository.FaceRepository;
|
||||||
import com.ycwl.basic.repository.OrderRepository;
|
import com.ycwl.basic.repository.OrderRepository;
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
import com.ycwl.basic.repository.TemplateRepository;
|
import com.ycwl.basic.repository.TemplateRepository;
|
||||||
@ -27,9 +29,9 @@ public class OrderBiz {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TemplateRepository templateRepository;
|
private TemplateRepository templateRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FaceMapper faceMapper;
|
|
||||||
@Autowired
|
|
||||||
private OrderRepository orderRepository;
|
private OrderRepository orderRepository;
|
||||||
|
@Autowired
|
||||||
|
private FaceRepository faceRepository;
|
||||||
|
|
||||||
public PriceObj queryPrice(Long scenicId, int goodsType, Long goodsId) {
|
public PriceObj queryPrice(Long scenicId, int goodsType, Long goodsId) {
|
||||||
PriceObj priceObj = new PriceObj();
|
PriceObj priceObj = new PriceObj();
|
||||||
@ -56,16 +58,21 @@ public class OrderBiz {
|
|||||||
return priceObj;
|
return priceObj;
|
||||||
}
|
}
|
||||||
priceObj.setPrice(template.getPrice());
|
priceObj.setPrice(template.getPrice());
|
||||||
priceObj.setSlashPrice(template.getSlashPrice());
|
BigDecimal slashPrice = template.getSlashPrice();
|
||||||
|
if (slashPrice == null) {
|
||||||
|
priceObj.setSlashPrice(priceObj.getPrice());
|
||||||
|
} else {
|
||||||
|
priceObj.setSlashPrice(slashPrice);
|
||||||
|
}
|
||||||
priceObj.setScenicId(video.getScenicId());
|
priceObj.setScenicId(video.getScenicId());
|
||||||
break;
|
break;
|
||||||
case 1: // source
|
case 1: // source
|
||||||
// goodsId 实际上是人脸ID
|
// goodsId 实际上是人脸ID
|
||||||
FaceRespVO _faceRespVO = faceMapper.getById(goodsId);
|
FaceEntity _face = faceRepository.getFace(goodsId);
|
||||||
if (_faceRespVO == null || _faceRespVO.getScenicId() == null) {
|
if (_face == null || _face.getScenicId() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ScenicEntity _scenic = scenicRepository.getScenic(_faceRespVO.getScenicId());
|
ScenicEntity _scenic = scenicRepository.getScenic(_face.getScenicId());
|
||||||
if (_scenic == null) {
|
if (_scenic == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -74,11 +81,11 @@ public class OrderBiz {
|
|||||||
break;
|
break;
|
||||||
case 2: // source
|
case 2: // source
|
||||||
// goodsId 实际上是人脸ID
|
// goodsId 实际上是人脸ID
|
||||||
FaceRespVO __faceRespVO = faceMapper.getById(goodsId);
|
FaceEntity __face = faceRepository.getFace(goodsId);
|
||||||
if (__faceRespVO == null || __faceRespVO.getScenicId() == null) {
|
if (__face == null || __face.getScenicId() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ScenicEntity __scenic = scenicRepository.getScenic(__faceRespVO.getScenicId());
|
ScenicEntity __scenic = scenicRepository.getScenic(__face.getScenicId());
|
||||||
if (__scenic == null) {
|
if (__scenic == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,15 @@ package com.ycwl.basic.controller.mobile;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ycwl.basic.annotation.IgnoreToken;
|
import com.ycwl.basic.annotation.IgnoreToken;
|
||||||
import com.ycwl.basic.model.wx.WechatMessageSubscribeForm;
|
import com.ycwl.basic.model.wx.WechatMessageSubscribeForm;
|
||||||
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
import com.ycwl.basic.service.mobile.WxNotifyService;
|
import com.ycwl.basic.service.mobile.WxNotifyService;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -30,20 +33,43 @@ import java.util.List;
|
|||||||
public class AppWxNotifyController {
|
public class AppWxNotifyController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private WxNotifyService wxNotifyService;
|
private WxNotifyService wxNotifyService;
|
||||||
|
@Autowired
|
||||||
|
private ScenicRepository scenicRepository;
|
||||||
|
//
|
||||||
|
// @ApiOperation(value = "通知", notes = "通知")
|
||||||
|
// @PostMapping("/pushMessage")
|
||||||
|
// @IgnoreToken
|
||||||
|
// public ApiResponse<?> pushMessage(@RequestBody WechatMessageSubscribeForm req) {
|
||||||
|
// JSONObject resJson = wxNotifyService.pushMessage(req);
|
||||||
|
// return ApiResponse.success(resJson);
|
||||||
|
// }
|
||||||
|
|
||||||
@ApiOperation(value = "通知", notes = "通知")
|
@GetMapping({"/getIds", "/"})
|
||||||
@PostMapping("/pushMessage")
|
|
||||||
@IgnoreToken
|
|
||||||
public ApiResponse<?> pushMessage(@RequestBody WechatMessageSubscribeForm req) {
|
|
||||||
JSONObject resJson = wxNotifyService.pushMessage(req);
|
|
||||||
return ApiResponse.success(resJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getIds")
|
|
||||||
@IgnoreToken
|
@IgnoreToken
|
||||||
public ApiResponse<List<String>> getIds() {
|
public ApiResponse<List<String>> getIds() {
|
||||||
return ApiResponse.success(new ArrayList<String>() {{
|
return ApiResponse.success(new ArrayList<String>() {{
|
||||||
add("5b8vTm7kvwYubqDxb3dxBqFIhc3Swt5l7QHSK5r-ZRI");
|
add("5b8vTm7kvwYubqDxb3dxBs0BqxMsgVgGw573aahTEd8");
|
||||||
|
add("vPIzbkA0x4mMj-vdbWx6_45e8juWXzs3FGYnDsIPv3A");
|
||||||
|
add("HB1vp-0BXc2WyYeoYN3a3GuZV9HtPLXUTT7blCBq9eY");
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{scenicId}")
|
||||||
|
@IgnoreToken
|
||||||
|
public ApiResponse<List<String>> getIds(@PathVariable("scenicId") Long scenicId) {
|
||||||
|
return ApiResponse.success(new ArrayList<String>() {{
|
||||||
|
String videoGeneratedTemplateId = scenicRepository.getVideoGeneratedTemplateId(scenicId);
|
||||||
|
if (StringUtils.isNotBlank(videoGeneratedTemplateId)) {
|
||||||
|
add(videoGeneratedTemplateId);
|
||||||
|
}
|
||||||
|
String videoDownloadTemplateId = scenicRepository.getVideoDownloadTemplateId(scenicId);
|
||||||
|
if (StringUtils.isNotBlank(videoDownloadTemplateId)) {
|
||||||
|
add(videoDownloadTemplateId);
|
||||||
|
}
|
||||||
|
String videoPreExpireTemplateId = scenicRepository.getVideoPreExpireTemplateId(scenicId);
|
||||||
|
if (StringUtils.isNotBlank(videoPreExpireTemplateId)) {
|
||||||
|
add(videoPreExpireTemplateId);
|
||||||
|
}
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +54,6 @@ public class FaceController {
|
|||||||
public ApiResponse<Integer> deleteByIds(@RequestBody List<Long> ids) {
|
public ApiResponse<Integer> deleteByIds(@RequestBody List<Long> ids) {
|
||||||
return faceService.deleteByIds(ids);
|
return faceService.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
@ApiOperation("修改用户人脸信息")
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ApiResponse<Integer> update(@RequestBody FaceEntity face) {
|
|
||||||
return faceService.update(face);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class ViidController {
|
|||||||
// log.info("已经解析过的心跳信息:{}", keepaliveObject);
|
// log.info("已经解析过的心跳信息:{}", keepaliveObject);
|
||||||
|
|
||||||
return new VIIDBaseResp(
|
return new VIIDBaseResp(
|
||||||
new ResponseStatusObject(deviceId, "/VIID/System/UnRegister", "0", "注销成功", sdfTime.format(new Date()))
|
new ResponseStatusObject(deviceId, "/VIID/System/Keepalive", "0", "保活", sdfTime.format(new Date()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +186,8 @@ public class ViidController {
|
|||||||
* 批量新增人脸
|
* 批量新增人脸
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/Faces", method = RequestMethod.POST)
|
@RequestMapping(value = "/Faces", method = RequestMethod.POST)
|
||||||
|
@IgnoreLogReq
|
||||||
public VIIDBaseResp faces(@RequestBody FaceUploadReq req) {
|
public VIIDBaseResp faces(@RequestBody FaceUploadReq req) {
|
||||||
log.info("收到的人脸上报信息:{}",req);
|
|
||||||
FaceListObject faceListObject = req.getFaceListObject();
|
FaceListObject faceListObject = req.getFaceListObject();
|
||||||
List<FaceObject> faceObject = faceListObject.getFaceObject();
|
List<FaceObject> faceObject = faceListObject.getFaceObject();
|
||||||
String faceId = null;
|
String faceId = null;
|
||||||
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@Api(tags = "WVP对接接口")
|
@Api(tags = "WVP对接接口")
|
||||||
@RequestMapping("/wvp/v1/")
|
@RequestMapping("/wvp/v1/")
|
||||||
public class WvpController {
|
public class WvpController {
|
||||||
|
|
||||||
@IgnoreLogReq
|
@IgnoreLogReq
|
||||||
@PostMapping("/sync")
|
@PostMapping("/sync")
|
||||||
public ApiResponse sync() {
|
public ApiResponse sync() {
|
||||||
|
@ -61,6 +61,7 @@ public interface SourceMapper {
|
|||||||
|
|
||||||
int hasRelationTo(Long memberId, Long sourceId, int type);
|
int hasRelationTo(Long memberId, Long sourceId, int type);
|
||||||
|
|
||||||
|
List<SourceEntity> listVideoByScenicFaceRelation(Long scenicId, Long faceId);
|
||||||
List<SourceEntity> listVideoByFaceRelation(Long faceId);
|
List<SourceEntity> listVideoByFaceRelation(Long faceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.ycwl.basic.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ycwl.basic.model.pc.source.entity.SourceTaskEntity;
|
||||||
|
|
||||||
|
public interface SourceTaskMapper extends BaseMapper<SourceTaskEntity> {
|
||||||
|
}
|
@ -19,6 +19,7 @@ import java.util.List;
|
|||||||
public interface TemplateMapper {
|
public interface TemplateMapper {
|
||||||
List<TemplateRespVO> list(TemplateReqQuery templateReqQuery);
|
List<TemplateRespVO> list(TemplateReqQuery templateReqQuery);
|
||||||
TemplateRespVO getById(Long id);
|
TemplateRespVO getById(Long id);
|
||||||
|
TemplateEntity get(Long id);
|
||||||
int add(TemplateEntity task);
|
int add(TemplateEntity task);
|
||||||
int deleteById(Long id);
|
int deleteById(Long id);
|
||||||
int update(TemplateEntity task);
|
int update(TemplateEntity task);
|
||||||
|
@ -10,4 +10,6 @@ public class ScenicMpNotifyVO {
|
|||||||
private String appSecret;
|
private String appSecret;
|
||||||
private String appState;
|
private String appState;
|
||||||
private String videoGeneratedTemplateId;
|
private String videoGeneratedTemplateId;
|
||||||
|
private String videoDownloadTemplateId;
|
||||||
|
private String videoPreExpireTemplateId;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.ycwl.basic.model.pc.source.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("source_task")
|
||||||
|
public class SourceTaskEntity {
|
||||||
|
private Integer id;
|
||||||
|
private Long scenicId;
|
||||||
|
private Long deviceId;
|
||||||
|
private Long faceSampleId;
|
||||||
|
private Integer status;
|
||||||
|
private String url;
|
||||||
|
private Date createTime;
|
||||||
|
private Date startTime;
|
||||||
|
private Date endTime;
|
||||||
|
private Long waitTaskId;
|
||||||
|
private String nextFsIds;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.ycwl.basic.device.repository;
|
package com.ycwl.basic.repository;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ycwl.basic.mapper.DeviceMapper;
|
import com.ycwl.basic.mapper.DeviceMapper;
|
@ -1,10 +1,10 @@
|
|||||||
package com.ycwl.basic.repository;
|
package com.ycwl.basic.repository;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ycwl.basic.mapper.FaceMapper;
|
import com.ycwl.basic.mapper.FaceMapper;
|
||||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||||
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
||||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
@ -24,14 +24,40 @@ public class FaceRepository {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FaceSampleMapper faceSampleMapper;
|
private FaceSampleMapper faceSampleMapper;
|
||||||
|
|
||||||
|
public static final String FACE_CACHE_KEY = "face:%s";
|
||||||
|
public static final String FACE_SAMPLE_CACHE_KEY = "face:%s:sample";
|
||||||
|
|
||||||
|
public FaceEntity getFace(Long id) {
|
||||||
|
if (redisTemplate.hasKey(String.format(FACE_CACHE_KEY, id))) {
|
||||||
|
return JSONObject.parseObject(redisTemplate.opsForValue().get(String.format(FACE_CACHE_KEY, id)), FaceEntity.class);
|
||||||
|
}
|
||||||
|
FaceEntity face = faceMapper.get(id);
|
||||||
|
if (face != null) {
|
||||||
|
redisTemplate.opsForValue().set(String.format(FACE_CACHE_KEY, id), JSONObject.toJSONString(face));
|
||||||
|
}
|
||||||
|
return face;
|
||||||
|
}
|
||||||
|
|
||||||
public List<FaceSampleEntity> getFaceSampleList(Long faceId) {
|
public List<FaceSampleEntity> getFaceSampleList(Long faceId) {
|
||||||
FaceEntity face = faceMapper.get(faceId);
|
if (redisTemplate.hasKey(String.format(FACE_SAMPLE_CACHE_KEY, faceId))) {
|
||||||
|
return JSONObject.parseArray(redisTemplate.opsForValue().get(String.format(FACE_SAMPLE_CACHE_KEY, faceId)), FaceSampleEntity.class);
|
||||||
|
}
|
||||||
|
FaceEntity face = getFace(faceId);
|
||||||
if (face == null) {
|
if (face == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(face.getMatchSampleIds())) {
|
if (StringUtils.isBlank(face.getMatchSampleIds())) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return faceSampleMapper.listByIds(Arrays.stream(face.getMatchSampleIds().split(",")).map(Long::valueOf).collect(Collectors.toList()));
|
List<FaceSampleEntity> list = faceSampleMapper.listByIds(Arrays.stream(face.getMatchSampleIds().split(",")).map(Long::valueOf).collect(Collectors.toList()));
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
redisTemplate.opsForValue().set(String.format(FACE_SAMPLE_CACHE_KEY, faceId), JSONObject.toJSONString(list));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearFaceCache(Long faceId) {
|
||||||
|
redisTemplate.delete(String.format(FACE_CACHE_KEY, faceId));
|
||||||
|
redisTemplate.delete(String.format(FACE_SAMPLE_CACHE_KEY, faceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OrderRepository {
|
public class OrderRepository {
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -17,10 +19,11 @@ public class OrderRepository {
|
|||||||
|
|
||||||
public boolean checkUserBuyItem(Long userId, int goodsType, Long goodsId) {
|
public boolean checkUserBuyItem(Long userId, int goodsType, Long goodsId) {
|
||||||
if (redisTemplate.hasKey(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId))) {
|
if (redisTemplate.hasKey(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId))) {
|
||||||
return true;
|
return "1".equals(redisTemplate.opsForValue().get(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId)));
|
||||||
}
|
}
|
||||||
OrderEntity orderEntity = orderMapper.getUserBuyItem(userId, goodsType, goodsId);
|
OrderEntity orderEntity = orderMapper.getUserBuyItem(userId, goodsType, goodsId);
|
||||||
if (orderEntity == null) {
|
if (orderEntity == null) {
|
||||||
|
redisTemplate.opsForValue().set(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId), "0", 60, TimeUnit.SECONDS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
redisTemplate.opsForValue().set(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId), "1");
|
redisTemplate.opsForValue().set(String.format(ORDER_ITEM_CACHE_KEY, userId, goodsType, goodsId), "1");
|
||||||
|
@ -81,6 +81,12 @@ public class ScenicRepository {
|
|||||||
case 0:
|
case 0:
|
||||||
mpNotifyConfig.setVideoGeneratedTemplateId(item.getTemplateId());
|
mpNotifyConfig.setVideoGeneratedTemplateId(item.getTemplateId());
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
mpNotifyConfig.setVideoDownloadTemplateId(item.getTemplateId());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
mpNotifyConfig.setVideoPreExpireTemplateId(item.getTemplateId());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
redisTemplate.opsForValue().set(String.format(SCENIC_MP_NOTIFY_CACHE_KEY, scenicId), JSONObject.toJSONString(mpNotifyConfig));
|
redisTemplate.opsForValue().set(String.format(SCENIC_MP_NOTIFY_CACHE_KEY, scenicId), JSONObject.toJSONString(mpNotifyConfig));
|
||||||
@ -95,6 +101,22 @@ public class ScenicRepository {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVideoDownloadTemplateId(Long scenicId) {
|
||||||
|
ScenicMpNotifyVO scenicMpNotifyConfig = getScenicMpNotifyConfig(scenicId);
|
||||||
|
if (scenicMpNotifyConfig != null) {
|
||||||
|
return scenicMpNotifyConfig.getVideoDownloadTemplateId();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVideoPreExpireTemplateId(Long scenicId) {
|
||||||
|
ScenicMpNotifyVO scenicMpNotifyConfig = getScenicMpNotifyConfig(scenicId);
|
||||||
|
if (scenicMpNotifyConfig != null) {
|
||||||
|
return scenicMpNotifyConfig.getVideoPreExpireTemplateId();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void clearCache(Long scenicId) {
|
public void clearCache(Long scenicId) {
|
||||||
redisTemplate.delete(String.format(SCENIC_CACHE_KEY, scenicId));
|
redisTemplate.delete(String.format(SCENIC_CACHE_KEY, scenicId));
|
||||||
redisTemplate.delete(String.format(SCENIC_CONFIG_CACHE_KEY, scenicId));
|
redisTemplate.delete(String.format(SCENIC_CONFIG_CACHE_KEY, scenicId));
|
||||||
|
@ -17,10 +17,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Service // 临时这么用
|
@Service // 临时这么用
|
||||||
public class TemplateRepository {
|
public class TemplateRepository {
|
||||||
@Autowired
|
|
||||||
private FaceMapper faceMapper;
|
|
||||||
@Autowired
|
|
||||||
private FaceSampleMapper faceSampleMapper;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateMapper templateMapper;
|
private TemplateMapper templateMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -39,6 +35,15 @@ public class TemplateRepository {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTemplateMinimalPlaceholderCount(Long templateId) {
|
||||||
|
TemplateConfigEntity config = getTemplateConfig(templateId);
|
||||||
|
if (config == null || config.getMinimalPlaceholderFill() == null) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return config.getMinimalPlaceholderFill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<TemplateRespVO> getTemplateListByScenicId(Long scenicId) {
|
public List<TemplateRespVO> getTemplateListByScenicId(Long scenicId) {
|
||||||
List<Long> idList;
|
List<Long> idList;
|
||||||
if (redisTemplate.hasKey(String.format(TEMPLATE_ID_BY_SCENIC_ID_CACHE_KEY, scenicId))) {
|
if (redisTemplate.hasKey(String.format(TEMPLATE_ID_BY_SCENIC_ID_CACHE_KEY, scenicId))) {
|
||||||
@ -69,6 +74,9 @@ public class TemplateRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TemplateConfigEntity getTemplateConfig(Long templateId) {
|
public TemplateConfigEntity getTemplateConfig(Long templateId) {
|
||||||
|
if (templateId == null) {
|
||||||
|
return new TemplateConfigEntity();
|
||||||
|
}
|
||||||
if (redisTemplate.hasKey(String.format(TEMPLATE_CONFIG_CACHE_KEY, templateId))) {
|
if (redisTemplate.hasKey(String.format(TEMPLATE_CONFIG_CACHE_KEY, templateId))) {
|
||||||
return JSONObject.parseObject(redisTemplate.opsForValue().get(String.format(TEMPLATE_CONFIG_CACHE_KEY, templateId)), TemplateConfigEntity.class);
|
return JSONObject.parseObject(redisTemplate.opsForValue().get(String.format(TEMPLATE_CONFIG_CACHE_KEY, templateId)), TemplateConfigEntity.class);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
|||||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||||
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||||
|
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||||
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
|
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
|
||||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||||
@ -258,14 +259,19 @@ public class GoodsServiceImpl implements GoodsService {
|
|||||||
return ApiResponse.success(response);
|
return ApiResponse.success(response);
|
||||||
}
|
}
|
||||||
response.setScenicId(taskList.get(0).getScenicId());
|
response.setScenicId(taskList.get(0).getScenicId());
|
||||||
response.setMaxCount(templateRepository.getTemplateListByScenicId(response.getScenicId()).size());
|
List<TemplateRespVO> templateList = templateRepository.getTemplateListByScenicId(response.getScenicId());
|
||||||
List<MemberVideoEntity> notFinishedTasks = taskList.stream().filter(task -> {
|
List<Long> templateIds = templateList.stream().map(TemplateRespVO::getId).collect(Collectors.toList());
|
||||||
TaskEntity taskById = videoTaskRepository.getTaskById(task.getTaskId());
|
response.setMaxCount(templateList.size());
|
||||||
if (taskById == null) {
|
List<MemberVideoEntity> notFinishedTasks = taskList.stream()
|
||||||
return true;
|
.filter(task -> templateIds.contains(task.getTemplateId()))
|
||||||
}
|
.filter(task -> {
|
||||||
return taskById.getStatus() != 1;
|
TaskEntity taskById = videoTaskRepository.getTaskById(task.getTaskId());
|
||||||
}).collect(Collectors.toList());
|
if (taskById == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return taskById.getStatus() != 1;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
if (!notFinishedTasks.isEmpty()) {
|
if (!notFinishedTasks.isEmpty()) {
|
||||||
response.setCount(taskList.size() - notFinishedTasks.size());
|
response.setCount(taskList.size() - notFinishedTasks.size());
|
||||||
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
||||||
@ -300,13 +306,14 @@ public class GoodsServiceImpl implements GoodsService {
|
|||||||
}
|
}
|
||||||
response.setScenicId(taskList.get(0).getScenicId());
|
response.setScenicId(taskList.get(0).getScenicId());
|
||||||
response.setMaxCount(templateRepository.getTemplateListByScenicId(response.getScenicId()).size());
|
response.setMaxCount(templateRepository.getTemplateListByScenicId(response.getScenicId()).size());
|
||||||
List<MemberVideoEntity> notFinishedTasks = taskList.stream().filter(task -> {
|
List<MemberVideoEntity> notFinishedTasks = taskList.stream()
|
||||||
TaskEntity taskById = videoTaskRepository.getTaskById(task.getTaskId());
|
.filter(task -> {
|
||||||
if (taskById == null) {
|
TaskEntity taskById = videoTaskRepository.getTaskById(task.getTaskId());
|
||||||
return true;
|
if (taskById == null) {
|
||||||
}
|
return true;
|
||||||
return taskById.getStatus() != 1;
|
}
|
||||||
}).collect(Collectors.toList());
|
return taskById.getStatus() != 1;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
if (!notFinishedTasks.isEmpty()) {
|
if (!notFinishedTasks.isEmpty()) {
|
||||||
response.setCount(taskList.size() - notFinishedTasks.size());
|
response.setCount(taskList.size() - notFinishedTasks.size());
|
||||||
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
||||||
@ -319,7 +326,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|||||||
response.setTemplateId(lastVideo.getTemplateId());
|
response.setTemplateId(lastVideo.getTemplateId());
|
||||||
response.setVideoId(lastVideo.getVideoId());
|
response.setVideoId(lastVideo.getVideoId());
|
||||||
response.setCount(taskList.size());
|
response.setCount(taskList.size());
|
||||||
response.setStatus(1);
|
if (null == lastVideo.getVideoId()) {
|
||||||
|
response.setStatus(2);
|
||||||
|
} else {
|
||||||
|
response.setStatus(1);
|
||||||
|
response.setVideoId(lastVideo.getVideoId());
|
||||||
|
}
|
||||||
return ApiResponse.success(response);
|
return ApiResponse.success(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +130,9 @@ public class WxPayServiceImpl implements WxPayService {
|
|||||||
Payer payer = new Payer();
|
Payer payer = new Payer();
|
||||||
payer.setOpenid(req.getOpenId());
|
payer.setOpenid(req.getOpenId());
|
||||||
request.setPayer(payer);
|
request.setPayer(payer);
|
||||||
SettleInfo settleInfo = new SettleInfo();
|
// SettleInfo settleInfo = new SettleInfo();
|
||||||
settleInfo.setProfitSharing(true);
|
// settleInfo.setProfitSharing(true);
|
||||||
request.setSettleInfo(settleInfo);
|
// request.setSettleInfo(settleInfo);
|
||||||
|
|
||||||
// 调用下单方法,得到应答
|
// 调用下单方法,得到应答
|
||||||
PrepayResponse response = service.prepay(request);
|
PrepayResponse response = service.prepay(request);
|
||||||
|
@ -2,7 +2,7 @@ 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.device.repository.DeviceRepository;
|
import com.ycwl.basic.repository.DeviceRepository;
|
||||||
import com.ycwl.basic.mapper.DeviceMapper;
|
import com.ycwl.basic.mapper.DeviceMapper;
|
||||||
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
||||||
import com.ycwl.basic.model.pc.device.req.DeviceAddOrUpdateReq;
|
import com.ycwl.basic.model.pc.device.req.DeviceAddOrUpdateReq;
|
||||||
@ -89,5 +89,6 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
public void saveConfig(Long configId, DeviceConfigEntity config) {
|
public void saveConfig(Long configId, DeviceConfigEntity config) {
|
||||||
config.setId(configId);
|
config.setId(configId);
|
||||||
deviceMapper.updateConfig(config);
|
deviceMapper.updateConfig(config);
|
||||||
|
deviceRepository.clearDeviceCache(config.getDeviceId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
|||||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||||
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||||
|
import com.ycwl.basic.repository.FaceRepository;
|
||||||
import com.ycwl.basic.service.pc.FaceService;
|
import com.ycwl.basic.service.pc.FaceService;
|
||||||
import com.ycwl.basic.service.task.TaskFaceService;
|
import com.ycwl.basic.service.task.TaskFaceService;
|
||||||
import com.ycwl.basic.service.task.TaskService;
|
import com.ycwl.basic.service.task.TaskService;
|
||||||
@ -66,6 +67,8 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
private FaceSampleMapper faceSampleMapper;
|
private FaceSampleMapper faceSampleMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderBiz orderBiz;
|
private OrderBiz orderBiz;
|
||||||
|
@Autowired
|
||||||
|
private FaceRepository faceRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<PageInfo<FaceRespVO>> pageQuery(FaceReqQuery faceReqQuery) {
|
public ApiResponse<PageInfo<FaceRespVO>> pageQuery(FaceReqQuery faceReqQuery) {
|
||||||
@ -113,15 +116,6 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
return ApiResponse.success(i);
|
return ApiResponse.success(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApiResponse<Integer> update(FaceEntity face) {
|
|
||||||
int i = faceMapper.update(face);
|
|
||||||
if (i == 0) {
|
|
||||||
return ApiResponse.fail("修改失败");
|
|
||||||
}
|
|
||||||
return ApiResponse.success(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// @Transactional(rollbackFor = Exception.class)
|
// @Transactional(rollbackFor = Exception.class)
|
||||||
public ApiResponse faceUpload(MultipartFile file, Long scenicId) {
|
public ApiResponse faceUpload(MultipartFile file, Long scenicId) {
|
||||||
@ -191,6 +185,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
} else {
|
} else {
|
||||||
//2、更新人脸
|
//2、更新人脸
|
||||||
faceMapper.update(faceEntity);
|
faceMapper.update(faceEntity);
|
||||||
|
faceRepository.clearFaceCache(faceEntity.getId());
|
||||||
}
|
}
|
||||||
if (sampleListIds == null) {
|
if (sampleListIds == null) {
|
||||||
return ApiResponse.fail("请先游玩后再来获取视频吧");
|
return ApiResponse.fail("请先游玩后再来获取视频吧");
|
||||||
@ -215,11 +210,6 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
return memberSourceEntity;
|
return memberSourceEntity;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
sourceMapper.addRelations(memberSourceEntityList);
|
sourceMapper.addRelations(memberSourceEntityList);
|
||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
|
||||||
task.faceId = faceEntity.getId();
|
|
||||||
task.faceSampleIds = sampleListIds;
|
|
||||||
task.memberId = userId;
|
|
||||||
VideoPieceGetter.addTask(task);
|
|
||||||
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
|
taskTaskService.autoCreateTaskByFaceId(faceEntity.getId());
|
||||||
StatisticsRecordAddReq statisticsRecordAddReq = new StatisticsRecordAddReq();
|
StatisticsRecordAddReq statisticsRecordAddReq = new StatisticsRecordAddReq();
|
||||||
statisticsRecordAddReq.setMemberId(userId);
|
statisticsRecordAddReq.setMemberId(userId);
|
||||||
@ -230,6 +220,11 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
FaceRecognizeResp resp = new FaceRecognizeResp();
|
FaceRecognizeResp resp = new FaceRecognizeResp();
|
||||||
resp.setUrl(faceUrl);
|
resp.setUrl(faceUrl);
|
||||||
resp.setFaceId(faceEntity.getId());
|
resp.setFaceId(faceEntity.getId());
|
||||||
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
|
task.faceId = faceEntity.getId();
|
||||||
|
task.faceSampleIds = sampleListIds;
|
||||||
|
task.memberId = userId;
|
||||||
|
VideoPieceGetter.addTask(task);
|
||||||
return ApiResponse.success(resp);
|
return ApiResponse.success(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
@Override
|
@Override
|
||||||
public ApiResponse<Boolean> updateStatus(Long id) {
|
public ApiResponse<Boolean> updateStatus(Long id) {
|
||||||
int i = templateMapper.updateStatus(id);
|
int i = templateMapper.updateStatus(id);
|
||||||
|
templateRepository.clearTemplateCache(id);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
return ApiResponse.success(true);
|
return ApiResponse.success(true);
|
||||||
}else {
|
}else {
|
||||||
|
@ -20,7 +20,6 @@ public interface FaceService {
|
|||||||
ApiResponse<Integer> add(FaceEntity face);
|
ApiResponse<Integer> add(FaceEntity face);
|
||||||
ApiResponse<Integer> deleteById(Long id);
|
ApiResponse<Integer> deleteById(Long id);
|
||||||
ApiResponse<Integer> deleteByIds(List<Long> ids);
|
ApiResponse<Integer> deleteByIds(List<Long> ids);
|
||||||
ApiResponse<Integer> update(FaceEntity face);
|
|
||||||
|
|
||||||
ApiResponse faceUpload(MultipartFile file, Long scrnicId);
|
ApiResponse faceUpload(MultipartFile file, Long scrnicId);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
public interface TaskService {
|
public interface TaskService {
|
||||||
TaskSyncRespVo handleSyncTask(TaskReqVo req);
|
TaskSyncRespVo handleSyncTask(TaskReqVo req);
|
||||||
void createRenderTask(Long scenicId, Long templateId, Long faceId);
|
boolean createRenderTask(Long scenicId, Long templateId, Long faceId);
|
||||||
|
|
||||||
TemplateRespVO workerGetTemplate(Long templateId, WorkerAuthReqVo req);
|
TemplateRespVO workerGetTemplate(Long templateId, WorkerAuthReqVo req);
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
|||||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||||
import com.ycwl.basic.model.task.resp.AddFaceSampleRespVo;
|
import com.ycwl.basic.model.task.resp.AddFaceSampleRespVo;
|
||||||
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||||
|
import com.ycwl.basic.repository.FaceRepository;
|
||||||
import com.ycwl.basic.service.task.TaskFaceService;
|
import com.ycwl.basic.service.task.TaskFaceService;
|
||||||
import com.ycwl.basic.storage.StorageFactory;
|
import com.ycwl.basic.storage.StorageFactory;
|
||||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||||
@ -71,6 +72,8 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
private RedisTemplate<String, String> redisTemplate;
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FaceDetectLogMapper logMapper;
|
private FaceDetectLogMapper logMapper;
|
||||||
|
@Autowired
|
||||||
|
private FaceRepository faceRepository;
|
||||||
|
|
||||||
private IAcsClient getClient() {
|
private IAcsClient getClient() {
|
||||||
DefaultProfile profile = DefaultProfile.getProfile(
|
DefaultProfile profile = DefaultProfile.getProfile(
|
||||||
@ -91,6 +94,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
faceEntity.setScore(respVo.getScore());
|
faceEntity.setScore(respVo.getScore());
|
||||||
faceEntity.setMatchSampleIds(StringUtils.join(respVo.getSampleListIds(), ","));
|
faceEntity.setMatchSampleIds(StringUtils.join(respVo.getSampleListIds(), ","));
|
||||||
faceMapper.update(faceEntity);
|
faceMapper.update(faceEntity);
|
||||||
|
faceRepository.clearFaceCache(faceId);
|
||||||
}
|
}
|
||||||
return respVo;
|
return respVo;
|
||||||
}
|
}
|
||||||
@ -162,7 +166,9 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
AddFaceSampleRespVo respVo = addFaceSample(faceSampleRespVO.getScenicId().toString(), entityId, faceSampleRespVO.getFaceUrl(), faceSampleId.toString());
|
AddFaceSampleRespVo respVo = addFaceSample(faceSampleRespVO.getScenicId().toString(), entityId, faceSampleRespVO.getFaceUrl(), faceSampleId.toString());
|
||||||
FaceSampleEntity faceSampleEntity = new FaceSampleEntity();
|
FaceSampleEntity faceSampleEntity = new FaceSampleEntity();
|
||||||
faceSampleEntity.setId(faceSampleId);
|
faceSampleEntity.setId(faceSampleId);
|
||||||
faceSampleEntity.setScore(respVo.getScore());
|
if (respVo != null) {
|
||||||
|
faceSampleEntity.setScore(respVo.getScore());
|
||||||
|
}
|
||||||
faceSampleEntity.setUpdateAt(new Date());
|
faceSampleEntity.setUpdateAt(new Date());
|
||||||
faceSampleMapper.update(faceSampleEntity);
|
faceSampleMapper.update(faceSampleEntity);
|
||||||
addFaceSampleUrlCache(faceSampleId, faceSampleRespVO.getFaceUrl());
|
addFaceSampleUrlCache(faceSampleId, faceSampleRespVO.getFaceUrl());
|
||||||
@ -178,6 +184,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
try {
|
try {
|
||||||
client.getAcsResponse(request);
|
client.getAcsResponse(request);
|
||||||
} catch (ClientException e) {
|
} catch (ClientException e) {
|
||||||
|
log.error("addFaceEntity", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
AddFaceRequest addFaceRequest = new AddFaceRequest();
|
AddFaceRequest addFaceRequest = new AddFaceRequest();
|
||||||
@ -191,6 +198,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
respVo.setScore(acsResponse.getData().getQualitieScore());
|
respVo.setScore(acsResponse.getData().getQualitieScore());
|
||||||
return respVo;
|
return respVo;
|
||||||
} catch (ClientException e) {
|
} catch (ClientException e) {
|
||||||
|
log.error("addFaceEntity", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ import com.ycwl.basic.mapper.TaskMapper;
|
|||||||
import com.ycwl.basic.mapper.TemplateMapper;
|
import com.ycwl.basic.mapper.TemplateMapper;
|
||||||
import com.ycwl.basic.mapper.VideoMapper;
|
import com.ycwl.basic.mapper.VideoMapper;
|
||||||
import com.ycwl.basic.model.mobile.order.PriceObj;
|
import com.ycwl.basic.model.mobile.order.PriceObj;
|
||||||
|
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
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.entity.FaceSampleEntity;
|
||||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
|
||||||
import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
|
import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
|
||||||
import com.ycwl.basic.model.pc.mp.MpConfigEntity;
|
import com.ycwl.basic.model.pc.mp.MpConfigEntity;
|
||||||
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
|
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
|
||||||
@ -42,6 +42,7 @@ import com.ycwl.basic.notify.NotifyFactory;
|
|||||||
import com.ycwl.basic.notify.adapters.INotifyAdapter;
|
import com.ycwl.basic.notify.adapters.INotifyAdapter;
|
||||||
import com.ycwl.basic.notify.entity.NotifyContent;
|
import com.ycwl.basic.notify.entity.NotifyContent;
|
||||||
import com.ycwl.basic.notify.enums.NotifyType;
|
import com.ycwl.basic.notify.enums.NotifyType;
|
||||||
|
import com.ycwl.basic.repository.FaceRepository;
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||||
import com.ycwl.basic.service.task.TaskService;
|
import com.ycwl.basic.service.task.TaskService;
|
||||||
@ -100,6 +101,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
private ScenicRepository scenicRepository;
|
private ScenicRepository scenicRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateBiz templateBiz;
|
private TemplateBiz templateBiz;
|
||||||
|
@Autowired
|
||||||
|
private FaceRepository faceRepository;
|
||||||
|
|
||||||
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
|
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
|
||||||
String accessKey = req.getAccessKey();
|
String accessKey = req.getAccessKey();
|
||||||
@ -151,32 +154,18 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createRenderTask(Long scenicId, Long templateId, Long faceId) {
|
public boolean createRenderTask(Long scenicId, Long templateId, Long faceId) {
|
||||||
// 有人脸,找视频
|
|
||||||
if (faceId == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean canGenerate = templateBiz.determineTemplateCanGenerate(templateId, faceId);
|
boolean canGenerate = templateBiz.determineTemplateCanGenerate(templateId, faceId);
|
||||||
if (!canGenerate) {
|
if (!canGenerate) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
TemplateConfigEntity config = templateRepository.getTemplateConfig(templateId);
|
FaceEntity face = faceRepository.getFace(faceId);
|
||||||
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
if (face == null) {
|
||||||
if (faceRespVO == null) {
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Map<String, List<SourceRespVO>> sourcesMap = Arrays.stream(faceRespVO.getMatchSampleIds().split(","))
|
List<SourceEntity> sourceEntityList = sourceMapper.listVideoByScenicFaceRelation(scenicId, faceId);
|
||||||
.map(Long::valueOf)
|
Map<String, List<SourceEntity>> sourcesMap = sourceEntityList.stream()
|
||||||
.map(sampleId -> faceSampleMapper.getById(sampleId))
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(FaceSampleRespVO::getSourceId)
|
|
||||||
.map(sourceId -> sourceMapper.getById(sourceId))
|
|
||||||
.collect(Collectors.groupingBy(item -> item.getDeviceId().toString()));
|
.collect(Collectors.groupingBy(item -> item.getDeviceId().toString()));
|
||||||
if (config != null) {
|
|
||||||
if (config.getMinimalPlaceholderFill() > sourcesMap.size()) {
|
|
||||||
throw new RuntimeException("请先游玩后在来生成吧~");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TaskEntity taskEntity = new TaskEntity();
|
TaskEntity taskEntity = new TaskEntity();
|
||||||
taskEntity.setId(SnowFlakeUtil.getLongId());
|
taskEntity.setId(SnowFlakeUtil.getLongId());
|
||||||
taskEntity.setFaceId(faceId);
|
taskEntity.setFaceId(faceId);
|
||||||
@ -185,6 +174,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
taskEntity.setTaskParams(JSON.toJSONString(sourcesMap));
|
taskEntity.setTaskParams(JSON.toJSONString(sourcesMap));
|
||||||
taskEntity.setStatus(0);
|
taskEntity.setStatus(0);
|
||||||
taskMapper.add(taskEntity);
|
taskMapper.add(taskEntity);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -250,8 +240,11 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
@Override
|
@Override
|
||||||
public void createTaskByFaceIdAndTempalteId(Long faceId, Long templateId, int automatic) {
|
public void createTaskByFaceIdAndTempalteId(Long faceId, Long templateId, int automatic) {
|
||||||
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
||||||
|
if (faceRespVO == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(faceRespVO.getScenicId());
|
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(faceRespVO.getScenicId());
|
||||||
List<FaceSampleEntity> faceSampleList = faceSampleMapper.listByIds(Arrays.stream(faceRespVO.getMatchSampleIds().split(",")).map(Long::valueOf).collect(Collectors.toList()));
|
List<FaceSampleEntity> faceSampleList = faceRepository.getFaceSampleList(faceId);
|
||||||
if (faceSampleList.isEmpty()) {
|
if (faceSampleList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -296,13 +289,16 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||||
task.faceId = faceId;
|
task.faceId = faceId;
|
||||||
task.faceSampleIds = faceSampleIds;
|
task.faceSampleIds = faceSampleIds;
|
||||||
|
task.templateId = templateId;
|
||||||
task.memberId = faceRespVO.getMemberId();
|
task.memberId = faceRespVO.getMemberId();
|
||||||
task.callback = () -> {
|
task.callback = () -> {
|
||||||
|
log.info("task callback");
|
||||||
boolean canGenerate = templateBiz.determineTemplateCanGenerate(templateId, faceId);
|
boolean canGenerate = templateBiz.determineTemplateCanGenerate(templateId, faceId);
|
||||||
if (!canGenerate) {
|
if (!canGenerate) {
|
||||||
|
log.info("task callback: 不能生成");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<SourceEntity> videoSourceList = sourceMapper.listVideoByFaceRelation(faceId);
|
List<SourceEntity> videoSourceList = sourceMapper.listVideoByScenicFaceRelation(faceRespVO.getScenicId(), faceId);
|
||||||
Map<String, List<SourceEntity>> sourcesMap = videoSourceList.stream()
|
Map<String, List<SourceEntity>> sourcesMap = videoSourceList.stream()
|
||||||
.peek(item -> item.setUrl(item.getVideoUrl()))
|
.peek(item -> item.setUrl(item.getVideoUrl()))
|
||||||
.collect(Collectors.groupingBy(item -> item.getDeviceId().toString()));
|
.collect(Collectors.groupingBy(item -> item.getDeviceId().toString()));
|
||||||
@ -329,7 +325,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
taskEntity.setTaskParams(JSON.toJSONString(sourcesMap));
|
taskEntity.setTaskParams(JSON.toJSONString(sourcesMap));
|
||||||
taskMapper.add(taskEntity);
|
taskMapper.add(taskEntity);
|
||||||
memberVideoEntity.setTaskId(taskEntity.getId());
|
memberVideoEntity.setTaskId(taskEntity.getId());
|
||||||
} else{
|
} else {
|
||||||
memberVideoEntity.setTaskId(list.get(0).getId());
|
memberVideoEntity.setTaskId(list.get(0).getId());
|
||||||
VideoEntity video = videoMapper.findByTaskId(list.get(0).getId());
|
VideoEntity video = videoMapper.findByTaskId(list.get(0).getId());
|
||||||
if (video != null) {
|
if (video != null) {
|
||||||
@ -483,32 +479,24 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||||
String title = "您在【" + scenic.getName() + "】的影像";
|
String title = "您在【" + scenic.getName() + "】的专属影像";
|
||||||
String page = "pages/videoSynthesis/buy?scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId() + "&id=" + item.getVideoId();
|
String page = "pages/videoSynthesis/buy?scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId() + "&id=" + item.getVideoId();
|
||||||
/**
|
/**
|
||||||
* 景点 {{thing5.DATA}}
|
|
||||||
* 视频名称 {{thing1.DATA}}
|
* 视频名称 {{thing1.DATA}}
|
||||||
* 游玩时间 {{time2.DATA}}
|
|
||||||
* 生成时间 {{time4.DATA}}
|
* 生成时间 {{time4.DATA}}
|
||||||
* 备注 {{thing3.DATA}}
|
* 备注 {{thing3.DATA}}
|
||||||
*/
|
*/
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
Map<String, Object> dataParam = new HashMap<>();
|
Map<String, Object> dataParam = new HashMap<>();
|
||||||
Map<String, String> scenicMap = new HashMap<>();
|
|
||||||
scenicMap.put("value", scenic.getName());
|
|
||||||
dataParam.put("thing5", scenicMap);
|
|
||||||
Map<String, String> videoMap = new HashMap<>();
|
Map<String, String> videoMap = new HashMap<>();
|
||||||
TemplateRespVO template = templateRepository.getTemplate(item.getTemplateId());
|
TemplateRespVO template = templateRepository.getTemplate(item.getTemplateId());
|
||||||
videoMap.put("value", template.getName());
|
videoMap.put("value", template.getName());
|
||||||
dataParam.put("thing1", videoMap);
|
dataParam.put("thing1", videoMap);
|
||||||
Map<String, String> timeMap = new HashMap<>();
|
|
||||||
timeMap.put("value", DateUtil.format(getTaskShotDate(taskId), "yyyy-MM-dd"));
|
|
||||||
dataParam.put("time2", timeMap);
|
|
||||||
Map<String, String> timeMap2 = new HashMap<>();
|
Map<String, String> timeMap2 = new HashMap<>();
|
||||||
timeMap2.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
timeMap2.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
||||||
dataParam.put("time4", timeMap2);
|
dataParam.put("time4", timeMap2);
|
||||||
Map<String, String> remarkMap = new HashMap<>();
|
Map<String, String> remarkMap = new HashMap<>();
|
||||||
remarkMap.put("value", "您的游玩Vlog已经等候多时,快来看看吧");
|
remarkMap.put("value", "请及时查看视频,48小时后系统删除");
|
||||||
dataParam.put("thing3", remarkMap);
|
dataParam.put("thing3", remarkMap);
|
||||||
params.put("data", dataParam);
|
params.put("data", dataParam);
|
||||||
params.put("page", page);
|
params.put("page", page);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ycwl.basic.service.wvp.impl;
|
package com.ycwl.basic.service.wvp.impl;
|
||||||
|
|
||||||
import com.ycwl.basic.device.repository.DeviceRepository;
|
import com.ycwl.basic.repository.DeviceRepository;
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
import com.ycwl.basic.service.wvp.WvpService;
|
import com.ycwl.basic.service.wvp.WvpService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -42,12 +42,8 @@ public class DynamicTaskGenerator {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TaskFaceService faceService;
|
private TaskFaceService faceService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FaceSampleMapper faceSampleMapper;
|
|
||||||
@Autowired
|
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceMapper deviceMapper;
|
|
||||||
@Autowired
|
|
||||||
private TemplateBiz templateBiz;
|
private TemplateBiz templateBiz;
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 * * * ?")
|
@Scheduled(cron = "0 0 * * * ?")
|
||||||
|
@ -4,7 +4,8 @@ import com.ycwl.basic.biz.OrderBiz;
|
|||||||
import com.ycwl.basic.device.DeviceFactory;
|
import com.ycwl.basic.device.DeviceFactory;
|
||||||
import com.ycwl.basic.device.entity.common.FileObject;
|
import com.ycwl.basic.device.entity.common.FileObject;
|
||||||
import com.ycwl.basic.device.operator.IDeviceStorageOperator;
|
import com.ycwl.basic.device.operator.IDeviceStorageOperator;
|
||||||
import com.ycwl.basic.device.repository.DeviceRepository;
|
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
||||||
|
import com.ycwl.basic.repository.DeviceRepository;
|
||||||
import com.ycwl.basic.mapper.DeviceMapper;
|
import com.ycwl.basic.mapper.DeviceMapper;
|
||||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||||
import com.ycwl.basic.mapper.SourceMapper;
|
import com.ycwl.basic.mapper.SourceMapper;
|
||||||
@ -14,6 +15,7 @@ import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
|||||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||||
|
import com.ycwl.basic.repository.TemplateRepository;
|
||||||
import com.ycwl.basic.storage.StorageFactory;
|
import com.ycwl.basic.storage.StorageFactory;
|
||||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||||
@ -31,10 +33,13 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
@ -45,21 +50,21 @@ public class VideoPieceGetter {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FaceSampleMapper faceSampleMapper;
|
private FaceSampleMapper faceSampleMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceMapper deviceMapper;
|
|
||||||
@Autowired
|
|
||||||
private DeviceRepository deviceRepository;
|
private DeviceRepository deviceRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SourceMapper sourceMapper;
|
private SourceMapper sourceMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderBiz orderBiz;
|
private OrderBiz orderBiz;
|
||||||
|
@Autowired
|
||||||
|
private TemplateRepository templateRepository;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Task {
|
public static class Task {
|
||||||
public String type = "normal";
|
|
||||||
public List<Long> faceSampleIds;
|
public List<Long> faceSampleIds;
|
||||||
public Callback callback;
|
public Callback callback;
|
||||||
public Long memberId;
|
public Long memberId;
|
||||||
public Long faceId;
|
public Long faceId;
|
||||||
|
public Long templateId;
|
||||||
|
|
||||||
public static interface Callback {
|
public static interface Callback {
|
||||||
void onInvoke();
|
void onInvoke();
|
||||||
@ -86,112 +91,149 @@ public class VideoPieceGetter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("poll task: {}", task);
|
log.info("poll task: {}", task);
|
||||||
if (task.getType().equalsIgnoreCase("normal")) {
|
List<String> templatePlaceholder;
|
||||||
task.getFaceSampleIds().parallelStream().forEach(faceSampleId -> {
|
if (null != task.getTemplateId()) {
|
||||||
FaceSampleRespVO faceSample = faceSampleMapper.getById(faceSampleId);
|
templatePlaceholder = templateRepository.getTemplatePlaceholder(task.getTemplateId());
|
||||||
DeviceEntity device = deviceRepository.getDevice(faceSample.getDeviceId());
|
} else {
|
||||||
DeviceConfigEntity config = deviceRepository.getDeviceConfig(faceSample.getDeviceId());
|
templatePlaceholder = null;
|
||||||
|
|
||||||
SourceEntity source = sourceMapper.querySameVideo(faceSample.getId(), device.getId());
|
|
||||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), faceSample.getScenicId(), 1, faceSample.getId());
|
|
||||||
if (source != null) {
|
|
||||||
// 有原视频
|
|
||||||
int count = sourceMapper.hasRelationTo(task.getMemberId(), source.getId(), 1);
|
|
||||||
if (count > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MemberSourceEntity videoSource = new MemberSourceEntity();
|
|
||||||
videoSource.setId(SnowFlakeUtil.getLongId());
|
|
||||||
videoSource.setScenicId(faceSample.getScenicId());
|
|
||||||
videoSource.setFaceId(task.getFaceId());
|
|
||||||
videoSource.setMemberId(task.getMemberId());
|
|
||||||
videoSource.setType(1);
|
|
||||||
if (isBuy.isBuy()) { // 如果用户买过
|
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else if (isBuy.isFree()) { // 全免费逻辑
|
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else {
|
|
||||||
videoSource.setIsBuy(0);
|
|
||||||
}
|
|
||||||
videoSource.setSourceId(source.getId());
|
|
||||||
sourceMapper.addRelation(videoSource);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BigDecimal cutPre = BigDecimal.valueOf(5L);
|
|
||||||
BigDecimal cutPost = BigDecimal.valueOf(4L);
|
|
||||||
if (config == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 有配置
|
|
||||||
if (config.getCutPre() != null) {
|
|
||||||
cutPre = config.getCutPre();
|
|
||||||
}
|
|
||||||
if (config.getCutPost() != null) {
|
|
||||||
cutPost = config.getCutPost();
|
|
||||||
}
|
|
||||||
IDeviceStorageOperator pieceGetter = DeviceFactory.getDeviceStorageOperator(device, config);
|
|
||||||
if (pieceGetter == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BigDecimal duration = cutPre.add(cutPost);
|
|
||||||
List<FileObject> listByDtRange = pieceGetter.getFileListByDtRange(
|
|
||||||
new Date(faceSample.getCreateAt().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue()),
|
|
||||||
new Date(faceSample.getCreateAt().getTime() + cutPost.multiply(BigDecimal.valueOf(1000)).longValue())
|
|
||||||
);
|
|
||||||
if (listByDtRange.isEmpty()) {
|
|
||||||
log.warn("没有可用的文件");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
log.info("查询到可用的文件: {}", listByDtRange);
|
|
||||||
long offset = faceSample.getCreateAt().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue() - listByDtRange.get(0).getCreateTime().getTime();
|
|
||||||
FfmpegTask ffmpegTask = new FfmpegTask();
|
|
||||||
ffmpegTask.setFileList(listByDtRange);
|
|
||||||
ffmpegTask.setDuration(duration);
|
|
||||||
ffmpegTask.setOffsetStart(BigDecimal.valueOf(offset, 3));
|
|
||||||
File outFile = new File(faceSample.getDeviceId().toString() + "_" + faceSample.getId() + ".mp4");
|
|
||||||
ffmpegTask.setOutputFile(outFile.getAbsolutePath());
|
|
||||||
boolean result = startFfmpegTask(ffmpegTask);
|
|
||||||
if (!result) {
|
|
||||||
log.warn("视频裁切失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
log.info("视频裁切成功");
|
|
||||||
IStorageAdapter adapter = StorageFactory.use("assets");
|
|
||||||
String url = adapter.uploadFile(outFile, "video-source", outFile.getName());
|
|
||||||
// 上传成功后删除文件
|
|
||||||
outFile.delete();
|
|
||||||
SourceEntity imgSource = sourceMapper.findBySampleId(faceSample.getId());
|
|
||||||
SourceEntity sourceEntity = new SourceEntity();
|
|
||||||
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
|
||||||
sourceEntity.setCreateTime(faceSample.getCreateAt());
|
|
||||||
MemberSourceEntity videoSource = new MemberSourceEntity();
|
|
||||||
videoSource.setMemberId(task.getMemberId());
|
|
||||||
videoSource.setType(1);
|
|
||||||
videoSource.setFaceId(task.getFaceId());
|
|
||||||
videoSource.setScenicId(faceSample.getScenicId());
|
|
||||||
videoSource.setSourceId(sourceEntity.getId());
|
|
||||||
if (imgSource != null) {
|
|
||||||
sourceEntity.setUrl(imgSource.getUrl());
|
|
||||||
sourceEntity.setPosJson(imgSource.getPosJson());
|
|
||||||
}
|
|
||||||
sourceEntity.setVideoUrl(url);
|
|
||||||
sourceEntity.setFaceSampleId(faceSample.getId());
|
|
||||||
sourceEntity.setScenicId(faceSample.getScenicId());
|
|
||||||
sourceEntity.setDeviceId(faceSample.getDeviceId());
|
|
||||||
sourceEntity.setType(1);
|
|
||||||
if (isBuy.isBuy()) { // 如果用户买过
|
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else if (isBuy.isFree()) { // 全免费逻辑
|
|
||||||
videoSource.setIsBuy(1);
|
|
||||||
} else {
|
|
||||||
videoSource.setIsBuy(0);
|
|
||||||
}
|
|
||||||
sourceMapper.add(sourceEntity);
|
|
||||||
sourceMapper.addRelation(videoSource);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
AtomicBoolean invoke = new AtomicBoolean(false);
|
||||||
|
List<String> currentPlaceholder = new ArrayList<>();
|
||||||
|
List<FaceSampleEntity> list = faceSampleMapper.listByIds(task.getFaceSampleIds());
|
||||||
|
Collection<List<FaceSampleEntity>> collection = list.stream()
|
||||||
|
.filter(faceSample -> {
|
||||||
|
if (templatePlaceholder != null) {
|
||||||
|
return templatePlaceholder.contains(faceSample.getDeviceId().toString());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.collect(Collectors.groupingBy(FaceSampleEntity::getDeviceId))
|
||||||
|
.values();
|
||||||
|
collection
|
||||||
|
.stream()
|
||||||
|
.parallel()
|
||||||
|
.forEach(faceSampleList -> {
|
||||||
|
faceSampleList.forEach(faceSample -> {
|
||||||
|
DeviceEntity device = deviceRepository.getDevice(faceSample.getDeviceId());
|
||||||
|
DeviceConfigEntity config = deviceRepository.getDeviceConfig(faceSample.getDeviceId());
|
||||||
|
|
||||||
|
SourceEntity source = sourceMapper.querySameVideo(faceSample.getId(), device.getId());
|
||||||
|
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), faceSample.getScenicId(), 1, faceSample.getId());
|
||||||
|
if (source == null) {
|
||||||
|
BigDecimal cutPre = BigDecimal.valueOf(5L);
|
||||||
|
BigDecimal cutPost = BigDecimal.valueOf(4L);
|
||||||
|
if (config == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 有配置
|
||||||
|
if (config.getCutPre() != null) {
|
||||||
|
cutPre = config.getCutPre();
|
||||||
|
}
|
||||||
|
if (config.getCutPost() != null) {
|
||||||
|
cutPost = config.getCutPost();
|
||||||
|
}
|
||||||
|
IDeviceStorageOperator pieceGetter = DeviceFactory.getDeviceStorageOperator(device, config);
|
||||||
|
if (pieceGetter == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BigDecimal duration = cutPre.add(cutPost);
|
||||||
|
List<FileObject> listByDtRange = pieceGetter.getFileListByDtRange(
|
||||||
|
new Date(faceSample.getCreateAt().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue()),
|
||||||
|
new Date(faceSample.getCreateAt().getTime() + cutPost.multiply(BigDecimal.valueOf(1000)).longValue())
|
||||||
|
);
|
||||||
|
if (listByDtRange.isEmpty()) {
|
||||||
|
log.warn("没有可用的文件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("查询到可用的文件: {}", listByDtRange);
|
||||||
|
long offset = faceSample.getCreateAt().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue() - listByDtRange.get(0).getCreateTime().getTime();
|
||||||
|
FfmpegTask ffmpegTask = new FfmpegTask();
|
||||||
|
ffmpegTask.setFileList(listByDtRange);
|
||||||
|
ffmpegTask.setDuration(duration);
|
||||||
|
ffmpegTask.setOffsetStart(BigDecimal.valueOf(offset, 3));
|
||||||
|
File outFile = new File(faceSample.getDeviceId().toString() + "_" + faceSample.getId() + ".mp4");
|
||||||
|
ffmpegTask.setOutputFile(outFile.getAbsolutePath());
|
||||||
|
boolean result = startFfmpegTask(ffmpegTask);
|
||||||
|
if (!result) {
|
||||||
|
log.warn("视频裁切失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("视频裁切成功");
|
||||||
|
IStorageAdapter adapter = StorageFactory.use("assets");
|
||||||
|
String url = adapter.uploadFile(outFile, "video-source", outFile.getName());
|
||||||
|
// 上传成功后删除文件
|
||||||
|
outFile.delete();
|
||||||
|
SourceEntity imgSource = sourceMapper.findBySampleId(faceSample.getId());
|
||||||
|
SourceEntity sourceEntity = new SourceEntity();
|
||||||
|
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
||||||
|
sourceEntity.setCreateTime(faceSample.getCreateAt());
|
||||||
|
MemberSourceEntity videoSource = new MemberSourceEntity();
|
||||||
|
videoSource.setMemberId(task.getMemberId());
|
||||||
|
videoSource.setType(1);
|
||||||
|
videoSource.setFaceId(task.getFaceId());
|
||||||
|
videoSource.setScenicId(faceSample.getScenicId());
|
||||||
|
videoSource.setSourceId(sourceEntity.getId());
|
||||||
|
if (imgSource != null) {
|
||||||
|
sourceEntity.setUrl(imgSource.getUrl());
|
||||||
|
sourceEntity.setPosJson(imgSource.getPosJson());
|
||||||
|
}
|
||||||
|
sourceEntity.setVideoUrl(url);
|
||||||
|
sourceEntity.setFaceSampleId(faceSample.getId());
|
||||||
|
sourceEntity.setScenicId(faceSample.getScenicId());
|
||||||
|
sourceEntity.setDeviceId(faceSample.getDeviceId());
|
||||||
|
sourceEntity.setType(1);
|
||||||
|
if (isBuy.isBuy()) { // 如果用户买过
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else if (isBuy.isFree()) { // 全免费逻辑
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else {
|
||||||
|
videoSource.setIsBuy(0);
|
||||||
|
}
|
||||||
|
sourceMapper.add(sourceEntity);
|
||||||
|
sourceMapper.addRelation(videoSource);
|
||||||
|
} else {
|
||||||
|
// 有原视频
|
||||||
|
int count = sourceMapper.hasRelationTo(task.getMemberId(), source.getId(), 1);
|
||||||
|
if (count <= 0) {
|
||||||
|
// 没有关联
|
||||||
|
MemberSourceEntity videoSource = new MemberSourceEntity();
|
||||||
|
videoSource.setId(SnowFlakeUtil.getLongId());
|
||||||
|
videoSource.setScenicId(faceSample.getScenicId());
|
||||||
|
videoSource.setFaceId(task.getFaceId());
|
||||||
|
videoSource.setMemberId(task.getMemberId());
|
||||||
|
videoSource.setType(1);
|
||||||
|
if (isBuy.isBuy()) { // 如果用户买过
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else if (isBuy.isFree()) { // 全免费逻辑
|
||||||
|
videoSource.setIsBuy(1);
|
||||||
|
} else {
|
||||||
|
videoSource.setIsBuy(0);
|
||||||
|
}
|
||||||
|
videoSource.setSourceId(source.getId());
|
||||||
|
sourceMapper.addRelation(videoSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (templatePlaceholder != null) {
|
||||||
|
if (templatePlaceholder.contains(faceSample.getDeviceId().toString())) {
|
||||||
|
if (!currentPlaceholder.contains(faceSample.getDeviceId().toString())) {
|
||||||
|
currentPlaceholder.add(faceSample.getDeviceId().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("当前进度:{}/{}", currentPlaceholder.size(), collection.size());
|
||||||
|
if (currentPlaceholder.size() >= collection.size()) {
|
||||||
|
if (!invoke.get()) {
|
||||||
|
invoke.set(true);
|
||||||
|
task.getCallback().onInvoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
if (null != task.getCallback()) {
|
if (null != task.getCallback()) {
|
||||||
task.getCallback().onInvoke();
|
if (!invoke.get()) {
|
||||||
|
invoke.set(true);
|
||||||
|
task.getCallback().onInvoke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@
|
|||||||
select *
|
select *
|
||||||
from device_config
|
from device_config
|
||||||
where device_id = #{deviceId}
|
where device_id = #{deviceId}
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
<select id="getByDeviceId" resultType="com.ycwl.basic.model.pc.device.entity.DeviceEntity">
|
<select id="getByDeviceId" resultType="com.ycwl.basic.model.pc.device.entity.DeviceEntity">
|
||||||
select *
|
select *
|
||||||
|
@ -94,5 +94,6 @@
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
)
|
)
|
||||||
|
order by create_at desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
<select id="listByMpId" resultType="com.ycwl.basic.model.pc.mp.MpNotifyConfigEntity">
|
<select id="listByMpId" resultType="com.ycwl.basic.model.pc.mp.MpNotifyConfigEntity">
|
||||||
select *
|
select *
|
||||||
from mp_notify_config
|
from mp_notify_config
|
||||||
where mp_id = #{mpId}
|
where mp_id = #{mpId} and status = 1
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -163,4 +163,11 @@
|
|||||||
where ms.face_id = #{faceId} and ms.type = 1
|
where ms.face_id = #{faceId} and ms.type = 1
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listVideoByScenicFaceRelation" resultType="com.ycwl.basic.model.pc.source.entity.SourceEntity">
|
||||||
|
select s.*
|
||||||
|
from member_source ms
|
||||||
|
left join source s on ms.source_id = s.id
|
||||||
|
where ms.face_id = #{faceId} and ms.type = 1 and ms.scenic_id = #{scenicId}
|
||||||
|
order by create_time desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
</delete>
|
</delete>
|
||||||
<select id="list" resultType="com.ycwl.basic.model.pc.task.resp.TaskRespVO">
|
<select id="list" resultType="com.ycwl.basic.model.pc.task.resp.TaskRespVO">
|
||||||
select id, worker_id, face_id, member_id, template_id, scenic_id, task_params, video_url, `status`, result, create_time, update_time, start_time, end_time
|
select id, worker_id, face_id, member_id, template_id, scenic_id, task_params, video_url, `status`, result, create_time, update_time, start_time, end_time
|
||||||
from task
|
from task
|
||||||
<where>
|
<where>
|
||||||
<if test="workerId!= null">and worker_id = #{workerId} </if>
|
<if test="workerId!= null">and worker_id = #{workerId} </if>
|
||||||
<if test="memberId!= null">and member_id = #{memberId} </if>
|
<if test="memberId!= null">and member_id = #{memberId} </if>
|
||||||
|
@ -110,4 +110,9 @@
|
|||||||
from template t
|
from template t
|
||||||
where t.scenic_id = #{scenicId} and t.pid = 0 and t.status = 1
|
where t.scenic_id = #{scenicId} and t.pid = 0 and t.status = 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="get" resultType="com.ycwl.basic.model.pc.template.entity.TemplateEntity">
|
||||||
|
select *
|
||||||
|
from template
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user