Browse Source

Merge remote-tracking branch 'remotes/origin/dev_bugfix_ljj' into 烟台master

dev
jianjun 3 years ago
parent
commit
35847b0576
  1. 7
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  3. 60
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java
  4. 1
      epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.43__alter_work_log.sql
  5. 14
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  6. 36
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

7
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -849,4 +849,11 @@ public class RedisKeys {
public static String getServiceOrgNameKey(String customerId,String serviceOrgType,String serviceOrgId){
return rootPrefix.concat("serviceOrgName:").concat(serviceOrgType).concat(":").concat(customerId).concat(":").concat(serviceOrgId);
}
public static String getUserBaseInfoKey(String userId) {
if (StringUtils.isBlank(userId)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误");
}
return rootPrefix.concat("staffbaseinfo:")+userId;
}
}

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -376,5 +376,13 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
CustomerAgencyEntity getAreaRootAgency(@Param("customerId") String customerId);
/**
* @Description 根据人查询所在组织
* @Param userId
* @author zhy
* @date 2021/8/5 10:08 上午
*/
CustomerAgencyEntity getAgencyByUserId(@Param("userId") String userId, @Param("customerId") String customerId);
}

60
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java

@ -12,6 +12,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dao.CustomerGridDao;
import com.epmet.dao.IcWorkLogDao;
import com.epmet.dto.CustomerStaffDTO;
@ -19,6 +20,8 @@ import com.epmet.dto.IcWorkLogDTO;
import com.epmet.dto.IcWorkLogFileDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.result.GridDetailResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerGridEntity;
import com.epmet.entity.IcWorkLogEntity;
import com.epmet.entity.IcWorkLogFileEntity;
import com.epmet.feign.EpmetAdminOpenFeignClient;
@ -64,6 +67,9 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl<IcWorkLogDao, IcWorkLo
@Resource
private CustomerGridDao customerGridDao;
@Resource
private CustomerAgencyDao customerAgencyDao;
@Override
public PageData<IcWorkLogDTO> page(Map<String, Object> params) {
@ -110,6 +116,11 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl<IcWorkLogDao, IcWorkLo
public IcWorkLogDTO get(String id) {
IcWorkLogEntity entity = baseDao.selectById(id);
IcWorkLogDTO dto = ConvertUtils.sourceToTarget(entity, IcWorkLogDTO.class);
if (StringUtils.isNotBlank(entity.getGridId())) {
CustomerGridEntity grid = customerGridDao.selectById(entity.getGridId());
dto.setGridName(grid.getGridName());
}
Map<String, Object> params = new HashMap<>(2);
params.put("logId", id);
List<IcWorkLogFileDTO> files = icWorkLogFileService.list(params);
@ -132,14 +143,9 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl<IcWorkLogDao, IcWorkLo
dto.setCreatedUser(staffInfo.getData().getRealName());
dto.setMobile(staffInfo.getData().getMobile());
}
// 查询网格信息
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO();
customerGridFormDTO.setGridId(dto.getGridId());
GridDetailResultDTO gridDetailResultDTO = customerGridDao.griddetail(customerGridFormDTO);
if (gridDetailResultDTO != null) {
dto.setAgencyId(gridDetailResultDTO.getAgencyId());
dto.setPids(gridDetailResultDTO.getPIds());
}
// 组织机构处理
orgHandle(dto);
IcWorkLogEntity entity = ConvertUtils.sourceToTarget(dto, IcWorkLogEntity.class);
insert(entity);
@ -150,14 +156,9 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl<IcWorkLogDao, IcWorkLo
@Override
@Transactional(rollbackFor = Exception.class)
public void update(IcWorkLogDTO dto) {
// 查询网格信息
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO();
customerGridFormDTO.setGridId(dto.getGridId());
GridDetailResultDTO gridDetailResultDTO = customerGridDao.griddetail(customerGridFormDTO);
if (gridDetailResultDTO != null) {
dto.setAgencyId(gridDetailResultDTO.getAgencyId());
dto.setPids(gridDetailResultDTO.getPIds());
}
// 组织机构处理
orgHandle(dto);
IcWorkLogEntity entity = ConvertUtils.sourceToTarget(dto, IcWorkLogEntity.class);
updateById(entity);
@ -195,4 +196,31 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl<IcWorkLogDao, IcWorkLo
}
}
/**
* 组织机构处理
*
* @param dto
* @return
* @author zhy
* @date 2022/8/12 17:30
*/
private void orgHandle(IcWorkLogDTO dto) {
if (StringUtils.isNotBlank(dto.getGridId())) {
// 查询网格信息
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO();
customerGridFormDTO.setGridId(dto.getGridId());
GridDetailResultDTO gridDetailResultDTO = customerGridDao.griddetail(customerGridFormDTO);
if (gridDetailResultDTO != null) {
dto.setAgencyId(gridDetailResultDTO.getAgencyId());
dto.setPids(gridDetailResultDTO.getPIds());
}
} else {
CustomerAgencyEntity agency = customerAgencyDao.getAgencyByUserId(loginUserUtil.getLoginUserId(), loginUserUtil.getLoginUserCustomerId());
if (agency != null) {
dto.setAgencyId(agency.getId());
dto.setPids(agency.getPids());
}
}
}
}

1
epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.43__alter_work_log.sql

@ -0,0 +1 @@
ALTER TABLE epmet_gov_org.ic_work_log MODIFY COLUMN GRID_ID varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '网格Id【场所区域】';

14
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -982,4 +982,18 @@
</if>
</select>
<!-- 根据人查询所在组织 -->
<select id="getAgencyByUserId" resultType="com.epmet.entity.CustomerAgencyEntity">
SELECT
a.*
FROM
customer_staff_agency sa
LEFT JOIN customer_agency a ON sa.AGENCY_ID = a.ID
WHERE
sa.del_flag = '0'
AND a.DEL_FLAG = '0'
AND sa.USER_ID = #{userId} AND sa.CUSTOMER_ID = #{customerId} AND a.CUSTOMER_ID = #{customerId}
LIMIT 1
</select>
</mapper>

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

@ -29,6 +29,8 @@ import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
@ -60,16 +62,16 @@ import com.epmet.service.UserService;
import com.epmet.util.ModuleConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
/**
@ -100,6 +102,10 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private GovAccessFeignClient govAccessFeignClient;
@Autowired
private ExecutorService executorService;
@Autowired
private RedisUtils redisUtils;
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
@ -739,7 +745,28 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
@Override
public Result<StaffBasicInfoResultDTO> selectStaffBasicInfo(String userId, String customerId) {
StaffBasicInfoResultDTO resultDTO = baseDao.selectStaffBasicInfo(userId);
StaffBasicInfoResultDTO resultDTO = null;
String userBaseInfoKey = RedisKeys.getUserBaseInfoKey(userId);
resultDTO = (StaffBasicInfoResultDTO)redisUtils.get(userBaseInfoKey);
if(resultDTO == null){
resultDTO = getStaffBasicInfoResultDTO(userId, customerId, userBaseInfoKey);
}
//启用线程去查询 并替换redis
executorService.submit(() -> {
try {
getStaffBasicInfoResultDTO(userId, customerId, userBaseInfoKey);
} catch (Exception e) {
log.error("selectStaffBasicInfo exception", e);
}
});
return new Result<StaffBasicInfoResultDTO>().ok(resultDTO);
}
@Nullable
private StaffBasicInfoResultDTO getStaffBasicInfoResultDTO(String userId, String customerId, String userBaseInfoKey) {
StaffBasicInfoResultDTO resultDTO;
resultDTO = baseDao.selectStaffBasicInfo(userId);
if (null != resultDTO) {
resultDTO.setRoleList(baseDao.selectStaffRoles(userId, resultDTO.getCustomerId()));
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId);
@ -767,7 +794,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
resultDTO.setCustomerName(customerResult.getData().getCustomerName());
}
}
return new Result<StaffBasicInfoResultDTO>().ok(resultDTO);
redisUtils.set(userBaseInfoKey,resultDTO);
return resultDTO;
}
/**

Loading…
Cancel
Save