Browse Source

运行监控及应急物资相关代码

Zimo 8 giờ trước cách đây
mục cha
commit
8e198714b4

+ 9 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/emergency/vo/QhseEmergencyCertPageReqVO.java

@@ -1,10 +1,12 @@
 package cn.iocoder.yudao.module.pms.controller.admin.qhse.emergency.vo;
 
-import lombok.*;
-import java.util.*;
-import io.swagger.v3.oas.annotations.media.Schema;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
+
 import java.time.LocalDateTime;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -50,4 +52,8 @@ public class QhseEmergencyCertPageReqVO extends PageParam {
     @Schema(description = "部门名称", example = "赵六")
     private String deptName;
 
+    @Schema(description = "过期")
+    private Boolean expired;
+    @Schema(description = "预警")
+    private Boolean alertWarn;
 }

+ 8 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/emergency/vo/QhseEmergencyCertRespVO.java

@@ -1,11 +1,11 @@
 package cn.iocoder.yudao.module.pms.controller.admin.qhse.emergency.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.*;
-import java.util.*;
-import org.springframework.format.annotation.DateTimeFormat;
+import lombok.Data;
+
 import java.time.LocalDateTime;
-import com.alibaba.excel.annotation.*;
 
 @Schema(description = "管理后台 - QHSE应急物资检测证书 Response VO")
 @Data
@@ -60,4 +60,8 @@ public class QhseEmergencyCertRespVO {
     @ExcelProperty("部门名称")
     private String deptName;
 
+    @Schema(description = "过期")
+    private Boolean expired;
+    @Schema(description = "预警")
+    private Boolean alertWarn;
 }

+ 4 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/emergency/vo/QhseEmergencyCertSaveReqVO.java

@@ -50,4 +50,8 @@ public class QhseEmergencyCertSaveReqVO {
     @Schema(description = "部门名称", example = "赵六")
     private String deptName;
 
+    @Schema(description = "过期")
+    private Boolean expired;
+    @Schema(description = "预警")
+    private Boolean alertWarn;
 }

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/emergency/QhseEmergencyCertDO.java

@@ -56,6 +56,9 @@ public class QhseEmergencyCertDO extends BaseDO {
      * 有效期
      */
     private LocalDateTime certExpire;
+
+    private Boolean expired;
+    private Boolean alertWarn;
     /**
      * 附件
      */

+ 80 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -211,6 +211,45 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
                 .inIfPresent(IotDeviceDO::getDeptId, deptIds));
     }
 
+    default PageResult<IotDeviceDO> selectAllTdPage(IotDevicePageReqVO reqVO, Collection<Long> deptIds, List<String> codes) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceDO>()
+//                .inIfPresent(IotDeviceDO::getDeviceCode, codes)
+                .likeIfPresent(IotDeviceDO::getDeviceName, reqVO.getDeviceName())
+                .eqIfPresent(IotDeviceDO::getBrand, reqVO.getBrand())
+                .eqIfPresent(IotDeviceDO::getModel, reqVO.getModel())
+                //.eqIfPresent(IotDeviceDO::getOrgId, reqVO.getOrgId())
+                .inIfPresent(IotDeviceDO::getDeptId, deptIds)
+                .eqIfPresent(IotDeviceDO::getDeviceStatus, reqVO.getDeviceStatus())
+                .eqIfPresent(IotDeviceDO::getAssetProperty, reqVO.getAssetProperty())
+                .eqIfPresent(IotDeviceDO::getPicUrl, reqVO.getPicUrl())
+                .eqIfPresent(IotDeviceDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(IotDeviceDO::getManufacturerId, reqVO.getManufacturerId())
+                .eqIfPresent(IotDeviceDO::getSupplierId, reqVO.getSupplierId())
+                .eqIfPresent(IotDeviceDO::getNameplate, reqVO.getNameplate())
+                .eqIfPresent(IotDeviceDO::getExpires, reqVO.getExpires())
+                .eqIfPresent(IotDeviceDO::getPlPrice, reqVO.getPlPrice())
+                //.betweenIfPresent(IotDeviceDO::getPlDate, reqVO.getPlDate())
+                //.betweenIfPresent(IotDeviceDO::getManDate, reqVO.getManDate())
+                .eqIfPresent(IotDeviceDO::getPlYear, reqVO.getPlYear())
+                .betweenIfPresent(IotDeviceDO::getPlStartDate, reqVO.getPlStartDate())
+                .eqIfPresent(IotDeviceDO::getPlMonthed, reqVO.getPlMonthed())
+                .eqIfPresent(IotDeviceDO::getPlAmounted, reqVO.getPlAmounted())
+                .eqIfPresent(IotDeviceDO::getRemainAmount, reqVO.getRemainAmount())
+                .eqIfPresent(IotDeviceDO::getInfoId, reqVO.getInfoId())
+                .eqIfPresent(IotDeviceDO::getInfoType, reqVO.getInfoType())
+                .eqIfPresent(IotDeviceDO::getAssetClass, reqVO.getAssetClass())
+                .likeIfPresent(IotDeviceDO::getInfoName, reqVO.getInfoName())
+                .eqIfPresent(IotDeviceDO::getInfoRemark, reqVO.getInfoRemark())
+                .eqIfPresent(IotDeviceDO::getInfoUrl, reqVO.getInfoUrl())
+                .eqIfPresent(IotDeviceDO::getTemplateJson, reqVO.getTemplateJson())
+                .likeIfPresent(IotDeviceDO::getDeviceCode, reqVO.getDeviceCode())
+                .inIfPresent(IotDeviceDO::getDeviceCode, codes)
+                .eqIfPresent(IotDeviceDO::getBomSyncStatus, reqVO.getBomSyncStatus())
+                .eqIfPresent(IotDeviceDO::getIfInline, reqVO.getIfInline())
+                .isNotNull(IotDeviceDO::getIfInline)
+                .orderByAsc(IotDeviceDO::getIfInline).orderByDesc(IotDeviceDO::getLastInlineTime).orderByAsc(IotDeviceDO::getDeviceCode));
+    }
+
     default PageResult<IotDeviceDO> selectTdPage(IotDevicePageReqVO reqVO, Collection<Long> deptIds, List<String> codes) {
         return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceDO>()
 //                .inIfPresent(IotDeviceDO::getDeviceCode, codes)
@@ -247,14 +286,51 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
                 .eqIfPresent(IotDeviceDO::getBomSyncStatus, reqVO.getBomSyncStatus())
                 .eqIfPresent(IotDeviceDO::getIfInline, reqVO.getIfInline())
                 .isNotNull(IotDeviceDO::getIfInline)
-                .eq(reqVO.getSource() != null && "gateway".equals(reqVO.getSource()),
-                        IotDeviceDO::getVehicleName, null)  // gateway → 为空
-                .ne(reqVO.getSource() != null && "zhbd".equals(reqVO.getSource()),
-                        IotDeviceDO::getVehicleName, null)  // 非 gateway → 不为空
+                .isNull(IotDeviceDO::getVehicleName)
                 .orderByAsc(IotDeviceDO::getIfInline).orderByDesc(IotDeviceDO::getLastInlineTime).orderByAsc(IotDeviceDO::getDeviceCode));
     }
 
 
+    default PageResult<IotDeviceDO> selectZhbdTdPage(IotDevicePageReqVO reqVO, Collection<Long> deptIds, List<String> codes) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceDO>()
+//                .inIfPresent(IotDeviceDO::getDeviceCode, codes)
+                .likeIfPresent(IotDeviceDO::getDeviceName, reqVO.getDeviceName())
+                .eqIfPresent(IotDeviceDO::getBrand, reqVO.getBrand())
+                .eqIfPresent(IotDeviceDO::getModel, reqVO.getModel())
+                //.eqIfPresent(IotDeviceDO::getOrgId, reqVO.getOrgId())
+                .inIfPresent(IotDeviceDO::getDeptId, deptIds)
+                .eqIfPresent(IotDeviceDO::getDeviceStatus, reqVO.getDeviceStatus())
+                .eqIfPresent(IotDeviceDO::getAssetProperty, reqVO.getAssetProperty())
+                .eqIfPresent(IotDeviceDO::getPicUrl, reqVO.getPicUrl())
+                .eqIfPresent(IotDeviceDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(IotDeviceDO::getManufacturerId, reqVO.getManufacturerId())
+                .eqIfPresent(IotDeviceDO::getSupplierId, reqVO.getSupplierId())
+                .eqIfPresent(IotDeviceDO::getNameplate, reqVO.getNameplate())
+                .eqIfPresent(IotDeviceDO::getExpires, reqVO.getExpires())
+                .eqIfPresent(IotDeviceDO::getPlPrice, reqVO.getPlPrice())
+                //.betweenIfPresent(IotDeviceDO::getPlDate, reqVO.getPlDate())
+                //.betweenIfPresent(IotDeviceDO::getManDate, reqVO.getManDate())
+                .eqIfPresent(IotDeviceDO::getPlYear, reqVO.getPlYear())
+                .betweenIfPresent(IotDeviceDO::getPlStartDate, reqVO.getPlStartDate())
+                .eqIfPresent(IotDeviceDO::getPlMonthed, reqVO.getPlMonthed())
+                .eqIfPresent(IotDeviceDO::getPlAmounted, reqVO.getPlAmounted())
+                .eqIfPresent(IotDeviceDO::getRemainAmount, reqVO.getRemainAmount())
+                .eqIfPresent(IotDeviceDO::getInfoId, reqVO.getInfoId())
+                .eqIfPresent(IotDeviceDO::getInfoType, reqVO.getInfoType())
+                .eqIfPresent(IotDeviceDO::getAssetClass, reqVO.getAssetClass())
+                .likeIfPresent(IotDeviceDO::getInfoName, reqVO.getInfoName())
+                .eqIfPresent(IotDeviceDO::getInfoRemark, reqVO.getInfoRemark())
+                .eqIfPresent(IotDeviceDO::getInfoUrl, reqVO.getInfoUrl())
+                .eqIfPresent(IotDeviceDO::getTemplateJson, reqVO.getTemplateJson())
+                .likeIfPresent(IotDeviceDO::getDeviceCode, reqVO.getDeviceCode())
+                .inIfPresent(IotDeviceDO::getDeviceCode, codes)
+                .eqIfPresent(IotDeviceDO::getBomSyncStatus, reqVO.getBomSyncStatus())
+                .eqIfPresent(IotDeviceDO::getIfInline, reqVO.getIfInline())
+                .isNotNull(IotDeviceDO::getIfInline)
+                .isNotNull(IotDeviceDO::getVehicleName)
+                .orderByAsc(IotDeviceDO::getIfInline).orderByDesc(IotDeviceDO::getLastInlineTime).orderByAsc(IotDeviceDO::getDeviceCode));
+    }
+
     default PageResult<IotDeviceDO> selectTdPageApp(IotDevicePageReqVO reqVO, Collection<Long> deptIds) {
         LambdaQueryWrapper<IotDeviceDO> wrapper = new LambdaQueryWrapper<>();
 //        wrapper.isNotNull(IotDeviceDO::getIfInline).like(StringUtils.isNotBlank(reqVO.getCommonParam()), IotDeviceDO::getDeviceName, reqVO.getCommonParam())

+ 19 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/qhse/CertJob.java

@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureDetectDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.qhse.cert.IotMeasureCertMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.qhse.devicecert.QhseDeviceCertMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.emergency.QhseEmergencyCertMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.qhse.measure.IotMeasureBookMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.qhse.measure.IotMeasureDetectMapper;
 import cn.iocoder.yudao.module.pms.message.PmsMessage;
@@ -42,6 +43,8 @@ public class CertJob implements JobHandler {
     private PmsMessage pmsMessage;
     @Autowired
     private QhseDeviceCertMapper qhseDeviceCertMapper;
+    @Autowired
+    private QhseEmergencyCertMapper qhseEmergencyCertMapper;
 
     @Override
     @TenantIgnore
@@ -117,6 +120,22 @@ public class CertJob implements JobHandler {
             }
             qhseDeviceCertMapper.updateById(item);
         });
+        qhseEmergencyCertMapper.selectList().forEach(item -> {
+            LocalDateTime certExpire = item.getCertExpire();
+            if (certExpire.isBefore(LocalDateTime.now())) {
+                item.setExpired(true);
+            } else {
+                item.setExpired(false);
+            }
+            //如果相差不到90天了就进行预警
+            if (certExpire.isAfter(LocalDateTime.now()) && ChronoUnit.DAYS.between(LocalDateTime.now(), certExpire) < 90) {
+                item.setAlertWarn(true);
+                item.setExpired(false);
+            }
+            qhseEmergencyCertMapper.updateById(item);
+        });
+
+
         return "执行成功";
     }
 }

+ 8 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -752,7 +752,14 @@ public class IotDeviceServiceImpl implements IotDeviceService {
             ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
             ids.add(pageReqVO.getDeptId());
         }
-        return iotDeviceMapper.selectTdPage(pageReqVO,ids, codes);
+
+        if ("gateway".equals(pageReqVO.getSource())) {
+            return iotDeviceMapper.selectTdPage(pageReqVO,ids,codes);
+        } else if ("zhbd".equals(pageReqVO.getSource())) {
+            return iotDeviceMapper.selectZhbdTdPage(pageReqVO,ids,codes);
+        } else {
+            return iotDeviceMapper.selectAllTdPage(pageReqVO,ids,codes);
+        }
     }
 
     @Override