提交 | 用户 | 时间
|
0ca254
|
1 |
package com.jcdm.main.restful.qingYan.service; |
A |
2 |
|
|
3 |
import cn.hutool.core.collection.CollUtil; |
|
4 |
import cn.hutool.core.util.ObjectUtil; |
|
5 |
import cn.hutool.core.util.StrUtil; |
|
6 |
import cn.hutool.http.HttpRequest; |
|
7 |
import cn.hutool.http.HttpResponse; |
|
8 |
import cn.hutool.json.JSONObject; |
|
9 |
import cn.hutool.json.JSONUtil; |
|
10 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
11 |
import com.fasterxml.jackson.core.JsonProcessingException; |
0691dd
|
12 |
import com.fasterxml.jackson.databind.JsonNode; |
0ca254
|
13 |
import com.fasterxml.jackson.databind.ObjectMapper; |
A |
14 |
import com.jcdm.common.core.domain.AjaxResult; |
|
15 |
import com.jcdm.common.utils.StringUtils; |
|
16 |
import com.jcdm.framework.websocket.WebSocketUsers; |
|
17 |
import com.jcdm.main.bs.beatSetting.domain.BsBeatSetting; |
|
18 |
import com.jcdm.main.bs.beatSetting.service.IBsBeatSettingService; |
|
19 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
|
20 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
|
21 |
import com.jcdm.main.constant.Constants; |
0691dd
|
22 |
import com.jcdm.main.da.cellData.domain.DaCellData; |
A |
23 |
import com.jcdm.main.da.cellData.service.IDaCellDataService; |
0ca254
|
24 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
A |
25 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
|
26 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
|
27 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
|
28 |
import com.jcdm.main.da.testDeviceInterface.domain.DaTestDeviceInterface; |
|
29 |
import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService; |
475e40
|
30 |
import com.jcdm.main.da.testDeviceInterfaceTemp.domain.DaTestDeviceInterfaceTemp; |
A |
31 |
import com.jcdm.main.da.testDeviceInterfaceTemp.service.IDaTestDeviceInterfaceTempService; |
0ca254
|
32 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
A |
33 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
|
34 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
|
35 |
import com.jcdm.main.restful.qingYan.doman.*; |
|
36 |
import lombok.extern.slf4j.Slf4j; |
|
37 |
import org.aspectj.weaver.loadtime.Aj; |
|
38 |
import org.slf4j.Logger; |
|
39 |
import org.slf4j.LoggerFactory; |
|
40 |
import org.springframework.beans.factory.annotation.Autowired; |
|
41 |
import org.springframework.web.bind.annotation.*; |
|
42 |
|
|
43 |
import javax.annotation.Resource; |
|
44 |
import javax.websocket.Session; |
|
45 |
import java.lang.reflect.Field; |
|
46 |
import java.text.ParseException; |
|
47 |
import java.text.SimpleDateFormat; |
|
48 |
import java.util.*; |
|
49 |
import java.util.concurrent.CompletableFuture; |
|
50 |
import java.util.stream.Collectors; |
|
51 |
@Slf4j |
|
52 |
@RestController |
|
53 |
@RequestMapping("/jcdmMes") |
|
54 |
public class ExternalInterface { |
|
55 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
|
56 |
|
|
57 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
|
58 |
|
|
59 |
public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
60 |
|
|
61 |
@Autowired |
|
62 |
private IDaTestDeviceInterfaceService daTestDeviceInterfaceService; |
|
63 |
|
|
64 |
@Autowired |
|
65 |
private IOmProductionOrdeInfoService omProductionOrdeInfoService; |
|
66 |
|
|
67 |
@Autowired |
|
68 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
|
69 |
|
|
70 |
@Autowired |
0691dd
|
71 |
private IDaCellDataService daCellDataService; |
0ca254
|
72 |
|
475e40
|
73 |
@Autowired |
A |
74 |
private IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService; |
|
75 |
|
0691dd
|
76 |
String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
0ca254
|
77 |
|
0691dd
|
78 |
// String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
0ca254
|
79 |
|
0691dd
|
80 |
/** |
A |
81 |
* 20工位接收清研数据 |
|
82 |
*/ |
|
83 |
@PostMapping("/receiveOVCDataFrom020Workstations") |
|
84 |
public AjaxResult receiveOVCDataFrom020Workstations(@RequestBody ParentVO parentVO) |
|
85 |
{ |
|
86 |
|
|
87 |
return AjaxResult.success(null); |
|
88 |
} |
0ca254
|
89 |
|
A |
90 |
/** |
|
91 |
* 导出点检任务列表 |
|
92 |
*/ |
|
93 |
@PostMapping("/deviceResultFeedback") |
0691dd
|
94 |
public AjaxResult deviceResultFeedback(@RequestBody ParentVO parentVO) |
0ca254
|
95 |
{ |
A |
96 |
ObjectMapper mapper = new ObjectMapper(); |
|
97 |
List<ChildVO> li = parentVO.getCheckList(); |
475e40
|
98 |
String checkList = ""; |
0ca254
|
99 |
try { |
475e40
|
100 |
checkList = mapper.writeValueAsString(li); |
0ca254
|
101 |
} catch (JsonProcessingException e) { |
A |
102 |
throw new RuntimeException(e); |
|
103 |
} |
475e40
|
104 |
this.saveDaTestDeviceInterface(parentVO,checkList); |
A |
105 |
if(parentVO.getStationCode().equals("M1OP020")){ |
|
106 |
this.saveDaTestDeviceInterfaceTemp(parentVO,checkList); |
|
107 |
} |
|
108 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
109 |
return AjaxResult.success(execute.body()); |
|
110 |
} |
|
111 |
|
|
112 |
public void saveDaTestDeviceInterface(ParentVO parentVO,String checkList){ |
0ca254
|
113 |
DaTestDeviceInterface daTestDeviceInterface = new DaTestDeviceInterface(); |
A |
114 |
daTestDeviceInterface.setRecordId(parentVO.getRecordId()); |
|
115 |
daTestDeviceInterface.setStationCode(parentVO.getStationCode()); |
|
116 |
daTestDeviceInterface.setProductNum(parentVO.getProductNum()); |
|
117 |
daTestDeviceInterface.setTotalResult(parentVO.getTotalResult()); |
475e40
|
118 |
daTestDeviceInterface.setCheckList(checkList); |
0ca254
|
119 |
daTestDeviceInterface.setCreateTime(new Date()); |
A |
120 |
daTestDeviceInterfaceService.save(daTestDeviceInterface); |
475e40
|
121 |
} |
A |
122 |
|
|
123 |
public void saveDaTestDeviceInterfaceTemp(ParentVO parentVO,String checkList){ |
|
124 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = new DaTestDeviceInterfaceTemp(); |
|
125 |
daTestDeviceInterfaceTemp.setRecordId(parentVO.getRecordId()); |
|
126 |
daTestDeviceInterfaceTemp.setStationCode(parentVO.getStationCode()); |
|
127 |
daTestDeviceInterfaceTemp.setProductNum(parentVO.getProductNum()); |
|
128 |
daTestDeviceInterfaceTemp.setTotalResult(parentVO.getTotalResult()); |
|
129 |
daTestDeviceInterfaceTemp.setCheckList(checkList); |
|
130 |
daTestDeviceInterfaceTemp.setCreateTime(new Date()); |
|
131 |
daTestDeviceInterfaceTempService.save(daTestDeviceInterfaceTemp); |
0ca254
|
132 |
} |
A |
133 |
|
|
134 |
@GetMapping("/productionWorkOrderRequest") |
|
135 |
public AjaxResult productionWorkOrderRequest(){ |
|
136 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(); |
|
137 |
List<RestFulOrder> restFulOrders = new ArrayList<>(); |
|
138 |
for (OmProductionOrdeInfo omProductionOrdeInfo : list) { |
|
139 |
RestFulOrder order = new RestFulOrder(); |
|
140 |
order.setProductionOrderNum(omProductionOrdeInfo.getWorkOrderNo()); |
|
141 |
order.setProductNum(omProductionOrdeInfo.getProductNum()); |
|
142 |
order.setMaterialCode(omProductionOrdeInfo.getMaterialCode()); |
|
143 |
order.setStationCode(omProductionOrdeInfo.getStationCode()); |
|
144 |
order.setPlanQty(omProductionOrdeInfo.getPlanQty()); |
|
145 |
order.setCreateTime(format.format(omProductionOrdeInfo.getCreateTime())); |
|
146 |
restFulOrders.add(order); |
|
147 |
} |
|
148 |
return AjaxResult.success(restFulOrders); |
|
149 |
} |
|
150 |
|
|
151 |
@GetMapping("/productionOrderComponentRequest") |
|
152 |
public AjaxResult productionOrderComponentRequest(BsFormulaChildInfo bsFormulaChildInfo){ |
|
153 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
|
154 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getProcessesCode()) |
|
155 |
.eq(BsFormulaChildInfo::getOperationType, "2") |
|
156 |
); |
|
157 |
List<ProductionOrderComponentRequest> requests = new ArrayList<>(); |
|
158 |
for (BsFormulaChildInfo info : list) { |
|
159 |
ProductionOrderComponentRequest request = new ProductionOrderComponentRequest(); |
|
160 |
request.setMaterialCode(info.getMaterialCode()); |
|
161 |
request.setOperationSteps(info.getOperationSteps()); |
|
162 |
requests.add(request); |
|
163 |
} |
|
164 |
return AjaxResult.success(requests); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* 放行请空状态 |
|
169 |
*/ |
|
170 |
@PostMapping("/sendWebSocket") |
|
171 |
public void sendWebSocket(@RequestBody BsFormulaChildInfo bsFormulaChildInfo) |
|
172 |
{ |
22c9e0
|
173 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
A |
174 |
logger.info("接收电芯开始执行异步方法"); |
|
175 |
WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), bsFormulaChildInfo.getResults()); |
|
176 |
logger.info("接收电芯异步方法执行结束"); |
|
177 |
}); |
|
178 |
// WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), bsFormulaChildInfo.getResults()); |
0ca254
|
179 |
} |
A |
180 |
|
|
181 |
/** |
0691dd
|
182 |
* 接收电芯数据 |
0ca254
|
183 |
*/ |
0691dd
|
184 |
@PostMapping("/receivingBatteryCellData") |
bd9653
|
185 |
public AjaxResult receivingBatteryCellData(@RequestBody CellDataVo cellDataVo){ |
A |
186 |
try { |
|
187 |
ObjectMapper objectMapper = new ObjectMapper(); |
|
188 |
JSONObject jsonObject = new JSONObject(cellDataVo); |
|
189 |
String cellListString = jsonObject.getStr("cellList"); |
|
190 |
JsonNode cellListNode = objectMapper.readValue(cellListString, JsonNode.class); |
|
191 |
List<DaCellData> daCellDataList = new ArrayList<>(); |
|
192 |
for (JsonNode jsonNode : cellListNode) { |
|
193 |
String cellCheckListString = jsonNode.path("cellCheckList").toString(); |
|
194 |
JsonNode cellCheckListNode = objectMapper.readValue(cellCheckListString, JsonNode.class); |
|
195 |
for (JsonNode checkNode : cellCheckListNode) { |
22c9e0
|
196 |
if(checkNode.path("cellItem").toString().replaceAll("\"", "").equals("电芯挡位")){ |
A |
197 |
DaCellData daCellData = new DaCellData(); |
|
198 |
daCellData.setSiteCode(jsonObject.getStr("siteCode")); |
|
199 |
daCellData.setModuleSerial(jsonObject.getStr("moduleSerial")); |
|
200 |
daCellData.setModuleModel(jsonObject.getStr("moduleModel")); |
|
201 |
daCellData.setAbModule(jsonObject.getStr("ABModule")); |
|
202 |
daCellData.setPackageNo(jsonObject.getStr("packageNo")); |
|
203 |
daCellData.setSupplierModuleBarcode(jsonObject.getStr("supplierModuleBarcode")); |
|
204 |
daCellData.setCustomerModuleBarcode(jsonObject.getStr("customerModuleBarcode")); |
|
205 |
daCellData.setCellSerial(jsonNode.path("cellSerial").toString().replaceAll("\"", "")); |
|
206 |
daCellData.setCellModel(jsonNode.path("cellModel").toString().replaceAll("\"", "")); |
|
207 |
daCellData.setGbCellCode(jsonNode.path("GBCellCode").toString().replaceAll("\"", "")); |
|
208 |
daCellData.setGbModuleCode(jsonNode.path("GBModuleCode").toString().replaceAll("\"", "")); |
|
209 |
daCellData.setCellItem(checkNode.path("cellItem").toString().replaceAll("\"", "")); |
|
210 |
daCellData.setCellValue(checkNode.path("cellValue").toString().replaceAll("\"", "")); |
|
211 |
daCellData.setCreateUser("工厂MES"); |
|
212 |
daCellData.setCreateTime(new Date()); |
|
213 |
daCellDataList.add(daCellData); |
|
214 |
} |
|
215 |
// DaCellData daCellData = new DaCellData(); |
|
216 |
// daCellData.setSiteCode(jsonObject.getStr("siteCode")); |
|
217 |
// daCellData.setModuleSerial(jsonObject.getStr("moduleSerial")); |
|
218 |
// daCellData.setModuleModel(jsonObject.getStr("moduleModel")); |
|
219 |
// daCellData.setAbModule(jsonObject.getStr("ABModule")); |
|
220 |
// daCellData.setPackageNo(jsonObject.getStr("packageNo")); |
|
221 |
// daCellData.setSupplierModuleBarcode(jsonObject.getStr("supplierModuleBarcode")); |
|
222 |
// daCellData.setCustomerModuleBarcode(jsonObject.getStr("customerModuleBarcode")); |
|
223 |
// daCellData.setCellSerial(jsonNode.path("cellSerial").toString().replaceAll("\"", "")); |
|
224 |
// daCellData.setCellModel(jsonNode.path("cellModel").toString().replaceAll("\"", "")); |
|
225 |
// daCellData.setGbCellCode(jsonNode.path("GBCellCode").toString().replaceAll("\"", "")); |
|
226 |
// daCellData.setGbModuleCode(jsonNode.path("GBModuleCode").toString().replaceAll("\"", "")); |
|
227 |
// daCellData.setCellItem(checkNode.path("cellItem").toString().replaceAll("\"", "")); |
|
228 |
// daCellData.setCellValue(checkNode.path("cellValue").toString().replaceAll("\"", "")); |
|
229 |
// daCellData.setCreateUser("工厂MES"); |
|
230 |
// daCellData.setCreateTime(new Date()); |
|
231 |
// daCellDataList.add(daCellData); |
bd9653
|
232 |
} |
0ca254
|
233 |
} |
8f92f2
|
234 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
5e34d9
|
235 |
logger.info("接收电芯开始执行异步方法"); |
8f92f2
|
236 |
daCellDataService.insertBatch(daCellDataList); |
A |
237 |
logger.info("接收电芯异步方法执行结束"); |
|
238 |
}); |
|
239 |
|
bd9653
|
240 |
return AjaxResult.success("API调用成功"); |
A |
241 |
}catch (Exception e){ |
|
242 |
return AjaxResult.error("API调用失败"); |
0ca254
|
243 |
} |
A |
244 |
} |
|
245 |
|
|
246 |
} |