zhoushihao
2024-04-29 902f9cc6e03c78722d67bed36a46c4cb61c13891
新增定时任务
忽略日志文件
2个文件已修改
1个文件已添加
1个文件已删除
239 ■■■■ 已修改文件
.gitignore 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/CacheVerticalClassModuleApplication.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/component/PlcStorageCage.java 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -22,4 +22,6 @@
.idea/
#忽略所有.iml文件
*.iml
#忽略所有日志文件
*.log
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/CacheVerticalClassModuleApplication.java
@@ -5,6 +5,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.scheduling.annotation.EnableScheduling;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
@@ -17,6 +18,7 @@
@EnableSwagger2
@EnableDiscoveryClient
@MapperScan(basePackages = "com.mes.*.mapper")
@EnableScheduling
public class CacheVerticalClassModuleApplication {
    public static void main(String[] args) {
        try {
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/component/PlcStorageCage.java
File was deleted
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java
New file
@@ -0,0 +1,122 @@
package com.mes.job;
import cn.hutool.json.JSONObject;
import com.mes.bigstorage.entity.BigStorageCageDetails;
import com.mes.bigstorage.service.BigStorageCageDetailsService;
import com.mes.bigstorage.service.BigStorageCageService;
import com.mes.bigstoragetask.entity.BigStorageCageFeedTask;
import com.mes.bigstoragetask.service.BigStorageCageFeedTaskService;
import com.mes.bigstoragetask.service.BigStorageCageOutTaskService;
import com.mes.edgstoragetask.service.TaskCacheService;
import com.mes.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.menu.service.SysMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Slf4j
public class PlcStorageCageTask {
    @Autowired
    private BigStorageCageService bigStorageCageService;
    @Autowired
    private BigStorageCageDetailsService bigStorageCageDetailsService;
    @Autowired
    private GlassInfoService glassInfoService;
    @Autowired
    private BigStorageCageFeedTaskService bigStorageCageFeedTaskService;
    @Autowired
    private BigStorageCageOutTaskService bigStorageCageOutTaskService;
    @Autowired
    private TaskCacheService taskCacheService;
    @Autowired
    private SysMenuService sysMenuService;
    /**
     * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成)
     * fixedDelay : 上一个调用结束后再次调用的延时
     */
    @Scheduled(fixedDelay = 300)
    public void plcStorageCageTask() throws InterruptedException {
        JSONObject jsonObject = new JSONObject();
        try {
            Thread.sleep(300);
            boolean bigStorageCageFullAlarm = false;
            String plcD01FeedReq = "0";
            String plcD04FeedReq = "0";
            String plcFeedGlassid = "111";
            String plcFeedReqLine = "0";
            if ("1".equals(plcD01FeedReq)) {
                plcFeedReqLine = "1";
            } else {
                //plc任务发送字0
            }
            if ("1".equals(plcD04FeedReq)) {
                plcFeedReqLine = "2";
            } else {
                //plc任务发送字0
            }
            if (!("0".equals(plcFeedReqLine))) {
                log.info("1、Plc进片请求时");
                BigStorageCageDetails bigStorageCageDetails = new BigStorageCageDetails();
                GlassInfo glassInfo = glassInfoService.getById(plcFeedGlassid);
                log.info("2、根据玻璃id获取玻璃信息" + glassInfo);
                BigStorageCageDetails slotInfo = bigStorageCageService.feedGlass(glassInfo, bigStorageCageDetails);
                if (slotInfo != null) {
                    int taskType = taskCacheService.judgeTasktype();
                    log.info("3、查询任务表判断当前任务类型为上车等到还是上车启动" + taskType);
                    bigStorageCageFeedTaskService.addFeedTask(slotInfo, Integer.parseInt(plcFeedReqLine), taskType);
                    log.info("4、添加任务到任务表");
                    //plc任务发送字1
                    bigStorageCageFullAlarm = false;
                } else {
                    //理片笼爆笼报警
                    bigStorageCageFullAlarm = true;
                }
            } else {
                List<BigStorageCageFeedTask> bigStorageCageFeedTaskList = bigStorageCageFeedTaskService.querybigStorageCageFeedTask(1);
                log.info("5、查询任务表是否有已经完成的进片任务" + bigStorageCageFeedTaskList.size());
                for (BigStorageCageFeedTask bigStorageCageFeedTask : bigStorageCageFeedTaskList
                ) {
                    BigStorageCageDetails bigStorageCageDetails = new BigStorageCageDetails();
                    bigStorageCageDetails.setId(bigStorageCageFeedTask.getId());
                    bigStorageCageDetails.setState(1);
                    bigStorageCageDetailsService.updateById(bigStorageCageDetails);
                    log.info("6、修改理片笼详情玻璃状态");
                    bigStorageCageFeedTaskService.removeById(bigStorageCageFeedTask);
                    log.info("7、删除已经完成的进片任务");
                }
            }
            //出片请求
            String plcOutReq = "0";
            boolean result = false;
            if ("1".equals(plcOutReq)) {
                result = bigStorageCageService.outGlass();
                log.info("8、出片请求时调用出片接口" + result);
                if (result) {
                    //plc任务发送字1
                }
            } else {
                bigStorageCageOutTaskService.updateOutTask();
                //plc任务发送字0
            }
            //显示剩余空格子
            //报警信息
            jsonObject.append("bigStorageCageFullAlarm", bigStorageCageFullAlarm);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}