admin
2024-11-12 706d57aa682845cf1bc01cbfd1087c4c0f33093f
jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
@@ -58,6 +58,8 @@
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.SystemUtils.getUserName;
/**
 * 设备产品过程参数采集Service业务层处理
 * 
@@ -405,6 +407,59 @@
            daParamCollectionTempService.insertBatch(saveParamListTemp);
        }
    }
    public void addCollectParamBasicData(String stationCode,String modelCode){
        List<DaCollectionParamConf> confList = daCollectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>().like(DaCollectionParamConf::getCollectParameterId, "YGBH"));
        if(!confList.isEmpty()){
            DaCollectionParamConf daCollectionParamConf = confList.get(0);
            DaParamCollection collection = new DaParamCollection();
            collection.setSfcCode(modelCode);//模组码
            collection.setParamCode(daCollectionParamConf.getCollectParameterId());//参数编码
            collection.setParamName(daCollectionParamConf.getCollectParameterName());//参数名称
            collection.setParamValue(getUserName());//参数值
            collection.setLocationCode(stationCode);//工位
            collection.setCollectionTime(new Date());//采集时间
            daParamCollectionService.save(collection);
            DaParamCollectionTemp collectionTemp = new DaParamCollectionTemp();
            collectionTemp.setSfcCode(modelCode);//模组码
            collectionTemp.setParamCode(daCollectionParamConf.getCollectParameterId());//参数编码
            collectionTemp.setParamName(daCollectionParamConf.getCollectParameterName());//参数名称
            collectionTemp.setParamValue(getUserName());//参数值
            collectionTemp.setLocationCode(stationCode);//工位
            collectionTemp.setCollectionTime(new Date());//采集时间
            daParamCollectionTempService.save(collectionTemp);
        }
    }
    @Override
    public void pushStartStopTime(String paramCode, String paramName, String productNum) {
        ParentVO parentVO = new ParentVO();
        parentVO.setSiteCode("3983");
        parentVO.setRecordId(String.valueOf(Instant.now().toEpochMilli()));
        parentVO.setStationCode("OP165");
        parentVO.setProductNum(productNum);
        parentVO.setTotalResult("1");
        List<ChildVO> listChildVo = new ArrayList<>();
        ChildVO childVO = new ChildVO();
        childVO.setItemCode(paramCode);
        childVO.setItemType("3");
        childVO.setItemText(paramName);
        childVO.setItemValue(format.format(new Date()));
        childVO.setCheckResult("1");
        childVO.setCheckTime(format.format(new Date()));
        listChildVo.add(childVO);
        parentVO.setCheckList(listChildVo);
        try{
            CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute();
                System.out.println(execute.body());
            });
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }
    @Override
    public void insertBatch(List<DaParamCollection> confList){
        try{
@@ -545,6 +600,12 @@
    @Override
    public void pushGeelycvMesFeedback(String packID, String stationCode) {
        //添加基础参数(登陆人信息)
        try {
            addCollectParamBasicData(stationCode,packID);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
        logger.info("进入人工工位推送工厂MES数据方法-pushGeelycvMesFeedback-工位{}-pack码{}",stationCode,packID);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String totalResult = "0";
@@ -561,43 +622,32 @@
            for (DaParamCollectionTemp daParamCollection : paramList) {
                ChildVO childVO = new ChildVO();
                childVO.setItemCode(daParamCollection.getParamCode());
//                BsFormulaChildInfo childOne = bsFormulaChildInfoService.getOne(new LambdaQueryWrapper<BsFormulaChildInfo>().eq(BsFormulaChildInfo::getParamCode, daParamCollection.getParamCode()));
//                DaCollectionParamConf paramConfOne = daCollectionParamConfService.getOne(new LambdaQueryWrapper<DaCollectionParamConf>().eq(DaCollectionParamConf::getCollectParameterId, daParamCollection.getParamCode()));
                List<DaCollectionParamConf> paramConfOneList = daCollectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>()
                        .eq(DaCollectionParamConf::getCollectParameterId, daParamCollection.getParamCode())
                        .eq(DaCollectionParamConf::getProcessesCode,stationCode));
                DaCollectionParamConf paramConfOne = paramConfOneList.get(0);
//                if(childOne!=null){
//                    String operationType = childOne.getOperationType();
//                    if(operationType.equals("1")){
//                        childVO.setItemType("2");
//                    }else if(operationType.equals("2")){
//                        childVO.setItemType("1");
//                    }
//                }else {
//                    childVO.setItemType("3");
//                }
                if(paramConfOne!=null){
                    childVO.setItemType(paramConfOne.getItemType());
                    childVO.setItemText(paramConfOne.getCollectParameterName());
                }else {
                    childVO.setItemType("3");
                    childVO.setItemText("");
                }
                childVO.setItemValue(daParamCollection.getParamValue());
                if(!paramConfOneList.isEmpty()){
                    if(paramConfOne!=null){
                        childVO.setItemType(paramConfOne.getItemType());
                        childVO.setItemText(paramConfOne.getCollectParameterName());
                    }else {
                        childVO.setItemType("3");
                        childVO.setItemText("");
                    }
                    childVO.setItemValue(daParamCollection.getParamValue());
                if(daParamCollection.getParamValue().equals("1")){
                    childVO.setCheckResult("1");
                }else if(daParamCollection.getParamValue().equals("2")){
                    childVO.setCheckResult("0");
                    parentVO.setTotalResult("0");
                    totalResult = "1";
                }else {
                    childVO.setCheckResult("1");
                    if(daParamCollection.getParamValue().equals("1")){
                        childVO.setCheckResult("1");
                    }else if(daParamCollection.getParamValue().equals("2")){
                        childVO.setCheckResult("0");
                        parentVO.setTotalResult("0");
                        totalResult = "1";
                    }else {
                        childVO.setCheckResult("1");
                    }
                    childVO.setCheckTime(format.format(daParamCollection.getCollectionTime()));
                    listChildVo.add(childVO);
                }
                childVO.setCheckTime(format.format(daParamCollection.getCollectionTime()));
                listChildVo.add(childVO);
            }
            parentVO.setCheckList(listChildVo);
            try{
@@ -763,32 +813,34 @@
    @Override
    public void manualWorkstationsAddBasicParameters(DaParamCollection daParamCollection) {
        // 假设这是从数据库或其他地方获取的参数数据
        Map<String, String> map = new HashMap<>();
        map.put("GC", "南浔工厂");
        map.put("CXBH", "Pack线");
        map.put("SBBH", "设备001");
        map.put("YGBH", SecurityUtils.getUsername());
        map.put("GDBH", daParamCollection.getWorkOrderNo());
        map.put("CPXH", daParamCollection.getProductCode());
        map.put("INT", format.format(daParamCollection.getInboundTime()));
        map.put("OUTT",format.format(new Date()));
        map.forEach((key, value) -> {
            DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
            daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode());
            daCollectionParamConf.setCollectParameterId(key);
            List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf);
            DaParamCollection saveData = new DaParamCollection();
            saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo());
            saveData.setProductCode(daParamCollection.getProductCode());
            saveData.setLocationCode(daParamCollection.getLocationCode());
            saveData.setSfcCode(daParamCollection.getProductBarcode());
            saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId());
            saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName());
            saveData.setCollectionTime(new Date());
            saveData.setParamValue(value);
            daParamCollectionMapper.insertDaParamCollection(saveData);
        });
//        Map<String, String> map = new HashMap<>();
//        map.put("GC", "南浔工厂");
//        map.put("CXBH", "Pack线");
//        map.put("SBBH", "设备001");
//        map.put("YGBH", SecurityUtils.getUsername());
//        map.put("GDBH", daParamCollection.getWorkOrderNo());
//        map.put("CPXH", daParamCollection.getProductCode());
//        map.put("INT", format.format(daParamCollection.getInboundTime()));
//        map.put("OUTT",format.format(new Date()));
//
//        map.forEach((key, value) -> {
//            DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
//            daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode());
//            daCollectionParamConf.setCollectParameterId(key);
//            List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf);
//            DaParamCollection saveData = new DaParamCollection();
//            saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo());
//            saveData.setProductCode(daParamCollection.getProductCode());
//            saveData.setLocationCode(daParamCollection.getLocationCode());
//            saveData.setSfcCode(daParamCollection.getProductBarcode());
//            if(daCollectionParamConfs.isEmpty()){
//                saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId());
//                saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName());
//            }
//            saveData.setCollectionTime(new Date());
//            saveData.setParamValue(value);
//            daParamCollectionMapper.insertDaParamCollection(saveData);
//        });
    }
    @Override