-
admin
2024-05-14 616f9896be815a60b5c4063116b7d138892dcfaf
-
已修改5个文件
196 ■■■■■ 文件已修改
jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/controller/DaParamCollectionController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/plcserver/util/TimeUtil.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/restful/qingYan/service/ExternalInterface.java 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/controller/DaParamCollectionController.java
@@ -47,7 +47,7 @@
    @GetMapping("/testput")
    public void testput()
    {
        daParamCollectionService.pushGeelycvMesFeedback("80012","OP240");
        daParamCollectionService.pushGeelycvMesFeedback("0RSPB001139E3AE5B0000002","OP470");
    }
    /**
jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
@@ -475,4 +475,5 @@
        }
    }
}
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -264,7 +264,7 @@
                    //1、更新工单信息
                    updateOrderInfo(snCode);
                }
                daParamCollectionService.pushGeelycvMesFeedback(snCode,device);
                result = "21";
            }
@@ -324,8 +324,8 @@
        daPassingStationCollection.setLocationCode(device);
        String strt = TimeUtil.stringProcessing(startTime);
        String end = TimeUtil.stringProcessing(stopTime);
        daPassingStationCollection.setInboundTime(sdf.parse(strt));//入站时间
        daPassingStationCollection.setOutboundTime(sdf.parse(end));//出站时间
        daPassingStationCollection.setInboundTime(format.parse(TimeUtil.test(strt)));//入站时间
        daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//出站时间
        daPassingStationCollection.setOutRsSign(stationStatus);//出站是否合格
        daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection);
    }
@@ -358,7 +358,7 @@
                    if(tt.contains("Time")){
//                        String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt));
//                        ParamCollection.setParamValue(str);
                        ParamCollection.setParamValue(TimeUtil.getYyyyDdMm(TimeUtil.stringProcessing(tt)));
                        ParamCollection.setParamValue(TimeUtil.test(TimeUtil.stringProcessing(tt)));
                    }else {
                        ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
                    }
jcdm-main/src/main/java/com/jcdm/main/plcserver/util/TimeUtil.java
@@ -2,14 +2,18 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class TimeUtil {
    public static void main(String[] args) {
        String str = "PACK.OP360.ModuleSNCode1";
        System.out.println(str.charAt(str.length()-1));
        String dateString = "Tue May 14 18:25:18 CST 2024";
//        System.out.println(test(dateString));
        System.out.println(test( stringProcessing("DateTime{utcTime=133601559184960000, javaDate=Tue May 14 18:25:18 CST 2024}")));
    }
    public static String stringProcessing(String dateTimeStr){
@@ -79,4 +83,31 @@
        String outputDate = formatter.format(date);
        return outputDate;
    }
    public static String test(String param){
        String str = "";
        // 创建一个SimpleDateFormat对象来解析输入的日期字符串(假设CST为中国标准时间)
        SimpleDateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
        inputFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); // 设置为中国时区
        Date date = null;
        try {
            date = inputFormat.parse(param);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        // 创建一个SimpleDateFormat对象来格式化日期为UTC时间
        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        outputFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置为UTC时区
        // 格式化日期
        if (date != null) {
            str = outputFormat.format(date);
        }
        return str;
    }
}
jcdm-main/src/main/java/com/jcdm/main/restful/qingYan/service/ExternalInterface.java
@@ -7,12 +7,15 @@
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jcdm.common.core.domain.AjaxResult;
import com.jcdm.main.constant.Constants;
import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
import com.jcdm.main.da.testDeviceInterface.domain.DaTestDeviceInterface;
import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService;
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
import com.jcdm.main.restful.qingYan.doman.ChildVO;
@@ -37,6 +40,8 @@
@RequestMapping("/jcdmMes")
public class ExternalInterface {
    @Autowired
    private IDaTestDeviceInterfaceService daTestDeviceInterfaceService;
    @Autowired
    private IDaParamCollectionService daParamCollectionService;
    @Resource
@@ -55,74 +60,89 @@
    {
        //保存
        //过站记录
        String productNum = parentVO.getProductNum();
        if (StrUtil.isNotBlank(productNum)){
            List<OmProductionOrdeInfo> list = productionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, productNum));
            if (CollUtil.isNotEmpty(list)){
                OmProductionOrdeInfo omProductionOrdeInfo = list.get(0);
                DaPassingStationCollection passingStationCollection = new DaPassingStationCollection();
                passingStationCollection.setWorkOrderNo(omProductionOrdeInfo.getWorkOrderNo());
                passingStationCollection.setSfcCode(productNum);
                passingStationCollection.setProductCode(omProductionOrdeInfo.getProductCode());
                passingStationCollection.setLocationCode(parentVO.getStationCode());
                passingStationCollection.setOutRsSign(parentVO.getTotalResult());
                passingStationCollection.setCreateTime(new Date());
                List<ChildVO> checkList = parentVO.getCheckList();
                if (CollUtil.isNotEmpty(checkList)){
                    List<String> collect = checkList.stream()
                            .filter(x -> Constants.IN_BOUND_TIME_CODE.equals(x.getItemCode()))
                            .map(ChildVO::getItemValue)
                            .collect(Collectors.toList());
                    if (CollUtil.isNotEmpty(collect)){
                        String s = collect.get(0);
                        if (StrUtil.isNotBlank(s)){
                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String productNum = parentVO.getProductNum();
//        if (StrUtil.isNotBlank(productNum)){
//            List<OmProductionOrdeInfo> list = productionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, productNum));
//            if (CollUtil.isNotEmpty(list)){
//                OmProductionOrdeInfo omProductionOrdeInfo = list.get(0);
//                DaPassingStationCollection passingStationCollection = new DaPassingStationCollection();
//                passingStationCollection.setWorkOrderNo(omProductionOrdeInfo.getWorkOrderNo());
//                passingStationCollection.setSfcCode(productNum);
//                passingStationCollection.setProductCode(omProductionOrdeInfo.getProductCode());
//                passingStationCollection.setLocationCode(parentVO.getStationCode());
//                passingStationCollection.setOutRsSign(parentVO.getTotalResult());
//                passingStationCollection.setCreateTime(new Date());
//
//                List<ChildVO> checkList = parentVO.getCheckList();
//                if (CollUtil.isNotEmpty(checkList)){
//                    List<String> collect = checkList.stream()
//                            .filter(x -> Constants.IN_BOUND_TIME_CODE.equals(x.getItemCode()))
//                            .map(ChildVO::getItemValue)
//                            .collect(Collectors.toList());
//                    if (CollUtil.isNotEmpty(collect)){
//                        String s = collect.get(0);
//                        if (StrUtil.isNotBlank(s)){
//                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                            try {
//                                Date parse = simpleDateFormat.parse(s);
//                                passingStationCollection.setInboundTime(parse);
//                            } catch (ParseException e) {
//                                throw new RuntimeException(e);
//                            }
//                        }
//                    }
//                    List<String> collect2 = checkList.stream()
//                            .filter(x -> Constants.OUT_BOUND_TIME_CODE.equals(x.getItemCode()))
//                            .map(ChildVO::getItemValue)
//                            .collect(Collectors.toList());
//                    if (CollUtil.isNotEmpty(collect2)){
//                        String s = collect2.get(0);
//                        if (StrUtil.isNotBlank(s)){
//                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                            try {
//                                Date parse = simpleDateFormat.parse(s);
//                                passingStationCollection.setOutboundTime(parse);
//                            } catch (ParseException e) {
//                                throw new RuntimeException(e);
//                            }
//                        }
//                    }
//                    daPassingStationCollectionService.save(passingStationCollection);
//                    //参数保存
//                    List<DaParamCollection> paramCollectionList = new ArrayList<>();
//                    for (ChildVO childVO : checkList) {
//                        DaParamCollection daParamCollection = new DaParamCollection();
//                        daParamCollection.setWorkOrderNo(omProductionOrdeInfo.getWorkOrderNo());
//                        daParamCollection.setSfcCode(productNum);
//                        daParamCollection.setProductCode(omProductionOrdeInfo.getProductCode());
//                        daParamCollection.setLocationCode(omProductionOrdeInfo.getStationCode());
//                        daParamCollection.setParamCode(childVO.getItemCode());
//                        daParamCollection.setParamValue(childVO.getItemValue());
//                        daParamCollection.setCollectionTime(new Date());
//                        daParamCollection.setParamName(childVO.getItemText());
//                        paramCollectionList.add(daParamCollection);
//                    }
//                    if (CollUtil.isNotEmpty(paramCollectionList)){
//                        daParamCollectionService.insertBatch(paramCollectionList);
//                    }
//                }
//            }
//        }
        ObjectMapper mapper = new ObjectMapper();
        List<ChildVO> li = parentVO.getCheckList();
        String s = null;
                            try {
                                Date parse = simpleDateFormat.parse(s);
                                passingStationCollection.setInboundTime(parse);
                            } catch (ParseException e) {
            s = mapper.writeValueAsString(li);
        } catch (JsonProcessingException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }
                    List<String> collect2 = checkList.stream()
                            .filter(x -> Constants.OUT_BOUND_TIME_CODE.equals(x.getItemCode()))
                            .map(ChildVO::getItemValue)
                            .collect(Collectors.toList());
                    if (CollUtil.isNotEmpty(collect2)){
                        String s = collect2.get(0);
                        if (StrUtil.isNotBlank(s)){
                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            try {
                                Date parse = simpleDateFormat.parse(s);
                                passingStationCollection.setOutboundTime(parse);
                            } catch (ParseException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }
                    daPassingStationCollectionService.save(passingStationCollection);
                    //参数保存
                    List<DaParamCollection> paramCollectionList = new ArrayList<>();
                    for (ChildVO childVO : checkList) {
                        DaParamCollection daParamCollection = new DaParamCollection();
                        daParamCollection.setWorkOrderNo(omProductionOrdeInfo.getWorkOrderNo());
                        daParamCollection.setSfcCode(productNum);
                        daParamCollection.setProductCode(omProductionOrdeInfo.getProductCode());
                        daParamCollection.setLocationCode(omProductionOrdeInfo.getStationCode());
                        daParamCollection.setParamCode(childVO.getItemCode());
                        daParamCollection.setParamValue(childVO.getItemValue());
                        daParamCollection.setCollectionTime(new Date());
                        daParamCollection.setParamName(childVO.getItemText());
                        paramCollectionList.add(daParamCollection);
                    }
                    if (CollUtil.isNotEmpty(paramCollectionList)){
                        daParamCollectionService.insertBatch(paramCollectionList);
                    }
                }
            }
        }
        DaTestDeviceInterface daTestDeviceInterface = new DaTestDeviceInterface();
        daTestDeviceInterface.setRecordId(parentVO.getRecordId());
        daTestDeviceInterface.setStationCode(parentVO.getStationCode());
        daTestDeviceInterface.setProductNum(parentVO.getProductNum());
        daTestDeviceInterface.setTotalResult(parentVO.getTotalResult());
        daTestDeviceInterface.setCheckList(s);
        daTestDeviceInterfaceService.save(daTestDeviceInterface);
        HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute();
        return AjaxResult.success(execute.body());
    }