From c10d6358b9f014375a13821465bc978d0c0da22e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Wed, 29 May 2024 17:17:08 +0800
Subject: [PATCH] 通过E呼即办数据统计

---
 src/main/java/org/springblade/modules/property/service/impl/PropertyCompanyServiceImpl.java |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/src/main/java/org/springblade/modules/property/service/impl/PropertyCompanyServiceImpl.java b/src/main/java/org/springblade/modules/property/service/impl/PropertyCompanyServiceImpl.java
index b2204ae..65e16c2 100644
--- a/src/main/java/org/springblade/modules/property/service/impl/PropertyCompanyServiceImpl.java
+++ b/src/main/java/org/springblade/modules/property/service/impl/PropertyCompanyServiceImpl.java
@@ -18,20 +18,32 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.common.cache.SysCache;
 import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.RoleUtil;
 import org.springblade.common.utils.SpringUtils;
 import org.springblade.core.mp.support.Condition;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.DigestUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.SpringUtil;
 import org.springblade.modules.pay.entity.AliPayInfo;
 import org.springblade.modules.pay.entity.WxPayInfo;
 import org.springblade.modules.pay.service.IAliPayService;
 import org.springblade.modules.pay.service.IWxPayService;
+import org.springblade.modules.property.entity.PropertyCompanyDistrictEntity;
 import org.springblade.modules.property.entity.PropertyCompanyEntity;
 import org.springblade.modules.property.mapper.PropertyCompanyMapper;
+import org.springblade.modules.property.service.IPropertyCompanyDistrictService;
 import org.springblade.modules.property.service.IPropertyCompanyService;
+import org.springblade.modules.property.service.IPropertyDistrictUserService;
 import org.springblade.modules.property.vo.PropertyCompanyDetailVO;
 import org.springblade.modules.property.vo.PropertyCompanyVO;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.modules.property.vo.PropertyDistrictInfo;
 import org.springblade.modules.system.entity.Dept;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.entity.UserDept;
@@ -42,7 +54,9 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 物业公司 服务实现类
@@ -82,6 +96,12 @@
 	 */
 	@Override
 	public List<PropertyCompanyVO> getPropertyCompanyList(PropertyCompanyVO propertyCompany) {
+		String userRole = AuthUtil.getUserRole();
+		if (!AuthUtil.isAdministrator() && userRole.contains("wygly")) {
+			Long deptId = Func.firstLong(AuthUtil.getDeptId());
+			Dept dept = SysCache.getDept(deptId);
+			propertyCompany.setName(dept.getDeptName());
+		}
 		return baseMapper.getPropertyCompanyList(propertyCompany);
 	}
 
@@ -190,7 +210,8 @@
 	public PropertyCompanyDetailVO getPayConfig(PropertyCompanyVO propertyCompany) {
 
 
-		PropertyCompanyDetailVO detail = this.getDetail(propertyCompany);
+//		PropertyCompanyDetailVO detail = this.getDetail(propertyCompany);
+		PropertyCompanyDetailVO detail = baseMapper.getDetailVO(propertyCompany);
 
 
 		AliPayInfo pA = new AliPayInfo();
@@ -203,4 +224,28 @@
 
 		return detail;
 	}
+
+	/**
+	 * 通过用户机构查询
+	 *
+	 * @return
+	 */
+	@Override
+	public PropertyCompanyDetailVO getDetailByDeptId() {
+		String userRole = AuthUtil.getUserRole();
+		if (RoleUtil.isProperty(userRole)) {
+			// 通过用户机构查询用户的物业公司
+			IPropertyCompanyService bean = SpringUtil.getBean(IPropertyCompanyService.class);
+			PropertyCompanyEntity propertyCompanyEntity = bean.getOne(Wrappers.<PropertyCompanyEntity>lambdaQuery().eq(PropertyCompanyEntity::getDeptId, AuthUtil.getDeptId()).last("limit 1"));
+			if (propertyCompanyEntity != null) {
+				return baseMapper.getDetailVO(BeanUtil.copyProperties(propertyCompanyEntity, PropertyCompanyVO.class));
+			}
+		}
+		return null;
+	}
+
+	@Override
+	public PropertyDistrictInfo getPropertyDistrictInfo(PropertyDistrictInfo propertyDistrictInfo) {
+		return baseMapper.getPropertyDistrictInfo(propertyDistrictInfo);
+	}
 }

--
Gitblit v1.9.3