admin
2024-07-26 b849c6d6056a6783914546fed92399472e34f9dd
提交 | 用户 | 时间
258f26 1 package com.jcdm.main.restful.qingYan.service;
A 2
fd7bc3 3 import cn.hutool.core.collection.CollUtil;
a846f2 4 import cn.hutool.core.util.ObjectUtil;
fd7bc3 5 import cn.hutool.core.util.StrUtil;
3581b1 6 import cn.hutool.http.HttpRequest;
A 7 import cn.hutool.http.HttpResponse;
768498 8 import cn.hutool.json.JSONObject;
3581b1 9 import cn.hutool.json.JSONUtil;
258f26 10 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
A 11 import com.fasterxml.jackson.core.JsonProcessingException;
616f98 12 import com.fasterxml.jackson.databind.ObjectMapper;
4e83fa 13 import com.google.gson.Gson;
3581b1 14 import com.jcdm.common.core.domain.AjaxResult;
a846f2 15 import com.jcdm.common.utils.StringUtils;
d76bba 16 import com.jcdm.framework.websocket.WebSocketUsers;
768498 17 import com.jcdm.main.bs.beatSetting.domain.BsBeatSetting;
A 18 import com.jcdm.main.bs.beatSetting.service.IBsBeatSettingService;
1ccd69 19 import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo;
A 20 import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService;
fd7bc3 21 import com.jcdm.main.constant.Constants;
258f26 22 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
A 23 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
fd7bc3 24 import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
W 25 import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
616f98 26 import com.jcdm.main.da.testDeviceInterface.domain.DaTestDeviceInterface;
A 27 import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService;
258f26 28 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
A 29 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
768498 30 import com.jcdm.main.restful.factoryMes.service.RestfulService;
68f0c8 31 import com.jcdm.main.restful.qingYan.doman.*;
d76bba 32 import lombok.extern.slf4j.Slf4j;
1ccd69 33 import org.aspectj.weaver.loadtime.Aj;
d76bba 34 import org.slf4j.Logger;
A 35 import org.slf4j.LoggerFactory;
258f26 36 import org.springframework.beans.factory.annotation.Autowired;
1ccd69 37 import org.springframework.web.bind.annotation.*;
258f26 38
fd7bc3 39 import javax.annotation.Resource;
d76bba 40 import javax.websocket.Session;
258f26 41 import java.lang.reflect.Field;
fd7bc3 42 import java.text.ParseException;
W 43 import java.text.SimpleDateFormat;
1ccd69 44 import java.util.*;
d76bba 45 import java.util.concurrent.CompletableFuture;
fd7bc3 46 import java.util.stream.Collectors;
d76bba 47 @Slf4j
258f26 48 @RestController
A 49 @RequestMapping("/jcdmMes")
50 public class ExternalInterface {
d76bba 51     Map<String, Session> map = WebSocketUsers.getUsers();
A 52
53     private static final Logger logger = LoggerFactory.getLogger("sys-user");
54
019f1c 55     public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
A 56
258f26 57     @Autowired
616f98 58     private IDaTestDeviceInterfaceService daTestDeviceInterfaceService;
A 59     @Autowired
258f26 60     private IDaParamCollectionService daParamCollectionService;
fd7bc3 61
W 62     @Resource
63     private IDaPassingStationCollectionService daPassingStationCollectionService;
258f26 64
A 65     @Autowired
66     private IOmProductionOrdeInfoService productionOrdeInfoService;
1ccd69 67
A 68     @Autowired
69     private IOmProductionOrdeInfoService omProductionOrdeInfoService;
70
71     @Autowired
72     private IBsFormulaChildInfoService bsFormulaChildInfoService;
768498 73
A 74     @Autowired
75     private IBsBeatSettingService bsBeatSettingService;
68f0c8 76
A 77     private IDaPassingStationCollectionService passingStationCollectionService;
1ccd69 78
a846f2 79 //    String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback";
982c84 80
a846f2 81     String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback";
3581b1 82
A 83     /**
84      * 导出点检任务列表
85      */
86     @PostMapping("/deviceResultFeedback")
273d64 87     public AjaxResult deviceResultFeedback(@RequestBody ParentVO parentVO)
3581b1 88     {
616f98 89         ObjectMapper mapper = new ObjectMapper();
A 90         List<ChildVO> li = parentVO.getCheckList();
91         String s = null;
92         try {
93             s = mapper.writeValueAsString(li);
94         } catch (JsonProcessingException e) {
95             throw new RuntimeException(e);
fd7bc3 96         }
616f98 97         DaTestDeviceInterface daTestDeviceInterface = new DaTestDeviceInterface();
A 98         daTestDeviceInterface.setRecordId(parentVO.getRecordId());
99         daTestDeviceInterface.setStationCode(parentVO.getStationCode());
100         daTestDeviceInterface.setProductNum(parentVO.getProductNum());
101         daTestDeviceInterface.setTotalResult(parentVO.getTotalResult());
102         daTestDeviceInterface.setCheckList(s);
a846f2 103         daTestDeviceInterface.setCreateTime(new Date());
616f98 104         daTestDeviceInterfaceService.save(daTestDeviceInterface);
b849c6 105 //        if(parentVO.getStationCode().contains("POP410")){
A 106 //            if(StringUtils.isNotBlank(parentVO.getProductNum())){
107 //                OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, parentVO.getProductNum()));
108 //                if(ObjectUtil.isNotNull(one)){
109 //                    logger.info("解绑小车{},pack码是{}"+one.getTrolleyYard(),one.getProductNum());
110 //                    one.setTrolleyYard("");
111 //                    omProductionOrdeInfoService.saveOrUpdate(one);
112 //                }
113 //            }
114 //        }
d76bba 115 //        try{
A 116 //            CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
117 //                logger.info("开始执行异步方法");
118 //                HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute();
119 //                logger.info("异步方法执行结束");
120 //                logger.info("接收清研,气密异步方法{}"+execute.body());
121 //            });
122 //        }catch (Exception e){
123 //            System.out.println(e.getMessage());
124 //        }
4e83fa 125         logger.info("收到工位{}的测试设备数据入参VO{}" + parentVO.getStationCode(),new Gson().toJson(parentVO));
3581b1 126         HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute();
4e83fa 127         logger.info("工厂MES返回报文{}-工位{}" + execute.body(),parentVO.getStationCode());
3581b1 128         return AjaxResult.success(execute.body());
A 129     }
130
1ccd69 131     @GetMapping("/productionWorkOrderRequest")
A 132     public AjaxResult productionWorkOrderRequest(){
68f0c8 133         List<RestFulOrder> restFulOrders = new ArrayList<>();
273d64 134 //        try{
A 135 //            CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
136 //                List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list();
137 //                for (OmProductionOrdeInfo omProductionOrdeInfo : list) {
138 //                    RestFulOrder order = new RestFulOrder();
139 //                    order.setProductionOrderNum(omProductionOrdeInfo.getWorkOrderNo());
140 //                    order.setProductNum(omProductionOrdeInfo.getProductNum());
141 //                    order.setMaterialCode(omProductionOrdeInfo.getMaterialCode());
142 //                    order.setStationCode(omProductionOrdeInfo.getStationCode());
143 //                    order.setPlanQty(omProductionOrdeInfo.getPlanQty());
144 //                    order.setCreateTime(format.format(omProductionOrdeInfo.getCreateTime()));
145 //                    restFulOrders.add(order);
146 //                }
147 //            });
148 //        }catch (Exception e){
149 //            System.out.println(e.getMessage());
150 //        }
68f0c8 151         return AjaxResult.success(restFulOrders);
768498 152     }
A 153
68f0c8 154     @GetMapping("/getQualityData")
A 155     public AjaxResult getQualityData(){
768498 156 //        List<DaPassingStationCollection> qualified = daPassingStationCollectionService.list(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getOutRsSign, "1"));
A 157 //        List<DaPassingStationCollection> unQualified = daPassingStationCollectionService.list(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getOutRsSign, "2"));
158 //        Map<String,Integer> map = new HashMap<>();
159 //        map.put("qualified",qualified.size());
160 //        map.put("unQualified",unQualified.size());
273d64 161 //        for (BsBeatSetting bsBeatSetting : bsBeatSettingService.list()) {
A 162 //            String str = bsBeatSetting.getProductCode();
163 //            String[] split = str.split("  ");
164 //            String reportResult = RestfulService.getWorkReportResultFeedback(split[0], "", "2024-06-27 15:48:51");
165 //            JSONObject jsonObject = new JSONObject(reportResult);
166 //            String code = jsonObject.getStr("code");
167 //            String status = jsonObject.getJSONObject("data").getStr("resultCode");
168 //            if("success".equals(code)&&"S".equals(status)){
169 //                //如果成功,执行报工成功方法,修改是否报工为1,添加报工时间
170 //                bsBeatSetting.setProductName("S");
171 //                this.bsBeatSettingService.saveOrUpdate(bsBeatSetting);
172 //            }else{
173 //                bsBeatSetting.setProductName("F");
174 //                this.bsBeatSettingService.saveOrUpdate(bsBeatSetting);
175 //            }
176 //        }
768498 177         return AjaxResult.success();
68f0c8 178     }
A 179
180
1ccd69 181
A 182     @GetMapping("/productionOrderComponentRequest")
183     public AjaxResult productionOrderComponentRequest(BsFormulaChildInfo bsFormulaChildInfo){
68f0c8 184         List<ProductionOrderComponentRequest> requests = new ArrayList<>();
273d64 185 //        try{
A 186 //            CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
187 //                List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
188 //                        .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getProcessesCode())
189 //                        .eq(BsFormulaChildInfo::getOperationType, "2")
190 //                );
191 //                for (BsFormulaChildInfo info : list) {
192 //                    ProductionOrderComponentRequest request = new ProductionOrderComponentRequest();
193 //                    request.setMaterialCode(info.getMaterialCode());
194 //                    request.setOperationSteps(info.getOperationSteps());
195 //                    requests.add(request);
196 //                }
197 //            });
198 //        }catch (Exception e){
199 //            System.out.println(e.getMessage());
200 //        }
68f0c8 201         return AjaxResult.success(requests);
258f26 202     }
A 203
d76bba 204     /**
A 205      * 放行请空状态
206      */
207     @PostMapping("/sendWebSocket")
208     public void sendWebSocket(@RequestBody BsFormulaChildInfo bsFormulaChildInfo)
209     {
210         WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), bsFormulaChildInfo.getResults());
211     }
258f26 212 }