修改解密返回参数、设备添加字段修改
This commit is contained in:
parent
c025df74c8
commit
ee4ea188b9
|
|
@ -38,6 +38,9 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
@Value("${system.jie-enable}")
|
@Value("${system.jie-enable}")
|
||||||
public boolean jaData;
|
public boolean jaData;
|
||||||
|
|
||||||
|
@Value("${system.jia-enable}")
|
||||||
|
public boolean jiData;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ValidateCodeService validateCodeService;
|
private ValidateCodeService validateCodeService;
|
||||||
|
|
||||||
|
|
@ -63,7 +66,10 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String rspStr = resolveBodyFromRequest(request);
|
String rspStr = resolveBodyFromRequest(request);
|
||||||
rspStr= AesCbcUtils.decrypt(rspStr);
|
if(jiData){
|
||||||
|
rspStr= AesCbcUtils.decrypt(rspStr);
|
||||||
|
}
|
||||||
|
|
||||||
if(StringUtils.isEmpty(rspStr)){
|
if(StringUtils.isEmpty(rspStr)){
|
||||||
throw new CaptchaException("请求参数异常");
|
throw new CaptchaException("请求参数异常");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ public class DeviceInformationController extends BaseController {
|
||||||
if(!ditService.checkDeviceNameUnique(bean)){
|
if(!ditService.checkDeviceNameUnique(bean)){
|
||||||
return error("设备名称不能重复!");
|
return error("设备名称不能重复!");
|
||||||
}
|
}
|
||||||
return toAjax(ditService.addDeviceInformation(bean));
|
AjaxResult ajaxResult=ditService.addDeviceInformation(bean);
|
||||||
|
return ajaxResult;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.toString(), e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +88,8 @@ public class DeviceInformationController extends BaseController {
|
||||||
if(!ditService.checkDeviceNameUnique(bean)){
|
if(!ditService.checkDeviceNameUnique(bean)){
|
||||||
return error("设备名称不能重复!");
|
return error("设备名称不能重复!");
|
||||||
}
|
}
|
||||||
return toAjax(ditService.updateDeviceInformation(bean));
|
AjaxResult ajaxResult=ditService.updateDeviceInformation(bean);
|
||||||
|
return ajaxResult;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.toString(), e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ public class DeviceInformation extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String deviceId;
|
private String deviceId;
|
||||||
|
|
||||||
|
private String typeCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*设备名称
|
*设备名称
|
||||||
*/
|
*/
|
||||||
|
|
@ -37,6 +39,10 @@ public class DeviceInformation extends BaseEntity {
|
||||||
* 设备类型
|
* 设备类型
|
||||||
*/
|
*/
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
*/
|
||||||
|
private int deviceStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型名称
|
* 设备类型名称
|
||||||
|
|
|
||||||
|
|
@ -65,4 +65,6 @@ public interface DeviceInformationMapper {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int updateDeviceCode(DeviceInformation bean);
|
int updateDeviceCode(DeviceInformation bean);
|
||||||
|
|
||||||
|
int getDeviceIdByPuid(DeviceInformation bean);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.project.service;
|
package com.bonus.project.service;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.project.domain.DeviceInformation;
|
import com.bonus.project.domain.DeviceInformation;
|
||||||
import com.bonus.project.domain.DeviceType;
|
import com.bonus.project.domain.DeviceType;
|
||||||
|
|
||||||
|
|
@ -24,7 +25,7 @@ public interface DeviceInformationService {
|
||||||
* @param bean 设备信息实体
|
* @param bean 设备信息实体
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int addDeviceInformation(DeviceInformation bean);
|
AjaxResult addDeviceInformation(DeviceInformation bean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设备信息
|
* 修改设备信息
|
||||||
|
|
@ -32,7 +33,7 @@ public interface DeviceInformationService {
|
||||||
* @param bean 设备信息实体
|
* @param bean 设备信息实体
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int updateDeviceInformation(DeviceInformation bean);
|
AjaxResult updateDeviceInformation(DeviceInformation bean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除设备信息
|
* 删除设备信息
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,12 @@ package com.bonus.project.service.impl;
|
||||||
|
|
||||||
import com.bonus.common.core.constant.UserConstants;
|
import com.bonus.common.core.constant.UserConstants;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.project.domain.DeviceInformation;
|
import com.bonus.project.domain.DeviceInformation;
|
||||||
import com.bonus.project.mapper.DeviceInformationMapper;
|
import com.bonus.project.mapper.DeviceInformationMapper;
|
||||||
import com.bonus.project.service.DeviceInformationService;
|
import com.bonus.project.service.DeviceInformationService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -20,6 +22,7 @@ import java.util.UUID;
|
||||||
* @date 2024-07-11
|
* @date 2024-07-11
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class DeviceInformationServiceImpl implements DeviceInformationService {
|
public class DeviceInformationServiceImpl implements DeviceInformationService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -45,33 +48,34 @@ public class DeviceInformationServiceImpl implements DeviceInformationService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int addDeviceInformation(DeviceInformation bean) {
|
public AjaxResult addDeviceInformation(DeviceInformation bean) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
try {
|
try {
|
||||||
// 使用UUID改进设备编号生成机制
|
// 使用UUID改进设备编号生成机制
|
||||||
String uniquePartOfDeviceCode = UUID.randomUUID().toString().replace("-", "").substring(0, 3);
|
String uniquePartOfDeviceCode = UUID.randomUUID().toString().replace("-", "").substring(0, 3);
|
||||||
bean.setDeviceCode(bean.getDeviceTypeName() + "-" + uniquePartOfDeviceCode);
|
bean.setDeviceCode(bean.getDeviceTypeName() + "-" + uniquePartOfDeviceCode);
|
||||||
|
|
||||||
// 设置创建者和创建ID
|
// 设置创建者和创建ID
|
||||||
bean.setCreateUser(SecurityUtils.getUsername());
|
bean.setCreateUser(SecurityUtils.getUsername());
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
bean.setCreateId(userId.toString());
|
bean.setCreateId(userId.toString());
|
||||||
code = ditMapper.addDeviceType(bean);
|
int nums=ditMapper.getDeviceIdByPuid(bean);
|
||||||
if (code == 0){
|
if(nums>0){
|
||||||
throw new RuntimeException("新增设备信息失败");
|
return AjaxResult.error("设备puId与摄像头已存在");
|
||||||
}
|
}
|
||||||
String id = String.format("%03d", Integer.parseInt(bean.getDeviceId()));
|
code = ditMapper.addDeviceType(bean);
|
||||||
bean.setDeviceCode(bean.getDeviceTypeName() + "-" + id);
|
if (code >0){
|
||||||
code = ditMapper.updateDeviceCode(bean);
|
String id = String.format("%03d", Integer.parseInt(bean.getDeviceId()));
|
||||||
if (code == 0){
|
bean.setDeviceCode(bean.getDeviceTypeName() + "-" + id);
|
||||||
throw new RuntimeException("修改设备编码失败");
|
code = ditMapper.updateDeviceCode(bean);
|
||||||
|
if (code == 0){
|
||||||
|
return AjaxResult.error("修改设备编码失败");
|
||||||
|
}
|
||||||
|
return AjaxResult.success("新增成功");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("新增设备信息失败");
|
log.error(e.toString(),e);
|
||||||
}
|
}
|
||||||
|
return AjaxResult.error("新增设备失败");
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -81,8 +85,20 @@ public class DeviceInformationServiceImpl implements DeviceInformationService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateDeviceInformation(DeviceInformation bean) {
|
public AjaxResult updateDeviceInformation(DeviceInformation bean) {
|
||||||
return ditMapper.updateDeviceInformation(bean);
|
try{
|
||||||
|
int nums=ditMapper.getDeviceIdByPuid(bean);
|
||||||
|
if(nums>0){
|
||||||
|
return AjaxResult.error("设备puId与摄像头已存在");
|
||||||
|
}
|
||||||
|
int num= ditMapper.updateDeviceInformation(bean);
|
||||||
|
if(num>0){
|
||||||
|
return AjaxResult.success("修改成功");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return AjaxResult.error("修改失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<mapper namespace="com.bonus.project.mapper.DeviceInformationMapper">
|
<mapper namespace="com.bonus.project.mapper.DeviceInformationMapper">
|
||||||
<insert id="addDeviceType" useGeneratedKeys="true" keyProperty="deviceId">
|
<insert id="addDeviceType" useGeneratedKeys="true" keyProperty="deviceId">
|
||||||
INSERT INTO pf_device_info (device_code, device_name, device_type, device_model, device_user, device_phone,
|
INSERT INTO pf_device_info (device_code, device_name, device_type, device_model, device_user, device_phone,
|
||||||
create_id, create_user, create_time, is_active,puid,ball_index)
|
create_id, create_user, create_time, is_active,puid,ball_index,type_code,device_status)
|
||||||
VALUES (#{deviceCode}, #{deviceName}, #{deviceType}, #{deviceModel}, #{deviceUser}, #{devicePhone},
|
VALUES (#{deviceCode}, #{deviceName}, #{deviceType}, #{deviceModel}, #{deviceUser}, #{devicePhone},
|
||||||
#{createId}, #{createUser}, now(), '1',#{puid},#{ballIndex})
|
#{createId}, #{createUser}, now(), '1',#{puid},#{ballIndex},#{typeCode},#{deviceStatus})
|
||||||
</insert>
|
</insert>
|
||||||
<update id="updateDeviceInformation">
|
<update id="updateDeviceInformation">
|
||||||
UPDATE pf_device_info SET
|
UPDATE pf_device_info SET
|
||||||
|
|
@ -16,7 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
device_phone = #{devicePhone},
|
device_phone = #{devicePhone},
|
||||||
puid = #{puid},
|
puid = #{puid},
|
||||||
ball_index = #{ballIndex},
|
ball_index = #{ballIndex},
|
||||||
update_time = now()
|
update_time = now(),
|
||||||
|
type_code=#{typeCode},
|
||||||
|
device_status=#{deviceStatus}
|
||||||
WHERE device_id = #{deviceId}
|
WHERE device_id = #{deviceId}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateDeviceCode">
|
<update id="updateDeviceCode">
|
||||||
|
|
@ -41,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
pdi.device_phone AS devicePhone,
|
pdi.device_phone AS devicePhone,
|
||||||
pdi.create_user AS createUser,
|
pdi.create_user AS createUser,
|
||||||
pdi.create_time AS createTime,
|
pdi.create_time AS createTime,
|
||||||
pdi.puid,
|
pdi.puid,pdi.type_code typeCode,
|
||||||
pdi.ball_index as ballIndex,
|
pdi.ball_index as ballIndex,
|
||||||
if(ppi.pro_name IS NULL, '无', ppi.pro_name) AS proName
|
if(ppi.pro_name IS NULL, '无', ppi.pro_name) AS proName
|
||||||
FROM
|
FROM
|
||||||
|
|
@ -87,4 +89,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{deviceId}
|
#{deviceId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getDeviceIdByPuid" resultType="java.lang.Integer">
|
||||||
|
select count(1)
|
||||||
|
from pf_device_info
|
||||||
|
where is_active=1 and puid=#{puid} and ball_index=#{ballIndex}
|
||||||
|
<if test="deviceId!=null and deviceId!=''">
|
||||||
|
and device_id!=#{deviceId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue