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