|
@@ -12,12 +12,14 @@ import com.bizmatics.model.Site;
|
|
|
import com.bizmatics.model.system.SysUser;
|
|
|
import com.bizmatics.model.vo.*;
|
|
|
import com.bizmatics.persistence.mapper.PlatformAreaMapper;
|
|
|
+import com.bizmatics.persistence.mapper.system.SysUserMapper;
|
|
|
import com.bizmatics.service.PlatformAreaService;
|
|
|
import com.bizmatics.service.util.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -43,14 +45,24 @@ public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMap
|
|
|
@Autowired
|
|
|
private DeviceAttributeServiceImpl deviceAttributeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserMapper userMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void platformAreaAdd(PlatformArea platformArea){
|
|
|
+ List<SysUser> tenantDaya = userMapper.getTenantId(SecurityUtils.getLoginUser().getUser().getUserId());
|
|
|
+ if (tenantDaya.size()<0) {
|
|
|
+ throw new BusinessException("无此租户,请联系管理员");
|
|
|
+ }
|
|
|
LambdaQueryWrapper<PlatformArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(PlatformArea::getEnable, 1).eq(PlatformArea::getPlatformAreaCode, platformArea.getPlatformAreaCode());
|
|
|
List<PlatformArea> platformAreaList = this.list(queryWrapper);
|
|
|
if (platformAreaList!=null&&!platformAreaList.isEmpty()){
|
|
|
throw new BusinessException("台区编号重复,不可重复添加台区");
|
|
|
- }{
|
|
|
+ }else {
|
|
|
+ platformArea.setCreator(SecurityUtils.getLoginUser().getUser().getUserName());
|
|
|
+ platformArea.setCreateTime(new Date());
|
|
|
+ platformArea.setTenantId(tenantDaya.get(0).getTenantId());
|
|
|
platformArea.setEnable(1);
|
|
|
this.save(platformArea);
|
|
|
}
|
|
@@ -100,11 +112,14 @@ public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMap
|
|
|
|
|
|
@Override
|
|
|
public CommonPage<PlatformAreaVo> platformAreaListOne(String platformAreaName,Integer current,Integer size){
|
|
|
- SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
- List<PlatformAreaVo> platformAreaVoSiteOne = baseMapper.siteCount(platformAreaName,null,0,user.getUserId());
|
|
|
+ List<SysUser> tenantDaya = userMapper.getTenantId(SecurityUtils.getLoginUser().getUser().getUserId());
|
|
|
+ if (tenantDaya.size()<0) {
|
|
|
+ throw new BusinessException("无此租户,请联系管理员");
|
|
|
+ }
|
|
|
+ int platformAreaConut = baseMapper.platformSiteCount(platformAreaName,null,0,tenantDaya.get(0).getTenantId());
|
|
|
int startCurrent = (current - 1) * size;
|
|
|
- List<PlatformAreaVo> platformAreaVoSite = baseMapper.siteCount(platformAreaName,startCurrent,size,user.getUserId());
|
|
|
- List<PlatformAreaVo> platformAreaVoDevice =baseMapper.deviceCount(platformAreaName);
|
|
|
+ List<PlatformAreaVo> platformAreaVoSite = baseMapper.siteCount(platformAreaName,startCurrent,size,tenantDaya.get(0).getTenantId());
|
|
|
+ List<PlatformAreaVo> platformAreaVoDevice =baseMapper.deviceCount(platformAreaName,tenantDaya.get(0).getTenantId());
|
|
|
List<PlatformAreaVo> platformAreaList = new ArrayList<>();
|
|
|
for (int i = 0; i < platformAreaVoSite.size(); i++) {
|
|
|
PlatformAreaVo platformArea = new PlatformAreaVo();
|
|
@@ -114,6 +129,9 @@ public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMap
|
|
|
platformArea.setId(platformAreaVoSite.get(i).getId());
|
|
|
platformArea.setEnable(platformAreaVoSite.get(i).getEnable());
|
|
|
platformArea.setSiteCount(platformAreaVoSite.get(i).getSiteCount());
|
|
|
+ platformArea.setCreator(platformAreaVoSite.get(i).getCreator());
|
|
|
+ platformArea.setTenantId(platformAreaVoSite.get(i).getTenantId());
|
|
|
+ platformArea.setCreateTime(platformAreaVoSite.get(i).getCreateTime());
|
|
|
if (platformAreaVoDevice.size()>0){
|
|
|
Integer deviceCount = 0;
|
|
|
for (int j = 0; j < platformAreaVoDevice.size(); j++) {
|
|
@@ -130,9 +148,44 @@ public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMap
|
|
|
|
|
|
platformAreaList.add(platformArea);
|
|
|
}
|
|
|
- return new CommonPage<>(platformAreaList, platformAreaVoSiteOne.size(), size, current);
|
|
|
+ return new CommonPage<>(platformAreaList, platformAreaConut, size, current);
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// public CommonPage<PlatformAreaVo> platformAreaListOne(String platformAreaName,Integer current,Integer size){
|
|
|
+// SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+// List<PlatformAreaVo> platformAreaVoSiteOne = baseMapper.siteCount(platformAreaName,null,0,user.getUserId());
|
|
|
+// int startCurrent = (current - 1) * size;
|
|
|
+// List<PlatformAreaVo> platformAreaVoSite = baseMapper.siteCount(platformAreaName,startCurrent,size,user.getUserId());
|
|
|
+// List<PlatformAreaVo> platformAreaVoDevice =baseMapper.deviceCount(platformAreaName);
|
|
|
+// List<PlatformAreaVo> platformAreaList = new ArrayList<>();
|
|
|
+// for (int i = 0; i < platformAreaVoSite.size(); i++) {
|
|
|
+// PlatformAreaVo platformArea = new PlatformAreaVo();
|
|
|
+// platformArea.setPlatformAreaName(platformAreaVoSite.get(i).getPlatformAreaName());
|
|
|
+// platformArea.setPlatformAreaAddress(platformAreaVoSite.get(i).getPlatformAreaAddress());
|
|
|
+// platformArea.setPlatformAreaCode(platformAreaVoSite.get(i).getPlatformAreaCode());
|
|
|
+// platformArea.setId(platformAreaVoSite.get(i).getId());
|
|
|
+// platformArea.setEnable(platformAreaVoSite.get(i).getEnable());
|
|
|
+// platformArea.setSiteCount(platformAreaVoSite.get(i).getSiteCount());
|
|
|
+// if (platformAreaVoDevice.size()>0){
|
|
|
+// Integer deviceCount = 0;
|
|
|
+// for (int j = 0; j < platformAreaVoDevice.size(); j++) {
|
|
|
+// int id1=platformAreaVoSite.get(i).getId();
|
|
|
+// int id2=platformAreaVoDevice.get(j).getId();
|
|
|
+// if (id1==id2){
|
|
|
+// deviceCount = deviceCount + platformAreaVoDevice.get(j).getDeviceCount();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// platformArea.setDeviceCount(deviceCount);
|
|
|
+// }else {
|
|
|
+// platformArea.setDeviceCount(0);
|
|
|
+// }
|
|
|
+//
|
|
|
+// platformAreaList.add(platformArea);
|
|
|
+// }
|
|
|
+// return new CommonPage<>(platformAreaList, platformAreaVoSiteOne.size(), size, current);
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
public void platformAreaDel(int id){
|
|
|
PlatformArea platformArea = new PlatformArea();
|