|
|
@ -21,6 +21,7 @@ import com.epmet.commons.tools.exception.ValidateException; |
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
@ -127,7 +128,8 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<WorkdiaryServiceRecordDTO> page(String gridId, Short serviceType, String applicantName, String applicantAddress, |
|
|
|
String serviceContent, String applicantMobile, Integer pageNo, Integer pageSize) { |
|
|
|
String serviceContent, String applicantMobile, Date serviceTimeStart, Date serviceTimeEnd, |
|
|
|
Integer pageNo, Integer pageSize) { |
|
|
|
|
|
|
|
LoginUserDetailsResultDTO currentStaff = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails(new LoginUserDetailsFormDTO( |
|
|
|
EpmetRequestHolder.getLoginUserApp(), EpmetRequestHolder.getLoginUserClient(), EpmetRequestHolder.getLoginUserId() |
|
|
@ -142,6 +144,13 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
query.like(StringUtils.isNotBlank(applicantMobile), WorkdiaryServiceRecordEntity::getApplicantMobile, applicantMobile); |
|
|
|
query.likeRight(WorkdiaryServiceRecordEntity::getOrgIdPath, currentStaff.getOrgIdPath()); |
|
|
|
|
|
|
|
// 服务时间查询,两端包含,闭区间
|
|
|
|
query.ge(serviceTimeStart != null, WorkdiaryServiceRecordEntity::getServiceTime, serviceTimeStart); |
|
|
|
query.le(serviceTimeStart != null, WorkdiaryServiceRecordEntity::getServiceTime, serviceTimeEnd); |
|
|
|
|
|
|
|
// 创建时间倒序
|
|
|
|
query.orderByDesc(WorkdiaryServiceRecordEntity::getCreatedTime); |
|
|
|
|
|
|
|
// 查找类型列表
|
|
|
|
List<WorkdiaryServiceTypeDTO> stList = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(null, 1, 100); |
|
|
|
Map<Short, String> stMap = stList.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); |
|
|
@ -182,12 +191,28 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
public void save(WorkdiaryServiceRecordDTO dto) { |
|
|
|
WorkdiaryServiceRecordEntity entity = ConvertUtils.sourceToTarget(dto, WorkdiaryServiceRecordEntity.class); |
|
|
|
|
|
|
|
// orgidPath
|
|
|
|
Optional.ofNullable(CustomerOrgRedis.getGridInfo(dto.getGridId())) |
|
|
|
.ifPresent(gi -> { |
|
|
|
entity.setOrgIdPath(gi.getPids().concat(":").concat(gi.getId())); |
|
|
|
entity.setAgencyId(gi.getPid()); |
|
|
|
}); |
|
|
|
LoginUserDetailsResultDTO currentStaff = getResultDataOrThrowsException(userOpenFeignClient.getLoginUserDetails(new LoginUserDetailsFormDTO( |
|
|
|
EpmetRequestHolder.getLoginUserApp(), EpmetRequestHolder.getLoginUserClient(), EpmetRequestHolder.getLoginUserId() |
|
|
|
)), ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "查询工作人员信息失败", "查询工作人员信息失败"); |
|
|
|
|
|
|
|
String staffOrgIdPath = currentStaff.getOrgIdPath(); |
|
|
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(dto.getGridId()); |
|
|
|
|
|
|
|
if (gridInfo == null) { |
|
|
|
// 说明网格是其他组织下的
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "网格未找到", "网格未找到"); |
|
|
|
} |
|
|
|
|
|
|
|
String gridOrgIdPath = gridInfo.getPids().concat(":").concat(gridInfo.getId()); |
|
|
|
|
|
|
|
if (!gridOrgIdPath.contains(staffOrgIdPath)) { |
|
|
|
// 说明网格是其他组织下的
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所选网格不在您所属组织下", "所选网格不在您所属组织下"); |
|
|
|
} |
|
|
|
|
|
|
|
entity.setOrgIdPath(gridOrgIdPath); |
|
|
|
entity.setAgencyId(gridInfo.getPid()); |
|
|
|
|
|
|
|
IcResiUserDTO applicant = getResultDataOrThrowsException(userOpenFeignClient.getIcResiUserDTO(dto.getApplicantId()), ServiceConstant.EPMET_USER_SERVER, |
|
|
|
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到申请人信息"); |
|
|
@ -215,6 +240,7 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
entity.setPrincipalName(dto.getPrincipalName()); |
|
|
|
entity.setServiceTime(dto.getServiceTime()); |
|
|
|
entity.setRemark(dto.getRemark()); |
|
|
|
//entity.setApplicantIdCard(dto.getApplicantIdCard());
|
|
|
|
|
|
|
|
// orgidPath
|
|
|
|
if (StringUtils.isNotBlank(dto.getGridId())) { |
|
|
@ -261,7 +287,7 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
|
|
|
|
@Override |
|
|
|
public void export(String gridId, Short serviceType, String applicantName, String applicantAddress, |
|
|
|
String serviceContent, String applicantMobile, HttpServletResponse response) { |
|
|
|
String serviceContent, String applicantMobile, Date serviceTimeStart, Date serviceTimeEnd, HttpServletResponse response) { |
|
|
|
|
|
|
|
ExcelWriter writer; |
|
|
|
try { |
|
|
@ -280,7 +306,9 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
//一次500条,分批导出
|
|
|
|
int pageSize = 500; |
|
|
|
for (int pageNo = 1; ; pageNo++) { |
|
|
|
PageData<WorkdiaryServiceRecordDTO> page = this.page(gridId, serviceType, applicantName, applicantAddress, serviceContent, applicantMobile, pageNo, pageSize); |
|
|
|
PageData<WorkdiaryServiceRecordDTO> page = this.page(gridId, serviceType, applicantName, applicantAddress, serviceContent, |
|
|
|
applicantMobile, serviceTimeStart, serviceTimeEnd, pageNo, pageSize); |
|
|
|
|
|
|
|
List<WorkdiaryServiceRecordDTO> list = page.getList(); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
// 空的,导出结束
|
|
|
@ -437,9 +465,21 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
row.setApplicantAddress(house.getFullName()); |
|
|
|
} |
|
|
|
// 填充到entity
|
|
|
|
WorkdiaryServiceRecordEntity record = new WorkdiaryServiceRecordEntity(EpmetRequestHolder.getLoginUserCustomerId(), serviceType.getServiceType(), currentStaff.getAgencyId(), |
|
|
|
grid.getValue(), currentStaff.getOrgIdPath().concat(":").concat(grid.getValue()), resi.getId(), row.getApplicantName(), |
|
|
|
row.getApplicantAddress(), row.getApplicantMobile(), row.getServiceContent(), row.getServiceTime(), row.getPrincipal(), row.getRemark()); |
|
|
|
WorkdiaryServiceRecordEntity record = new WorkdiaryServiceRecordEntity( |
|
|
|
EpmetRequestHolder.getLoginUserCustomerId(), |
|
|
|
serviceType.getServiceType(), |
|
|
|
currentStaff.getAgencyId(), |
|
|
|
grid.getValue(), |
|
|
|
currentStaff.getOrgIdPath().concat(":").concat(grid.getValue()), |
|
|
|
resi.getId(), |
|
|
|
row.getApplicantIdCard(), |
|
|
|
row.getApplicantName(), |
|
|
|
row.getApplicantAddress(), |
|
|
|
row.getApplicantMobile(), |
|
|
|
row.getServiceContent(), |
|
|
|
row.getServiceTime(), |
|
|
|
row.getPrincipal(), |
|
|
|
row.getRemark()); |
|
|
|
|
|
|
|
diaryRecordList.add(record); |
|
|
|
} catch (ValidateException ve) { |
|
|
|