From 8fb013a6d6707929799e9f7a8a82f311cbca29ae Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Wed, 23 Dec 2020 14:47:04 +0800
Subject: [PATCH] update大屏年,月数据查询接口
---
src/main/java/com/moral/service/impl/AccountServiceImpl.java | 235 +++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 199 insertions(+), 36 deletions(-)
diff --git a/src/main/java/com/moral/service/impl/AccountServiceImpl.java b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
index fe05269..435d4eb 100644
--- a/src/main/java/com/moral/service/impl/AccountServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -11,7 +11,13 @@
import java.util.Set;
import javax.annotation.Resource;
+import javax.management.monitor.Monitor;
+import com.moral.entity.*;
+import com.moral.mapper.DictionaryDataMapper;
+
+import com.moral.mapper.MonitorPointMapper;
+import com.moral.service.MonitorPointService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
@@ -25,10 +31,6 @@
import com.moral.common.exception.BusinessException;
import com.moral.common.util.ResourceUtil;
import com.moral.common.util.ValidateUtil;
-import com.moral.entity.Account;
-import com.moral.entity.Menu;
-import com.moral.entity.Organization;
-import com.moral.entity.Role;
import com.moral.mapper.AccountMapper;
import com.moral.mapper.OrganizationMapper;
import com.moral.service.AccountService;
@@ -57,6 +59,109 @@
@Resource
private OrganizationMapper organizationMapper;
+ @Resource
+ private MonitorPointService monitorPointService;
+
+ @Resource
+ private MonitorPointMapper monitorPointMapper;
+
+ @Override
+ public Map<String, Object> getAccountInfoById(String accountId) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ Account account = new Account();
+ account.setId(Integer.parseInt(accountId));
+ account = accountMapper.selectOne(account);
+ if (ObjectUtils.isEmpty(account)) {
+ result.put("msg", "token������");
+ result.put("accountId", -1);
+ } else {
+ result = judgeAccountInfo(account);
+ String regionCode = getRegionCodeByAccount(account);
+ if (!String.valueOf(result.get("accountId")).equals("-1")) {
+ List<MonitorPoint> monitorPoints = new ArrayList<>();
+ if (account.getOrganizationId().equals(dictionaryDataMapper.selectSupperOrgId())) {
+ Map<String, Object> paramMap = new HashMap<>();
+ paramMap.put("regionCode", regionCode);
+ paramMap.put("organizationId", account.getOrganizationId());
+ monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(paramMap);
+ } else {
+ Set<Integer> orgIds = organizationService.getChildOrganizationIds(account.getOrganizationId());
+ orgIds.add(account.getOrganizationId());
+ monitorPoints = monitorPointService.getMonitorPointsByOrganizationIds(orgIds);
+ }
+ List<Integer> monitorPointIds = new ArrayList<>();
+ monitorPoints.forEach(value -> {
+ monitorPointIds.add(value.getId());
+ });
+
+ List<Menu> menuList = accountMapper.getScreenMenuListsByAccountName(account.getAccountName());
+ result.put("msg", "���������������");
+ result.put("accountId", account.getId());
+ result.put("orgId", account.getOrganizationId());
+ result.put("data", menuList);
+ result.put("regionCode", regionCode);
+ result.put("monitorPointIds", monitorPointIds);
+ setOrgIdsByAccount(result);
+ }
+ }
+ return result;
+ }
+
+
+ @Override
+ public Map<String, Object> webLogin(Map<String, Object> parameters) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ Account account = new Account();
+ account.setAccountName((String) parameters.get("account"));
+ String rawPassword = (String) parameters.get("password");
+ account = accountMapper.selectOne(account);
+ boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
+ if (!isValid) {
+ result.put("msg", "���������������������������������");
+ result.put("accountId", -1);
+ } else {
+ result = judgeAccountInfo(account);
+ }
+ return result;
+ }
+
+
+ @Override
+ public Map<String, Object> screenLoginNew(Map<String, Object> parameters) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ Account account = new Account();
+ account.setAccountName((String) parameters.get("account"));
+ String rawPassword = (String) parameters.get("password");
+// account.setPassword(encoder.encode((String) parameters.get("password")));
+ account = accountMapper.selectOne(account);
+ Integer existRole = null;
+ List<Menu> menuList = new ArrayList<>();
+ if (account != null) {
+ existRole = accountMapper.getScreenRoleByAccountName(account.getAccountName());
+ menuList = accountMapper.getScreenMenuListsByAccountName(account.getAccountName());
+ }
+ boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
+ if (!isValid) {
+ result.put("msg", "���������������������������������");
+ result.put("accountId", -1);
+ } else {
+ if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
+ if (existRole != null) {
+ result.put("msg", "���������������");
+ result.put("accountId", account.getId());
+ result.put("orgId", account.getOrganizationId());
+ result.put("data", menuList);
+ setOrgIdsByAccount(result);
+ } else {
+ result.put("msg", "���������������������");
+ }
+ } else {
+ result.put("msg", "���������������������������������������������");
+ }
+ }
+ return result;
+ }
+
@Override
public Map<String, Object> screenLogin(Map<String, Object> parameters) {
Map<String, Object> result = new HashMap<String, Object>();
@@ -74,37 +179,6 @@
result.put("accountId", account.getId());
result.put("orgId", account.getOrganizationId());
setOrgIdsByAccount(result);
- } else {
- result.put("msg", "���������������������������������������������");
- }
- }
- return result;
- }
-
- @Override
- public Map<String, Object> screenLoginNew(Map<String, Object> parameters) {
- Map<String, Object> result = new HashMap<String, Object>();
- Account account = new Account();
- account.setAccountName((String) parameters.get("account"));
- String rawPassword = (String) parameters.get("password");
-// account.setPassword(encoder.encode((String) parameters.get("password")));
- account = accountMapper.selectOne(account);
- Integer existRole=accountMapper.getScreenRoleByAccountName(account.getAccountName());
- List<Menu> menuList = accountMapper.getScreenMenuListsByAccountName(account.getAccountName());
- boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
- if (!isValid) {
- result.put("msg", "���������������������������������");
- } else {
- if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
- if(existRole!=null) {
- result.put("msg", "���������������");
- result.put("accountId", account.getId());
- result.put("orgId", account.getOrganizationId());
- result.put("data",menuList);
- setOrgIdsByAccount(result);
- }else{
- result.put("msg", "���������������������");
- }
} else {
result.put("msg", "���������������������������������������������");
}
@@ -262,7 +336,7 @@
List<Menu> menuList = accountMapper.getParentMenuListsByAccountName(accountName);
Integer organizationId = accountMapper.getByAccountName(accountName).getOrganizationId();
Map<String, Object> organizationMap = new LinkedHashMap<>();
- organizationMap.put("organizationId",organizationId);
+ organizationMap.put("organizationId", organizationId);
String email = accountMapper.getEmailByAccountName(accountName);
Map<String, Object> mapList = new LinkedHashMap<>();
Map<String, Object> appMap = new LinkedHashMap<>();
@@ -318,4 +392,93 @@
return mapList;
}
+ private Map<String, Object> judgeAccountInfo(Account account) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ Integer existRole = accountMapper.getScreenRoleByAccountName(account.getAccountName());
+ if (!IS_DELETE_FALSE.equals(account.getIsDelete())) {
+ result.put("msg", "���������������������������������������������");
+ result.put("accountId", -1);
+ } else if (ObjectUtils.isEmpty(existRole)) {
+ result.put("msg", "���������������������");
+ result.put("accountId", -1);
+ } else {
+ result.put("msg", "���������������");
+ result.put("accountId", account.getId());
+ }
+ return result;
+ }
+
+ @Resource
+ DictionaryDataMapper dictionaryDataMapper;
+
+ @Override
+ public Map<String, Object> bsWebLogin(Map<String, Object> parameters) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ Account account = new Account();
+ account.setAccountName((String) parameters.get("account"));
+ String rawPassword = (String) parameters.get("password");
+ account = accountMapper.selectOne(account);
+ boolean isValid = account == null ? false : encoder.matches(rawPassword, account.getPassword());
+ if (!isValid) {
+ result.put("msg", "���������������������������������");
+ result.put("accountId", -1);
+ } else {
+ result = judgeAccountInfo(account);
+
+ }
+ return result;
+ }
+
+ /**
+ * @Description: ������id������������������������������
+ * @Param: [params]
+ * @return: java.util.Map<java.lang.String , java.lang.Object>
+ * @Author: ������������
+ * @Date: 2020/11/25
+ */
+ private String getRegionCodeByAccount(Account account) {
+ Organization organization = new Organization();
+ organization.setId(account.getOrganizationId());
+ organization = organizationMapper.selectOne(organization);
+ Map<String, Object> regionCodeAndType = getRegionCodeAndTypeByOrg(organization);
+ if (ObjectUtils.isEmpty(regionCodeAndType))
+ return null;
+ return (String) regionCodeAndType.get("regionCode");
+ }
+
+ public Map<String, Object> getRegionCodeAndTypeByOrg(Organization organization) {
+ Map<String, Object> result = new HashMap<>();
+ String regionCode = "";
+ String regionType = "";
+ Long villageCode = organization.getVillageCode();
+ Long townCode = organization.getTownCode();
+ Integer areaCode = organization.getAreaCode();
+ Integer cityCode = organization.getCityCode();
+ Integer provinceCode = organization.getProvinceCode();
+
+ if (!ObjectUtils.isEmpty(villageCode)) {
+ regionCode = String.valueOf(villageCode);
+ regionType = "village";
+ } else if (!ObjectUtils.isEmpty(townCode)) {
+ regionCode = String.valueOf(townCode);
+ regionType = "town";
+ } else if (!ObjectUtils.isEmpty(areaCode)) {
+ regionCode = String.valueOf(areaCode);
+ regionType = "area";
+ } else if (!ObjectUtils.isEmpty(cityCode)) {
+ regionCode = String.valueOf(cityCode);
+ regionType = "city";
+ } else if (!ObjectUtils.isEmpty(provinceCode)) {
+ regionCode = String.valueOf(provinceCode);
+ regionType = "province";
+ } else {
+ return null;
+ }
+ result.put("regionCode", regionCode);
+ result.put("regionType", regionType);
+ return result;
+ }
}
+
+
+
--
Gitblit v1.8.0