Merge branch 'server_five' into server_five_dongxiaodong
# Conflicts: # couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/CoupletMsgApplication.java # couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/consumer/KafkaConsumerQuickStart.java # couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/contents/KafkaContents.java # couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/producer/KafkaProducerQuickStart.javaserver_five_liuyunhu
commit
757f51a2dd
|
@ -4,6 +4,8 @@ server:
|
|||
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: couplet-auth
|
||||
|
@ -15,7 +17,6 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
|
@ -24,6 +25,3 @@ spring:
|
|||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
|
|
@ -40,6 +40,10 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private Long parentId;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 祖级列表
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,6 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
|
@ -24,7 +23,6 @@ spring:
|
|||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
sentinel:
|
||||
# 取消控制台懒加载
|
||||
eager: true
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-analyze</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>couplet-analyze-incident</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,20 @@
|
|||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-analyze</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>couplet-analyze-msg</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -9,7 +9,12 @@
|
|||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>couplet-msg</artifactId>
|
||||
<artifactId>couplet-analyze</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>couplet-analyze-incident</module>
|
||||
<module>couplet-analyze-msg</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
|
@ -14,8 +14,12 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
|
@ -37,6 +41,8 @@ public class Fence extends BaseEntity{
|
|||
/**
|
||||
* 围栏名称
|
||||
*/
|
||||
|
||||
@NotEmpty(message = "围栏名称不能为空")
|
||||
private String fenceName;
|
||||
/**
|
||||
* 围栏经纬度
|
||||
|
@ -45,6 +51,7 @@ public class Fence extends BaseEntity{
|
|||
/**
|
||||
* 围栏描述
|
||||
*/
|
||||
@NotEmpty(message = "围栏描述不能为空")
|
||||
private String fenceDescription;
|
||||
/**
|
||||
* 是否删除
|
||||
|
@ -66,15 +73,15 @@ public class Fence extends BaseEntity{
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@NotEmpty(message = "创建人不能为空")
|
||||
private String createName;
|
||||
/**
|
||||
* 维护人
|
||||
*/
|
||||
|
||||
@NotEmpty(message = "维护人不能为空")
|
||||
private String maintainerName;
|
||||
/**
|
||||
* 告警状态
|
||||
|
@ -86,7 +93,7 @@ public class Fence extends BaseEntity{
|
|||
/**
|
||||
* 标识
|
||||
*/
|
||||
private Integer[] logoId;
|
||||
private Integer logoId;
|
||||
@TableField(exist = false)
|
||||
private String logoName;
|
||||
|
||||
|
|
|
@ -15,13 +15,9 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
public class FenceConfig {
|
||||
|
||||
|
||||
private String fenceName;
|
||||
/**
|
||||
* 围栏状态
|
||||
*/
|
||||
private Integer fenceState;
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
|
|||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
|
@ -69,5 +70,5 @@ public class FenceRequest {
|
|||
* 标识
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String[] logoId;
|
||||
private String[] logoIds;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,10 @@
|
|||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-system</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
import static com.couplet.common.core.utils.PageUtils.startPage;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/3/28
|
||||
|
@ -39,7 +37,6 @@ public class FenceController extends BaseController {
|
|||
@RequiresPermissions("couplet:fence:fenceList")
|
||||
@PostMapping("/fenceList")
|
||||
public Result<?> fenceList(@RequestBody FenceConfig fenceConfig){
|
||||
|
||||
startPage();
|
||||
List<Fence> list = fenceService.pageQuery(fenceConfig);
|
||||
return getDataTable(list);
|
||||
|
@ -55,10 +52,11 @@ public class FenceController extends BaseController {
|
|||
@RequiresPermissions("couplet:fence:fenceAdd")
|
||||
@Log(title = "电子围栏新增",businessType = BusinessType.INSERT)
|
||||
public Result<?> fenceInsert(HttpServletRequest request, @RequestBody FenceRequest fenceRequest){
|
||||
|
||||
if (!fenceService.checkFenceKeyUnique(fenceRequest.getFenceName())) {
|
||||
return error("新增参数'" + fenceRequest.getFenceName() + "'失败,参数键名已存在");
|
||||
}
|
||||
fenceService.fenceInsert(request,fenceRequest);
|
||||
return Result.success("新增成功");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +68,9 @@ public class FenceController extends BaseController {
|
|||
@RequiresPermissions("couplet:fence:fenceUpdate")
|
||||
@Log(title = "电子围栏修改",businessType = BusinessType.UPDATE)
|
||||
public Result<?> fenceUpdate(@Validated @RequestBody FenceUpdateRequest fenceUpdateRequest){
|
||||
|
||||
if (!fenceService.checkFenceKeyUnique(fenceUpdateRequest.getFenceName())) {
|
||||
return error("修改参数'" + fenceUpdateRequest.getFenceName() + "'失败,参数键名已存在");
|
||||
}
|
||||
fenceService.changeFenceStatus(fenceUpdateRequest);
|
||||
return Result.success("修改成功");
|
||||
}
|
||||
|
@ -84,18 +84,20 @@ public class FenceController extends BaseController {
|
|||
@RequiresPermissions("couplet:fence:fenceDelete")
|
||||
@Log(title = "电子围栏删除",businessType = BusinessType.DELETE)
|
||||
public Result<?> fenceDelete(@PathVariable Long fenceId){
|
||||
boolean b = fenceService.removeById(fenceId);
|
||||
// fenceService.removeByFenceId(fenceId);
|
||||
return toAjax(b);
|
||||
fenceService.removeByFenceId(fenceId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用停用
|
||||
* @param fenceUpdateRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/fenceState")
|
||||
@RequiresPermissions("couplet:fence:fenceState")
|
||||
@Log(title = "围栏启用和停用",businessType = BusinessType.OTHER)
|
||||
public Result<?> fenceState(@RequestBody FenceUpdateRequest fenceUpdateRequest){
|
||||
|
||||
fenceService.changeFenceStatus(fenceUpdateRequest);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,4 +32,10 @@ public interface FenceMapper extends BaseMapper<Fence> {
|
|||
*/
|
||||
List<Fence> pageQuery(FenceConfig fenceConfig);
|
||||
|
||||
/**
|
||||
* 判断名字唯一
|
||||
* @param fenceName
|
||||
* @return
|
||||
*/
|
||||
boolean checkFenceKeyUnique(String fenceName);
|
||||
}
|
||||
|
|
|
@ -35,4 +35,12 @@ public interface FenceService extends IService<Fence> {
|
|||
*/
|
||||
void removeByFenceId(Long fenceId);
|
||||
|
||||
/**
|
||||
* 判断数据是否存在
|
||||
*
|
||||
* @param fenceName
|
||||
* @return
|
||||
*/
|
||||
boolean checkFenceKeyUnique(String fenceName);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.couplet.map.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.couplet.map.common.domain.Fence;
|
||||
import com.couplet.map.common.domain.request.FenceConfig;
|
||||
|
@ -57,15 +55,13 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
@Override
|
||||
public void fenceInsert(HttpServletRequest request,FenceRequest fenceRequest) {
|
||||
|
||||
|
||||
int a= fenceMapper.insertFence(fenceRequest);
|
||||
String[] logoId = fenceRequest.getLogoId();
|
||||
String[] split=null;
|
||||
if (logoId != null && logoId.length> 0){
|
||||
split = logoId[0].split(",");
|
||||
}
|
||||
if (a>0){
|
||||
fenAndLogoService.addBach(fenceRequest.getFenceId(),split);
|
||||
String[] logoIds = fenceRequest.getLogoIds();
|
||||
String[] parts = new String[0];
|
||||
for (String logoId : logoIds) {
|
||||
parts = logoId.split(",");
|
||||
fenAndLogoService.addBach(fenceRequest.getFenceId(),parts);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,4 +70,9 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
public void removeByFenceId(Long fenceId) {
|
||||
fenceMapper.removeByFenceId(fenceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkFenceKeyUnique(String fenceName) {
|
||||
return fenceMapper.checkFenceKeyUnique(fenceName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -22,9 +22,10 @@
|
|||
|
||||
<insert id="addBach">
|
||||
INSERT INTO `couplet-cloud`.`couplet_fences_and_logo`
|
||||
(`fences_id`, `logo_id`) VALUES
|
||||
<foreach collection="logoIds" item="logoItemId" separator="," close="(" open=")">
|
||||
(#{fenceId}, #{logoItemId})
|
||||
(`fences_id`, `logo_id`)
|
||||
VALUES
|
||||
<foreach collection="logoIds" item="item" separator=",">
|
||||
(#{fenceId}, #{item})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</resultMap>
|
||||
<sql id="selectFence">
|
||||
SELECT
|
||||
fence_id,
|
||||
f.fence_id,
|
||||
fence_name,
|
||||
fence_longitude_latitude,
|
||||
fence_description,
|
||||
|
@ -33,19 +33,32 @@
|
|||
maintainer_name,
|
||||
alarm_status,
|
||||
l.logo_id,
|
||||
logo_name
|
||||
GROUP_CONCAT(logo_name) as logoName
|
||||
FROM couplet_fence_info f INNER JOIN couplet_fences_and_logo m on
|
||||
f.fence_id=m.fences_id INNER JOIN couplet_logo_info l on l.logo_id=m.logo_id GROUP BY fence_id
|
||||
f.fence_id=m.fences_id INNER JOIN couplet_logo_info l on l.logo_id=m.logo_id
|
||||
</sql>
|
||||
<sql id="fence">
|
||||
SELECT
|
||||
fence_id,
|
||||
fence_name,
|
||||
fence_longitude_latitude,
|
||||
fence_description,
|
||||
is_delete,
|
||||
fence_state,
|
||||
create_time,
|
||||
update_time,
|
||||
create_name,
|
||||
maintainer_name,
|
||||
alarm_status
|
||||
FROM couplet_fence_info
|
||||
</sql>
|
||||
<insert id="insertFence" parameterType="com.couplet.map.common.domain.request.FenceRequest" keyProperty="fenceId"
|
||||
useGeneratedKeys="true">
|
||||
|
||||
INSERT INTO `couplet-cloud`.`couplet_fence_info`
|
||||
(`fence_name`, `fence_description`, `is_delete`, `fence_state`, `create_time`,
|
||||
`create_name`, `maintainer_name`, `alarm_status`)
|
||||
(`fence_name`, `fence_longitude_latitude`, `fence_description`, `is_delete`, `fence_state`, `create_time`,
|
||||
`update_time`, `create_name`, `maintainer_name`, `alarm_status`)
|
||||
VALUES
|
||||
(#{fenceName}, #{fenceDescription}, 0, 0, now(), #{createTime},
|
||||
#{createName}, 0);
|
||||
(#{fenceName}, null, #{fenceDescription}, 0, 0, now(), null, null, #{maintainerName}, 0)
|
||||
|
||||
|
||||
</insert>
|
||||
|
@ -78,5 +91,9 @@
|
|||
and fence_state = #{fenceState}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY f.fence_id
|
||||
</select>
|
||||
<select id="checkFenceKeyUnique" resultType="java.lang.Boolean">
|
||||
<include refid="fence"/> where fence_name = #{fenceName}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/1
|
||||
* 异步发送
|
||||
*/
|
||||
public class test {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Properties props = new Properties();
|
||||
props.put("bootstrap.servers","39.103.133.136:9092");
|
||||
//使用默认的配置
|
||||
// props.put("acks","all");
|
||||
// props.put("retries",0);
|
||||
// props.put("batch.size",16384);
|
||||
// props.put("linger.ms",1);
|
||||
// props.put("buffer.memory",33554432);
|
||||
props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
|
||||
props.put("value.serializer","org.apache.kafka.common.serialization.StringSerializer");
|
||||
KafkaProducer<String, String> producer = new KafkaProducer<>(props);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
producer.send(new ProducerRecord<String,String>("my-topic",Integer.toString(i),Integer.toString(i)));
|
||||
}
|
||||
producer.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.apache.kafka.clients.producer.RecordMetadata;
|
||||
import org.yaml.snakeyaml.introspector.Property;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/1
|
||||
* 同步发送
|
||||
*/
|
||||
public class test2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put("bootstrap.servers", "39.103.133.136:9092");
|
||||
properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
|
||||
properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
|
||||
KafkaProducer<String, String> producer = new KafkaProducer<String, String>(properties);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Future<RecordMetadata> result = producer.send(new ProducerRecord<>("test", Integer.toString(i), Integer.toString(i)));
|
||||
try {
|
||||
RecordMetadata recordMetadata =result.get();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
producer.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -4,6 +4,8 @@ server:
|
|||
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: couplet-gen
|
||||
|
@ -15,11 +17,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -4,6 +4,8 @@ server:
|
|||
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: couplet-job
|
||||
|
@ -15,11 +17,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -84,6 +84,13 @@
|
|||
<artifactId>couplet-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Pagehelper -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -10,6 +10,8 @@ import com.couplet.vehicle.domain.req.VehicleEditParams;
|
|||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||
import com.couplet.vehicle.service.VehicleService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -39,10 +41,13 @@ public class VehicleController extends BaseController {
|
|||
@PostMapping("/list")
|
||||
@Log(title = "车辆列表")
|
||||
public Result list(@RequestBody VehicleListParams listParams) {
|
||||
PageHelper.startPage(listParams.getPageNum(), listParams.getPageSize());
|
||||
|
||||
List<Vehicle> List = vehicleService.list(listParams);
|
||||
List<Vehicle> list = vehicleService.list(listParams);
|
||||
|
||||
return Result.success(List);
|
||||
PageInfo<Vehicle> vehiclePageInfo = new PageInfo<>(list);
|
||||
|
||||
return Result.success(vehiclePageInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -90,9 +95,27 @@ public class VehicleController extends BaseController {
|
|||
@PostMapping("/insert")
|
||||
@Log(title = "新增车辆", businessType = BusinessType.INSERT)
|
||||
public Result insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
||||
|
||||
System.out.println(insertParams);
|
||||
String result = vehicleService.insert(insertParams);
|
||||
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/3/31 21:34
|
||||
* @Description: 获取绑定当前车辆的标识
|
||||
* @Param: [vehicleId]
|
||||
* @Return: com.couplet.common.core.domain.Result
|
||||
**/
|
||||
@RequiresPermissions("couplet:vehicle:list")
|
||||
@GetMapping("/getBindLogoById/{vehicleId}")
|
||||
public Result getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
||||
|
||||
List<Long> bindLogoById = vehicleService.getBindLogoById(vehicleId);
|
||||
|
||||
|
||||
return Result.success(bindLogoById);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -53,4 +54,7 @@ public class VehicleEditParams {
|
|||
* */
|
||||
private String batteryNumber;
|
||||
|
||||
//标识id集合
|
||||
private List<Long> logoIds;
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ public class VehicleInsertParams {
|
|||
/*
|
||||
* 一辆车可以绑定多个标识
|
||||
* */
|
||||
@Size(min = 1, message = "车辆至少绑定一个标识")
|
||||
private List<Long> logoIds;
|
||||
|
||||
}
|
||||
|
|
|
@ -26,4 +26,10 @@ public class VehicleListParams {
|
|||
* */
|
||||
private Integer vehicleState;
|
||||
|
||||
/*
|
||||
* 分页参数
|
||||
* */
|
||||
private Integer pageNum = 1;
|
||||
private Integer pageSize = 5;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,4 +18,8 @@ import java.util.List;
|
|||
@Component
|
||||
public interface VehicleAndLogoMapper extends BaseMapper<VehicleAndLogo> {
|
||||
int vehicleBindLogo(@Param("vehicleId") Long vehicleId, @Param("logoIds") List<Long> logoIds);
|
||||
|
||||
int deleteByVehicleId(@Param("vehicleId") Long vehicleId);
|
||||
|
||||
List<Long> getBindLogoById(@Param("vehicleId") Long vehicleId);
|
||||
}
|
||||
|
|
|
@ -14,4 +14,8 @@ import java.util.List;
|
|||
|
||||
public interface VehicleAndLogoService extends IService<VehicleAndLogo> {
|
||||
int vehicleBindLogo(Long vehicleId, List<Long> logoIds);
|
||||
|
||||
int deleteByVehicleId(Long vehicleId);
|
||||
|
||||
List<Long> getBindLogoById(Long vehicleId);
|
||||
}
|
||||
|
|
|
@ -23,4 +23,6 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
String editById(VehicleEditParams editParams);
|
||||
|
||||
String insert(VehicleInsertParams insertParams);
|
||||
|
||||
List<Long> getBindLogoById(Long vehicleId);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +35,43 @@ public class VehicleAndLogoServiceImpl extends ServiceImpl<VehicleAndLogoMapper,
|
|||
**/
|
||||
@Override
|
||||
public int vehicleBindLogo(Long vehicleId, List<Long> logoIds) {
|
||||
//将ids转为list
|
||||
// ArrayList<Long> logoIdList = new ArrayList<>();
|
||||
// String[] split = logoIds.split(",");
|
||||
// for (String s : split) {
|
||||
// logoIdList.add(Long.parseLong(s));
|
||||
// }
|
||||
|
||||
//执行绑定
|
||||
return mapper.vehicleBindLogo(vehicleId, logoIds);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/3/31 21:21
|
||||
* @Description: 删除掉车辆绑定
|
||||
* @Param: [vehicleId]
|
||||
* @Return: int
|
||||
**/
|
||||
@Override
|
||||
public int deleteByVehicleId(Long vehicleId) {
|
||||
|
||||
|
||||
return mapper.deleteByVehicleId(vehicleId);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/3/31 21:35
|
||||
* @Description: 获取绑定当前车辆的标识
|
||||
* @Param: [vehicleId]
|
||||
* @Return: java.util.List<java.lang.Long>
|
||||
**/
|
||||
@Override
|
||||
public List<Long> getBindLogoById(Long vehicleId) {
|
||||
|
||||
|
||||
return mapper.getBindLogoById(vehicleId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ package com.couplet.vehicle.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleType;
|
||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||
import com.couplet.vehicle.exception.VehicleException;
|
||||
import com.couplet.vehicle.mapper.VehicleMapper;
|
||||
import com.couplet.vehicle.service.VehicleAndLogoService;
|
||||
import com.couplet.vehicle.service.VehicleService;
|
||||
|
@ -107,7 +107,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
|
||||
if (!update) {
|
||||
result = "删除失败";
|
||||
throw new VehicleException(result);
|
||||
Result.error(result);
|
||||
}
|
||||
|
||||
result = "删除成功!";
|
||||
|
@ -126,10 +126,14 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
public String editById(VehicleEditParams editParams) {
|
||||
String result = "";
|
||||
|
||||
if ((editParams.getLogoIds() == null || editParams.getLogoIds().isEmpty())) {
|
||||
result = "未选择电子围栏";
|
||||
Result.error(result);
|
||||
}
|
||||
|
||||
UpdateWrapper<Vehicle> updateWrapper = new UpdateWrapper<>();
|
||||
|
||||
//编辑车辆类型
|
||||
|
||||
updateWrapper.set("vehicle_type", editParams.getVehicleType())
|
||||
|
||||
//编辑电机厂商
|
||||
|
@ -152,9 +156,15 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
|
||||
if (!update) {
|
||||
result = "编辑失败";
|
||||
throw new VehicleException(result);
|
||||
Result.error(result);
|
||||
}
|
||||
|
||||
//删除掉车辆id为入参的车辆、标识的中间表数据
|
||||
int delete = vehicleAndLogoService.deleteByVehicleId(editParams.getVehicleId());
|
||||
|
||||
//删除绑定之后,再添加新的绑定
|
||||
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
|
||||
|
||||
result = "编辑成功!";
|
||||
|
||||
return result;
|
||||
|
@ -171,6 +181,12 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
public String insert(VehicleInsertParams insertParams) {
|
||||
String result = "";
|
||||
|
||||
if ((insertParams.getLogoIds() == null || insertParams.getLogoIds().isEmpty())) {
|
||||
result = "未选择电子围栏";
|
||||
Result.error(result);
|
||||
}
|
||||
|
||||
|
||||
//雪花算法生成随机数
|
||||
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||
long randomId = idGenerator.nextId();
|
||||
|
@ -195,7 +211,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
|
||||
if (insert == 0) {
|
||||
result = "新增失败";
|
||||
throw new VehicleException(result);
|
||||
Result.error(result);
|
||||
}
|
||||
|
||||
//获取新增的车辆id值
|
||||
|
@ -208,4 +224,19 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/3/31 21:34
|
||||
* @Description: 获取绑定当前车辆的标识
|
||||
* @Param: [vehicleId]
|
||||
* @Return: java.util.List<java.lang.Long>
|
||||
**/
|
||||
@Override
|
||||
public List<Long> getBindLogoById(Long vehicleId) {
|
||||
List<Long> logoIds = vehicleAndLogoService.getBindLogoById(vehicleId);
|
||||
|
||||
return logoIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -12,4 +12,16 @@
|
|||
(#{vehicleId},#{logoId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByVehicleId">
|
||||
DELETE
|
||||
FROM `couplet_vehicle_and_logo`
|
||||
WHERE `vehicle_id` = #{vehicleId}
|
||||
</delete>
|
||||
|
||||
<select id="getBindLogoById" resultType="java.lang.Long">
|
||||
SELECT val.logo_id
|
||||
FROM `couplet_vehicle_and_logo` val
|
||||
WHERE val.vehicle_id = #{vehicleId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -66,7 +66,7 @@ public class SysFirmController {
|
|||
* @param deptId
|
||||
* @return com.couplet.common.core.domain.Result
|
||||
**/
|
||||
@DeleteMapping("delFirm/{deptId}")
|
||||
@PostMapping("delFirm/{deptId}")
|
||||
public Result delFirm(@PathVariable Integer deptId){
|
||||
int i = sysFirmService.delFirm(deptId);
|
||||
Result<Integer> success = Result.success(i);
|
||||
|
|
|
@ -4,6 +4,8 @@ server:
|
|||
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: couplet-system
|
||||
|
@ -15,7 +17,6 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
|
@ -24,7 +25,6 @@ spring:
|
|||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
logging:
|
||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<module>couplet-modules-vehicle</module>
|
||||
<module>couplet-modules-mq</module>
|
||||
<module>couplet-enterprisemanagement</module>
|
||||
<module>couplet-msg</module>
|
||||
<module>couplet-analyze</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>couplet-modules</artifactId>
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -250,14 +250,14 @@
|
|||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-modules-vehicle</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<version>${couplet.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RabbitMq模块 -->
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-modules-mq</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<version>${couplet.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
Loading…
Reference in New Issue