long转string mybatis_1.List<Long>转为List<String>

package com.gxhj.safecampus.visit.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.gxhj.commontools.utils.BeanUtils;

import com.gxhj.commontools.utils.CollectionUtils;

import com.gxhj.commontools.utils.ConvertUtils;

import com.gxhj.core.base.service.impl.CommonServiceImpl;

import com.gxhj.core.exception.BusinessException;

import com.gxhj.core.model.PageInfo;

import com.gxhj.safecampus.person.entity.EmployeeInfo;

import com.gxhj.safecampus.person.service.IEmployeeService;

import com.gxhj.safecampus.visit.constant.AccessingInviteStatusType;

import com.gxhj.safecampus.visit.entity.AccessingInviteInfo;

import com.gxhj.safecampus.visit.mapper.AccessingInviteMapper;

import com.gxhj.safecampus.visit.service.IAccessingInviteService;

import com.gxhj.safecampus.visit.service.IAccessingRecordService;

import com.gxhj.safecampus.visit.vo.AccessingInviteInfoVo;

import com.gxhj.usermanage.entity.GroupInfo;

import com.gxhj.usermanage.service.IGroupService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.io.Serializable;

import java.util.ArrayList;

import java.util.List;

import java.util.Map;

import java.util.function.Function;

import java.util.stream.Collectors;

/**

*

* 服务实现类

*

*

* @author ZS

* @since 2020-08-20

*/

@Service

public class AccessingInviteServiceImpl extends CommonServiceImpl implements IAccessingInviteService {

@Autowired

private IAccessingRecordService iAccessingRecordService;

@Autowired

private IEmployeeService employeeService;

@Autowired

private IGroupService groupService;

@Override

public String entityName() {

return "访问邀请";

}

@Override

public AccessingInviteInfo getInfoById(Serializable id) {

AccessingInviteInfo info = super.getById(id);

if (info==null) {

throw new BusinessException(String.format("%s编号对应信息不存在", this.entityName()));

}else {

EmployeeInfo employeeInfo = employeeService.getById(info.getFirstTrialPersonal());

GroupInfo groupInfo = groupService.getById(info.getUnitID());

// 邀请人姓名

info.setFinalMind(employeeInfo.getDepartment());

// 邀请人部门

info.setFirstTrialMind(employeeInfo.getDepartment());

// 邀请人单位

info.setVisitMatter(groupInfo.getName());

return info;

}

}

@Override

public IPage page(AccessingInviteInfoVo queryCondition, PageInfo pageInfo) {

// 10(1,0) 待初审 46(4,6)终审通过

// 构建分页信息

Page page = new Page<>(pageInfo.getPageIndex(), pageInfo.getPageSize());

//查询条件:单位ID 访问对象名 审核状态 起止时间

// 通过对象名获取 对象id

List lstEmployeeIds = null;

if (StringUtils.isNotBlank(queryCondition.getIntervieweesName())) {

lstEmployeeIds = this.employeeService.lambdaQuery().select(EmployeeInfo::getEmployeeId)

.like(EmployeeInfo::getName, queryCondition.getIntervieweesName())

.list()

.stream().map(EmployeeInfo::getEmployeeId).collect(Collectors.toList());

}

LambdaQueryChainWrapper le = super.lambdaQuery()

.eq(queryCondition.getUnitID()!=null, AccessingInviteInfo::getUnitID, queryCondition.getUnitID())

.ge(queryCondition.getStartDate() != null, AccessingInviteInfo::getAccessingTime, queryCondition.getStartDate())

.le(queryCondition.getEndDate() != null, AccessingInviteInfo::getBeOffTime, queryCondition.getEndDate())

.in(CollectionUtils.isNotEmpty(lstEmployeeIds), AccessingInviteInfo::getFirstTrialPersonal, lstEmployeeIds);

Integer status = queryCondition.getStatus();

if (status != null) {

// 待初审

if (status == AccessingInviteStatusType.WAIT_FIRST_TRIAL) {

le = le.and(wrapper -> wrapper.in(AccessingInviteInfo::getStatus, AccessingInviteStatusType.firstTrialStatus()));

}

// 审核通过

else if (status == AccessingInviteStatusType.FINAL_TRIAL_SUCCESS) {

le = le.and(wrapper -> wrapper.in(AccessingInviteInfo::getStatus, AccessingInviteStatusType.finalTrialSuccess()));

} else {

le = le.and(wrapper -> wrapper.in(AccessingInviteInfo::getStatus, status));

}

}

Page pageList = le.orderByDesc(AccessingInviteInfo::getCreateTime).page(page);

// 查询结果处理

if (CollectionUtils.isNotEmpty(pageList.getRecords())) {

// 处理附件预览地址

processListEntityFileUrl(pageList.getRecords());

// 处理结果数据

pageList.setRecords(this.afterQuery(pageList.getRecords()));

}

return pageList;

}

@Override

public List afterQuery(List list) {

// 获取邀请id集合

List lstInviteId = list.stream().map(AccessingInviteInfo::getAccessingInviteID).collect(Collectors.toList());

// 通过邀请id集 合获取对应邀请的 签到人数

Map inviteIDComingNumberMap = this.iAccessingRecordService.selectComingNumber(lstInviteId);

// 通过groupIds获取单位集合

List lstGroupId = list.stream().map(v -> ConvertUtils.parseStr(v.getUnitID())).collect(Collectors.toList());

Map groupInfoMap = this.groupService.lambdaQuery().in(CollectionUtils.isNotEmpty(lstGroupId), GroupInfo::getGroupId, lstGroupId)

.list()

.stream().collect(Collectors.toMap(GroupInfo::getGroupId, Function.identity()));

// 查初审人和邀请人姓名 // 通过对象id集合 邀请对象名

List lstEmployeeId = list.stream().map(e-> ConvertUtils.parseStr(e.getFirstTrialPersonal())).collect(Collectors.toList());

Map employeeInfoMap = this.employeeService.getEmployeeInfoMap(lstEmployeeId);

// 查终审人姓名

List finalTrailEmployee = list.stream().map(e -> ConvertUtils.parseStr(e.getFinalPersonal())).collect(Collectors.toList());

Map finalEmployeeInfoMap = this.employeeService.getEmployeeInfoMap(finalTrailEmployee);

// 遍历列表构造Vo对象

AccessingInviteInfoVo infoVo;

List lstVoInfo = new ArrayList<>(list.size());

GroupInfo defaultGrp = new GroupInfo();

EmployeeInfo defaultEmp = new EmployeeInfo();

GroupInfo findGrp;

EmployeeInfo findEmp;

for (AccessingInviteInfo accessingInviteInfo : list) {

infoVo = new AccessingInviteInfoVo();

// 复制对象信息

BeanUtils.copy(accessingInviteInfo, infoVo);

// 设置签到人数

infoVo.setComingNumber(inviteIDComingNumberMap.getOrDefault(accessingInviteInfo.getAccessingInviteID(), 0));

findEmp = employeeInfoMap.getOrDefault(accessingInviteInfo.getFirstTrialPersonal(), defaultEmp);

// 设置邀请名

infoVo.setIntervieweesName(findEmp.getName());

// 设置初审人

infoVo.setFirstTrialName(findEmp.getName());

// 设置总审人

infoVo.setFinalTrialName(finalEmployeeInfoMap.getOrDefault(accessingInviteInfo.getFinalPersonal(),findEmp).getName());

// 设置部门

infoVo.setDepartment(findEmp.getDepartment());

findGrp = groupInfoMap.getOrDefault(accessingInviteInfo.getUnitID(), defaultGrp);

// 设置单位

infoVo.setUnitName(findGrp.getName());

// 设置地址

infoVo.setUnitAddress(findGrp.getAddress());

lstVoInfo.add(infoVo);

}

return lstVoInfo;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vo类 public class ArealRainfallVo implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "区域编码") private String code; @ApiModelProperty(value = "雨量总和") private BigDecimal value; } Mapper类 public interface WeightBetweenObjectAndRainfallStationMapper extends BaseMapper<WeightBetweenObjectAndRainfallStation> { List<ArealRainfallVo> ListbySumList (List<PointRainfallSumVO> list); } mapper配置类 <mapper namespace="com.ndwp.jboot.bootstrap.mapper.WeightBetweenObjectAndRainfallStationMapper"> <select id="ListbySumList" resultType="com.ndwp.jboot.bootstrap.entity.vo.ArealRainfallVo"> SELECT code, SUM(CASE <foreach collection="list" item = "item"> WHEN rainfall_station_code = '${item.getCode()}' THEN weight * ${item.getValue()} </foreach> END ) AS value FROM bootstrap.weight_between_object_and_rainfall_station GROUP BY code; </select> </mapper> 服务类 public interface IWeightBetweenObjectAndRainfallStationService extends BaseService<WeightBetweenObjectAndRainfallStation> { List<ArealRainfallVo> listAreaRainfall(Date start, Date end); } 服务实现类 @Service public class WeightBetweenObjectAndRainfallStationServiceImpl extends BaseServiceImpl<WeightBetweenObjectAndRainfallStationMapper, WeightBetweenObjectAndRainfallStation> implements IWeightBetweenObjectAndRainfallStationService { @Autowired IDataHistoricRainfallService dataHistoricRainfallService; @Override public List<ArealRainfallVo> listAreaRainfall(Date start, Date end) { List<PointRainfallSumVO> pointRainfallSumVOS = dataHistoricRainfallService.listAllPointRainfallByTime(start, end); return baseMapper.ListbySumList(pointRainfallSumVOS); } } 控制台打印的sql语句能够正常运行,结合代码分析一下为何会返回四个空对象?
最新发布
07-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值