-
admin
2025-03-26 5e0888a8dc804a4df27ce033b6c3429e530a9ef9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package com.billion.main.da.service.impl;
 
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Objects;
 
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.billion.main.bs.domain.BsBomChildInfo;
import com.billion.main.bs.service.IBsBomChildInfoService;
import com.billion.main.constant.Constants;
import com.billion.main.da.domain.CollectMT;
import com.billion.main.om.domain.OmOrderScheduling;
import com.billion.main.om.service.IOmOrderSchedulingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.billion.main.da.mapper.DaMaterialCollectionMapper;
import com.billion.main.da.domain.DaMaterialCollection;
import com.billion.main.da.service.IDaMaterialCollectionService;
 
/**
 * 物料采集Service业务层处理
 * 
 * @author Billion-Yi
 * @date 2024-11-22
 */
@Slf4j
@Service
public class DaMaterialCollectionServiceImpl extends ServiceImpl<DaMaterialCollectionMapper, DaMaterialCollection> implements IDaMaterialCollectionService
{
    @Autowired
    private DaMaterialCollectionMapper daMaterialCollectionMapper;
    @Autowired
    public IBsBomChildInfoService bsBomChildInfoService;
    @Autowired
    public IOmOrderSchedulingService omOrderSchedulingService;
    /**
     * 查询物料采集
     * 
     * @param id 物料采集主键
     * @return 物料采集
     */
    @Override
    public DaMaterialCollection selectDaMaterialCollectionById(Long id)
    {
        return daMaterialCollectionMapper.selectDaMaterialCollectionById(id);
    }
 
    /**
     * 查询物料采集列表
     * 
     * @param daMaterialCollection 物料采集
     * @return 物料采集
     */
    @Override
    public List<DaMaterialCollection> selectDaMaterialCollectionList(DaMaterialCollection daMaterialCollection)
    {
        return daMaterialCollectionMapper.selectDaMaterialCollectionList(daMaterialCollection);
    }
 
    /**
     * 新增物料采集
     * 
     * @param daMaterialCollection 物料采集
     * @return 结果
     */
    @Override
    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()) ||
                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();
        //要改!!!!
        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");
        }
 
        this.save(daMaterialCollection1);
        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("推送失败");
        }
//        this.save(daMaterialCollection);
    }
 
 
//    @Override
//    public void insertDaMaterialCollectionOP020OP130(DaMaterialCollection DaMaterialCollection)
//    {
//
////        this.save(daMaterialCollection);
//    }
//
 
    /**
     * 修改物料采集
     * 
     * @param daMaterialCollection 物料采集
     * @return 结果
     */
    @Override
    public int updateDaMaterialCollection(DaMaterialCollection daMaterialCollection)
    {
        return daMaterialCollectionMapper.updateDaMaterialCollection(daMaterialCollection);
    }
 
    /**
     * 批量删除物料采集
     * 
     * @param ids 需要删除的物料采集主键
     * @return 结果
     */
    @Override
    public int deleteDaMaterialCollectionByIds(Long[] ids)
    {
        return daMaterialCollectionMapper.deleteDaMaterialCollectionByIds(ids);
    }
 
    /**
     * 删除物料采集信息
     * 
     * @param id 物料采集主键
     * @return 结果
     */
    @Override
    public int deleteDaMaterialCollectionById(Long id)
    {
        return daMaterialCollectionMapper.deleteDaMaterialCollectionById(id);
    }
 
    @Override
    public void plusSave(DaMaterialCollection daMaterialCollection) {
        this.save(daMaterialCollection);
    }
}