Browse Source

添加用户类型的判断

jichaobo 2 years ago
parent
commit
c25a40d88b

+ 6 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecord.java

@@ -119,5 +119,11 @@ public class PatrolInspectionRecord implements Serializable {
      */
     private Integer companyId;
 
+    /**
+     * 用户名
+     */
+    private String creator;
+
+
 
 }

+ 21 - 17
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAreaServiceImpl.java

@@ -1,10 +1,7 @@
 package com.usky.fire.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-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;
@@ -15,10 +12,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -81,10 +75,10 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
     @Transactional
     public void delPatrolInspectionArea(Integer id) {
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid,id);
+        queryWrapper.eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid, id);
         List<PatrolInspectionArea> patrolInspectionArealist = this.list(queryWrapper);
-        if (null!=patrolInspectionArealist&&!patrolInspectionArealist.isEmpty()){
-            for (int i=0;i<patrolInspectionArealist.size();i++){
+        if (null != patrolInspectionArealist && !patrolInspectionArealist.isEmpty()) {
+            for (int i = 0; i < patrolInspectionArealist.size(); i++) {
                 PatrolInspectionArea patrolInspectionAreaz = new PatrolInspectionArea();
                 patrolInspectionAreaz.setId(patrolInspectionArealist.get(i).getId());
                 patrolInspectionAreaz.setEnable(0);
@@ -99,16 +93,21 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
 
     /**
      * 巡查自检-巡检区域-列表查詢
-     * @param id 区域ID
+     *
+     * @param id       区域ID
      * @param areaName 区域名称
-     * @param pageNum 当前页
+     * @param pageNum  当前页
      * @param pageSize 每页条数
      * @return
      */
     public List<PatrolInspectionArea> patrolInspectionAreaList(Integer id, String areaName, Integer pageNum, Integer pageSize) {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
-                .eq(PatrolInspectionArea::getEnable, 1);
+        queryWrapper.eq(PatrolInspectionArea::getEnable, 1)
+                .eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionArea::getCreator, SecurityUtils.getUsername());
+        }
         if (id != null && id != 0) {
             queryWrapper.eq(PatrolInspectionArea::getId, id);
         }
@@ -122,16 +121,21 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
 
     /**
      * 巡查自检-巡检区域-一级区域下拉框
+     *
      * @return
      */
-    public List<PatrolInspectionArea> patrolInspectionAreaSelect(){
+    public List<PatrolInspectionArea> patrolInspectionAreaSelect() {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
-                .eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid,0)
-                .orderByDesc(PatrolInspectionArea::getId);
+                .eq(PatrolInspectionArea::getEnable, 1)
+                .eq(PatrolInspectionArea::getAreaFid, 0);
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionArea::getCreator, SecurityUtils.getUsername());
+        }
+        queryWrapper.orderByDesc(PatrolInspectionArea::getId);
         return this.list(queryWrapper);
     }
 
 
-
 }

+ 10 - 8
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionContentServiceImpl.java

@@ -7,7 +7,6 @@ import com.usky.common.core.exception.BusinessException;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.ContentOption;
-import com.usky.fire.domain.PatrolInspectionArea;
 import com.usky.fire.domain.PatrolInspectionContent;
 import com.usky.fire.domain.SiteContent;
 import com.usky.fire.mapper.PatrolInspectionContentMapper;
@@ -71,9 +70,9 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
     @Transactional
     public void updatePatrolInspectionContent(PatrolInspectionContentVo patrolInspectionContentVo) {
         LambdaQueryWrapper<SiteContent> queryWrapperOne = Wrappers.lambdaQuery();
-        queryWrapperOne.eq(SiteContent::getContentId,patrolInspectionContentVo.getId());
+        queryWrapperOne.eq(SiteContent::getContentId, patrolInspectionContentVo.getId());
         List<SiteContent> siteContentList = siteContentService.list(queryWrapperOne);
-        if (siteContentList.size()<=0){
+        if (siteContentList.size() <= 0) {
             throw new BusinessException("巡检内容已绑定站点不可修改");
         }
         PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
@@ -85,7 +84,7 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
         this.updateById(patrolInspectionContent);
         LambdaQueryWrapper<ContentOption> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(ContentOption::getEnable, 1)
-        .eq(ContentOption::getContentId,patrolInspectionContentVo.getId());
+                .eq(ContentOption::getContentId, patrolInspectionContentVo.getId());
         List<ContentOption> ContentOptionList = contentOptionService.list(queryWrapper);
         if (ContentOptionList.size() > 0) {
             for (int i = 0; i < ContentOptionList.size(); i++) {
@@ -143,9 +142,13 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
 
     @Override
     public CommonPage<PatrolInspectionContentVo> patrolInspectionContentList(String contentTitle, Integer pageNum, Integer pageSize, Integer id) {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionContent> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionContent::getTenantId, SecurityUtils.getTenantId())
-                .eq(PatrolInspectionContent::getEnable, 1);
+        queryWrapper.eq(PatrolInspectionContent::getEnable, 1)
+                .eq(PatrolInspectionContent::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionContent::getCreator, SecurityUtils.getUsername());
+        }
         if (contentTitle != null && !"".equals(contentTitle)) {
             queryWrapper.like(PatrolInspectionContent::getContentTitle, contentTitle);
         }
@@ -160,7 +163,6 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
             List<Integer> idList = new ArrayList<>();
             for (int i = 0; i < patrolInspectionContentList.size(); i++) {
                 idList.add(patrolInspectionContentList.get(i).getId());
-
             }
             LambdaQueryWrapper<ContentOption> queryWrapperOne = Wrappers.lambdaQuery();
             queryWrapperOne.eq(ContentOption::getEnable, 1)
@@ -189,7 +191,7 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
             list = patrolInspectionContentVoList.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
 
         }
-        return new CommonPage<>(list, patrolInspectionContentVoList.size(), pageSize,pageNum);
+        return new CommonPage<>(list, patrolInspectionContentVoList.size(), pageSize, pageNum);
     }
 
 

+ 23 - 3
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanServiceImpl.java

@@ -62,12 +62,20 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
 
     @Override
     public List<PatrolInspectionAreaVo> planLeftList() {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
-                .eq(PatrolInspectionArea::getEnable, 1);
+        queryWrapper.eq(PatrolInspectionArea::getEnable, 1)
+                .eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionArea::getCreator, SecurityUtils.getUsername());
+        }
         List<PatrolInspectionArea> patrolInspectionAreaList = patrolInspectionAreaService.list(queryWrapper);
         LambdaQueryWrapper<PatrolInspectionPlan> queryWrapperOne = Wrappers.lambdaQuery();
-        queryWrapperOne.eq(PatrolInspectionPlan::getEnable, 1).eq(PatrolInspectionPlan::getTenantId, SecurityUtils.getTenantId());
+        queryWrapperOne.eq(PatrolInspectionPlan::getEnable, 1)
+                .eq(PatrolInspectionPlan::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapperOne.eq(PatrolInspectionPlan::getCreator, SecurityUtils.getUsername());
+        }
         List<PatrolInspectionPlan> list = this.list(queryWrapperOne);
         Map<Integer, List<PatrolInspectionPlan>> grouypByAreaId = list.stream().collect(
                 Collectors.groupingBy(o -> o.getAreaId())
@@ -494,9 +502,14 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
 
 
     public CommonPage<PatrolInspectionPlanDataVo> patrolInspectionPlanList(String planName, Integer planType, Integer areaId, Integer pageNum, Integer pageSize, Integer id) {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionPlan> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionPlan::getEnable, 1)
                 .eq(PatrolInspectionPlan::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionPlan::getCreator, SecurityUtils.getUsername());
+        }
+
         if (planName != null && "".equals(planName)) {
             queryWrapper.like(PatrolInspectionPlan::getPlanName, planName);
         }
@@ -565,10 +578,14 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
 
 
     public List<PatrolInspectionSiteVo> patrolInspectionSiteVoList(Integer planId, Integer areaId) {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionSite::getEnable, 1)
                 .eq(PatrolInspectionSite::getAreaId, areaId)
                 .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionSite::getCreator, SecurityUtils.getUsername());
+        }
         List<PatrolInspectionSite> patrolInspectionSiteList = patrolInspectionSiteService.list();
         LambdaQueryWrapper<PlanSite> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.eq(PlanSite::getPlanId, planId);
@@ -576,6 +593,9 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapperTwo = Wrappers.lambdaQuery();
         queryWrapperTwo.eq(PatrolInspectionArea::getEnable, 1)
                 .eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapperTwo.eq(PatrolInspectionArea::getCreator, SecurityUtils.getUsername());
+        }
         List<PatrolInspectionArea> PatrolInspectionAreaList = patrolInspectionAreaService.list(queryWrapperTwo);
         List<PatrolInspectionSiteVo> list = new ArrayList<>();
         for (int i = 0; i < patrolInspectionSiteList.size(); i++) {

+ 12 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordServiceImpl.java

@@ -54,8 +54,12 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
     public CommonPage<PatrolInspectionRecord> patrolInspectionRecordLsit(String areaName, String siteName, String name,
                                                                          Integer planType, String startDateTime, String endDateTime,
                                                                          Integer pageNum, Integer pageSize) {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionRecord> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionRecord::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionRecord::getCreator, SecurityUtils.getUsername());
+        }
         if (areaName != null && "".equals(areaName)) {
             queryWrapper.like(PatrolInspectionRecord::getAreaName, areaName);
         }
@@ -190,6 +194,7 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
             patrolInspectionRecordVo.setSiteId(patrolInspectionRecordList.get(i).getSiteId());
             patrolInspectionRecordVo.setTenantId(patrolInspectionRecordList.get(i).getTenantId());
             patrolInspectionRecordVo.setCompanyId(patrolInspectionRecordList.get(i).getCompanyId());
+            patrolInspectionRecordVo.setCreator(patrolInspectionRecordList.get(i).getCreator());
             patrolInspectionRecordVo.setRecordPictureList(patrolInspectionRecordPictureList);
             patrolInspectionRecordVo.setContentVoList(patrolInspectionContentVoList);
             list.add(patrolInspectionRecordVo);
@@ -254,9 +259,13 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
      */
     @Override
     public List<Integer> getPlanSon(String startDate, String endDate) {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionPlanSon::getPlanType, 1)
                 .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapper.eq(PatrolInspectionPlanSon::getCreator, SecurityUtils.getUsername());
+        }
         if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
             queryWrapper.between(PatrolInspectionPlanSon::getInspectionDate, startDate, endDate);
         }
@@ -269,6 +278,9 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
         LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.eq(PatrolInspectionPlanSon::getPlanType, 2)
                 .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)) {
+            queryWrapperOne.eq(PatrolInspectionPlanSon::getCreator, SecurityUtils.getUsername());
+        }
         if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
             queryWrapperOne.and(wq -> wq
                     .between(PatrolInspectionPlanSon::getStartDate, startDate, endDate)

+ 17 - 5
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionSiteServiceImpl.java

@@ -49,12 +49,20 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
 
     @Override
     public List<PatrolInspectionAreaVo> areaLeftList() {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
-                .eq(PatrolInspectionArea::getEnable, 1);
+        queryWrapper.eq(PatrolInspectionArea::getEnable, 1)
+                .eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId());
+        if ("00".equals(userType)){
+            queryWrapper.eq(PatrolInspectionArea::getCreator, SecurityUtils.getUsername());
+        }
         List<PatrolInspectionArea> patrolInspectionAreaList = patrolInspectionAreaService.list(queryWrapper);
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapperOne = Wrappers.lambdaQuery();
-        queryWrapperOne.eq(PatrolInspectionSite::getEnable, 1).eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+        queryWrapperOne.eq(PatrolInspectionSite::getEnable, 1)
+                .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+        if("00".equals(userType)){
+            queryWrapperOne.eq(PatrolInspectionSite::getCreator, SecurityUtils.getUsername());
+        }
         List<PatrolInspectionSite> list = this.list(queryWrapperOne);
         Map<Integer, List<PatrolInspectionSite>> grouypByAreaId = list.stream().collect(
                 Collectors.groupingBy(o -> o.getAreaId())
@@ -96,9 +104,13 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
 
     @Override
     public CommonPage<PatrolInspectionSite> patrolInspectionSiteList(Integer areaId, String siteName, Integer pageNum, Integer pageSize, Integer id) {
+        String userType = SecurityUtils.getLoginUser().getUserType();
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId())
-                .eq(PatrolInspectionSite::getEnable, 1);
+        queryWrapper.eq(PatrolInspectionSite::getEnable, 1)
+                .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+        if("00".equals(userType)){
+            queryWrapper.eq(PatrolInspectionSite::getCreator, SecurityUtils.getUsername());
+        }
         if (areaId != null) {
             queryWrapper.eq(PatrolInspectionSite::getAreaId, areaId);
         }

+ 5 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionRecordVo.java

@@ -122,6 +122,11 @@ public class PatrolInspectionRecordVo implements Serializable {
      */
     private Integer companyId;
 
+    /**
+     * 用户名
+     */
+    private String creator;
+
     /**
      * 图片路径
      */