diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index a38c4cbb0e..3faf895eb5 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -87,6 +87,7 @@ public enum EpmetErrorCode { EXIT_PEND_PROJECT(8408,"该工作人员有项目尚在处理,处理完毕方可操作"), EXIT_PUBLISHED_ACTIVITY(8409,"该工作人员有活动尚在进行,等活动完成方可操作"), CAN_NOT_SELF(8410,"无法对自己进行操作"), + PATROL_IS_NOT_OVER(8520,"巡查尚未结束"), ALREADY_EVALUATE(8501,"您已评价"), ALREADY_VOTE(8502,"您已表态"), diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index 67ab18f0ec..3a556da632 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java @@ -608,6 +608,24 @@ public class DateUtils { return minutes; } + + /** + * @return java.lang.Integer + * @param startDate + * @param endDate + * @author yinzuomei + * @description 计算两个时间点之间相隔秒数 + * @Date 2020/7/29 13:38 + **/ + public static Integer calculateSecond(Date startDate,Date endDate){ + long start=startDate.getTime(); + long end=endDate.getTime(); + // 计算差多少分钟 + int second = (int) ((end - start) / 1000); + System.out.println("两个时间之间的分钟差为:" + second); + return second; + } + /** * @return java.lang.String * @param dateOne diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/PatrolDateListFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/PatrolDateListFormDTO.java new file mode 100644 index 0000000000..9ee50f8930 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/PatrolDateListFormDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dataaggre.dto.epmetuser.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/10 14:31 + */ +@NoArgsConstructor +@Data +public class PatrolDateListFormDTO implements Serializable { + + private static final long serialVersionUID = -3120791500214908595L; + public interface PatrolDateListGroup {} + + @NotBlank(message = "网格Id不能为空",groups = PatrolDateListGroup.class) + private String gridId; + @NotBlank(message = "工作人员ID不能为空",groups = PatrolDateListGroup.class) + private String staffId; +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/PatrolRecordListFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/PatrolRecordListFormDTO.java new file mode 100644 index 0000000000..c9cc99344b --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/PatrolRecordListFormDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dataaggre.dto.epmetuser.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:23 + */ +@Data +@NoArgsConstructor +public class PatrolRecordListFormDTO implements Serializable { + private static final long serialVersionUID = 7496587490046732883L; + public interface PatrolRecordListGroup {} + + /** + * 巡查日期,格式:yyyy-MM-dd + */ + @NotBlank(message = "巡查日期不能为空",groups = PatrolRecordListGroup.class) + private String patrolDate; + /** + * 网格Id + */ + @NotBlank(message = "网格Id不能为空",groups = PatrolRecordListGroup.class) + private String gridId; + /** + * 用户ID + */ + @NotBlank(message = "用户ID不能为空",groups = PatrolRecordListGroup.class) + private String userId; +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolDateListResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolDateListResultDTO.java new file mode 100644 index 0000000000..e51ce38b2a --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolDateListResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dataaggre.dto.epmetuser.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/10 14:32 + */ +@NoArgsConstructor +@Data +public class PatrolDateListResultDTO implements Serializable { + + private static final long serialVersionUID = -1516170049255588336L; + private String startDate; + private List list; +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolRecordDetailDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolRecordDetailDTO.java new file mode 100644 index 0000000000..922f21867b --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolRecordDetailDTO.java @@ -0,0 +1,37 @@ +package com.epmet.dataaggre.dto.epmetuser.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/9 14:38 + */ +@NoArgsConstructor +@Data +public class PatrolRecordDetailDTO implements Serializable { + private static final long serialVersionUID = 757994412954699222L; + /** + * 上传时间;yyyy-MM-dd HH:mm + */ + private String uploadTime; + /** + * 纬度 + */ + private String latitude; + /** + * 经度 + */ + private String longitude; + /** + * 速度,单位m/s + */ + private String speed; + /** + * 后端返回:开始巡查;结束巡查;此列只有集合第一条,和最后一条有值 + */ + private String flag; +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolRecordListResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolRecordListResultDTO.java new file mode 100644 index 0000000000..d59abe39de --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolRecordListResultDTO.java @@ -0,0 +1,48 @@ +package com.epmet.dataaggre.dto.epmetuser.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:24 + */ +@NoArgsConstructor +@Data +public class PatrolRecordListResultDTO implements Serializable { + + private static final long serialVersionUID = -8808482239766626564L; + /** + * 巡查记录id + */ + private String staffPatrolRecId; + /** + * 总时长描述,后端返回格式:XX小时XX分;前端直接展示 + */ + private String totalTimeDesc; + /** + * 开始时间;yyyy-MM-dd HH:mm + */ + private String patrolStartTime; + /** + * 结束时间;yyyy-MM-dd HH:mm + */ + private String patrolEndTime; + /** + * 巡查中:patrolling;已结束:end;如果是巡查中,界面不展示结束时间这一行 + */ + private String status; + /** + * 后端返回:巡查员最近地址变动是XX分钟前 + */ + private String latestChangeDesc; + /** + * 巡查记录详情 + */ + private List details; + +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java index 4f7145b3fd..f01ef8a3d4 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java @@ -5,11 +5,12 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dataaggre.dto.datastats.form.SubAgencyFormDTO; -import com.epmet.dataaggre.dto.datastats.result.SubAgencyUserResultDTO; +import com.epmet.dataaggre.dto.epmetuser.form.PatrolDateListFormDTO; +import com.epmet.dataaggre.dto.epmetuser.form.PatrolRecordListFormDTO; import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolDateListResultDTO; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolRecordListResultDTO; import com.epmet.dataaggre.dto.epmetuser.result.StaffListResultDTO; -import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -49,5 +50,31 @@ public class EpmetUserController { return new Result>().ok(epmetUserService.staffList(formDTO)); } + /** + * 巡查记录列表查询 + * @author zhaoqifeng + * @date 2021/6/9 14:48 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("recordlist") + public Result> recordList(@RequestBody PatrolRecordListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result>().ok(epmetUserService.recordList(formDTO)); + } + + /** + * 历史巡查日期查询 + * @author zhaoqifeng + * @date 2021/6/10 14:36 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("patrolleddatelist") + public Result patrolDateList(@RequestBody PatrolDateListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(epmetUserService.patrolDateList(formDTO)); + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java index b43df6d3a4..2a27686184 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java @@ -1,6 +1,10 @@ package com.epmet.dataaggre.service.epmetuser; +import com.epmet.dataaggre.dto.epmetuser.form.PatrolDateListFormDTO; +import com.epmet.dataaggre.dto.epmetuser.form.PatrolRecordListFormDTO; import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolDateListResultDTO; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolRecordListResultDTO; import com.epmet.dataaggre.dto.epmetuser.result.StaffListResultDTO; import com.epmet.dataaggre.dto.epmetuser.result.UserInfosResultDTO; @@ -34,4 +38,22 @@ public interface EpmetUserService { * @author sun */ List staffList(StaffListFormDTO formDTO); + + /** + * 巡查记录列表查询 + * @author zhaoqifeng + * @date 2021/6/9 14:49 + * @param formDTO + * @return java.util.List + */ + List recordList(PatrolRecordListFormDTO formDTO); + + /** + * 历史巡查日期查询 + * @author zhaoqifeng + * @date 2021/6/10 14:36 + * @param formDTO + * @return com.epmet.dataaggre.dto.epmetuser.result.PatrolDateListResultDTO + */ + PatrolDateListResultDTO patrolDateList(PatrolDateListFormDTO formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolDetailService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolDetailService.java index 2463f47a0c..54dccbe854 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolDetailService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolDetailService.java @@ -19,8 +19,12 @@ package com.epmet.dataaggre.service.epmetuser; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO; import com.epmet.dataaggre.entity.epmetuser.StaffPatrolDetailEntity; +import java.util.List; +import java.util.Map; + /** * 工作人员巡查记录明细 * @@ -29,5 +33,12 @@ import com.epmet.dataaggre.entity.epmetuser.StaffPatrolDetailEntity; */ public interface StaffPatrolDetailService extends BaseService { - + /** + * 获取记录明细 + * @author zhaoqifeng + * @date 2021/6/9 15:09 + * @param recordIds + * @return java.util.Map> + */ + Map> getDetailByRecordIds(List recordIds); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolRecordService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolRecordService.java index c2cfcdd450..a7bf7d5155 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolRecordService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StaffPatrolRecordService.java @@ -18,8 +18,11 @@ package com.epmet.dataaggre.service.epmetuser; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO; import com.epmet.dataaggre.entity.epmetuser.StaffPatrolRecordEntity; +import java.util.List; + /** * 工作人员巡查主记录 * @@ -28,5 +31,25 @@ import com.epmet.dataaggre.entity.epmetuser.StaffPatrolRecordEntity; */ public interface StaffPatrolRecordService extends BaseService { + /** + * 获取巡查记录列表 + * + * @param gridId + * @param userId + * @param patrolDate + * @return java.util.List + * @author zhaoqifeng + * @date 2021/6/9 14:55 + */ + List getRecordList(String gridId, String userId, String patrolDate); + /** + * 获取日期列表 + * @author zhaoqifeng + * @date 2021/6/10 14:49 + * @param gridId + * @param staffId + * @return java.util.List + */ + List getDateList(String gridId, String staffId); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java index 301b3ff441..fdbb43843b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java @@ -6,11 +6,16 @@ import com.epmet.commons.tools.utils.DateUtils; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.epmetuser.StaffPatrolRecordDao; import com.epmet.dataaggre.dao.epmetuser.UserBaseInfoDao; +import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO; +import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO; +import com.epmet.dataaggre.dto.epmetuser.form.PatrolDateListFormDTO; +import com.epmet.dataaggre.dto.epmetuser.form.PatrolRecordListFormDTO; import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO; -import com.epmet.dataaggre.dto.epmetuser.result.StaffListResultDTO; -import com.epmet.dataaggre.dto.epmetuser.result.UserInfosResultDTO; +import com.epmet.dataaggre.dto.epmetuser.result.*; import com.epmet.dataaggre.dto.govorg.CustomerGridDTO; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; +import com.epmet.dataaggre.service.epmetuser.StaffPatrolDetailService; +import com.epmet.dataaggre.service.epmetuser.StaffPatrolRecordService; import com.epmet.dataaggre.service.govorg.GovOrgService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -18,6 +23,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -36,6 +42,10 @@ public class EpmetUserServiceImpl implements EpmetUserService { private GovOrgService govOrgService; @Autowired private StaffPatrolRecordDao staffPatrolRecordDao; + @Resource + private StaffPatrolDetailService staffPatrolDetailService; + @Resource + private StaffPatrolRecordService staffPatrolRecordService; /** * @Description 根据UserIds查询 @@ -93,5 +103,77 @@ public class EpmetUserServiceImpl implements EpmetUserService { return resultList; } + /** + * 巡查记录列表查询 + * + * @param formDTO + * @return java.util.List + * @author zhaoqifeng + * @date 2021/6/9 14:49 + */ + @Override + public List recordList(PatrolRecordListFormDTO formDTO) { + List recordList = staffPatrolRecordService.getRecordList(formDTO.getGridId(), formDTO.getUserId(), formDTO.getPatrolDate()); + if (CollectionUtils.isEmpty(recordList)) { + return Collections.emptyList(); + } + List recordIds = recordList.stream().map(StaffPatrolRecordDTO :: getId).collect(Collectors.toList()); + Map> details = staffPatrolDetailService.getDetailByRecordIds(recordIds); + + List result = recordList.stream().map(record -> { + PatrolRecordListResultDTO dto = new PatrolRecordListResultDTO(); + dto.setStaffPatrolRecId(record.getId()); + dto.setStatus(record.getStatus()); + dto.setPatrolStartTime(DateUtils.format(record.getPatrolStartTime(), DateUtils.DATE_TIME_PATTERN)); + dto.setPatrolEndTime(DateUtils.format(record.getPatrolEndTime(), DateUtils.DATE_TIME_PATTERN)); + Integer minutes; + if (("patrolling").equals(record.getStatus())) { + minutes = DateUtils.calculateMin(record.getPatrolStartTime(), new Date()); + String latestChangeDesc = "后端返回:巡查员最近地址变动是" + minutes + "分钟前"; + dto.setLatestChangeDesc(latestChangeDesc); + } else { + minutes = record.getTotalTime() / 60; + } + String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; + dto.setTotalTimeDesc(totalTimeDesc); + List detailList = details.get(record.getId()); + List recordDetails = + detailList.stream().sorted(Comparator.comparing(StaffPatrolDetailDTO::getSerialNum).reversed()).collect(Collectors.toList()).stream().map( detail -> { + PatrolRecordDetailDTO detailDTO = new PatrolRecordDetailDTO(); + detailDTO.setLatitude(detail.getLatitude()); + detailDTO.setLongitude(detail.getLongitude()); + detailDTO.setSpeed(detail.getSpeed()); + detailDTO.setUploadTime(DateUtils.format(detail.getUploadTime(), DateUtils.DATE_TIME_PATTERN)); + return detailDTO; + }).collect(Collectors.toList()); + if (("end").equals(record.getStatus())) { + recordDetails.get(NumConstant.ZERO).setFlag("结束巡查"); + } + recordDetails.get(recordDetails.size() - 1).setFlag("开始巡查"); + dto.setDetails(recordDetails); + return dto; + }).collect(Collectors.toList()); + return result; + } + + /** + * 历史巡查日期查询 + * + * @param formDTO + * @return com.epmet.dataaggre.dto.epmetuser.result.PatrolDateListResultDTO + * @author zhaoqifeng + * @date 2021/6/10 14:36 + */ + @Override + public PatrolDateListResultDTO patrolDateList(PatrolDateListFormDTO formDTO) { + List list = staffPatrolRecordService.getDateList(formDTO.getGridId(), formDTO.getStaffId()); + PatrolDateListResultDTO dto = new PatrolDateListResultDTO(); + if (CollectionUtils.isNotEmpty(list)) { + dto.setStartDate(list.get(NumConstant.ZERO)); + } + dto.setList(list); + return dto; + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolDetailServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolDetailServiceImpl.java index fad170f41f..98f41f75a3 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolDetailServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolDetailServiceImpl.java @@ -17,15 +17,22 @@ package com.epmet.dataaggre.service.epmetuser.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.epmetuser.StaffPatrolDetailDao; +import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO; import com.epmet.dataaggre.entity.epmetuser.StaffPatrolDetailEntity; import com.epmet.dataaggre.service.epmetuser.StaffPatrolDetailService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; +import java.util.*; +import java.util.stream.Collectors; + /** * 工作人员巡查记录明细 * @@ -38,4 +45,27 @@ import org.springframework.stereotype.Service; public class StaffPatrolDetailServiceImpl extends BaseServiceImpl implements StaffPatrolDetailService { + /** + * 获取记录明细 + * + * @param recordIds + * @return java.util.Map> + * @author zhaoqifeng + * @date 2021/6/9 15:09 + */ + @Override + public Map> getDetailByRecordIds(List recordIds) { + if (CollectionUtils.isEmpty(recordIds)) { + return Collections.emptyMap(); + } + StringBuilder sql = new StringBuilder("( STAFF_PATROL_REC_ID = '' "); + for (String id : recordIds) { + sql.append("OR STAFF_PATROL_REC_ID = '").append(id).append("' "); + } + sql.append(")"); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.apply(sql.toString()); + List list = ConvertUtils.sourceToTarget(baseDao.selectList(wrapper), StaffPatrolDetailDTO.class); + return list.stream().collect(Collectors.groupingBy(StaffPatrolDetailDTO::getStaffPatrolRecId)); + } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolRecordServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolRecordServiceImpl.java index f245db7138..67eb153f04 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolRecordServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StaffPatrolRecordServiceImpl.java @@ -17,15 +17,23 @@ package com.epmet.dataaggre.service.epmetuser.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.epmetuser.StaffPatrolRecordDao; +import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO; import com.epmet.dataaggre.entity.epmetuser.StaffPatrolRecordEntity; import com.epmet.dataaggre.service.epmetuser.StaffPatrolRecordService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + /** * 工作人员巡查主记录 * @@ -38,5 +46,48 @@ import org.springframework.stereotype.Service; public class StaffPatrolRecordServiceImpl extends BaseServiceImpl implements StaffPatrolRecordService { + /** + * 获取巡查记录列表 + * + * @param gridId + * @param userId + * @param patrolDate + * @return java.util.List + * @author zhaoqifeng + * @date 2021/6/9 14:55 + */ + @Override + public List getRecordList(String gridId, String userId, String patrolDate) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("GRID", gridId) + .eq("STAFF_ID", userId) + .eq("DATE_FORMAT(PATROL_START_TIME,'%Y-%m-%d') ", patrolDate) + .orderByDesc("PATROL_START_TIME"); + + return ConvertUtils.sourceToTarget(baseDao.selectList(wrapper), StaffPatrolRecordDTO.class); + } + + /** + * 获取日期列表 + * + * @param gridId + * @param staffId + * @return java.util.List + * @author zhaoqifeng + * @date 2021/6/10 14:49 + */ + @Override + public List getDateList(String gridId, String staffId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.select("DISTINCT DATE_FORMAT(PATROL_START_TIME,'%Y-%m-%d') AS ID") + .eq("GRID", gridId) + .eq("STAFF_ID", staffId) + .orderByAsc("PATROL_START_TIME"); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(StaffPatrolRecordEntity::getId).collect(Collectors.toList()); + } } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectGridDailyDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectGridDailyDTO.java index 60fdc4a14a..fefcc025bb 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectGridDailyDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectGridDailyDTO.java @@ -70,6 +70,11 @@ public class ScreenProjectGridDailyDTO implements Serializable { */ private String pids; + /** + * 网格所有的父级id,以英文:或者英文,隔开 + */ + private String centerMark; + /** * 截止到当前日期,网格内项目总数 */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/GridCenterPointForm.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/GridCenterPointForm.java index 6859b4a1ee..22d1e569d3 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/GridCenterPointForm.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/GridCenterPointForm.java @@ -16,6 +16,7 @@ public class GridCenterPointForm implements Serializable { private static final long serialVersionUID = -6988009829971668860L; private String customerId; + private String pids; private List centerDataList = new ArrayList<>(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java index 1d5099bc67..6aa2aacc1c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java @@ -40,8 +40,8 @@ import java.util.List; @Mapper public interface ScreenCustomerGridDao extends BaseDao { /** - *15、网格信息上传 - * 1) 根据CUSTOMER_ID 进行查询,如果有数据,则先进行物理删除, 一次删除1000条 + * 15、网格信息上传 + * 1) 根据CUSTOMER_ID 进行查询,如果有数据,则先进行物理删除, 一次删除1000条 * * @param customerId * @return java.util.Integer @@ -52,18 +52,18 @@ public interface ScreenCustomerGridDao extends BaseDao /** * 15、网格信息上传 - * 2) 在批量新增 + * 2) 在批量新增 * * @param list * @param customerId * @Author zhangyong * @Date 10:52 2020-08-18 **/ - void batchInsertCustomerGrid(@Param("list") List list, @Param("customerId")String customerId); + void batchInsertCustomerGrid(@Param("list") List list, @Param("customerId") String customerId); /** - * @return java.lang.Integer * @param customerId + * @return java.lang.Integer * @author yinzuomei * @description 查询客户下网格总数 * @Date 2020/8/26 15:33 @@ -71,17 +71,17 @@ public interface ScreenCustomerGridDao extends BaseDao Integer selectCountByCustomerId(@Param("customerId") String customerId); /** - * @return java.util.List * @param customerId + * @return java.util.List * @author yinzuomei * @description 查询客户下网格信息 * @Date 2020/8/26 15:33 **/ - List selectListByCustomerId(@Param("customerId")String customerId); + List selectListByCustomerId(@Param("customerId") String customerId); /** - * @return java.util.List * @param formDTO + * @return java.util.List * @author yinzuomei * @description 分页查询网格列表 * @Date 2020/8/27 14:42 @@ -89,7 +89,7 @@ public interface ScreenCustomerGridDao extends BaseDao List pageListByCustomerId(PageQueryGridFormDTO formDTO); /** - * @param gridId 网格id + * @param gridId 网格id * @return java.lang.String * @author yinzuomei * @description 查询网格所属的组织id @@ -107,28 +107,29 @@ public interface ScreenCustomerGridDao extends BaseDao * @Date 10:45 2020-09-04 **/ List selectListMismatchGridInfo(@Param("customerId") String customerId, - @Param("gridIds") String[] gridIds, - @Param("customerAreaCode") String customerAreaCode, - @Param("subCustomerIds")List subCustomerIds); + @Param("gridIds") String[] gridIds, + @Param("customerAreaCode") String customerAreaCode, + @Param("subCustomerIds") List subCustomerIds); /** * 根据客户id 查询网格(党支部)详细信息 + * * @param customerId * @return java.util.List * @Author zhangyong * @Date 16:57 2020-09-03 **/ - List selectListGridInfo(@Param("customerId")String customerId, + List selectListGridInfo(@Param("customerId") String customerId, @Param("customerAreaCode") String customerAreaCode, - @Param("subCustomerIds")List subCustomerIds); + @Param("subCustomerIds") List subCustomerIds); /** - * @Description 根据agencyId查询网格ID * @param agencyId + * @Description 根据agencyId查询网格ID * @author zxc * @date 2020/9/22 2:16 下午 */ - List selectGridIdByAgencyId(@Param("agencyId")String agencyId); + List selectGridIdByAgencyId(@Param("agencyId") String agencyId); ScreenCustomerGridEntity getLastAddGrid(); @@ -137,58 +138,59 @@ public interface ScreenCustomerGridDao extends BaseDao ScreenCustomerGridEntity getByGridId(String gridId); /** - * @Description 查询客户下所有网格ID * @param customerId * @param dateId + * @Description 查询客户下所有网格ID * @author zxc * @date 2020/9/23 3:10 下午 */ List selectAllGridIdToParty(String customerId, String dateId); /** - * @Description 查询客户下所有网格ID + * @Description 查询客户下所有网格ID * @Param customerId * @Param monthId * @author zxc * @date 2020/9/25 10:43 上午 */ - List selectAllGridIdToPartyLinkMessage(@Param("customerId") String customerId,@Param("monthId") String monthId); - List selectAllGridIdToOrganize(@Param("customerId") String customerId,@Param("monthId") String monthId); + List selectAllGridIdToPartyLinkMessage(@Param("customerId") String customerId, @Param("monthId") String monthId); + + List selectAllGridIdToOrganize(@Param("customerId") String customerId, @Param("monthId") String monthId); /** - * @Description 查询org名称 * @param gridIds + * @Description 查询org名称 * @author zxc * @date 2020/9/24 1:27 下午 */ List selectOrgName(@Param("gridIds") List gridIds); /** - * @Description 查询机关的直属网格 * @param agencyIds + * @Description 查询机关的直属网格 * @author zxc * @date 2020/9/24 2:33 下午 */ List selectDirectGrid(@Param("agencyIds") List agencyIds); /** - * @Description 查询全部网格信息 * @param customerId + * @Description 查询全部网格信息 * @author zxc * @date 2020/9/19 10:50 上午 */ List selectAllGridInfoToParty(String customerId); /** - * @Description 查询全部网格信息 * @param customerId + * @Description 查询全部网格信息 * @author zxc * @date 2020/9/18 10:47 上午 */ List selectAllGridInfo(@Param("customerId") String customerId); /** - * @Description 查询客户下的网格信息 + * @Description 查询客户下的网格信息 * @Param customerId * @author zxc * @date 2021/1/28 下午3:18 @@ -196,11 +198,22 @@ public interface ScreenCustomerGridDao extends BaseDao List selectGridInfoByCustomerId(@Param("customerId") String customerId); /** - * @Description 查询直属网格信息 + * @Description 查询直属网格信息 * @Param customerId * @Param level * @author zxc * @date 2021/3/23 下午4:03 */ - List selectBelongGridInfo(@Param("customerId") String customerId,@Param("level") String level); + List selectBelongGridInfo(@Param("customerId") String customerId, @Param("level") String level); + + /** + * desc: 根据客户Id 和pids 获取该客户下及该组织下的网格列表 + * + * @param customerId + * @param pids + * @return java.util.List + * @author LiuJanJun + * @date 2021/6/10 10:45 上午 + */ + List selectGridInfoList(@Param("customerId") String customerId, @Param("pids") String pids); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java index d19a8bfca8..f2a40b11c0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java @@ -107,4 +107,6 @@ public interface ScreenCustomerGridService extends BaseService center); List selectGridInfoByCustomerId(String customerId); + + List selectGridInfoList(String customerId, String pids); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java index f8100355bc..9f1c1c2a96 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java @@ -206,4 +206,9 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl selectGridInfoByCustomerId(String customerId) { return baseDao.selectGridInfoByCustomerId(customerId); } + + @Override + public List selectGridInfoList(String customerId, String pids) { + return baseDao.selectGridInfoList(customerId,pids); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java index c846f14f30..696b6fb221 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java @@ -15,6 +15,7 @@ import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; import com.epmet.service.org.CustomerAgencyService; import com.epmet.service.org.CustomerDepartmentService; import com.epmet.service.org.CustomerGridService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -136,21 +137,23 @@ public class EIDimServiceImpl implements EIDimService { @Override public Map updateCenterPointByName(GridCenterPointForm param) { - List gridInfos = screenCustomerGridService.selectGridInfoByCustomerId(param.getCustomerId()); + List gridInfos = screenCustomerGridService.selectGridInfoList(param.getCustomerId(),param.getPids()); Map result = new HashMap<>(); gridInfos.forEach(grid -> { //客户id 和组织id 都相等 且 名字 包含关系时才修改 if (grid.getCustomerId().equals(param.getCustomerId())) { AtomicInteger integer = new AtomicInteger(0); - param.getCenterDataList().forEach(o -> { - String title = o.getTitle().replace("委会",""); - if (grid.getGridName().contains(title)) { - Integer effectRow = screenCustomerGridService.updateCenterPointByName(param.getCustomerId(), title, o.getCenter()); - integer.addAndGet(effectRow); - } - result.put(grid.getGridId(), integer.intValue()); - }); + if ("[]".equals(grid.getCenterMark()) || StringUtils.isBlank(grid.getCenterMark())){ + param.getCenterDataList().forEach(o -> { + String title = o.getTitle().replace("委会",""); + if (grid.getGridName().startsWith(title)) { + Integer effectRow = screenCustomerGridService.updateCenterPointByName(param.getCustomerId(), title, o.getCenter()); + integer.addAndGet(effectRow); + } + result.put(grid.getGridId(), integer.intValue()); + }); + } } }); return result; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml index e5d0c1a183..0fca6febf5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml @@ -352,6 +352,7 @@ cg.GRID_NAME, cg.PARENT_AGENCY_ID AS pid, cg.AREA_CODE, + cg.CENTER_MARK, ca.pids FROM screen_customer_grid cg LEFT JOIN screen_customer_agency ca ON ca.AGENCY_ID = cg.PARENT_AGENCY_ID @@ -371,5 +372,18 @@ AND scg.DEL_FLAG = 0 AND scg.CUSTOMER_ID = #{customerId} + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index 2a7dd704f8..c0a987206b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -705,6 +705,6 @@ public class CustomerGridServiceImpl extends BaseServiceImpl getBaseInfo(CustomerGridFormDTO customerGridFormDTO) { - return new Result().ok(baseDao.getGridBaseInfoById(customerGridFormDTO.getGridId())); + return new Result().ok(ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class)); } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/PatrolConstant.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/PatrolConstant.java new file mode 100644 index 0000000000..b6f27bbd62 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/PatrolConstant.java @@ -0,0 +1,13 @@ +package com.epmet.constant; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/8 15:28 + */ +public interface PatrolConstant { + String PATROLLING = "patrolling"; + String END = "end"; + + String NOT_END_MSG = "%s巡查尚未结束,请切换至%s查看。"; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolRecordDetailFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolRecordDetailFormDTO.java new file mode 100644 index 0000000000..2f87874dd5 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolRecordDetailFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:23 + */ +@NoArgsConstructor +@Data +public class PatrolRecordDetailFormDTO implements Serializable { + private static final long serialVersionUID = 7496587490046732883L; + /** + * 巡查记录id + */ + private String staffPatrolRecId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolUploadDetailFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolUploadDetailFormDTO.java new file mode 100644 index 0000000000..4484f45f30 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolUploadDetailFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/9 16:31 + */ +@Data +public class PatrolUploadDetailFormDTO implements Serializable { + private static final long serialVersionUID = 1527344810917196996L; + /** + * 巡查主记录id, 开始巡查反参 + */ + private String staffPatrolRecId; + private List details; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolUploadFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolUploadFormDTO.java new file mode 100644 index 0000000000..a6f564dca7 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolUploadFormDTO.java @@ -0,0 +1,55 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:05 + */ +@NoArgsConstructor +@Data +public class PatrolUploadFormDTO implements Serializable { + + private static final long serialVersionUID = 4665110896043941317L; + /** + * 巡查主记录id, 开始巡查反参 + */ + private String staffPatrolRecId; + /** + * 纬度 + */ + private String latitude; + /** + * 经度 + */ + private String longitude; + /** + * 速度 + */ + private String speed; + /** + * 位置的精确度 + */ + private String accuracy; + /** + * 高度,单位m + */ + private String altitude; + /** + * 垂直经度,单位m + */ + private String verticalAccuracy; + /** + * 水平经度,单位m + */ + private String horizontalAccuracy; + /** + * 序号,前端生成,后端记录 + */ + private Integer serialNum; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffPatrolInitFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffPatrolInitFormDTO.java new file mode 100644 index 0000000000..fb895e8c90 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffPatrolInitFormDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:16 + */ +@NoArgsConstructor +@Data +public class StaffPatrolInitFormDTO { + + /** + * 当前工作人员基层治理所在网格id;可为空 + */ + private String gridId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StartPatrolFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StartPatrolFormDTO.java new file mode 100644 index 0000000000..1bf9d55e25 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StartPatrolFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:32 + */ +@NoArgsConstructor +@Data +public class StartPatrolFormDTO implements Serializable { + + private static final long serialVersionUID = -2765639550834711582L; + /** + * 网格id + */ + private String gridId; + /** + * 纬度 + */ + private String latitude; + /** + * 经度 + */ + private String longitude; + /** + * 速度,如果拿不到默认0 + */ + private String speed; + /** + * 序号;前端生成,后端负责记录,开始巡查赋值0 + */ + private Integer serialNum; + + private String staffPatrolRecId; + + private String patrolEndTime; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PatrolRecordDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PatrolRecordDetailResultDTO.java new file mode 100644 index 0000000000..ee1b9e172d --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PatrolRecordDetailResultDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:24 + */ +@NoArgsConstructor +@Data +public class PatrolRecordDetailResultDTO implements Serializable { + + private static final long serialVersionUID = -1812674284508241468L; + /** + * 上传时间;yyyy-MM-dd HH:mm + */ + private String uploadTime; + /** + * 纬度 + */ + private String latitude; + /** + * 经度 + */ + private String longitude; + /** + * 速度,单位m/s + */ + private String speed; + /** + * 后端返回:开始巡查;结束巡查;此列只有集合第一条,和最后一条有值 + */ + private String flag; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PatrolUploadResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PatrolUploadResultDTO.java new file mode 100644 index 0000000000..50882ef37a --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PatrolUploadResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:14 + */ +@Data +public class PatrolUploadResultDTO implements Serializable { + private static final long serialVersionUID = -1750373142795803118L; + /** + * 巡查主记录id + */ + private String staffPatrolRecId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffPatrolInitResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffPatrolInitResultDTO.java new file mode 100644 index 0000000000..56b2589341 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffPatrolInitResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:17 + */ +@NoArgsConstructor +@Data +public class StaffPatrolInitResultDTO implements Serializable { + + private static final long serialVersionUID = -1752690564468072256L; + /** + * 存在正在巡查中记录返回:patrolling;不存在:end + */ + private String status; + /** + * 巡查记录id,status=patrolling时此列有值 + */ + private String staffPatrolRecId; + /** + * patrolling:返回最大的序号;status=end时,此列返回-1 + */ + private Integer latestSerialNum; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StartPatrolResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StartPatrolResultDTO.java new file mode 100644 index 0000000000..06d323df11 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StartPatrolResultDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:34 + */ +@NoArgsConstructor +@Data +public class StartPatrolResultDTO implements Serializable { + + private static final long serialVersionUID = -8064467225255970920L; + /** + * 巡查记录id + */ + private String staffPatrolRecId; + /** + * 最小时间间隔,单位s;默认30,后面可以做成客户可配置参数 + */ + private Integer carmDown; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffPatrolController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffPatrolController.java index f0a0558c34..4948e36d7a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffPatrolController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffPatrolController.java @@ -1,21 +1,25 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.PatrolTrackFormDTO; -import com.epmet.dto.form.RecordListFormDTO; -import com.epmet.dto.result.GridManagerUserListResultDTO; -import com.epmet.dto.result.PatrolTrackResultDTO; -import com.epmet.dto.result.RecordListResultDTO; -import com.epmet.dto.result.UserNameAndLLResultDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.service.StaffPatrolDetailService; import com.epmet.service.StaffPatrolRecordService; -import com.epmet.user.result.GridManagerListResultDTO; -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 javax.annotation.Resource; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 15:49 import java.util.List; /** @@ -26,9 +30,81 @@ import java.util.List; @RestController @RequestMapping("staffpatrol") public class StaffPatrolController { + @Resource + private StaffPatrolDetailService staffPatrolDetailService; + @Resource + private StaffPatrolRecordService staffPatrolRecordService; + + /** + * 巡查界面初始化 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2021/6/7 16:40 + */ + @PostMapping("init") + public Result init(@LoginUser TokenDto tokenDto, @RequestBody StaffPatrolInitFormDTO formDTO) { + StaffPatrolInitResultDTO result = staffPatrolRecordService.init(tokenDto, formDTO); + return new Result().ok(result); + + } + + /** + * 开始巡查 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2021/6/7 16:46 + */ + @PostMapping("startpatrol") + public Result startPatrol(@LoginUser TokenDto tokenDto, @RequestBody StartPatrolFormDTO formDTO) { + StartPatrolResultDTO result = staffPatrolRecordService.startPatrol(tokenDto, formDTO); + return new Result().ok(result); + + } + + /** + * 结束巡查 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2021/6/7 16:46 + */ + @PostMapping("endpatrol") + public Result endPatrol(@LoginUser TokenDto tokenDto, @RequestBody StartPatrolFormDTO formDTO) { + staffPatrolRecordService.endPatrol(tokenDto, formDTO); + return new Result(); + + } + + /** + * 上传巡查记录 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2021/6/7 16:46 + */ + @PostMapping("uploaddetail") + public Result uploadDetail(@LoginUser TokenDto tokenDto, @RequestBody PatrolUploadFormDTO formDTO) { + PatrolUploadResultDTO result = staffPatrolRecordService.uploadDetail(tokenDto, formDTO); + return new Result().ok(result); + + } + + @PostMapping("uploaddetails") + public Result uploadDetails(@LoginUser TokenDto tokenDto, @RequestBody PatrolUploadDetailFormDTO formDTO) { + PatrolUploadResultDTO result = staffPatrolRecordService.uploadDetails(tokenDto, formDTO); + return new Result().ok(result); - @Autowired - private StaffPatrolRecordService staffPatrolRecordService; + } /** * @Description 查询经纬度 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolDetailService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolDetailService.java index ff79804e27..0ceb24625f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolDetailService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolDetailService.java @@ -18,8 +18,11 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dto.StaffPatrolDetailDTO; import com.epmet.entity.StaffPatrolDetailEntity; +import java.util.List; + /** * 工作人员巡查记录明细 * @@ -28,5 +31,23 @@ import com.epmet.entity.StaffPatrolDetailEntity; */ public interface StaffPatrolDetailService extends BaseService { + /** + * 获取最后一次记录明细 + * @author zhaoqifeng + * @date 2021/6/8 15:13 + * @param staffPatrolRecId + * @return com.epmet.dto.StaffPatrolDetailDTO + */ + StaffPatrolDetailDTO getLastDetail(String staffPatrolRecId); + + /** + * 获取所以记录明细 + * @author zhaoqifeng + * @date 2021/6/8 15:13 + * @param staffPatrolRecId + * @return java.util.List + */ + List getDetailList(String staffPatrolRecId); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolRecordService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolRecordService.java index 9883d87bc9..7eae381718 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolRecordService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffPatrolRecordService.java @@ -18,8 +18,11 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.dto.form.PatrolTrackFormDTO; -import com.epmet.dto.form.RecordListFormDTO; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.form.*; +import com.epmet.dto.result.PatrolUploadResultDTO; +import com.epmet.dto.result.StaffPatrolInitResultDTO; +import com.epmet.dto.result.StartPatrolResultDTO; import com.epmet.dto.result.PatrolTrackResultDTO; import com.epmet.dto.result.RecordListResultDTO; import com.epmet.dto.result.UserNameAndLLResultDTO; @@ -36,6 +39,60 @@ import java.util.List; */ public interface StaffPatrolRecordService extends BaseService { + /** + * 巡查界面初始化 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.StaffPatrolInitResultDTO + * @author zhaoqifeng + * @date 2021/6/7 16:47 + */ + StaffPatrolInitResultDTO init(TokenDto tokenDto, StaffPatrolInitFormDTO formDTO); + + /** + * 开始巡查 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.StartPatrolResultDTO + * @author zhaoqifeng + * @date 2021/6/7 16:49 + */ + StartPatrolResultDTO startPatrol(TokenDto tokenDto, StartPatrolFormDTO formDTO); + + /** + * 结束巡查 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2021/6/7 16:49 + */ + void endPatrol(TokenDto tokenDto, StartPatrolFormDTO formDTO); + + /** + * 上传巡查记录 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.PatrolUploadResultDTO + * @author zhaoqifeng + * @date 2021/6/7 16:49 + */ + PatrolUploadResultDTO uploadDetail(TokenDto tokenDto, PatrolUploadFormDTO formDTO); + + /** + * 上传巡查记录 + * @author zhaoqifeng + * @date 2021/6/9 16:32 + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.PatrolUploadResultDTO + */ + PatrolUploadResultDTO uploadDetails(TokenDto tokenDto, PatrolUploadDetailFormDTO formDTO); + /** * @Description 查询经纬度 * @Param userIds diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolDetailServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolDetailServiceImpl.java index 591e95c093..2c3e9a8460 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolDetailServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolDetailServiceImpl.java @@ -17,12 +17,17 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.StaffPatrolDetailDao; +import com.epmet.dto.StaffPatrolDetailDTO; import com.epmet.entity.StaffPatrolDetailEntity; import com.epmet.service.StaffPatrolDetailService; import org.springframework.stereotype.Service; +import java.util.List; + /** * 工作人员巡查记录明细 * @@ -33,5 +38,38 @@ import org.springframework.stereotype.Service; public class StaffPatrolDetailServiceImpl extends BaseServiceImpl implements StaffPatrolDetailService { + /** + * 获取最后一次记录明细 + * + * @param staffPatrolRecId + * @return com.epmet.dto.StaffPatrolDetailDTO + * @author zhaoqifeng + * @date 2021/6/8 15:13 + */ + @Override + public StaffPatrolDetailDTO getLastDetail(String staffPatrolRecId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("STAFF_PATROL_REC_ID", staffPatrolRecId); + wrapper.orderByDesc("SERIAL_NUM"); + wrapper.last("limit 1"); + StaffPatrolDetailEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, StaffPatrolDetailDTO.class); + } + /** + * 获取所以记录明细 + * + * @param staffPatrolRecId + * @return java.util.List + * @author zhaoqifeng + * @date 2021/6/8 15:13 + */ + @Override + public List getDetailList(String staffPatrolRecId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("STAFF_PATROL_REC_ID", staffPatrolRecId); + wrapper.orderByDesc("SERIAL_NUM"); + List entity = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(entity, StaffPatrolDetailDTO.class); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java index f0d9103e51..f72166928b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java @@ -1,21 +1,39 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.PatrolConstant; import com.epmet.dao.CustomerStaffDao; import com.epmet.dao.StaffPatrolDetailDao; import com.epmet.dao.StaffPatrolRecordDao; -import com.epmet.dao.UserBaseInfoDao; -import com.epmet.dto.form.PatrolTrackFormDTO; -import com.epmet.dto.form.RecordListFormDTO; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.StaffPatrolDetailDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.*; +import com.epmet.entity.StaffPatrolDetailEntity; import com.epmet.entity.StaffPatrolRecordEntity; +import com.epmet.feign.GovOrgFeignClient; +import com.epmet.service.StaffPatrolDetailService; import com.epmet.service.StaffPatrolRecordService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; +import org.springframework.transaction.annotation.Transactional; +import org.apache.commons.collections4.CollectionUtils; +import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * 工作人员巡查主记录 @@ -24,41 +42,246 @@ import java.util.List; * @since v1.0.0 2021-06-07 */ @Service +@Slf4j public class StaffPatrolRecordServiceImpl extends BaseServiceImpl implements StaffPatrolRecordService { - @Autowired - private CustomerStaffDao customerStaffDao; + @Resource + private StaffPatrolDetailService staffPatrolDetailService; + @Resource + private GovOrgFeignClient govOrgFeignClient; + @Autowired + private CustomerStaffDao customerStaffDao; - @Autowired - private StaffPatrolRecordDao staffPatrolRecordDao; + @Autowired + private StaffPatrolRecordDao staffPatrolRecordDao; - @Autowired - private StaffPatrolDetailDao staffPatrolDetailDao; + @Autowired + private StaffPatrolDetailDao staffPatrolDetailDao; - /** - * @Description 查询经纬度 - * @Param userIds - * @author zxc - * @date 2021/6/9 10:40 上午 - */ - @Override - public UserNameAndLLResultDTO selectLL(List userIds) { - UserNameAndLLResultDTO result = new UserNameAndLLResultDTO(); - if (CollectionUtils.isEmpty(userIds)){ - return result; - } - // 经纬度查询 - List llResult = baseDao.selectLL(userIds); - if (!CollectionUtils.isEmpty(llResult)){ - result.setLl(llResult); - } - // 姓名查询 - List nameResult = customerStaffDao.selectUserName(userIds); - if (!CollectionUtils.isEmpty(nameResult)){ - result.setUserNames(nameResult); - } - return result; - } + + /** + * 巡查界面初始化 + * + * @param tokenDto token + * @param formDTO 入参 + * @return com.epmet.dto.result.StaffPatrolInitResultDTO + * @author zhaoqifeng + * @date 2021/6/7 16:47 + */ + @Override + public StaffPatrolInitResultDTO init(TokenDto tokenDto, StaffPatrolInitFormDTO formDTO) { + StaffPatrolInitResultDTO result = new StaffPatrolInitResultDTO(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(formDTO.getGridId()), "GRID", formDTO.getGridId()) + .eq("STAFF_ID", tokenDto.getUserId()) + .orderByDesc("PATROL_START_TIME") + .last("limit 1"); + StaffPatrolRecordEntity entity = baseDao.selectOne(wrapper); + if (null == entity) { + result.setLatestSerialNum(NumConstant.ONE_NEG); + result.setStatus(PatrolConstant.END); + result.setStaffPatrolRecId(StrConstant.EPMETY_STR); + return result; + } + StaffPatrolDetailDTO detail = staffPatrolDetailService.getLastDetail(entity.getId()); + result.setStaffPatrolRecId(entity.getId()); + result.setStatus(entity.getStatus()); + result.setLatestSerialNum(PatrolConstant.END.equals(entity.getStatus()) ? NumConstant.ONE_NEG : detail.getSerialNum()); + return result; + } + + /** + * 开始巡查 + * + * @param tokenDto token + * @param formDTO 入参 + * @return com.epmet.dto.result.StartPatrolResultDTO + * @author zhaoqifeng + * @date 2021/6/7 16:49 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public StartPatrolResultDTO startPatrol(TokenDto tokenDto, StartPatrolFormDTO formDTO) { + //获取最新的巡查记录 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(formDTO.getGridId()), "GRID", formDTO.getGridId()) + .eq("STAFF_ID", tokenDto.getUserId()) + .orderByDesc("PATROL_START_TIME") + .last("limit 1"); + StaffPatrolRecordEntity entity = baseDao.selectOne(wrapper); + + CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO(); + customerGridFormDTO.setGridId(formDTO.getGridId()); + Result gridResult = govOrgFeignClient.getGridBaseInfoByGridId(customerGridFormDTO); + if (!gridResult.success() || null == gridResult.getData()) { + //查询网格名称失败 + log.error(String.format("查找网格信息失败,网格Id:【%s】", formDTO.getGridId())); + throw new RenException(gridResult.getCode(), gridResult.getMsg()); + } + CustomerGridDTO grid = gridResult.getData(); + + //判断巡查是否结束,如果未结束,返回消息提示 + if (null != entity && PatrolConstant.PATROLLING.equals(entity.getStatus())) { + throw new RenException(EpmetErrorCode.PATROL_IS_NOT_OVER.getCode(), String.format(PatrolConstant.NOT_END_MSG, grid.getGridName(), + grid.getGridName())); + } + //创建巡查记录 + StaffPatrolRecordEntity record = new StaffPatrolRecordEntity(); + record.setCustomerId(grid.getCustomerId()); + record.setAgencyId(grid.getPid()); + record.setGridPids(grid.getPids()); + record.setGrid(formDTO.getGridId()); + record.setStaffId(tokenDto.getUserId()); + record.setPatrolStartTime(new Date()); + record.setStatus(PatrolConstant.PATROLLING); + insert(record); + + //保存记录明细 + StaffPatrolDetailEntity detailEntity = new StaffPatrolDetailEntity(); + detailEntity.setStaffPatrolRecId(record.getId()); + detailEntity.setCustomerId(grid.getCustomerId()); + detailEntity.setSerialNum(formDTO.getSerialNum()); + detailEntity.setUploadTime(new Date()); + detailEntity.setLatitude(formDTO.getLatitude()); + detailEntity.setLongitude(formDTO.getLongitude()); + detailEntity.setSpeed(formDTO.getSpeed()); + staffPatrolDetailService.insert(detailEntity); + + StartPatrolResultDTO result = new StartPatrolResultDTO(); + result.setStaffPatrolRecId(record.getId()); + result.setCarmDown(NumConstant.THIRTY); + return result; + } + + /** + * 结束巡查 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2021/6/7 16:49 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void endPatrol(TokenDto tokenDto, StartPatrolFormDTO formDTO) { + StaffPatrolRecordEntity record = baseDao.selectById(formDTO.getStaffPatrolRecId()); + if (null == record) { + throw new RenException("巡查记录不存在"); + } + if (PatrolConstant.END.equals(record.getStatus())) { + throw new RenException("巡查已结束,请勿重复提交"); + } + + record.setActrualEndTime(new Date()); + record.setUpdatedTime(null); + record.setPatrolEndTime(DateUtils.parse(formDTO.getPatrolEndTime(), DateUtils.DATE_TIME_PATTERN)); + record.setTotalTime(DateUtils.calculateSecond(record.getPatrolStartTime(), record.getPatrolEndTime())); + record.setStatus(PatrolConstant.END); + baseDao.updateById(record); + //保存记录明细 + StaffPatrolDetailEntity detailEntity = new StaffPatrolDetailEntity(); + detailEntity.setStaffPatrolRecId(record.getId()); + detailEntity.setCustomerId(record.getCustomerId()); + detailEntity.setSerialNum(formDTO.getSerialNum()); + detailEntity.setUploadTime(new Date()); + detailEntity.setLatitude(formDTO.getLatitude()); + detailEntity.setLongitude(formDTO.getLongitude()); + detailEntity.setSpeed(formDTO.getSpeed()); + staffPatrolDetailService.insert(detailEntity); + } + + /** + * 上传巡查记录 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.PatrolUploadResultDTO + * @author zhaoqifeng + * @date 2021/6/7 16:49 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public PatrolUploadResultDTO uploadDetail(TokenDto tokenDto, PatrolUploadFormDTO formDTO) { + StaffPatrolDetailEntity detailEntity = new StaffPatrolDetailEntity(); + detailEntity.setStaffPatrolRecId(formDTO.getStaffPatrolRecId()); + detailEntity.setCustomerId(tokenDto.getCustomerId()); + detailEntity.setSerialNum(formDTO.getSerialNum()); + detailEntity.setUploadTime(new Date()); + detailEntity.setLatitude(formDTO.getLatitude()); + detailEntity.setLongitude(formDTO.getLongitude()); + detailEntity.setSpeed(formDTO.getSpeed()); + detailEntity.setAccuracy(formDTO.getAccuracy()); + detailEntity.setAltitude(formDTO.getAltitude()); + detailEntity.setVerticalaccuracy(formDTO.getVerticalAccuracy()); + detailEntity.setHorizontalaccuracy(formDTO.getHorizontalAccuracy()); + staffPatrolDetailService.insert(detailEntity); + + PatrolUploadResultDTO dto = new PatrolUploadResultDTO(); + dto.setStaffPatrolRecId(formDTO.getStaffPatrolRecId()); + return dto; + } + + /** + * 上传巡查记录 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.PatrolUploadResultDTO + * @author zhaoqifeng + * @date 2021/6/9 16:32 + */ + @Override + public PatrolUploadResultDTO uploadDetails(TokenDto tokenDto, PatrolUploadDetailFormDTO formDTO) { + if (CollectionUtils.isNotEmpty(formDTO.getDetails())) { + List list = formDTO.getDetails().stream().map(detail -> { + StaffPatrolDetailEntity detailEntity = new StaffPatrolDetailEntity(); + detailEntity.setStaffPatrolRecId(formDTO.getStaffPatrolRecId()); + detailEntity.setCustomerId(tokenDto.getCustomerId()); + detailEntity.setSerialNum(detail.getSerialNum()); + detailEntity.setUploadTime(new Date()); + detailEntity.setLatitude(detail.getLatitude()); + detailEntity.setLongitude(detail.getLongitude()); + detailEntity.setSpeed(detail.getSpeed()); + detailEntity.setAccuracy(detail.getAccuracy()); + detailEntity.setAltitude(detail.getAltitude()); + detailEntity.setVerticalaccuracy(detail.getVerticalAccuracy()); + detailEntity.setHorizontalaccuracy(detail.getHorizontalAccuracy()); + return detailEntity; + }).collect(Collectors.toList()); + + staffPatrolDetailService.insertBatch(list); + } + + PatrolUploadResultDTO dto = new PatrolUploadResultDTO(); + dto.setStaffPatrolRecId(formDTO.getStaffPatrolRecId()); + return dto; + } + + /** + * @Description 查询经纬度 + * @Param userIds + * @author zxc + * @date 2021/6/9 10:40 上午 + */ + @Override + public UserNameAndLLResultDTO selectLL(List userIds) { + UserNameAndLLResultDTO result = new UserNameAndLLResultDTO(); + if (CollectionUtils.isEmpty(userIds)){ + return result; + } + // 经纬度查询 + List llResult = baseDao.selectLL(userIds); + if (!CollectionUtils.isEmpty(llResult)){ + result.setLl(llResult); + } + // 姓名查询 + List nameResult = customerStaffDao.selectUserName(userIds); + if (!CollectionUtils.isEmpty(nameResult)){ + result.setUserNames(nameResult); + } + return result; + } /** * @Description 002、查看巡查记录 diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.12__add_user_patrol.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.12__add_user_patrol.sql new file mode 100644 index 0000000000..80a59beb1d --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.12__add_user_patrol.sql @@ -0,0 +1,46 @@ +CREATE TABLE `staff_patrol_detail` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', + `STAFF_PATROL_REC_ID` varchar(64) NOT NULL COMMENT 'staff_patrol_record.ID', + `SERIAL_NUM` int(11) NOT NULL COMMENT '前端给的序号', + `UPLOAD_TIME` datetime NOT NULL COMMENT '上传时间,后台自动插入该时间', + `LATITUDE` varchar(64) NOT NULL COMMENT '纬度', + `LONGITUDE` varchar(64) NOT NULL COMMENT '经度', + `SPEED` varchar(64) NOT NULL DEFAULT '0' COMMENT '速度,单位m/s;开始和结束时默认0', + `ACCURACY` varchar(64) DEFAULT NULL COMMENT '位置的精确度', + `ALTITUDE` varchar(64) DEFAULT NULL COMMENT '高度,单位米', + `VERTICALACCURACY` varchar(64) DEFAULT NULL COMMENT '垂直经度,单位m', + `HORIZONTALACCURACY` varchar(64) DEFAULT NULL COMMENT '水平经度,单位m', + `ADDRESS` varchar(255) DEFAULT NULL COMMENT '地址;暂时不用', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作人员巡查记录明细'; + +-- ---------------------------- +-- Table structure for staff_patrol_record +-- ---------------------------- +CREATE TABLE `staff_patrol_record` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', + `GRID` varchar(64) NOT NULL COMMENT '网格id', + `GRID_PIDS` varchar(512) NOT NULL COMMENT '网格所有上级id', + `STAFF_ID` varchar(64) NOT NULL COMMENT '工作人员用户id', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '工作人员所属组织id=网格所属的组织id', + `PATROL_START_TIME` datetime NOT NULL COMMENT '巡查开始时间', + `PATROL_END_TIME` datetime DEFAULT NULL COMMENT '巡查结束时间,前端传入', + `ACTRUAL_END_TIME` datetime DEFAULT NULL COMMENT '实际结束时间=操作结束巡查的时间', + `TOTAL_TIME` int(11) DEFAULT NULL COMMENT '本次巡查总耗时,单位秒;结束巡查时写入', + `STATUS` varchar(10) NOT NULL DEFAULT 'patrolling' COMMENT '正在巡查中:patrolling;结束:end', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作人员巡查主记录';