jiazx0107@163.com
2023-07-04 785ce007ce4b7b2119a99aacc95cefe9da09e32e
igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
@@ -1,8 +1,6 @@
package com.ld.igds.inout.service.impl;
import com.bstek.dorado.data.entity.EntityUtils;
import com.ld.igds.common.CoreCommonService;
import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.RedisConst;
import com.ld.igds.data.CommonData;
@@ -19,7 +17,6 @@
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
import com.ld.igds.util.RedisUtil;
import com.ld.igds.websocket.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -28,9 +25,6 @@
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
@Slf4j
@Component
@@ -42,8 +36,6 @@
    private InoutCheckMapper inoutCheckMapper;
    @Resource
    private RedisUtil redisUtil;
    @Resource
    private CoreCommonService commonService;
    @Override
    public InoutData inoutProgressQuery(InoutParam param) throws Exception {
@@ -156,7 +148,7 @@
            if (EntityUtils.isEntity(data)) {
                newData = new InoutData();
                BeanUtils.copyProperties(data, newData, new String[]{"checkItems", "files"});
            }else{
            } else {
                newData = data;
            }
@@ -516,16 +508,6 @@
        inoutMapper.deleteData(param);
    }
    @Override
    public void setCheckCache(InoutData data) {
        String cacheKey = RedisConst.buildKey(data.getCompanyId(), data.getCheckId());
        //化验结果存入缓存3天
        redisUtil.set(cacheKey, data.getCheckItems(), 60 * 60 * 24 * 3);
    }
    /**
     * 出入库流程ID创建 202001030001 202001030001
     *
@@ -626,53 +608,6 @@
        String key = this.buildInoutKey(deptId, InoutConstant.KEY_INOUT_COMPLETE_LIST, data.getType(), data.getId());
        //设置缓存到第二天凌晨(计算当前时间到第二天凌晨的时间差秒数)
        redisUtil.set(key, data, DateUtil.getNowToNextDaySeconds());
    }
    /**
     * 推送到大屏,判断只有当大屏在线时候才处理当前逻辑,避免页面卡顿,调用子任务完成推送
     *
     * @param companyId 组织编号
     * @param deptId    分库编号
     * @param progress  流转节点
     */
    public void notifyToScreen(String companyId, String deptId, String progress) {
        // 推送到大屏
        List<InoutData> curList = this.getListInoutCache(deptId);
        List<InoutData> completeList = this.getCompleteListInoutCache(deptId);
        if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN
                .getCode())) {
            WebSocketServer.contextOnLineMap.put(BizType.SCREEN.getCode(),
                    false);
        }
        if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN_INOUT
                .getCode())) {
            WebSocketServer.contextOnLineMap.put(
                    BizType.SCREEN_INOUT.getCode(), false);
        }
        if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN_CHECK
                .getCode())) {
            WebSocketServer.contextOnLineMap.put(
                    BizType.SCREEN_CHECK.getCode(), false);
        }
        if (WebSocketServer.contextOnLineMap.get(BizType.SCREEN.getCode())
                || WebSocketServer.contextOnLineMap.get(BizType.SCREEN_INOUT
                .getCode())
                || WebSocketServer.contextOnLineMap.get(BizType.SCREEN_CHECK
                .getCode())) {
            // 创建一个子任务进行推送信息
            FutureTask<String> futureTask = new FutureTask<>(new NotifyScreenTask(curList, completeList, deptId));
            ExecutorService executorService = Executors.newCachedThreadPool();
            executorService.submit(futureTask);
            executorService.shutdown();
        }
    }
    /**