From 2090cffd3c2181fcfc015c99c69d46e3c93dba13 Mon Sep 17 00:00:00 2001 From: gaoben Date: Tue, 11 May 2021 10:00:16 +0800 Subject: [PATCH] =?UTF-8?q?v2.0.3=201.=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?ten=5Fvideo=E8=A1=A8=202.=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?ten=5Fvideo=5Frecord=E8=A1=A8=203.=E8=BD=A6=E8=BE=86=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=8C=89=E6=97=B6=E9=97=B4=E5=80=92=E5=BA=8F=E6=8E=92?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/job/task/XaImageTask.java | 8 +- .../ten/controller/TenVideoController.java | 112 ++++++++++++ .../controller/TenVideoRecordController.java | 62 +++++++ .../modules/ten/dao/TenVideoDao.java | 14 ++ .../modules/ten/dao/TenVideoRecordDao.java | 14 ++ .../modules/ten/entity/TenVideoEntity.java | 74 ++++++++ .../ten/entity/TenVideoRecordEntity.java | 56 ++++++ .../ten/service/TenVideoRecordService.java | 17 ++ .../modules/ten/service/TenVideoService.java | 17 ++ .../impl/TenPackRecordEnterServiceImpl.java | 2 + .../impl/TenPackRecordExitServiceImpl.java | 1 + .../impl/TenVideoRecordServiceImpl.java | 65 +++++++ .../ten/service/impl/TenVideoServiceImpl.java | 61 +++++++ .../video/controller/VideoOpenApi.java | 171 ++++++++++++++++++ .../modules/xian/service/XaApi.java | 10 +- .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application.yml | 2 +- .../resources/mapper/ten/TenRecordDao.xml | 2 + .../main/resources/mapper/ten/TenVideoDao.xml | 20 ++ .../mapper/ten/TenVideoRecordDao.xml | 18 ++ .../shapelight/common/utils/DateUtils.java | 1 + 21 files changed, 718 insertions(+), 11 deletions(-) create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoRecordController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoDao.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoRecordDao.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoEntity.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoRecordEntity.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoRecordService.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoService.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoRecordServiceImpl.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoServiceImpl.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/video/controller/VideoOpenApi.java create mode 100644 shapelight-admin/src/main/resources/mapper/ten/TenVideoDao.xml create mode 100644 shapelight-admin/src/main/resources/mapper/ten/TenVideoRecordDao.xml diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java index 293f95f..55f817a 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java @@ -75,8 +75,8 @@ public class XaImageTask implements ITask { if (type.intValue() == 1) { String appId = object.getString("appId"); String appSecret = object.getString("appSecret"); -// String fwikUrl = XaApi.getFwikUrl(appId, appSecret); - String fwikUrl = "http://"; + String fwikUrl = XaApi.getFwikUrl(appId, appSecret); +// String fwikUrl = "http://"; if (fwikUrl != null) { List allCells = this.tenCellService.list((Wrapper) (new QueryWrapper()) .eq("tenant_id", sysTenUser.getTenantId())); @@ -449,8 +449,8 @@ public class XaImageTask implements ITask { TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,"","SYRK", "SYRK", appId, appSecret); String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId()); -// String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "SYRK", "SYRK", appId, appSecret,tranId); - String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; + String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "SYRK", "SYRK", appId, appSecret,tranId); +// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "23232"; // System.out.println(s); log.debug("processRealPersonImage:" + resJson); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoController.java new file mode 100644 index 0000000..b425a2c --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoController.java @@ -0,0 +1,112 @@ +package net.shapelight.modules.ten.controller; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import net.shapelight.common.utils.Constant; +import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.sys.entity.SysUserEntity; +import net.shapelight.modules.sys.service.SysUserRoleService; +import net.shapelight.modules.ten.entity.TenUserScopeEntity; +import net.shapelight.modules.ten.service.TenUserScopeService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import net.shapelight.modules.ten.entity.TenVideoEntity; +import net.shapelight.modules.ten.service.TenVideoService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; + + + +/** + * 视频设备表 + * + */ +@RestController +@RequestMapping("ten/video") +@Api(value="视频设备",tags={"视频设备"}) +public class TenVideoController extends AbstractController { + @Autowired + private TenVideoService tenVideoService; + @Autowired + private SysUserRoleService sysUserRoleService; + @Autowired + private TenUserScopeService tenUserScopeService; + + /** + * 列表 + */ + @GetMapping("/list") + @RequiresPermissions("ten:video") + @ApiOperation(value = "查询列表",response = TenVideoEntity.class) + public R list(@RequestParam Map params){ + String tenantId = getUser().getTenantId()+""; + params.put("tenantId",tenantId+""); + SysUserEntity user = getUser(); + List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId()); + //小区管理员 + if(roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL){ + TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id",user.getUserId())); + params.put("cellId",scope.getCellId().toString()); + } + PageUtils page = tenVideoService.queryPage(params); + + return R.ok().put("data", page); + } + + + /** + * 信息 + */ + @GetMapping("/info/{id}") + @RequiresPermissions("ten:video") + @ApiOperation(value = "查询详情",response = TenVideoEntity.class) + public R info(@PathVariable("id") Long id){ + TenVideoEntity tenVideo = tenVideoService.getById(id); + + return R.ok().put("data", tenVideo); + } + + /** + * 保存 + */ + @PostMapping("/save") + @RequiresPermissions("ten:video") + @ApiOperation(value = "保存",response = TenVideoEntity.class) + public R save(@RequestBody TenVideoEntity tenVideo){ + tenVideoService.save(tenVideo); + + return R.ok(); + } + + /** + * 修改 + */ + @PostMapping("/update") + @RequiresPermissions("ten:video") + @ApiOperation(value = "修改",response = TenVideoEntity.class) + public R update(@RequestBody TenVideoEntity tenVideo){ + tenVideoService.updateById(tenVideo); + + return R.ok(); + } + + /** + * 删除 + */ + @PostMapping("/delete") + @RequiresPermissions("ten:video") + @ApiOperation(value = "删除",response = TenVideoEntity.class) + public R delete(@RequestBody Long[] ids){ + tenVideoService.removeByIds(Arrays.asList(ids)); + + return R.ok(); + } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoRecordController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoRecordController.java new file mode 100644 index 0000000..fba2a23 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenVideoRecordController.java @@ -0,0 +1,62 @@ +package net.shapelight.modules.ten.controller; + +import java.util.List; +import java.util.Map; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import net.shapelight.common.utils.Constant; +import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.sys.entity.SysUserEntity; +import net.shapelight.modules.sys.service.SysUserRoleService; +import net.shapelight.modules.ten.entity.TenUserScopeEntity; +import net.shapelight.modules.ten.entity.TenVideoEntity; +import net.shapelight.modules.ten.service.TenUserScopeService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import net.shapelight.modules.ten.entity.TenVideoRecordEntity; +import net.shapelight.modules.ten.service.TenVideoRecordService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; + + + +/** + * 视频抓拍表 + * + */ +@RestController +@RequestMapping("ten/videorecord") +@Api(value="视频抓拍记录",tags={"视频抓拍记录"}) +public class TenVideoRecordController extends AbstractController { + @Autowired + private TenVideoRecordService tenVideoRecordService; + @Autowired + private SysUserRoleService sysUserRoleService; + @Autowired + private TenUserScopeService tenUserScopeService; + + /** + * 列表 + */ + @GetMapping("/list") + @RequiresPermissions("ten:videorecord") + @ApiOperation(value = "查询列表",response = TenVideoEntity.class) + public R list(@RequestParam Map params){ + String tenantId = getUser().getTenantId()+""; + params.put("tenantId",tenantId+""); + SysUserEntity user = getUser(); + List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId()); + //小区管理员 + if(roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL){ + TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id",user.getUserId())); + params.put("cellId",scope.getCellId().toString()); + } + PageUtils page = tenVideoRecordService.queryPage(params); + + return R.ok().put("data", page); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoDao.java new file mode 100644 index 0000000..945a227 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.ten.dao; + +import net.shapelight.modules.ten.entity.TenVideoEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 视频设备表 + * + */ +@Mapper +public interface TenVideoDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoRecordDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoRecordDao.java new file mode 100644 index 0000000..9f1adeb --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenVideoRecordDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.ten.dao; + +import net.shapelight.modules.ten.entity.TenVideoRecordEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 视频抓拍表 + * + */ +@Mapper +public interface TenVideoRecordDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoEntity.java new file mode 100644 index 0000000..c3d0f74 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoEntity.java @@ -0,0 +1,74 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 视频设备表 + * + */ +@Data +@TableName("ten_video") +public class TenVideoEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long id; + /** + * 设备编码 + */ + private String sn; + /** + * 小区 + */ + private Long cellId; + /** + * 运营商id + */ + private Long tenantId; + /** + * 名称 + */ + private String name; + /** + * 安装位置 + */ + private String location; + /** + * 厂家 + */ + private String factory; + /** + * 描述 + */ + private String note; + /** + * 状态1在线0离线 + */ + private Integer status; + /** + * ip + */ + private String ip; + /** + * 最后在线时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastOnlineTime; + + @TableField(exist = false) + @ApiModelProperty("小区名称") + private String cellName; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoRecordEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoRecordEntity.java new file mode 100644 index 0000000..e860f35 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenVideoRecordEntity.java @@ -0,0 +1,56 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 视频抓拍表 + * + */ +@Data +@TableName("ten_video_record") +public class TenVideoRecordEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long recordId; + /** + * 设备编码 + */ + private String sn; + /** + * 时间 + */ + private Date captureTime; + /** + * 小图 + */ + private String facePicture; + /** + * 大图 + */ + private String backgroudPicture; + /** + * 小区id + */ + private Long cellId; + /** + * 运营商id + */ + private Long tenantId; + + @TableField(exist = false) + @ApiModelProperty("小区名称") + private String cellName; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoRecordService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoRecordService.java new file mode 100644 index 0000000..13456e1 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoRecordService.java @@ -0,0 +1,17 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenVideoRecordEntity; + +import java.util.Map; + +/** + * 视频抓拍表 + * + */ +public interface TenVideoRecordService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoService.java new file mode 100644 index 0000000..c0e515b --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenVideoService.java @@ -0,0 +1,17 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenVideoEntity; + +import java.util.Map; + +/** + * 视频设备表 + * + */ +public interface TenVideoService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordEnterServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordEnterServiceImpl.java index e1b4dde..148cb46 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordEnterServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordEnterServiceImpl.java @@ -51,6 +51,8 @@ public class TenPackRecordEnterServiceImpl extends ServiceImpl() .eq("tenant_id",params.get("tenantId")) .in("cell_id",cellIds) + .orderByDesc("enter_time") + ); for(TenPackRecordEnterEntity entity: page.getRecords()){ diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordExitServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordExitServiceImpl.java index 7adc4e4..87bf0d7 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordExitServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPackRecordExitServiceImpl.java @@ -48,6 +48,7 @@ public class TenPackRecordExitServiceImpl extends ServiceImpl() .eq("tenant_id",params.get("tenantId")) .in("cell_id",cellIds) + .orderByDesc("exit_time") ); for(TenPackRecordExitEntity entity: page.getRecords()){ diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoRecordServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoRecordServiceImpl.java new file mode 100644 index 0000000..713c3b7 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoRecordServiceImpl.java @@ -0,0 +1,65 @@ +package net.shapelight.modules.ten.service.impl; + +import net.shapelight.modules.ten.entity.TenCellEntity; +import net.shapelight.modules.ten.entity.TenVideoEntity; +import net.shapelight.modules.ten.service.TenCellService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; + +import net.shapelight.modules.ten.dao.TenVideoRecordDao; +import net.shapelight.modules.ten.entity.TenVideoRecordEntity; +import net.shapelight.modules.ten.service.TenVideoRecordService; + +import javax.xml.ws.Action; + + +@Service("tenVideoRecordService") +public class TenVideoRecordServiceImpl extends ServiceImpl implements TenVideoRecordService { + + @Autowired + private TenCellService tenCellService; + + @Override + public PageUtils queryPage(Map params) { + + List cellIds = new ArrayList<>(); +// cellIds.add(709832651506188289L); + String cellId = (String)params.get("cellId"); + if (cellId!=null && !cellId.isEmpty()){ + Long cellLong = Long.parseLong(cellId); + cellIds.add(cellLong); + }else { + List cells = tenCellService.queryAll(params); + for (TenCellEntity cell : cells) { + cellIds.add(cell.getCellId()); + } + } + if (cellIds.size() == 0) { + return new PageUtils(new ArrayList<>(),0,0,0); + } + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() +// .eq("tenant_id",params.get("tenantId")) + .in("cell_id",cellIds) + .orderByDesc("capture_time") + ); + + for(TenVideoRecordEntity videoEntity: page.getRecords()){ + String cellName = tenCellService.getCellName(videoEntity.getCellId()+""); + videoEntity.setCellName(cellName); + } + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoServiceImpl.java new file mode 100644 index 0000000..8c4e6e1 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenVideoServiceImpl.java @@ -0,0 +1,61 @@ +package net.shapelight.modules.ten.service.impl; + +import net.shapelight.modules.ten.entity.TenCellEntity; +import net.shapelight.modules.ten.service.TenCellService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; + +import net.shapelight.modules.ten.dao.TenVideoDao; +import net.shapelight.modules.ten.entity.TenVideoEntity; +import net.shapelight.modules.ten.service.TenVideoService; + + +@Service("tenVideoService") +public class TenVideoServiceImpl extends ServiceImpl implements TenVideoService { + + @Autowired + private TenCellService tenCellService; + + @Override + public PageUtils queryPage(Map params) { + + List cellIds = new ArrayList<>(); +// cellIds.add(709832651506188289L); + String cellId = (String)params.get("cellId"); + if (cellId!=null && !cellId.isEmpty()){ + Long cellLong = Long.parseLong(cellId); + cellIds.add(cellLong); + }else { + List cells = tenCellService.queryAll(params); + for (TenCellEntity cell : cells) { + cellIds.add(cell.getCellId()); + } + } + if (cellIds.size() == 0) { + return new PageUtils(new ArrayList<>(),0,0,0); + } + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() +// .eq("tenant_id",params.get("tenantId")) + .in("cell_id",cellIds) + ); + + for(TenVideoEntity videoEntity: page.getRecords()){ + String cellName = tenCellService.getCellName(videoEntity.getCellId()+""); + videoEntity.setCellName(cellName); + } + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/video/controller/VideoOpenApi.java b/shapelight-admin/src/main/java/net/shapelight/modules/video/controller/VideoOpenApi.java new file mode 100644 index 0000000..c887894 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/video/controller/VideoOpenApi.java @@ -0,0 +1,171 @@ +package net.shapelight.modules.video.controller; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.minio.MinioClient; +import io.minio.PutObjectOptions; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + + +import net.shapelight.common.config.GlobalValue; +import net.shapelight.common.config.MinioConfig; +import net.shapelight.common.utils.*; +import net.shapelight.modules.ten.entity.TenVideoEntity; +import net.shapelight.modules.ten.entity.TenVideoRecordEntity; +import net.shapelight.modules.ten.service.TenVideoRecordService; +import net.shapelight.modules.ten.service.TenVideoService; +import org.springframework.beans.factory.annotation.Autowired; +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 javax.imageio.ImageIO; + + +@RestController +@RequestMapping({"/api/video/v1"}) +@Api("视频接口") +public class VideoOpenApi { + + @Autowired + private TenVideoService tenVideoService; + @Autowired + private MinioConfig minioConfig; + @Autowired + private MinioClient minioClient; + @Autowired + private GlobalValue globalValue; + @Autowired + private TenVideoRecordService tenVideoRecordService; + + + + /* + { + "TimeStamp": "2020-12-11 18:06:33", + "Data": { + "DeviceInfo": { + "DeviceId": "01234567891234567" + }, + "CaptureInfo": { + "CaptureTime": "2020-12-11 18:06:33", + "FacePicture": "/9j/4AAQSkZJRgABAQAAAQABAAD", + "BackgroundPicture": "/9j/4AAQSkZJRgABAQAAAQABAAD" + } + } +} + */ + + @PostMapping({"/personZpCallback"}) + @ApiOperation("第三方推送") + public Map personZpCallback(@RequestBody Object object) { + JSONObject jsonObject = (JSONObject) JSONObject.toJSON(object); + String deviceId = jsonObject.getJSONObject("Data").getJSONObject("DeviceInfo").getString("DeviceId"); + String captureTimeStr = jsonObject.getJSONObject("Data").getJSONObject("CaptureInfo").getString("CaptureTime"); + String facePicture = jsonObject.getJSONObject("Data").getJSONObject("CaptureInfo").getString("FacePicture"); + String backgroundPicture = jsonObject.getJSONObject("Data").getJSONObject("CaptureInfo").getString("BackgroundPicture"); + TenVideoEntity videoEntity = tenVideoService.getOne(new QueryWrapper() + .eq("sn",deviceId)); + if(videoEntity!=null){ + TenVideoRecordEntity recordEntity = new TenVideoRecordEntity(); + recordEntity.setSn(deviceId); + recordEntity.setCaptureTime(DateUtils.stringToDate(captureTimeStr,DateUtils.DATE_TIME_PATTERN)); + recordEntity.setCellId(videoEntity.getCellId()); + recordEntity.setTenantId(videoEntity.getTenantId()); + + + if(facePicture!=null && !facePicture.isEmpty()){ + try { + byte[] b = Base64.getDecoder().decode(facePicture.replace("\n", "")); + InputStream inputStream = new ByteArrayInputStream(b); + String userFileUrl = "video/" + + recordEntity.getCellId().toString() + "/" + + DateUtils.format(new Date(),DateUtils.DATE_YEAR_MONTH) + "/"; + String fileName = userFileUrl + UUIDUtil.uuid() + ".jpg"; +// String fileName = "t_"+UUIDUtil.uuid()+ "." +extension; + PutObjectOptions putObjectOptions = new PutObjectOptions(b.length, -1); + putObjectOptions.setContentType("image/jpeg"); + minioClient.putObject( + minioConfig.getBucketName(), fileName, inputStream, putObjectOptions); + inputStream.close(); + recordEntity.setFacePicture(fileName); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + if(backgroundPicture!=null && !backgroundPicture.isEmpty()){ + try { + byte[] b = Base64.getDecoder().decode(backgroundPicture.replace("\n", "")); + InputStream inputStream = new ByteArrayInputStream(b); + String userFileUrl = "video/" + + recordEntity.getCellId().toString() + "/" + + DateUtils.format(new Date(),DateUtils.DATE_YEAR_MONTH) + "/"; + String fileName = userFileUrl + UUIDUtil.uuid() + ".jpg"; +// String fileName = "t_"+UUIDUtil.uuid()+ "." +extension; + PutObjectOptions putObjectOptions = new PutObjectOptions(b.length, -1); + putObjectOptions.setContentType("image/jpeg"); + minioClient.putObject( + minioConfig.getBucketName(), fileName, inputStream, putObjectOptions); + inputStream.close(); + recordEntity.setBackgroudPicture(fileName); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + tenVideoRecordService.save(recordEntity); + } + + Map res = new HashMap(); + res.put("code","0"); + res.put("msg","上传成功"); + res.put("result","success"); + + return res; + } + + + + + + + + + @PostMapping({"/zpPersonHeartbeat"}) + @ApiOperation("第三方心跳") + public Map zpPersonHeartbeat(@RequestBody Object object) { + JSONObject jsonObject = (JSONObject) JSONObject.toJSON(object); + String deviceId = jsonObject.getJSONObject("Data").getJSONObject("DeviceInfo").getString("DeviceId"); + String deviceIp = jsonObject.getJSONObject("Data").getJSONObject("DeviceInfo").getString("DeviceIp"); + TenVideoEntity videoEntity = tenVideoService.getOne(new QueryWrapper() + .eq("sn",deviceId)); + if(videoEntity!=null){ +// videoEntity.setIp(deviceIp); +// videoEntity.setLastOnlineTime(new Date()); +// tenVideoService.updateById(videoEntity); + } + + Map res = new HashMap(); + res.put("code","0"); + res.put("msg","上传成功"); + res.put("result","success"); + + return res; + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java b/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java index 8da8bfa..cbe8be2 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java @@ -393,16 +393,16 @@ public class XaApi { //伟丰花园:610113600000000005977 欧风园:610113600000000004538 //西安文理学院:610113630000000010348 绿地花都:610113610000000017653 String xqid = "610113600000000004538"; - String address = getAddress(xqid, appid, appsecret); - System.out.println(address); +// String address = getAddress(xqid, appid, appsecret); +// System.out.println(address); //6.2 获取数据对接接口--------------------------------------------------------------------------- String apiUrl = getFwikUrl(appid, appsecret); System.out.println(apiUrl); //6.1 获取标准地址接口--------------------------------------------------------------------------- - String addressCell = getAddress(xqid, appid, appsecret); - System.out.println(addressCell); +// String addressCell = getAddress(xqid, appid, appsecret); +// System.out.println(addressCell); //6.3.1 实有房屋信息---------------------------------------------------------------------------- // 1820591355 610113600000000001202 610113003012013 陕西省西安市雁塔区长安南路439号4栋1单元3层4131号 长安南路 108.942481 34.207741 14 10 610113600000000004538 欧风园小区 610113 陕师大警务室 000268000029000013000001000003000002 000268 A61011304538 西安市雁塔区 610113600000 2021-03-23 16:50:08 /* @@ -420,7 +420,7 @@ public class XaApi { //6.3.2 实有人口信息---------------------------------------------------------------------------- // syncPerson(); //6.3.9 车辆出入记录------------------------------------------------------------- -// processRecordCarEnter(); + processRecordCarEnter(); } diff --git a/shapelight-admin/src/main/resources/application-dev.yml b/shapelight-admin/src/main/resources/application-dev.yml index 47aa778..d7842fa 100644 --- a/shapelight-admin/src/main/resources/application-dev.yml +++ b/shapelight-admin/src/main/resources/application-dev.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.50.232:3306/cell_db_tcp?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true + url: jdbc:mysql://192.168.50.232:3306/cell_db_0427?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true username: user password: user@server001 initial-size: 10 diff --git a/shapelight-admin/src/main/resources/application.yml b/shapelight-admin/src/main/resources/application.yml index 8af09bb..4deb392 100644 --- a/shapelight-admin/src/main/resources/application.yml +++ b/shapelight-admin/src/main/resources/application.yml @@ -78,7 +78,7 @@ global: opt_dir: opt db_bak: db_filepath: db_bak - db_name: cell_db + db_name: cell_db_0427 db_username: root db_password: root db_host: localhost diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml index 15af226..682f1d7 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml @@ -412,6 +412,7 @@ select * from ten_record_${tenantId} where cell_id = #{cellId} and xa_sync = 0 + and record_face is not null and TO_DAYS(record_time) = TO_DAYS(NOW()) @@ -420,6 +421,7 @@ where cell_id = #{cellId} and xa_sync_image = 0 and xa_sync = 1 + and record_face is not null and TO_DAYS(record_time) = TO_DAYS(NOW()) diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenVideoDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenVideoDao.xml new file mode 100644 index 0000000..40c7a76 --- /dev/null +++ b/shapelight-admin/src/main/resources/mapper/ten/TenVideoDao.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenVideoRecordDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenVideoRecordDao.xml new file mode 100644 index 0000000..bcc2e06 --- /dev/null +++ b/shapelight-admin/src/main/resources/mapper/ten/TenVideoRecordDao.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java b/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java index 6ec5f29..b9abdbf 100644 --- a/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java +++ b/shapelight-common/src/main/java/net/shapelight/common/utils/DateUtils.java @@ -22,6 +22,7 @@ public class DateUtils { /** 时间格式(yyyy-MM-dd HH:mm:ss) */ public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; public final static String DATE_TIME_DB= "yyyyMMddHHmmss"; + public final static String DATE_YEAR_MONTH= "yyyyMMdd"; /** * 日期格式化 日期格式为:yyyy-MM-dd