Merge branch 'dev' of http://47.97.8.94:19527/yj/zn-cloud into dev
This commit is contained in:
commit
bbc8e4c6a6
@ -14,6 +14,9 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|||||||
import com.github.yulichang.toolkit.SpringContentUtils;
|
import com.github.yulichang.toolkit.SpringContentUtils;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronization;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
import org.springframework.web.socket.WebSocketSession;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -40,6 +43,7 @@ public class AttendanceWebSocketMessageListener implements WebSocketMessageListe
|
|||||||
private AttendanceMachineApi attendanceMachineApi;
|
private AttendanceMachineApi attendanceMachineApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void onMessage(WebSocketSession session, AttendanceSendMessage message) {
|
public void onMessage(WebSocketSession session, AttendanceSendMessage message) {
|
||||||
|
|
||||||
StringRedisTemplate redisTemplate = SpringContentUtils.getBean(StringRedisTemplate.class);
|
StringRedisTemplate redisTemplate = SpringContentUtils.getBean(StringRedisTemplate.class);
|
||||||
@ -91,46 +95,55 @@ public class AttendanceWebSocketMessageListener implements WebSocketMessageListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (object1.get("cmd").equals(AttendanceConstants.CMD_TO_CLIENT)) {
|
if (object1.get("cmd").equals(AttendanceConstants.CMD_TO_CLIENT)) {
|
||||||
System.out.println("进来了"+ System.currentTimeMillis());
|
|
||||||
|
|
||||||
// 获取响应数据
|
// 获取响应数据
|
||||||
DeviceResponseDTO dto = JsonUtils.parseObject2(object1.get("data").toString(), DeviceResponseDTO.class);
|
DeviceResponseDTO dto = JsonUtils.parseObject2(object1.get("data").toString(), DeviceResponseDTO.class);
|
||||||
|
|
||||||
|
// 获取设备号
|
||||||
|
String deviceNo = object1.get("from").toString();
|
||||||
String requestId = object1.get("extra").toString().split("_")[0];
|
String requestId = object1.get("extra").toString().split("_")[0];
|
||||||
String userId = object1.get("extra").toString().split("_")[1];
|
String userId = object1.get("extra").toString().split("_")[1];
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
|
|
||||||
// 更新下发数据
|
// 更新下发数据
|
||||||
AttendanceUpdateDTO attendanceUpdateDTO = new AttendanceUpdateDTO();
|
AttendanceUpdateDTO attendanceUpdateDTO = new AttendanceUpdateDTO();
|
||||||
List<DistributeRecordDTO> recordDTOs = new ArrayList<>();
|
|
||||||
|
|
||||||
// 更新下发记录表
|
// 在事务提交后,更新下发记录,
|
||||||
if (dto.getDelFailed() == null) {
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||||
|
@Override
|
||||||
|
public void afterCommit() {
|
||||||
|
|
||||||
DistributeRecordDTO recordDTO = new DistributeRecordDTO();
|
List<DistributeRecordDTO> recordDTOs = new ArrayList<>();
|
||||||
recordDTO.setCode(dto.getCode());
|
|
||||||
recordDTO.setResult(dto.getMsg());
|
|
||||||
recordDTO.setUserId(dto.getUserId() == null ? Long.valueOf(userId) : Long.valueOf(dto.getUserId()));
|
|
||||||
recordDTO.setRequestId(requestId);
|
|
||||||
recordDTO.setUpdater(userId);
|
|
||||||
recordDTOs.add(recordDTO);
|
|
||||||
}else {
|
|
||||||
|
|
||||||
// 更新下发记录表
|
// 更新下发记录表
|
||||||
for (DeviceResponseDTO.DeleteUser info : dto.getDelFailed()) {
|
if (dto.getDelFailed() == null) {
|
||||||
|
|
||||||
DistributeRecordDTO deleteRecord = new DistributeRecordDTO();
|
DistributeRecordDTO recordDTO = new DistributeRecordDTO();
|
||||||
deleteRecord.setCode(info.getCode());
|
recordDTO.setCode(dto.getCode());
|
||||||
deleteRecord.setResult(info.getMsg());
|
recordDTO.setResult(dto.getMsg());
|
||||||
deleteRecord.setUserId(Long.valueOf(info.getUserId()));
|
recordDTO.setUserId(dto.getUserId() == null ? Long.valueOf(userId) : Long.valueOf(dto.getUserId()));
|
||||||
deleteRecord.setRequestId(requestId);
|
recordDTO.setRequestId(requestId);
|
||||||
deleteRecord.setUpdater(userId);
|
recordDTO.setUpdater(userId);
|
||||||
recordDTOs.add(deleteRecord);
|
recordDTOs.add(recordDTO);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// 更新下发记录表
|
||||||
|
for (DeviceResponseDTO.DeleteUser info : dto.getDelFailed()) {
|
||||||
|
|
||||||
|
DistributeRecordDTO deleteRecord = new DistributeRecordDTO();
|
||||||
|
deleteRecord.setCode(info.getCode());
|
||||||
|
deleteRecord.setResult(info.getMsg());
|
||||||
|
deleteRecord.setUserId(Long.valueOf(info.getUserId()));
|
||||||
|
deleteRecord.setRequestId(requestId);
|
||||||
|
deleteRecord.setUpdater(userId);
|
||||||
|
recordDTOs.add(deleteRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新下发记录表
|
||||||
|
attendanceMachineApi.updateDistributeRecord(recordDTOs);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// 更新下发记录表
|
|
||||||
attendanceMachineApi.updateDistributeRecord(recordDTOs);
|
|
||||||
|
|
||||||
// 响应失败的情况
|
// 响应失败的情况
|
||||||
if (dto.getCode() != 0) {
|
if (dto.getCode() != 0) {
|
||||||
@ -139,8 +152,8 @@ public class AttendanceWebSocketMessageListener implements WebSocketMessageListe
|
|||||||
webSocketMessageSender.sendObject(object1.get("to").toString(), "attendance-message-send", object1);
|
webSocketMessageSender.sendObject(object1.get("to").toString(), "attendance-message-send", object1);
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
redisTemplate.opsForValue().set(object1.get("from").toString() + "msg", dto.getCode() + "_" + dto.getMsg(), 30, TimeUnit.SECONDS);
|
redisTemplate.opsForValue().set(deviceNo + "msg", dto.getCode() + "_" + dto.getMsg(), 30, TimeUnit.SECONDS);
|
||||||
redisTemplate.opsForValue().set(object1.get("from").toString(), "false", 30, TimeUnit.SECONDS);
|
redisTemplate.opsForValue().set(deviceNo, "false", 30, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -151,20 +164,20 @@ public class AttendanceWebSocketMessageListener implements WebSocketMessageListe
|
|||||||
case "addUserRet":
|
case "addUserRet":
|
||||||
// 更新设备绑定用户信息
|
// 更新设备绑定用户信息
|
||||||
attendanceUpdateDTO.setUserId(Collections.singletonList(Long.valueOf(dto.getUserId())));
|
attendanceUpdateDTO.setUserId(Collections.singletonList(Long.valueOf(dto.getUserId())));
|
||||||
attendanceUpdateDTO.setDeviceNo(object1.get("from").toString());
|
attendanceUpdateDTO.setDeviceNo(deviceNo);
|
||||||
attendanceUpdateDTO.setMethod(0);
|
attendanceUpdateDTO.setMethod(0);
|
||||||
|
|
||||||
// 更新设备绑定用户信息
|
// 更新设备绑定用户信息
|
||||||
attendanceMachineApi.updateAttendance(attendanceUpdateDTO);
|
attendanceMachineApi.updateAttendance(attendanceUpdateDTO);
|
||||||
break;
|
break;
|
||||||
case "delMultiUserRet":
|
case "delMultiUserRet":
|
||||||
List<String> userIds = JsonUtils.parseArray(redisTemplate.opsForValue().get(object1.get("from").toString()), String.class);
|
List<String> userIds = JsonUtils.parseArray(redisTemplate.opsForValue().get(deviceNo), String.class);
|
||||||
if (dto.getDelFailed() != null) {
|
if (dto.getDelFailed() != null) {
|
||||||
userIds.removeAll(convertList(dto.getDelFailed(), DeviceResponseDTO.DeleteUser::getUserId));
|
userIds.removeAll(convertList(dto.getDelFailed(), DeviceResponseDTO.DeleteUser::getUserId));
|
||||||
}
|
}
|
||||||
// 更新设备绑定用户信息
|
// 更新设备绑定用户信息
|
||||||
attendanceUpdateDTO.setUserId(userIds.stream().map(Long::valueOf).collect(Collectors.toList()));
|
attendanceUpdateDTO.setUserId(userIds.stream().map(Long::valueOf).collect(Collectors.toList()));
|
||||||
attendanceUpdateDTO.setDeviceNo(object1.get("from").toString());
|
attendanceUpdateDTO.setDeviceNo(deviceNo);
|
||||||
attendanceUpdateDTO.setMethod(1);
|
attendanceUpdateDTO.setMethod(1);
|
||||||
|
|
||||||
// 更新设备绑定用户信息
|
// 更新设备绑定用户信息
|
||||||
@ -172,20 +185,24 @@ public class AttendanceWebSocketMessageListener implements WebSocketMessageListe
|
|||||||
break;
|
break;
|
||||||
case "setPasswordRet":
|
case "setPasswordRet":
|
||||||
// 更新设备密码
|
// 更新设备密码
|
||||||
String value = redisTemplate.opsForValue().get(object1.get("from").toString());
|
String value = redisTemplate.opsForValue().get(deviceNo);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
String oldPassword = value.split("-")[0];
|
String oldPassword = value.split("-")[0];
|
||||||
String newPassword = value.split("-")[1];
|
String newPassword = value.split("-")[1];
|
||||||
attendanceMachineApi.updateDevicePassword(object1.get("from").toString(), oldPassword, newPassword);
|
attendanceMachineApi.updateDevicePassword(deviceNo, oldPassword, newPassword);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
redisTemplate.delete(object1.get("from").toString());
|
redisTemplate.delete(deviceNo);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object1.get("to").toString().isEmpty()) {
|
if (!object1.get("to").toString().isEmpty()) {
|
||||||
webSocketMessageSender.sendObject(object1.get("to").toString(), "attendance-message-send", object1);
|
webSocketMessageSender.sendObject(object1.get("to").toString(), "attendance-message-send", object1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.equipment;
|
package cn.iocoder.yudao.module.system.service.equipment;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.DistributeRecordDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.DistributeRecordDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.equipment.DistributeRecordMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.equipment.DistributeRecordMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -34,8 +35,11 @@ public class DistributeRecordServiceImpl implements DistributeRecordService {
|
|||||||
|
|
||||||
for (DistributeRecordDO updateDO : updateReqVO) {
|
for (DistributeRecordDO updateDO : updateReqVO) {
|
||||||
|
|
||||||
distributeRecordMapper.update(updateDO,
|
DistributeRecordDO updateVO = BeanUtils.toBean(updateDO, DistributeRecordDO.class);
|
||||||
new LambdaQueryWrapperX<DistributeRecordDO>()
|
updateVO.setRequestId(null);
|
||||||
|
updateVO.setUserId(null);
|
||||||
|
distributeRecordMapper.update(updateVO,
|
||||||
|
new LambdaUpdateWrapper<DistributeRecordDO>()
|
||||||
.eq(DistributeRecordDO::getUserId, updateDO.getUserId())
|
.eq(DistributeRecordDO::getUserId, updateDO.getUserId())
|
||||||
.eq(DistributeRecordDO::getRequestId, updateDO.getRequestId()));
|
.eq(DistributeRecordDO::getRequestId, updateDO.getRequestId()));
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public interface UsersExtService {
|
|||||||
/**
|
/**
|
||||||
* 删除用户人脸信息
|
* 删除用户人脸信息
|
||||||
*/
|
*/
|
||||||
String deleteUser(Long userId);
|
void deleteUser(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得用户信息拓展
|
* 获得用户信息拓展
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.equipment;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
@ -28,7 +29,9 @@ import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|||||||
import cn.iocoder.yudao.module.system.service.websocket.WebsocketService;
|
import cn.iocoder.yudao.module.system.service.websocket.WebsocketService;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.github.yulichang.toolkit.SpringContentUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -197,7 +200,7 @@ public class UsersExtServiceImpl implements UsersExtService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deleteUser(Long userId) {
|
public void deleteUser(Long userId) {
|
||||||
|
|
||||||
//校验 当前用户人脸信息是否已存在
|
//校验 当前用户人脸信息是否已存在
|
||||||
UsersExtDO usersExtDO = usersExtMapper.selectOne(UsersExtDO::getUserId, userId);
|
UsersExtDO usersExtDO = usersExtMapper.selectOne(UsersExtDO::getUserId, userId);
|
||||||
@ -214,17 +217,14 @@ public class UsersExtServiceImpl implements UsersExtService {
|
|||||||
.setCmd("delMultiUser")
|
.setCmd("delMultiUser")
|
||||||
.setUser_ids(new String[]{String.valueOf(usersExtDO.getUserId())});
|
.setUser_ids(new String[]{String.valueOf(usersExtDO.getUserId())});
|
||||||
|
|
||||||
try {
|
// 删除的用户Id 存在redis中
|
||||||
for (String deviceNo : deviceNos) {
|
StringRedisTemplate redisTemplate = SpringContentUtils.getBean(StringRedisTemplate.class);
|
||||||
|
for (String deviceNo : deviceNos) {
|
||||||
|
|
||||||
websocketService.sendSn(deviceNo, userVO, 0);
|
redisTemplate.opsForValue().set(deviceNo, new JSONObject(userVO).get("user_ids").toString());
|
||||||
}
|
websocketService.sendSn(deviceNo, userVO, 0);
|
||||||
} catch (RuntimeException ex) {
|
|
||||||
|
|
||||||
return ex.getMessage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateUsersExtExists(Long userId) {
|
private void validateUsersExtExists(Long userId) {
|
||||||
|
@ -21,6 +21,7 @@ import org.springframework.context.annotation.Lazy;
|
|||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -85,7 +86,7 @@ public class FactoryUserServiceImpl implements FactoryUserService{
|
|||||||
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
||||||
user.setDeptId(deptDO.getId());
|
user.setDeptId(deptDO.getId());
|
||||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||||
user.setPassword(encodePassword("123456")); // 设置默认密码
|
user.setPassword(encodePassword()); // 设置默认密码
|
||||||
user.setUserType(2); // 设置用户类型为 工厂用户
|
user.setUserType(2); // 设置用户类型为 工厂用户
|
||||||
userMapper.insert(user);
|
userMapper.insert(user);
|
||||||
|
|
||||||
@ -114,8 +115,10 @@ public class FactoryUserServiceImpl implements FactoryUserService{
|
|||||||
// 发送指令至 考勤设备 下发员工
|
// 发送指令至 考勤设备 下发员工
|
||||||
websocketService.sendSn(machineDO.getDeviceNo(), addUserVO, 1);
|
websocketService.sendSn(machineDO.getDeviceNo(), addUserVO, 1);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
// 手动回滚
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
return ex.getMessage();
|
return ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,8 +186,10 @@ public class FactoryUserServiceImpl implements FactoryUserService{
|
|||||||
// 发送指令至 考勤设备 修改员工信息
|
// 发送指令至 考勤设备 修改员工信息
|
||||||
websocketService.sendSn(machineDO.getDeviceNo(), addUserVO, 1);
|
websocketService.sendSn(machineDO.getDeviceNo(), addUserVO, 1);
|
||||||
}
|
}
|
||||||
}catch (RuntimeException ex) {
|
}catch (Exception ex) {
|
||||||
|
|
||||||
|
// 手动回滚
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
return ex.getMessage();
|
return ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +207,16 @@ public class FactoryUserServiceImpl implements FactoryUserService{
|
|||||||
userMapper.deleteById(id);
|
userMapper.deleteById(id);
|
||||||
|
|
||||||
// 同步删除用户拓展信息
|
// 同步删除用户拓展信息
|
||||||
return usersExtService.deleteUser(id);
|
try {
|
||||||
|
|
||||||
|
usersExtService.deleteUser(id);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
// 手动回滚
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
return ex.getMessage();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateId(Long id) {
|
private void validateId(Long id) {
|
||||||
@ -215,10 +229,9 @@ public class FactoryUserServiceImpl implements FactoryUserService{
|
|||||||
/**
|
/**
|
||||||
* 对密码进行加密
|
* 对密码进行加密
|
||||||
*
|
*
|
||||||
* @param password 密码
|
|
||||||
* @return 加密后的密码
|
* @return 加密后的密码
|
||||||
*/
|
*/
|
||||||
private String encodePassword(String password) {
|
private String encodePassword() {
|
||||||
return passwordEncoder.encode(password);
|
return passwordEncoder.encode("123456");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.websocket;
|
package cn.iocoder.yudao.module.system.service.websocket;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
||||||
@ -11,7 +12,6 @@ import com.xingyuv.http.util.StringUtil;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -47,11 +47,13 @@ public class WebsocketServiceImpl implements WebsocketService{
|
|||||||
.setExtra(requestId + "_" + getLoginUserId())
|
.setExtra(requestId + "_" + getLoginUserId())
|
||||||
.setData(data);
|
.setData(data);
|
||||||
|
|
||||||
|
JSONObject dataJson = new JSONObject(data);
|
||||||
|
|
||||||
// 设置 设备下发记录
|
// 设置 设备下发记录
|
||||||
DistributeRecordDO recordDO = new DistributeRecordDO();
|
DistributeRecordDO recordDO = new DistributeRecordDO();
|
||||||
recordDO.setRequestId(requestId);
|
recordDO.setRequestId(requestId);
|
||||||
recordDO.setDeviceNo(deviceNo);
|
recordDO.setDeviceNo(deviceNo);
|
||||||
recordDO.setUserId(getLoginUserId());
|
recordDO.setUserId(dataJson.get("user_id") == null ? getLoginUserId() : Long.valueOf(dataJson.get("user_id").toString()));
|
||||||
recordDO.setType(type);
|
recordDO.setType(type);
|
||||||
recordDO.setResult("通讯失败");
|
recordDO.setResult("通讯失败");
|
||||||
|
|
||||||
@ -60,7 +62,10 @@ public class WebsocketServiceImpl implements WebsocketService{
|
|||||||
|
|
||||||
// 设备租户ID
|
// 设备租户ID
|
||||||
TenantContextHolder.setTenantId(1L);
|
TenantContextHolder.setTenantId(1L);
|
||||||
stringRedisTemplate.opsForValue().set(deviceNo, "true");
|
|
||||||
|
if (StringUtil.isEmpty(stringRedisTemplate.opsForValue().get(deviceNo))) {
|
||||||
|
stringRedisTemplate.opsForValue().set(deviceNo, "true");
|
||||||
|
}
|
||||||
// 发送修改密码命令给设备
|
// 发送修改密码命令给设备
|
||||||
webSocketSenderApi.sendSN(deviceNo, "attendance-message-send", JsonUtils.toJsonString(baseVO));
|
webSocketSenderApi.sendSN(deviceNo, "attendance-message-send", JsonUtils.toJsonString(baseVO));
|
||||||
|
|
||||||
@ -88,6 +93,7 @@ public class WebsocketServiceImpl implements WebsocketService{
|
|||||||
}
|
}
|
||||||
Long currentTime = System.currentTimeMillis();
|
Long currentTime = System.currentTimeMillis();
|
||||||
if (currentTime - startTime > 30000) {
|
if (currentTime - startTime > 30000) {
|
||||||
|
|
||||||
throw exception(REQUEST_FAILURE);
|
throw exception(REQUEST_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
) read_user ON user.id = read_user.user_id
|
) read_user ON user.id = read_user.user_id
|
||||||
WHERE
|
WHERE
|
||||||
user.deleted = 0
|
user.deleted = 0
|
||||||
|
AND user.status = 0
|
||||||
AND read_user.data_scope != 5
|
AND read_user.data_scope != 5
|
||||||
) result
|
) result
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -1,32 +1,37 @@
|
|||||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice;
|
package cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import javax.annotation.Resource;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
|
|
||||||
import javax.validation.*;
|
|
||||||
import javax.servlet.http.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDevicePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDeviceRespVO;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDeviceSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraUpdateStatusReqVO;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactorySimpleRespVO;
|
||||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryTreeRespVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.convert.cameradevice.CameraDeviceConvert;
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.device.cameradevice.CameraDeviceService;
|
import cn.iocoder.yudao.module.smartfactory.service.device.cameradevice.CameraDeviceService;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-监控摄像头")
|
@Tag(name = "管理后台 - 设备-监控摄像头")
|
||||||
@RestController
|
@RestController
|
||||||
@ -37,6 +42,9 @@ public class CameraDeviceController {
|
|||||||
@Resource
|
@Resource
|
||||||
private CameraDeviceService cameraDeviceService;
|
private CameraDeviceService cameraDeviceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FactoryInfoService factoryInfoService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建设备-监控摄像头")
|
@Operation(summary = "创建设备-监控摄像头")
|
||||||
@PreAuthorize("@ss.hasPermission('smartfactory:camera-device:create')")
|
@PreAuthorize("@ss.hasPermission('smartfactory:camera-device:create')")
|
||||||
@ -52,6 +60,15 @@ public class CameraDeviceController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update-status")
|
||||||
|
@Operation(summary = "更新设备-监控摄像头状态")
|
||||||
|
@PreAuthorize("@ss.hasPermission('smartfactory:camera-device:update')")
|
||||||
|
public CommonResult<Boolean> updateCameraDevice(@Valid @RequestBody CameraUpdateStatusReqVO updateReqVO) {
|
||||||
|
|
||||||
|
cameraDeviceService.updateCameraDeviceStatus(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除设备-监控摄像头")
|
@Operation(summary = "删除设备-监控摄像头")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@ -74,21 +91,58 @@ public class CameraDeviceController {
|
|||||||
@Operation(summary = "获得设备-监控摄像头分页")
|
@Operation(summary = "获得设备-监控摄像头分页")
|
||||||
@PreAuthorize("@ss.hasPermission('smartfactory:camera-device:query')")
|
@PreAuthorize("@ss.hasPermission('smartfactory:camera-device:query')")
|
||||||
public CommonResult<PageResult<CameraDeviceRespVO>> getCameraDevicePage(@Valid CameraDevicePageReqVO pageReqVO) {
|
public CommonResult<PageResult<CameraDeviceRespVO>> getCameraDevicePage(@Valid CameraDevicePageReqVO pageReqVO) {
|
||||||
|
|
||||||
PageResult<CameraDeviceDO> pageResult = cameraDeviceService.getCameraDevicePage(pageReqVO);
|
PageResult<CameraDeviceDO> pageResult = cameraDeviceService.getCameraDevicePage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, CameraDeviceRespVO.class));
|
PageResult<CameraDeviceRespVO> pageData = BeanUtils.toBean(pageResult, CameraDeviceRespVO.class);
|
||||||
|
|
||||||
|
List<CameraDeviceRespVO> pageList = pageData.getList();
|
||||||
|
|
||||||
|
// 获得工厂信息
|
||||||
|
List<FactoryInfoDO> factoryInfoDOS = factoryInfoService.getFactoryList(convertList(pageList, CameraDeviceRespVO::getFactoryId));
|
||||||
|
Map<Long, FactoryInfoDO> factoryMap = convertMap(factoryInfoDOS, FactoryInfoDO::getId);
|
||||||
|
pageList.forEach(data -> {
|
||||||
|
|
||||||
|
data.setFactoryName(factoryMap.get(data.getFactoryId()).getName());
|
||||||
|
});
|
||||||
|
return success(pageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/camera-tree")
|
||||||
@Operation(summary = "导出设备-监控摄像头 Excel")
|
@Operation(summary = "获得设备-监控摄像头Tree")
|
||||||
@PreAuthorize("@ss.hasPermission('smartfactory:camera-device:export')")
|
@PreAuthorize("@ss.hasPermission('smartfactory:camera-device:query')")
|
||||||
@OperateLog(type = EXPORT)
|
public CommonResult<FactoryTreeRespVO> getCameraDeviceTree() {
|
||||||
public void exportCameraDeviceExcel(@Valid CameraDevicePageReqVO pageReqVO,
|
|
||||||
HttpServletResponse response) throws IOException {
|
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
||||||
List<CameraDeviceDO> list = cameraDeviceService.getCameraDevicePage(pageReqVO).getList();
|
|
||||||
// 导出 Excel
|
|
||||||
ExcelUtils.write(response, "设备-监控摄像头.xls", "数据", CameraDeviceRespVO.class,
|
|
||||||
BeanUtils.toBean(list, CameraDeviceRespVO.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FactoryTreeRespVO data = new FactoryTreeRespVO();
|
||||||
|
List<FactorySimpleRespVO> info = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取工厂信息
|
||||||
|
List<FactoryInfoDO> factoryInfo = factoryInfoService.getFactoryList();
|
||||||
|
|
||||||
|
List<Long> factoryIds = convertList(factoryInfo, FactoryInfoDO::getId);
|
||||||
|
// 获取监控设备信息
|
||||||
|
List<CameraDeviceDO> cameraDeviceDOS = cameraDeviceService.getListCameraList(factoryIds);
|
||||||
|
Map<Long, List<CameraDeviceDO>> cameraMap = cameraDeviceDOS.stream().collect(Collectors.groupingBy(CameraDeviceDO::getFactoryId));
|
||||||
|
|
||||||
|
if (!CollUtil.isEmpty(factoryInfo)) {
|
||||||
|
|
||||||
|
Map<String, List<FactoryInfoDO>> infoDOMap = factoryInfo.stream().collect(Collectors.groupingBy(FactoryInfoDO::getType));
|
||||||
|
for (String key : infoDOMap.keySet()) {
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case "1":
|
||||||
|
data = BeanUtils.toBean(infoDOMap.get(key).get(0), FactoryTreeRespVO.class);
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
info.addAll(0, CameraDeviceConvert.INSTANCE.convertList(infoDOMap.get(key), cameraMap));
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
info.addAll(CameraDeviceConvert.INSTANCE.convertList(infoDOMap.get(key), cameraMap));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setSubsidiary(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(data);
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,6 +19,9 @@ public class CameraDeviceRespVO {
|
|||||||
@ExcelProperty("工厂id")
|
@ExcelProperty("工厂id")
|
||||||
private Long factoryId;
|
private Long factoryId;
|
||||||
|
|
||||||
|
@Schema(description = "工厂名称")
|
||||||
|
private String factoryName;
|
||||||
|
|
||||||
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||||
@ExcelProperty("设备名称")
|
@ExcelProperty("设备名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -38,6 +38,9 @@ public class CameraDeviceSaveReqVO {
|
|||||||
@Schema(description = "流媒体地址", example = "https://www.iocoder.cn")
|
@Schema(description = "流媒体地址", example = "https://www.iocoder.cn")
|
||||||
private String streamUrl;
|
private String streamUrl;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
@Schema(description = "是否在大屏显示 0否 1是", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "是否在大屏显示 0否 1是", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "是否在大屏显示 0否 1是不能为空")
|
@NotNull(message = "是否在大屏显示 0否 1是不能为空")
|
||||||
private Integer isShow;
|
private Integer isShow;
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 设备-监控摄像头 Response VO")
|
||||||
|
@Data
|
||||||
|
public class CameraSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "工厂id", requiredMode = Schema.RequiredMode.REQUIRED, example = "32023")
|
||||||
|
@ExcelProperty("工厂id")
|
||||||
|
private Long factoryId;
|
||||||
|
|
||||||
|
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||||
|
@ExcelProperty("设备名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("设备编号")
|
||||||
|
private String code;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 监控设备更新状态 Request VO")
|
||||||
|
@Data
|
||||||
|
public class CameraUpdateStatusReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
@NotNull(message = "设备编号不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@NotNull(message = "状态不能为空")
|
||||||
|
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
@ -1,19 +1,16 @@
|
|||||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo;
|
package cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryInfoPageReqVO;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.*;
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryInfoRespVO;
|
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryInfoSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactorySimpleRespVO;
|
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
||||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -25,10 +22,9 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -43,9 +39,6 @@ public class FactoryInfoController {
|
|||||||
@Resource
|
@Resource
|
||||||
private FactoryInfoService factoryInfoService;
|
private FactoryInfoService factoryInfoService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DictDataApi dictDataApi;
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建工厂信息")
|
@Operation(summary = "创建工厂信息")
|
||||||
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:create')")
|
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:create')")
|
||||||
@ -100,36 +93,32 @@ public class FactoryInfoController {
|
|||||||
@GetMapping("/get-tree")
|
@GetMapping("/get-tree")
|
||||||
@Operation(summary = "获得工厂树结构")
|
@Operation(summary = "获得工厂树结构")
|
||||||
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')")
|
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')")
|
||||||
public CommonResult<Map<FactorySimpleRespVO, Map<String, List<FactorySimpleRespVO>>>> getFactoryTree() {
|
public CommonResult<FactoryTreeRespVO> getFactoryTree() {
|
||||||
|
|
||||||
Map<FactorySimpleRespVO, Map<String, List<FactorySimpleRespVO>>> data = new HashMap<>();
|
FactoryTreeRespVO data = new FactoryTreeRespVO();
|
||||||
|
List<FactorySimpleRespVO> info = new ArrayList<>();
|
||||||
|
|
||||||
List<FactoryInfoDO> factoryInfo = factoryInfoService.getFactoryList();
|
List<FactoryInfoDO> factoryInfo = factoryInfoService.getFactoryList();
|
||||||
|
if (!CollUtil.isEmpty(factoryInfo)) {
|
||||||
|
|
||||||
// 获取所有工厂类型
|
Map<String, List<FactoryInfoDO>> infoDOMap = factoryInfo.stream().collect(Collectors.groupingBy(FactoryInfoDO::getType));
|
||||||
List<DictDataRespDTO> dictDataDTOs = dictDataApi.getDictDataList("sf_factory_type").getCheckedData();
|
for (String key : infoDOMap.keySet()) {
|
||||||
|
|
||||||
Map<String, List<FactorySimpleRespVO>> subdataMap = new HashMap<>();
|
switch (key) {
|
||||||
for (DictDataRespDTO dto : dictDataDTOs) {
|
case "1":
|
||||||
|
data = BeanUtils.toBean(infoDOMap.get(key).get(0), FactoryTreeRespVO.class);
|
||||||
if (!"1".equals(dto.getValue())) {
|
break;
|
||||||
|
case "2":
|
||||||
List<FactorySimpleRespVO> subData = BeanUtils.toBean(
|
info.addAll(0, BeanUtils.toBean(infoDOMap.get(key), FactorySimpleRespVO.class));
|
||||||
factoryInfo.stream().filter(info -> info.getType().equals(dto.getValue())).collect(Collectors.toList()),
|
break;
|
||||||
FactorySimpleRespVO.class);
|
case "3":
|
||||||
|
info.addAll(BeanUtils.toBean(infoDOMap.get(key), FactorySimpleRespVO.class));
|
||||||
subdataMap.put(dto.getLabel(), subData);
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
data.setSubsidiary(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获得type为1 即总公司的工厂信息
|
|
||||||
Optional<FactoryInfoDO> factoryInfoDO = factoryInfo.stream().filter(info -> "1".equals(info.getType())).findFirst();
|
|
||||||
|
|
||||||
FactorySimpleRespVO headOfficeVO = BeanUtils.toBean(
|
|
||||||
factoryInfoDO.orElse(null), FactorySimpleRespVO.class);
|
|
||||||
|
|
||||||
data.put(headOfficeVO, subdataMap);
|
|
||||||
|
|
||||||
return success(data);
|
return success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,5 +142,4 @@ public class FactoryInfoController {
|
|||||||
ExcelUtils.write(response, "工厂信息.xls", "数据", FactoryInfoRespVO.class,
|
ExcelUtils.write(response, "工厂信息.xls", "数据", FactoryInfoRespVO.class,
|
||||||
BeanUtils.toBean(list, FactoryInfoRespVO.class));
|
BeanUtils.toBean(list, FactoryInfoRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo;
|
package cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraSimpleRespVO;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 工厂信息 Response VO")
|
@Schema(description = "管理后台 - 工厂信息 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
@ -17,4 +20,7 @@ public class FactorySimpleRespVO {
|
|||||||
|
|
||||||
@Schema(description = "工厂简称", requiredMode = Schema.RequiredMode.REQUIRED, example = "第一工厂")
|
@Schema(description = "工厂简称", requiredMode = Schema.RequiredMode.REQUIRED, example = "第一工厂")
|
||||||
private String shortName;
|
private String shortName;
|
||||||
|
|
||||||
|
@Schema(description = "监控列表")
|
||||||
|
private List<CameraSimpleRespVO> subsidiary;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 工厂信息数结构 Response VO")
|
||||||
|
@Data
|
||||||
|
public class FactoryTreeRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28794")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "工厂名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "江西省南昌市第一工厂")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "工厂简称", requiredMode = Schema.RequiredMode.REQUIRED, example = "第一工厂")
|
||||||
|
private String shortName;
|
||||||
|
|
||||||
|
@Schema(description = "列表")
|
||||||
|
private List<FactorySimpleRespVO> subsidiary;
|
||||||
|
}
|
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.annotation.security.PermitAll;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工厂管理-工厂列表
|
* 工厂管理-工厂列表
|
||||||
@ -28,6 +29,7 @@ public class HikController {
|
|||||||
|
|
||||||
@GetMapping("/getCameraUrl")
|
@GetMapping("/getCameraUrl")
|
||||||
@Operation(summary = "视频播放->查询播放地址")
|
@Operation(summary = "视频播放->查询播放地址")
|
||||||
|
@PermitAll
|
||||||
public CommonResult<String> getCameraUrl(String cameraCode) {
|
public CommonResult<String> getCameraUrl(String cameraCode) {
|
||||||
String url = hikService.getPreviewUrlsApi(cameraCode, 0);
|
String url = hikService.getPreviewUrlsApi(cameraCode, 0);
|
||||||
return CommonResult.success(url);
|
return CommonResult.success(url);
|
||||||
@ -35,6 +37,7 @@ public class HikController {
|
|||||||
|
|
||||||
@GetMapping("/replayUrl")
|
@GetMapping("/replayUrl")
|
||||||
@Operation(summary = "视频播放->回放流")
|
@Operation(summary = "视频播放->回放流")
|
||||||
|
@PermitAll
|
||||||
public CommonResult<JSONObject> getReplayUrl(CameraReplayDTO cameraReplayDTO) {
|
public CommonResult<JSONObject> getReplayUrl(CameraReplayDTO cameraReplayDTO) {
|
||||||
JSONObject replayUrl = hikService.getReplayUrl(cameraReplayDTO);
|
JSONObject replayUrl = hikService.getReplayUrl(cameraReplayDTO);
|
||||||
return CommonResult.success(replayUrl);
|
return CommonResult.success(replayUrl);
|
||||||
@ -42,9 +45,10 @@ public class HikController {
|
|||||||
|
|
||||||
@GetMapping("/operate")
|
@GetMapping("/operate")
|
||||||
@Operation(summary = "视频->云台操作")
|
@Operation(summary = "视频->云台操作")
|
||||||
|
@PermitAll
|
||||||
public CommonResult<String> operate(CameraOperateDTO dto) {
|
public CommonResult<String> operate(CameraOperateDTO dto) {
|
||||||
//判断操作权限
|
//判断操作权限
|
||||||
Long cameraFactoryId = dto.getFactoryId();
|
// Long cameraFactoryId = dto.getFactoryId();
|
||||||
// Long userFactoryId = SecurityUtils.getFactoryId();
|
// Long userFactoryId = SecurityUtils.getFactoryId();
|
||||||
// if (cameraFactoryId == null || userFactoryId == null) {
|
// if (cameraFactoryId == null || userFactoryId == null) {
|
||||||
// throw new ServiceException("没有权限操控该摄像头,请联系管理员");
|
// throw new ServiceException("没有权限操控该摄像头,请联系管理员");
|
||||||
|
@ -62,11 +62,12 @@ public class FactoryScreenDataController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getFactoryOperateData")
|
@GetMapping("/getFactoryOperateData")
|
||||||
@Operation(summary = "大屏工厂运营数据 调用接口 http://znkj.ispt.com.cn/prod-api/screen/detail/dateList?factoryId=10000011")
|
@Operation(summary = "大屏工厂数据分析")
|
||||||
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
|
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public CommonResult<OperateDataRespVO> getFactoryOperateData(@RequestParam Long factoryId) {
|
public CommonResult<List<ScreenTotalDataVO>> getFactoryOperateData(@RequestParam Long factoryId) {
|
||||||
OperateDataRespVO factoryOperateDataRespVO = screenDataService.getFactoryOperateData(factoryId);
|
|
||||||
|
List<ScreenTotalDataVO> factoryOperateDataRespVO = screenDataService.getFactoryOperateData(factoryId);
|
||||||
return success(factoryOperateDataRespVO);
|
return success(factoryOperateDataRespVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ import lombok.Data;
|
|||||||
/**
|
/**
|
||||||
* 功能描述
|
* 功能描述
|
||||||
*
|
*
|
||||||
* @author: yj
|
|
||||||
* @date: 2024年03月05日 13:55
|
|
||||||
*/
|
*/
|
||||||
@Schema(description = "大屏数据 - 工厂摄像头数据 Response VO")
|
@Schema(description = "大屏数据 - 工厂摄像头数据 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ -28,9 +26,6 @@ public class FactoryCameraDataRespVO {
|
|||||||
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@Schema(description = "设备图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://xx.com/ss.jpg")
|
|
||||||
private String imgUrl ;
|
|
||||||
|
|
||||||
@Schema(description = "推流地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "ws://hik.znkj.ispt.com.cn:559/openUrl/Koe0Kg8")
|
@Schema(description = "推流地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "ws://hik.znkj.ispt.com.cn:559/openUrl/Koe0Kg8")
|
||||||
private String streamUrl ;
|
private String streamUrl ;
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "大屏工厂数据分析 VO")
|
||||||
|
@Data
|
||||||
|
public class ScreenTotalDataVO {
|
||||||
|
|
||||||
|
@Schema(description = "类型")
|
||||||
|
private Integer dateType;
|
||||||
|
|
||||||
|
@Schema(description = "入库")
|
||||||
|
private Integer inNum;
|
||||||
|
|
||||||
|
@Schema(description = "出库")
|
||||||
|
private Integer outNum;
|
||||||
|
|
||||||
|
@Schema(description = "破损")
|
||||||
|
private Integer damageNum;
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package cn.iocoder.yudao.module.smartfactory.convert.cameradevice;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraSimpleRespVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactorySimpleRespVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CameraDeviceConvert {
|
||||||
|
|
||||||
|
CameraDeviceConvert INSTANCE = Mappers.getMapper(CameraDeviceConvert.class);
|
||||||
|
|
||||||
|
default List<FactorySimpleRespVO> convertList(List<FactoryInfoDO> infoDOS, Map<Long, List<CameraDeviceDO>> cameraMap) {
|
||||||
|
|
||||||
|
return CollectionUtils.convertList(infoDOS, data -> convert(data, cameraMap.get(data.getId())));
|
||||||
|
}
|
||||||
|
|
||||||
|
default FactorySimpleRespVO convert(FactoryInfoDO infoDO, List<CameraDeviceDO> cameraDeviceDOS) {
|
||||||
|
|
||||||
|
FactorySimpleRespVO respVO = BeanUtils.toBean(infoDO, FactorySimpleRespVO.class);
|
||||||
|
|
||||||
|
List<CameraSimpleRespVO> cameraList = BeanUtils.toBean(cameraDeviceDOS, CameraSimpleRespVO.class);
|
||||||
|
|
||||||
|
return respVO.setSubsidiary(cameraList);
|
||||||
|
}
|
||||||
|
}
|
@ -54,6 +54,10 @@ public class CameraDeviceDO extends BaseDO {
|
|||||||
* 流媒体地址
|
* 流媒体地址
|
||||||
*/
|
*/
|
||||||
private String streamUrl;
|
private String streamUrl;
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
/**
|
/**
|
||||||
* 是否在大屏显示 0否 1是
|
* 是否在大屏显示 0否 1是
|
||||||
*/
|
*/
|
||||||
|
@ -23,7 +23,7 @@ public interface CameraDeviceMapper extends BaseMapperX<CameraDeviceDO> {
|
|||||||
.eqIfPresent(CameraDeviceDO::getType, reqVO.getType())
|
.eqIfPresent(CameraDeviceDO::getType, reqVO.getType())
|
||||||
.eqIfPresent(CameraDeviceDO::getStatus, reqVO.getStatus())
|
.eqIfPresent(CameraDeviceDO::getStatus, reqVO.getStatus())
|
||||||
.betweenIfPresent(CameraDeviceDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(CameraDeviceDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(CameraDeviceDO::getId));
|
.orderByAsc(CameraDeviceDO::getSort));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.smartfactory.service.device.cameradevice;
|
package cn.iocoder.yudao.module.smartfactory.service.device.cameradevice;
|
||||||
|
|
||||||
import javax.validation.*;
|
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDevicePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDeviceSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraUpdateStatusReqVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备-监控摄像头 Service 接口
|
* 设备-监控摄像头 Service 接口
|
||||||
@ -50,4 +54,23 @@ public interface CameraDeviceService {
|
|||||||
*/
|
*/
|
||||||
PageResult<CameraDeviceDO> getCameraDevicePage(CameraDevicePageReqVO pageReqVO);
|
PageResult<CameraDeviceDO> getCameraDevicePage(CameraDevicePageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定工厂下的监控摄像头列表
|
||||||
|
* @param factoryId 工厂编号
|
||||||
|
* @return 监控摄像头列表
|
||||||
|
*/
|
||||||
|
List<CameraDeviceDO> getListCameraByFactoryId(Long factoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定监控摄像头列表
|
||||||
|
* @param factoryIds 工厂编号
|
||||||
|
* @return 监控摄像头列表
|
||||||
|
*/
|
||||||
|
List<CameraDeviceDO> getListCameraList(List<Long> factoryIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新监控设备状态
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateCameraDeviceStatus(CameraUpdateStatusReqVO updateReqVO);
|
||||||
}
|
}
|
@ -4,12 +4,14 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDevicePageReqVO;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDevicePageReqVO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDeviceSaveReqVO;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraDeviceSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.device.cameradevice.vo.CameraUpdateStatusReqVO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.device.cameradevice.CameraDeviceMapper;
|
import cn.iocoder.yudao.module.smartfactory.dal.mysql.device.cameradevice.CameraDeviceMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.CAMERA_DEVICE_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.CAMERA_DEVICE_NOT_EXISTS;
|
||||||
@ -68,4 +70,25 @@ public class CameraDeviceServiceImpl implements CameraDeviceService {
|
|||||||
return cameraDeviceMapper.selectPage(pageReqVO);
|
return cameraDeviceMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CameraDeviceDO> getListCameraByFactoryId(Long factoryId) {
|
||||||
|
|
||||||
|
return cameraDeviceMapper.selectList(CameraDeviceDO::getFactoryId, factoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CameraDeviceDO> getListCameraList(List<Long> factoryIds) {
|
||||||
|
|
||||||
|
return cameraDeviceMapper.selectList(CameraDeviceDO::getFactoryId, factoryIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCameraDeviceStatus(CameraUpdateStatusReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateCameraDeviceExists(updateReqVO.getId());
|
||||||
|
|
||||||
|
// 更新
|
||||||
|
CameraDeviceDO updateObj = BeanUtils.toBean(updateReqVO, CameraDeviceDO.class);
|
||||||
|
cameraDeviceMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
}
|
}
|
@ -251,7 +251,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
|||||||
@Override
|
@Override
|
||||||
public FactoryDataTotalVO getDataTotal(Long factoryId, LocalDate[] date) {
|
public FactoryDataTotalVO getDataTotal(Long factoryId, LocalDate[] date) {
|
||||||
|
|
||||||
return dataMapper.selectDataSum(factoryId, date);
|
return dataMapper.selectDataSum(factoryId, date) == null ? new FactoryDataTotalVO() : dataMapper.selectDataSum(factoryId, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public interface ScreenDataService {
|
|||||||
* @param factoryId factoryId是null,查询所有工厂运营数据
|
* @param factoryId factoryId是null,查询所有工厂运营数据
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
OperateDataRespVO getFactoryOperateData(Long factoryId);
|
List<ScreenTotalDataVO> getFactoryOperateData(Long factoryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 大屏工厂滚屏数据查询
|
* 大屏工厂滚屏数据查询
|
||||||
|
@ -6,8 +6,11 @@ import cn.hutool.core.date.Month;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.factorydata.vo.FactoryDataTotalVO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.*;
|
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.device.cameradevice.CameraDeviceDO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factorydata.FactoryDataDO;
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factorydata.FactoryDataDO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factorydataoverview.FactoryDataOverviewDO;
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factorydataoverview.FactoryDataOverviewDO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
||||||
@ -15,16 +18,22 @@ import cn.iocoder.yudao.module.smartfactory.dal.dataobject.packagedata.PackageDa
|
|||||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.screenfactoryextra.ScreenFactoryExtraDO;
|
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.screenfactoryextra.ScreenFactoryExtraDO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.factorydataoverview.FactoryDataOverviewMapper;
|
import cn.iocoder.yudao.module.smartfactory.dal.mysql.factorydataoverview.FactoryDataOverviewMapper;
|
||||||
import cn.iocoder.yudao.module.smartfactory.framework.util.HttpUtil;
|
import cn.iocoder.yudao.module.smartfactory.framework.util.HttpUtil;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.service.device.cameradevice.CameraDeviceService;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.factorydata.FactoryDataService;
|
import cn.iocoder.yudao.module.smartfactory.service.factorydata.FactoryDataService;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.factorydataoverview.FactoryDataOverviewService;
|
import cn.iocoder.yudao.module.smartfactory.service.factorydataoverview.FactoryDataOverviewService;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.service.hik.HikService;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.packagedata.PackageDataService;
|
import cn.iocoder.yudao.module.smartfactory.service.packagedata.PackageDataService;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.screenfactoryextra.ScreenFactoryExtraService;
|
import cn.iocoder.yudao.module.smartfactory.service.screenfactoryextra.ScreenFactoryExtraService;
|
||||||
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
|
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
|
||||||
|
import jodd.util.StringUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -52,6 +61,12 @@ public class ScreenDataServiceImpl implements ScreenDataService {
|
|||||||
@Resource
|
@Resource
|
||||||
private FactoryDataOverviewMapper factoryDataOverviewMapper;
|
private FactoryDataOverviewMapper factoryDataOverviewMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CameraDeviceService cameraDeviceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private HikService hikService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProvincesDataRespVO> getProvincesData(String code) {
|
public List<ProvincesDataRespVO> getProvincesData(String code) {
|
||||||
return factoryInfoService.getProvincesData(code);
|
return factoryInfoService.getProvincesData(code);
|
||||||
@ -68,8 +83,57 @@ public class ScreenDataServiceImpl implements ScreenDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OperateDataRespVO getFactoryOperateData(Long factoryId) {
|
public List<ScreenTotalDataVO> getFactoryOperateData(Long factoryId) {
|
||||||
return null;
|
|
||||||
|
// 获取当前日期
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
// 获取本周的开始日期(周一)
|
||||||
|
LocalDate startOfWeek = currentDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
||||||
|
// 获取本周的结束日期(周日)
|
||||||
|
LocalDate endOfWeek = currentDate.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
|
||||||
|
// 获取本月的开始日期
|
||||||
|
LocalDate startOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth());
|
||||||
|
// 获取本月的结束日期
|
||||||
|
LocalDate endOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth());
|
||||||
|
|
||||||
|
// 获取今日出入库总数
|
||||||
|
FactoryDataTotalVO toDayVO = factoryDataService.getDataTotal(factoryId, new LocalDate[]{currentDate, currentDate});
|
||||||
|
// 设置今日出入数据
|
||||||
|
ScreenTotalDataVO toDayTotalDataVO = new ScreenTotalDataVO()
|
||||||
|
.setDateType(1)
|
||||||
|
.setInNum(toDayVO.getInTotal())
|
||||||
|
.setOutNum(toDayVO.getOutTotal())
|
||||||
|
.setDamageNum(toDayVO.getDamageNum());
|
||||||
|
|
||||||
|
// 获取昨日出入库总数
|
||||||
|
FactoryDataTotalVO yesterdayVO = factoryDataService.getDataTotal(factoryId,
|
||||||
|
new LocalDate[]{currentDate.minusDays(1), currentDate.minusDays(1)});
|
||||||
|
// 设置昨日出入数据
|
||||||
|
ScreenTotalDataVO yesterdayTotalDataVO = new ScreenTotalDataVO()
|
||||||
|
.setDateType(2)
|
||||||
|
.setInNum(yesterdayVO.getInTotal())
|
||||||
|
.setOutNum(yesterdayVO.getOutTotal())
|
||||||
|
.setDamageNum(yesterdayVO.getDamageNum());
|
||||||
|
|
||||||
|
// 获取本周出入库总数
|
||||||
|
FactoryDataTotalVO weekVO = factoryDataService.getDataTotal(factoryId, new LocalDate[]{startOfWeek, endOfWeek});
|
||||||
|
// 设置本周出入数据
|
||||||
|
ScreenTotalDataVO weekTotalDataVO = new ScreenTotalDataVO()
|
||||||
|
.setDateType(3)
|
||||||
|
.setInNum(weekVO.getInTotal())
|
||||||
|
.setOutNum(weekVO.getOutTotal())
|
||||||
|
.setDamageNum(weekVO.getDamageNum());
|
||||||
|
|
||||||
|
// 获取本月出入库总数
|
||||||
|
FactoryDataTotalVO monthVO = factoryDataService.getDataTotal(factoryId, new LocalDate[]{startOfMonth, endOfMonth});
|
||||||
|
// 设置本月出入数据
|
||||||
|
ScreenTotalDataVO monthTotalDataVO = new ScreenTotalDataVO()
|
||||||
|
.setDateType(4)
|
||||||
|
.setInNum(monthVO.getInTotal())
|
||||||
|
.setOutNum(monthVO.getOutTotal())
|
||||||
|
.setDamageNum(monthVO.getDamageNum());
|
||||||
|
|
||||||
|
return Arrays.asList(toDayTotalDataVO, yesterdayTotalDataVO, weekTotalDataVO, monthTotalDataVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,7 +143,16 @@ public class ScreenDataServiceImpl implements ScreenDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FactoryCameraDataRespVO> getFactoryCamerasData(Long factoryId) {
|
public List<FactoryCameraDataRespVO> getFactoryCamerasData(Long factoryId) {
|
||||||
return null;
|
|
||||||
|
List<CameraDeviceDO> cameraDeviceDOS = cameraDeviceService.getListCameraByFactoryId(factoryId);
|
||||||
|
cameraDeviceDOS.forEach(data -> {
|
||||||
|
|
||||||
|
String url = hikService.getPreviewUrlsApi(data.getCode(), 1);
|
||||||
|
if (!StringUtil.isEmpty(url)) {
|
||||||
|
data.setStreamUrl(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return BeanUtils.toBean(cameraDeviceDOS, FactoryCameraDataRespVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -316,33 +389,34 @@ public class ScreenDataServiceImpl implements ScreenDataService {
|
|||||||
public ObtainFactoryInboundAndOutboundStatusVO getObtainFactoryInboundAndOutboundStatus(Long factoryId) {
|
public ObtainFactoryInboundAndOutboundStatusVO getObtainFactoryInboundAndOutboundStatus(Long factoryId) {
|
||||||
ObtainFactoryInboundAndOutboundStatusVO vo = new ObtainFactoryInboundAndOutboundStatusVO();
|
ObtainFactoryInboundAndOutboundStatusVO vo = new ObtainFactoryInboundAndOutboundStatusVO();
|
||||||
|
|
||||||
Date today = new Date();
|
// 获取当前日期
|
||||||
//本日打包数
|
LocalDate currentDate = LocalDate.now();
|
||||||
Date beginDay = DateUtil.beginOfDay(today);
|
// 获取本月的开始日期
|
||||||
Date endDay = DateUtil.endOfDay(today);
|
LocalDate startOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth());
|
||||||
|
// 获取本月的结束日期
|
||||||
|
LocalDate endOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth());
|
||||||
|
|
||||||
List<FactoryDataDO> dayList = factoryDataService.getByTimeAndFactoryId(factoryId, beginDay, endDay);
|
// 获取今日出入库总数
|
||||||
Integer outTotalNum = dayList.stream().filter(a -> a.getDataType() == 1).mapToInt(FactoryDataDO::getTotalNum).sum();
|
FactoryDataTotalVO toDayVO = factoryDataService.getDataTotal(factoryId, new LocalDate[]{currentDate, currentDate});
|
||||||
Integer inTotalNum = dayList.stream().filter(a -> a.getDataType() == 2).mapToInt(FactoryDataDO::getTotalNum).sum();
|
vo.setOutToday(toDayVO.getOutTotal());
|
||||||
vo.setOutToday(outTotalNum);
|
vo.setInToday(toDayVO.getInTotal());
|
||||||
vo.setInToday(inTotalNum);
|
|
||||||
|
|
||||||
//本月打包數
|
//本月打包數
|
||||||
Date beginMonth = DateUtil.beginOfMonth(today);
|
FactoryDataTotalVO monthVO = factoryDataService.getDataTotal(factoryId, new LocalDate[]{startOfMonth, endOfMonth});
|
||||||
Date endMonth = DateUtil.endOfMonth(today);
|
vo.setOutMonth(monthVO.getOutTotal());
|
||||||
List<FactoryDataDO> monthList = factoryDataService.getByTimeAndFactoryId(factoryId, beginMonth, endMonth);
|
vo.setInMonth(monthVO.getInTotal());
|
||||||
Integer outMonthNum = monthList.stream().filter(a -> a.getDataType() == 1).mapToInt(FactoryDataDO::getTotalNum).sum();
|
|
||||||
Integer inMonthNum = monthList.stream().filter(a -> a.getDataType() == 2).mapToInt(FactoryDataDO::getTotalNum).sum();
|
|
||||||
vo.setOutMonth(outMonthNum);
|
|
||||||
vo.setInMonth(inMonthNum);
|
|
||||||
Random random = new Random();
|
|
||||||
int randomNumber = random.nextInt(21); // 生成0到20之间的随机数
|
|
||||||
vo.setDamagedTotal(randomNumber);
|
|
||||||
|
|
||||||
random = new Random();
|
// 获取昨日出入库总数
|
||||||
double increaseCompared = (random.nextDouble() * 4) - 2; // 生成-2到2之间的随机数
|
FactoryDataTotalVO yesterdayVO = factoryDataService.getDataTotal(factoryId,
|
||||||
increaseCompared = Math.round(increaseCompared * 100.0) / 100.0; // 保留两位小数
|
new LocalDate[]{currentDate.minusDays(1), currentDate.minusDays(1)});
|
||||||
|
|
||||||
|
// 设置今日破损数
|
||||||
|
vo.setDamagedTotal(toDayVO.getDamageNum());
|
||||||
|
|
||||||
|
// 设置同昨日比较 百分比
|
||||||
|
double increaseCompared = Math.round(toDayVO.getDamageNum() - yesterdayVO.getDamageNum() * 100.0) / 100.0; // 保留两位小数
|
||||||
vo.setIncreaseCompared(increaseCompared);
|
vo.setIncreaseCompared(increaseCompared);
|
||||||
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user