|
@@ -1,11 +1,31 @@
|
|
|
package com.macro.mall.tiny.modules.business.service.impl;
|
|
|
|
|
|
-import com.macro.mall.tiny.modules.business.model.BTower;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.macro.mall.tiny.common.exception.Asserts;
|
|
|
+import com.macro.mall.tiny.common.util.MyFileUtils;
|
|
|
+import com.macro.mall.tiny.config.UploadConfig;
|
|
|
+import com.macro.mall.tiny.domain.AdminUserDetails;
|
|
|
+import com.macro.mall.tiny.modules.business.enums.DirectoryEnum;
|
|
|
+import com.macro.mall.tiny.modules.business.mapper.BLineMapper;
|
|
|
+import com.macro.mall.tiny.modules.business.mapper.BProvinceMapper;
|
|
|
import com.macro.mall.tiny.modules.business.mapper.BTowerMapper;
|
|
|
+import com.macro.mall.tiny.modules.business.model.BLine;
|
|
|
+import com.macro.mall.tiny.modules.business.model.BProvince;
|
|
|
+import com.macro.mall.tiny.modules.business.model.BTower;
|
|
|
import com.macro.mall.tiny.modules.business.service.BTowerService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.macro.mall.tiny.modules.ums.service.UmsAdminService;
|
|
|
+import com.macro.mall.tiny.security.util.AuthUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FilenameFilter;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 塔表 服务实现类
|
|
@@ -17,4 +37,70 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class BTowerServiceImpl extends ServiceImpl<BTowerMapper, BTower> implements BTowerService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ BTowerMapper towerMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ BLineMapper lineMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ BProvinceMapper provinceMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long saveAndUpdate(List<BTower> towerList) {
|
|
|
+ return towerMapper.saveAndUpdate(towerList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, List<String>> getData(Long id, AdminUserDetails userDetails) {
|
|
|
+ if (userDetails == null) {
|
|
|
+ Asserts.fail("查询失败,未获取到当前用户");
|
|
|
+ }
|
|
|
+ boolean auth = AuthUtil.checkAccess(userDetails, "/visit");
|
|
|
+
|
|
|
+ HashMap<String, List<String>> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ BTower tower = towerMapper.selectById(id);
|
|
|
+ if (tower == null) Asserts.fail("该电塔不存在,id:" + id);
|
|
|
+ BLine line = lineMapper.selectById(tower.getLineId());
|
|
|
+ if (line == null) Asserts.fail("该电塔所在的线路不存在,lineId:" + tower.getLineId());
|
|
|
+ BProvince province = provinceMapper.selectById(line.getProvinceId());
|
|
|
+ String basePath = UploadConfig.powerPath +
|
|
|
+ province.getProvince() + UploadConfig.SEPARATOR +
|
|
|
+ line.getName();
|
|
|
+
|
|
|
+ String SecBasePath;
|
|
|
+ String ThirdBasePath;
|
|
|
+ List<String> sonList;
|
|
|
+ // 获取3杆塔图纸
|
|
|
+ String shape = tower.getShape();
|
|
|
+ int lastIndex = shape.lastIndexOf('-');
|
|
|
+ if (lastIndex > 0) {
|
|
|
+ shape = shape.substring(0, lastIndex).replace('/', ' ');
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(shape)) {
|
|
|
+ SecBasePath = MyFileUtils.getAuthFilePath(basePath, DirectoryEnum.TOWER_PIC.getName(), auth);
|
|
|
+ ThirdBasePath = MyFileUtils.getAuthFilePath(SecBasePath, shape, auth);
|
|
|
+ sonList = MyFileUtils.getSonPaths(ThirdBasePath, auth);
|
|
|
+ } else {
|
|
|
+ sonList = Lists.newArrayList();
|
|
|
+ }
|
|
|
+ resultMap.put("shapeFileList", sonList);
|
|
|
+
|
|
|
+ // 获取6地线金具串图
|
|
|
+ SecBasePath = MyFileUtils.getAuthFilePath(basePath, DirectoryEnum.EARTH_WIRE_HARD_PIC.getName(), auth);
|
|
|
+ String hardwareType = tower.getHardwareType().replace('/', ' ');
|
|
|
+ FilenameFilter hardwareTypeFilter = (dir, name) -> name.startsWith(hardwareType) || (name.startsWith(UploadConfig.AUTH_STR + hardwareType) && auth);
|
|
|
+ sonList = MyFileUtils.getSonPaths(SecBasePath, hardwareTypeFilter, auth);
|
|
|
+ resultMap.put("hardwareFileList", sonList);
|
|
|
+
|
|
|
+ // 获取7班组巡检照片
|
|
|
+ SecBasePath = MyFileUtils.getAuthFilePath(basePath, DirectoryEnum.TEAM_CHECK_PIC.getName(), auth);
|
|
|
+ String towerName = tower.getName();
|
|
|
+ ThirdBasePath = MyFileUtils.getAuthFilePath(SecBasePath, towerName, auth);
|
|
|
+ sonList = MyFileUtils.getSonPaths(ThirdBasePath, auth);
|
|
|
+ resultMap.put("teamCheckFileList", sonList);
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
}
|