|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
@ -31,10 +32,12 @@ import com.epmet.dto.result.StaffGridResultDTO; |
|
|
import com.epmet.feign.*; |
|
|
import com.epmet.feign.*; |
|
|
import com.epmet.service.StaffAgencyService; |
|
|
import com.epmet.service.StaffAgencyService; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -214,30 +217,59 @@ public class StaffAgencyServiceImpl implements StaffAgencyService { |
|
|
**/ |
|
|
**/ |
|
|
@Override |
|
|
@Override |
|
|
public Result<CustomerGridByUserIdResultDTO> getLatestGrid(LatestGridFormDTO latestGridFormDTO) { |
|
|
public Result<CustomerGridByUserIdResultDTO> getLatestGrid(LatestGridFormDTO latestGridFormDTO) { |
|
|
Result<CustomerGridByUserIdResultDTO> latestGridResult = |
|
|
//首先获取该员工的网格列表 如果为空则直接返回
|
|
|
epmetUserFeignClient.getStaffLatestGrid(latestGridFormDTO); |
|
|
Result<List<CustomerGridByUserIdResultDTO>> staffGridListResult = govOrgFeignClient.getMyGrids(latestGridFormDTO.getStaffId()); |
|
|
|
|
|
if (staffGridListResult == null || !staffGridListResult.success() || CollectionUtils.isEmpty(staffGridListResult.getData())){ |
|
|
|
|
|
logger.warn("getLatestGrid method getMyGrids return null,param:{}", JSON.toJSONString(latestGridFormDTO)); |
|
|
|
|
|
return new Result<>(); |
|
|
|
|
|
} |
|
|
|
|
|
//获取该工作人员的最后访问记录 如果不为空 判断下是否所访问网格有效 无效则取工作人员的任意网格返回并生成记录 否则 直接返回访问记录中的网格
|
|
|
|
|
|
Result<CustomerGridByUserIdResultDTO> latestGridResult = epmetUserFeignClient.getStaffLatestGrid(latestGridFormDTO); |
|
|
if (latestGridResult.success() && null != latestGridResult.getData() && StringUtils.isNotBlank(latestGridResult.getData().getGridId())) { |
|
|
if (latestGridResult.success() && null != latestGridResult.getData() && StringUtils.isNotBlank(latestGridResult.getData().getGridId())) { |
|
|
|
|
|
long count = staffGridListResult.getData().stream().filter(o -> o.getGridId().equals(latestGridResult.getData().getGridId())).count(); |
|
|
|
|
|
//count 如果==0 说明访问记录中的网格已经无效了 则直接查询工作人员最新的网格作为进入的网格
|
|
|
|
|
|
if (count == 0){ |
|
|
|
|
|
Result<CustomerGridByUserIdResultDTO> staffGridResult = getStaffLatestGridAndSaveVisitRecord(latestGridFormDTO); |
|
|
|
|
|
if (staffGridResult != null) { |
|
|
|
|
|
return staffGridResult; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return latestGridResult; |
|
|
return latestGridResult; |
|
|
} else { |
|
|
} else { |
|
|
Result<CustomerGridByUserIdResultDTO> staffGridResult = |
|
|
Result<CustomerGridByUserIdResultDTO> staffGridResult = getStaffLatestGridAndSaveVisitRecord(latestGridFormDTO); |
|
|
govOrgFeignClient.getStaffGrid(latestGridFormDTO); |
|
|
if (staffGridResult != null) { |
|
|
if (staffGridResult.success() && null != staffGridResult.getData() && StringUtils.isNotBlank(staffGridResult.getData().getGridId())) { |
|
|
|
|
|
StaffGridVisitedFormDTO gridRecordParam = new StaffGridVisitedFormDTO(); |
|
|
|
|
|
gridRecordParam.setGridId(staffGridResult.getData().getGridId()); |
|
|
|
|
|
gridRecordParam.setCustomerId(latestGridFormDTO.getCustomerId()); |
|
|
|
|
|
gridRecordParam.setStaffId(latestGridFormDTO.getStaffId()); |
|
|
|
|
|
Result writeRecordResult = epmetUserFeignClient.saveStaffGridVisitedRecord(gridRecordParam); |
|
|
|
|
|
if(writeRecordResult.success()){ |
|
|
|
|
|
logger.warn("com.epmet.service.impl.StaffAgencyServiceImpl.getLatestGrid,工作人员网格访问网格写入失败,staffId:{},gridId:{}",latestGridFormDTO.getStaffId(),staffGridResult.getData().getGridId()); |
|
|
|
|
|
} |
|
|
|
|
|
return staffGridResult; |
|
|
return staffGridResult; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
logger.info(String.format("客户id%s,staffId%s查询最后一次登录网格为空",latestGridFormDTO.getCustomerId(),latestGridFormDTO.getStaffId())); |
|
|
logger.info(String.format("客户id%s,staffId%s查询最后一次登录网格为空",latestGridFormDTO.getCustomerId(),latestGridFormDTO.getStaffId())); |
|
|
//.error(StaffAgencyConstant.QUERY_LATEST_GRID_INFO_FAILED)
|
|
|
|
|
|
return new Result<>(); |
|
|
return new Result<>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* desc: 根据参数获取工作人员最新网格 并生成网格网格记录 |
|
|
|
|
|
* |
|
|
|
|
|
* @param latestGridFormDTO |
|
|
|
|
|
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.CustomerGridByUserIdResultDTO> |
|
|
|
|
|
* @author LiuJanJun |
|
|
|
|
|
* @date 2021/7/27 4:04 下午 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Nullable |
|
|
|
|
|
private Result<CustomerGridByUserIdResultDTO> getStaffLatestGridAndSaveVisitRecord(LatestGridFormDTO latestGridFormDTO) { |
|
|
|
|
|
Result<CustomerGridByUserIdResultDTO> staffGridResult = govOrgFeignClient.getStaffGrid(latestGridFormDTO); |
|
|
|
|
|
if (staffGridResult.success() && null != staffGridResult.getData() && StringUtils.isNotBlank(staffGridResult.getData().getGridId())) { |
|
|
|
|
|
StaffGridVisitedFormDTO gridRecordParam = new StaffGridVisitedFormDTO(); |
|
|
|
|
|
gridRecordParam.setGridId(staffGridResult.getData().getGridId()); |
|
|
|
|
|
gridRecordParam.setCustomerId(latestGridFormDTO.getCustomerId()); |
|
|
|
|
|
gridRecordParam.setStaffId(latestGridFormDTO.getStaffId()); |
|
|
|
|
|
Result writeRecordResult = epmetUserFeignClient.saveStaffGridVisitedRecord(gridRecordParam); |
|
|
|
|
|
if(writeRecordResult.success()){ |
|
|
|
|
|
logger.warn("com.epmet.service.impl.StaffAgencyServiceImpl.getLatestGrid,工作人员网格访问网格写入失败,staffId:{},gridId:{}",latestGridFormDTO.getStaffId(),staffGridResult.getData().getGridId()); |
|
|
|
|
|
} |
|
|
|
|
|
return staffGridResult; |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void switchGrid(SwitchGridFormDTO switchGridFormDTO) { |
|
|
public void switchGrid(SwitchGridFormDTO switchGridFormDTO) { |
|
@ -253,4 +285,4 @@ public class StaffAgencyServiceImpl implements StaffAgencyService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|