|
|
@ -1,16 +1,32 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
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.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
|
|
import com.epmet.dao.WorkdiaryServiceRecordDao; |
|
|
|
import com.epmet.dao.WorkdiaryServiceTypeDao; |
|
|
|
import com.epmet.dto.IcResiUserDTO; |
|
|
|
import com.epmet.dto.WorkdiaryServiceTypeDTO; |
|
|
|
import com.epmet.dto.result.WorkdiaryServiceRecordDTO; |
|
|
|
import com.epmet.entity.WorkdiaryServiceRecordEntity; |
|
|
|
import com.epmet.entity.WorkdiaryServiceTypeEntity; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.redis.WorkdiaryServiceRecordRedis; |
|
|
|
import com.epmet.service.WorkdiaryServiceRecordService; |
|
|
|
import com.epmet.service.WorkdiaryServiceTypeService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -19,6 +35,8 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 工作日志(服务)-记录 |
|
|
@ -27,11 +45,17 @@ import java.util.Map; |
|
|
|
* @since v1.0.0 2022-08-23 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<WorkdiaryServiceRecordDao, WorkdiaryServiceRecordEntity> implements WorkdiaryServiceRecordService { |
|
|
|
public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<WorkdiaryServiceRecordDao, WorkdiaryServiceRecordEntity> implements WorkdiaryServiceRecordService, ResultDataResolver { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WorkdiaryServiceRecordRedis workdiaryServiceRecordRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WorkdiaryServiceTypeDao workdiaryServiceTypeDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient userOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<WorkdiaryServiceRecordDTO> page(Map<String, Object> params) { |
|
|
|
IPage<WorkdiaryServiceRecordEntity> page = baseDao.selectPage( |
|
|
@ -41,6 +65,31 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
return getPageData(page, WorkdiaryServiceRecordDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<WorkdiaryServiceRecordDTO> page(String gridId, Short serviceType, String applicantName, String applicantAddress, |
|
|
|
String serviceContent, String applicantMobile, Integer pageNo, Integer pageSize) { |
|
|
|
|
|
|
|
LambdaQueryWrapper<WorkdiaryServiceRecordEntity> query = new LambdaQueryWrapper<>(); |
|
|
|
query.eq(StringUtils.isNotBlank(gridId), WorkdiaryServiceRecordEntity::getGridId, gridId); |
|
|
|
query.eq(serviceType != null, WorkdiaryServiceRecordEntity::getServiceType, serviceType); |
|
|
|
query.like(StringUtils.isNotBlank(applicantName), WorkdiaryServiceRecordEntity::getApplicantName, applicantName); |
|
|
|
query.like(StringUtils.isNotBlank(applicantAddress), WorkdiaryServiceRecordEntity::getApplicantAddress, applicantAddress); |
|
|
|
query.like(StringUtils.isNotBlank(serviceContent), WorkdiaryServiceRecordEntity::getServiceContent, serviceContent); |
|
|
|
query.like(StringUtils.isNotBlank(applicantMobile), WorkdiaryServiceRecordEntity::getApplicantMobile, applicantMobile); |
|
|
|
|
|
|
|
// 查找类型列表
|
|
|
|
List<WorkdiaryServiceTypeDTO> stList = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(1, 100); |
|
|
|
Map<Short, String> stMap = stList.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); |
|
|
|
|
|
|
|
// 查找服务记录
|
|
|
|
PageHelper.startPage(pageNo, pageSize); |
|
|
|
List<WorkdiaryServiceRecordDTO> list = baseDao.selectList(query) |
|
|
|
.stream() |
|
|
|
.map(e -> convertEntity2DTO(e, stMap)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
return new PageData<>(list, new PageInfo<>(list).getTotal(), pageSize); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<WorkdiaryServiceRecordDTO> list(Map<String, Object> params) { |
|
|
|
List<WorkdiaryServiceRecordEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
@ -60,13 +109,24 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
@Override |
|
|
|
public WorkdiaryServiceRecordDTO get(String id) { |
|
|
|
WorkdiaryServiceRecordEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, WorkdiaryServiceRecordDTO.class); |
|
|
|
return convertEntity2DTO(entity, null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
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()))); |
|
|
|
|
|
|
|
IcResiUserDTO applicant = getResultDataOrThrowsException(userOpenFeignClient.getIcResiUserDTO(dto.getApplicantId()), ServiceConstant.EPMET_USER_SERVER, |
|
|
|
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到申请人信息"); |
|
|
|
|
|
|
|
if (applicant != null) { |
|
|
|
entity.setApplicantName(applicant.getName()); |
|
|
|
} |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
@ -84,4 +144,18 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl<Workdiary |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
private WorkdiaryServiceRecordDTO convertEntity2DTO(WorkdiaryServiceRecordEntity entity, Map<Short, String> stMap) { |
|
|
|
|
|
|
|
if (stMap == null || stMap.size() == 0) { |
|
|
|
// 查找类型列表
|
|
|
|
List<WorkdiaryServiceTypeDTO> list = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(1, 100); |
|
|
|
stMap = list.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); |
|
|
|
} |
|
|
|
|
|
|
|
WorkdiaryServiceRecordDTO d = ConvertUtils.sourceToTarget(entity, WorkdiaryServiceRecordDTO.class); |
|
|
|
Optional.ofNullable(CustomerOrgRedis.getGridInfo(entity.getGridId())).ifPresent((gridInfo) -> d.setGridName(gridInfo.getAgencyName() + gridInfo.getGridName())); |
|
|
|
d.setServiceTypeName(stMap.get(entity.getServiceType())); |
|
|
|
return d; |
|
|
|
} |
|
|
|
|
|
|
|
} |