fix():重构电子围栏以及围栏组

dev
86191 2024-09-24 11:13:34 +08:00
parent 0619a5102c
commit ffc698bc11
41 changed files with 29 additions and 499 deletions

View File

@ -1,19 +0,0 @@
package com.muyu.fence;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-18 11:27:38
*/
@SpringBootApplication
@EnableMyFeignClients
public class FenceApplication {
public static void main(String[] args) {
SpringApplication.run(FenceApplication.class, args);
}
}

View File

@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.controller
* @Projectcloud-server
* @nameFenceEtlController

View File

@ -20,7 +20,7 @@ import java.util.Collection;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.controller
* @Projectcloud-server
* @nameFenceGroupController

View File

@ -1,112 +0,0 @@
package com.muyu.fence.controller;
import java.util.Arrays;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.fence.domain.TbFence;
import com.muyu.fence.service.ITbFenceService;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.security.utils.SecurityUtils;
import org.springframework.validation.annotation.Validated;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-09-18
*/
@RestController
@RequestMapping("/fence")
public class TbFenceController extends BaseController
{
@Resource
private ITbFenceService tbFenceService;
/**
*
*/
@RequiresPermissions("fence:fence:list")
@GetMapping("/list")
public Result<TableDataInfo<TbFence>> list(TbFence tbFence)
{
startPage();
List<TbFence> list = tbFenceService.selectTbFenceList(tbFence);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("fence:fence:export")
@PostMapping("/export")
public void export(HttpServletResponse response, TbFence tbFence)
{
List<TbFence> list = tbFenceService.selectTbFenceList(tbFence);
ExcelUtil<TbFence> util = new ExcelUtil<TbFence>(TbFence.class);
util.exportExcel(response, list, "电子围栏数据");
}
/**
*
*/
@RequiresPermissions("fence:fence:query")
@GetMapping(value = "/{fenceId}")
public Result<List<TbFence>> getInfo(@PathVariable("fenceId") Long fenceId)
{
return success(tbFenceService.selectTbFenceByFenceId(fenceId));
}
/**
*
*/
@RequiresPermissions("fence:fence:add")
@PostMapping
public Result<Integer> add(
@Validated @RequestBody TbFence tbFence)
{
if (tbFenceService.checkIdUnique(tbFence)) {
return error("新增 电子围栏 '" + tbFence + "'失败,电子围栏已存在");
}
tbFence.setCreateBy(SecurityUtils.getUsername());
return toAjax(tbFenceService.save(tbFence));
}
/**
*
*/
@RequiresPermissions("fence:fence:edit")
@PutMapping
public Result<Integer> edit(
@Validated @RequestBody TbFence tbFence)
{
if (!tbFenceService.checkIdUnique(tbFence)) {
return error("修改 电子围栏 '" + tbFence + "'失败,电子围栏不存在");
}
tbFence.setUpdateBy(SecurityUtils.getUsername());
return toAjax(tbFenceService.updateById(tbFence));
}
/**
*
*/
@RequiresPermissions("fence:fence:remove")
@DeleteMapping("/{fenceIds}")
public Result<Integer> remove(@PathVariable("fenceIds") Long[] fenceIds)
{
tbFenceService.removeBatchByIds(Arrays.asList(fenceIds));
return success();
}
}

View File

@ -1,36 +0,0 @@
package com.muyu.fence.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.fence.domain.TbGroup;
import com.muyu.fence.service.TbGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-22 17:00:08
*/
@RestController
@RequestMapping("/tbGroup")
public class TbGroupController {
@Autowired
private TbGroupService tbGroupService;
/**
*
* @return
*/
@GetMapping("/selectTbGroupList")
public Result<List<TbGroup>> selectTbGroupList() {
return Result.success(tbGroupService.selectTbGroupList());
}
}

View File

@ -1,72 +0,0 @@
package com.muyu.fence.domain;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
/**
* tb_fence
*
* @author muyu
* @date 2024-09-18
*/
@Data
@Setter
@Getter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("tb_fence")
public class TbFence extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 围栏编号 */
@TableId( type = IdType.AUTO)
private Long fenceId;
/** 围栏名称 */
@Excel(name = "围栏名称")
private String fenceName;
/** 围栏类型1.驶入2驶出 */
@Excel(name = "围栏类型1.驶入2驶出")
private Long fenceType;
/** 围栏状态1.正常2.停用 */
@Excel(name = "围栏状态1.正常2.停用")
private Long fenceFlag;
/** 经纬度信息 */
@Excel(name = "经纬度信息")
private String longitudeAndLatitudeInformation;
/** 优先级 */
@Excel(name = "优先级")
private String fencePriority;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("fenceId", getFenceId())
.append("fenceName", getFenceName())
.append("fenceType", getFenceType())
.append("fenceFlag", getFenceFlag())
.append("longitudeAndLatitudeInformation", getLongitudeAndLatitudeInformation())
.append("fencePriority", getFencePriority())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -1,26 +0,0 @@
package com.muyu.fence.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-22 16:55:16
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TbGroup {
/**
*
*/
private Integer groupId;
/**
*
*/
private String groupName;
}

View File

@ -16,7 +16,7 @@ import lombok.experimental.SuperBuilder;
import java.util.function.Supplier;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameElectronicFence

View File

@ -16,7 +16,7 @@ import lombok.experimental.SuperBuilder;
import java.util.function.Supplier;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameElectronicFenceGroup

View File

@ -9,7 +9,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameFenceGroupMid

View File

@ -10,7 +10,7 @@ import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameElectroicAdd

View File

@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameElectroicFenceReq

View File

@ -8,7 +8,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameElectroicFenceUpdReq

View File

@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameElectronicFenceGroupAddReq

View File

@ -8,7 +8,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameElectronicFenceGroupListReq

View File

@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameElectronicFenceGroupAddReq

View File

@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameFenceAndGroupBoundReq

View File

@ -5,7 +5,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameFenceWay

View File

@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.resp
* @Projectcloud-server
* @nameElectronicFenceGroupResp

View File

@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameElectronicFence

View File

@ -9,7 +9,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain.req
* @Projectcloud-server
* @nameGroupFenceListresp

View File

@ -1,7 +1,7 @@
package com.muyu.fence.domain.utils;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameElectricFenceModel

View File

@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameElectricFenceResultTmp

View File

@ -9,7 +9,7 @@ import java.sql.Timestamp;
import java.util.Date;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameElectronicFenceResult

View File

@ -10,7 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.domain
* @Projectcloud-server
* @nameElectronicFenceSetting

View File

@ -5,7 +5,7 @@ import com.muyu.fence.domain.database.ElectronicFenceGroup;
import org.apache.ibatis.annotations.Mapper;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.mapper
* @Projectcloud-server
* @nameFenceGroupMapper

View File

@ -5,7 +5,7 @@ import com.muyu.fence.domain.database.ElectronicFence;
import org.apache.ibatis.annotations.Mapper;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.mapper
* @Projectcloud-server
* @nameElectronicFenceMapper

View File

@ -5,7 +5,7 @@ import com.muyu.fence.domain.database.FenceGroupMid;
import org.apache.ibatis.annotations.Mapper;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.mapper
* @Projectcloud-server
* @nameFenceGroupMidMapper

View File

@ -1,17 +0,0 @@
package com.muyu.fence.mapper;
import java.util.List;
import com.muyu.fence.domain.TbFence;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper
*
* @author muyu
* @date 2024-09-18
*/
@Mapper
public interface TbFenceMapper extends BaseMapper<TbFence>{
}

View File

@ -1,12 +0,0 @@
package com.muyu.fence.mapper;
import com.muyu.fence.domain.TbGroup;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TbGroupDao {
//查询围栏组列表
public List<TbGroup> selectTbGroupList();
}

View File

@ -10,7 +10,7 @@ import com.muyu.fence.domain.resp.ElectronicFenceGroupResp;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.service
* @Projectcloud-server
* @nameFenceGroupController

View File

@ -9,7 +9,7 @@ import com.muyu.fence.domain.resp.ElectronicFenceResp;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.service
* @Projectcloud-server
* @nameElectronicFenceService

View File

@ -8,7 +8,7 @@ import com.muyu.fence.domain.resp.ElectronicFenceResp;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.service
* @Projectcloud-server
* @nameFenceGroupMidService

View File

@ -1,37 +0,0 @@
package com.muyu.fence.service;
import java.util.List;
import com.muyu.fence.domain.TbFence;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* Service
*
* @author muyu
* @date 2024-09-18
*/
public interface ITbFenceService extends IService<TbFence> {
/**
*
*
* @param fenceId
* @return
*/
public TbFence selectTbFenceByFenceId(Long fenceId);
/**
*
*
* @param tbFence
* @return
*/
public List<TbFence> selectTbFenceList(TbFence tbFence);
/**
* id
* @param tbFence
* @return
*/
Boolean checkIdUnique(TbFence tbFence);
}

View File

@ -1,10 +0,0 @@
package com.muyu.fence.service;
import com.muyu.fence.domain.TbGroup;
import java.util.List;
public interface TbGroupService {
//查询围栏组列表
public List<TbGroup> selectTbGroupList();
}

View File

@ -22,7 +22,7 @@ import java.util.List;
import java.util.Set;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.service.impl
* @Projectcloud-server
* @nameFenceGroupServiceImpl

View File

@ -20,7 +20,7 @@ import java.util.List;
import java.util.Set;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.service.impl
* @Projectcloud-server
* @nameElectronicFenceServiceImpl

View File

@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author
* @Authoryuping
* @Packagecom.muyu.fence.service.impl
* @Projectcloud-server
* @nameFenceGroupMidServiceImpl

View File

@ -1,80 +0,0 @@
package com.muyu.fence.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.muyu.fence.mapper.TbFenceMapper;
import com.muyu.fence.domain.TbFence;
import com.muyu.fence.service.ITbFenceService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.util.Assert;
/**
* Service
*
* @author muyu
* @date 2024-09-18
*/
@Service
public class TbFenceServiceImpl
extends ServiceImpl<TbFenceMapper, TbFence>
implements ITbFenceService {
/**
*
*
* @param fenceId
* @return
*/
@Override
public TbFence selectTbFenceByFenceId(Long fenceId)
{
LambdaQueryWrapper<TbFence> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(fenceId, "fenceId不可为空");
queryWrapper.eq(TbFence::getFenceId, fenceId);
return this.getOne(queryWrapper);
}
/**
*
*
* @param tbFence
* @return
*/
@Override
public List<TbFence> selectTbFenceList(TbFence tbFence)
{
LambdaQueryWrapper<TbFence> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(tbFence.getFenceName())){
queryWrapper.like(TbFence::getFenceName, tbFence.getFenceName());
}
if (tbFence.getFenceType()!=null){
queryWrapper.eq(TbFence::getFenceType, tbFence.getFenceType());
}
if (tbFence.getFenceFlag()!=null){
queryWrapper.eq(TbFence::getFenceFlag, tbFence.getFenceFlag());
}
if (StringUtils.isNotEmpty(tbFence.getLongitudeAndLatitudeInformation())){
queryWrapper.eq(TbFence::getLongitudeAndLatitudeInformation, tbFence.getLongitudeAndLatitudeInformation());
}
if (tbFence.getFencePriority()!=null){
queryWrapper.eq(TbFence::getFencePriority, tbFence.getFencePriority());
}
return this.list(queryWrapper);
}
/**
*
* @param tbFence
* @return
*/
@Override
public Boolean checkIdUnique(TbFence tbFence) {
LambdaQueryWrapper<TbFence> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TbFence::getFenceId, tbFence.getFenceId());
return this.count(queryWrapper) > 0;
}
}

View File

@ -1,32 +0,0 @@
package com.muyu.fence.service.impl;
import com.muyu.fence.domain.TbGroup;
import com.muyu.fence.mapper.TbGroupDao;
import com.muyu.fence.service.TbGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-22 16:59:33
*/
@Service
public class TbGroupServiceImpl implements TbGroupService {
@Autowired
private TbGroupDao tbGroupDao;
/**
*
* @return
*/
@Override
public List<TbGroup> selectTbGroupList() {
return tbGroupDao.selectTbGroupList();
}
}

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--
1.在mybats的开发中namespace有特殊的意思一定要是对应接口的全限定名
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
-->
<mapper namespace="com.muyu.fence.mapper.TbGroupDao">
<!--查询围栏组列表-->
<select id="selectTbGroupList" resultType="com.muyu.fence.domain.TbGroup">
select group_id, group_name
from tb_group;
</select>
</mapper>