Pārlūkot izejas kodu

feat(新增字段调试通过): 上传调试

上传文件调试,自动生成线路和电塔表信息
gjs 3 gadi atpakaļ
vecāks
revīzija
c37d3b8d21

+ 6 - 4
src/main/java/com/macro/mall/tiny/modules/business/service/impl/AsyncHandler.java

@@ -1,6 +1,7 @@
 package com.macro.mall.tiny.modules.business.service.impl;
 
 import com.alibaba.excel.EasyExcel;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.collect.Lists;
 import com.macro.mall.tiny.common.exception.ApiException;
@@ -48,9 +49,6 @@ public class AsyncHandler {
     private KrBRegionProvinceServiceImpl krBRegionProvinceService;
 
     @Autowired
-    private KrBRegionCityServiceImpl krBRegionCityService;
-
-    @Autowired
     private KrBLineService krBLineService;
 
     @Autowired
@@ -75,7 +73,8 @@ public class AsyncHandler {
             if (provinceId == null) Asserts.fail("上传失败,省份不能为空,provinceId:" + provinceId);
             if (userDetails == null) Asserts.fail("上传失败,未获取到当前用户");
 
-            KrBRegionProvince province = krBRegionProvinceService.getById(provinceId);
+            LambdaQueryWrapper<KrBRegionProvince> provinceWrapper = new QueryWrapper<KrBRegionProvince>().lambda().eq(KrBRegionProvince::getProvinceId, provinceId);
+            KrBRegionProvince province = krBRegionProvinceService.getOne(provinceWrapper);
             String provinceName = province.getName();
 
             String username = userDetails.getUsername();
@@ -145,9 +144,11 @@ public class AsyncHandler {
                     } else if ("杆塔信息录入.xlsx".equals(SecDirectoryName) || "杆塔信息录入.xls".equals(SecDirectoryName)) {
                         List<TowerExcelModel> modelArrayList = EasyExcel.read(ais, TowerExcelModel.class, null).sheet().doReadSync();
                         KrBLine finalLine = line;
+                        Long finalUserId = userId;
                         towerList = modelArrayList.stream().map(model -> {
                             KrBTower tower = new KrBTower();
                             tower.setLineId(finalLine.getId());
+                            tower.setTowerIndex(model.getTowerIndex());
                             tower.setTowerName(model.getTowerName());
                             tower.setTowerNumber(model.getTowerNumber());
                             tower.setHardwareType(model.getHardwareType());
@@ -170,6 +171,7 @@ public class AsyncHandler {
                             tower.setServuceBegintime(model.getServuceBegintime());
                             tower.setRemark(model.getRemark());
                             tower.setHasFile(0);
+                            tower.setCreatorId(finalUserId);
                             tower.setCreateTime(new Date());
                             return tower;
                         }).collect(Collectors.toList());

+ 4 - 1
src/main/java/com/macro/mall/tiny/modules/business/service/impl/KrBLineServiceImpl.java

@@ -1,6 +1,8 @@
 package com.macro.mall.tiny.modules.business.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.macro.mall.tiny.common.exception.Asserts;
 import com.macro.mall.tiny.common.util.MyFileUtils;
@@ -80,7 +82,8 @@ public class KrBLineServiceImpl extends ServiceImpl<KrBLineMapper, KrBLine> impl
         boolean auth = AuthUtil.checkAccess(AuthUtil.ACCESS);
         KrBLine line = krBLineMapper.selectById(id);
         if (line == null) Asserts.fail("该线路不存在,id:" + id);
-        KrBRegionProvince province = krBRegionProvinceMapper.selectById(line.getProvinceId());
+        LambdaQueryWrapper<KrBRegionProvince> provinceWrapper = new QueryWrapper<KrBRegionProvince>().lambda().eq(KrBRegionProvince::getProvinceId, line.getProvinceId());
+        KrBRegionProvince province = krBRegionProvinceMapper.selectOne(provinceWrapper);
         String basePath = UploadConfig.powerPath +
                 province.getName() + UploadConfig.SEPARATOR +
                 line.getLineName();

+ 2 - 2
src/main/java/com/macro/mall/tiny/modules/business/service/impl/KrBRegionCityServiceImpl.java

@@ -29,7 +29,7 @@ public class KrBRegionCityServiceImpl extends ServiceImpl<KrBRegionCityMapper, K
     public List<KrBRegionCity> getCityListByprovince(String provinceId) {
         QueryWrapper<KrBRegionCity> cityQueryWrapper = new QueryWrapper<>();
         cityQueryWrapper.lambda().eq(KrBRegionCity::getProvinceId, provinceId);
-        krBRegionCityMapper.selectList(cityQueryWrapper);
-        return null;
+        List<KrBRegionCity> cities = krBRegionCityMapper.selectList(cityQueryWrapper);
+        return cities;
     }
 }

+ 9 - 2
src/main/java/com/macro/mall/tiny/modules/business/service/impl/KrBTowerServiceImpl.java

@@ -1,5 +1,7 @@
 package com.macro.mall.tiny.modules.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.macro.mall.tiny.common.exception.Asserts;
@@ -20,6 +22,8 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.io.FilenameFilter;
 import java.util.HashMap;
@@ -61,7 +65,8 @@ public class KrBTowerServiceImpl extends ServiceImpl<KrBTowerMapper, KrBTower> i
         if (tower == null) Asserts.fail("该电塔不存在,id:" + id);
         KrBLine line = krBLineMapper.selectById(tower.getLineId());
         if (line == null) Asserts.fail("该电塔所在的线路不存在,lineId:" + tower.getLineId());
-        KrBRegionProvince province = krBRegionProvinceMapper.selectById(line.getProvinceId());
+        LambdaQueryWrapper<KrBRegionProvince> provinceWrapper = new QueryWrapper<KrBRegionProvince>().lambda().eq(KrBRegionProvince::getProvinceId, line.getProvinceId());
+        KrBRegionProvince province = krBRegionProvinceMapper.selectOne(provinceWrapper);
         String basePath = UploadConfig.powerPath +
                 province.getName() + UploadConfig.SEPARATOR +
                 line.getLineName();
@@ -112,6 +117,7 @@ public class KrBTowerServiceImpl extends ServiceImpl<KrBTowerMapper, KrBTower> i
     }
 
     @Override
+    @Transactional(propagation = Propagation.REQUIRED)
     public void setHasFile(List<KrBTower> towerList, AdminUserDetails userDetails) {
         if (towerList == null || towerList.size() == 0) {
             return;
@@ -119,7 +125,8 @@ public class KrBTowerServiceImpl extends ServiceImpl<KrBTowerMapper, KrBTower> i
         boolean access = AuthUtil.checkAccess(userDetails, AuthUtil.ACCESS);
         KrBTower firstTower = towerList.get(0);
         KrBLine line = krBLineMapper.selectById(firstTower.getLineId());
-        KrBRegionProvince province = krBRegionProvinceMapper.selectById(line.getProvinceId());
+        LambdaQueryWrapper<KrBRegionProvince> provinceWrapper = new QueryWrapper<KrBRegionProvince>().lambda().eq(KrBRegionProvince::getProvinceId, line.getProvinceId());
+        KrBRegionProvince province = krBRegionProvinceMapper.selectOne(provinceWrapper);
         String basePath = UploadConfig.powerPath +
                 province.getName() + UploadConfig.SEPARATOR +
                 line.getLineName();

+ 8 - 7
src/main/java/com/macro/mall/tiny/modules/ums/service/impl/UmsRoleServiceImpl.java

@@ -25,7 +25,7 @@ import java.util.List;
  * Created by macro on 2018/9/30.
  */
 @Service
-public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper,UmsRole>implements UmsRoleService {
+public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper, UmsRole> implements UmsRoleService {
     @Autowired
     private UmsAdminCacheService adminCacheService;
     @Autowired
@@ -36,6 +36,7 @@ public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper,UmsRole>implem
     private UmsMenuMapper menuMapper;
     @Autowired
     private UmsResourceMapper resourceMapper;
+
     @Override
     public boolean create(UmsRole role) {
         role.setCreateTime(new Date());
@@ -53,13 +54,13 @@ public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper,UmsRole>implem
 
     @Override
     public Page<UmsRole> list(String keyword, Integer pageSize, Integer pageNum) {
-        Page<UmsRole> page = new Page<>(pageNum,pageSize);
+        Page<UmsRole> page = new Page<>(pageNum, pageSize);
         QueryWrapper<UmsRole> wrapper = new QueryWrapper<>();
         LambdaQueryWrapper<UmsRole> lambda = wrapper.lambda();
-        if(StrUtil.isNotEmpty(keyword)){
-            lambda.like(UmsRole::getName,keyword);
+        if (StrUtil.isNotEmpty(keyword)) {
+            lambda.like(UmsRole::getName, keyword);
         }
-        return page(page,wrapper);
+        return page(page, wrapper);
     }
 
     @Override
@@ -81,7 +82,7 @@ public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper,UmsRole>implem
     public int allocMenu(Long roleId, List<Long> menuIds) {
         //先删除原有关系
         QueryWrapper<UmsRoleMenuRelation> wrapper = new QueryWrapper<>();
-        wrapper.lambda().eq(UmsRoleMenuRelation::getRoleId,roleId);
+        wrapper.lambda().eq(UmsRoleMenuRelation::getRoleId, roleId);
         roleMenuRelationService.remove(wrapper);
         //批量插入新关系
         List<UmsRoleMenuRelation> relationList = new ArrayList<>();
@@ -99,7 +100,7 @@ public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper,UmsRole>implem
     public int allocResource(Long roleId, List<Long> resourceIds) {
         //先删除原有关系
         QueryWrapper<UmsRoleResourceRelation> wrapper = new QueryWrapper<>();
-        wrapper.lambda().eq(UmsRoleResourceRelation::getRoleId,roleId);
+        wrapper.lambda().eq(UmsRoleResourceRelation::getRoleId, roleId);
         roleResourceRelationService.remove(wrapper);
         //批量插入新关系
         List<UmsRoleResourceRelation> relationList = new ArrayList<>();

+ 2 - 2
src/main/resources/application-dev.yml

@@ -1,8 +1,8 @@
 spring:
   datasource:
-    url: jdbc:mysql://localhost:3306/power_system?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://localhost:3306/file_collect?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
     username: root
-    password: root
+    password: abc45628
   redis:
     host: localhost # Redis服务器地址
     database: 0 # Redis数据库索引(默认为0)

+ 2 - 2
src/main/resources/application-prod.yml

@@ -1,8 +1,8 @@
 spring:
   datasource:
-    url: jdbc:mysql://localhost:3306/power_system?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://localhost:3306/file_collect?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
     username: root
-    password: abc45628
+    password: root
   redis:
     host: localhost # Redis服务器地址
     database: 0 # Redis数据库索引(默认为0)