diff --git a/couplet-auth/src/main/resources/bootstrap.yml b/couplet-auth/src/main/resources/bootstrap.yml index 870a494..c9f22f8 100644 --- a/couplet-auth/src/main/resources/bootstrap.yml +++ b/couplet-auth/src/main/resources/bootstrap.yml @@ -15,13 +15,13 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 diff --git a/couplet-common/couplet-common-security/src/main/java/com/couplet/common/security/utils/SecurityUtils.java b/couplet-common/couplet-common-security/src/main/java/com/couplet/common/security/utils/SecurityUtils.java index 4daf3da..27f67ea 100644 --- a/couplet-common/couplet-common-security/src/main/java/com/couplet/common/security/utils/SecurityUtils.java +++ b/couplet-common/couplet-common-security/src/main/java/com/couplet/common/security/utils/SecurityUtils.java @@ -7,6 +7,7 @@ import com.couplet.common.core.utils.ServletUtils; import com.couplet.common.core.utils.StringUtils; import com.couplet.common.system.domain.LoginUser; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.util.Assert; import javax.servlet.http.HttpServletRequest; @@ -44,6 +45,15 @@ public class SecurityUtils { return SecurityContextHolder.get(SecurityConstants.LOGIN_USER, LoginUser.class); } + /** + * 获取登录企业ID + */ + public static Long getEnterpriseId(){ + Long enterpriseId = getLoginUser().getEnterpriseId(); + Assert.notNull(enterpriseId, "该用户未绑定负责企业"); + return enterpriseId; + } + /** * 获取请求token */ diff --git a/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/LoginUser.java b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/LoginUser.java index 1edfd94..338dcb9 100644 --- a/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/LoginUser.java +++ b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/LoginUser.java @@ -1,6 +1,8 @@ package com.couplet.common.system.domain; +import lombok.*; + import java.io.Serializable; import java.util.Set; @@ -9,6 +11,10 @@ import java.util.Set; * * @author couplet */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor public class LoginUser implements Serializable { private static final long serialVersionUID = 1L; @@ -52,80 +58,14 @@ public class LoginUser implements Serializable { */ private Set roles; + /** + * 企业ID + */ + private Long enterpriseId; + /** * 用户信息 */ private SysUser sysUser; - public String getToken () { - return token; - } - - public void setToken (String token) { - this.token = token; - } - - public Long getUserid () { - return userid; - } - - public void setUserid (Long userid) { - this.userid = userid; - } - - public String getUsername () { - return username; - } - - public void setUsername (String username) { - this.username = username; - } - - public Long getLoginTime () { - return loginTime; - } - - public void setLoginTime (Long loginTime) { - this.loginTime = loginTime; - } - - public Long getExpireTime () { - return expireTime; - } - - public void setExpireTime (Long expireTime) { - this.expireTime = expireTime; - } - - public String getIpaddr () { - return ipaddr; - } - - public void setIpaddr (String ipaddr) { - this.ipaddr = ipaddr; - } - - public Set getPermissions () { - return permissions; - } - - public void setPermissions (Set permissions) { - this.permissions = permissions; - } - - public Set getRoles () { - return roles; - } - - public void setRoles (Set roles) { - this.roles = roles; - } - - public SysUser getSysUser () { - return sysUser; - } - - public void setSysUser (SysUser sysUser) { - this.sysUser = sysUser; - } } diff --git a/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/SysFirm.java b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/SysFirm.java new file mode 100644 index 0000000..8ade07b --- /dev/null +++ b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/SysFirm.java @@ -0,0 +1,25 @@ +package com.couplet.common.system.domain; + +import lombok.Data; + +/** + * @ClassName SysFirm + * @Description 企业实体类 + * @Author YuanYongH + * @Date 2024/3/28 22:14 + */ +@Data +public class SysFirm { + /** + * 企业id + **/ + private Integer firmId; + /** + * 企业名称 + **/ + private String firmName; + /** + * 企业认证 + **/ + private Integer approveId; +} diff --git a/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/remote/RemoteDeptService.java b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/remote/RemoteDeptService.java new file mode 100644 index 0000000..a05dd4f --- /dev/null +++ b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/remote/RemoteDeptService.java @@ -0,0 +1,36 @@ +package com.couplet.common.system.remote; + +import com.couplet.common.core.constant.ServiceNameConstants; +import com.couplet.common.core.domain.Result; +import com.couplet.common.core.web.page.TableDataInfo; +import com.couplet.common.system.domain.SysDept; +import com.couplet.common.system.domain.SysUser; +import com.couplet.common.system.remote.factory.RemoteDeptFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + + +@FeignClient(contextId = "remoteFileService" , + value = ServiceNameConstants.SYSTEM_SERVICE, + fallbackFactory = RemoteDeptFallbackFactory.class, + path = "/dept" +) +public interface RemoteDeptService { + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + @GetMapping("/list") + public Result list (SysDept dept); + + /** + * 根据企业ID获取企业下部门 + * @param enterpriseId 企业ID + * @return 企业信息,内含有部门 + */ + @GetMapping("/getSysDeptByEnterpriseId/{enterpriseId}") + public Result getSysDeptByEnterpriseId(@PathVariable(value = "enterpriseId") Long enterpriseId); +} diff --git a/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/remote/factory/RemoteDeptFallbackFactory.java b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/remote/factory/RemoteDeptFallbackFactory.java new file mode 100644 index 0000000..24ef720 --- /dev/null +++ b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/remote/factory/RemoteDeptFallbackFactory.java @@ -0,0 +1,43 @@ +package com.couplet.common.system.remote.factory; + +import com.couplet.common.core.domain.Result; +import com.couplet.common.core.web.page.TableDataInfo; +import com.couplet.common.system.domain.SysDept; +import com.couplet.common.system.domain.SysUser; +import com.couplet.common.system.remote.RemoteDeptService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * @author fufanrui + * @version 1.0 + * @description: TODO + * @date 2024/3/27 15:29 + */ +@Slf4j + +public class RemoteDeptFallbackFactory implements FallbackFactory { + @Override + public RemoteDeptService create(Throwable cause) { + log.error("sys服务调用失败:{}", cause.getMessage()); + return new RemoteDeptService() { + @Override + public Result list(SysDept dept) { + return Result.error("调用失败..."+cause.getMessage()); + } + + /** + * 根据企业ID获取企业下部门 + * + * @param enterpriseId 企业ID + * + * @return 企业信息,内含有部门 + */ + @Override + public Result getSysDeptByEnterpriseId (Long enterpriseId) { + return Result.error("调用失败..."+cause.getMessage()); + } + + }; + } +} diff --git a/couplet-common/couplet-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/couplet-common/couplet-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index fe7c0f3..a990272 100644 --- a/couplet-common/couplet-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/couplet-common/couplet-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,3 +1,4 @@ com.couplet.common.system.remote.factory.RemoteUserFallbackFactory com.couplet.common.system.remote.factory.RemoteLogFallbackFactory com.couplet.common.system.remote.factory.RemoteFileFallbackFactory +com.couplet.common.system.remote.factory.RemoteDeptFallbackFactory diff --git a/couplet-gateway/src/main/resources/bootstrap.yml b/couplet-gateway/src/main/resources/bootstrap.yml index 307a581..9707804 100644 --- a/couplet-gateway/src/main/resources/bootstrap.yml +++ b/couplet-gateway/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-electronic-fence/.gitignore b/couplet-modules/couplet-electronic-fence/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/.gitignore b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/pom.xml b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/pom.xml new file mode 100644 index 0000000..d1ab065 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.couplet + couplet-electronic-fence + 3.6.3 + + + + couplet-electronic-fence-common + + + couplet-electronic-fence-common + + + + 17 + 17 + UTF-8 + + + + + + com.couplet + couplet-common-core + + + + + diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/src/main/java/com/couplet/map/common/domin/Fence.java b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/src/main/java/com/couplet/map/common/domin/Fence.java new file mode 100644 index 0000000..0971935 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/src/main/java/com/couplet/map/common/domin/Fence.java @@ -0,0 +1,80 @@ +package com.couplet.map.common.domin; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.couplet.common.core.web.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.SuperBuilder; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @Author: LiJiaYao + * @Date: 2024/3/28 + */ +@Data +@SuperBuilder +@TableName("couplet_fence") +public class Fence extends BaseEntity { + + @TableId(value = "fence_id", type = IdType.AUTO) + /** + * 围栏id + */ + private Long fenceId; + /** + * 围栏名称 + */ + private String fenceName; + /** + * 围栏经纬度 + */ + private String fenceLongitudeLatitude; + /** + * 围栏描述 + */ + private String fenceDescription; + /** + * 是否删除 + */ + private Integer isDelete; + /** + * 围栏状态 + */ + private Integer fenceState; + /** + * 创建时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + /** + * 更新时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date updateTime; + + /** + * 创建人 + */ + private String createName; + /** + * 维护人 + */ + + private String maintainerName; + /** + * 告警状态 + */ + + private Integer alarmStatus; + /** + * 围栏类型 + */ + private Integer fenceType; + +} diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/src/main/java/com/couplet/map/common/domin/request/FenceConfig.java b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/src/main/java/com/couplet/map/common/domin/request/FenceConfig.java new file mode 100644 index 0000000..6143e51 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-common/src/main/java/com/couplet/map/common/domin/request/FenceConfig.java @@ -0,0 +1,24 @@ +package com.couplet.map.common.domin.request; + +import com.couplet.common.core.web.domain.BaseEntity; +import com.couplet.map.common.domin.Fence; +import lombok.Builder; +import lombok.Data; + +/** + * @Author: LiJiaYao + * @Date: 2024/3/28 + */ +@Data +public class FenceConfig{ + + + private String fenceName; + /** + * 围栏经纬度 + */ + private String fenceLongitudeLatitude; + private Integer pageNum=1; + private Integer pageSize=3; + +} diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-remote/.gitignore b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-remote/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-remote/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-remote/pom.xml b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-remote/pom.xml new file mode 100644 index 0000000..b8bb402 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-remote/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + com.couplet + couplet-electronic-fence + 3.6.3 + + + couplet-electronic-fence-remote + + + 17 + 17 + UTF-8 + + + + + + com.couplet + couplet-electronic-fence-common + + + + + diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/.gitignore b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/pom.xml b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/pom.xml new file mode 100644 index 0000000..7808595 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/pom.xml @@ -0,0 +1,116 @@ + + + 4.0.0 + + com.couplet + couplet-electronic-fence + 3.6.3 + + + couplet-electronic-fence-server + + + 17 + 17 + UTF-8 + + + + + com.couplet + couplet-electronic-fence-common + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.couplet + couplet-common-datasource + + + + + com.couplet + couplet-common-datascope + + + + + com.couplet + couplet-common-log + + + + + com.couplet + couplet-common-swagger + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/CoupletElectronicFenceApplication.java b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/CoupletElectronicFenceApplication.java new file mode 100644 index 0000000..2f3466e --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/CoupletElectronicFenceApplication.java @@ -0,0 +1,22 @@ +package com.couplet.map.server; + +import com.couplet.common.security.annotation.EnableCustomConfig; +import com.couplet.common.security.annotation.EnableMyFeignClients; +import com.couplet.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 系统模块 + * + * @author couplet + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableMyFeignClients +@SpringBootApplication +public class CoupletElectronicFenceApplication { + public static void main (String[] args) { + SpringApplication.run(CoupletElectronicFenceApplication.class, args); + } +} diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/controller/FenceController.java b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/controller/FenceController.java new file mode 100644 index 0000000..71aa0c8 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/controller/FenceController.java @@ -0,0 +1,46 @@ +package com.couplet.map.server.controller; + +import com.couplet.common.core.domain.Result; +import com.couplet.common.core.web.controller.BaseController; +import com.couplet.map.common.domin.Fence; +import com.couplet.map.common.domin.request.FenceConfig; +import com.couplet.map.server.service.FenceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static com.couplet.common.core.utils.PageUtils.startPage; + +/** + * @Author: LiJiaYao + * @Date: 2024/3/28 + */ +@RestController +@RequestMapping("/fence") +public class FenceController extends BaseController { + + /** + * 调用服务 + */ + @Autowired + private FenceService fenceService; + + /** + * 获取围栏列表 + * @return + * @param fenceConfig + */ + @GetMapping("/fenceList") + public Result fenceList(@RequestBody FenceConfig fenceConfig){ + + startPage(); + List list = fenceService.pageQuery(fenceConfig); + return getDataTable(list); + } + + +} diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/mapper/FenceMapper.java b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/mapper/FenceMapper.java new file mode 100644 index 0000000..51f95cd --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/mapper/FenceMapper.java @@ -0,0 +1,13 @@ +package com.couplet.map.server.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.couplet.map.common.domin.Fence; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Author: LiJiaYao + * @Date: 2024/3/28 + */ +@Mapper +public interface FenceMapper extends BaseMapper { +} diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/service/FenceService.java b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/service/FenceService.java new file mode 100644 index 0000000..d156b60 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/service/FenceService.java @@ -0,0 +1,15 @@ +package com.couplet.map.server.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.couplet.map.common.domin.Fence; +import com.couplet.map.common.domin.request.FenceConfig; + +import java.util.List; + +/** + * @Author: LiJiaYao + * @Date: 2024/3/28 + */ +public interface FenceService extends IService { + List pageQuery(FenceConfig fenceConfig); +} diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/service/impl/FenceServiceImpl.java b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/service/impl/FenceServiceImpl.java new file mode 100644 index 0000000..85f69d4 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/java/com/couplet/map/server/service/impl/FenceServiceImpl.java @@ -0,0 +1,34 @@ +package com.couplet.map.server.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.couplet.map.common.domin.Fence; +import com.couplet.map.common.domin.request.FenceConfig; +import com.couplet.map.server.mapper.FenceMapper; +import com.couplet.map.server.service.FenceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author: LiJiaYao + * @Date: 2024/3/28 + */ +@Service +public class FenceServiceImpl extends ServiceImpl implements FenceService { + + /** + * 调用围栏mapper + */ + @Autowired + private FenceMapper fenceMapper; + + + @Override + public List pageQuery(FenceConfig fenceConfig) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + return this.list(queryWrapper); + } +} diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/resources/bootstrap.yml b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..044ab55 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/resources/bootstrap.yml @@ -0,0 +1,28 @@ +# Tomcat +server: + port: 9999 + +# Spring +spring: + application: + # 应用名称 + name: couplet-electronic-fence + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 121.89.211.230:8848 + config: + # 配置中心地址 + server-addr: 121.89.211.230:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.couplet.trouble.mapper: DEBUG diff --git a/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/resources/mapper/map/FenceMapper.xml b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/resources/mapper/map/FenceMapper.xml new file mode 100644 index 0000000..04e9aac --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/couplet-electronic-fence-server/src/main/resources/mapper/map/FenceMapper.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/couplet-modules/couplet-electronic-fence/pom.xml b/couplet-modules/couplet-electronic-fence/pom.xml new file mode 100644 index 0000000..baf57f6 --- /dev/null +++ b/couplet-modules/couplet-electronic-fence/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.couplet + couplet-modules + 3.6.3 + + + pom + + + + couplet-electronic-fence + + + couplet-electronic-fence-server + couplet-electronic-fence-common + couplet-electronic-fence-remote + + + + 17 + 17 + UTF-8 + + + diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-common/pom.xml b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-common/pom.xml new file mode 100644 index 0000000..e34dd5a --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-common/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.couplet + couplet-enterprisemanagement + 3.6.3 + + + couplet-enterprisemanagement-common + + + 17 + 17 + UTF-8 + + + + com.couplet + couplet-common-core + + + com.couplet + couplet-common-system + + + + diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-remote/pom.xml b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-remote/pom.xml new file mode 100644 index 0000000..c9c52a9 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-remote/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.couplet + couplet-enterprisemanagement + 3.6.3 + + + couplet-enterprisemanagement-remote + + + 17 + 17 + UTF-8 + + + + com.couplet + couplet-enterprisemanagement-common + + + com.couplet + couplet-common-security + + + com.couplet + couplet-common-security + + + + diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/pom.xml b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/pom.xml new file mode 100644 index 0000000..523c572 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/pom.xml @@ -0,0 +1,88 @@ + + + 4.0.0 + + com.couplet + couplet-enterprisemanagement + 3.6.3 + + + couplet-enterprisemanagement-server + + + 17 + 17 + UTF-8 + + + + com.couplet + couplet-enterprisemanagement-common + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.couplet + couplet-common-datasource + + + + + com.couplet + couplet-common-datascope + + + + + com.couplet + couplet-common-log + + + + + com.couplet + couplet-common-swagger + + + + + + diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/CoupleManagementApp.java b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/CoupleManagementApp.java new file mode 100644 index 0000000..2b72827 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/CoupleManagementApp.java @@ -0,0 +1,27 @@ +package com.couplet.server; + +import com.couplet.common.security.annotation.EnableCustomConfig; +import com.couplet.common.security.annotation.EnableMyFeignClients; +import com.couplet.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author fufanrui + * @version 1.0 + * @description: 启动类 + * @date 2024/3/27 14:04 + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableMyFeignClients +@SpringBootApplication +public class CoupleManagementApp { + + public static void main(String[] args) { + + SpringApplication.run(CoupleManagementApp.class, args); + + + } +} diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/controller/ManageController.java b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/controller/ManageController.java new file mode 100644 index 0000000..d51e9b6 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/controller/ManageController.java @@ -0,0 +1,24 @@ +package com.couplet.server.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author fufanrui + * @version 1.0 + * @description: TODO + * @date 2024/3/27 15:33 + */ +@RestController +@RequestMapping("/manage") +public class ManageController { + + + + + +} diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/ManageServer.java b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/ManageServer.java new file mode 100644 index 0000000..c6ff389 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/ManageServer.java @@ -0,0 +1,7 @@ +package com.couplet.server.service; +import org.springframework.beans.factory.annotation.Autowired; + +public interface ManageServer { + + +} diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/impl/ManageServiceImpl.java b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/impl/ManageServiceImpl.java new file mode 100644 index 0000000..a0e9b61 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/impl/ManageServiceImpl.java @@ -0,0 +1,32 @@ +package com.couplet.server.service.impl; + +import com.couplet.common.core.domain.Result; +import com.couplet.common.security.utils.SecurityUtils; +import com.couplet.common.system.domain.SysDept; +import com.couplet.common.system.remote.RemoteDeptService; +import com.couplet.server.service.ManageServer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author fufanrui + * @version 1.0 + * @description: TODO + * @date 2024/3/27 15:34 + */ +@Service +public class ManageServiceImpl implements ManageServer { + + @Autowired + private RemoteDeptService remoteDeptService; + { + Long enterpriseId = SecurityUtils.getEnterpriseId(); + Result sysDeptByEnterpriseId = remoteDeptService.getSysDeptByEnterpriseId(enterpriseId); + if (sysDeptByEnterpriseId.getCode() == 200){ + SysDept sysDept = sysDeptByEnterpriseId.getData(); + } + } + + + +} diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/banner.txt b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/banner.txt new file mode 100644 index 0000000..0dd5eee --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/bootstrap.yml b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..285745c --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/bootstrap.yml @@ -0,0 +1,30 @@ +# Tomcat +server: + port: 9222 + +# Spring +spring: + application: + # 应用名称 + name: couplet-enterprisemanagement + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + config: + # 配置中心地址 + server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.couplet.system.mapper: DEBUG diff --git a/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/logback.xml b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/logback.xml new file mode 100644 index 0000000..4940ee0 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/couplet-modules/couplet-enterprisemanagement/pom.xml b/couplet-modules/couplet-enterprisemanagement/pom.xml new file mode 100644 index 0000000..8a9e031 --- /dev/null +++ b/couplet-modules/couplet-enterprisemanagement/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + com.couplet + couplet-modules + 3.6.3 + + + couplet-enterprisemanagement + pom + + couplet-enterprisemanagement-common + couplet-enterprisemanagement-server + couplet-enterprisemanagement-remote + + + + 17 + 17 + UTF-8 + + + diff --git a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml index 1b923b2..8681657 100644 --- a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml @@ -15,13 +15,13 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 diff --git a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml index 8829025..c041c96 100644 --- a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml @@ -15,13 +15,13 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 diff --git a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml index 866823e..c7dbdbe 100644 --- a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml @@ -15,13 +15,13 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 diff --git a/couplet-modules/couplet-modules-mqtt/pom.xml b/couplet-modules/couplet-modules-mqtt/pom.xml new file mode 100644 index 0000000..66187c1 --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/pom.xml @@ -0,0 +1,120 @@ + + + 4.0.0 + + com.couplet + couplet-modules + 3.6.3 + + + couplet-modules-mqtt + + + + + + + + + couplet-modules-mqttx获取报文模块 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.couplet + couplet-common-datasource + + + + + com.couplet + couplet-common-datascope + + + + + com.couplet + couplet-common-log + + + + + com.couplet + couplet-common-swagger + + + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + 1.2.5 + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + diff --git a/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/LyhMqttxApplatcaion.java b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/LyhMqttxApplatcaion.java new file mode 100644 index 0000000..02986b8 --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/LyhMqttxApplatcaion.java @@ -0,0 +1,26 @@ +package com.couplet.mqtt; + +import com.couplet.common.security.annotation.EnableCustomConfig; +import com.couplet.common.security.annotation.EnableMyFeignClients; +import com.couplet.common.swagger.annotation.EnableCustomSwagger2; +import com.couplet.mqtt.service.impl.MqttListen; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @ProjectName: Default (Template) Project + * @Author: LiuYunHu + * @CreateTime: 2024/3/28 + * @Description: + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableMyFeignClients +@SpringBootApplication +public class LyhMqttxApplatcaion { + public static void main(String[] args) { + SpringApplication.run(LyhMqttxApplatcaion.class, args); + System.out.println("获取报文模块启动成功"); + } +} diff --git a/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/controller/Test.java b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/controller/Test.java new file mode 100644 index 0000000..11f75ca --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/controller/Test.java @@ -0,0 +1,51 @@ +package com.couplet.mqtt.controller; + +import org.eclipse.paho.client.mqttv3.*; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/28 + * @Description: + */ + +public class Test { + public static void main(String[] args) { + String broker = "tcp://115.159.47.13:1883"; + String clientId = "JavaMqttSubscriber"; + String topic = "test"; // 替换成您要订阅的主题 + + try { + MqttClient client = new MqttClient(broker, clientId, new MemoryPersistence()); + MqttConnectOptions connOpts = new MqttConnectOptions(); + connOpts.setCleanSession(true); + + System.out.println("Connecting to broker: " + broker); + client.connect(connOpts); + System.out.println("Connected"); + + client.setCallback(new MqttCallback() { + @Override + public void connectionLost(Throwable cause) { + System.out.println("Connection lost"); + } + + @Override + public void messageArrived(String topic, MqttMessage message) throws Exception { + System.out.println("Received message: " + new String(message.getPayload())); + } + + @Override + public void deliveryComplete(IMqttDeliveryToken token) { + } + }); + + client.subscribe(topic); + System.out.println("Subscribed to topic: " + topic); + } catch (MqttException e) { + e.printStackTrace(); + } + } +} + diff --git a/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/mapper/MqttMapper.java b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/mapper/MqttMapper.java new file mode 100644 index 0000000..c9c07e3 --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/mapper/MqttMapper.java @@ -0,0 +1,15 @@ +package com.couplet.mqtt.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/28 + * @Description: + */ +@Component +@Mapper +public interface MqttMapper { +} diff --git a/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/MqttService.java b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/MqttService.java new file mode 100644 index 0000000..68277a7 --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/MqttService.java @@ -0,0 +1,12 @@ +package com.couplet.mqtt.service; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/28 + * @Description: + */ + +public interface MqttService { + +} diff --git a/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/impl/MqttListen.java b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/impl/MqttListen.java new file mode 100644 index 0000000..b519726 --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/impl/MqttListen.java @@ -0,0 +1,108 @@ +package com.couplet.mqtt.service.impl; + +import lombok.extern.slf4j.Slf4j; +import org.eclipse.paho.client.mqttv3.*; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/28 + * @Description: mqtt客户端 + */ +@Component +@Slf4j +public class MqttListen { + /* + * 路径 + * */ + @Value("${mqtt.server.broker}") + private String BROKER; + + /* + * 主题 + * */ + @Value("${mqtt.server.topic}") + private String TOPIC; + + /* + * 客户端id + * */ + @Value("${mqtt.server.clientid}") + private String CLIENTID; + + /* + * 用户名 + * */ + @Value("${mqtt.server.username}") + private String USERNAME; + + /* + * 密码 + * */ + @Value("${mqtt.server.password}") + private String PASSWORD; + + /* + * qos + * */ + @Value("${mqtt.server.qos}") + private Integer QOS; + + + + @PostConstruct + public void connect() { + System.out.println("监听者启动"); + try { + + MqttClient client = new MqttClient(BROKER, CLIENTID, new MemoryPersistence()); + MqttConnectOptions options = new MqttConnectOptions(); + options.setUserName(USERNAME); + options.setPassword(PASSWORD.toCharArray()); + + //连接超时 + options.setConnectionTimeout(60); + + //心跳 + options.setKeepAliveInterval(60); + + log.info("连接到:"+BROKER); + + client.connect(options); + log.info("连接成功"); + + //设置回调 + client.setCallback(new MqttCallback() { + @Override + public void connectionLost(Throwable throwable) { + log.error("连接断开:" + throwable.getMessage()); + } + + @Override + public void messageArrived(String topic, MqttMessage message) throws Exception { + log.info("消息到达"); + log.info("接收消息主题:" + topic); + log.info("接收消息Qos:" + message.getQos()); + log.info("接收消息内容:" + new String(message.getPayload())); + + } + + @Override + public void deliveryComplete(IMqttDeliveryToken token) { + log.info("消息发送成功----------" + token.isComplete()); + } + }); + client.subscribe(TOPIC, QOS); + + + } catch (MqttException e) { + throw new RuntimeException(e); + } + + } +} diff --git a/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/impl/MqttServiceImpl.java b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/impl/MqttServiceImpl.java new file mode 100644 index 0000000..d1372ef --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/java/com/couplet/mqtt/service/impl/MqttServiceImpl.java @@ -0,0 +1,16 @@ +package com.couplet.mqtt.service.impl; + +import com.couplet.mqtt.service.MqttService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/28 + * @Description: + */ +@Service +@Slf4j +public class MqttServiceImpl implements MqttService { +} diff --git a/couplet-modules/couplet-modules-mqtt/src/main/resources/banner.txt b/couplet-modules/couplet-modules-mqtt/src/main/resources/banner.txt new file mode 100644 index 0000000..0dd5eee --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/couplet-modules/couplet-modules-mqtt/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-mqtt/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..d74e389 --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/resources/bootstrap.yml @@ -0,0 +1,40 @@ +# Tomcat +server: + port: 9616 + +# Spring +spring: + application: + # 应用名称 + name: couplet-mqtt + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 121.89.211.230:8848 + namespace: 172469 + config: + # 配置中心地址 + server-addr: 121.89.211.230:8848 + namespace: 172469 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.couplet.system.mapper: DEBUG + +# 订阅端配置 +mqtt: + server: + broker: tcp://115.159.47.13:1883 + username: + password: + clientid: mqttx + qos: 0 + topic: test diff --git a/couplet-modules/couplet-modules-mqtt/src/main/resources/logback.xml b/couplet-modules/couplet-modules-mqtt/src/main/resources/logback.xml new file mode 100644 index 0000000..4940ee0 --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/couplet-modules/couplet-modules-mqtt/src/main/resources/mapper/mqtt/MqttMapper.xml b/couplet-modules/couplet-modules-mqtt/src/main/resources/mapper/mqtt/MqttMapper.xml new file mode 100644 index 0000000..5a70a2c --- /dev/null +++ b/couplet-modules/couplet-modules-mqtt/src/main/resources/mapper/mqtt/MqttMapper.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/couplet-modules/couplet-modules-vehicle/pom.xml b/couplet-modules/couplet-modules-vehicle/pom.xml new file mode 100644 index 0000000..bd06244 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/pom.xml @@ -0,0 +1,114 @@ + + + + com.couplet + couplet-modules + 3.6.3 + + 4.0.0 + + couplet-modules-vehicle + + + + + + + + + couplet-modules-vehicle车辆管理模块 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.couplet + couplet-common-datasource + + + + + com.couplet + couplet-common-datascope + + + + + com.couplet + couplet-common-log + + + + + com.couplet + couplet-common-swagger + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/CoupletVehicleApplication.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/CoupletVehicleApplication.java new file mode 100644 index 0000000..813555c --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/CoupletVehicleApplication.java @@ -0,0 +1,24 @@ +package com.couplet.vehicle; + +import com.couplet.common.security.annotation.EnableCustomConfig; +import com.couplet.common.security.annotation.EnableMyFeignClients; +import com.couplet.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @ProjectName: Default (Template) Project + * @Author: LiuYunHu + * @CreateTime: 2024/3/26 + * @Description: + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableMyFeignClients +@SpringBootApplication +public class CoupletVehicleApplication { + public static void main(String[] args) { + SpringApplication.run(CoupletVehicleApplication.class, args); + System.out.println("车辆管理模块启动成功"); + } +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java new file mode 100644 index 0000000..3bfe921 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java @@ -0,0 +1,92 @@ +package com.couplet.vehicle.controller; + +import com.couplet.common.core.domain.Result; +import com.couplet.common.core.web.controller.BaseController; +import com.couplet.common.log.annotation.Log; +import com.couplet.common.log.enums.BusinessType; +import com.couplet.vehicle.domain.LyhVehicle; +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 org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/26 + * @Description: + */ +@RestController +@RequestMapping("/vehicle") +public class VehicleController extends BaseController { + @Autowired + private VehicleService lyhVehicleService; + + /* + * @Author: LiuYunHu + * @Date: 2024/3/26 21:39 + * @Description: 查询车辆列表 + * @Param: [listParams] + * @Return: com.couplet.common.core.domain.Result + **/ + @PostMapping("/list") + @Log(title = "车辆列表") + public Result list(@RequestBody VehicleListParams listParams) { + + List List = lyhVehicleService.list(listParams); + + return Result.success(List); + } + + /* + * @Author: LiuYunHu + * @Date: 2024/3/26 22:35 + * @Description: 通过id删除车辆 + * @Param: [vehicleId] + * @Return: com.couplet.common.core.domain.Result + **/ + @GetMapping("/deleteById/{vehicleId}") + @Log(title = "删除车辆", businessType = BusinessType.DELETE) + public Result deleteById(@PathVariable Long vehicleId) { + String result = lyhVehicleService.deleteById(vehicleId); + + return Result.success(result); + } + + + /* + * @Author: LiuYunHu + * @Date: 2024/3/27 16:09 + * @Description: 编辑车辆 + * @Param: [editParams] + * @Return: com.couplet.common.core.domain.Result + **/ + @PostMapping("/editById") + @Log(title = "编辑车辆", businessType = BusinessType.UPDATE) + public Result editById(@RequestBody VehicleEditParams editParams) { + + String result = lyhVehicleService.editById(editParams); + + return Result.success(result); + } + + /* + * @Author: LiuYunHu + * @Date: 2024/3/27 16:21 + * @Description: 新增车辆 + * @Param: [insertParams] + * @Return: com.couplet.common.core.domain.Result + **/ + @PostMapping("/insert") + @Log(title = "新增车辆", businessType = BusinessType.INSERT) + public Result insert(@RequestBody VehicleInsertParams insertParams) { + + String result = lyhVehicleService.insert(insertParams); + + return Result.success(result); + } +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/LyhVehicle.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/LyhVehicle.java new file mode 100644 index 0000000..26058ed --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/LyhVehicle.java @@ -0,0 +1,82 @@ +package com.couplet.vehicle.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/26 + * @Description: 车辆信息表 + */ + +@Data +@SuperBuilder +@AllArgsConstructor +@NoArgsConstructor +@TableName("lyh_vehicle") +public class LyhVehicle { + + /* + *车辆id + * */ + @TableId(type = IdType.AUTO, value = "vehicle_id") + private Long vehicleId; + + /* + *车辆类型 + * */ + @TableField(value = "vehicle_type") + private Integer vehicleType; + + + /* + *电机厂商 + * */ + @TableField(value = "motor_manufacturer") + private String motorManufacturer; + + /* + *电池厂商 + * */ + @TableField(value = "battery_manufacturer") + private String batteryManufacturer; + + /* + *电机编号 + * */ + @TableField(value = "motor_number") + private String motorNumber; + + /* + *电池编号 + * */ + @TableField(value = "battery_number") + private String batteryNumber; + + /* + *vin码 + * */ + @TableField(value = "vin") + private String vin; + + /* + *0离线 1在线 + * */ + @TableField(value = "vehicle_state") + private Integer vehicleState; + + /* + *0未删除 1删除 + * */ + @TableField(value = "isdelete") + private Integer isdelete; + + +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleEditParams.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleEditParams.java new file mode 100644 index 0000000..75f8c05 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleEditParams.java @@ -0,0 +1,51 @@ +package com.couplet.vehicle.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/27 + * @Description: 车辆编辑入参 + */ + +@Data +@SuperBuilder +@AllArgsConstructor +@NoArgsConstructor +public class VehicleEditParams { + /* + *车辆id + * */ + private Long vehicleId; + + /* + *车辆类型 + * */ + private Integer vehicleType; + + + /* + *电机厂商 + * */ + private String motorManufacturer; + + /* + *电池厂商 + * */ + private String batteryManufacturer; + + /* + *电机编号 + * */ + private String motorNumber; + + /* + *电池编号 + * */ + private String batteryNumber; + +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleInsertParams.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleInsertParams.java new file mode 100644 index 0000000..047c15b --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleInsertParams.java @@ -0,0 +1,55 @@ +package com.couplet.vehicle.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/27 + * @Description: 车辆编辑入参 + */ + +@Data +@SuperBuilder +@AllArgsConstructor +@NoArgsConstructor +public class VehicleInsertParams { + + /* + *车辆类型 + * */ + @NotNull(message = "车辆类型不能为空") + private Integer vehicleType; + + + /* + *电机厂商 + * */ + @NotBlank(message = "电机厂商不能为空") + private String motorManufacturer; + + /* + *电池厂商 + * */ + @NotBlank(message = "电池厂商不能为空") + private String batteryManufacturer; + + /* + *电机编号 + * */ + @NotBlank(message = "电机编号不能为空") + private String motorNumber; + + /* + *电池编号 + * */ + @NotBlank(message = "电池编号不能为空") + private String batteryNumber; + +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleListParams.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleListParams.java new file mode 100644 index 0000000..7568e72 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleListParams.java @@ -0,0 +1,29 @@ +package com.couplet.vehicle.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/26 + * @Description: 查询车辆列表入参 + */ +@Data +@SuperBuilder +@AllArgsConstructor +@NoArgsConstructor +public class VehicleListParams { + /* + *车辆类型 + * */ + private Integer vehicleType; + + /* + *0离线 1在线 + * */ + private Integer vehicleState; + +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/mapper/VehicleMapper.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/mapper/VehicleMapper.java new file mode 100644 index 0000000..adeb7bf --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/mapper/VehicleMapper.java @@ -0,0 +1,17 @@ +package com.couplet.vehicle.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.couplet.vehicle.domain.LyhVehicle; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/26 + * @Description: + */ +@Mapper +@Component +public interface VehicleMapper extends BaseMapper { +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java new file mode 100644 index 0000000..93b680e --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java @@ -0,0 +1,26 @@ +package com.couplet.vehicle.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.couplet.vehicle.domain.LyhVehicle; +import com.couplet.vehicle.domain.req.VehicleEditParams; +import com.couplet.vehicle.domain.req.VehicleInsertParams; +import com.couplet.vehicle.domain.req.VehicleListParams; + +import java.util.List; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/26 + * @Description: + */ + +public interface VehicleService extends IService { + List list(VehicleListParams listParams); + + String deleteById(Long vehicleId); + + String editById(VehicleEditParams editParams); + + String insert(VehicleInsertParams insertParams); +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.java new file mode 100644 index 0000000..0227349 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.java @@ -0,0 +1,162 @@ +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.utils.StringUtils; +import com.couplet.vehicle.domain.LyhVehicle; +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.mapper.VehicleMapper; +import com.couplet.vehicle.service.VehicleService; +import com.couplet.vehicle.utils.SnowflakeIdGenerator; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/26 + * @Description: + */ + +@Service +@Slf4j +public class VehicleServiceImpl extends ServiceImpl implements VehicleService { + @Autowired + private VehicleMapper lyhVehicleMapper; + + /* + * @Author: LiuYunHu + * @Date: 2024/3/26 22:11 + * @Description: 查询列表 + * @Param: [listParams] + * @Return: java.util.List + **/ + @Override + public List list(VehicleListParams listParams) { + // 创建查询条件包装器 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + // 如果车辆类型不为空,添加车辆类型作为查询条件 + if (!StringUtils.isNull(listParams.getVehicleType())) { + queryWrapper.eq(LyhVehicle::getVehicleType, listParams.getVehicleType()); + } + + // 如果车辆状态不为空,添加车辆状态作为查询条件 + if (!StringUtils.isNull(listParams.getVehicleState())) { + queryWrapper.eq(LyhVehicle::getVehicleState, listParams.getVehicleState()); + } + + //只查询车辆未被删除的 + queryWrapper.eq(LyhVehicle::getIsdelete, 0); + + // 执行查询并返回结果 + return this.list(queryWrapper); + } + + /* + * @Author: LiuYunHu + * @Date: 2024/3/26 22:31 + * @Description: 通过id删除 + * @Param: [vehicleId] + * @Return: java.lang.String + **/ + @Override + public String deleteById(Long vehicleId) { + String result = ""; + + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + + updateWrapper.set("isdelete", 1) + .eq("vehicle_id", vehicleId); + + boolean update = update(updateWrapper); + + if (!update) { + result = "删除失败"; + throw new RuntimeException(result); + } + + result = "删除成功!"; + + return result; + } + + /* + * @Author: LiuYunHu + * @Date: 2024/3/27 15:21 + * @Description: 通过id进行编辑 + * @Param: [editParams] + * @Return: java.lang.String + **/ + @Override + public String editById(VehicleEditParams editParams) { + String result = ""; + + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + + //编辑车辆类型 + + updateWrapper.set("vehicle_type", editParams.getVehicleType()) + + //编辑电机厂商 + .set("motor_manufacturer", editParams.getMotorManufacturer()) + + //编辑电池厂商 + .set("battery_manufacturer", editParams.getBatteryManufacturer()) + + //编辑电机编号 + .set("motor_number", editParams.getMotorNumber()) + + //编辑电池编号 + .set("battery_number", editParams.getBatteryNumber()) + + //匹配车辆id + .eq("vehicle_id", editParams.getVehicleId()); + + + boolean update = update(updateWrapper); + + if (!update) { + result = "编辑失败"; + throw new RuntimeException(result); + } + + result = "编辑成功!"; + + return result; + } + + /* + * @Author: LiuYunHu + * @Date: 2024/3/27 16:34 + * @Description: 新增车辆 + * @Param: [insertParams] + * @Return: java.lang.String + **/ + @Override + public String insert(VehicleInsertParams insertParams) { + String result = ""; + + SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1); + long randomId = idGenerator.nextId(); + String vin = "VIN" + randomId; + + int insert = lyhVehicleMapper.insert(new LyhVehicle(null, insertParams.getVehicleType(), insertParams.getMotorManufacturer(), insertParams.getBatteryManufacturer(), insertParams.getMotorNumber(), insertParams.getBatteryNumber(), vin, 0, 0)); + + if (insert == 0) { + result = "新增失败"; + throw new RuntimeException(result); + } + + result = "新增成功!"; + + return result; + } + +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/utils/SnowflakeIdGenerator.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/utils/SnowflakeIdGenerator.java new file mode 100644 index 0000000..3f6132c --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/utils/SnowflakeIdGenerator.java @@ -0,0 +1,79 @@ +package com.couplet.vehicle.utils; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/27 + * @Description: 雪花ID生成器 + * 使用方法 + * SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1); // 创建一个 ID 生成器,传入机器 ID 和数据中心 ID + * long id = idGenerator.nextId(); // 生成 ID + */ + +public class SnowflakeIdGenerator { + + private final long epoch = 1420041600000L; // 起始时间戳,用于缩小时间戳范围,可根据实际情况调整 + private final long workerIdBits = 5L; // 机器 ID 所占位数 + private final long dataCenterIdBits = 5L; // 数据中心 ID 所占位数 + private final long sequenceBits = 12L; // 序列号所占位数 + + private final long maxWorkerId = -1L ^ (-1L << workerIdBits); // 机器 ID 最大值 + private final long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits); // 数据中心 ID 最大值 + private final long maxSequence = -1L ^ (-1L << sequenceBits); // 序列号最大值 + + private final long workerIdShift = sequenceBits; // 机器 ID 向左移动位数 + private final long dataCenterIdShift = sequenceBits + workerIdBits; // 数据中心 ID 向左移动位数 + private final long timestampShift = sequenceBits + workerIdBits + dataCenterIdBits; // 时间戳向左移动位数 + + private long workerId; // 机器 ID + private long dataCenterId; // 数据中心 ID + private long sequence = 0L; // 序列号 + private long lastTimestamp = -1L; // 上次生成的时间戳 + + public SnowflakeIdGenerator(long workerId, long dataCenterId) { + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException("Worker ID can't be greater than " + maxWorkerId + " or less than 0"); + } + if (dataCenterId > maxDataCenterId || dataCenterId < 0) { + throw new IllegalArgumentException("Data center ID can't be greater than " + maxDataCenterId + " or less than 0"); + } + this.workerId = workerId; + this.dataCenterId = dataCenterId; + } + + public synchronized long nextId() { + long timestamp = timeGen(); + + if (timestamp < lastTimestamp) { + throw new RuntimeException("Clock moved backwards, refusing to generate ID"); + } + + if (timestamp == lastTimestamp) { + sequence = (sequence + 1) & maxSequence; + if (sequence == 0) { + timestamp = tilNextMillis(lastTimestamp); + } + } else { + sequence = 0L; + } + + lastTimestamp = timestamp; + + return ((timestamp - epoch) << timestampShift) | + (dataCenterId << dataCenterIdShift) | + (workerId << workerIdShift) | + sequence; + } + + private long tilNextMillis(long lastTimestamp) { + long timestamp = timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = timeGen(); + } + return timestamp; + } + + private long timeGen() { + return System.currentTimeMillis(); + } +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/resources/banner.txt b/couplet-modules/couplet-modules-vehicle/src/main/resources/banner.txt new file mode 100644 index 0000000..0dd5eee --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-vehicle/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..b30719a --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/resources/bootstrap.yml @@ -0,0 +1,30 @@ +# Tomcat +server: + port: 9615 + +# Spring +spring: + application: + # 应用名称 + name: couplet-vehicle + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 121.89.211.230:8848 + namespace: 172469 + config: + # 配置中心地址 + server-addr: 121.89.211.230:8848 + namespace: 172469 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.couplet.system.mapper: DEBUG diff --git a/couplet-modules/couplet-modules-vehicle/src/main/resources/logback.xml b/couplet-modules/couplet-modules-vehicle/src/main/resources/logback.xml new file mode 100644 index 0000000..4940ee0 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/couplet-modules/couplet-modules-vehicle/src/main/resources/mapper/vehicle/VehicleMapper.xml b/couplet-modules/couplet-modules-vehicle/src/main/resources/mapper/vehicle/VehicleMapper.xml new file mode 100644 index 0000000..ac9dc8d --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/resources/mapper/vehicle/VehicleMapper.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/couplet-modules/couplet-modules-vehicle/src/test/java/IdTest.java b/couplet-modules/couplet-modules-vehicle/src/test/java/IdTest.java new file mode 100644 index 0000000..8a754b4 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/test/java/IdTest.java @@ -0,0 +1,20 @@ +import com.couplet.vehicle.utils.SnowflakeIdGenerator; + +/** + * @ProjectName: five-groups-couplet + * @Author: LiuYunHu + * @CreateTime: 2024/3/27 + * @Description: + */ + +public class IdTest { + + + public static void main(String[] args) { + SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1); + + long l = idGenerator.nextId(); + System.out.println(l); + + } +} diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysDeptController.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysDeptController.java index da7f6c0..3d47e40 100644 --- a/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysDeptController.java +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysDeptController.java @@ -14,12 +14,9 @@ import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import java.util.List; - /** * 部门信息 - * * @author couplet */ @RestController @@ -110,4 +107,15 @@ public class SysDeptController extends BaseController { deptService.checkDeptDataScope(deptId); return toAjax(deptService.deleteDeptById(deptId)); } + + /** + * 根据企业ID获取企业下部门 + * @param enterpriseId 企业ID + * @return 企业信息,内含有部门 + */ + @GetMapping("/getSysDeptByEnterpriseId/{enterpriseId}") + public Result getSysDeptByEnterpriseId(@PathVariable(value = "enterpriseId") Long enterpriseId){ + SysDept sysDept = deptService.getSysDeptByEnterpriseId(enterpriseId); + return Result.success(sysDept); + } } diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysFirmController.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysFirmController.java new file mode 100644 index 0000000..404529b --- /dev/null +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysFirmController.java @@ -0,0 +1,64 @@ +package com.couplet.system.controller; + +import com.couplet.common.core.domain.Result; +import com.couplet.common.system.domain.SysFirm; +import com.couplet.system.service.SysFirmService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @ClassName SysFirmController + * @Description 企业信息 + * @Author YuanYongH + * @Date 2024/3/28 22:14 + */ +@RestController +@RequestMapping("firm") +public class SysFirmController { + + @Autowired + private SysFirmService sysFirmService; + /** + * @Description // 管理企业列表 + * @Date 2024/3/28 + * @param sysFirm + * @return com.couplet.common.core.domain.Result> + **/ + @PostMapping("firmList") + public Result> firmList(@RequestBody SysFirm sysFirm){ + List list = sysFirmService.firmList(sysFirm); + Result> result = Result.success(list); + return result; + } + + /** + * @Description // 添加企业 默认未认证 + * @Date 2024/3/28 + * @param sysFirm + * @return com.couplet.common.core.domain.Result + **/ + @PostMapping("addFirm") + public Result addFirm(@RequestBody SysFirm sysFirm){ + int i = sysFirmService.addFirm(sysFirm); + Result result = Result.success(i); + return result; + } + + /** + * @Description // 修改企业信息 + * @Date 2024/3/28 + * @param sysFirm + * @return com.couplet.common.core.domain.Result + **/ + @PostMapping("updateFirm") + public Result updateFirm(@RequestBody SysFirm sysFirm){ + int i = sysFirmService.updateFirm(sysFirm); + Result result = Result.success(i); + return result; + } +} diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysUserController.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysUserController.java index 91aa779..493cb33 100644 --- a/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysUserController.java +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/controller/SysUserController.java @@ -107,10 +107,13 @@ public class SysUserController extends BaseController { Set roles = permissionService.getRolePermission(sysUser); // 权限集合 Set permissions = permissionService.getMenuPermission(sysUser); + // 查询企业信息 + Long deptId = deptService.selectDeptIdByLeader(sysUser.getUserName()); LoginUser sysUserVo = new LoginUser(); sysUserVo.setSysUser(sysUser); sysUserVo.setRoles(roles); sysUserVo.setPermissions(permissions); + sysUserVo.setEnterpriseId(deptId); return Result.success(sysUserVo); } diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/mapper/SysFirmMapper.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/mapper/SysFirmMapper.java new file mode 100644 index 0000000..f5f1429 --- /dev/null +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/mapper/SysFirmMapper.java @@ -0,0 +1,22 @@ +package com.couplet.system.mapper; + +import com.couplet.common.system.domain.SysFirm; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @ClassName SysFirmMapper + * @Description TODO + * @Author YuanYongH + * @Date 2024/3/28 22:18 + */ +@Mapper +public interface SysFirmMapper { + List firmList(SysFirm sysFirm); + + int addFirm(SysFirm sysFirm); + + int updateFirm(SysFirm sysFirm); + +} diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/SysDeptService.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/SysDeptService.java index 2a5889e..dde112b 100644 --- a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/SysDeptService.java +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/SysDeptService.java @@ -135,4 +135,18 @@ public interface SysDeptService extends IService { * @return 结果 */ public int deleteDeptById (Long deptId); + + /** + * 通过负责人查询企业ID + * @param leader 负责人 + * @return 企业ID + */ + Long selectDeptIdByLeader (String leader); + + /** + * 根据企业ID获取企业下部门 + * @param enterpriseId 企业ID + * @return 企业信息,内含有部门 + */ + SysDept getSysDeptByEnterpriseId (Long enterpriseId); } diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/SysFirmService.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/SysFirmService.java new file mode 100644 index 0000000..ceeebad --- /dev/null +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/SysFirmService.java @@ -0,0 +1,19 @@ +package com.couplet.system.service; + +import com.couplet.common.system.domain.SysFirm; + +import java.util.List; + +/** + * @ClassName SysFirmService + * @Description TODO + * @Author YuanYongH + * @Date 2024/3/28 22:17 + */ +public interface SysFirmService { + List firmList(SysFirm sysFirm); + + int addFirm(SysFirm sysFirm); + + int updateFirm(SysFirm sysFirm); +} diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysDeptServiceImpl.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysDeptServiceImpl.java index 98059a3..05f5ec9 100644 --- a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysDeptServiceImpl.java +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysDeptServiceImpl.java @@ -1,5 +1,6 @@ package com.couplet.system.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.couplet.common.core.constant.UserConstants; import com.couplet.common.core.exception.ServiceException; @@ -17,6 +18,7 @@ import com.couplet.system.mapper.SysRoleMapper; import com.couplet.system.service.SysDeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; import java.util.ArrayList; import java.util.Iterator; @@ -280,6 +282,34 @@ public class SysDeptServiceImpl extends ServiceImpl impl return deptMapper.deleteDeptById(deptId); } + /** + * 通过负责人查询企业ID + * + * @param leader 负责人 + * + * @return 企业ID + */ + @Override + public Long selectDeptIdByLeader (String leader) { + SysDept sysDept = getOne(new LambdaQueryWrapper<>() {{ + eq(SysDept::getLeader, leader); + }}); + + return sysDept == null ? null : sysDept.getDeptId(); + } + + /** + * 根据企业ID获取企业下部门 + * + * @param enterpriseId 企业ID + * + * @return 企业信息,内含有部门 + */ + @Override + public SysDept getSysDeptByEnterpriseId (Long enterpriseId) { + return null; + } + /** * 递归列表 */ diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysFirmServiceImpl.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysFirmServiceImpl.java new file mode 100644 index 0000000..903a67a --- /dev/null +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysFirmServiceImpl.java @@ -0,0 +1,35 @@ +package com.couplet.system.service.impl; + +import com.couplet.common.system.domain.SysFirm; +import com.couplet.system.mapper.SysFirmMapper; +import com.couplet.system.service.SysFirmService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @ClassName SysFirmServiceImpl + * @Description TODO + * @Author YuanYongH + * @Date 2024/3/28 22:17 + */ +@Service +public class SysFirmServiceImpl implements SysFirmService { + @Autowired + private SysFirmMapper sysFirmMapper; + @Override + public List firmList(SysFirm sysFirm) { + return sysFirmMapper.firmList(sysFirm); + } + + @Override + public int addFirm(SysFirm sysFirm) { + return sysFirmMapper.addFirm(sysFirm); + } + + @Override + public int updateFirm(SysFirm sysFirm) { + return sysFirmMapper.updateFirm(sysFirm); + } +} diff --git a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysUserServiceImpl.java b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysUserServiceImpl.java index f0463f6..4683c96 100644 --- a/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysUserServiceImpl.java +++ b/couplet-modules/couplet-system/src/main/java/com/couplet/system/service/impl/SysUserServiceImpl.java @@ -61,6 +61,8 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @DataScope(deptAlias = "d", userAlias = "u") public List selectUserList (SysUser user) { + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + user.setDeptId(deptId); return userMapper.selectUserList(user); } diff --git a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml index 5ddc18b..0c29b0b 100644 --- a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml @@ -15,16 +15,16 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 logging: level: com.couplet.system.mapper: DEBUG diff --git a/couplet-modules/couplet-system/src/main/resources/mapper/system/SysFirmMapper.xml b/couplet-modules/couplet-system/src/main/resources/mapper/system/SysFirmMapper.xml new file mode 100644 index 0000000..99ca2eb --- /dev/null +++ b/couplet-modules/couplet-system/src/main/resources/mapper/system/SysFirmMapper.xml @@ -0,0 +1,22 @@ + + + + + INSERT INTO `ry-cloud`.`yyh_firm` ( `firm_name`) + VALUES ( #{firmName}); + + + + + UPDATE `ry-cloud`.`yyh_firm` + SET `firm_name` = #{firmName}, `approve_id` = #{approveId} + WHERE `firm_id` = #{firmId}; + + + + + diff --git a/couplet-modules/couplet-trouble/src/main/resources/bootstrap.yml b/couplet-modules/couplet-trouble/src/main/resources/bootstrap.yml index c73ca5b..2739b92 100644 --- a/couplet-modules/couplet-trouble/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-trouble/src/main/resources/bootstrap.yml @@ -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 logging: level: com.couplet.trouble.mapper: DEBUG diff --git a/couplet-modules/pom.xml b/couplet-modules/pom.xml index 8372348..6594626 100644 --- a/couplet-modules/pom.xml +++ b/couplet-modules/pom.xml @@ -14,6 +14,10 @@ couplet-job couplet-file couplet-trouble + couplet-electronic-fence + couplet-modules-vehicle + couplet-modules-mqtt + couplet-enterprisemanagement couplet-modules diff --git a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml index 98a7702..d08106c 100644 --- a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml +++ b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml @@ -15,13 +15,13 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 diff --git a/pom.xml b/pom.xml index 196caab..fcd0e7c 100644 --- a/pom.xml +++ b/pom.xml @@ -211,6 +211,40 @@ couplet-modules-system ${couplet.version} + + com.couplet + couplet-trouble + ${couplet.version} + + + com.couplet + couplet-electronic-fence-server + ${couplet.version} + + + com.couplet + couplet-electronic-fence-common + ${couplet.version} + + + com.couplet + couplet-electronic-fence-remote + ${couplet.version} + + + + + com.couplet + couplet-enterprisemanagement-common + ${couplet.version} + + + + + com.couplet + couplet-enterprisemanagement-remote + ${couplet.version} +