diff --git a/.gitignore b/.gitignore index 55c1137..0f4c0f6 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ buildNumber.properties .mvn/wrapper/maven-wrapper.jar .idea/ +.DS_Store diff --git a/common/src/main/java/com/jiagutech/ams/mapper/RegionMapper.java b/common/src/main/java/com/jiagutech/ams/mapper/RegionMapper.java index d2fe167..b251072 100644 --- a/common/src/main/java/com/jiagutech/ams/mapper/RegionMapper.java +++ b/common/src/main/java/com/jiagutech/ams/mapper/RegionMapper.java @@ -2,6 +2,7 @@ package com.jiagutech.ams.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.jiagutech.ams.model.LoginUser; +import com.jiagutech.ams.model.RegionE; import com.jiagutech.ams.model.RegionVO; import com.jiagutech.ams.model.UserDetail; import com.jiagutech.ams.model.dto.RegionDTO; @@ -23,4 +24,7 @@ public interface RegionMapper extends BaseMapper { RegionVO getCompleteRegionInfo(@Param("regionCode") long regionCode); + + + List selectHistoryJobRegions(@Param("deptId")Long deptId); } diff --git a/social/src/main/java/com/jiagutech/ams/controller/RegionController.java b/social/src/main/java/com/jiagutech/ams/controller/RegionController.java index 7d9c2ba..95fb9ed 100644 --- a/social/src/main/java/com/jiagutech/ams/controller/RegionController.java +++ b/social/src/main/java/com/jiagutech/ams/controller/RegionController.java @@ -1,5 +1,8 @@ package com.jiagutech.ams.controller; +import cn.dev33.satoken.annotation.SaCheckRole; +import cn.dev33.satoken.annotation.SaMode; +import com.jiagutech.ams.model.RegionE; import com.jiagutech.ams.model.common.R; import com.jiagutech.ams.model.dto.RegionDTO; import com.jiagutech.ams.service.RegionService; @@ -28,12 +31,20 @@ public class RegionController { private final RegionService regionService; + @SaCheckRole(value = {"manager", "machinist"}, mode = SaMode.OR) @Operation(summary = "获取下一级的所有区域列表") @GetMapping("getChildren") - public R> getChildren(Long regionCode) { + public R> getChildren(Long regionCode) { List regionDTOList = regionService.getChildren(regionCode); return R.ok(regionDTOList); } + @Operation(summary = "从历史作业中获取区域列表") + @GetMapping("getHistoryJobRegions") + public R> getHistoryJobRegions() { + List historyJobRegions = regionService.getHistoryJobRegions(); + return R.ok(historyJobRegions); + } + } diff --git a/social/src/main/java/com/jiagutech/ams/listener/JobFinishListener.java b/social/src/main/java/com/jiagutech/ams/listener/JobFinishListener.java index 1b05a67..b202645 100644 --- a/social/src/main/java/com/jiagutech/ams/listener/JobFinishListener.java +++ b/social/src/main/java/com/jiagutech/ams/listener/JobFinishListener.java @@ -26,6 +26,11 @@ public class JobFinishListener { @EventListener(JobFinishEvent.class) public void finishJob(JobFinishEvent event) { log.info("JobFinishListener:{}", event.getJobId()); - List trackList = jobService.getTrackList(event.getJobId()); + try { + List trackList = jobService.getTrackList(event.getJobId()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/social/src/main/java/com/jiagutech/ams/model/JobMapping.java b/social/src/main/java/com/jiagutech/ams/model/JobMapping.java index 3e11179..f16e7e4 100644 --- a/social/src/main/java/com/jiagutech/ams/model/JobMapping.java +++ b/social/src/main/java/com/jiagutech/ams/model/JobMapping.java @@ -6,6 +6,7 @@ import com.jiagutech.ams.model.response.JobCreateResponse; import com.jiagutech.ams.model.response.JobItem; import com.jiagutech.ams.model.response.JobPolyItem; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; @@ -16,6 +17,7 @@ public interface JobMapping { JobDTO jobCreateToJobDTO(JobCreateRequest job); + @Mapping(source = "id", target = "jobId") JobCreateResponse jobDTOToJobCreateResponse(JobDTO job); JobPolyItem jobItemToJobPolyItem(JobItem job); diff --git a/social/src/main/java/com/jiagutech/ams/model/TrackDataJG.java b/social/src/main/java/com/jiagutech/ams/model/TrackDataJG.java index 6af2c40..4c78740 100644 --- a/social/src/main/java/com/jiagutech/ams/model/TrackDataJG.java +++ b/social/src/main/java/com/jiagutech/ams/model/TrackDataJG.java @@ -70,51 +70,6 @@ public class TrackDataJG implements Serializable { */ private Float roll; - /** - * 本架次起飞后,已飞行的时间。单位:秒 - */ - private Integer ftime; - - /** - * 本架次起飞后,已喷洒的面积。单位:亩 - */ - private Float farea; - - /** - * 喷洒流速,单位:升/分钟 - */ - private Float curFlow; - - /** - * 目前接收到的导航卫星的数量 - */ - private Integer gpsNum; - - /** - * 定位精度类型,1:GPS/BD 单点,2:差分,4:RTK 固定解,5:RTK 浮点解 - */ - private Integer posAccur; - - private Integer areaCode; - - private Integer flying;//1=正在飞 0在地上 - - //替换 int - long - //private Integer operUserId; - private Long operUserId; - - private Float totalArea;//飞控总亩数 - - private Integer errorCode; - - private Integer deviceType; - - // 耕深(厘米)[浮点数,最多保留一位小数] - private Double deep; - // 流量(脉冲值)[浮点数,最多保留一位小数] - private Double flow; - // 播种速度 粒/s生成对应的实体类 - private Double seeding; } diff --git a/social/src/main/java/com/jiagutech/ams/model/response/JobPolyItem.java b/social/src/main/java/com/jiagutech/ams/model/response/JobPolyItem.java index 26d89ea..fef530c 100644 --- a/social/src/main/java/com/jiagutech/ams/model/response/JobPolyItem.java +++ b/social/src/main/java/com/jiagutech/ams/model/response/JobPolyItem.java @@ -21,6 +21,8 @@ public class JobPolyItem { @ExcelProperty(value = "农户手机号") private String farmerPhone; + @ExcelProperty(value = "作业类型") + private String typeName; @ExcelProperty(value = "开始作业时间") private String startTimeStr; @@ -28,8 +30,7 @@ public class JobPolyItem { @ExcelProperty(value = "作业总面积") private Float area; - @ExcelProperty(value = "作业类型") - private String typeName; + @ExcelProperty(value = "合作社") private String deptName; diff --git a/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java b/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java index b143860..cf4d51e 100644 --- a/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java +++ b/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java @@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.jiagutech.ams.constant.UserConstants; import com.jiagutech.ams.mapper.DeviceMapper; import com.jiagutech.ams.model.LoginUser; @@ -22,9 +24,11 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; +import java.lang.reflect.Type; import java.util.*; import java.util.function.Consumer; import java.util.function.Predicate; +import java.util.stream.Collectors; /** * @ClassName DeviceServiceImpl @@ -50,9 +54,15 @@ public class DeviceServiceImpl implements DeviceService { deviceInfos.add(deviceInfo1); if (CollectionUtils.isNotEmpty(keys)) { List values = stringRedisTemplate.opsForValue().multiGet(keys); - List trackDataJGS = JSON.parseArray(JSON.toJSONString(values), TrackDataJG.class); + if (CollectionUtils.isEmpty(values)) { + return deviceInfos; + } + List trackDataJGS = values.stream().map(s -> JSON.parseObject(s, TrackDataJG.class)).collect(Collectors.toList()); Predicate predicate = t -> t.getLat() <= maxLat && t.getLat() >= minLat && ((t.getLng() >= -180 && t.getLng() <= maxLng) || (t.getLng() >= minLng && t.getLng() <= 180)); + if (maxLat==0 && minLat==0 && maxLng==0 && minLng==0){ + predicate = t-> true; + } Consumer consumer = t -> deviceInfos.add(new DeviceInfo().setBoxNum(t.getDroneId()).setLng(t.getLng()).setLat(t.getLat())); trackDataJGS.stream().filter(predicate).forEach(consumer); LoginUser loginUser = StpUtil.getSession().get(UserConstants.SYS_SESSION, new LoginUser()); @@ -81,7 +91,7 @@ public class DeviceServiceImpl implements DeviceService { Page page = new Page(pageRequest.getPageNum(), pageRequest.getPageSize()); QueryWrapper queryWrapper = Wrappers.query(); LoginUser loginUser = StpUtil.getSession().get(UserConstants.SYS_SESSION, new LoginUser()); - queryWrapper.eq("dept_id",loginUser.getDept().getId()); + queryWrapper.eq("dept_id", loginUser.getDept().getId()); Page result = deviceMapper.selectPage(page, queryWrapper); return PageResult.of((int) result.getTotal(), (int) pageRequest.getPageSize(), (int) result.getCurrent(), result.getRecords()); } diff --git a/social/src/main/java/com/jiagutech/ams/service/RegionService.java b/social/src/main/java/com/jiagutech/ams/service/RegionService.java index 7ab7c6c..444955c 100644 --- a/social/src/main/java/com/jiagutech/ams/service/RegionService.java +++ b/social/src/main/java/com/jiagutech/ams/service/RegionService.java @@ -1,9 +1,12 @@ package com.jiagutech.ams.service; +import com.jiagutech.ams.model.RegionE; import com.jiagutech.ams.model.dto.RegionDTO; import java.util.List; public interface RegionService { List getChildren(Long regionCode); + + List getHistoryJobRegions(); } diff --git a/social/src/main/java/com/jiagutech/ams/service/RegionServiceImpl.java b/social/src/main/java/com/jiagutech/ams/service/RegionServiceImpl.java index eefef8b..ae48cc2 100644 --- a/social/src/main/java/com/jiagutech/ams/service/RegionServiceImpl.java +++ b/social/src/main/java/com/jiagutech/ams/service/RegionServiceImpl.java @@ -2,11 +2,19 @@ package com.jiagutech.ams.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.jiagutech.ams.constant.UserConstants; import com.jiagutech.ams.mapper.RegionMapper; +import com.jiagutech.ams.model.LoginUser; +import com.jiagutech.ams.model.RegionE; import com.jiagutech.ams.model.dto.RegionDTO; + +import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.core.util.ObjectUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.Collection; +import java.util.Collections; import java.util.List; @Service @@ -15,10 +23,22 @@ public class RegionServiceImpl implements RegionService { private final RegionMapper regionMapper; + + @Override public List getChildren(Long regionCode) { QueryWrapper query = Wrappers.query(); return regionMapper.selectList(query.eq("parent_code", regionCode).orderByAsc("region_code")); } + @Override + public List getHistoryJobRegions() { + LoginUser currentUser = StpUtil.getSession().get(UserConstants.SYS_SESSION, new LoginUser()); + if (ObjectUtil.isNotNull(currentUser)) { + return regionMapper.selectHistoryJobRegions(currentUser.getDept().getId()); + } + + return Collections.emptyList(); + } + } diff --git a/social/src/main/java/com/jiagutech/ams/service/SortieService.java b/social/src/main/java/com/jiagutech/ams/service/SortieService.java index 148428d..63c70be 100644 --- a/social/src/main/java/com/jiagutech/ams/service/SortieService.java +++ b/social/src/main/java/com/jiagutech/ams/service/SortieService.java @@ -3,7 +3,6 @@ package com.jiagutech.ams.service; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.jiagutech.ams.mapper.DeviceMapper; import com.jiagutech.ams.mapper.SortieMapper; import com.jiagutech.ams.model.SortieMapping; import com.jiagutech.ams.model.UavSortie; diff --git a/social/src/main/resources/mapper/JobMapper.xml b/social/src/main/resources/mapper/JobMapper.xml index 941bead..a70beea 100644 --- a/social/src/main/resources/mapper/JobMapper.xml +++ b/social/src/main/resources/mapper/JobMapper.xml @@ -53,6 +53,7 @@ left join ams_user u2 on j.farmer_id = u2.id ${ew.getCustomSqlSegment} group by j.farmer_id,j.job_type,t.name,d.id,d.name,u2.nick_name + order by j.farmer_id,j.job_type diff --git a/social/src/main/resources/mapper/RegionMapper.xml b/social/src/main/resources/mapper/RegionMapper.xml index accff1c..7eaaf38 100644 --- a/social/src/main/resources/mapper/RegionMapper.xml +++ b/social/src/main/resources/mapper/RegionMapper.xml @@ -44,4 +44,15 @@ GROUP_CONCAT(region_name ORDER BY level SEPARATOR '-') AS regionName from cte + + + \ No newline at end of file diff --git a/system/src/main/java/com/jiagutech/ams/model/request/UserRequest.java b/system/src/main/java/com/jiagutech/ams/model/request/UserRequest.java index e545f43..52fe691 100644 --- a/system/src/main/java/com/jiagutech/ams/model/request/UserRequest.java +++ b/system/src/main/java/com/jiagutech/ams/model/request/UserRequest.java @@ -81,4 +81,6 @@ public class UserRequest { private String roleKey; private Long regionCode; + + private String contactPhone; } diff --git a/system/src/main/java/com/jiagutech/ams/service/UserServiceImpl.java b/system/src/main/java/com/jiagutech/ams/service/UserServiceImpl.java index 6d51122..7038bd6 100644 --- a/system/src/main/java/com/jiagutech/ams/service/UserServiceImpl.java +++ b/system/src/main/java/com/jiagutech/ams/service/UserServiceImpl.java @@ -2,6 +2,7 @@ package com.jiagutech.ams.service; import cn.dev33.satoken.secure.BCrypt; import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -96,6 +97,7 @@ public class UserServiceImpl implements UserService { @Transactional public void addUser(UserRequest userRequest) { UserDTO userDTO = UserMapping.INSTANCE.userToUserDTO(userRequest); + userDTO.setId(null); userDTO.setPassword(BCrypt.hashpw(userRequest.getPassword())); if (userDTO.getRegionCode() != null && userDTO.getRegionCode() != 0l) { RegionVO completeRegionInfo = regionMapper.getCompleteRegionInfo(userDTO.getRegionCode()); @@ -138,7 +140,7 @@ public class UserServiceImpl implements UserService { if (StringUtils.isNotBlank(roleKey)) { userRoleMapper.insertUserRole(user.getId(), roleKey); } - if (deptId != null) { + if (ObjectUtil.isNotEmpty(deptId) && deptId != 0l) { UserDeptDTO userDeptDTO = new UserDeptDTO().setUserId(user.getId()).setDeptId(deptId); userDeptMapper.insert(userDeptDTO); } diff --git a/web/src/main/java/com/jiagutech/ams/config/SpringDocConfig.java b/web/src/main/java/com/jiagutech/ams/config/SpringDocConfig.java index e10df36..69e2b03 100644 --- a/web/src/main/java/com/jiagutech/ams/config/SpringDocConfig.java +++ b/web/src/main/java/com/jiagutech/ams/config/SpringDocConfig.java @@ -29,16 +29,16 @@ public class SpringDocConfig { private Info getApiInfo() { return new Info() // 配置文档标题 - .title("SpringBoot3集成Swagger3") + .title("贵州农机管理平台-社会化管理平台") // 配置文档描述 - .description("SpringBoot3集成Swagger3示例文档") + .description("社会化管理平台API文档") // 配置作者信息 - .contact(new Contact().name("农机管理-社会化").url("https://www.baidu.com")) + .contact(new Contact().name("Mr Zhang").url("https://www.baidu.com")) // 配置License许可证信息 - .license(new License().name("Apache 2.0").url("https://www.xiezhrspace.cn")) +// .license(new License().name("Apache 2.0").url("https://www.xiezhrspace.cn")) // 概述信息 - .summary("SpringBoot3集成Swagger3示例文档aaa") - .termsOfService("https://www.xiezhrspace.cn") + .summary("社会化管理平台API文档") + .termsOfService("http://www.jiagutech.com") // 配置版本号 .version("2.0"); } diff --git a/web/src/main/resources/application.yml b/web/src/main/resources/application.yml index fb2dc3d..faf3d2f 100644 --- a/web/src/main/resources/application.yml +++ b/web/src/main/resources/application.yml @@ -19,9 +19,9 @@ spring: # 校验超时时间 validationTimeout: 5000 # 空闲连接存活最大时间,默认10分钟 - idleTimeout: 600000 + idleTimeout: 300000 # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟 - maxLifetime: 600000 + maxLifetime: 1800000 # 多久检查一次连接的活性 keepaliveTime: 60000 connection-test-query: SELECT 1 @@ -88,3 +88,5 @@ logging: springdoc: api-docs: enabled: true + +