admin
2024-08-12 1405923e6301e3bb19c786733066dc3d25f4a39c
jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
@@ -220,30 +220,11 @@
    public AjaxResult yzUpdateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) {
        Boolean b = true;
        String result = "1";
//        BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
//        getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode());
//        getMaterTwo.setOperationType("2");
//        List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo);
//        List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList());
//        for (String s : collect) {
//            if(s.equals("")){
////                return AjaxResult.success("扫描未完成,禁止拧紧操作!");
//            }
//        }
//        BsFormulaChildInfo listQuery = new BsFormulaChildInfo();
//        listQuery.setParamCode(bsFormulaChildInfo.getParamCode());
//        listQuery.setProcessesCode(bsFormulaChildInfo.getLocationCode());
        String paramData = bsFormulaChildInfo.getTightenTheArray();
        if(paramData.contains("N")){
            result = "3";
//            List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
//            bsFormulaChildInfos.get(0).setResults("NG");
//            bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
//            bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
            this.updateTighteningData(bsFormulaChildInfo,"NG",paramData);
//            return AjaxResult.success("扫描结果NG,请重新扫描!");
        }else {
//            List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
            if(bsFormulaChildInfo.getSpareField2()!=null&&bsFormulaChildInfo.getSpareField3()!=null){
                String tightenArray = bsFormulaChildInfo.getTightenTheArray().replace("[", "").replace("]", "").replace(" ", "");
                String[] tightenDataParts = tightenArray.split(",");
@@ -251,15 +232,11 @@
            }
            if(b){
                result = "3";
//                bsFormulaChildInfos.get(0).setResults("OK");
//                bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
//                bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
                this.updateTighteningData(bsFormulaChildInfo,"OK",paramData);
//                logger.info("yzUpdateTighteningFormula--查询条件参数:"+listQuery);
//                logger.info("yzUpdateTighteningFormula--查询结果:"+bsFormulaChildInfos.get(0));
                Integer stepNumber = Integer.valueOf(bsFormulaChildInfo.getStepSort());
                try {
                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".MStepNumber").value(stepNumber+1).build());
                    String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getLocationCode());//获取通道
                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare+"."+bsFormulaChildInfo.getLocationCode()+".MESScrew").value(stepNumber+1).build());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
@@ -269,7 +246,6 @@
                    // 执行操作
                    if(bsFormulaChildInfo.getSpareField4().equals("1")){
                        try {
//                        WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT");
                            result = "2";
                        } catch (Exception e) {
                            throw new RuntimeException(e);
@@ -278,14 +254,8 @@
                }
            }else {
                result = "3";
//                List<BsFormulaChildInfo> bsFormulaChildInfos1 = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
//                bsFormulaChildInfos1.get(0).setResults("NG");
//                String originalString = bsFormulaChildInfo.getTightenTheArray();
                String modifiedString = paramData.replaceFirst("OK", "NG");
//                bsFormulaChildInfos1.get(0).setCollectData(modifiedString);
//                bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos1.get(0));
                this.updateTighteningData(bsFormulaChildInfo,"NG",modifiedString);
//                return AjaxResult.success("扫描结果NG,请重新扫描!");
            }
        }
        return AjaxResult.success(result);
@@ -354,13 +324,6 @@
    @Override
    public AjaxResult jrmWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
        this.clearCollectDataAndResultsByProcessesCode(bsFormulaChildInfo);
//        List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
//                .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
//                .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
//        for (BsFormulaChildInfo info : list) {
//            info.setCollectData("");
//            info.setResults("");
//            bsFormulaChildInfoService.saveOrUpdate(info);
//        }
        String[] split = bsFormulaChildInfo.getProductBarcode().split(",");
        try {
@@ -555,35 +518,8 @@
    @Override
    public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
        this.clearCollectDataAndResultsByProcessesCode(bsFormulaChildInfo);
//        List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
//                .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
//                .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
//        for (BsFormulaChildInfo info : list) {
//            info.setCollectData("");
//            info.setResults("");
//            bsFormulaChildInfoService.saveOrUpdate(info);
//        }
        try {
            daParamCollectionService.pushGeelycvMesFeedback(bsFormulaChildInfo.getProductBarcode(), bsFormulaChildInfo.getLocationCode());
//            String barCode = bsFormulaChildInfo.getProductBarcode();
//            String locationCode = bsFormulaChildInfo.getLocationCode();
//
//            if(StringUtils.isNotBlank(locationCode)&&StringUtils.isNotBlank(barCode)){
//                DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
//                daPassingStationCollection.setOutRsSign("1");
//                daPassingStationCollection.setOutboundTime(new Date());
//                daPassingStationCollection.setSfcCode(barCode);
//                daPassingStationCollection.setLocationCode(locationCode);
//                int updateDaPassingStation = daPassingStationCollectionService.updateDaPassingStationCollectionBySfcCodeAndLocationCode(daPassingStationCollection);
//                logger.info("普通人工工位更新过站记录updateDaPassingStationCollectionBySfcCodeAndLocationCode:更新了{}条数据-更新条件pack码{}-工位{}",updateDaPassingStation,barCode,locationCode);
//            }
//            DaPassingStationCollection passingStationCollectionOne = daPassingStationCollectionService.getOne(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getSfcCode, barCode).eq(DaPassingStationCollection::getLocationCode, locationCode));
//            if (passingStationCollectionOne != null) {
//                passingStationCollectionOne.setOutRsSign("1");
//                passingStationCollectionOne.setOutboundTime(new Date());
//                daPassingStationCollectionService.saveOrUpdate(passingStationCollectionOne);
//            }
        }catch (Exception e){
        }
        return AjaxResult.success();
@@ -636,8 +572,8 @@
                bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo);
                Integer stepNumber = Integer.valueOf(bsFormulaChildInfo.getStepSort());
                String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getLocationCode());//获取通道
                try {
                    String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getLocationCode());//获取通道
                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare+"."+bsFormulaChildInfo.getLocationCode()+".MESScrew").value(stepNumber+1).build());
                } catch (Exception e) {
                    throw new RuntimeException(e);
@@ -654,7 +590,7 @@
    //                        List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection);
    //                        daPassingStationCollections.get(0).setOutboundTime(new Date());
    //                        daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0));
//                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare +"."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
                            WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT");
                        } catch (Exception e) {
                            throw new RuntimeException(e);