春风项目四线(合箱线、总装线)
wujian
2024-07-12 d2daac02fbc20980162799fc7bf6b1ca59f5686a
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java
@@ -1,6 +1,7 @@
package com.jcdm.main.bs.orderScheduling.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
@@ -12,7 +13,6 @@
import com.jcdm.common.core.domain.entity.SysDictData;
import com.jcdm.common.core.page.TableDataInfo;
import com.jcdm.common.enums.BusinessType;
import com.jcdm.common.utils.SecurityUtils;
import com.jcdm.common.utils.StringUtils;
import com.jcdm.common.utils.poi.ExcelUtil;
import com.jcdm.main.bs.orderScheduling.common.Constants;
@@ -23,8 +23,11 @@
import com.jcdm.main.bs.orderScheduling.vo.SumDataVO;
import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation;
import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService;
import com.jcdm.main.da.tileMatchCollection.domain.DaTileMatchCollection;
import com.jcdm.main.da.tileMatchCollection.service.IDaTileMatchCollectionService;
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
import com.jcdm.main.om.productionOrde.service.impl.OmProductionOrdeInfoServiceImpl;
import com.jcdm.main.plcserver.conf.OPCElement;
@@ -41,9 +44,10 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
@@ -67,6 +71,10 @@
    private OmProductionOrdeInfoServiceImpl productionOrdeInfoService;
    @Resource
    private DaParamCollectionMapper daParamCollectionService;
    @Resource
    private IDaTileMatchCollectionService daTileMatchCollectionService;
    @Resource
    private ProductNewPassStationService productNewPassStationService;
    @Autowired
    MiloService miloService;
@@ -311,7 +319,6 @@
        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
        bsOrderScheduling.setOrderNo(orderNo);
        //bsOrderScheduling.setProductionStatus("1");
        List<BsOrderScheduling> allList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        List<BsOrderScheduling> dlist = allList.stream().filter(x->x.getProductionStatus().equals(Constants.WAIT_PRODUCTION)).collect(Collectors.toList());
        List<BsOrderScheduling> collect = allList.stream().filter(x -> x.getProductionStatus().equals(Constants.ORDER_STATUS_ING)
@@ -319,13 +326,13 @@
        BsOrderScheduling OrderScheduling=dlist.get(0);
        DaParamCollection daParamCollection = new DaParamCollection();
        daParamCollection.setParamValue(engineNo);
        daParamCollection.setSfcCode("OP010");
        List<DaParamCollection> list = daParamCollectionService.selectDaParamCollectionList(daParamCollection);
        if (CollUtil.isNotEmpty(list)){
            return R.ok(500,"已存在此箱体码,请勿重复扫描");
        }
//        DaParamCollection daParamCollection = new DaParamCollection();
//        daParamCollection.setParamValue(engineNo);
//        daParamCollection.setLocationCode("OP010");
//        List<DaParamCollection> list = daParamCollectionService.selectDaParamCollectionList(daParamCollection);
//        if (CollUtil.isNotEmpty(list)){
//            return R.ok(500,"已存在此箱体码,请勿重复扫描");
//        }
        OmProductionOrdeInfo info = new OmProductionOrdeInfo();
        info.setWorkOrderNo(orderNo);
@@ -343,8 +350,35 @@
        saveData.setParamValue(engineNo);
        saveData.setLocationCode("OP010");
        saveData.setParamCode("XTM");
        saveData.setParamName("箱体码");
        saveData.setParamName("箱体");
        daParamCollectionService.insertDaParamCollection(saveData);
        DaTileMatchCollection MatchCollection = new DaTileMatchCollection();
        MatchCollection.setSfcCode(OrderScheduling.getEngineNo());
        MatchCollection.setParamValue(engineNo);
        MatchCollection.setLocationCode("OP010");
        MatchCollection.setParamCode("XTM");
        MatchCollection.setParamName("箱体");
        daTileMatchCollectionService.insertDaTileMatchCollection(MatchCollection);
        if (StrUtil.isNotBlank(OrderScheduling.getEngineNo())){
            String snCode = OrderScheduling.getEngineNo();
            if (snCode.startsWith("280") || snCode.startsWith("380")){
                ProductNewPassStation productNewPassStation = new ProductNewPassStation();
                UUID uuid = UUID.randomUUID();
                productNewPassStation.setId(uuid.getMostSignificantBits());
                productNewPassStation.setFinishFlag("0");
                productNewPassStation.setSfcCode(OrderScheduling.getEngineNo());
                productNewPassStation.setCreateTime(new Date());
                productNewPassStation.setBoxCode(engineNo);
                if (snCode.startsWith("280")){
                    productNewPassStation.setProductType("280");
                } else {
                    productNewPassStation.setProductType("380");
                }
                productNewPassStationService.insertPassStation(productNewPassStation);
            }
        }
        //更新上线数量
        int onlineNum = 0;
@@ -365,15 +399,12 @@
        }
        //OPC操作
        ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.HOP010.Code", OrderScheduling.getEngineNo());
        ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", OrderScheduling.getEngineNo());
        OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN
        ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.HOP010.SNDoor", 1);
        OPCUaSubscription.miloService.writeToOpcByte(entity2);//写完成
        OrderScheduling.setProductionStatus("2");
        bsOrderSchedulingService.updateBsOrderScheduling(OrderScheduling);
        return R.ok();
    }
}