基础管理调试

This commit is contained in:
mashuai 2024-09-19 11:04:18 +08:00
parent 9385f88ae4
commit 3b608b044c
16 changed files with 192 additions and 69 deletions

View File

@ -71,5 +71,8 @@ public class TbBdDeviceRecord implements Serializable {
@Size(max = 128,message = "负责人电话-sm4加密最大长度要小于 128")
private String devUserPhone;
@ApiModelProperty(value="工程id")
private Long proId;
private static final long serialVersionUID = 1L;
}

View File

@ -27,9 +27,15 @@ public class TbDevice implements Serializable {
* 设备类型(码表)
*/
@ApiModelProperty(value="设备类型(码表)")
@Excel(name = "设备类型")
private String devType;
/**
* 设备类型(码表)
*/
@ApiModelProperty(value="设备类型名称")
@Excel(name = "设备类型")
private String devTypeName;
/**
* 设备编码(唯一)
*/

View File

@ -35,7 +35,7 @@ public interface TbBdDeviceRecordMapper {
int updateById(Long id);
TbBdDeviceRecord selectByName(TbBdDeviceRecord deviceRecord);
List<TbBdDeviceRecord> selectByName(TbBdDeviceRecord deviceRecord);
/**
* 边带设备管理信息列表

View File

@ -1,10 +1,7 @@
package com.bonus.base.mapper;
import com.bonus.base.domain.TbBdDeviceRecord;
import com.bonus.base.domain.TbBdRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;

View File

@ -55,7 +55,7 @@ public interface TbDeviceMapper {
* @param record
* @return
*/
TbDevice selectByDevCode(TbDevice record);
List<TbDevice> selectByDevCode(TbDevice record);
/**
* 根据主键查询

View File

@ -1,7 +1,8 @@
package com.bonus.base.service.impl;
import com.bonus.base.vo.TbBdDeviceVo;
import com.bonus.base.vo.TbDeviceVo;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
@ -73,7 +74,15 @@ public class TbBdDeviceRecordServiceImpl implements TbBdDeviceRecordService{
*/
@Override
public List<TbBdDeviceVo> getDeviceList(TbBdDeviceVo tbBdDeviceVo) {
return tbBdDeviceRecordMapper.getDeviceList(tbBdDeviceVo);
List<TbBdDeviceVo> deviceList = tbBdDeviceRecordMapper.getDeviceList(tbBdDeviceVo);
if (deviceList != null && deviceList.size() > 0) {
for (TbBdDeviceVo bdDeviceVo : deviceList) {
if (StringUtils.isNotBlank(bdDeviceVo.getDevUserPhone())) {
bdDeviceVo.setDevUserPhone(Sm4Utils.decode(bdDeviceVo.getDevUserPhone()));
}
}
}
return deviceList;
}

View File

@ -16,6 +16,7 @@ import com.bonus.base.domain.TbBdRecord;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.bonus.base.mapper.TbBdRecordMapper;
@ -72,15 +73,16 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{
if (record.getRecordList() != null && record.getRecordList().size() > 0) {
for (TbBdDeviceRecord deviceRecord : record.getRecordList()) {
deviceRecord.setRecordId(record.getId());
deviceRecord.setProId(record.getProId());
if (StringUtils.isNotBlank(deviceRecord.getDevUserPhone())) {
deviceRecord.setDevUserPhone(Sm4Utils.encode(deviceRecord.getDevUserPhone()));
}
//根据设备名称或编码唯一校验
TbBdDeviceRecord tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(deviceRecord);
if (tbBdDeviceRecord != null) {
return AjaxResult.error(tbBdDeviceRecord.getDevName() + "设备名称或编码重复,请勿重复添加");
List<TbBdDeviceRecord> tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(deviceRecord);
if (CollectionUtils.isNotEmpty(tbBdDeviceRecord)) {
return AjaxResult.error("设备名称或编码与库中重复,请勿重复添加");
}
result += tbBdDeviceRecordMapper.insert(deviceRecord);
result += tbBdDeviceRecordMapper.insertSelective(deviceRecord);
}
}
if (result > 0) {
@ -120,10 +122,22 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{
}
//校验内层设备名称或编码重复性
if (record.getRecordList() != null && record.getRecordList().size() > 0) {
// 检查设备名称是否重复
long distinctNames = record.getRecordList().stream().map(TbBdDeviceRecord::getDevName).distinct().count();
if (distinctNames < record.getRecordList().size()) {
return AjaxResult.error("提交的数据中设备名称存在重复,请勿重复添加");
}
// 检查设备编码是否重复
long distinctCodes = record.getRecordList().stream().map(TbBdDeviceRecord::getDevCode).distinct().count();
if (distinctCodes < record.getRecordList().size()) {
return AjaxResult.error("提交的数据中设备编码存在重复,请勿重复添加");
}
for (TbBdDeviceRecord deviceRecord : record.getRecordList()) {
TbBdDeviceRecord tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(deviceRecord);
if (tbBdDeviceRecord != null && !tbBdDeviceRecord.getRecordId().equals(deviceRecord.getId())) {
return AjaxResult.error(tbBdDeviceRecord.getDevName() + "设备名称或编码重复,请勿重复添加");
List<TbBdDeviceRecord> tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(deviceRecord);
if (CollectionUtils.isNotEmpty(tbBdDeviceRecord)) {
if (tbBdDeviceRecord.size() > 1) {
return AjaxResult.error("设备名称或编码与库中重复,请勿重复添加");
}
}
}
}
@ -140,10 +154,11 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{
if (record.getRecordList() != null && record.getRecordList().size() > 0) {
for (TbBdDeviceRecord deviceRecord : record.getRecordList()) {
deviceRecord.setRecordId(record.getId());
deviceRecord.setProId(record.getProId());
if (StringUtils.isNotBlank(deviceRecord.getDevUserPhone())) {
deviceRecord.setDevUserPhone(Sm4Utils.encode(deviceRecord.getDevUserPhone()));
}
result += tbBdDeviceRecordMapper.insert(deviceRecord);
result += tbBdDeviceRecordMapper.insertSelective(deviceRecord);
}
}
if (result > 0) {

View File

@ -1,5 +1,6 @@
package com.bonus.base.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.base.config.ExceptionEnum;
import com.bonus.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Service;
@ -7,6 +8,8 @@ import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Objects;
import com.bonus.base.mapper.TbDeviceMapper;
import com.bonus.base.domain.TbDevice;
import com.bonus.base.service.TbDeviceService;
@ -32,10 +35,10 @@ public class TbDeviceServiceImpl implements TbDeviceService{
@Override
public AjaxResult insertSelective(TbDevice record) {
//根据传入的devCode判重确保唯一性
TbDevice tbDevice = tbDeviceMapper.selectByDevCode(record);
if (tbDevice != null) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), "设备编码与库中重复");
//根据传入的名称和编码判重确保唯一性同类型下名称或编码均不得重复
List<TbDevice> tbDevice = tbDeviceMapper.selectByDevCode(record);
if (CollectionUtils.isNotEmpty(tbDevice)) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), "设备名称或编码与库中重复");
}
int result = tbDeviceMapper.insertSelective(record);
if (result > 0) {
@ -51,10 +54,12 @@ public class TbDeviceServiceImpl implements TbDeviceService{
@Override
public AjaxResult updateByPrimaryKeySelective(TbDevice record) {
//根据传入的devCode判重确保唯一性
TbDevice tbDevice = tbDeviceMapper.selectByDevCode(record);
if (tbDevice != null && !tbDevice.getId().equals(record.getId())) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), "设备编码与库中重复");
//根据传入的名称和编码判重确保唯一性,同类型下名称或编码均不得重复
List<TbDevice> tbDevice = tbDeviceMapper.selectByDevCode(record);
if (tbDevice != null) {
if (tbDevice.size() > 1) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), "设备名称或编码与库中重复");
}
}
int result = tbDeviceMapper.updateByPrimaryKeySelective(record);
if (result > 0) {

View File

@ -29,6 +29,7 @@ import java.io.OutputStream;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
/**
@ -154,9 +155,11 @@ public class TbPeopleServiceImpl implements TbPeopleService {
}
//同名同身份证号判重
TbPeople people = tbPeopleDao.queryByName(tbPeople);
if (people != null && !people.getId().equals(tbPeople.getId())) {
if (people != null) {
if (!Objects.equals(people.getId(), tbPeople.getId())) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg());
}
}
tbPeople.setUpdateUser(SecurityUtils.getUserId());
tbPeople.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
int result = tbPeopleDao.update(tbPeople);

View File

@ -21,6 +21,7 @@ import javax.annotation.Resource;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 项目部(TbProDepart)表服务实现类
@ -131,9 +132,11 @@ public class TbProDepartServiceImpl implements TbProDepartService {
}
//名称重复性校验一个地区内不能重复
TbProDepart depart = tbProDepartDao.selectByName(tbProDepart);
if (depart != null && !depart.getId().equals(tbProDepart.getId())) {
if (depart != null) {
if (!Objects.equals(depart.getId(), tbProDepart.getId())) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg());
}
}
if (getObjectResultBean(tbProDepart)) {
return AjaxResult.error(ExceptionEnum.INVALID_PHONE_NUMBER_FORMAT.getCode(), ExceptionEnum.INVALID_PHONE_NUMBER_FORMAT.getMsg());
}

View File

@ -24,6 +24,7 @@ import java.io.OutputStream;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 工程杆塔表(TbProPower)表服务实现类
@ -105,9 +106,11 @@ public class TbProPowerServiceImpl implements TbProPowerService {
}
//根据名称判重
TbProPower power = tbProPowerDao.selectByName(tbProPower);
if (power != null && !power.getId().equals(tbProPower.getId())) {
if (power != null) {
if (!Objects.equals(power.getId(), tbProPower.getId())) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg());
}
}
int result = tbProPowerDao.update(tbProPower);
if (result > 0) {
return AjaxResult.success(ExceptionEnum.SUCCESS);

View File

@ -17,6 +17,7 @@ import javax.annotation.Resource;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -100,9 +101,11 @@ public class TbProjectServiceImpl implements TbProjectService {
}
//工程名称判重
TbProjectVo project = tbProjectDao.selectByName(tbProject);
if (project != null && !project.getId().equals(tbProject.getId())) {
if (project != null) {
if (!Objects.equals(project.getId(), tbProject.getId())) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg());
}
}
tbProject.setUpdateUser(SecurityUtils.getUserId());
int result = tbProjectDao.update(tbProject);
if (result > 0) {

View File

@ -9,6 +9,8 @@ import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Objects;
import com.bonus.base.mapper.TbWarnConfigMapper;
import com.bonus.base.service.TbWarnConfigService;
/**
@ -73,9 +75,11 @@ public class TbWarnConfigServiceImpl implements TbWarnConfigService{
}
//根据同类型同名称规则判重
TbWarnConfig tbWarnConfig = tbWarnConfigMapper.selectByName(record);
if (tbWarnConfig != null && !tbWarnConfig.getId().equals(record.getId())) {
if (tbWarnConfig != null) {
if (!Objects.equals(tbWarnConfig.getId(), record.getId())) {
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg());
}
}
record.setUpdateUser(SecurityUtils.getUserId().intValue());
int result = tbWarnConfigMapper.updateByPrimaryKeySelective(record);
if (result > 0) {

View File

@ -35,18 +35,15 @@
<!--@mbg.generated-->
insert into tb_bd_device_record (record_id, dev_name,
dev_code, unit_name, area_name,
dev_user, dev_user_phone)
dev_user, dev_user_phone, pro_id)
values (#{recordId,jdbcType=BIGINT}, #{devName,jdbcType=VARCHAR},
#{devCode,jdbcType=VARCHAR}, #{unitName,jdbcType=VARCHAR}, #{areaName,jdbcType=VARCHAR},
#{devUser,jdbcType=VARCHAR}, #{devUserPhone,jdbcType=VARCHAR})
#{devUser,jdbcType=VARCHAR}, #{devUserPhone,jdbcType=VARCHAR}, #{proId})
</insert>
<insert id="insertSelective" parameterType="com.bonus.base.domain.TbBdDeviceRecord">
<!--@mbg.generated-->
insert into tb_bd_device_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="recordId != null">
record_id,
</if>
@ -68,34 +65,38 @@
<if test="devUserPhone != null and devUserPhone != ''">
dev_user_phone,
</if>
<if test="proId != null and proId != ''">
pro_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="recordId != null">
#{recordId,jdbcType=BIGINT},
#{recordId},
</if>
<if test="devName != null and devName != ''">
#{devName,jdbcType=VARCHAR},
#{devName},
</if>
<if test="devCode != null and devCode != ''">
#{devCode,jdbcType=VARCHAR},
#{devCode},
</if>
<if test="unitName != null and unitName != ''">
#{unitName,jdbcType=VARCHAR},
#{unitName},
</if>
<if test="areaName != null and areaName != ''">
#{areaName,jdbcType=VARCHAR},
#{areaName},
</if>
<if test="devUser != null and devUser != ''">
#{devUser,jdbcType=VARCHAR},
#{devUser},
</if>
<if test="devUserPhone != null and devUserPhone != ''">
#{devUserPhone,jdbcType=VARCHAR},
#{devUserPhone},
</if>
<if test="proId != null and proId != ''">
#{proId},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.base.domain.TbBdDeviceRecord">
<!--@mbg.generated-->
update tb_bd_device_record
@ -213,11 +214,18 @@
from tb_bd_device_record
where 1=1
<if test="devName != null and devName != ''">
<if test="devCode != null and devCode != ''">
and (dev_name = #{devName} or dev_code = #{devCode})
</if>
<if test="devCode == null or devCode == ''">
and dev_name = #{devName}
</if>
</if>
<if test="devName == null or devName == ''">
<if test="devCode != null and devCode != ''">
and dev_code = #{devCode}
</if>
</if>
</select>
<select id="getDeviceList" resultType="com.bonus.base.vo.TbBdDeviceVo">

View File

@ -55,21 +55,21 @@
<if test="auditStatus != null and auditStatus != ''">
and tbr.audit_status = #{auditStatus}
</if>
GROUP BY tbr.id
</select>
<select id="selectByName" resultType="com.bonus.base.domain.TbBdRecord">
select
tbr.id as id, tbr.depart_id as departId, tbr.depart_name as departName, tbr.pro_id as proId, tbr.pro_name as
proName, tbr.rel_user as relUser, tbr.rel_phone as relPhone, tbr.create_time as createTime,
tbr.audit_status as auditStatus,tbr.remarks as remarks, tbr.audit_user as auditUser, tbr.audit_time as auditTime
from tb_bd_record tbr
left join tb_bd_device_record tbd on tbd.record_id = tbr.id
id as id, depart_id as departId, depart_name as departName, pro_id as proId, pro_name as
proName, rel_user as relUser, rel_phone as relPhone, create_time as createTime,
audit_status as auditStatus,remarks as remarks, audit_user as auditUser, audit_time as auditTime
from tb_bd_record
where del_flag = 0
<if test="departId != null">
and tbr.depart_id = #{departId}
and depart_id = #{departId}
</if>
<if test="proId != null">
and tbr.pro_id = #{proId}
and pro_id = #{proId}
</if>
</select>

View File

@ -15,11 +15,13 @@
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="logo_url" jdbcType="VARCHAR" property="logoUrl" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, dev_type, dev_code, dev_name, bd_id, config_id, dev_status, dev_warn, del_flag,
logo_url
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
@ -27,10 +29,12 @@
from tb_device
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
update tb_device set del_flag = 1
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.bonus.base.domain.TbDevice">
<!--@mbg.generated-->
insert into tb_device (id, dev_type, dev_code,
@ -106,6 +110,7 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.base.domain.TbDevice">
<!--@mbg.generated-->
update tb_device
@ -140,6 +145,7 @@
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.bonus.base.domain.TbDevice">
<!--@mbg.generated-->
update tb_device
@ -154,16 +160,7 @@
logo_url = #{logoUrl,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getAll" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from tb_device
where del_flag = 0
</select>
<select id="selectByDevCode" resultType="com.bonus.base.domain.TbDevice">
select * from tb_device where dev_code = #{devCode}
</select>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update tb_device
@ -245,4 +242,71 @@
from tb_device
where del_flag = 0
</select>
<select id="getAll" resultType="com.bonus.base.domain.TbDevice">
SELECT
td.id as id,
td.dev_type as devType,
sda.dict_label as devTypeName,
td.dev_code as devCode,
td.dev_name as devName,
td.bd_id as bdId,
t1.dev_name as bdName,
td.config_id as configId,
t2.config_name as configName,
td.dev_status as devStatus,
CASE
WHEN td.dev_status = 0 THEN
'离线'
WHEN td.dev_status = 1 THEN
'在线'
ELSE
'未知状态'
END devStatusName,
td.dev_warn as devWarn,
td.del_flag as delFlag,
td.logo_url as logoUrl
FROM
tb_device td
LEFT JOIN sys_dict_data sda ON td.dev_type = sda.dict_code
LEFT JOIN tb_bd_device_record t1 on td.bd_id = t1.id
LEFT JOIN tb_warn_config t2 on t2.id = td.config_id and t2.del_flag = 0
WHERE
td.del_flag = 0
<if test="devType != null and devType != ''">
and td.dev_type = #{devType}
</if>
<if test="devName != null and devName != ''">
and td.dev_name like concat('%',#{devName},'%')
</if>
<if test="devCode != null and devCode != ''">
and td.dev_code like concat('%',#{devCode},'%')
</if>
<if test="devStatus != null and devStatus != ''">
and td.dev_status = #{devStatus}
</if>
</select>
<select id="selectByDevCode" resultType="com.bonus.base.domain.TbDevice">
select
<include refid="Base_Column_List" />
from tb_device
where 1=1
<if test="devName != null and devName != ''">
<if test="devCode != null and devCode != ''">
and (dev_name = #{devName} or dev_code = #{devCode})
</if>
<if test="devCode == null or devCode == ''">
and dev_name = #{devName}
</if>
</if>
<if test="devName == null or devName == ''">
<if test="devCode != null and devCode != ''">
and dev_code = #{devCode}
</if>
</if>
<if test="devType != null and devType != ''">
and dev_type = #{devType}
</if>
</select>
</mapper>