package com.panzhihua.service_equipment.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.panzhihua.common.model.dtos.equipment.UnionReportDto;
|
import com.panzhihua.common.model.vos.R;
|
import com.panzhihua.service_equipment.dao.UnionReportMapper;
|
import com.panzhihua.service_equipment.dao.UnionUserMapper;
|
import com.panzhihua.service_equipment.model.dos.UnionReport;
|
import com.panzhihua.service_equipment.model.dos.UnionUser;
|
import com.panzhihua.service_equipment.service.UnionReportService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.time.LocalDateTime;
|
|
@Service
|
@Slf4j
|
public class UnionReportServiceImpl extends ServiceImpl<UnionReportMapper, UnionReport> implements UnionReportService {
|
|
@Resource
|
private UnionUserMapper unionUserMapper;
|
|
|
/**
|
* 户外劳工站上报表
|
*
|
* @param unionReportDto
|
* @return 新增结果
|
*/
|
@Override
|
public R add(UnionReportDto unionReportDto) {
|
UnionReport unionReport = new UnionReport();
|
BeanUtils.copyProperties(unionReportDto, unionReport);
|
UnionUser unionUser=null;
|
if (unionReportDto.getIsApplets().equals(1))
|
{
|
unionUser = unionUserMapper
|
.selectOne(new QueryWrapper<UnionUser>().eq("user_id", unionReportDto.getCreateUserId()));
|
}else if (unionReportDto.getIsApplets().equals(3)) {
|
unionUser = unionUserMapper
|
.selectOne(new QueryWrapper<UnionUser>().eq("id", unionReportDto.getCreateUnionUserId()));
|
}
|
if (unionUser!=null)
|
unionReport.setCreateUnionUserId(unionUser.getId());
|
unionReport.setStatus(1);
|
unionReport.setCreateAt(LocalDateTime.now());
|
if (baseMapper.insert(unionReport) > 0) {
|
return R.ok();
|
}
|
return R.fail();
|
}
|
|
/**
|
* 分页户外劳工站上报表
|
*
|
* @param unionReportDto
|
* @return 动态结果
|
*/
|
@Override
|
public R<IPage<UnionReport>> query(UnionReportDto unionReportDto) {
|
Page page = new Page(unionReportDto.getPageNum(), unionReportDto.getPageSize());
|
QueryWrapper<UnionReport> unionOutdoorLaborDynamicQueryWrapper = new QueryWrapper<>();
|
if (unionReportDto.getIsApplets().equals(1)){
|
unionOutdoorLaborDynamicQueryWrapper.eq("create_user_id",unionReportDto.getCreateUserId());
|
if (unionReportDto.getType()!=null)
|
unionOutdoorLaborDynamicQueryWrapper.eq("type",unionReportDto.getType());
|
if (unionReportDto.getStatus()!=null)
|
unionOutdoorLaborDynamicQueryWrapper.eq("status",unionReportDto.getStatus());
|
}else if(unionReportDto.getIsApplets().equals(3)){
|
unionOutdoorLaborDynamicQueryWrapper.eq("create_union_user_id",unionReportDto.getCreateUnionUserId()).eq("type",unionReportDto.getType());
|
if (unionReportDto.getStatus()!=null)
|
unionOutdoorLaborDynamicQueryWrapper.eq("status",unionReportDto.getStatus());
|
if (unionReportDto.getType()!=null)
|
unionOutdoorLaborDynamicQueryWrapper.eq("type",unionReportDto.getType());
|
}
|
Page pageResult = baseMapper.selectPage(page, unionOutdoorLaborDynamicQueryWrapper);
|
pageResult.setTotal(pageResult.getRecords().size());
|
return R.ok(pageResult);
|
}
|
|
}
|