接口联调

This commit is contained in:
mashuai 2024-09-26 15:52:11 +08:00
parent b14a26fc59
commit 796736ead7
20 changed files with 96 additions and 318 deletions

View File

@ -23,6 +23,7 @@ public enum ExceptionEnum {
UN_BIND_TO_DATABASE(500, "解散失败,请联系管理员"),
EXISTENCE_OF_MEMBERS(1005, "班组中还存在成员,无法解散"),
EXISTENCE_OF_HELMET(1008, "该班组人员绑定相关安全帽,无法解散"),
DELETE_BIND_DEVICE(1010, "该设备还绑定相关人员,无法删除"),
EXISTENCE_OF_BIND(1006, "该人员还绑定相关设备,无法移出"),
UPDATE_TO_DATABASE(500, "修改失败,请联系管理员"),
BIND_TO_DATABASE(500, "人员设备绑定失败,请联系管理员"),

View File

@ -99,5 +99,7 @@ public class TbPeople implements Serializable {
*/
private String devName;
private Long relId;
}

View File

@ -95,5 +95,10 @@ public class TbProject implements Serializable {
*/
private Long updateUser;
/**
* 工程编码
*/
private String proCode;
}

View File

@ -76,4 +76,11 @@ public interface TbDeviceMapper {
DeviceTypeEnum leadStrainMonitor);
List<DeviceWarnRecordVo> getDeviceModelDetailsPage(TbDevice tbDevice);
/**
* 根据主键查询是否被人员绑定
* @param id
* @return
*/
int getById(Long id);
}

View File

@ -65,8 +65,11 @@ public interface TbPeopleMapper {
*/
List<PeoplePositionVo> queryPeoplePositionByProId(@Param("proId") Integer proId);
/**
* 根据人员ID修改
* @param id
* @return
*/
int updateById(Long id);
}

View File

@ -30,6 +30,11 @@ public class TbDeviceServiceImpl implements TbDeviceService{
*/
@Override
public AjaxResult deleteByPrimaryKey(Long id) {
//根据id判断改设备是否被绑定被绑定则不能删除
int count = tbDeviceMapper.getById(id);
if (count > 0) {
return AjaxResult.error(ExceptionEnum.DELETE_BIND_DEVICE.getCode(), ExceptionEnum.DELETE_BIND_DEVICE.getMsg());
}
int result = tbDeviceMapper.deleteByPrimaryKey(id);
if (result > 0) {
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);

View File

@ -83,17 +83,6 @@ public class TbPeopleServiceImpl implements TbPeopleService {
people.setRelPhone(Sm4Utils.decode(people.getRelPhone()));
}
});
// 使用流对条件进行过滤
Stream<TbPeople> stream = peopleList.stream();
if (tbPeople.getRelName() != null) {
stream = stream.filter(people -> StringUtils.contains(people.getRelName(), tbPeople.getRelName()));
}
if (tbPeople.getSex() != null) {
stream = stream.filter(people -> people.getSex().equals(tbPeople.getSex()));
}
// 收集过滤后的结果
peopleList = stream.collect(Collectors.toList());
}
return peopleList;
}

View File

@ -128,6 +128,7 @@ public class TbTeamServiceImpl implements TbTeamService {
tbTeam.setRelPhone(Sm4Utils.encode(tbTeam.getRelPhone()));
}
result += tbTeamDao.insert(tbTeam);
result += tbTeamDao.insertPeople(tbTeam.getTeamId(), tbTeam.getRelId());
if (CollectionUtils.isNotEmpty(tbTeam.getIdList())) {
//将班组id插入到班组人员表
for (Long id : tbTeam.getIdList()) {
@ -165,7 +166,11 @@ public class TbTeamServiceImpl implements TbTeamService {
result += tbTeamDao.updatePeople(tbTeam.getId());
//修改
tbTeam.setUpdateUser(SecurityUtils.getUserId());
if (StringUtils.isNotBlank(tbTeam.getRelPhone())) {
tbTeam.setRelPhone(Sm4Utils.encode(tbTeam.getRelPhone()));
}
result += tbTeamDao.update(tbTeam);
result += tbTeamDao.insertPeople(tbTeam.getId(), tbTeam.getRelId());
if (CollectionUtils.isNotEmpty(tbTeam.getIdList())) {
//将班组id插入到班组人员表
for (Long id : tbTeam.getIdList()) {
@ -187,7 +192,7 @@ public class TbTeamServiceImpl implements TbTeamService {
@Override
public AjaxResult deleteById(Long id) {
//根据id去查询班组中是否存在成员存在则不能解散
if (tbTeamDao.getList(id).size() > 0) {
if (tbTeamDao.getList(id).size() > 1) {
return AjaxResult.error(ExceptionEnum.EXISTENCE_OF_MEMBERS.getCode(), ExceptionEnum.EXISTENCE_OF_MEMBERS.getMsg());
}
//根据id查询该班组长是否绑定安全帽绑定则不允许解散
@ -196,6 +201,8 @@ public class TbTeamServiceImpl implements TbTeamService {
return AjaxResult.error(ExceptionEnum.EXISTENCE_OF_HELMET.getCode(), ExceptionEnum.EXISTENCE_OF_HELMET.getMsg());
}
int result = tbTeamDao.updateById(id);
//根据班组id去人员表中解绑班组长
result += tbPeopleMapper.updateById(id);
if (result > 0) {
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);
}

View File

@ -1,5 +1,6 @@
package com.bonus.screen.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.data.entity.DevAttributeVo;
import com.bonus.screen.mapper.TbDeviceDataRecord;
@ -64,7 +65,7 @@ public class ProjectDetailsViewServiceImpl {
public AjaxResult getTowerDevAttributeWarnRecord(Integer proId) {
List<DevAttributeVo> records = tbDeviceDataRecordMapper.getTowerDevAttributeWarnRecord(proId);
if (records.isEmpty()) {
return AjaxResult.error("暂无数据");
return AjaxResult.success("暂无数据");
}
return AjaxResult.success(records);
}
@ -72,7 +73,7 @@ public class ProjectDetailsViewServiceImpl {
public AjaxResult getPitDevAttributeWarnRecord(Integer proId) {
List<DevAttributeVo> records = tbDeviceDataRecordMapper.getPitDevAttributeWarnRecord(proId);
if (records.isEmpty()) {
return AjaxResult.error("暂无数据");
return AjaxResult.success("暂无数据");
}
return AjaxResult.success(records);
}

View File

@ -337,4 +337,10 @@
and td.dev_code like concat('%',#{devCode},'%')
</if>
</select>
<select id="getById" resultType="java.lang.Integer">
SELECT count(1)
FROM tb_people
WHERE dev_id = #{id}
</select>
</mapper>

View File

@ -11,21 +11,19 @@
<select id="queryByPage" resultType="com.bonus.base.domain.TbPeople">
select
tp.id as id, tp.team_id as teamId, tp.rel_name as relName, tp.rel_phone as relPhone, tp.id_card as idCard,
tp.post_code as postCode, tp.sex as sex, td.dev_name as devName, CASE WHEN tp.team_id IS NULL THEN 0 ELSE 1 END as delFlag
tp.post_code as postCode, tp.sex as sex, td.dev_name as devName, tt.rel_id as relId
from tb_people tp
left join tb_device td on tp.dev_id = td.id and td.del_flag = '0'
left join tb_team tt on tp.team_id = tt.id and tt.del_flag = '0'
where tp.del_flag = '0'
<if test="id != null">
and tp.team_id = #{id}
UNION
select
tp.id as id, tp.team_id as teamId, tp.rel_name as relName, tp.rel_phone as relPhone, tp.id_card as idCard,
tp.post_code as postCode, tp.sex as sex, td.dev_name as devName, CASE WHEN tp.team_id IS NULL THEN 0 ELSE 1 END as delFlag
from tb_people tp
left join tb_team tt on tt.rel_id = tp.id and tt.del_flag = '0'
left join tb_device td on tp.dev_id = td.id and td.del_flag = '0'
WHERE tt.id = #{id}
ORDER BY delFlag
</if>
<if test="relName != null and relName != ''">
and tp.rel_name like concat('%',#{relName},'%')
</if>
<if test="sex != null">
and tp.sex = #{sex}
</if>
/**
* 班组长条件筛选,一个班组长只可带领一个组,班组员条件筛选,一个组员只可在一个班组
@ -33,6 +31,7 @@
<if test="isAll != null and isAll == 0">
and (tp.team_id is null and tp.id not in (select rel_id from tb_team where del_flag = '0' and js_time is null))
</if>
ORDER BY CASE WHEN tp.id = tt.rel_id THEN 0 ELSE 1 END, tp.id
</select>
<select id="queryById" resultType="com.bonus.base.domain.TbPeople">
@ -123,6 +122,12 @@
where id = #{id}
</update>
<update id="updateById">
update tb_people
set team_id = NULL
WHERE team_id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
update tb_people set del_flag = '1' where id = #{id}
@ -130,14 +135,14 @@
<select id="queryPeoplePositionByProId" resultType="com.bonus.screen.vo.PeoplePositionVo">
SELECT
tp.id_card,
tp.rel_name,
tp.dev_id,
tp.id_card as idCard,
tp.rel_name as relName,
tp.dev_id as devId,
tp.team_id AS teamId,
tt.team_name,
tt.pro_id,
project.pro_name,
device.dev_code,
tt.team_name as teamName,
tt.pro_id as proId,
project.pro_name as proName,
device.dev_code as devCode,
MAX(CASE WHEN tda.jc_name = '经度' THEN tda.jc_value END) AS lon,
MAX(CASE WHEN tda.jc_name = '纬度' THEN tda.jc_value END) AS lat

View File

@ -109,6 +109,7 @@
<if test="lat != null">lat,</if>
create_time,
<if test="createUser != null">create_user,</if>
<if test="proCode != null and proCode != ''">pro_code,</if>
del_flag
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
@ -122,6 +123,7 @@
<if test="lat != null">#{lat},</if>
NOW(),
<if test="createUser != null">#{createUser},</if>
<if test="proCode != null and proCode != ''">#{proCode},</if>
0
</trim>
</insert>
@ -161,6 +163,9 @@
<if test="updateUser != null">
update_user = #{updateUser},
</if>
<if test="updateUser != null">
pro_code = #{proCode},
</if>
</set>
where id = #{id}
</update>

View File

@ -8,7 +8,7 @@
relName, tt.rel_phone as relPhone,
tt.pro_id as proId, tt.pro_name as proName, tt.create_time as createTime, tt.create_user as createUser,
tt.update_time as updateTime, tt.js_time as jsTime, tt.update_user as updateUser, tt.del_flag as delFlag,
(count(tp.team_id) + 1) as peopleCount,
count(tp.team_id) as peopleCount,
CASE
WHEN tt.js_time is null THEN '正常'
ELSE '已解散'
@ -40,8 +40,19 @@
</select>
<select id="queryById" resultType="com.bonus.base.domain.TbTeam">
select
id, team_name, rel_id, rel_name, rel_phone, pro_id, pro_name, create_time, create_user, update_time, js_time, update_user, del_flag
select id as id,
team_name as teamName,
rel_id as relId,
rel_name as relName,
rel_phone as relPhone,
pro_id as proId,
pro_name as proName,
create_time as createTime,
create_user as createUser,
update_time as updateTime,
js_time as jsTime,
update_user as updateUser,
del_flag as delFlag
from tb_team
where id = #{id}
</select>

View File

@ -4,8 +4,8 @@
<select id="queryDevInfoByProject" resultType="java.util.Map">
SELECT
device.id,device.dev_name,project.id AS proId,project.pro_name AS proName,
device.dev_type
device.id as devId,device.dev_name as devName,project.id AS proId,project.pro_name AS proName,
device.dev_type as devType
FROM
tb_device device
LEFT JOIN tb_bd_device_record tbdr ON device.bd_id = tbdr.id
@ -70,8 +70,8 @@
<select id="getTowerDevAttributeRecordByDay" resultType="com.bonus.data.entity.DevAttributeVo">
SELECT
tddr.dev_id,tddr.dev_name,tddr.dev_type,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn,tddr.create_time as jcTime
tddr.dev_id as devId,tddr.dev_name as devName,tddr.dev_type as devType,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn as isWarn,tddr.create_time as jcTime
FROM tb_dev_data_record AS tddr
LEFT JOIN tb_device device ON device.id = tddr.dev_id
LEFT JOIN tb_bd_device_record tbdr ON tbdr.id = device.bd_id
@ -84,8 +84,8 @@
<select id="getTowerDevAttributeWarnRecord" resultType="com.bonus.data.entity.DevAttributeVo">
SELECT
tddr.dev_id,tddr.dev_name,tddr.dev_type,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn,tddr.create_time as jcTime
tddr.dev_id as devId,tddr.dev_name as devName,tddr.dev_type as devType,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn as isWarn,tddr.create_time as jcTime
FROM
tb_dev_data_record AS tddr
LEFT JOIN tb_device device ON device.id = tddr.dev_id
@ -100,8 +100,8 @@
<select id="getPitDevAttributeRecordByDeviceId" resultType="com.bonus.data.entity.DevAttributeVo">
SELECT
tddr.dev_id,tddr.dev_name,tddr.dev_type,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn,tddr.create_time as jcTime
tddr.dev_id as devId,tddr.dev_name as devName,tddr.dev_type as devType,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn as isWarn,tddr.create_time as jcTime
FROM tb_dev_data_record AS tddr
WHERE tddr.dev_id = #{devId}
AND tddr.attribute_name IN ('一氧化碳', '可燃气体', '含氧量','硫化氢')
@ -117,8 +117,8 @@
<select id="getPitDevAttributeWarnRecord" resultType="com.bonus.data.entity.DevAttributeVo">
SELECT
tddr.dev_id,tddr.dev_name,tddr.dev_type,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn,tddr.create_time as jcTime
tddr.dev_id as devId,tddr.dev_name as devName,tddr.dev_type as devType,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn as isWarn,tddr.create_time as jcTime
FROM
tb_dev_data_record AS tddr
LEFT JOIN tb_device device ON device.id = tddr.dev_id
@ -133,8 +133,8 @@
<select id="getPowerDevAttributeRecordByWarn" resultType="com.bonus.data.entity.DevAttributeVo">
SELECT
tddr.dev_id,tddr.dev_name,tddr.dev_type,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn,tddr.create_time as jcTime
tddr.dev_id as devId,tddr.dev_name as devName,tddr.dev_type as devType,tddr.attribute_name as jcName,tddr.attribute_val as jcValue,
tddr.is_warn as isWarn,tddr.create_time as jcTime
FROM
tb_dev_data_record AS tddr
LEFT JOIN tb_device device ON device.id = tddr.dev_id

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.bonus</groupId>
<artifactId>bonus-modules</artifactId>
<version>24.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bonus-data</artifactId>
<description>
bonus-modules-data 数据中心服务
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- bonus Common DataSource -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-datasource</artifactId>
</dependency>
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-core</artifactId>
</dependency>
<!-- bonus Common DataScope -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-datascope</artifactId>
</dependency>
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-log</artifactId>
</dependency>
<!-- bonus Common Log -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-log</artifactId>
</dependency>
<!-- bonus Common Swagger -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-security</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,33 +0,0 @@
package com.bonus.data;
import com.bonus.common.security.annotation.EnableCustomConfig;
import com.bonus.common.security.annotation.EnableRyFeignClients;
import com.bonus.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* base基础模块启动服务
* @author ma_sh
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class BonusDataApplication {
public static void main(String[] args) {
SpringApplication.run(BonusDataApplication.class, args);
System.err.println("(♥◠‿◠)ノ゙ 数据中心服务启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}

View File

@ -1,10 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ __ _ _
(_) / _|(_)| |
_ __ _ _ ___ _ _ _ ______ | |_ _ | | ___
| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \
| | | |_| || (_) || |_| || | | | | || || __/
|_| \__,_| \___/ \__, ||_| |_| |_||_| \___|
__/ |
|___/

View File

@ -1,29 +0,0 @@
# Tomcat
server:
port: 18089
# Spring
spring:
application:
# 应用名称
name: bonus-data
profiles:
# 环境配置
active: dev
cloud:
nacos:
username: nacos
password: Jjsp@nacos2023
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
namespace: bns-public
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
namespace: bns-public
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/bonus-ai" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.bonus" level="debug" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>