admin
2024-10-20 537bfb7e43c78d5b3b98ba8a135b638f0461ea60
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
package com.jcdm.main.bs.batchInfo.service.impl;
 
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.CompletableFuture;
 
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.jcdm.common.utils.DateUtils;
import com.jcdm.main.bs.beatSetting.domain.BsBeatSetting;
import com.jcdm.main.bs.beatSetting.mapper.BsBeatSettingMapper;
import com.jcdm.main.bs.beatSetting.service.IBsBeatSettingService;
import com.jcdm.main.constant.Constants;
import com.jcdm.main.restful.qingYan.doman.ChildVO;
import com.jcdm.main.restful.qingYan.doman.ParentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jcdm.main.bs.batchInfo.mapper.BsBatchInfoMapper;
import com.jcdm.main.bs.batchInfo.domain.BsBatchInfo;
import com.jcdm.main.bs.batchInfo.service.IBsBatchInfoService;
 
/**
 * 批次信息录入Service业务层处理
 * 
 * @author Yi
 * @date 2024-10-15
 */
@Service
public class BsBatchInfoServiceImpl extends ServiceImpl<BsBatchInfoMapper, BsBatchInfo> implements IBsBatchInfoService
{
    @Autowired
    private BsBatchInfoMapper bsBatchInfoMapper;
 
    /**
     * 查询批次信息录入
     * 
     * @param id 批次信息录入主键
     * @return 批次信息录入
     */
    @Override
    public BsBatchInfo selectBsBatchInfoById(Long id)
    {
        return bsBatchInfoMapper.selectBsBatchInfoById(id);
    }
 
    /**
     * 查询批次信息录入列表
     * 
     * @param bsBatchInfo 批次信息录入
     * @return 批次信息录入
     */
    @Override
    public List<BsBatchInfo> selectBsBatchInfoList(BsBatchInfo bsBatchInfo)
    {
        return bsBatchInfoMapper.selectBsBatchInfoList(bsBatchInfo);
    }
 
    /**
     * 新增批次信息录入
     * 
     * @param bsBatchInfo 批次信息录入
     * @return 结果
     */
    @Override
    public int insertBsBatchInfo(BsBatchInfo bsBatchInfo)
    {
        bsBatchInfo.setChangeTime(DateUtils.getNowDate());
        bsBatchInfo.setCreateTime(DateUtils.getNowDate());
        return bsBatchInfoMapper.insertBsBatchInfo(bsBatchInfo);
    }
 
    /**
     * 修改批次信息录入
     * 
     * @param bsBatchInfo 批次信息录入
     * @return 结果
     */
    @Override
    public int updateBsBatchInfo(BsBatchInfo bsBatchInfo)
    {
        bsBatchInfo.setUpdateTime(DateUtils.getNowDate());
        return bsBatchInfoMapper.updateBsBatchInfo(bsBatchInfo);
    }
 
    /**
     * 批量删除批次信息录入
     * 
     * @param ids 需要删除的批次信息录入主键
     * @return 结果
     */
    @Override
    public int deleteBsBatchInfoByIds(Long[] ids)
    {
        return bsBatchInfoMapper.deleteBsBatchInfoByIds(ids);
    }
 
    /**
     * 删除批次信息录入信息
     * 
     * @param id 批次信息录入主键
     * @return 结果
     */
    @Override
    public int deleteBsBatchInfoById(Long id)
    {
        return bsBatchInfoMapper.deleteBsBatchInfoById(id);
    }
 
    @Override
    public int bacthInput(Long[] ids) {
        Integer sendData = 0;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Set<Long> idSet = new HashSet<>(Arrays.asList(ids));
        List<BsBatchInfo> bsBatchInfos = this.listByIds(idSet);
        for (BsBatchInfo bsBatchInfo : bsBatchInfos) {
            ParentVO parentVO = new ParentVO();
            parentVO.setSiteCode("3983");
            parentVO.setRecordId(String.valueOf(Instant.now().toEpochMilli()));
            parentVO.setStationCode(bsBatchInfo.getStationCode());
            parentVO.setProductNum(format.format(new Date()));
            parentVO.setTotalResult("1");
            List<ChildVO> listChildVo = new ArrayList<>();
            ChildVO childVO = new ChildVO();
            childVO.setItemCode(bsBatchInfo.getMaterialCode());
            childVO.setItemType("3");
            childVO.setItemText(bsBatchInfo.getMaterialName());
            childVO.setItemValue(bsBatchInfo.getBatch());
            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());
                    bsBatchInfo.setFlag("Y");
                    this.saveOrUpdate(bsBatchInfo);
                });
            }catch (Exception e){
                System.out.println(e.getMessage());
            }
            sendData = sendData+1;
        }
        return sendData;
    }
}