hdy
2025-03-29 1717a12c83db01e3b31ea9ed913e5bacaf9edbf3
billion-main/src/main/java/com/billion/main/da/service/impl/DaMaterialCollectionServiceImpl.java
@@ -1,6 +1,7 @@
package com.billion.main.da.service.impl;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -71,15 +72,16 @@
    public void insertDaMaterialCollection(DaMaterialCollection daMaterialCollection)
    {
        String url = "http://172.40.161.71:8890/Interaction/CollectMT";
        CollectMT collectMT = new CollectMT();
        DaMaterialCollection  daMaterialCollection1 = new DaMaterialCollection();
        BsBomChildInfo bsBomChildInfo = new BsBomChildInfo();
        OmOrderScheduling omOrderScheduling = new OmOrderScheduling();
        daMaterialCollection1.setSfcCode(daMaterialCollection.getSfcCode());
        daMaterialCollection1.setLocationCode(daMaterialCollection.getLocationCode());
        daMaterialCollection1.setParamValue(daMaterialCollection.getParamValue());
        daMaterialCollection1.setCollectTime(daMaterialCollection.getCollectTime());
        omOrderScheduling.setSfcCode(daMaterialCollection.getSfcCode());
        if(     Constants.PLC1.contains(daMaterialCollection.getLocationCode()) ||
                Constants.C005.equals(daMaterialCollection.getLocationCode()) ||
@@ -87,33 +89,27 @@
        {omOrderScheduling.setRemarks("Head");}
        else if(
                Constants.PLC2.contains(daMaterialCollection.getLocationCode()) ||
                        Constants.OP005.equals(daMaterialCollection.getLocationCode()) ||
                        Constants.OP310.equals(daMaterialCollection.getLocationCode()))
                Constants.OP005.equals(daMaterialCollection.getLocationCode()) ||
                Constants.OP310.equals(daMaterialCollection.getLocationCode()))
        {omOrderScheduling.setRemarks("Body");}
        else if(Constants.P010.equals(daMaterialCollection.getLocationCode()))
        {omOrderScheduling.setRemarks("Pre");}
        List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling);
        String OrderNumber = omOrderSchedulingList.get(0).getWorkOrderNo();
        //要改!!!!
        if(Objects.equals(daMaterialCollection.getLocationCode(), "OP130") || Objects.equals(daMaterialCollection.getLocationCode(), "OP020")){
            daMaterialCollection1.setMaterialCode("0");
            daMaterialCollection1.setMaterialName("0");
            collectMT.setMaterial1("0");
        }else{
//            bsBomChildInfo.setLocationCode(daMaterialCollection.getLocationCode());
//            bsBomChildInfo.setBomCode(OrderNumber);
//            List<BsBomChildInfo> bsBomChildInfoList = bsBomChildInfoService.selectBsBomChildInfoList(bsBomChildInfo);
//            String MaterialCode = bsBomChildInfoList.get(0).getMaterialCode();
//            String MaterialName = bsBomChildInfoList.get(0).getMaterialName();
//            daMaterialCollection1.setMaterialCode(MaterialCode);
//            daMaterialCollection1.setMaterialName(MaterialName);
//            collectMT.setMaterial1(MaterialName);
            daMaterialCollection1.setMaterialCode("0");
            daMaterialCollection1.setMaterialName("0");
            collectMT.setMaterial1("0");
        }
            bsBomChildInfo.setLocationCode(daMaterialCollection.getLocationCode());
            bsBomChildInfo.setBomCode(OrderNumber);
            String[] parts = daMaterialCollection.getParamValue().split("#");
            String targetValue = parts[1]; // 取第二个元素(索引1)
            bsBomChildInfo.setMaterialCode(targetValue);
            List<BsBomChildInfo> bsBomChildInfoList = bsBomChildInfoService.selectBsBomChildInfoList(bsBomChildInfo);
            String MaterialCode = bsBomChildInfoList.get(0).getMaterialCode();
            String MaterialName = bsBomChildInfoList.get(0).getMaterialName();
            daMaterialCollection1.setMaterialCode(MaterialCode);
            daMaterialCollection1.setMaterialName(MaterialName);
        this.save(daMaterialCollection1);
        collectMT.setMaterial1(MaterialName);
        collectMT.setOrderNumber(OrderNumber);
        collectMT.setEngineNumber(daMaterialCollection.getSfcCode());
        collectMT.setStationName(daMaterialCollection.getLocationCode());
@@ -131,13 +127,53 @@
    }
//    @Override
//    public void insertDaMaterialCollectionOP020OP130(DaMaterialCollection DaMaterialCollection)
//    {
//
////        this.save(daMaterialCollection);
//    }
//
    @Override
    public void plusSave(DaMaterialCollection daMaterialCollection) {
        String url = "http://172.40.161.71:8890/Interaction/CollectMT";
        CollectMT collectMT = new CollectMT();
        DaMaterialCollection  daMaterialCollection1 = new DaMaterialCollection();
        BsBomChildInfo bsBomChildInfo = new BsBomChildInfo();
        OmOrderScheduling omOrderScheduling = new OmOrderScheduling();
        daMaterialCollection1.setSfcCode(daMaterialCollection.getSfcCode());
        daMaterialCollection1.setLocationCode(daMaterialCollection.getLocationCode());
        daMaterialCollection1.setParamValue(daMaterialCollection.getParamValue());
        daMaterialCollection1.setCollectTime(daMaterialCollection.getCollectTime());
        omOrderScheduling.setSfcCode(daMaterialCollection.getSfcCode());
        omOrderScheduling.setSfcCode(daMaterialCollection.getSfcCode());
        if(     Constants.PLC1.contains(daMaterialCollection.getLocationCode()) ||
                Constants.C005.equals(daMaterialCollection.getLocationCode()) ||
                Constants.C060.equals(daMaterialCollection.getLocationCode()) )
        {omOrderScheduling.setRemarks("Head");}
        else if(
                Constants.PLC2.contains(daMaterialCollection.getLocationCode()) ||
                        Constants.OP005.equals(daMaterialCollection.getLocationCode()) ||
                        Constants.OP310.equals(daMaterialCollection.getLocationCode()))
        {omOrderScheduling.setRemarks("Body");}
        else if(Constants.P010.equals(daMaterialCollection.getLocationCode()))
        {omOrderScheduling.setRemarks("Pre");}
        List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling);
        String OrderNumber = omOrderSchedulingList.get(0).getWorkOrderNo();
        String[] parts = daMaterialCollection.getParamValue().split("#");
        String targetValue = parts[1]; // 取第二个元素(索引1)
        daMaterialCollection1.setMaterialCode(targetValue);
        daMaterialCollection1.setMaterialName(daMaterialCollection.getParamName());
        this.save(daMaterialCollection1);
        collectMT.setMaterial1(daMaterialCollection.getMaterialName());
        collectMT.setOrderNumber(OrderNumber);
        collectMT.setEngineNumber(daMaterialCollection.getSfcCode());
        collectMT.setStationName(daMaterialCollection.getLocationCode());
        collectMT.setPartsNumber(daMaterialCollection.getParamValue());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        collectMT.setInsertTime(sdf.format(daMaterialCollection.getCollectTime()));
        try {
            HttpResponse response = HttpRequest.post(url).body(JSONUtil.toJsonStr(collectMT)).execute();
            log.info("推送成功,响应报文: {}", response);
        } catch (Exception e) {
            // 记录日志
            log.error("推送失败");
        }
    }
    /**
     * 修改物料采集
@@ -174,4 +210,5 @@
    {
        return daMaterialCollectionMapper.deleteDaMaterialCollectionById(id);
    }
}
}