Browse Source

处理Excel数据完善

王苗苗 2 months ago
parent
commit
b90836a3e1

+ 7 - 0
slibra-admin/src/main/java/com/slibra/web/controller/business/ExcelController.java

@@ -13,11 +13,13 @@ import com.slibra.business.service.IFrontService;
 import com.slibra.common.core.controller.BaseController;
 import com.slibra.common.core.domain.AjaxResult;
 import com.slibra.common.core.domain.entity.SysUser;
+import com.slibra.common.utils.StringUtils;
 import com.slibra.common.utils.poi.ExcelUtil;
 import io.micrometer.core.annotation.Timed;
 import lombok.extern.slf4j.Slf4j;
 import org.checkerframework.checker.units.qual.C;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -86,6 +88,7 @@ public class ExcelController extends BaseController {
      * @return
      */
     @GetMapping("/moreExcel2DB")
+//    @Transactional
     public String moreExcel2DB(){
         //Excel转JSON
         List<BZXQLHInfo> excelFormBZXQLH = getExcelFormBZXQLH();
@@ -98,6 +101,9 @@ public class ExcelController extends BaseController {
                 bzxqlhInfo.setNeighbourName(bzxqlhInfo.getArea() + bzxqlhInfo.getNeighbourName());
                 //2024年12月31日10:30:16 将区+泵站名称拼接作为泵站名称
                 bzxqlhInfo.setPumpingStationName(bzxqlhInfo.getArea() + bzxqlhInfo.getPumpingStationName());
+                //2024年12月31日11:23:14  解决楼号不存在,无法插入数据库的问题
+                if(StringUtils.isBlank(bzxqlhInfo.getBuildingName()))
+                    bzxqlhInfo.setBuildingName("无");
             }
             Map<String, List<BZXQLHInfo>> map = excelFormBZXQLH.stream().collect(Collectors.groupingBy(BZXQLHInfo::getNeighbourName));
             map.forEach((k, v) -> {
@@ -121,6 +127,7 @@ public class ExcelController extends BaseController {
                 if(CollectionUtils.isEmpty(pumpingStations)){
                     log.info("A第一次添加泵站信息,泵站名称是{}", pumpingStationName);
                     //新增泵站,然后再通过小区和楼号查询对应的数据,绑定关系
+                    tPumpingStation.setName(pumpingStationName);
                     this.tPumpingStationMapper.insertTPumpingStation(tPumpingStation);
                 }else{
                     log.info("Z已经添加过泵站信息,泵站名称是{}", pumpingStationName);

+ 4 - 4
slibra-admin/src/main/resources/application-local.yml

@@ -6,11 +6,11 @@ spring:
         druid:
             # 主库数据源
             master:
-#                url: jdbc:mysql://localhost:3306/big_model?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                url: jdbc:mysql://192.168.100.159:3306/libra_bot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://localhost:3306/big_model?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+#                url: jdbc:mysql://192.168.100.159:3306/libra_bot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
-#                password: 1234qwer
-                password: EKoAe3H8xybQKrFPApXM
+                password: 1234qwer
+#                password: EKoAe3H8xybQKrFPApXM
             # 从库数据源
             slave:
                 # 从数据源开关/默认关闭

+ 1 - 1
slibra-framework/src/main/java/com/slibra/framework/config/SecurityConfig.java

@@ -125,7 +125,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/websocket/**").permitAll()//websocket的
                 .antMatchers("/bigModel/**").permitAll()//2024年11月05日14:18:08 和曹永创交互的接口,不需要token即可访问
                 .antMatchers("/actuator/prometheus").permitAll()//2024年12月24日10:22:27 监控相关,不需要登录 prometheu需要从里面获取数据
-//                .antMatchers("/front/**","/grpc/**").permitAll()//临时测试的
+                .antMatchers("/excel/**").permitAll()//Excel解析数据
                 .antMatchers("/qiniuyun/**", "/out/**", "/business/daily").permitAll()//文件上传相关 外部接口等
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()