提交 | 用户 | 时间
|
258f26
|
1 |
package com.jcdm.main.restful.qingYan.service; |
A |
2 |
|
fd7bc3
|
3 |
import cn.hutool.core.collection.CollUtil; |
W |
4 |
import cn.hutool.core.util.StrUtil; |
3581b1
|
5 |
import cn.hutool.http.HttpRequest; |
A |
6 |
import cn.hutool.http.HttpResponse; |
|
7 |
import cn.hutool.json.JSONUtil; |
258f26
|
8 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
A |
9 |
import com.fasterxml.jackson.core.JsonProcessingException; |
616f98
|
10 |
import com.fasterxml.jackson.databind.ObjectMapper; |
3581b1
|
11 |
import com.jcdm.common.core.domain.AjaxResult; |
1ccd69
|
12 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
A |
13 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
fd7bc3
|
14 |
import com.jcdm.main.constant.Constants; |
258f26
|
15 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
A |
16 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
fd7bc3
|
17 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
W |
18 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
616f98
|
19 |
import com.jcdm.main.da.testDeviceInterface.domain.DaTestDeviceInterface; |
A |
20 |
import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService; |
258f26
|
21 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
A |
22 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
68f0c8
|
23 |
import com.jcdm.main.restful.qingYan.doman.*; |
1ccd69
|
24 |
import org.aspectj.weaver.loadtime.Aj; |
258f26
|
25 |
import org.springframework.beans.factory.annotation.Autowired; |
1ccd69
|
26 |
import org.springframework.web.bind.annotation.*; |
258f26
|
27 |
|
fd7bc3
|
28 |
import javax.annotation.Resource; |
258f26
|
29 |
import java.lang.reflect.Field; |
fd7bc3
|
30 |
import java.text.ParseException; |
W |
31 |
import java.text.SimpleDateFormat; |
1ccd69
|
32 |
import java.util.*; |
fd7bc3
|
33 |
import java.util.stream.Collectors; |
258f26
|
34 |
|
A |
35 |
@RestController |
|
36 |
@RequestMapping("/jcdmMes") |
|
37 |
public class ExternalInterface { |
|
38 |
@Autowired |
616f98
|
39 |
private IDaTestDeviceInterfaceService daTestDeviceInterfaceService; |
A |
40 |
@Autowired |
258f26
|
41 |
private IDaParamCollectionService daParamCollectionService; |
fd7bc3
|
42 |
|
W |
43 |
@Resource |
|
44 |
private IDaPassingStationCollectionService daPassingStationCollectionService; |
258f26
|
45 |
|
A |
46 |
@Autowired |
|
47 |
private IOmProductionOrdeInfoService productionOrdeInfoService; |
1ccd69
|
48 |
|
A |
49 |
@Autowired |
|
50 |
private IOmProductionOrdeInfoService omProductionOrdeInfoService; |
|
51 |
|
|
52 |
@Autowired |
|
53 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
68f0c8
|
54 |
|
A |
55 |
private IDaPassingStationCollectionService passingStationCollectionService; |
1ccd69
|
56 |
|
258f26
|
57 |
|
3581b1
|
58 |
String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
A |
59 |
|
|
60 |
/** |
|
61 |
* 导出点检任务列表 |
|
62 |
*/ |
|
63 |
@PostMapping("/deviceResultFeedback") |
|
64 |
public AjaxResult hdy(@RequestBody ParentVO parentVO) |
|
65 |
{ |
fd7bc3
|
66 |
//保存 |
W |
67 |
//过站记录 |
616f98
|
68 |
// String productNum = parentVO.getProductNum(); |
A |
69 |
// if (StrUtil.isNotBlank(productNum)){ |
|
70 |
// List<OmProductionOrdeInfo> list = productionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, productNum)); |
|
71 |
// if (CollUtil.isNotEmpty(list)){ |
|
72 |
// OmProductionOrdeInfo omProductionOrdeInfo = list.get(0); |
|
73 |
// DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
74 |
// passingStationCollection.setWorkOrderNo(omProductionOrdeInfo.getWorkOrderNo()); |
|
75 |
// passingStationCollection.setSfcCode(productNum); |
|
76 |
// passingStationCollection.setProductCode(omProductionOrdeInfo.getProductCode()); |
|
77 |
// passingStationCollection.setLocationCode(parentVO.getStationCode()); |
|
78 |
// passingStationCollection.setOutRsSign(parentVO.getTotalResult()); |
|
79 |
// passingStationCollection.setCreateTime(new Date()); |
|
80 |
// |
|
81 |
// List<ChildVO> checkList = parentVO.getCheckList(); |
|
82 |
// if (CollUtil.isNotEmpty(checkList)){ |
|
83 |
// List<String> collect = checkList.stream() |
|
84 |
// .filter(x -> Constants.IN_BOUND_TIME_CODE.equals(x.getItemCode())) |
|
85 |
// .map(ChildVO::getItemValue) |
|
86 |
// .collect(Collectors.toList()); |
|
87 |
// if (CollUtil.isNotEmpty(collect)){ |
|
88 |
// String s = collect.get(0); |
|
89 |
// if (StrUtil.isNotBlank(s)){ |
|
90 |
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
91 |
// try { |
|
92 |
// Date parse = simpleDateFormat.parse(s); |
|
93 |
// passingStationCollection.setInboundTime(parse); |
|
94 |
// } catch (ParseException e) { |
|
95 |
// throw new RuntimeException(e); |
|
96 |
// } |
|
97 |
// } |
|
98 |
// } |
|
99 |
// List<String> collect2 = checkList.stream() |
|
100 |
// .filter(x -> Constants.OUT_BOUND_TIME_CODE.equals(x.getItemCode())) |
|
101 |
// .map(ChildVO::getItemValue) |
|
102 |
// .collect(Collectors.toList()); |
|
103 |
// if (CollUtil.isNotEmpty(collect2)){ |
|
104 |
// String s = collect2.get(0); |
|
105 |
// if (StrUtil.isNotBlank(s)){ |
|
106 |
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
107 |
// try { |
|
108 |
// Date parse = simpleDateFormat.parse(s); |
|
109 |
// passingStationCollection.setOutboundTime(parse); |
|
110 |
// } catch (ParseException e) { |
|
111 |
// throw new RuntimeException(e); |
|
112 |
// } |
|
113 |
// } |
|
114 |
// } |
|
115 |
// daPassingStationCollectionService.save(passingStationCollection); |
|
116 |
// //参数保存 |
|
117 |
// List<DaParamCollection> paramCollectionList = new ArrayList<>(); |
|
118 |
// for (ChildVO childVO : checkList) { |
|
119 |
// DaParamCollection daParamCollection = new DaParamCollection(); |
|
120 |
// daParamCollection.setWorkOrderNo(omProductionOrdeInfo.getWorkOrderNo()); |
|
121 |
// daParamCollection.setSfcCode(productNum); |
|
122 |
// daParamCollection.setProductCode(omProductionOrdeInfo.getProductCode()); |
|
123 |
// daParamCollection.setLocationCode(omProductionOrdeInfo.getStationCode()); |
|
124 |
// daParamCollection.setParamCode(childVO.getItemCode()); |
|
125 |
// daParamCollection.setParamValue(childVO.getItemValue()); |
|
126 |
// daParamCollection.setCollectionTime(new Date()); |
|
127 |
// daParamCollection.setParamName(childVO.getItemText()); |
|
128 |
// paramCollectionList.add(daParamCollection); |
|
129 |
// } |
|
130 |
// if (CollUtil.isNotEmpty(paramCollectionList)){ |
|
131 |
// daParamCollectionService.insertBatch(paramCollectionList); |
|
132 |
// } |
|
133 |
// } |
|
134 |
// } |
|
135 |
// } |
|
136 |
ObjectMapper mapper = new ObjectMapper(); |
|
137 |
List<ChildVO> li = parentVO.getCheckList(); |
|
138 |
String s = null; |
|
139 |
try { |
|
140 |
s = mapper.writeValueAsString(li); |
|
141 |
} catch (JsonProcessingException e) { |
|
142 |
throw new RuntimeException(e); |
fd7bc3
|
143 |
} |
616f98
|
144 |
DaTestDeviceInterface daTestDeviceInterface = new DaTestDeviceInterface(); |
A |
145 |
daTestDeviceInterface.setRecordId(parentVO.getRecordId()); |
|
146 |
daTestDeviceInterface.setStationCode(parentVO.getStationCode()); |
|
147 |
daTestDeviceInterface.setProductNum(parentVO.getProductNum()); |
|
148 |
daTestDeviceInterface.setTotalResult(parentVO.getTotalResult()); |
|
149 |
daTestDeviceInterface.setCheckList(s); |
|
150 |
daTestDeviceInterfaceService.save(daTestDeviceInterface); |
3581b1
|
151 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
A |
152 |
return AjaxResult.success(execute.body()); |
|
153 |
} |
|
154 |
|
1ccd69
|
155 |
@GetMapping("/productionWorkOrderRequest") |
A |
156 |
public AjaxResult productionWorkOrderRequest(){ |
|
157 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(); |
68f0c8
|
158 |
List<RestFulOrder> restFulOrders = new ArrayList<>(); |
A |
159 |
for (OmProductionOrdeInfo omProductionOrdeInfo : list) { |
|
160 |
RestFulOrder order = new RestFulOrder(); |
|
161 |
order.setProductionOrderNum(omProductionOrdeInfo.getWorkOrderNo()); |
|
162 |
order.setProductNum(omProductionOrdeInfo.getProductNum()); |
|
163 |
order.setMaterialCode(omProductionOrdeInfo.getMaterialCode()); |
|
164 |
order.setStationCode(omProductionOrdeInfo.getStationCode()); |
|
165 |
// order.setPlanQty(omProductionOrdeInfo.getPlanQty()); |
|
166 |
restFulOrders.add(order); |
|
167 |
} |
|
168 |
return AjaxResult.success(restFulOrders); |
1ccd69
|
169 |
} |
68f0c8
|
170 |
|
A |
171 |
@GetMapping("/getQualityData") |
|
172 |
public AjaxResult getQualityData(){ |
|
173 |
List<DaPassingStationCollection> qualified = daPassingStationCollectionService.list(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getOutRsSign, "1")); |
|
174 |
List<DaPassingStationCollection> unQualified = daPassingStationCollectionService.list(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getOutRsSign, "2")); |
|
175 |
Map<String,Integer> map = new HashMap<>(); |
|
176 |
map.put("qualified",qualified.size()); |
|
177 |
map.put("unQualified",unQualified.size()); |
|
178 |
return AjaxResult.success(map); |
|
179 |
} |
|
180 |
|
|
181 |
|
1ccd69
|
182 |
|
A |
183 |
@GetMapping("/productionOrderComponentRequest") |
|
184 |
public AjaxResult productionOrderComponentRequest(BsFormulaChildInfo bsFormulaChildInfo){ |
|
185 |
Map<String,List<String>> map = new HashMap<>(); |
|
186 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
|
187 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getProcessesCode()) |
|
188 |
.eq(BsFormulaChildInfo::getOperationType, "2") |
|
189 |
); |
68f0c8
|
190 |
List<ProductionOrderComponentRequest> requests = new ArrayList<>(); |
A |
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 |
return AjaxResult.success(requests); |
1ccd69
|
198 |
} |
A |
199 |
|
258f26
|
200 |
|
A |
201 |
@PostMapping("/pushParamData") |
|
202 |
public void receivingData(@RequestBody PostEntity postEntity) throws JsonProcessingException { |
|
203 |
// ObjectMapper objectMapper = new ObjectMapper(); |
|
204 |
// PostEntity person = objectMapper.readValue(postEntity, PostEntity.class); |
|
205 |
|
|
206 |
|
|
207 |
Class<?> entityClass = PostEntity.class; // 替换为你的实体类 |
|
208 |
String packId = postEntity.getPEOL_PackID(); |
|
209 |
OmProductionOrdeInfo one = productionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, packId)); |
|
210 |
String productType = "type"; |
|
211 |
String workOrderNo = one.getWorkOrderNo(); |
|
212 |
for (Field field : entityClass.getDeclaredFields()) { |
|
213 |
String fieldName = field.getName(); |
|
214 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
215 |
daParamCollection.setWorkOrderNo(workOrderNo); |
|
216 |
daParamCollection.setProductCode(productType); |
|
217 |
daParamCollection.setSfcCode(packId); |
|
218 |
daParamCollection.setParamCode(field.getName()); |
|
219 |
daParamCollection.setParamValue((String) getFieldValue(postEntity, fieldName)); |
|
220 |
if(fieldName.contains("GDBH")){ |
|
221 |
daParamCollection.setParamValue(workOrderNo); |
|
222 |
} |
|
223 |
if(fieldName.contains("CPXH")){ |
|
224 |
daParamCollection.setParamValue(productType); |
|
225 |
} |
|
226 |
daParamCollectionService.save(daParamCollection); |
|
227 |
} |
|
228 |
|
|
229 |
} |
|
230 |
|
|
231 |
|
|
232 |
/** |
|
233 |
* 使用反射获取对象的属性值 |
|
234 |
* |
|
235 |
* @param obj 目标对象 |
|
236 |
* @param fieldName 属性名 |
|
237 |
* @return 属性值,如果获取失败则返回null |
|
238 |
*/ |
|
239 |
public static Object getFieldValue(Object obj, String fieldName) { |
|
240 |
if (obj == null) { |
|
241 |
throw new IllegalArgumentException("Object must not be null"); |
|
242 |
} |
|
243 |
try { |
|
244 |
Field field = obj.getClass().getDeclaredField(fieldName); |
|
245 |
field.setAccessible(true); // 设置可访问性,以便访问私有字段 |
|
246 |
return field.get(obj); |
|
247 |
} catch (NoSuchFieldException e) { |
|
248 |
// 如果当前类没有该字段,则尝试从父类中获取 |
|
249 |
Class<?> superClass = obj.getClass().getSuperclass(); |
|
250 |
if (superClass != null && !superClass.equals(Object.class)) { |
|
251 |
return getFieldValue(obj, fieldName, superClass); |
|
252 |
} |
|
253 |
e.printStackTrace(); |
|
254 |
} catch (IllegalAccessException e) { |
|
255 |
e.printStackTrace(); |
|
256 |
} |
|
257 |
return null; |
|
258 |
} |
|
259 |
|
|
260 |
private static Object getFieldValue(Object obj, String fieldName, Class<?> superClass) { |
|
261 |
try { |
|
262 |
Field field = superClass.getDeclaredField(fieldName); |
|
263 |
field.setAccessible(true); |
|
264 |
return field.get(obj); |
|
265 |
} catch (NoSuchFieldException e) { |
|
266 |
// 如果父类也没有该字段,则继续向上查找 |
|
267 |
Class<?> grandParentClass = superClass.getSuperclass(); |
|
268 |
if (grandParentClass != null && !grandParentClass.equals(Object.class)) { |
|
269 |
return getFieldValue(obj, fieldName, grandParentClass); |
|
270 |
} |
|
271 |
e.printStackTrace(); |
|
272 |
} catch (IllegalAccessException e) { |
|
273 |
e.printStackTrace(); |
|
274 |
} |
|
275 |
return null; |
|
276 |
} |
|
277 |
|
|
278 |
} |