|
|
@@ -12,27 +12,36 @@ import com.tuoheng.admin.entity.Accident; |
|
|
|
import com.tuoheng.admin.entity.Dept; |
|
|
|
import com.tuoheng.admin.entity.Inspection; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.enums.AccidentEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.enums.RoleEnum; |
|
|
|
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.AccidentMapper; |
|
|
|
import com.tuoheng.admin.mapper.DeptMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.admin.mapper.UserMapper; |
|
|
|
import com.tuoheng.admin.query.AccidentQuery; |
|
|
|
import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; |
|
|
|
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; |
|
|
|
import com.tuoheng.admin.service.inspection.query.handle.GenerateInspectionFieldHander; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.accident.AccidentVo; |
|
|
|
import com.tuoheng.admin.vo.accident.QueryAccidentPageVO; |
|
|
|
import com.tuoheng.admin.vo.inspection.InspectionVo; |
|
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
|
import com.tuoheng.common.core.enums.ServiceExceptionEnum; |
|
|
|
import com.tuoheng.common.core.exception.ServiceException; |
|
|
|
import com.tuoheng.common.core.utils.DateUtils; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@@ -137,4 +146,61 @@ public class QueryAccidentPageListService { |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
public JsonResult index(AccidentQuery query) { |
|
|
|
//校验 |
|
|
|
if(query.getLimit() == null && query.getPage() == null){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
//当前租户下 |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
if(tenantId == null){ |
|
|
|
return JsonResult.error(AccidentEnum.TENANT_ID_IS_NULL.getCode(),AccidentEnum.TENANT_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
query.setTenantId(tenantId); |
|
|
|
IPage<Accident> page = new Page<>(query.getPage(),query.getLimit()); |
|
|
|
IPage<QueryAccidentPageVO> pageData = new Page<>(query.getPage(),query.getLimit()); |
|
|
|
//搜索时间 |
|
|
|
Date startTime = null; |
|
|
|
Date endTime = null; |
|
|
|
if(StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())){ |
|
|
|
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getStartTime()+" 00:00:00"); |
|
|
|
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getEndTime()+" 23:59:59"); |
|
|
|
} |
|
|
|
query.setAccidentStartTime(startTime); |
|
|
|
query.setAccidentEndTime(endTime); |
|
|
|
//获取分页数据 |
|
|
|
IPage<Accident> accidentPageData = accidentMapper.selectPage(page, Wrappers.<Accident>lambdaQuery() |
|
|
|
.eq(null != query.getCode(),Accident::getRoadCode,query.getCode()) |
|
|
|
.eq(null != query.getDeptId(),Accident::getDeptId,query.getDeptId()) |
|
|
|
.between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(), |
|
|
|
Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime()) |
|
|
|
.eq(Accident::getMark, MarkEnum.VALID.getCode()) |
|
|
|
.orderByDesc(Accident::getCreateTime)); |
|
|
|
//属性复制 |
|
|
|
List<QueryAccidentPageVO> result = accidentPageData.getRecords().stream().map(x -> { |
|
|
|
QueryAccidentPageVO vo = new QueryAccidentPageVO(); |
|
|
|
BeanUtils.copyProperties(x, vo); |
|
|
|
//公路代号 |
|
|
|
if (StringUtils.isNotEmpty(x.getRoadCode())) { |
|
|
|
vo.setCode(x.getRoadCode()); |
|
|
|
} |
|
|
|
//监管部门 |
|
|
|
if (StringUtils.isNotEmpty(x.getDeptId())) { |
|
|
|
//根据当前部门id查询对应的部门名称 |
|
|
|
Dept dept = deptMapper.selectById(x.getDeptId()); |
|
|
|
vo.setName(dept.getName() !=null?dept.getName():""); |
|
|
|
} |
|
|
|
|
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
pageData.setPages(accidentPageData.getPages()); |
|
|
|
pageData.setRecords(result); |
|
|
|
pageData.setTotal(accidentPageData.getTotal()); |
|
|
|
pageData.setCurrent(accidentPageData.getCurrent()); |
|
|
|
|
|
|
|
return JsonResult.success(pageData); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |