Compare commits

...

16 Commits

Author SHA1 Message Date
8a17392ae5 Jenkinsfile
Some checks are pending
Gitea/FrameTour-BE/pipeline/head Build queued...
2025-06-30 17:51:34 +08:00
529b52f19c 出现问题清除缓存 2025-06-30 15:26:27 +08:00
7a21fb01d0 添加筛选条件 2025-06-30 11:10:43 +08:00
f40837cd05 menu 2025-06-28 14:41:13 +08:00
66334b8963 1 2025-06-28 13:47:35 +08:00
206696deb8 支持用户切换景区账号,单账号多景区权限 2025-06-28 13:44:44 +08:00
e8488d081f 仅在正式服上运行 2025-06-20 16:50:55 +08:00
245387f280 后台景区端趋势图 2025-06-20 16:47:23 +08:00
6d8261ff25 自动任务稍微等一等 2025-06-17 18:04:43 +08:00
7d6c87cc74 VirtualThread 2025-06-17 17:39:53 +08:00
5f8c4fd6e6 订单查询 2025-06-17 17:09:03 +08:00
53a09c1cab 修复bug 2025-06-17 16:05:24 +08:00
b0c8643e92 调整一下切片逻辑 2025-06-17 16:05:24 +08:00
fae62ab7c2 各种sql、缓存优化 2025-06-17 16:05:23 +08:00
5895d9c56f OTEL 2025-06-17 16:05:23 +08:00
207fcb6414 测试 2025-06-13 16:55:33 +08:00
56 changed files with 767 additions and 275 deletions

20
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,20 @@
pipeline {
agent any
environment {
JAVA_HOME = "/opt/openjdk21.0.7"
MAVEN_HOME = "/opt/apache-maven-3.9.9"
PATH = "${env.JAVA_HOME}/bin:${env.MAVEN_HOME}/bin:${env.PATH}"
}
stages {
stage('Build') {
steps {
bat 'mvn clean package -DskipTests=true'
}
}
}
post {
always {
archiveArtifacts artifacts: 'target/*.jar', allowEmptyArchive: false
}
}
}

22
pom.xml
View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<version>3.3.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ycwl</groupId>
@@ -27,7 +27,18 @@
<!--跳过单元测试-->
<skipTests>true</skipTests>
</properties>
<!-- OpenTelemetry -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-bom</artifactId>
<version>2.16.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- 添加 jakarta.servlet-api 依赖 -->
@@ -89,7 +100,7 @@
<!--mybatis plus和springboot整合-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.5</version>
</dependency>
@@ -198,6 +209,11 @@
<artifactId>java-sdk</artifactId>
<version>4.16.19</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -53,6 +53,10 @@ public class BrokerBiz {
expireDay = scenicConfig.getSampleStoreDay();
}
List<Long> brokerIdList = statisticsMapper.getBrokerIdListForUser(order.getMemberId(), DateUtil.offsetDay(DateUtil.beginOfDay(order.getCreateAt()), -expireDay), order.getCreateAt());
if (brokerIdList == null || brokerIdList.isEmpty()) {
log.info("用户与推客无关,订单ID:{}", orderId);
return;
}
Long directBrokerId = brokerIdList.getFirst();
List<BrokerRespVO> brokerInfoList = brokerIdList.stream().map(brokerId -> {
BrokerRespVO broker = brokerMapper.getById(brokerId);

View File

@@ -0,0 +1,13 @@
package com.ycwl.basic.constant;
public enum JwtRoleConstant {
MERCHANT("merchant"),
ADMIN("admin"),
APP_USER("app_user");
public final String type;
JwtRoleConstant(String type) {
this.type = type;
}
}

View File

@@ -1,25 +1,36 @@
package com.ycwl.basic.controller.mobile.manage;
import com.ycwl.basic.annotation.IgnoreToken;
import com.ycwl.basic.constant.BaseContextHandler;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginReq;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginRespVO;
import com.ycwl.basic.model.mobile.weChat.DTO.WeChatUserInfoDTO;
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
import com.ycwl.basic.service.mobile.AppScenicService;
import com.ycwl.basic.service.pc.ScenicAccountService;
import com.ycwl.basic.service.pc.ScenicService;
import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static com.ycwl.basic.constant.JwtRoleConstant.MERCHANT;
/**
* @Author:longbinbin
* @Date:2024/12/12 18:28
@@ -28,9 +39,12 @@ import java.util.List;
@RequestMapping("/api/mobile/scenicAccount/v1")
@Api(tags = "景区账号相关接口")
public class AppScenicAccountController {
@Autowired
private ScenicAccountService accountService;
@Autowired
private AppScenicService scenicService;
@Autowired
private ScenicService adminScenicService;
@ApiOperation("登录")
@PostMapping("/login")
@@ -39,13 +53,68 @@ public class AppScenicAccountController {
return scenicService.login(scenicLoginReq);
}
@GetMapping("/myScenicList")
public ApiResponse<List<ScenicRespVO>> myScenicList() {
List<ScenicRespVO> list = Collections.emptyList();
if (StringUtils.equals(BaseContextHandler.getRoleId(), MERCHANT.type)) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = accountService.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
list = account.getScenicId().stream().map(id -> {
return scenicService.getDetails(id).getData();
}).toList();
} else {
list = adminScenicService.list(new ScenicReqQuery()).getData();
}
return ApiResponse.success(list);
}
@GetMapping("/getScenic")
public ApiResponse<ScenicRespVO> getMyScenic() {
return scenicService.getMyScenic();
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = accountService.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
return scenicService.getDetails(account.getScenicId().getFirst());
}
@GetMapping("/{scenicId}")
public ApiResponse<ScenicRespVO> getScenic(@PathVariable Long scenicId) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = accountService.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
if (!account.getScenicId().contains(scenicId)) {
return ApiResponse.fail("无权限");
}
return scenicService.getDetails(scenicId);
}
@GetMapping("/devices")
public ApiResponse<List<DeviceRespVO>> getDeviceList() {
return scenicService.getMyDevices();
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = accountService.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
return scenicService.getDevices(account.getScenicId().getFirst());
}
@GetMapping("/{scenicId}/devices")
public ApiResponse<List<DeviceRespVO>> getDeviceList(@PathVariable Long scenicId) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = accountService.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
if (!account.getScenicId().contains(scenicId)) {
return ApiResponse.fail("无权限");
}
return scenicService.getDevices(scenicId);
}
}

View File

@@ -7,9 +7,11 @@ import com.ycwl.basic.model.pc.order.req.OrderReqQuery;
import com.ycwl.basic.model.pc.order.resp.OrderRespVO;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import com.ycwl.basic.service.pc.OrderService;
import com.ycwl.basic.service.pc.ScenicAccountService;
import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,27 +26,57 @@ public class AppScenicOrderController {
@Autowired
private OrderService orderService;
@Autowired
private ScenicAccountMapper scenicAccountMapper;
private ScenicAccountService service;
@PostMapping("/list")
@Deprecated
public ApiResponse<List<OrderRespVO>> list(@RequestBody OrderReqQuery query) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = scenicAccountMapper.findAccountById(userId);
if (account == null) {
return ApiResponse.fail("用户未绑定景区");
ScenicAccountEntity account = service.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
query.setScenicId(account.getScenicId());
query.setScenicId(account.getScenicId().getFirst());
return orderService.list(query);
}
@PostMapping("/{scenicId}/list")
public ApiResponse<List<OrderRespVO>> list(@PathVariable Long scenicId, @RequestBody OrderReqQuery query) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = service.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
if (!account.getScenicId().contains(scenicId)) {
return ApiResponse.fail("无权限查看该景区订单");
}
query.setScenicId(scenicId);
return orderService.list(query);
}
@PostMapping("/page")
@Deprecated
public ApiResponse<PageInfo<OrderRespVO>> page(@RequestBody OrderReqQuery query) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = scenicAccountMapper.findAccountById(userId);
if (account == null) {
return ApiResponse.fail("用户未绑定景区");
ScenicAccountEntity account = service.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
query.setScenicId(account.getScenicId());
query.setScenicId(account.getScenicId().getFirst());
return orderService.pageQueryDetail(query);
}
@PostMapping("/{scenicId}/page")
public ApiResponse<PageInfo<OrderRespVO>> page(@PathVariable Long scenicId, @RequestBody OrderReqQuery query) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = service.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
if (!account.getScenicId().contains(scenicId)) {
return ApiResponse.fail("无权限查看该景区订单");
}
query.setScenicId(scenicId);
return orderService.pageQueryDetail(query);
}
}

View File

@@ -40,28 +40,5 @@ public class FaceSampleController {
public ApiResponse<FaceSampleRespVO> getDetail(@PathVariable("id") Long id) {
return FaceSampleService.getById(id);
}
@ApiOperation("添加人脸样本")
@PostMapping("/add")
public ApiResponse<Integer> add(@RequestBody FaceSampleEntity FaceSample) {
return FaceSampleService.add(FaceSample);
}
@ApiOperation("删除人脸样本")
@PostMapping("/deleteById/{id}")
public ApiResponse<Integer> deleteById(@PathVariable Long id) {
return FaceSampleService.deleteById(id);
}
@ApiOperation("批量删除人脸样本")
@PostMapping("/deleteByIds")
public ApiResponse<Integer> deleteByIds(@RequestBody List<Long> ids) {
return FaceSampleService.deleteByIds(ids);
}
@ApiOperation("修改人脸样本信息")
@PostMapping("/update")
public ApiResponse<Integer> update(@RequestBody FaceSampleEntity FaceSample) {
return FaceSampleService.update(FaceSample);
}
}

View File

@@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import static com.ycwl.basic.constant.JwtRoleConstant.MERCHANT;
@RestController
@RequestMapping("/api/permission/v1")
@Api(tags = "权限管理接口")
@@ -32,9 +34,9 @@ public class PermissionController {
String userId = BaseContextHandler.getUserId();
PermissionEntity permission = permissionService.getPermissionByUserId(Long.parseLong(userId));
if (permission == null || StringUtils.isEmpty(permission.getPermString())) {
return ApiResponse.success(new PermissionResp(new ArrayList<>()));
return ApiResponse.success(new PermissionResp(new ArrayList<>(), new ArrayList<>()));
}
return ApiResponse.success(new PermissionResp(Arrays.asList(StringUtils.split(permission.getPermString(), ","))));
return ApiResponse.success(new PermissionResp(Arrays.asList(StringUtils.split(permission.getPermString(), ",")), Arrays.asList(StringUtils.split(permission.getMenuString(), ","))));
}
@ApiOperation("根据用户ID查询权限信息")
@@ -42,15 +44,15 @@ public class PermissionController {
public ApiResponse<PermissionResp> getPermissionByUser(@PathVariable Long userId) {
PermissionEntity permission = permissionService.getPermissionByUserId(userId);
if (permission == null || StringUtils.isEmpty(permission.getPermString())) {
return ApiResponse.success(new PermissionResp(new ArrayList<>()));
return ApiResponse.success(new PermissionResp(new ArrayList<>(), new ArrayList<>()));
}
return ApiResponse.success(new PermissionResp(Arrays.asList(StringUtils.split(permission.getPermString(), ","))));
return ApiResponse.success(new PermissionResp(Arrays.asList(StringUtils.split(permission.getPermString(), ",")), Arrays.asList(StringUtils.split(permission.getMenuString(), ","))));
}
@ApiOperation("保存或更新权限信息")
@PostMapping("/save/{userId}")
public ApiResponse saveOrUpdate(@PathVariable Long userId, @RequestBody PermissionSaveReq req) {
permissionService.saveOrUpdate(userId, StringUtils.join(req.getPermissions(), ","));
permissionService.saveOrUpdate(userId, StringUtils.join(req.getPermissions(), ","), StringUtils.join(req.getMenus(), ","));
return ApiResponse.success(true);
}
}

View File

@@ -2,6 +2,7 @@ package com.ycwl.basic.controller.pc;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.mapper.ScenicAccountMapper;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
import com.ycwl.basic.service.pc.ScenicAccountService;
@@ -16,6 +17,8 @@ import java.util.List;
public class ScenicAccountController {
@Autowired
private ScenicAccountService service;
@Autowired
private ScenicAccountMapper scenicAccountMapper;
// 添加景区账号
@PostMapping("/add")
@@ -62,6 +65,10 @@ public class ScenicAccountController {
public ApiResponse<PageInfo<ScenicAccountEntity>> pageQuery(@RequestBody ScenicAccountReqQuery req) {
PageHelper.startPage(req.getPageNum(), req.getPageSize());
List<ScenicAccountEntity> list = service.pageQuery(req);
list.forEach(entity -> {
entity.setPassword("");
entity.setScenicId(scenicAccountMapper.getAccountRelations(entity.getId()));
});
PageInfo<ScenicAccountEntity> pageInfo = new PageInfo<>(list);
return ApiResponse.success(pageInfo);
}

View File

@@ -1,12 +1,16 @@
package com.ycwl.basic.controller.pc;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.constant.BaseContextHandler;
import com.ycwl.basic.model.mobile.statistic.req.CommonQueryReq;
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.req.ScenicAddOrUpdateReq;
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
import com.ycwl.basic.service.mobile.AppScenicService;
import com.ycwl.basic.service.mobile.AppStatisticsService;
import com.ycwl.basic.service.pc.ScenicAccountService;
import com.ycwl.basic.service.pc.ScenicService;
import com.ycwl.basic.storage.StorageFactory;
import com.ycwl.basic.storage.adapters.IStorageAdapter;
@@ -17,12 +21,16 @@ import com.ycwl.basic.repository.ScenicRepository;
import com.ycwl.basic.model.pc.mp.MpConfigEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.util.Collections;
import java.util.List;
import static com.ycwl.basic.constant.JwtRoleConstant.MERCHANT;
/**
* @Author:longbinbin
* @Date:2024/12/3 15:20
@@ -34,11 +42,15 @@ public class ScenicController {
@Autowired
private ScenicService scenicService;
@Autowired
private AppScenicService appScenicService;
@Autowired
private ScenicRepository scenicRepository;
@Autowired
private AppStatisticsService appStatisticsService;
@Autowired
private ScenicAccountService accountService;
@ApiOperation("分页查询景区")
@PostMapping("/page")
@@ -150,4 +162,27 @@ public class ScenicController {
query.setScenicId(scenicId);
return appStatisticsService.userConversionFunnel(query);
}
@PostMapping("/{scenicId}/orderChart")
public ApiResponse getOrderChart(@PathVariable("scenicId") Long scenicId, @RequestBody CommonQueryReq query) {
query.setScenicId(scenicId);
return appStatisticsService.orderChart(query);
}
@GetMapping("/myScenicList")
public ApiResponse<List<ScenicRespVO>> myScenicList() {
List<ScenicRespVO> list = Collections.emptyList();
if (StringUtils.equals(BaseContextHandler.getRoleId(), MERCHANT.type)) {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = accountService.getScenicAccountById(Long.valueOf(userId));
if (account == null || account.getScenicId().isEmpty()) {
return ApiResponse.fail("景区账号未绑定景区");
}
list = account.getScenicId().stream().map(id -> {
return appScenicService.getDetails(id).getData();
}).toList();
} else {
list = scenicService.list(new ScenicReqQuery()).getData();
}
return ApiResponse.success(list);
}
}

View File

@@ -315,7 +315,7 @@ public class ViidController {
AddFaceResp addFaceResp = faceBodyAdapter.addFace(scenicId.toString(), faceSample.getId().toString(), url, newFaceSampleId.toString());
if (addFaceResp != null) {
faceSample.setScore(addFaceResp.getScore());
faceSampleMapper.update(faceSample);
faceSampleMapper.updateScore(faceSample.getId(), addFaceResp.getScore());
}
}
if (deviceConfig != null && Integer.valueOf(1).equals(deviceConfig.getEnablePreBook())) {
@@ -377,7 +377,7 @@ public class ViidController {
AddFaceResp addFaceResp = faceBodyAdapter.addFace(scenicId.toString(), faceSample.getId().toString(), url, newFaceSampleId.toString());
if (addFaceResp != null) {
faceSample.setScore(addFaceResp.getScore());
faceSampleMapper.update(faceSample);
faceSampleMapper.updateScore(faceSample.getId(), addFaceResp.getScore());
}
}
if (Integer.valueOf(1).equals(deviceConfig.getEnablePreBook())) {

View File

@@ -27,4 +27,6 @@ public interface FaceSampleMapper {
FaceSampleEntity getEntity(Long faceSampleId);
List<FaceSampleEntity> listEntityBeforeDate(Long scenicId, Date endDate);
void updateScore(Long id, Float score);
}

View File

@@ -19,4 +19,11 @@ public interface ScenicAccountMapper {
ScenicAccountEntity findAccountById(String id);
List<ScenicAccountEntity> pageQuery(ScenicAccountReqQuery req);
int addAccountScenicRelation(Long accountId, Long scenicId, int isAdmin);
int deleteRelationByScenicId(Long scenicId);
List<Long> getAccountRelations(Long accountId);
int deleteRelationById(Long accountId);
}

View File

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
/**
@@ -97,4 +98,8 @@ public interface StatisticsMapper {
List<AppStatisticsFunnelVO> listStatByScenic(Long scenicId, Date startTime, Date endTime);
int insertStat(Long scenicId, Date date, AppStatisticsFunnelVO data);
List<HashMap<String, String>> orderChartByDate(CommonQueryReq query);
List<HashMap<String, String>> orderChartByHour(CommonQueryReq query);
}

View File

@@ -44,11 +44,6 @@ public class JwtInfo implements Serializable {
private String phone;
/**
* 景区id
*/
private Long scenicId;
/**
* 生成 token 的时间

View File

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @Author:longbinbin
* @Date:2024/12/13 9:44
@@ -13,7 +15,7 @@ import lombok.Data;
public class ScenicLoginRespVO {
private Long id;
@ApiModelProperty("景区id")
private Long scenicId;
private List<Long> scenicId;
@ApiModelProperty("是否是超级管理员")
private Integer isSuper;
@ApiModelProperty("账号名称")

View File

@@ -33,16 +33,6 @@ public class OrderReqQuery extends BaseQueryParameterReq {
*/
@ApiModelProperty("微信openId")
private Long openId;
/**
* 价格
*/
@ApiModelProperty("价格")
private BigDecimal price;
/**
* 实际支付价格
*/
@ApiModelProperty("实际支付价格")
private BigDecimal payPrice;
/**
* 备注
*/

View File

@@ -20,10 +20,12 @@ public class PermissionEntity implements Serializable {
private Integer id;
@TableField("user_id")
private Long userId; // 确保字段映射
private Long userId;
@TableField("perm_str")
private String permString;
@TableField("menu_str")
private String menuString;
@TableField("create_time")
private Date createTime;

View File

@@ -7,4 +7,5 @@ import java.util.List;
@Data
public class PermissionSaveReq {
private List<String> permissions;
private List<String> menus;
}

View File

@@ -9,4 +9,5 @@ import java.util.List;
@AllArgsConstructor
public class PermissionResp {
private List<String> permissions;
private List<String> menus;
}

View File

@@ -7,4 +7,5 @@ public class PriceConfigListReq {
private Long scenicId;
private Integer type;
private Long goodsId;
private Integer status;
}

View File

@@ -4,12 +4,13 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
@TableName("scenic_account")
public class ScenicAccountEntity {
private Long id;
private Long scenicId;
private List<Long> scenicId;
private Integer isSuper;
private String name;
private String phone;

View File

@@ -3,6 +3,7 @@ package com.ycwl.basic.model.task.req;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
@@ -15,4 +16,5 @@ public class ClientStatusReqVo {
private BigDecimal memory_total;
private BigDecimal memory_available;
private List<String> support_feature;
private Date updateAt;
}

View File

@@ -0,0 +1,75 @@
package com.ycwl.basic.repository;
import com.alibaba.fastjson.JSONObject;
import com.ycwl.basic.mapper.RenderWorkerMapper;
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
import com.ycwl.basic.model.task.req.ClientStatusReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@Component
public class RenderWorkerRepository {
@Autowired
private RedisTemplate<String, String> redisTemplate;
public static final String RENDER_WORKER_CACHE_KEY = "render_worker:%s";
public static final String RENDER_WORKER_STATUS_CACHE_KEY = "render_worker:host_status:%s";
@Autowired
private RenderWorkerMapper mapper;
public RenderWorkerEntity getWorkerByAccessKey(String accessKey) {
String key = String.format(RENDER_WORKER_CACHE_KEY, accessKey);
if (redisTemplate.hasKey(key)) {
return JSONObject.parseObject(redisTemplate.opsForValue().get(key), RenderWorkerEntity.class);
}
RenderWorkerEntity renderWorker = mapper.findByAccessKey(accessKey);
if (renderWorker != null) {
redisTemplate.opsForValue().set(key, JSONObject.toJSONString(renderWorker), 1, TimeUnit.HOURS);
redisTemplate.opsForValue().set(String.format(RENDER_WORKER_CACHE_KEY, renderWorker.getId()), JSONObject.toJSONString(renderWorker), 1, TimeUnit.HOURS);
}
return renderWorker;
}
public RenderWorkerEntity getWorker(Long id) {
String key = String.format(RENDER_WORKER_CACHE_KEY, id);
if (redisTemplate.hasKey(key)) {
return JSONObject.parseObject(redisTemplate.opsForValue().get(key), RenderWorkerEntity.class);
}
RenderWorkerEntity renderWorker = mapper.getById(id);
if (renderWorker != null) {
redisTemplate.opsForValue().set(key, JSONObject.toJSONString(renderWorker), 1, TimeUnit.HOURS);
redisTemplate.opsForValue().set(String.format(RENDER_WORKER_CACHE_KEY, renderWorker.getAccessKey()), JSONObject.toJSONString(renderWorker), 1, TimeUnit.HOURS);
}
return renderWorker;
}
public void setWorkerHostStatus(Long id, ClientStatusReqVo status) {
String key = String.format(RENDER_WORKER_STATUS_CACHE_KEY, id);
if (status == null) {
return;
}
status.setUpdateAt(new Date());
redisTemplate.opsForValue().set(key, JSONObject.toJSONString(status), 1, TimeUnit.HOURS);
}
public ClientStatusReqVo getWorkerHostStatus(Long id) {
String key = String.format(RENDER_WORKER_STATUS_CACHE_KEY, id);
if (redisTemplate.hasKey(key)) {
String status = redisTemplate.opsForValue().get(key);
return JSONObject.parseObject(status, ClientStatusReqVo.class);
}
return null;
}
public void clearCache(Long id) {
RenderWorkerEntity worker = getWorker(id);
redisTemplate.delete(String.format(RENDER_WORKER_CACHE_KEY, id));
if (worker != null) {
redisTemplate.delete(String.format(RENDER_WORKER_CACHE_KEY, worker.getAccessKey()));
}
redisTemplate.delete(String.format(RENDER_WORKER_STATUS_CACHE_KEY, id));
}
}

View File

@@ -26,9 +26,7 @@ public interface AppScenicService {
ApiResponse<ScenicLoginRespVO> login(ScenicLoginReq scenicLoginReq) throws Exception;
ApiResponse<ScenicRespVO> getMyScenic();
ApiResponse<List<DeviceRespVO>> getMyDevices();
List<ScenicAppVO> scenicListByLnLa(ScenicIndexVO scenicIndexVO);
ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId);
}

View File

@@ -23,4 +23,6 @@ public interface AppStatisticsService {
ApiResponse<AppStatisticsFunnelVO> userConversionFunnel(CommonQueryReq query);
ApiResponse<String> addStatistics(StatisticsRecordAddReq req);
ApiResponse orderChart(CommonQueryReq query);
}

View File

@@ -2,7 +2,6 @@ package com.ycwl.basic.service.mobile.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ycwl.basic.constant.BaseContextHandler;
import com.ycwl.basic.constant.NumberConstant;
import com.ycwl.basic.enums.BizCodeEnum;
@@ -13,7 +12,6 @@ import com.ycwl.basic.model.jwt.JwtInfo;
import com.ycwl.basic.model.mobile.weChat.DTO.WeChatUserInfoDTO;
import com.ycwl.basic.model.mobile.weChat.DTO.WeChatUserInfoUpdateDTO;
import com.ycwl.basic.model.pc.member.entity.MemberEntity;
import com.ycwl.basic.model.pc.member.req.MemberReqQuery;
import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
import com.ycwl.basic.model.pc.mp.MpConfigEntity;
import com.ycwl.basic.repository.ScenicRepository;
@@ -88,13 +86,9 @@ public class AppMemberServiceImpl implements AppMemberService {
throw new AppException(BizCodeEnum.SERVER_UNKONWN_ERROR, "未获取到当前用户openId");
}
MemberRespVO memberRespVO = new MemberRespVO();
JwtInfo jwtInfo = new JwtInfo();
// 根据返回的openId,判断用户是否是新用户,是的话,将用户信息存到数据库;
MemberReqQuery memberReqQuery = new MemberReqQuery();
memberReqQuery.setOpenId(openId.toString());
List<MemberRespVO> list = memberMapper.list(memberReqQuery);
if (list.isEmpty()) {
MemberRespVO memberRespVO = memberMapper.getByOpenId(openId.toString());
if (memberRespVO == null) {
MemberEntity memberEntity = new MemberEntity();
memberEntity.setId(SnowFlakeUtil.getLongId());
memberEntity.setScenicId(scenicId);
@@ -107,6 +101,7 @@ public class AppMemberServiceImpl implements AppMemberService {
memberEntity.setProvince(userInfoDTO.getProvince());
memberEntity.setCity(userInfoDTO.getCity());
memberMapper.add(memberEntity);
memberRespVO = new MemberRespVO();
memberRespVO.setId(memberEntity.getId());
memberRespVO.setOpenId(memberEntity.getOpenId());
memberRespVO.setNickname(memberEntity.getNickname());
@@ -117,18 +112,6 @@ public class AppMemberServiceImpl implements AppMemberService {
memberRespVO.setProvince(memberEntity.getProvince());
memberRespVO.setCity(memberEntity.getCity());
memberRespVO.setScenicId(memberEntity.getScenicId());
} else {
MemberRespVO temp = list.getFirst();
memberRespVO.setId(temp.getId());
memberRespVO.setOpenId(temp.getOpenId());
memberRespVO.setNickname(temp.getNickname());
memberRespVO.setAvatarUrl(temp.getAvatarUrl());
memberRespVO.setAgreement(1);
memberRespVO.setPhone(temp.getPhone());
memberRespVO.setCountry(temp.getCountry());
memberRespVO.setProvince(temp.getProvince());
memberRespVO.setCity(temp.getCity());
memberRespVO.setScenicId(temp.getScenicId());
}
jwtInfo.setUserId(memberRespVO.getId());
jwtInfo.setName(memberRespVO.getNickname());

View File

@@ -16,6 +16,7 @@ import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
import com.ycwl.basic.service.mobile.AppScenicService;
import com.ycwl.basic.service.pc.ScenicAccountService;
import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.JwtTokenUtil;
import lombok.extern.slf4j.Slf4j;
@@ -25,6 +26,8 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import static com.ycwl.basic.constant.JwtRoleConstant.MERCHANT;
/**
* @Author:longbinbin
* @Date:2024/12/6 10:23
@@ -41,6 +44,8 @@ public class AppScenicServiceImpl implements AppScenicService {
private ScenicAccountMapper scenicAccountMapper;
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Autowired
private ScenicAccountService scenicAccountService;
@Override
public ApiResponse<PageInfo<ScenicAppVO>> pageQuery(ScenicReqQuery scenicReqQuery) {
@@ -67,8 +72,7 @@ public class AppScenicServiceImpl implements AppScenicService {
@Override
public ApiResponse<ScenicLoginRespVO> login(ScenicLoginReq scenicLoginReq) throws Exception {
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicLoginReq.getAccount());
ScenicAccountEntity scenicAccount = scenicAccountService.getScenicAccountByAccount(scenicLoginReq.getAccount());
if (scenicAccount == null) {
return ApiResponse.fail("账号不存在");
}
@@ -83,7 +87,7 @@ public class AppScenicServiceImpl implements AppScenicService {
jwtInfo.setName(scenicAccount.getName());
jwtInfo.setAccount(scenicAccount.getAccount());
jwtInfo.setUserId(scenicAccount.getId());
jwtInfo.setScenicId(scenicAccount.getScenicId());
jwtInfo.setRoleId(MERCHANT.type);
String token = jwtTokenUtil.generateToken(jwtInfo);
ScenicLoginRespVO scenicLoginRespVO = new ScenicLoginRespVO();
@@ -92,30 +96,15 @@ public class AppScenicServiceImpl implements AppScenicService {
return ApiResponse.success(scenicLoginRespVO);
}
@Override
public ApiResponse<ScenicRespVO> getMyScenic() {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = scenicAccountMapper.findAccountById(userId);
if (account == null) {
return ApiResponse.fail("用户未绑定景区");
}
return getDetails(account.getScenicId());
}
@Override
public ApiResponse<List<DeviceRespVO>> getMyDevices() {
String userId = BaseContextHandler.getUserId();
ScenicAccountEntity account = scenicAccountMapper.findAccountById(userId);
if (account == null) {
return ApiResponse.fail("用户未绑定景区");
}
List<DeviceRespVO> deviceRespVOList = deviceMapper.listByScenicIdWithWVP(account.getScenicId());
return ApiResponse.success(deviceRespVOList);
}
@Override
public List<ScenicAppVO> scenicListByLnLa(ScenicIndexVO scenicIndexVO) {
List<ScenicAppVO> scenicAppVOS = scenicMapper.scenicListByLnLa(scenicIndexVO);
return scenicAppVOS.stream().filter(scenic -> scenic.getDistance().compareTo(scenic.getRadius().multiply(BigDecimal.valueOf(1_000L))) < 0).toList();
}
@Override
public ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId) {
List<DeviceRespVO> deviceRespVOList = deviceMapper.listByScenicIdWithWVP(scenicId);
return ApiResponse.success(deviceRespVOList);
}
}

View File

@@ -1,6 +1,7 @@
package com.ycwl.basic.service.mobile.impl;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@@ -25,6 +26,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -313,6 +315,27 @@ public class AppStatisticsServiceImpl implements AppStatisticsService {
}
}
@Override
public ApiResponse orderChart(CommonQueryReq query) {
if(query.getEndTime()==null && query.getStartTime()==null){
// 没有传时间,则代表用户没有自定义查询时间,使用standard来判断查询时间范围
Integer standard = query.getStandard();
if(standard==null){
query.setStandard(0);
}
//获取当前周期的具体时间范围
standardToNewSpecificTime(query);
}
if (DateUtil.between(query.getStartTime(), query.getEndTime(), DateUnit.DAY) <= 2) {
// 如果是同一天
List<HashMap<String, String>> hashMaps = statisticsMapper.orderChartByHour(query);
return ApiResponse.success(hashMaps);
} else {
List<HashMap<String, String>> hashMaps = statisticsMapper.orderChartByDate(query);
return ApiResponse.success(hashMaps);
}
}
/**
*
* @param num1

View File

@@ -444,6 +444,7 @@ public class GoodsServiceImpl implements GoodsService {
if (taskById == null) {
response.setStatus(1);
} else {
videoTaskRepository.clearTaskCache(lastVideo.getTaskId());
if (taskById.getStatus() == 1) {
response.setStatus(1);
response.setVideoId(lastVideo.getVideoId());

View File

@@ -96,7 +96,7 @@ public class WxPayServiceImpl implements WxPayService {
log.info("[微信支付]parse = {}", callbackResponse);
// 更新订单信息
new Thread(() -> {
Thread.ofVirtual().start(() -> {
long orderId = Long.parseLong(callbackResponse.getOrderNo());
if (callbackResponse.isPay()) {
orderBiz.paidOrder(orderId);
@@ -105,7 +105,7 @@ public class WxPayServiceImpl implements WxPayService {
} else if (callbackResponse.isRefund()) {
orderBiz.refundOrder(orderId);
}
}).start();
});
} catch (Exception e) {
throw new AppException(BizCodeEnum.ADVANCE_PAYMENT_CALLBACK_FAILED, e.toString());
}

View File

@@ -20,8 +20,5 @@ public interface FaceSampleService {
ApiResponse<List<FaceSampleRespVO>> list(FaceSampleReqQuery faceSampleReqQuery);
ApiResponse<FaceSampleRespVO> getById(Long id);
ApiResponse<Integer> add(FaceSampleEntity face);
ApiResponse<Integer> deleteById(Long id);
ApiResponse<Integer> deleteByIds(List<Long> ids);
ApiResponse<Integer> update(FaceSampleEntity face);
}

View File

@@ -6,5 +6,5 @@ public interface PermissionService {
// 新增权限查询接口
PermissionEntity getPermissionByUserId(Long userId);
boolean saveOrUpdate(Long userId, String permStr);
boolean saveOrUpdate(Long userId, String permStr, String menuStr);
}

View File

@@ -16,4 +16,6 @@ public interface ScenicAccountService {
List<ScenicAccountEntity> pageQuery(ScenicAccountReqQuery req);
int updateStatus(Long id);
ScenicAccountEntity getScenicAccountByAccount(String account);
}

View File

@@ -130,7 +130,7 @@ public class AdminUserServiceImpl implements AdminUserService {
}
}
LoginRespVO loginRespVO = new LoginRespVO();
String token = jwtTokenUtil.generateToken(new JwtInfo(login.getStaffName(), login.getStaffId(), roleId, login.getAccount(), login.getAccount(), null,null));
String token = jwtTokenUtil.generateToken(new JwtInfo(login.getStaffName(), login.getStaffId(), roleId, login.getAccount(), login.getAccount(), null));
loginRespVO.setToken(token);
loginRespVO.setName(login.getStaffName());
loginRespVO.setTypeName(login.getTypeName());

View File

@@ -50,31 +50,4 @@ public class FaceSampleServiceImpl implements FaceSampleService {
}
return ApiResponse.success(i);
}
@Override
public ApiResponse<Integer> deleteById(Long id) {
int i = faceSampleMapper.deleteById(id);
if (i == 0) {
return ApiResponse.fail("删除失败");
}
return ApiResponse.success(i);
}
@Override
public ApiResponse<Integer> deleteByIds(List<Long> ids) {
int i = faceSampleMapper.deleteByIds(ids);
if (i == 0) {
return ApiResponse.fail("删除失败");
}
return ApiResponse.success(i);
}
@Override
public ApiResponse<Integer> update(FaceSampleEntity faceSample) {
int i = faceSampleMapper.update(faceSample);
if (i == 0) {
return ApiResponse.fail("修改失败");
}
return ApiResponse.success(i);
}
}

View File

@@ -314,12 +314,12 @@ public class FaceServiceImpl implements FaceService {
FaceEntity face = faceRepository.getFace(faceId);
faceMapper.deleteById(faceId);
faceRepository.clearFaceCache(faceId);
new Thread(() -> {
Thread.ofVirtual().start(() -> {
sourceMapper.deleteNotBuyFaceRelation(face.getMemberId(), faceId);
videoMapper.deleteNotBuyFaceRelations(face.getMemberId(), faceId);
IFaceBodyAdapter adapter = scenicService.getScenicFaceBodyAdapter(face.getScenicId());
adapter.deleteFace(USER_FACE_DB_NAME+face.getScenicId().toString(), faceId.toString());
}).start();
});
return ApiResponse.success("删除成功");
}

View File

@@ -17,10 +17,11 @@ public class PermissionServiceImpl implements PermissionService {
}
@Override
public boolean saveOrUpdate(Long userId, String permStr) {
public boolean saveOrUpdate(Long userId, String permStr, String menuStr) {
PermissionEntity entity = new PermissionEntity();
entity.setUserId(userId);
entity.setPermString(permStr);
entity.setMenuString(menuStr);
if (permissionMapper.selectByUserId(userId) == null) {
permissionMapper.insertPermission(entity);
} else {

View File

@@ -5,6 +5,8 @@ import com.github.pagehelper.PageInfo;
import com.ycwl.basic.mapper.RenderWorkerMapper;
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
import com.ycwl.basic.model.task.req.ClientStatusReqVo;
import com.ycwl.basic.repository.RenderWorkerRepository;
import com.ycwl.basic.service.pc.RenderWorkerService;
import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.SnowFlakeUtil;
@@ -12,6 +14,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
@@ -23,23 +27,76 @@ public class RenderWorkerServiceImpl implements RenderWorkerService {
@Autowired
private RenderWorkerMapper renderWorkerMapper;
@Autowired
private RenderWorkerRepository renderWorkerRepository;
@Override
public ApiResponse<PageInfo<RenderWorkerEntity>> pageQuery(RenderWorkerReqQuery renderWorkerReqQuery) {
PageHelper.startPage(renderWorkerReqQuery.getPageNum(), renderWorkerReqQuery.getPageSize());
List<RenderWorkerEntity> list = renderWorkerMapper.list(renderWorkerReqQuery);
list.forEach(worker -> {
ClientStatusReqVo clientStatus = renderWorkerRepository.getWorkerHostStatus(worker.getId());
if (clientStatus == null) {
return;
}
worker.setCpuCount(clientStatus.getCpu_count());
worker.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
worker.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setPlatform(clientStatus.getPlatform());
worker.setRuntimeVersion(clientStatus.getRuntime_version());
worker.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
worker.setVersion(clientStatus.getVersion());
worker.setUpdateAt(clientStatus.getUpdateAt());
});
PageInfo<RenderWorkerEntity> pageInfo = new PageInfo<>(list);
return ApiResponse.success(pageInfo);
}
@Override
public ApiResponse<List<RenderWorkerEntity>> list(RenderWorkerReqQuery renderWorkerReqQuery) {
return ApiResponse.success(renderWorkerMapper.list(renderWorkerReqQuery));
List<RenderWorkerEntity> list = renderWorkerMapper.list(renderWorkerReqQuery);
list.forEach(worker -> {
ClientStatusReqVo clientStatus = renderWorkerRepository.getWorkerHostStatus(worker.getId());
if (clientStatus == null) {
return;
}
worker.setCpuCount(clientStatus.getCpu_count());
worker.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
worker.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setPlatform(clientStatus.getPlatform());
worker.setRuntimeVersion(clientStatus.getRuntime_version());
worker.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
worker.setVersion(clientStatus.getVersion());
worker.setUpdateAt(clientStatus.getUpdateAt());
});
return ApiResponse.success(list);
}
@Override
public ApiResponse<RenderWorkerEntity> detail(Long id) {
return ApiResponse.success(renderWorkerMapper.getById(id));
RenderWorkerEntity worker = renderWorkerMapper.getById(id);
ClientStatusReqVo clientStatus = renderWorkerRepository.getWorkerHostStatus(worker.getId());
if (clientStatus != null) {
worker.setCpuCount(clientStatus.getCpu_count());
worker.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
worker.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setPlatform(clientStatus.getPlatform());
worker.setRuntimeVersion(clientStatus.getRuntime_version());
worker.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
worker.setVersion(clientStatus.getVersion());
worker.setUpdateAt(clientStatus.getUpdateAt());
}
return ApiResponse.success(worker);
}
@Override
@@ -59,11 +116,13 @@ public class RenderWorkerServiceImpl implements RenderWorkerService {
@Override
public ApiResponse<Integer> deleteById(Long id) {
renderWorkerRepository.clearCache(id);
return ApiResponse.success(renderWorkerMapper.deleteById(id));
}
@Override
public ApiResponse<Integer> update(RenderWorkerEntity renderWorker) {
renderWorkerRepository.clearCache(renderWorker.getId());
int update = renderWorkerMapper.update(renderWorker);
if (update == 0) {
return ApiResponse.fail("渲染机修改失败");
@@ -74,6 +133,7 @@ public class RenderWorkerServiceImpl implements RenderWorkerService {
@Override
public ApiResponse<Integer> updateStatus(Long id) {
renderWorkerRepository.clearCache(id);
return ApiResponse.success(renderWorkerMapper.updateStatus(id));
}
}

View File

@@ -1,5 +1,6 @@
package com.ycwl.basic.service.pc.impl;
import com.ycwl.basic.exception.BaseException;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
import com.ycwl.basic.service.pc.ScenicAccountService;
@@ -30,12 +31,23 @@ public class ScenicAccountServiceImpl implements ScenicAccountService {
@Override
public int updateScenicAccount(ScenicAccountEntity entity) {
return mapper.update(entity);
if (entity.getId() == null) {
throw new BaseException("参数错误");
}
int update = mapper.update(entity);
mapper.deleteRelationById(entity.getId());
entity.getScenicId().forEach(scenicId -> {
mapper.addAccountScenicRelation(entity.getId(), scenicId, entity.getIsSuper());
});
return update;
}
@Override
public ScenicAccountEntity getScenicAccountById(Long id) {
return mapper.findAccountById(String.valueOf(id));
ScenicAccountEntity account = mapper.findAccountById(String.valueOf(id));
List<Long> scenicList = mapper.getAccountRelations(id);
account.setScenicId(scenicList);
return account;
}
@Override
@@ -53,4 +65,12 @@ public class ScenicAccountServiceImpl implements ScenicAccountService {
public int updateStatus(Long id) {
return mapper.updateStatus(id);
}
@Override
public ScenicAccountEntity getScenicAccountByAccount(String account) {
ScenicAccountEntity accountEntity = mapper.getByAccount(account);
List<Long> scenicList = mapper.getAccountRelations(accountEntity.getId());
accountEntity.setScenicId(scenicList);
return accountEntity;
}
}

View File

@@ -71,21 +71,20 @@ public class ScenicServiceImpl implements ScenicService {
@Override
@Transactional(rollbackFor = Exception.class)
public ApiResponse<Boolean> add(ScenicAddOrUpdateReq scenicAddReq) {
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicAddReq.getAccount());
if (scenicAccount != null) {
return ApiResponse.fail("账号已存在");
}
Long scenicId = SnowFlakeUtil.getLongId();
scenicAddReq.setId(scenicId);
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);
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicAddReq.getAccount());
if (scenicAccount == null) {
scenicAccount = new ScenicAccountEntity();
scenicAccount.setId(SnowFlakeUtil.getLongId());
scenicAccount.setName(scenicAddReq.getName() + "管理员");
scenicAccount.setAccount(scenicAddReq.getAccount());
scenicAccount.setPassword(scenicAddReq.getPassword());
scenicAccount.setIsSuper(1);
scenicAccountMapper.add(scenicAccount);
}
scenicAccountMapper.addAccountScenicRelation(scenicAccount.getId(), scenicId, 1);
if (add > 0) {
return ApiResponse.success(true);
} else {
@@ -98,12 +97,12 @@ public class ScenicServiceImpl implements ScenicService {
public ApiResponse<Boolean> deleteById(Long id) {
int i = scenicMapper.deleteById(id);
if (i > 0) {
scenicAccountMapper.deleteByScenicId(id);
scenicAccountMapper.deleteRelationByScenicId(id);
IFaceBodyAdapter adapter = getScenicFaceBodyAdapter(id);
(new Thread(() -> {
Thread.ofVirtual().start(() -> {
adapter.deleteFaceDb(id.toString());
adapter.deleteFaceDb(USER_FACE_DB_NAME + id);
})).start();
});
scenicMapper.deleteConfigByScenicId(id);
scenicRepository.clearCache(id);
scenicFaceBodyAdapterMap.remove(id);
@@ -117,6 +116,9 @@ public class ScenicServiceImpl implements ScenicService {
@Override
public ApiResponse<Boolean> update(ScenicAddOrUpdateReq scenicUpdateReq) {
if (scenicUpdateReq.getId() == null) {
return ApiResponse.fail("参数错误");
}
if (StringUtils.isNotBlank(scenicUpdateReq.getAccount()) && StringUtils.isNotBlank(scenicUpdateReq.getPassword())) {
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicUpdateReq.getAccount());
if (scenicAccount != null) {
@@ -132,13 +134,13 @@ public class ScenicServiceImpl implements ScenicService {
} 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);
}
scenicAccountMapper.addAccountScenicRelation(account.getId(), scenicUpdateReq.getId(), 1);
}
int i = scenicMapper.update(scenicUpdateReq);
if (i > 0) {

View File

@@ -45,6 +45,7 @@ import com.ycwl.basic.notify.entity.NotifyContent;
import com.ycwl.basic.notify.enums.NotifyType;
import com.ycwl.basic.repository.DeviceRepository;
import com.ycwl.basic.repository.FaceRepository;
import com.ycwl.basic.repository.RenderWorkerRepository;
import com.ycwl.basic.repository.ScenicRepository;
import com.ycwl.basic.repository.VideoRepository;
import com.ycwl.basic.repository.VideoTaskRepository;
@@ -81,14 +82,10 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public class TaskTaskServiceImpl implements TaskService {
@Autowired
private TemplateMapper templateMapper;
@Autowired
private RenderWorkerMapper renderWorkerMapper;
@Autowired
private TaskMapper taskMapper;
@Autowired
private RedisTemplate<String, String> redisTemplate;
private RenderWorkerRepository repository;
@Autowired
private FaceMapper faceMapper;
@Autowired
@@ -124,13 +121,12 @@ public class TaskTaskServiceImpl implements TaskService {
@Autowired
private VideoReUploader videoReUploader;
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
String accessKey = req.getAccessKey();
if (accessKey == null) {
return null;
}
return renderWorkerMapper.findByAccessKey(accessKey);
return repository.getWorkerByAccessKey(accessKey);
}
@Override
@@ -144,23 +140,7 @@ public class TaskTaskServiceImpl implements TaskService {
worker.setStatus(null);
// get status
ClientStatusReqVo clientStatus = req.getClientStatus();
if (clientStatus != null) {
// 临时这么用下
worker.setCpuCount(clientStatus.getCpu_count());
worker.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
worker.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setPlatform(clientStatus.getPlatform());
worker.setRuntimeVersion(clientStatus.getRuntime_version());
worker.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
worker.setVersion(clientStatus.getVersion());
worker.setUpdateAt(new Date());
redisTemplate.opsForValue().set(TaskConstant.TASK_ONLINE_WORKER_KEY_PFX + worker.getId(), JSON.toJSONString(clientStatus), 60, TimeUnit.SECONDS);
}
renderWorkerMapper.update(worker);
repository.setWorkerHostStatus(worker.getId(), clientStatus);
TaskSyncRespVo resp = new TaskSyncRespVo();
// Template
List<TemplateRespVO> updTemplateList;
@@ -630,7 +610,7 @@ public class TaskTaskServiceImpl implements TaskService {
}
}
videoMapper.updateRelationWhenTaskSuccess(taskId, video.getId(), isBuy);
new Thread(() -> sendVideoGeneratedServiceNotification(taskId)).start();
Thread.ofVirtual().start(() -> sendVideoGeneratedServiceNotification(taskId));
}
@Override

View File

@@ -12,6 +12,7 @@ import com.ycwl.basic.model.pc.scenicDeviceStats.entity.ScenicDeviceStatsEntity;
import com.ycwl.basic.service.mobile.AppStatisticsService;
import com.ycwl.basic.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -21,6 +22,7 @@ import java.util.List;
@Component
@EnableScheduling
@Profile("prod")
public class ScenicStatsTask {
@Autowired
private ScenicDeviceStatsMapper mapper;

View File

@@ -103,13 +103,13 @@ public class VideoPieceGetter {
return;
}
log.info("poll task: {}/{}", task, queue.size());
new Thread(() -> {
Thread.ofVirtual().start(() -> {
try {
runTask(task);
} catch (Exception e) {
log.error("run task error", e);
}
}).start();
});
}
private void runTask(Task task) {
@@ -181,26 +181,22 @@ public class VideoPieceGetter {
.map(Map.Entry::getKey).forEach(pairDeviceId -> {
log.info("找到同景区关联设备:{} -> {}", pairDeviceId, faceSample.getDeviceId());
if (pairDeviceId != null) {
executor.execute(() -> {
doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
});
doCut(pairDeviceId, faceSample.getId(), faceSample.getCreateAt(), task);
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
}
});
}
executor.execute(() -> {
doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
if (templatePlaceholder != null) {
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), templatePlaceholder.size());
if (currentUnFinPlaceholder.isEmpty()) {
if (!invoke.get()) {
invoke.set(true);
task.getCallback().onInvoke();
}
doCut(faceSample.getDeviceId(), faceSample.getId(), faceSample.getCreateAt(), task);
currentUnFinPlaceholder.remove(faceSample.getDeviceId().toString());
if (templatePlaceholder != null) {
log.info("当前进度:!{}/{}", currentUnFinPlaceholder.size(), templatePlaceholder.size());
if (currentUnFinPlaceholder.isEmpty()) {
if (!invoke.get()) {
invoke.set(true);
task.getCallback().onInvoke();
}
}
});
}
});
});
});
@@ -210,6 +206,7 @@ public class VideoPieceGetter {
executor.shutdown();
executor.awaitTermination(5, TimeUnit.MINUTES);
log.info("executor已结束![A:{}/T:{}/F:{}]", executor.getActiveCount(), executor.getTaskCount(), executor.getCompletedTaskCount());
executor.close();
} catch (InterruptedException e) {
return;
} finally {

View File

@@ -108,6 +108,11 @@ public class VideoTaskGenerator {
log.info("task callback: 不自动生成");
}
}
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
});

View File

@@ -6,11 +6,13 @@ import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.apache.commons.lang3.StringUtils;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Map;
import java.util.Objects;
/**
* @author yangchen
@@ -46,19 +48,7 @@ public class JwtAnalysisUtil {
* @throws Exception
*/
public static JwtInfo getInfoFromToken(String token, byte[] pubKey) throws Exception {
Claims body = (Claims) RsaKeyUtil.parserToken(token, pubKey).getBody();
for (Map.Entry<String, Object> stringObjectEntry : body.entrySet()) {
Map.Entry<String, Object> entry = stringObjectEntry;
if (!"sub".equals(entry.getKey())
&& !"userId".equals(entry.getKey())
&& !"phone".equals(entry.getKey())
&& !"roleId".equals(entry.getKey())
&& !"account".equals(entry.getKey())
&& !"name".equals(entry.getKey())
&& !"roleName".equals(entry.getKey())
&& !"scenicId".equals(entry.getKey())
&& !"expire".equals(entry.getKey())) ;
}
Claims body = RsaKeyUtil.parserToken(token, pubKey).getBody();
// convert
LocalDateTime expireTime = null;
@@ -73,15 +63,13 @@ public class JwtAnalysisUtil {
}
Long userId = null;
if (body.get("userId")!=null) {
String strUserId = StringUtil.a(body.get("userId"));
userId= Long.parseLong(strUserId);
userId= Long.parseLong(Objects.requireNonNullElse(body.get("userId"), "").toString());
}
return new JwtInfo(StringUtil.a(body.get("name")),
return new JwtInfo(Objects.requireNonNullElse(body.get("name"), "").toString(),
userId,
StringUtil.a(body.get("roleId")),
Objects.requireNonNullElse(body.get("roleId"), "").toString(),
body.getSubject(),
StringUtil.a(body.get("phone")),
body.get("scenicId") == null ? null : Long.valueOf(body.get("scenicId").toString()),
Objects.requireNonNullElse(body.get("phone"), "").toString(),
expireTime);
}
}

View File

@@ -1,11 +0,0 @@
package com.ycwl.basic.utils;
public final class StringUtil {
public StringUtil() {
}
public static String a(Object obj) {
return obj == null ? "" : obj.toString();
}
}

View File

@@ -31,6 +31,9 @@ spring:
multipart:
max-file-size: 500MB
max-request-size: 500MB
threads:
virtual:
enabled: true
web:
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
@@ -160,4 +163,11 @@ notify:
- name: "developer"
type: "SERVER_CHAN"
config:
key: "sctp747ta-wkq4hlzb6e42t8d1sm8wbc9g"
key: "sctp747ta-wkq4hlzb6e42t8d1sm8wbc9g"
otel:
traces:
exporter: none
metrics:
exporter: none
logs:
exporter: none

View File

@@ -35,6 +35,9 @@ spring:
multipart:
max-file-size: 500MB
max-request-size: 500MB
threads:
virtual:
enabled: true
web:
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
@@ -166,4 +169,32 @@ notify:
- name: "developer"
type: "SERVER_CHAN"
config:
key: "sctp747ta-wkq4hlzb6e42t8d1sm8wbc9g"
key: "sctp747ta-wkq4hlzb6e42t8d1sm8wbc9g"
otel:
service:
name: ZT-BE
instrumentation:
annotations:
enabled: true
jdbc:
enabled: true
logback-mdc:
enabled: true
spring-web:
enabled: true
spring-webmvc:
enabled: true
spring-scheduling:
enabled: false
resource:
attributes:
environment: "production"
service: "ZT-BE"
exporter:
otlp:
endpoint: "https://oltp.jerryyan.top"
metrics:
exporter: none
logs:
exporter: none

View File

@@ -36,6 +36,11 @@
</set>
where id = #{id}
</update>
<update id="updateScore">
update face_sample
set score = #{score}
where id = #{id}
</update>
<delete id="deleteById">
delete from face_sample where id = #{id}
</delete>

View File

@@ -244,7 +244,7 @@
left join scenic s on o.scenic_id = s.id
<where>
<if test="id!= null ">
and o.id = #{id}
and o.id LIKE CONCAT('%',#{id},'%')
</if>
<if test="scenicId != null">
and o.scenic_id = #{scenicId}
@@ -253,26 +253,17 @@
and m.nickname like concat('%',#{memberNickname},'%')
</if>
<if test="memberId != null">
and o.member_id like concat('%',#{memberId},'%')
and (o.member_id like concat('%',#{memberId},'%') or m.uid like concat('%',#{memberId},'%'))
</if>
<if test="memberUid!= null">
and m.uid = #{memberUid}
</if>
<if test="price!= null ">
and o.price = #{price}
</if>
<if test="payPrice!= null ">
and pay_price = #{payPrice}
</if>
<if test="remark!= null and remark!= ''">
and remark like concat('%',#{remark},'%')
</if>
<if test="brokerId!= null ">
and o.broker_id = #{brokerId}
</if>
<if test="promoCode!= null and promoCode!= ''">
and o.promo_code like concat('%',#{promoCode},'%')
</if>
<if test="refundReason!= null and refundReason!= ''">
and refund_reason like concat('%',#{refundReason},'%')
</if>
@@ -338,12 +329,6 @@
<if test="memberUid!= null">
and m.uid = #{memberUid}
</if>
<if test="price!= null ">
and o.price = #{price}
</if>
<if test="payPrice!= null ">
and pay_price = #{payPrice}
</if>
<if test="remark!= null and remark!= ''">
and remark like concat('%',#{remark},'%')
</if>
@@ -450,12 +435,6 @@
<if test="memberUid!= null">
and m.uid = #{memberUid}
</if>
<if test="price!= null ">
and o.price = #{price}
</if>
<if test="payPrice!= null ">
and pay_price = #{payPrice}
</if>
<if test="remark!= null and remark!= ''">
and remark like concat('%',#{remark},'%')
</if>

View File

@@ -3,19 +3,19 @@
<mapper namespace="com.ycwl.basic.mapper.PermissionMapper">
<!-- 新增插入语句 -->
<insert id="insertPermission">
INSERT INTO permission (user_id, perm_str, create_time, update_time)
VALUES (#{userId}, #{permString}, NOW(), NOW())
INSERT INTO account_permission (user_id, perm_str, menu_str, create_time, update_time)
VALUES (#{userId}, #{permString}, #{menuString}, NOW(), NOW())
</insert>
<!-- 新增更新语句 -->
<update id="updatePermission">
UPDATE permission
SET perm_str = #{permString}, update_time = NOW()
UPDATE account_permission
SET perm_str = #{permString}, menu_str = #{menuString}, update_time = NOW()
WHERE user_id = #{userId}
</update>
<select id="selectByUserId" resultType="com.ycwl.basic.model.pc.permission.entity.PermissionEntity">
SELECT id, user_id, perm_str as permString, create_time, update_time
FROM permission
SELECT id, user_id, perm_str as permString, menu_str as menuString, create_time, update_time
FROM account_permission
WHERE user_id = #{userId}
limit 1
</select>

View File

@@ -52,6 +52,9 @@
<if test="req.goodsId != null">
and p.goods_ids like concat('%', #{req.goodsId}, '%')
</if>
<if test="req.status != null">
and p.status = #{req.status}
</if>
</where>
</select>
<select id="getPriceByScenicTypeGoods" resultType="com.ycwl.basic.model.pc.price.entity.PriceConfigEntity">

View File

@@ -5,6 +5,10 @@
insert into scenic_account(id, scenic_id, is_super, name, phone, account, password, create_time, update_time)
values (#{id}, #{scenicId}, #{isSuper}, #{name}, #{phone}, #{account}, #{password}, now(), now())
</insert>
<insert id="addAccountScenicRelation">
insert into account_scenic(account_id, scenic_id, is_admin)
values (#{accountId}, #{scenicId}, #{isAdmin})
</insert>
<update id="update">
update scenic_account
<set>
@@ -41,11 +45,17 @@
<delete id="deleteByScenicId">
delete from scenic_account where scenic_id = #{scenicId}
</delete>
<delete id="deleteRelationByScenicId">
delete from account_scenic where scenic_id = #{scenicId}
</delete>
<delete id="deleteRelationById">
delete from account_scenic where account_id = #{accountId}
</delete>
<select id="getSuperAccountOfScenic"
resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
select id, scenic_id, is_super, name, phone, account, password, create_time, update_time
from scenic_account
where scenic_id = #{scenicId} and is_super = 1
select a.id, b.scenic_id, b.is_admin as isSuper, a.name, a.phone, a.account, a.password, a.create_time, a.update_time
from scenic_account a left join account_scenic b on a.id = b.account_id
where b.scenic_id = #{scenicId} and b.is_admin = 1
</select>
<select id="getByAccount" resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
select id, scenic_id, is_super, name, phone, account, password, status,create_time, update_time
@@ -61,7 +71,7 @@
SELECT * FROM scenic_account
<where>
<if test="scenicId != null">
AND scenic_id = #{scenicId}
AND id in (select account_id from account_scenic where scenic_id = #{scenicId})
</if>
<if test="account != null and account != ''">
AND account LIKE CONCAT('%', #{account}, '%')
@@ -84,4 +94,9 @@
</where>
ORDER BY create_time DESC
</select>
<select id="getAccountRelations" resultType="java.lang.Long">
SELECT scenic_id
FROM account_scenic
WHERE account_id = #{scenicId}
</select>
</mapper>

View File

@@ -318,6 +318,174 @@
WHERE scenic_id = #{scenicId}
AND date BETWEEN #{startTime} AND #{endTime}
</select>
<select id="orderChartByDate" resultType="java.util.HashMap">
SELECT
DATE(date_series.DATE) as t,
COALESCE ( count( `order`.id ), 0 ) AS count,
COALESCE ( sum( `order`.pay_price ), 0 ) AS price
FROM
(
SELECT
DATE_ADD( #{startTime}, INTERVAL ( units.i + tens.i * 10 + hundreds.i * 100 ) DAY ) AS DATE
FROM
(
SELECT
0 AS i UNION ALL
SELECT
1 UNION ALL
SELECT
2 UNION ALL
SELECT
3 UNION ALL
SELECT
4 UNION ALL
SELECT
5 UNION ALL
SELECT
6 UNION ALL
SELECT
7 UNION ALL
SELECT
8 UNION ALL
SELECT
9
) units
CROSS JOIN (
SELECT
0 AS i UNION ALL
SELECT
1 UNION ALL
SELECT
2 UNION ALL
SELECT
3 UNION ALL
SELECT
4 UNION ALL
SELECT
5 UNION ALL
SELECT
6 UNION ALL
SELECT
7 UNION ALL
SELECT
8 UNION ALL
SELECT
9
) tens
CROSS JOIN (
SELECT
0 AS i UNION ALL
SELECT
1 UNION ALL
SELECT
2 UNION ALL
SELECT
3 UNION ALL
SELECT
4 UNION ALL
SELECT
5 UNION ALL
SELECT
6 UNION ALL
SELECT
7 UNION ALL
SELECT
8 UNION ALL
SELECT
9
) hundreds
WHERE
DATE_ADD( #{startTime}, INTERVAL ( units.i + tens.i * 10 + hundreds.i * 100 ) DAY ) &lt;= #{endTime}
) date_series
LEFT JOIN `order` ON DATE ( `order`.create_at ) = date_series.DATE AND `order`.scenic_id = #{scenicId} AND ( `order`.STATUS = 1 OR `order`.STATUS = 2 )
GROUP BY
date_series.DATE
ORDER BY date_series.DATE
</select>
<select id="orderChartByHour" resultType="java.util.HashMap">
SELECT
date_series.HOUR as t,
COALESCE ( count( `order`.id ), 0 ) AS count,
COALESCE ( sum( `order`.pay_price ), 0 ) AS price
FROM
(
SELECT
DATE_FORMAT( DATE_ADD( #{startTime}, INTERVAL ( units.i + tens.i * 10 + hundreds.i * 100 ) HOUR ), '%m-%d %H') AS HOUR
FROM
(
SELECT
0 AS i UNION ALL
SELECT
1 UNION ALL
SELECT
2 UNION ALL
SELECT
3 UNION ALL
SELECT
4 UNION ALL
SELECT
5 UNION ALL
SELECT
6 UNION ALL
SELECT
7 UNION ALL
SELECT
8 UNION ALL
SELECT
9
) units
CROSS JOIN (
SELECT
0 AS i UNION ALL
SELECT
1 UNION ALL
SELECT
2 UNION ALL
SELECT
3 UNION ALL
SELECT
4 UNION ALL
SELECT
5 UNION ALL
SELECT
6 UNION ALL
SELECT
7 UNION ALL
SELECT
8 UNION ALL
SELECT
9
) tens
CROSS JOIN (
SELECT
0 AS i UNION ALL
SELECT
1 UNION ALL
SELECT
2 UNION ALL
SELECT
3 UNION ALL
SELECT
4 UNION ALL
SELECT
5 UNION ALL
SELECT
6 UNION ALL
SELECT
7 UNION ALL
SELECT
8 UNION ALL
SELECT
9
) hundreds
WHERE
DATE_ADD( #{startTime}, INTERVAL ( units.i + tens.i * 10 + hundreds.i * 100 ) HOUR ) &lt;= #{endTime}
) date_series
LEFT JOIN `order` ON DATE_FORMAT( `order`.create_at, '%m-%d %H' ) = date_series.HOUR AND `order`.scenic_id = #{scenicId} AND ( `order`.STATUS = 1 OR `order`.STATUS = 2 )
GROUP BY
date_series.HOUR
ORDER BY date_series.HOUR
</select>
<insert id="insertStat">
REPLACE INTO scenic_stats (scenic_id, date, cs1, v1, sv1, u1, m1, gv1, gv2, pv1, pv2, cp1, o1, o2, o3, ro2, ro3)
VALUES (#{scenicId}, #{date}, #{data.cameraShotOfMemberNum}, #{data.totalVisitorOfMemberNum}, #{data.scanCodeVisitorOfMemberNum}, #{data.uploadFaceOfMemberNum}, #{data.pushOfMemberNum}, #{data.completeVideoOfMemberNum}, #{data.completeOfVideoNum}, #{data.previewVideoOfMemberNum}, #{data.previewOfVideoNum}, #{data.clickOnPayOfMemberNum}, #{data.payOfMemberNum}, #{data.payOfOrderNum}, #{data.payOfOrderAmount}, #{data.refundOfOrderNum}, #{data.refundOfOrderAmount})

View File

@@ -87,4 +87,14 @@ public class BceFaceBodyAdapterTest {
}
});
}
@Test
public void testDeleteFace() {
BceFaceBodyAdapter adapter = getAdapter();
String db = "3972138108618674176";
List<String> entityIds = adapter.listFace(db, "", null, null);
entityIds.forEach(entityId -> {
adapter.deleteFace(db, entityId);
});
}
}