diff --git a/common/src/main/java/com/jiagutech/ams/model/UserDetail.java b/common/src/main/java/com/jiagutech/ams/model/UserDetail.java index 8ca01db..ba59e97 100644 --- a/common/src/main/java/com/jiagutech/ams/model/UserDetail.java +++ b/common/src/main/java/com/jiagutech/ams/model/UserDetail.java @@ -30,4 +30,6 @@ public class UserDetail { private String regionName; private String userIdStr; private String contactPhone; + + private String identityCardNum; } diff --git a/common/src/main/java/com/jiagutech/ams/model/common/PageRequest.java b/common/src/main/java/com/jiagutech/ams/model/common/PageRequest.java index 30d8850..b199f70 100644 --- a/common/src/main/java/com/jiagutech/ams/model/common/PageRequest.java +++ b/common/src/main/java/com/jiagutech/ams/model/common/PageRequest.java @@ -10,7 +10,8 @@ import lombok.Data; * @description: **/ @Data -public class PageRequest { +public class PageRequest implements java.io.Serializable { + private static final long serialVersionUID = 1L; private int pageNum; private int pageSize; diff --git a/common/src/main/java/com/jiagutech/ams/model/dto/UserDTO.java b/common/src/main/java/com/jiagutech/ams/model/dto/UserDTO.java index e744c10..c56dbbe 100644 --- a/common/src/main/java/com/jiagutech/ams/model/dto/UserDTO.java +++ b/common/src/main/java/com/jiagutech/ams/model/dto/UserDTO.java @@ -25,5 +25,7 @@ public class UserDTO { private Long regionCode; private String regionPath; private String regionName; + private String contactPhone; + } \ No newline at end of file diff --git a/social/src/main/java/com/jiagutech/ams/controller/JobController.java b/social/src/main/java/com/jiagutech/ams/controller/JobController.java index 2d8a5d3..5e394cd 100644 --- a/social/src/main/java/com/jiagutech/ams/controller/JobController.java +++ b/social/src/main/java/com/jiagutech/ams/controller/JobController.java @@ -75,13 +75,13 @@ public class JobController { } - @PostMapping("/export") + @PostMapping(value = "/export",consumes = "application/json") @Operation(summary = "导出作业记录") public void exportJobs(@RequestBody(required = false) JobPageRequest jobPageRequest, HttpServletResponse response) { jobService.exportJobs(jobPageRequest, response); } - @PostMapping("/exportByFarmer") + @PostMapping(value = "/exportByFarmer",consumes = "application/json") @Operation(summary = "导出作业记录") public void exportByFarmer(@RequestBody(required = false) JobPageRequest jobPageRequest, HttpServletResponse response) { jobService.exportByFarmer(jobPageRequest, response); 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 95fb9ed..3509f6b 100644 --- a/social/src/main/java/com/jiagutech/ams/controller/RegionController.java +++ b/social/src/main/java/com/jiagutech/ams/controller/RegionController.java @@ -31,7 +31,6 @@ public class RegionController { private final RegionService regionService; - @SaCheckRole(value = {"manager", "machinist"}, mode = SaMode.OR) @Operation(summary = "获取下一级的所有区域列表") @GetMapping("getChildren") public R> getChildren(Long regionCode) { 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 b202645..2990a64 100644 --- a/social/src/main/java/com/jiagutech/ams/listener/JobFinishListener.java +++ b/social/src/main/java/com/jiagutech/ams/listener/JobFinishListener.java @@ -1,13 +1,17 @@ package com.jiagutech.ams.listener; import com.jiagutech.ams.event.JobFinishEvent; +import com.jiagutech.ams.mapper.JobMapper; import com.jiagutech.ams.model.TrackItem; +import com.jiagutech.ams.model.dto.JobDTO; import com.jiagutech.ams.service.JobService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; +import java.time.Duration; +import java.time.Instant; import java.util.List; /** @@ -22,12 +26,21 @@ import java.util.List; @RequiredArgsConstructor public class JobFinishListener { private final JobService jobService; + private final JobMapper jobMapper; @EventListener(JobFinishEvent.class) public void finishJob(JobFinishEvent event) { log.info("JobFinishListener:{}", event.getJobId()); + JobDTO jobDTO = jobMapper.selectById(event.getJobId()); + Long startTime = jobDTO.getStartTime(); + Long endTime = System.currentTimeMillis(); try { + Instant instant1 = Instant.ofEpochMilli(startTime); + Instant instant2 = Instant.ofEpochMilli(endTime); + Duration duration = Duration.between(instant1, instant2); + jobDTO.setDuration((int) duration.toSeconds()); List trackList = jobService.getTrackList(event.getJobId()); + jobMapper.updateById(jobDTO); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/social/src/main/java/com/jiagutech/ams/model/dto/JobDTO.java b/social/src/main/java/com/jiagutech/ams/model/dto/JobDTO.java index 839f2ba..855e0ef 100644 --- a/social/src/main/java/com/jiagutech/ams/model/dto/JobDTO.java +++ b/social/src/main/java/com/jiagutech/ams/model/dto/JobDTO.java @@ -33,7 +33,7 @@ public class JobDTO { private Long regionCode; - private Float duration; + private Integer duration; private Integer status; @@ -41,4 +41,5 @@ public class JobDTO { private Long deptId; + } diff --git a/social/src/main/java/com/jiagutech/ams/model/request/JobPageRequest.java b/social/src/main/java/com/jiagutech/ams/model/request/JobPageRequest.java index 6bffe63..163adcc 100644 --- a/social/src/main/java/com/jiagutech/ams/model/request/JobPageRequest.java +++ b/social/src/main/java/com/jiagutech/ams/model/request/JobPageRequest.java @@ -13,7 +13,10 @@ import lombok.Data; * @description: **/ @Data -public class JobPageRequest { +public class JobPageRequest implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + private long startTimeBegin; private long startTimeEnd; diff --git a/social/src/main/java/com/jiagutech/ams/model/response/JobItem.java b/social/src/main/java/com/jiagutech/ams/model/response/JobItem.java index 4ccd8a5..f11f209 100644 --- a/social/src/main/java/com/jiagutech/ams/model/response/JobItem.java +++ b/social/src/main/java/com/jiagutech/ams/model/response/JobItem.java @@ -21,8 +21,10 @@ public class JobItem { @ExcelIgnore @JsonSerialize(using = ToStringSerializer.class) private Long jobId; + @ExcelIgnore @ExcelProperty(value = "机手") private String operatorName; + @ExcelIgnore @ExcelProperty(value = "机手手机号") private String operatorPhone; @ExcelIgnore @@ -59,5 +61,7 @@ public class JobItem { @ExcelProperty(value = "作业地区") private String regionName; + private int duration; + } diff --git a/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java b/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java index a36cbfc..0beca90 100644 --- a/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java +++ b/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java @@ -196,6 +196,9 @@ public class JobServiceImpl implements JobService { if (requestParam.getFarmerId() != 0l) { queryWrapper.eq("j.farmer_id", requestParam.getFarmerId()); } + if (requestParam.getRegionCode() != 0l) { + queryWrapper.eq("j.region_code", requestParam.getRegionCode()); + } } diff --git a/social/src/main/resources/mapper/JobMapper.xml b/social/src/main/resources/mapper/JobMapper.xml index a70beea..7b8dbde 100644 --- a/social/src/main/resources/mapper/JobMapper.xml +++ b/social/src/main/resources/mapper/JobMapper.xml @@ -3,59 +3,84 @@ - select j.id as job_id, + select j.id as job_id, j.start_time, j.end_time, j.area, j.status, j.device_id, j.operator_id, - FROM_UNIXTIME(j.start_time/1000,'%Y-%m-%d %H:%i:%s') as start_time_str, - u1.nick_name as operator_name, - u1.phone as operator_phone, + j.duration, + FROM_UNIXTIME(j.start_time / 1000, '%Y-%m-%d %H:%i:%s') as start_time_str, + u1.nick_name as operator_name, + u1.phone as operator_phone, j.farmer_id, - u2.nick_name as farmer_name, - u2.phone as farmer_phone, - u2.region_name , + u2.nick_name as farmer_name, + u2.phone as farmer_phone, + u2.region_name, j.job_type, - t.name as type_name, - d.id as dept_id, - d.name as dept_name + t.name as type_name, + d.id as dept_id, + d.name as dept_name from ams_job_info j left join ams_job_type t on j.job_type = t.id - left join ams_dept d on j.dept_id=d.id + left join ams_dept d on j.dept_id = d.id left join ams_user u1 on j.operator_id = u1.id left join ams_user u2 on j.farmer_id = u2.id + + select j.id as job_id, + j.start_time, + j.end_time, + j.area, + j.status, + j.device_id, + j.operator_id, + j.duration, + FROM_UNIXTIME(j.start_time / 1000, '%Y-%m-%d %H:%i:%s') as start_time_str, + j.farmer_id, + u2.nick_name as farmer_name, + CONCAT(LEFT(u2.phone, 3), '****', RIGHT(u2.phone, 4)) as farmer_phone, + u2.region_name, + j.job_type, + t.name as type_name, + d.id as dept_id, + d.name as dept_name + from ams_job_info j + left join ams_job_type t on j.job_type = t.id + left join ams_dept d on j.dept_id = d.id + left join ams_user u2 on j.farmer_id = u2.id + + - \ No newline at end of file diff --git a/system/src/main/java/com/jiagutech/ams/controller/UserController.java b/system/src/main/java/com/jiagutech/ams/controller/UserController.java index 14c7bd7..a7f585e 100644 --- a/system/src/main/java/com/jiagutech/ams/controller/UserController.java +++ b/system/src/main/java/com/jiagutech/ams/controller/UserController.java @@ -85,7 +85,8 @@ public class UserController { @Operation(summary = "根据区域码获取农户列表") @GetMapping("/listFarmerByRegionCode") - public R> getAllFarmersByRegionCode(Long regionCode) { - return R.ok(userService.getAllFarmersByRegionCode(regionCode)); + public R> getAllFarmersByRegionCode(@RequestParam(value = "regionCode") Long regionCode, + @RequestParam(value = "nickName", required = false) String nickName) { + return R.ok(userService.getAllFarmersByRegionCode(regionCode,nickName)); } } diff --git a/system/src/main/java/com/jiagutech/ams/service/UserService.java b/system/src/main/java/com/jiagutech/ams/service/UserService.java index 8d88027..abeff43 100644 --- a/system/src/main/java/com/jiagutech/ams/service/UserService.java +++ b/system/src/main/java/com/jiagutech/ams/service/UserService.java @@ -28,5 +28,5 @@ public interface UserService { PageResult getUserPage(PageRequest pageRequest); - List getAllFarmersByRegionCode(Long regionCode); + List getAllFarmersByRegionCode(Long regionCode,String nickName); } 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 7038bd6..1f8057b 100644 --- a/system/src/main/java/com/jiagutech/ams/service/UserServiceImpl.java +++ b/system/src/main/java/com/jiagutech/ams/service/UserServiceImpl.java @@ -177,10 +177,13 @@ public class UserServiceImpl implements UserService { @Override - public List getAllFarmersByRegionCode(Long regionCode) { + public List getAllFarmersByRegionCode(Long regionCode, String nickName) { QueryWrapper query = Wrappers.query(); query.eq("u.region_code", regionCode); + if (nickName != null && !nickName.isEmpty()) { + query.eq("u.nick_name", nickName); + } query.eq("u.del_flag", 0); query.eq("r.key", "farmer"); diff --git a/system/src/main/resources/mapper/UserMapper.xml b/system/src/main/resources/mapper/UserMapper.xml index 9db48b6..08517e0 100644 --- a/system/src/main/resources/mapper/UserMapper.xml +++ b/system/src/main/resources/mapper/UserMapper.xml @@ -93,7 +93,9 @@ u.phone, u.create_time, u.avatar, - u.region_code + u.region_code, + u.contact_phone, + right(u.identity_card_num,4) as identity_card_num from ams_user u left join ams_user_role ur on u.id = ur.user_id left join ams_role r on ur.role_id = r.id diff --git a/web/pom.xml b/web/pom.xml index 8ac05e0..1c7c09a 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -1,162 +1,202 @@ - 4.0.0 - - com.jiagutech - ams-social - ${revision} - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + com.jiagutech + ams-social + ${revision} + - web + web - - 17 - 17 - UTF-8 - + + 17 + 17 + UTF-8 + - - - dev - - - dev - info - - - - true - - - - zyg - - zyg - info - - - - prod - - prod - info - - - - - - com.jiagutech - system - 1.0.0-SNAPSHOT - - - com.jiagutech - social - 1.0.0-SNAPSHOT - - - org.springframework.boot - spring-boot-starter-data-jdbc - - - mysql - mysql-connector-java - - - org.springdoc - springdoc-openapi-starter-webmvc-ui + + + dev + + + dev + info + + + + true + + + + zyg + + zyg + info + + + + prod + + prod + info + + + + + + com.jiagutech + system + 1.0.0-SNAPSHOT + + + com.jiagutech + social + 1.0.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + mysql + mysql-connector-java + + + org.springdoc + springdoc-openapi-starter-webmvc-ui - - - org.springdoc - springdoc-openapi-starter-webmvc-api - - - org.apache.commons - commons-pool2 - 2.12.0 - - - cn.dev33 - sa-token-spring-boot3-starter - + + + org.springdoc + springdoc-openapi-starter-webmvc-api + + + org.apache.commons + commons-pool2 + 2.12.0 + + + cn.dev33 + sa-token-spring-boot3-starter + + + cn.dev33 + sa-token-redis-jackson + + + + org.mapstruct + mapstruct + 1.5.3.Final + + + org.springframework.amqp + spring-rabbit + + + org.springframework.amqp + spring-amqp + + + + + + src/main/resources + true + + application.yml + application-${profiles.active}.yml + *.xml + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 + 17 + + + org.mapstruct + mapstruct-processor + 1.5.3.Final + + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.15.0 + + + net.sourceforge.pmd + pmd-core + 6.38.0 + + + net.sourceforge.pmd + pmd-java + 6.38.0 + + + org.ow2.asm + asm + 9.2 + + + + false + UTF-8 + 100 + 17 + true + ${project.build.directory}/pmd/pmd.cache + ${project.build.directory}/pmd + html + false + + + + pmd-check + verify + + check + cpd-check + pmd + + + + + - - - - - - cn.dev33 - sa-token-redis-jackson - - - - org.mapstruct - mapstruct - 1.5.3.Final - - - org.springframework.amqp - spring-rabbit - - - org.springframework.amqp - spring-amqp - - - - - - src/main/resources - true - - application.yml - application-${profiles.active}.yml - *.xml - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - - repackage - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 17 - 17 - - - org.mapstruct - mapstruct-processor - 1.5.3.Final - - - - org.projectlombok - lombok - ${lombok.version} - - - - - - - + \ No newline at end of file diff --git a/web/src/main/java/com/jiagutech/ams/common/RabbitConfig.java b/web/src/main/java/com/jiagutech/ams/common/RabbitConfig.java index 27e4cb5..9604bd6 100644 --- a/web/src/main/java/com/jiagutech/ams/common/RabbitConfig.java +++ b/web/src/main/java/com/jiagutech/ams/common/RabbitConfig.java @@ -1,10 +1,6 @@ package com.jiagutech.ams.common; import org.springframework.amqp.core.*; -import org.springframework.amqp.rabbit.connection.ConnectionFactory; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; -import org.springframework.amqp.support.converter.SimpleMessageConverter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; 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 69e2b03..fc62c6d 100644 --- a/web/src/main/java/com/jiagutech/ams/config/SpringDocConfig.java +++ b/web/src/main/java/com/jiagutech/ams/config/SpringDocConfig.java @@ -3,7 +3,6 @@ package com.jiagutech.ams.config; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import org.springframework.context.annotation.Bean;