Browse Source

Merge remote-tracking branch 'remotes/origin/dev_grid_patrol' into dev

dev_shibei_match
jianjun 4 years ago
parent
commit
c0b1c5fb16
  1. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 25
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridStaffResultDTO.java
  3. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StaffRoleDao.java
  4. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerStaffGridDao.java
  5. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  6. 100
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  7. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  8. 34
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  9. 4
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml
  10. 18
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffRoleDao.xml
  11. 16
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffGridDao.xml
  12. 9
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/ScreenProjectDetailResultDTO.java
  13. 21
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java
  14. 1
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml
  15. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectDataDTO.java
  16. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectDataEntity.java
  17. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenProjectSettleServiceImpl.java
  18. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java
  19. 4
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml
  20. 36
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerAgencyUserRoleDTO.java
  21. 30
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerAgencyUserRoleFormDTO.java
  22. 1
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/RecordListFormDTO.java
  23. 42
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RepairStaffRoleCacheResultDTO.java
  24. 24
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoleKeyValueResultDTO.java
  25. 9
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  26. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  27. 25
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
  28. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java
  29. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java
  30. 39
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java
  31. 18
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java
  32. 32
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  33. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java
  34. 71
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java
  35. 16
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml
  36. 8
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffPatrolRecordDao.xml
  37. 26
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -107,7 +107,8 @@ public enum EpmetErrorCode {
DUPLICATE_BADGE_NAME(8515, "徽章名已存在"),
DUPLICATE_PARTY_BADGE_NAME(8516, "不可删除党员徽章"),
ONLINE_BADGE_COUNT(8517, "最多上线5个徽章"),
PATROL_REPEATED_SUBMIT_ERROR(8521, "巡查已结束,请勿重复提交"),
PATROL_END_TIME_ERROR(8522, "巡查结束时间不能小于巡查开始时间"),
// 该错误不会提示给前端,只是后端传输错误信息用。
ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"),
OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR(8702, "添加客户根级组织失败"),

25
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridStaffResultDTO.java

@ -0,0 +1,25 @@
package com.epmet.dataaggre.dto.govorg.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/6/8 3:23 下午
* @DESC
*/
@Data
public class GridStaffResultDTO implements Serializable {
private static final long serialVersionUID = -5910427385795368242L;
private String gridId;
private String staffId;
//真名
private String staffName = "";
//性别0.未知,1男,2.女前端默认头像用
private String gender = "0";
}

10
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StaffRoleDao.java

@ -18,8 +18,12 @@
package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.entity.epmetuser.StaffRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 工作人员-角色关系表
@ -30,4 +34,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface StaffRoleDao extends BaseDao<StaffRoleEntity> {
/**
* @Description 查询是网格员的人
* @Param forms
* @author sun
*/
List<GridStaffResultDTO> staffGridRole(@Param("forms") List<GridStaffResultDTO> forms, @Param("staffName") String staffName);
}

10
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerStaffGridDao.java

@ -18,8 +18,12 @@
package com.epmet.dataaggre.dao.govorg;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.entity.govorg.CustomerStaffGridEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 网格人员关系表
@ -29,4 +33,10 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CustomerStaffGridDao extends BaseDao<CustomerStaffGridEntity> {
/**
* @Description 查询网格下有网格员角色的人
* @author sun
*/
List<GridStaffResultDTO> selectGridStaffByGridIds(@Param("gridIds") List<String> gridIds);
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java

@ -7,6 +7,7 @@ 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;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import java.util.List;
@ -56,4 +57,11 @@ public interface EpmetUserService {
* @return com.epmet.dataaggre.dto.epmetuser.result.PatrolDateListResultDTO
*/
PatrolDateListResultDTO patrolDateList(PatrolDateListFormDTO formDTO);
/**
* @Description 查询网格员角色
* @author sun
*/
List<GridStaffResultDTO> staffGridRole(List<GridStaffResultDTO> forms, String staffName);
}

100
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -5,7 +5,9 @@ import com.epmet.commons.tools.constant.NumConstant;
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.StaffRoleDao;
import com.epmet.dataaggre.dao.epmetuser.UserBaseInfoDao;
import com.epmet.dataaggre.dto.datastats.result.SubAgencyUserResultDTO;
import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO;
import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO;
import com.epmet.dataaggre.dto.epmetuser.form.PatrolDateListFormDTO;
@ -13,11 +15,13 @@ import com.epmet.dataaggre.dto.epmetuser.form.PatrolRecordListFormDTO;
import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.*;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
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 oracle.sql.NUMBER;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,6 +50,8 @@ public class EpmetUserServiceImpl implements EpmetUserService {
private StaffPatrolDetailService staffPatrolDetailService;
@Resource
private StaffPatrolRecordService staffPatrolRecordService;
@Resource
private StaffRoleDao staffRoleDao;
/**
* @Description 根据UserIds查询
@ -77,29 +83,78 @@ public class EpmetUserServiceImpl implements EpmetUserService {
@Override
public List<StaffListResultDTO> staffList(StaffListFormDTO formDTO) {
List<StaffListResultDTO> resultList = new ArrayList<>();
//1.设置分页参数
int num = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize();
formDTO.setPageNo(num);
//2.查询当前人员所属组织下网格列表数据,供后续使用
List<StaffListResultDTO> result = new ArrayList<>();
//1.查询当前人员所属组织下网格列表数据,供后续封装数据使用
List<CustomerGridDTO> list = govOrgService.gridListByStaffId(formDTO.getUserId());
if (list.size() < NumConstant.ONE) {
return resultList;
}
//网格集合为空则查询当前人员所属组织下网格列表
//2.网格集合为空则查询当前人员所属组织下网格列表
if (CollectionUtils.isEmpty(formDTO.getGridIds())) {
formDTO.setGridIds(list.stream().map(CustomerGridDTO::getId).collect(Collectors.toList()));
}
//3.按条件查询巡查业务数据
//3.按条件查询网格下工作人员基本信息
List<GridStaffResultDTO> staffList = govOrgService.selectGridStaffByGridIds(formDTO.getGridIds(), formDTO.getStaffName());
if (staffList.size() < NumConstant.ONE) {
return resultList;
}
for (GridStaffResultDTO st : staffList) {
StaffListResultDTO sf = new StaffListResultDTO();
sf.setGridId(st.getGridId());
sf.setStaffId(st.getStaffId());
sf.setStaffName(st.getStaffName());
sf.setGender(st.getGender());
result.add(sf);
}
//4.按条件查询巡查业务数据
formDTO.setPatrolStartTime(DateUtils.getBeforeMonthDate(formDTO.getTime()));
resultList = staffPatrolRecordDao.selectPatrolList(formDTO);
if (resultList.size() < NumConstant.ONE) {
return new ArrayList<>();
List<StaffListResultDTO> staffPatrolList = staffPatrolRecordDao.selectPatrolList(formDTO);
//5.封装数据
Map<String, String> map = new HashMap<>();
result.forEach(re -> {
staffPatrolList.forEach(st -> {
if (re.getGridId().equals(st.getGridId()) && re.getStaffId().equals(st.getStaffId())) {
re.setPatrolStartTime(st.getPatrolStartTime());
re.setPatrolTotal(st.getPatrolTotal());
re.setStatus(st.getStatus());
map.put(re.getGridId()+re.getStaffId(),re.getStaffId());
}
});
});
//可能存在的在a网格有记录后在a网格将该人员移除
staffPatrolList.forEach(st->{
if(!map.containsKey(st.getGridId()+st.getStaffId())){
result.add(st);
}
});
//6.按条件排序
Collections.sort(result, new Comparator<StaffListResultDTO>() {
@Override
public int compare(StaffListResultDTO o1, StaffListResultDTO o2) {
if ("latestPatrolledTime".equals(formDTO.getSortCode())) {
return o2.getPatrolStartTime().compareTo(o1.getPatrolStartTime());
} else {
return o2.getPatrolTotal().compareTo(o1.getPatrolTotal());
}
}
});
//7.按分页抽取数据
int num = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize();
int size = num + formDTO.getPageSize();
if (num > result.size()) {
return resultList;
}
resultList = result.subList(num, (size > result.size() ? result.size() : size));
//4.封装数据并返回
//8.赋值网格名称
resultList.forEach(re -> list.stream().filter(l -> re.getGridId().equals(l.getId())).forEach(s -> re.setGridName(s.getGridName())));
return resultList;
}
@ -137,8 +192,10 @@ public class EpmetUserServiceImpl implements EpmetUserService {
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分";
dto.setTotalTimeDesc(totalTimeDesc);
List<StaffPatrolDetailDTO> detailList = details.get(record.getId());
List<PatrolRecordDetailDTO> recordDetails =
detailList.stream().sorted(Comparator.comparing(StaffPatrolDetailDTO::getSerialNum).reversed()).collect(Collectors.toList()).stream().map( detail -> {
detailList =
detailList.stream().sorted(Comparator.comparing(StaffPatrolDetailDTO::getSerialNum).reversed()).collect(Collectors.toList()).stream()
.filter(item -> null == record.getPatrolEndTime() || record.getPatrolEndTime().compareTo(item.getUploadTime()) > -1).collect(Collectors.toList());
List<PatrolRecordDetailDTO> recordDetails = detailList.stream().map( detail -> {
PatrolRecordDetailDTO detailDTO = new PatrolRecordDetailDTO();
detailDTO.setLatitude(detail.getLatitude());
detailDTO.setLongitude(detail.getLongitude());
@ -175,5 +232,22 @@ public class EpmetUserServiceImpl implements EpmetUserService {
return dto;
}
/**
* @Description 查询网格员角色
* @Param forms
* @author sun
*/
@Override
public List<GridStaffResultDTO> staffGridRole(List<GridStaffResultDTO> forms, String staffName) {
if (org.springframework.util.CollectionUtils.isEmpty(forms)){
return new ArrayList<>();
}
List<GridStaffResultDTO> result = staffRoleDao.staffGridRole(forms, staffName);
if (org.springframework.util.CollectionUtils.isEmpty(result)){
return new ArrayList<>();
}
return result;
}
}

11
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -2,10 +2,7 @@ package com.epmet.dataaggre.service.govorg;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.result.AgencyGridResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridInfoResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridsInfoListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO;
import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import java.util.List;
@ -56,4 +53,10 @@ public interface GovOrgService {
* @Description 查询工作人员所属组织下网格列表
**/
List<CustomerGridDTO> gridListByStaffId(String staffId);
/**
* @Description 查询网格下有网格员角色的人
* @author sun
*/
List<GridStaffResultDTO> selectGridStaffByGridIds(List<String> gridIds, String staffName);
}

34
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -5,20 +5,20 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.govorg.CustomerAgencyDao;
import com.epmet.dataaggre.dao.govorg.CustomerGridDao;
import com.epmet.dataaggre.dao.govorg.CustomerStaffAgencyDao;
import com.epmet.dataaggre.dao.govorg.CustomerStaffGridDao;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.result.AgencyGridResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridInfoResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridsInfoListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO;
import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.service.commonservice.AreaCodeService;
import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import lombok.extern.slf4j.Slf4j;
@ -50,6 +50,10 @@ public class GovOrgServiceImpl implements GovOrgService {
private AreaCodeService areaCodeService;
@Autowired
private CustomerRelation customerRelation;
@Autowired
private CustomerStaffGridDao customerStaffGridDao;
@Autowired
private EpmetUserService epmetUserService;
/**
* @param staffId
@ -238,4 +242,26 @@ public class GovOrgServiceImpl implements GovOrgService {
return resultList;
}
/**
* @Description 查询网格下有网格员角色的人
* @author sun
*/
@Override
public List<GridStaffResultDTO> selectGridStaffByGridIds(List<String> gridIds, String staffName) {
if (org.springframework.util.CollectionUtils.isEmpty(gridIds)){
return new ArrayList<>();
}
// 查询网格下所有的人
List<GridStaffResultDTO> gridStaff = customerStaffGridDao.selectGridStaffByGridIds(gridIds);
if (org.springframework.util.CollectionUtils.isEmpty(gridStaff)){
return new ArrayList<>();
}
// 拿着网格下所有人去筛选网格员
List<GridStaffResultDTO> result = epmetUserService.staffGridRole(gridStaff, staffName);
if (org.springframework.util.CollectionUtils.isEmpty(result)){
return new ArrayList<>();
}
return result;
}
}

4
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml

@ -32,13 +32,14 @@
AND spr.patrol_start_time <![CDATA[ >= ]]> #{patrolStartTime}
</if>
<if test='staffName != "" and staffName != null'>
AND cs.real_name LIKE CONCAT('%',#{staffName},'%')
AND cs.real_name = #{staffName}
</if>
<foreach collection="gridIds" item="gridId" open="AND( " separator=" OR " close=")">
spr.GRID = #{gridId}
</foreach>
GROUP BY
spr.grid, spr.staff_id
<!--
<if test='sortCode != "" and sortCode != null and sortCode == "patrolTotal" '>
ORDER BY COUNT(spr.staff_id) DESC
</if>
@ -47,6 +48,7 @@
</if>
LIMIT
#{pageNo}, #{pageSize}
-->
</select>
</mapper>

18
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffRoleDao.xml

@ -3,5 +3,23 @@
<mapper namespace="com.epmet.dataaggre.dao.epmetuser.StaffRoleDao">
<select id="staffGridRole" resultType="com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO">
<foreach collection="forms" item="s" separator=" UNION ALL ">
SELECT
#{s.gridId} AS gridId,
sr.staff_id AS staffId,
cs.real_name AS staffName,
cs.gender AS gender
FROM staff_role sr
LEFT JOIN gov_staff_role gsr ON gsr.id = sr.role_id AND gsr.del_flag = 0
LEFT JOIN customer_staff cs ON sr.staff_id = cs.user_id
WHERE sr.del_flag = 0
AND gsr.role_key = 'grid_member'
AND sr.staff_id = #{s.staffId}
<if test='null != staffName and "" != staffName'>
AND cs.real_name = #{staffName}
</if>
</foreach>
</select>
</mapper>

16
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffGridDao.xml

@ -2,4 +2,20 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dataaggre.dao.govorg.CustomerStaffGridDao">
<select id="selectGridStaffByGridIds" resultType="com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO">
SELECT
user_id AS staffId,
grid_id
FROM
customer_staff_grid
WHERE
del_flag = '0'
AND (
<foreach collection="gridIds" item="gridId" separator=" OR ">
grid_id = #{gridId}
</foreach>
)
</select>
</mapper>

9
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/ScreenProjectDetailResultDTO.java

@ -7,6 +7,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* @description:
@ -36,6 +37,14 @@ public class ScreenProjectDetailResultDTO implements Serializable {
* 所属类别名称
*/
private String categoryName;
/**
* 上报人ID
*/
private String reportUserId;
/**
* 上报人角色列表
*/
private Set<String> reportUserRoleSet;
/**
* 上报人名
*/

21
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java

@ -10,6 +10,8 @@ import com.epmet.datareport.dao.evaluationindex.screen.ScreenEventImgDataDao;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenProjectDataDao;
import com.epmet.datareport.service.evaluationindex.screen.ScreenProjectService;
import com.epmet.dto.CustomerAgencyUserRoleDTO;
import com.epmet.dto.form.CustomerAgencyUserRoleFormDTO;
import com.epmet.dto.form.screen.CategoryAnalysisFormDTO;
import com.epmet.dto.form.screen.ColorProjectTotalFormDTO;
import com.epmet.dto.result.screen.CategoryAnalysisResultDTO;
@ -20,6 +22,7 @@ import com.epmet.evaluationindex.screen.dto.form.ScreenProjectDistributionFormDT
import com.epmet.evaluationindex.screen.dto.result.ProjectDetailResultDTO;
import com.epmet.evaluationindex.screen.dto.result.ScreenProjectDetailResultDTO;
import com.epmet.evaluationindex.screen.dto.result.ScreenProjectDistributionResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.project.CustomerProjectCategoryDTO;
import lombok.extern.slf4j.Slf4j;
@ -56,6 +59,8 @@ public class ScreenProjectServiceImpl implements ScreenProjectService {
private ScreenProjectCategoryOrgDailyDao screenProjectCategoryOrgDailyDao;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private EpmetUserOpenFeignClient userOpenFeignClient;
/**
* @Description 3项目详情
@ -105,6 +110,22 @@ public class ScreenProjectServiceImpl implements ScreenProjectService {
public Result projectDistributionDetail(ScreenProjectDetailFormDTO formDTO) {
List<ScreenProjectDetailResultDTO> resultDTOS = screenProjectDataDao.projectDistributionDetail(formDTO.getProjectId());
resultDTOS.forEach(item -> {
//获取联系人
if (StringUtils.isNotBlank(item.getReportUserId())){
CustomerAgencyUserRoleFormDTO userRoleFormDTO = new CustomerAgencyUserRoleFormDTO();
userRoleFormDTO.setCustomerId(formDTO.getCustomerId());
userRoleFormDTO.setStaffId(item.getReportUserId());
Result<CustomerAgencyUserRoleDTO> userRoles = userOpenFeignClient.getUserRoles(userRoleFormDTO);
if (userRoles != null && userRoles.success() && userRoles.getData() != null){
Map<String,String> roles = userRoles.getData().getRoles();
if (!CollectionUtils.isEmpty(roles)){
item.setReportUserRoleSet(roles.keySet());
}
}
}
//项目图片
List<String> imgList = screenProjectDataDao.selectProjectImgs(formDTO.getProjectId(),item.getCustomerId());
item.setImgList(imgList);

1
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml

@ -63,6 +63,7 @@
project_content AS projectContent,
project_create_time as reportTime,
ALL_CATEGORY_NAME as categoryName,
LINK_USER_ID as reportUserId,
LINK_NAME as reportUserName,
link_mobile as mobile,
project_address as reportAddress,

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectDataDTO.java

@ -83,7 +83,10 @@ public class ScreenProjectDataDTO implements Serializable {
* 事件时间
*/
private Date projectCreateTime;
/**
* 上报人ID
*/
private String linkUserId;
/**
* 上报人
*/

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectDataEntity.java

@ -77,7 +77,12 @@ public class ScreenProjectDataEntity extends BaseEpmetEntity {
/**
* 事件时间
*/
private String projectCreateTime;
private Date projectCreateTime;
/**
* 上报人ID
*/
private String linkUserId;
/**
* 上报人
@ -139,4 +144,5 @@ public class ScreenProjectDataEntity extends BaseEpmetEntity {
*/
private String allParentIds;
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenProjectSettleServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.service.evaluationindex.extract.toscreen.impl;
import com.epmet.constant.OrgTypeConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.screen.ScreenProjectImgDataDTO;
@ -86,7 +87,10 @@ public class ScreenProjectSettleServiceImpl implements ScreenProjectSettleServic
meta.setOrigin(projectInfo.getOrigin());
//直接立项的话 项目内容是项目背景 经纬度添加
if (ProjectConstant.PROJECT_ORIGIN_AGENCY.equals(projectInfo.getOrigin())){
meta.setOrgType(OrgTypeConstant.AGENCY);
meta.setOrgId(projectInfo.getAgencyId());
meta.setProjectContent(projectInfo.getBackGround());
meta.setLinkUserId(projectInfo.getCreatedBy());
meta.setLinkName(projectInfo.getCreatedBy());
if (StringUtils.isNotBlank(projectInfo.getLocateDimension())){
meta.setLatitude(new BigDecimal(projectInfo.getLocateDimension()));
@ -95,6 +99,8 @@ public class ScreenProjectSettleServiceImpl implements ScreenProjectSettleServic
meta.setLongitude(new BigDecimal(projectInfo.getLocateLongitude()));
}
meta.setProjectAddress(projectInfo.getLocateAddress());
} else {
meta.setLinkUserId(meta.getLinkName());
}
return meta;
})).collect(Collectors.toList());

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java

@ -272,7 +272,10 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
affectedRows = baseDao.deleteByProjectTimeAndCustomerId(customerId, dateId);
}
List<List<ScreenProjectDataDTO>> partition = ListUtils.partition(meta, NumConstant.ONE_HUNDRED);
partition.forEach(part -> baseDao.insertBatch(part));
partition.forEach(part -> {
List<ScreenProjectDataEntity> list = ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class);
insertBatch(list);
});
}

4
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml

@ -563,13 +563,13 @@
data.CUSTOMER_ID,
'grid' as orgType,
data.GRID_ID as orgId,
data.AGENCY_ID as parentId,
data.PID as parentId,
agency.AGENCY_NAME as orgName,
data.ID as projectId,
data.TOPIC_CREATOR_ID as linkName,
IF(data.PROJECT_STATUS = 'closed','closed_case',data.PROJECT_STATUS) as projectStatusCode,
3 as projectLevel,
IF(data.PIDS IS NULL || TRIM(data.PIDS) = '',data.AGENCY_ID,CONCAT(REPLACE(data.PIDS,':',','),',',data.AGENCY_ID)) as allParentIds,
data.PIDS as allParentIds,
data.TOPIC_ID,
IFNULL(log.response, 0) AS responseCount,
#{dataEndTime} as dataEndTime

36
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerAgencyUserRoleDTO.java

@ -0,0 +1,36 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* @Author zxc
* @DateTime 2021/6/15 10:00 上午
* @DESC
*/
@Data
public class CustomerAgencyUserRoleDTO implements Serializable {
/**
* 客户ID
*/
private String customerId;
/**
* 组织ID
*/
private String agencyId;
/**
* 工作人员ID
*/
private String staffId;
/**
* 角色
*/
private Map roles;
}

30
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerAgencyUserRoleFormDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @Author zxc
* @DateTime 2021/6/15 2:54 下午
* @DESC
*/
@Data
public class CustomerAgencyUserRoleFormDTO implements Serializable {
private static final long serialVersionUID = -4880100913767612685L;
public interface CustomerAgencyUserRoleForm{}
@NotBlank(message = "客户ID不能为空",groups = CustomerAgencyUserRoleForm.class)
private String customerId;
/**
* 工作人员IDs
*/
@NotBlank(message = "工作人员ID不能为空",groups = CustomerAgencyUserRoleForm.class)
private String staffId;
}

1
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/RecordListFormDTO.java

@ -20,7 +20,6 @@ public class RecordListFormDTO implements Serializable {
@NotBlank(message = "staffId不能为空",groups = RecordListForm.class)
private String staffId;
@NotBlank(message = "网格ID不能为空",groups = RecordListForm.class)
private String gridId;
}

42
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RepairStaffRoleCacheResultDTO.java

@ -0,0 +1,42 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/6/15 5:49 下午
* @DESC
*/
@Data
public class RepairStaffRoleCacheResultDTO implements Serializable {
private static final long serialVersionUID = 1220784037854283625L;
/**
* 角色key
*/
private String roleKey;
/**
* 角色value
*/
private String roleName;
/**
* 组织ID
*/
private String orgId;
/**
* 工作人员ID
*/
private String staffId;
/**
* 客户ID
*/
private String customerId;
}

24
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoleKeyValueResultDTO.java

@ -0,0 +1,24 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/6/15 2:31 下午
* @DESC
*/
@Data
public class RoleKeyValueResultDTO implements Serializable {
private static final long serialVersionUID = 6511646803043360335L;
private String roleKey;
private String roleName;
private String orgId;
private String staffId;
}

9
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -566,4 +566,13 @@ public interface EpmetUserOpenFeignClient {
*/
@PostMapping("/epmetuser/staffpatrol/patroltrack")
Result<List<PatrolTrackResultDTO>> patrolTrack(@RequestBody PatrolTrackFormDTO formDTO);
/**
* @Description 查询角色
* @Param formDTO
* @author zxc
* @date 2021/6/15 3:03 下午
*/
@PostMapping("/epmetuser/staffrole/getroles")
Result<CustomerAgencyUserRoleDTO> getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO);
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

@ -394,4 +394,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "patrolTrack", formDTO);
}
@Override
public Result<CustomerAgencyUserRoleDTO> getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserRoles", formDTO);
}
}

25
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.epmet.commons.mybatis.entity.DataScope;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.CustomerAgencyUserRoleDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.CommonUserFormDTO;
@ -189,4 +190,28 @@ public class StaffRoleController {
public Result<List<GridStaffResultDTO>> staffGridRole(@RequestBody List<GridStaffResultDTO> forms){
return new Result<List<GridStaffResultDTO>>().ok(staffRoleService.staffGridRole(forms));
}
/**
* @Description 补全缓存 工作人员角色
* @Param
* @author zxc
* @date 2021/6/15 2:05 下午
*/
@PostMapping("repairstaffrolecache")
public Result repairStaffRoleCache(){
staffRoleService.repairStaffRoleCache();
return new Result();
}
/**
* @Description 查询角色
* @Param formDTO
* @author zxc
* @date 2021/6/15 3:03 下午
*/
@PostMapping("getroles")
public Result<CustomerAgencyUserRoleDTO> getUserRoles(@RequestBody CustomerAgencyUserRoleFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, CustomerAgencyUserRoleFormDTO.CustomerAgencyUserRoleForm.class);
return new Result<CustomerAgencyUserRoleDTO>().ok(staffRoleService.getUserRoles(formDTO));
}
}

9
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.RoleInfoResultDTO;
import com.epmet.dto.result.RoleKeyValueResultDTO;
import com.epmet.dto.result.RoleResultDTO;
import com.epmet.entity.GovStaffRoleEntity;
import org.apache.ibatis.annotations.Mapper;
@ -79,4 +80,12 @@ public interface GovStaffRoleDao extends BaseDao<GovStaffRoleEntity> {
List<GovStaffRoleResultDTO> listRolesByRoleKey(@Param("roleKey") String roleKey);
Integer countRolesByCustomerId(@Param("customerId") String customerId);
/**
* @Description 查询role key name
* @Param roleIds
* @author zxc
* @date 2021/6/15 2:35 下午
*/
List<RoleKeyValueResultDTO> selectRoleKeyName(@Param("roleIds")List<String> roleIds);
}

16
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java

@ -136,4 +136,20 @@ public interface StaffRoleDao extends BaseDao<StaffRoleEntity> {
* @date 2021/6/8 4:53 下午
*/
List<GridStaffResultDTO> staffGridRole(@Param("forms") List<GridStaffResultDTO> forms);
/**
* @Description 查询角色
* @Param userIds
* @author zxc
* @date 2021/6/15 3:51 下午
*/
List<RoleKeyValueResultDTO> getRolesByDB(@Param("userId")String userId);
/**
* @Description 查询所有用户角色
* @Param
* @author zxc
* @date 2021/6/15 5:54 下午
*/
List<RepairStaffRoleCacheResultDTO> selectAllUserRoles();
}

39
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java

@ -17,10 +17,17 @@
package com.epmet.redis;
import cn.hutool.core.bean.BeanUtil;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dto.CustomerAgencyUserRoleDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
import static com.epmet.commons.tools.redis.RedisUtils.NOT_EXPIRE;
/**
* 工作人员-角色关系表
*
@ -44,4 +51,36 @@ public class StaffRoleRedis {
return null;
}
/**
* @Description 查询工作人员的角色
* @Param customerId
* @Param userId
* @author zxc
* @date 2021/6/15 3:20 下午
*/
public CustomerAgencyUserRoleDTO getRole(String customerId, String userId){
String key = "epmet:staffrole:"+customerId+":"+userId;
Map<String, Object> roleMap = redisUtils.hGetAll(key);
boolean empty = roleMap.isEmpty();
if (!empty){
CustomerAgencyUserRoleDTO result = ConvertUtils.mapToEntity(roleMap, CustomerAgencyUserRoleDTO.class);
return result;
}
return null;
}
/**
* @Description 放入缓存角色
* @Param customerId
* @Param userId
* @Param dto
* @author zxc
* @date 2021/6/15 4:01 下午
*/
public void setRole(String customerId,String userId,CustomerAgencyUserRoleDTO dto){
String key = "epmet:staffrole:"+customerId+":"+userId;
Map<String, Object> map = BeanUtil.beanToMap(dto, false, true);
redisUtils.hMSet(key, map,NOT_EXPIRE);
}
}

18
epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java

@ -21,8 +21,10 @@ import com.epmet.commons.mybatis.entity.DataScope;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyUserRoleDTO;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.CustomerAgencyUserRoleFormDTO;
import com.epmet.dto.form.CustomerStaffRoleListFormDTO;
import com.epmet.dto.form.RolesUsersListFormDTO;
import com.epmet.dto.result.*;
@ -164,4 +166,20 @@ public interface StaffRoleService extends BaseService<StaffRoleEntity> {
* @date 2021/6/8 4:42 下午
*/
List<GridStaffResultDTO> staffGridRole(List<GridStaffResultDTO> forms);
/**
* @Description 查询角色
* @Param formDTO
* @author zxc
* @date 2021/6/15 3:03 下午
*/
CustomerAgencyUserRoleDTO getUserRoles(CustomerAgencyUserRoleFormDTO formDTO);
/**
* @Description 补全缓存 工作人员角色
* @Param
* @author zxc
* @date 2021/6/15 2:05 下午
*/
void repairStaffRoleCache();
}

32
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -51,6 +51,7 @@ import com.epmet.feign.AuthFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.redis.CustomerStaffRedis;
import com.epmet.redis.StaffRoleRedis;
import com.epmet.service.CustomerStaffService;
import com.epmet.service.GovStaffRoleService;
import com.epmet.service.StaffRoleService;
@ -66,10 +67,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -104,6 +102,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
private GovStaffRoleDao govStaffRoleDao;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private StaffRoleRedis staffRoleRedis;
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
@ -327,6 +327,18 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
staffRoleService.insert(staffRoleEntity);
});
// 角色放缓存
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
dto.setCustomerId(fromDTO.getCustomerId());
dto.setStaffId(userEntity.getId());
dto.setAgencyId(fromDTO.getAgencyId());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(),r.getRoleName());
});
dto.setRoles(m);
staffRoleRedis.setRole(dto.getCustomerId(), dto.getStaffId(),dto);
return new Result<CustomerStaffDTO>().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class));
}
@ -388,6 +400,18 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
logger.error("修改用户信息:修改用户已缓存的角色列表异常:{}", ExceptionUtils.getErrorStackTrace(e));;
}
// 角色放缓存
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
dto.setCustomerId(fromDTO.getCustomerId());
dto.setStaffId(fromDTO.getStaffId());
dto.setAgencyId(fromDTO.getAgencyId());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(),r.getRoleName());
});
dto.setRoles(m);
staffRoleRedis.setRole(dto.getCustomerId(), dto.getStaffId(),dto);
return new Result();
}

8
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java

@ -6,6 +6,7 @@ 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.ErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.DateUtils;
@ -34,6 +35,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -187,9 +189,11 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImpl<StaffPatrolRec
throw new RenException("巡查记录不存在");
}
if (PatrolConstant.END.equals(record.getStatus())) {
throw new RenException("巡查已结束,请勿重复提交");
throw new RenException(EpmetErrorCode.PATROL_REPEATED_SUBMIT_ERROR.getCode());
}
if (record.getPatrolStartTime().compareTo(Objects.requireNonNull(DateUtils.parse(formDTO.getPatrolEndTime(), DateUtils.DATE_TIME_PATTERN))) > 0) {
throw new RenException(EpmetErrorCode.PATROL_END_TIME_ERROR.getCode());
}
record.setActrualEndTime(new Date());
record.setUpdatedTime(null);
record.setPatrolEndTime(DateUtils.parse(formDTO.getPatrolEndTime(), DateUtils.DATE_TIME_PATTERN));

71
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java

@ -17,6 +17,8 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.entity.DataScope;
@ -28,8 +30,10 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.GovStaffRoleTemplateDao;
import com.epmet.dao.StaffRoleDao;
import com.epmet.dto.CustomerAgencyUserRoleDTO;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.CustomerAgencyUserRoleFormDTO;
import com.epmet.dto.form.CustomerStaffRoleListFormDTO;
import com.epmet.dto.form.RolesUsersListFormDTO;
import com.epmet.dto.result.*;
@ -42,10 +46,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* 工作人员-角色关系表
@ -204,4 +206,65 @@ public class StaffRoleServiceImpl extends BaseServiceImpl<StaffRoleDao, StaffRol
return result;
}
/**
* @Description 查询角色
* @Param formDTO
* @author zxc
* @date 2021/6/15 3:03 下午
*/
@Override
public CustomerAgencyUserRoleDTO getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) {
String staffId = formDTO.getStaffId();
String customerId = formDTO.getCustomerId();
CustomerAgencyUserRoleDTO role = staffRoleRedis.getRole(customerId, staffId);
if (null != role){
return role;
}else {
List<RoleKeyValueResultDTO> rolesByDB = baseDao.getRolesByDB(staffId);
if (!CollectionUtils.isEmpty(rolesByDB)) {
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
dto.setStaffId(rolesByDB.get(NumConstant.ZERO).getStaffId());
dto.setCustomerId(customerId);
dto.setAgencyId(rolesByDB.get(NumConstant.ZERO).getOrgId());
Map map = new HashMap(16);
rolesByDB.forEach(l -> {
map.put(l.getRoleKey(), l.getRoleName());
});
dto.setRoles(map);
staffRoleRedis.setRole(customerId, staffId, dto);
return dto;
}
}
return null;
}
/**
* @Description 补全缓存 工作人员角色
* @Param
* @author zxc
* @date 2021/6/15 2:05 下午
*/
@Override
public void repairStaffRoleCache() {
// 查询所有工作人员的角色
List<RepairStaffRoleCacheResultDTO> allRoles = baseDao.selectAllUserRoles();
if (!CollectionUtils.isEmpty(allRoles)){
// 根据 userId分组【staffId】
Map<String, List<RepairStaffRoleCacheResultDTO>> groupByStaff = allRoles.stream().collect(Collectors.groupingBy(RepairStaffRoleCacheResultDTO::getStaffId));
groupByStaff.forEach((userId,list) -> {
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
String customerId = list.get(NumConstant.ZERO).getCustomerId();
dto.setStaffId(list.get(NumConstant.ZERO).getStaffId());
dto.setCustomerId(customerId);
dto.setAgencyId(list.get(NumConstant.ZERO).getOrgId());
Map map = new HashMap(16);
list.forEach(l -> {
map.put(l.getRoleKey(), l.getRoleName());
});
dto.setRoles(map);
staffRoleRedis.setRole(customerId, userId, dto);
});
}
}
}

16
epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

@ -117,4 +117,20 @@
from gov_staff_role
where CUSTOMER_ID = #{customerId}
</select>
<!-- 查询role key 和 name -->
<select id="selectRoleKeyName" resultType="com.epmet.dto.result.RoleKeyValueResultDTO">
SELECT
ROLE_KEY,
ROLE_NAME
FROM
gov_staff_role
WHERE
DEL_FLAG = 0
AND (
<foreach collection="roleIds" item="roleId" separator=" OR ">
ID = #{roleId}
</foreach>
)
</select>
</mapper>

8
epmet-user/epmet-user-server/src/main/resources/mapper/StaffPatrolRecordDao.xml

@ -29,12 +29,14 @@
<select id="recordList" resultType="com.epmet.dto.result.RecordListResultDTO">
SELECT
ID AS staffPatrolRecId,
DATE_FORMAT(PATROL_START_TIME,'%Y-%m-%d %H:%i:%s') AS patrolStartTime,
DATE_FORMAT(PATROL_END_TIME,'%Y-%m-%d %H:%i:%s') AS patrolEndTime,
IFNULL(DATE_FORMAT(PATROL_START_TIME,'%Y-%m-%d %H:%i:%s'),'') AS patrolStartTime,
IFNULL(DATE_FORMAT(PATROL_END_TIME,'%Y-%m-%d %H:%i:%s'),'') AS patrolEndTime,
`STATUS`
FROM staff_patrol_record
WHERE DEL_FLAG = 0
AND GRID = #{gridId}
<if test="gridId != '' and gridId != null ">
AND GRID = #{gridId}
</if>
AND STAFF_ID = #{staffId}
ORDER BY CREATED_TIME DESC
</select>

26
epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

@ -207,4 +207,30 @@
AND sr.STAFF_ID = #{s.staffId}
</foreach>
</select>
<!-- 查询角色 -->
<select id="getRolesByDB" resultType="com.epmet.dto.result.RoleKeyValueResultDTO">
SELECT
sr.ORG_ID,
gsr.ROLE_KEY,
gsr.ROLE_NAME,
sr.STAFF_ID
FROM staff_role sr
LEFT JOIN gov_staff_role gsr ON gsr.ID = sr.ROLE_ID AND gsr.DEL_FLAG = 0
WHERE sr.DEL_FLAG = 0
AND sr.STAFF_ID = #{userId}
</select>
<!-- 查询所有用户角色 -->
<select id="selectAllUserRoles" resultType="com.epmet.dto.result.RepairStaffRoleCacheResultDTO">
SELECT
sr.ORG_ID,
sr.CUSTOMER_ID,
gsr.ROLE_KEY,
gsr.ROLE_NAME,
sr.STAFF_ID
FROM staff_role sr
LEFT JOIN gov_staff_role gsr ON gsr.ID = sr.ROLE_ID AND gsr.DEL_FLAG = 0
WHERE sr.DEL_FLAG = 0
</select>
</mapper>

Loading…
Cancel
Save