Browse Source

移动端巡检点位详情接口修改

jichaobo 2 years ago
parent
commit
fdf0d4c2cc

+ 1 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/MybatisGeneratorUtils.java

@@ -71,7 +71,7 @@ public class MybatisGeneratorUtils {
         // strategy.setTablePrefix("t_"); // 表名前缀
         strategy.setEntityLombokModel(true); //使用lombok
         //修改自己想要生成的表
-        strategy.setInclude("alarm_detector");  // 逆向工程使用的表   如果要生成多个,这里可以传入String[]
+        strategy.setInclude("base_device");  // 逆向工程使用的表   如果要生成多个,这里可以传入String[]
         mpg.setStrategy(strategy);
 
         // 关闭默认 xml 生成,调整生成 至 根目录

+ 21 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/BaseDeviceController.java

@@ -0,0 +1,21 @@
+package com.usky.fire.controller.web;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-08-15
+ */
+@Controller
+@RequestMapping("/baseDevice")
+public class BaseDeviceController {
+
+}
+

+ 134 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/BaseDevice.java

@@ -0,0 +1,134 @@
+package com.usky.fire.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import java.time.LocalDate;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-08-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class BaseDevice implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 设备信息表主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
+    /**
+     * 安装位置
+     */
+    private String installAddress;
+
+    /**
+     * 设备类型
+     */
+    private Integer deviceType;
+
+    /**
+     * 产品ID
+     */
+    private Integer productId;
+
+    /**
+     * 所属楼层
+     */
+    private Integer floor;
+
+    /**
+     * 物联网卡号
+     */
+    private String simNum;
+
+    /**
+     * 通信方式
+     */
+    private Integer communicatMode;
+
+    /**
+     * 设备所属模型坐标
+     */
+    private String modelPosition;
+
+    /**
+     * 防火分区
+     */
+    private String fireZone;
+
+    /**
+     * 倍率
+     */
+    private Integer magnification;
+
+    /**
+     * 解析方法
+     */
+    private String analyticMethod;
+
+    /**
+     * 安装时间
+     */
+    private LocalDate installTime;
+
+    /**
+     * 安装人
+     */
+    private String installPerson;
+
+    /**
+     * 使能标识
+     */
+    private Integer enable;
+
+    /**
+     * 所属单位ID
+     */
+    private Integer companyId;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 更新人
+     */
+    private String updatePerson;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+
+}

+ 6 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionSite.java

@@ -130,5 +130,11 @@ public class PatrolInspectionSite implements Serializable {
     @TableField(exist = false)
     private String remarks;
 
+    /**
+     * 子计划ID
+     */
+    @TableField(exist = false)
+    private Integer planSonId;
+
 
 }

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/BaseDeviceMapper.java

@@ -0,0 +1,16 @@
+package com.usky.fire.mapper;
+
+import com.usky.fire.domain.BaseDevice;
+import com.usky.common.mybatis.core.CrudMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-08-15
+ */
+public interface BaseDeviceMapper extends CrudMapper<BaseDevice> {
+
+}

+ 6 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionPlanMapper.java

@@ -2,8 +2,11 @@ package com.usky.fire.mapper;
 
 import com.usky.common.mybatis.core.CrudMapper;
 import com.usky.fire.domain.PatrolInspectionPlan;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * <p>
  * Mapper 接口
@@ -14,5 +17,7 @@ import org.springframework.stereotype.Repository;
  */
 @Repository
 public interface PatrolInspectionPlanMapper extends CrudMapper<PatrolInspectionPlan> {
-
+    int planSiteCount(@Param("personnelIdList") List<Integer> personnelIdList,
+                      @Param("siteId") Integer siteId,
+                      @Param("inspectionDate") String inspectionDate);
 }

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/BaseDeviceService.java

@@ -0,0 +1,16 @@
+package com.usky.fire.service;
+
+import com.usky.fire.domain.BaseDevice;
+import com.usky.common.mybatis.core.CrudService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-08-15
+ */
+public interface BaseDeviceService extends CrudService<BaseDevice> {
+
+}

+ 20 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/BaseDeviceServiceImpl.java

@@ -0,0 +1,20 @@
+package com.usky.fire.service.impl;
+
+import com.usky.fire.domain.BaseDevice;
+import com.usky.fire.mapper.BaseDeviceMapper;
+import com.usky.fire.service.BaseDeviceService;
+import com.usky.common.mybatis.core.AbstractCrudService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-08-15
+ */
+@Service
+public class BaseDeviceServiceImpl extends AbstractCrudService<BaseDeviceMapper, BaseDevice> implements BaseDeviceService {
+
+}

+ 27 - 18
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanSonServiceImpl.java

@@ -1,7 +1,6 @@
 package com.usky.fire.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.usky.common.core.exception.BusinessException;
 import com.usky.common.core.util.StringUtils;
@@ -132,8 +131,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
         if (personnelIdList.size() > 0) {
             LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
             queryWrapper.eq(PatrolInspectionSite::getEnable, 1);
-            queryWrapper
-                    .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId())
+            queryWrapper.eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId())
                     .eq(PatrolInspectionSite::getSiteNubmber, siteNubmber);
             List<PatrolInspectionSite> siteList = patrolInspectionSiteService.list(queryWrapper);
             if (siteList.size() <= 0) {
@@ -177,6 +175,11 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
 
     @Override
     public Map<String, Object> siteDetails(Integer siteId, String siteNubmber, Integer planSonId) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        List<Integer> personnelIdList = this.getpersonId();
+        if (personnelIdList.size() <= 0) {
+            throw new BusinessException("该地点不在计划中");
+        }
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
         queryWrapper.eq(PatrolInspectionSite::getEnable, 1);
@@ -190,23 +193,29 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
         if (siteList.size() <= 0) {
             throw new BusinessException("无效地点,请联系管理人员添加点位");
         }
-        List<PatrolInspectionRecordPicture> recordPictureList = new ArrayList<>();
-        if (planSonId != null && planSonId != 0) {
-            LambdaQueryWrapper<PatrolInspectionRecord> query = Wrappers.lambdaQuery();
-            query.eq(PatrolInspectionRecord::getSiteId, siteId)
-                    .eq(PatrolInspectionRecord::getPlanSonId, planSonId);
-            List<PatrolInspectionRecord> recordList = patrolInspectionRecordMapper.selectList(query);
-            if (CollectionUtils.isNotEmpty(recordList)){
-                siteList.get(0).setRemarks(recordList.get(0).getRemarks());
-                LambdaQueryWrapper<PatrolInspectionRecordPicture> queryOne = Wrappers.lambdaQuery();
-                queryOne.eq(PatrolInspectionRecordPicture::getRecordId, recordList.get(0).getId());
-                recordPictureList = patrolInspectionRecordPictureService.list(queryOne);
-            }
+        int planSonSiteCount = patrolInspectionPlanMapper.planSiteCount(personnelIdList, siteList.get(0).getId(), dateFormat.format(new Date()));
+        if (planSonSiteCount <= 0) {
+            throw new BusinessException("此地点尚未采集,请采集该点位");
         }
-
-        siteList.get(0).setRecordPictureList(recordPictureList);
+        List<PatrolInspectionRecordPicture> recordPictureList = new ArrayList<>();
+//        if (planSonId != null && planSonId != 0) {
+//            LambdaQueryWrapper<PatrolInspectionRecord> query = Wrappers.lambdaQuery();
+//            query.eq(PatrolInspectionRecord::getSiteId, siteId)
+//                    .eq(PatrolInspectionRecord::getPlanSonId, planSonId);
+//            List<PatrolInspectionRecord> recordList = patrolInspectionRecordMapper.selectList(query);
+//            if (CollectionUtils.isNotEmpty(recordList)) {
+//                siteList.get(0).setRemarks(recordList.get(0).getRemarks());
+//                LambdaQueryWrapper<PatrolInspectionRecordPicture> queryOne = Wrappers.lambdaQuery();
+//                queryOne.eq(PatrolInspectionRecordPicture::getRecordId, recordList.get(0).getId());
+//                recordPictureList = patrolInspectionRecordPictureService.list(queryOne);
+//            }
+//        }
+
+//        siteList.get(0).setRecordPictureList(recordPictureList);
         List<PatrolInspectionContentVo> contentList = this.contentList(siteList.get(0).getId());
         siteList.get(0).setContentCount(contentList.size());
+        siteList.get(0).setPlanSonId(planSonId);
+
         Map<String, Object> map = new HashMap<>();
         map.put("siteList", siteList);
         map.put("contentList", contentList);
@@ -444,7 +453,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
                     List<PatrolInspectionRecordPicture> PatrolInspectionRecordPictureList = new ArrayList<>();
                     for (int j = 0; j < recordPictureList.size(); j++) {
                         PatrolInspectionRecordPicture patrolInspectionRecordPicture = new PatrolInspectionRecordPicture();
-                        if (recordList.get(i).getId()==recordPictureList.get(j).getRecordId()){
+                        if (recordList.get(i).getId() == recordPictureList.get(j).getRecordId()) {
                             patrolInspectionRecordPicture.setRecordId(recordPictureList.get(j).getRecordId());
                             patrolInspectionRecordPicture.setPictureUrl(recordPictureList.get(j).getPictureUrl());
                             patrolInspectionRecordPicture.setId(recordPictureList.get(j).getId());

+ 30 - 0
service-fire/service-fire-biz/src/main/resources/mapper/fire/BaseDeviceMapper.xml

@@ -0,0 +1,30 @@
+<?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.fire.mapper.BaseDeviceMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.usky.fire.domain.BaseDevice">
+        <id column="id" property="id" />
+        <result column="device_code" property="deviceCode" />
+        <result column="device_name" property="deviceName" />
+        <result column="install_address" property="installAddress" />
+        <result column="device_type" property="deviceType" />
+        <result column="product_id" property="productId" />
+        <result column="floor" property="floor" />
+        <result column="sim_num" property="simNum" />
+        <result column="communicat_mode" property="communicatMode" />
+        <result column="model_position" property="modelPosition" />
+        <result column="fire_zone" property="fireZone" />
+        <result column="magnification" property="magnification" />
+        <result column="analytic_method" property="analyticMethod" />
+        <result column="install_time" property="installTime" />
+        <result column="install_person" property="installPerson" />
+        <result column="enable" property="enable" />
+        <result column="company_id" property="companyId" />
+        <result column="create_time" property="createTime" />
+        <result column="update_time" property="updateTime" />
+        <result column="update_person" property="updatePerson" />
+        <result column="creator" property="creator" />
+    </resultMap>
+
+</mapper>

+ 33 - 19
service-fire/service-fire-biz/src/main/resources/mapper/fire/PatrolInspectionPlanMapper.xml

@@ -4,24 +4,38 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.usky.fire.domain.PatrolInspectionPlan">
-        <id column="id" property="id" />
-        <result column="plan_name" property="planName" />
-        <result column="start_date" property="startDate" />
-        <result column="end_date" property="endDate" />
-        <result column="area_id" property="areaId" />
-        <result column="plan_type" property="planType" />
-        <result column="plan_cycle" property="planCycle" />
-        <result column="plan_frequency" property="planFrequency" />
-        <result column="lap_time" property="lapTime" />
-        <result column="interval_time" property="intervalTime" />
-        <result column="plan_describe" property="planDescribe" />
-        <result column="create_time" property="createTime" />
-        <result column="creator" property="creator" />
-        <result column="enable" property="enable" />
-        <result column="tenant_id" property="tenantId" />
-        <result column="company_id" property="companyId" />
-        <result column="rest_day" property="restDay" />
-        <result column="week_count" property="weekCount" />
+        <id column="id" property="id"/>
+        <result column="plan_name" property="planName"/>
+        <result column="start_date" property="startDate"/>
+        <result column="end_date" property="endDate"/>
+        <result column="area_id" property="areaId"/>
+        <result column="plan_type" property="planType"/>
+        <result column="plan_cycle" property="planCycle"/>
+        <result column="plan_frequency" property="planFrequency"/>
+        <result column="lap_time" property="lapTime"/>
+        <result column="interval_time" property="intervalTime"/>
+        <result column="plan_describe" property="planDescribe"/>
+        <result column="create_time" property="createTime"/>
+        <result column="creator" property="creator"/>
+        <result column="enable" property="enable"/>
+        <result column="tenant_id" property="tenantId"/>
+        <result column="company_id" property="companyId"/>
+        <result column="rest_day" property="restDay"/>
+        <result column="week_count" property="weekCount"/>
     </resultMap>
-
+    <select id="planSiteCount" resultType="int">
+        SELECT
+        count(1)
+        FROM
+        patrol_inspection_plan_son AS p
+        JOIN patrol_inspection_plan_site_son AS ps ON p.id = ps.plan_id
+        <where>
+            ps.site_id =#{siteId}
+            AND p.inspection_date = #{inspectionDate}
+            AND p.personnel_id in
+            <foreach item="item" collection="personnelIdList" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </where>
+    </select>
 </mapper>