|
@@ -0,0 +1,103 @@
|
|
|
+package com.usky.fire.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.usky.common.core.bean.CommonPage;
|
|
|
+import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.common.security.utils.SecurityUtils;
|
|
|
+import com.usky.fire.domain.PatrolInspectionArea;
|
|
|
+import com.usky.fire.domain.PatrolInspectionSite;
|
|
|
+import com.usky.fire.mapper.PatrolInspectionSiteMapper;
|
|
|
+import com.usky.fire.service.PatrolInspectionAreaService;
|
|
|
+import com.usky.fire.service.PatrolInspectionSiteService;
|
|
|
+import com.usky.fire.service.util.OnlineMethod;
|
|
|
+import com.usky.fire.service.vo.DataCountVo;
|
|
|
+import com.usky.fire.service.vo.PatrolInspectionAreaVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author JCB
|
|
|
+ * @since 2022-07-13
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolInspectionSiteMapper, PatrolInspectionSite> implements PatrolInspectionSiteService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionAreaService patrolInspectionAreaService;
|
|
|
+
|
|
|
+ public List<PatrolInspectionAreaVo> areaLeftList() {
|
|
|
+ LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
|
|
|
+ .eq(PatrolInspectionArea::getEnable, 1);
|
|
|
+ List<PatrolInspectionArea> patrolInspectionAreaList = patrolInspectionAreaService.list(queryWrapper);
|
|
|
+ LambdaQueryWrapper<PatrolInspectionSite> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperOne.eq(PatrolInspectionSite::getEnable, 1);
|
|
|
+ List<PatrolInspectionSite> list = this.list(queryWrapperOne);
|
|
|
+ Map<Integer, List<PatrolInspectionSite>> grouypByAreaId = list.stream().collect(
|
|
|
+ Collectors.groupingBy(o -> o.getAreaId())
|
|
|
+ );
|
|
|
+ List<DataCountVo> dataCountVoList = new ArrayList<>();
|
|
|
+ grouypByAreaId.forEach((k, v) -> {
|
|
|
+ DataCountVo dataCountVo = new DataCountVo();
|
|
|
+ dataCountVo.setListCount(v.size());
|
|
|
+ dataCountVo.setId(k);
|
|
|
+ dataCountVoList.add(dataCountVo);
|
|
|
+ });
|
|
|
+ List<PatrolInspectionAreaVo> patrolInspectionAreaVoList = new ArrayList<>();
|
|
|
+ if (patrolInspectionAreaList.size() > 0) {
|
|
|
+ for (int i = 0; i < patrolInspectionAreaList.size(); i++) {
|
|
|
+ PatrolInspectionAreaVo patrolInspectionAreaVo = new PatrolInspectionAreaVo();
|
|
|
+ patrolInspectionAreaVo.setId(patrolInspectionAreaList.get(i).getId());
|
|
|
+ patrolInspectionAreaVo.setAreaName(patrolInspectionAreaList.get(i).getAreaName());
|
|
|
+ patrolInspectionAreaVo.setAreaFid(patrolInspectionAreaList.get(i).getAreaFid());
|
|
|
+ patrolInspectionAreaVo.setCompanyId(patrolInspectionAreaList.get(i).getCompanyId());
|
|
|
+ patrolInspectionAreaVo.setTenantId(patrolInspectionAreaList.get(i).getTenantId());
|
|
|
+ patrolInspectionAreaVo.setCreator(patrolInspectionAreaList.get(i).getCreator());
|
|
|
+ patrolInspectionAreaVo.setCreateTime(patrolInspectionAreaList.get(i).getCreateTime());
|
|
|
+ patrolInspectionAreaVo.setEnable(patrolInspectionAreaList.get(i).getEnable());
|
|
|
+ patrolInspectionAreaVo.setSiteCount(0);
|
|
|
+ for (int j = 0; j < dataCountVoList.size(); j++) {
|
|
|
+ if (patrolInspectionAreaList.get(i).getId() == dataCountVoList.get(j).getId()) {
|
|
|
+ patrolInspectionAreaVo.setSiteCount(dataCountVoList.get(j).getListCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ patrolInspectionAreaVoList.add(patrolInspectionAreaVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PatrolInspectionAreaVo> patrolInspectionAreaVoListOne = new ArrayList<>();
|
|
|
+ if (patrolInspectionAreaVoList.size() > 0) {
|
|
|
+ patrolInspectionAreaVoListOne = OnlineMethod.getChildPerms(patrolInspectionAreaVoList, 0);
|
|
|
+ }
|
|
|
+ return patrolInspectionAreaVoListOne;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public CommonPage<PatrolInspectionSite> patrolInspectionSiteList(Integer areaId, String siteName, Integer pageNum, Integer pageSize,Integer id) {
|
|
|
+ LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId())
|
|
|
+ .eq(PatrolInspectionSite::getEnable, 1);
|
|
|
+ if (areaId != null) {
|
|
|
+ queryWrapper.eq(PatrolInspectionSite::getAreaId, areaId);
|
|
|
+ }
|
|
|
+ if (id != null&&id !=0) {
|
|
|
+ queryWrapper.eq(PatrolInspectionSite::getId, id);
|
|
|
+ }
|
|
|
+ if (siteName != null && !"".equals(siteName)) {
|
|
|
+ queryWrapper.like(PatrolInspectionSite::getSiteName, siteName);
|
|
|
+ }
|
|
|
+ List<PatrolInspectionSite> patrolInspectionSiteList = this.list(queryWrapper);
|
|
|
+ List<PatrolInspectionSite> list = patrolInspectionSiteList.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
+ return new CommonPage<>(list, patrolInspectionSiteList.size(), pageNum, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|