严智鑫
2024-08-05 00c4dfc5ac687c93e0b7abafc33abb693b38edd6
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
@@ -21,6 +21,7 @@
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.taskcache.entity.TaskCache;
import com.mes.taskcache.service.TaskCacheService;
import com.mes.temperingglass.entity.TemperingGlassInfo;
import com.mes.tools.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -74,11 +75,19 @@
    @Value("${mes.max.secondLength}")
    private String secondLength;
    @Value("${mes.min.firstLength}")
    private String minFirstLength;
    @Value("${mes.min.one.firstLength}")
    private String minOneFirstLength;
    @Value("${mes.min.secondLength}")
    private String minSecondLength;
    @Value("${mes.min.one.secondLength}")
    private String minOneSecondLength;
    @Value("${mes.min.two.firstLength}")
    private String minTwoFirstLength;
    @Value("${mes.min.two.secondLength}")
    private String minTwoSecondLength;
    public static String engineerId="";
    @Scheduled(fixedDelay = 1000)
    public void plcHomeEdgTask() {
@@ -115,7 +124,7 @@
            inTo(glassIdeValue, confirmationWrodAddress, currentSlot);
        } else if ("2".equals(taskRequestTypeValue)) {
            //09空闲 :1      10空闲 :2        都空闲:3    其他0
            log.info("2、出片请求,且确认字为0,执行进片任务");
            log.info("2、出片请求,且确认字为0,执行出片任务");
            outTo(Integer.parseInt(out08Glassstate),
                    Integer.parseInt(out10Glassstate), confirmationWrodAddress, "", 0);
        } else if ("3".equals(taskRequestTypeValue)) {
@@ -131,7 +140,23 @@
        Date endDate = new Date();
        log.info("本次任务结束时间:{},共耗时:{}ms", endDate, endDate.getTime() - startDate.getTime());
    }
    @Scheduled(fixedDelay = 1000)
    public void temperingIsRun(){
        JSONObject jsonObject = new JSONObject();
        //正在进行的任务
        List<TaskCache>taskCaches=taskCacheService.selectTaskCacheIsRun();
        jsonObject.append("taskCaches", taskCaches);
        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun");
        if (sendwServer != null) {
            for (WebSocketServer webserver : sendwServer) {
                if (webserver != null) {
                    webserver.sendMessage(jsonObject.toString());
                } else {
                    log.info("Home is closed");
                }
            }
        }
    }
    /**
     * 进片任务
     *
@@ -227,7 +252,7 @@
//        2、如果没有历史出片任务
//        2.1、出当前版图id最小版序最小的玻璃(问题:两条线都没有历史任务,出片时两条线的玻璃尺寸相同,是否找尺寸不同的)
        if ((out08Glassstate == 2 && out10Glassstate == 2) || (out08Glassstate == 0 && out10Glassstate == 0)) {
            log.info("A09、A10为{},{}非自动状态,无法出片");
            log.info("A09、A10为{},{}非自动状态,无法出片", out08Glassstate, out10Glassstate);
            return Boolean.FALSE;
        }
        log.info("0、出片任务出的状态:A09:【{}】;A10:【{}】)", out08Glassstate, out10Glassstate);
@@ -263,26 +288,27 @@
                    if (endcell == Const.A10_OUT_TARGET_POSITION) {
                        wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
                                "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") ");
                                "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength
                                + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") ");
                    } else {
                        wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
                                "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") ");
                                "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") ");
                    }
                    wrapper.last("order by count(t.glass_id) desc  limit 2");
                    List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper);
                    if (CollectionUtil.isEmpty(list)) {
                        MPJQueryWrapper<GlassInfo> queryWrapper = new MPJQueryWrapper<GlassInfo>()
                                .selectAll(GlassInfo.class).eq("t.glass_id", glassId);
//                                .inSql("t.engineer_id", "select engineer_id from engineering where state = 1");
                        if (endcell == Const.A10_OUT_TARGET_POSITION) {
                            wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                            queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                    "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
                                    "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") ");
                                    "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength
                                    + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") ");
                        } else {
                            wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                            queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                    "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
                                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") ");
                                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") ");
                        }
                        GlassInfo one = glassInfoService.getOne(queryWrapper);
                        if (one != null) {
@@ -504,11 +530,12 @@
        if (endcell == Const.A10_OUT_TARGET_POSITION) {
            wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                    "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
                    "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") ");
                    "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength
                    + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") ");
        } else {
            wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                    "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") ");
                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") ");
        }
        wrapper.last("order by count(t.glass_id) desc  limit 2");
        List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper);
@@ -546,7 +573,7 @@
                return queryMinGlass(firstSize.getWidth(), firstSize.getHeight(), glassId);
            }
            EdgStorageCageDetails outGlassInfo = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
                    .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId()));
                    .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId()).last("limit 1"));
            log.info("{}线有出片任务信息,任务信息为{},玻璃信息为{}", endcell, taskCache, outGlassInfo);
            if (outGlassInfo.getWidth() == firstWidth && outGlassInfo.getHeight() == firstHeight) {
                log.info("数量最多的宽{}高{}和{}线任务的宽{}高{}相同,出数量排第二的玻璃,宽{}高{}",
@@ -641,6 +668,8 @@
        edgGlassTaskInfo.setStatus(Const.EDG_GLASS_BEFORE);
        edgGlassTaskInfo.setLine(endcell);
        edgGlassTaskInfo.setTime(new Date());
        //先将历史对列表中本玻璃的数据删除,重新新增一份最新的数据
        edgGlassTaskInfoService.remove(new LambdaQueryWrapper<EdgGlassTaskInfo>().eq(EdgGlassTaskInfo::getGlassId, glassInfo.getGlassId()));
        return edgGlassTaskInfoService.save(edgGlassTaskInfo);
    }
@@ -669,9 +698,17 @@
    @Scheduled(fixedDelay = 1000)
    public void CacheGlassTasks() {
        JSONObject jsonObject = new JSONObject();
        //识别摆片
        List<Map<String, Object>> currentCutTerritorys = edgStorageCageDetailsService.selectCutTerritory();
        List<Map<String, Object>> currentCutTerritorys= edgStorageCageDetailsService.selectCutTerritory();
//        List<Map<String, Object>> currentCutTerritorys=new ArrayList<>();
//        if(engineerId==null||engineerId.isEmpty()){
//            //识别摆片 当前版图数据
//            currentCutTerritorys = edgStorageCageDetailsService.selectCutTerritory();
//        }else{
//            //识别摆片 此engineerId 工程版图数据
//            currentCutTerritorys = edgStorageCageDetailsService.selectCurrentCutTerritory(engineerId);
//        }
        jsonObject.append("currentCutTerritory", currentCutTerritorys);
        //log.info("本次识别版图{},++++{}",engineerId,currentCutTerritorys);
        //磨边信息
        List<Map<String, Object>> EdgTasks1 = taskCacheService.selectEdgInfo("2001");
        List<Map<String, Object>> EdgTasks2 = taskCacheService.selectEdgInfo("2002");