Ver código fonte

解决报警日志页面警报报警功能

oyq28 3 anos atrás
pai
commit
cbda24ecfa

+ 4 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/AAutoNodeLogService.java

@@ -5,6 +5,8 @@ import com.github.zuihou.base.service.SuperService;
 import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 
+import java.util.List;
+
 /**
  * <p>
  * 业务接口
@@ -17,4 +19,6 @@ import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 public interface AAutoNodeLogService extends SuperService<AAutoNodeLog> {
 
     IPage<AAutoNodeLog> pageList(IPage page, LbqWrapper<AAutoNodeLog> wrapper);
+
+    Boolean updateStatus(List<Long> ids);
 }

+ 26 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/impl/AAutoNodeLogServiceImpl.java

@@ -1,13 +1,22 @@
 package com.github.zuihou.business.productionReadyCenter.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.base.service.SuperServiceImpl;
 import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
 import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
 import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
+import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -22,9 +31,26 @@ import org.springframework.stereotype.Service;
 @Service
 public class AAutoNodeLogServiceImpl extends SuperServiceImpl<AAutoNodeLogMapper, AAutoNodeLog> implements AAutoNodeLogService {
 
+    @Autowired
+    private AAutoNodeLogService aAutoNodeLogService;
 
     @Override
     public IPage<AAutoNodeLog> pageList(IPage page, LbqWrapper<AAutoNodeLog> wrapper) {
         return baseMapper.pageList(page,wrapper);
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean updateStatus(List<Long> ids) {
+        boolean bool = false;
+        if (CollectionUtil.isEmpty(ids)) {
+            return true;
+        }
+        List<AAutoNodeLog> list = super.listByIds(ids);
+        if (!list.isEmpty()){
+            List<Long> idList = list.stream().mapToLong(AAutoNodeLog::getId).boxed().collect(Collectors.toList());
+            bool = aAutoNodeLogService.update(Wraps.<AAutoNodeLog>lbU().in(AAutoNodeLog::getId, idList).set(AAutoNodeLog::getStatus,"1").set(AAutoNodeLog::getUpdateTime, LocalDateTime.now()).set(AAutoNodeLog::getUpdateUser, BaseContextHandler.getUserId()));
+        }
+        return bool;
+    }
 }

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockInfoMapper.xml

@@ -24,7 +24,7 @@
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
-        storge_id, lock_status, goods_type, goods_id, num, unique_code, turn_task_no, feed_task_no,storgeNo,
+        storge_id, lock_status, goods_type, goods_id, num, unique_code, turn_task_no, feed_task_no,
         categoryDesc,brandName,brandNo,specification,weight,spec_id,lockNum,availableNum,org_id
     </sql>
 

+ 7 - 6
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionReadyCenter/AAutoNodeLogMapper.xml

@@ -15,24 +15,25 @@
         <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
         <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
         <result column="feedback" jdbcType="VARCHAR" property="feedback"/>
+        <result column="status" jdbcType="VARCHAR" property="status"/>
         <result column="feedback_file" jdbcType="VARCHAR" property="feedbackFile"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,create_time ,create_user,update_time,update_user,
-        auto_node_id, exe_status, exe_result, start_time, end_time, feedback, feedback_file, resourceName,instructionName,procedureName
+        auto_node_id, exe_status, exe_result, start_time, end_time, feedback, feedback_file, status, resourceName,instructionName,procedureName,nodeNo
     </sql>
 
     <select id="pageList" resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List"/>
         from (
-            select l.*, c.name as resourceName, d.name as instructionName, p.`name` as procedureName from imcs_a_auto_node_log l
-            left join imcs_a_auto_node a ON l.auto_node_id = a.id
-            left join imcs_tenant_productionresource c on a.resource_id = c.id
-            left join imcs_b_bom_procedure p on a.procedure_id = p.id
-            left join view_module_instruction d on a.instruction_id = d.id
+        select l.*, a.node_no as nodeNo, c.name as resourceName, d.name as instructionName, p.`name` as procedureName from imcs_a_auto_node_log l
+        left join imcs_a_auto_node a ON l.auto_node_id = a.id
+        left join imcs_tenant_productionresource c on a.resource_id = c.id
+        left join imcs_b_bom_procedure p on a.procedure_id = p.id
+        left join view_module_instruction d on a.instruction_id = d.id
         ) s ${ew.customSqlSegment}
     </select>
 

+ 40 - 9
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionReadyCenter/WarnLogController.java

@@ -1,15 +1,25 @@
 package com.github.zuihou.business.controller.productionReadyCenter;
 
-import com.github.zuihou.base.controller.QueryController;
-import com.github.zuihou.base.controller.SuperSimpleController;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.R;
+import com.github.zuihou.base.controller.*;
+import com.github.zuihou.base.request.PageParams;
 import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
 import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
+import com.github.zuihou.common.util.DateUtil;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.log.annotation.SysLog;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
 
 /**
@@ -24,11 +34,32 @@ import org.springframework.web.bind.annotation.RestController;
 @Slf4j
 @Validated
 @RestController
-@RequestMapping("/autoNodeLog")
-@Api(value = "autoNodeLog", tags = "库存日志")
+@RequestMapping("/warnLog")
+@Api(value = "warnLog", tags = "报警日志")
 @SysLog(enabled = true)
-public class WarnLogController extends SuperSimpleController<AAutoNodeLogService, AAutoNodeLog> implements QueryController<AAutoNodeLog, Long, AAutoNodeLog> {
+public class WarnLogController extends SuperSimpleController<AAutoNodeLogService, AAutoNodeLog> implements QueryController<AAutoNodeLog, Long, AAutoNodeLog>, SaveController<AAutoNodeLog, AAutoNodeLog>, DeleteController<AAutoNodeLog, Long>, UpdateController<AAutoNodeLog, AAutoNodeLog> {
+
+    //延时阈值约为10分钟
+    private final int TIMEOUT_THRESHOLD_SEC = -600;
+
+    @Override
+    public void query(PageParams<AAutoNodeLog> params, IPage<AAutoNodeLog> page, Long defSize) {
+        QueryWrap<AAutoNodeLog> wrap = handlerWrapper(null, params);
+        LbqWrapper<AAutoNodeLog> wrapper = wrap.lambda();
+
+        wrapper.eq(AAutoNodeLog::getExeResult,"0").or(condition->condition.isNull(AAutoNodeLog::getExeResult).eq(AAutoNodeLog::getExeStatus,"2").lt(AAutoNodeLog::getStartTime, DateUtil.getAddSecondsTime(new Date(), TIMEOUT_THRESHOLD_SEC))).orderByDesc(AAutoNodeLog::getCreateTime);
+        baseService.pageList(page,wrapper);
+    }
+
+    @Override
+    public R<AAutoNodeLog> handlerSave(AAutoNodeLog model) {
+        Boolean bean = baseService.save(model);
+        return (bean)?success(model) : fail("操作失败");
+    }
 
-    
-	
+    @ApiOperation(value = "修改状态", notes = "修改状态")
+    @GetMapping("/updateStatus")
+    public R<Boolean> updateStatus(@RequestParam(value="ids[]")  List<Long> ids) {
+        return R.success(baseService.updateStatus(ids));
+    }
 }

+ 32 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionReadyCenter/entity/AAutoNodeLog.java

@@ -84,6 +84,15 @@ public class AAutoNodeLog extends Entity<Long> {
     @Excel(name = "执行结果(1-成功0-失败)")
     private String exeResult;
 
+    /**
+     * 处理状态(1-已处理0-未处理)
+     */
+    @ApiModelProperty(value = "处理状态(1-已处理0-未处理)")
+    @Length(max = 4, message = "处理状态(1-已处理0-未处理)长度不能超过4")
+    @TableField(value = "status", condition = LIKE)
+    @Excel(name = "处理状态(1-已处理0-未处理)")
+    private String status;
+
     /**
      * 开始时间
      */
@@ -142,6 +151,29 @@ public class AAutoNodeLog extends Entity<Long> {
     @Excel(name = "任务id")
     private Long taskId;
 
+    /**
+     * 设备名称
+     */
+    @TableField(exist = false)
+    private String resourceName;
+
+    /**
+     * 指令名称
+     */
+    @TableField(exist = false)
+    private String instructionName;
+
+    /**
+     * 工序名称
+     */
+    @TableField(exist = false)
+    private String procedureName;
+
+    /**
+     * 节点编号
+     */
+    @TableField(exist = false)
+    private String nodeNo;
 
     @Builder
     public AAutoNodeLog(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,