Procházet zdrojové kódy

巡更系统优化

hanzhengyi před 1 týdnem
rodič
revize
82e989d6d0

+ 15 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionSiteController.java

@@ -13,6 +13,7 @@ import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import com.usky.fire.service.vo.PatrolInspectionSiteExportVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -156,5 +157,19 @@ public class PatrolInspectionSiteController {
         ExcelUtil<PatrolInspectionSiteExportVo> util = new ExcelUtil<PatrolInspectionSiteExportVo>(PatrolInspectionSiteExportVo.class);
         util.exportExcel(response, list, "巡检地点列表", "巡检地点列表");
     }
+
+    /**
+     * 巡检点位-导入
+     *
+     * @param file 导入文件
+     * @return
+     * @throws Exception
+     */
+    @Log(title = "巡检地点", businessType = BusinessType.IMPORT)
+    @PostMapping("/patrolInspectionSiteImport")
+    public ApiResult<Void> patrolInspectionSiteImport(@RequestParam("file") MultipartFile file){
+        patrolInspectionSiteService.patrolInspectionSiteImport(file);
+        return ApiResult.success();
+    }
 }
 

+ 3 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionSiteService.java

@@ -6,6 +6,7 @@ import com.usky.fire.domain.PatrolInspectionSite;
 import com.usky.fire.domain.PatrolInspectionSiteContent;
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import com.usky.fire.service.vo.PatrolInspectionSiteExportVo;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -43,4 +44,6 @@ public interface PatrolInspectionSiteService extends CrudService<PatrolInspectio
      */
     List<Integer> siteIdList(List<Integer> areaIdList);
 
+    void patrolInspectionSiteImport(MultipartFile multipartFile);
+
 }

+ 1 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionContentServiceImpl.java

@@ -102,8 +102,7 @@ public class PatrolInspectionContentServiceImpl extends AbstractCrudService<Patr
                 PatrolInspectionContentOption contentOption = new PatrolInspectionContentOption();
                 contentOption.setOptionName(patrolInspectionContentVo.getContentOptionList().get(i).getOptionName());
                 contentOption.setContentId(patrolInspectionContentVo.getId());
-                if (patrolInspectionContentVo.getContentOptionList().get(i).getId() != 0 &&
-                        patrolInspectionContentVo.getContentOptionList().get(i).getId() != null) {
+                if (patrolInspectionContentVo.getContentOptionList().get(i).getId() != null && patrolInspectionContentVo.getContentOptionList().get(i).getId() != 0) {
                     contentOption.setId(patrolInspectionContentVo.getContentOptionList().get(i).getId());
                     contentOption.setEnable(1);
                     contentOptionService.updateById(contentOption);

+ 67 - 14
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionSiteServiceImpl.java

@@ -1,12 +1,15 @@
 package com.usky.fire.service.impl;
 
-import com.alibaba.nacos.common.utils.CollectionUtils;
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.datascope.annotation.DataScope;
 import com.ruoyi.common.datascope.context.DataScopeContextHolder;
 import com.usky.common.core.bean.CommonPage;
 import com.usky.common.core.exception.BusinessException;
+import com.usky.common.core.util.BeanMapperUtils;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.*;
@@ -19,17 +22,18 @@ import com.usky.fire.service.util.OnlineMethod;
 import com.usky.fire.service.vo.DataCountVo;
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import com.usky.fire.service.vo.PatrolInspectionSiteExportVo;
+import com.usky.fire.service.vo.PatrolInspectionSiteImportVo;
 import com.usky.system.model.LoginUser;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -194,16 +198,24 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
     @Override
     @Transactional
     public void addSiteContent(List<PatrolInspectionSiteContent> siteContentList) {
-        LambdaQueryWrapper<PatrolInspectionSiteContent> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionSiteContent::getSiteId, siteContentList.get(0).getSiteId());
-        List<PatrolInspectionSiteContent> siteContenListOne = siteContentService.list(queryWrapper);
-        if (siteContenListOne.size() > 0) {
-            for (int i = 0; i < siteContenListOne.size(); i++) {
-                siteContentService.removeById(siteContenListOne.get(i).getId());
+        List<Integer> list = new ArrayList<>();
+        List<Integer> list2 = new ArrayList<>();
+        if (siteContentList.size()>0){
+            for (int i = 0; i < siteContentList.size(); i++) {
+                list.add(siteContentList.get(i).getSiteId());
+            }
+            list2 = removeDuplicatesUsingHashSet(list);
+            LambdaQueryWrapper<PatrolInspectionSiteContent> queryWrapper = Wrappers.lambdaQuery();
+            queryWrapper.in(PatrolInspectionSiteContent::getSiteId, list2);
+            List<PatrolInspectionSiteContent> siteContenListOne = siteContentService.list(queryWrapper);
+            if (siteContenListOne.size() > 0) {
+                for (int i = 0; i < siteContenListOne.size(); i++) {
+                    siteContentService.removeById(siteContenListOne.get(i).getId());
+                }
+            }
+            for (int i = 0; i < siteContentList.size(); i++) {
+                siteContentService.save(siteContentList.get(i));
             }
-        }
-        for (int i = 0; i < siteContentList.size(); i++) {
-            siteContentService.save(siteContentList.get(i));
         }
     }
 
@@ -285,4 +297,45 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
         }
         return siteIdList;
     }
+
+    @Override
+    public void patrolInspectionSiteImport(MultipartFile multipartFile) {
+        ImportParams params = new ImportParams();
+        params.setHeadRows(1);
+        String err="文件导入失败";
+        try {
+            List<PatrolInspectionSiteImportVo> patrolInspectionSiteImportVos =
+                    ExcelImportUtil.importExcel(multipartFile.getInputStream(),
+                    PatrolInspectionSiteImportVo.class, params);
+            if (CollectionUtils.isNotEmpty(patrolInspectionSiteImportVos)){
+                int rot=0;
+                for (PatrolInspectionSiteImportVo patrolInspectionSiteImportVo:patrolInspectionSiteImportVos) {
+                    PatrolInspectionSite patrolInspectionSite = BeanMapperUtils.map(patrolInspectionSiteImportVo, PatrolInspectionSite.class);
+                    patrolInspectionSite.setEnable(1);
+                    patrolInspectionSite.setCreator(SecurityUtils.getUsername());
+                    patrolInspectionSite.setCollector(SecurityUtils.getLoginUser().getSysUser().getNickName());
+                    patrolInspectionSite.setCreateTime(LocalDateTime.now());
+                    patrolInspectionSite.setTenantId(SecurityUtils.getTenantId());
+                    patrolInspectionSite.setSiteType(2);
+                    try{
+                        this.save(patrolInspectionSite);
+                    }catch (Exception e){
+                        int h=rot+2;
+                        err="文件导入失败,第"+h+"行数据导入失败";
+                        throw  new BusinessException(err);
+                    }
+                    rot++;
+                }
+            }else {
+                err="文件不能为空";
+                throw new BusinessException(err);
+            }
+        }catch (Exception e){
+            throw  new BusinessException(e.getMessage());
+        }
+    }
+    public static <T> List<T> removeDuplicatesUsingHashSet(List<T> list) {
+        Set<T> set = new HashSet<>(list);
+        return new ArrayList<>(set);
+    }
 }

+ 51 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionSiteImportVo.java

@@ -0,0 +1,51 @@
+package com.usky.fire.service.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author han
+ * @since 2025-04-24
+ */
+@Data
+public class PatrolInspectionSiteImportVo{
+
+    /**
+     * 地点名称
+     */
+    @Excel(name = "地点名称")
+    private String siteName;
+
+    /**
+     * 地点号码
+     */
+    @Excel(name = "地点号码")
+    private String siteNubmber;
+
+    /**
+     * 经度
+     */
+    @Excel(name = "经度")
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    @Excel(name = "纬度")
+    private String latitude;
+
+    /**
+     * 图片地址
+     */
+    @Excel(name = "图片地址")
+    private String pictureUrl;
+
+}

+ 21 - 0
service-ids/service-ids-biz/src/main/java/com/usky/ids/controller/web/AccessEntryExitRecordController.java

@@ -0,0 +1,21 @@
+package com.usky.ids.controller.web;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 车辆进出记录 前端控制器
+ * </p>
+ *
+ * @author han
+ * @since 2025-03-26
+ */
+@Controller
+@RequestMapping("/accessEntryExitRecord")
+public class AccessEntryExitRecordController {
+
+}
+

+ 86 - 0
service-ids/service-ids-biz/src/main/java/com/usky/ids/domain/AccessEntryExitRecord.java

@@ -0,0 +1,86 @@
+package com.usky.ids.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 车辆进出记录
+ * </p>
+ *
+ * @author han
+ * @since 2025-03-26
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class AccessEntryExitRecord implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 车辆进出记录ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 车辆颜色
+     */
+    private String carColor;
+
+    /**
+     * 车牌
+     */
+    private String licensePlate;
+
+    /**
+     * 进出场类型(1进 2出)
+     */
+    private String actionDirection;
+
+    /**
+     * 监控点唯一编码
+     */
+    private String cameraIndexCode;
+
+    /**
+     * 监控点名称
+     */
+    private String cameraName;
+
+    /**
+     * 进/出场时间
+     */
+    private LocalDateTime recordTime;
+
+    /**
+     * 创建者
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新者
+     */
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+
+}

+ 16 - 0
service-ids/service-ids-biz/src/main/java/com/usky/ids/mapper/AccessEntryExitRecordMapper.java

@@ -0,0 +1,16 @@
+package com.usky.ids.mapper;
+
+import com.usky.ids.domain.AccessEntryExitRecord;
+import com.usky.common.mybatis.core.CrudMapper;
+
+/**
+ * <p>
+ * 车辆进出记录 Mapper 接口
+ * </p>
+ *
+ * @author han
+ * @since 2025-03-26
+ */
+public interface AccessEntryExitRecordMapper extends CrudMapper<AccessEntryExitRecord> {
+
+}

+ 16 - 0
service-ids/service-ids-biz/src/main/java/com/usky/ids/service/AccessEntryExitRecordService.java

@@ -0,0 +1,16 @@
+package com.usky.ids.service;
+
+import com.usky.ids.domain.AccessEntryExitRecord;
+import com.usky.common.mybatis.core.CrudService;
+
+/**
+ * <p>
+ * 车辆进出记录 服务类
+ * </p>
+ *
+ * @author han
+ * @since 2025-03-26
+ */
+public interface AccessEntryExitRecordService extends CrudService<AccessEntryExitRecord> {
+
+}

+ 20 - 0
service-ids/service-ids-biz/src/main/java/com/usky/ids/service/impl/AccessEntryExitRecordServiceImpl.java

@@ -0,0 +1,20 @@
+package com.usky.ids.service.impl;
+
+import com.usky.ids.domain.AccessEntryExitRecord;
+import com.usky.ids.mapper.AccessEntryExitRecordMapper;
+import com.usky.ids.service.AccessEntryExitRecordService;
+import com.usky.common.mybatis.core.AbstractCrudService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 车辆进出记录 服务实现类
+ * </p>
+ *
+ * @author han
+ * @since 2025-03-26
+ */
+@Service
+public class AccessEntryExitRecordServiceImpl extends AbstractCrudService<AccessEntryExitRecordMapper, AccessEntryExitRecord> implements AccessEntryExitRecordService {
+
+}

+ 21 - 0
service-ids/service-ids-biz/src/main/resources/mapper/ids/AccessEntryExitRecordMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.usky.ids.mapper.AccessEntryExitRecordMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.usky.ids.domain.AccessEntryExitRecord">
+        <id column="id" property="id" />
+        <result column="car_color" property="carColor" />
+        <result column="license_plate" property="licensePlate" />
+        <result column="action_direction" property="actionDirection" />
+        <result column="camera_index_code" property="cameraIndexCode" />
+        <result column="camera_name" property="cameraName" />
+        <result column="record_time" property="recordTime" />
+        <result column="create_by" property="createBy" />
+        <result column="create_time" property="createTime" />
+        <result column="update_by" property="updateBy" />
+        <result column="update_time" property="updateTime" />
+        <result column="remark" property="remark" />
+    </resultMap>
+
+</mapper>