提交 | 用户 | 时间
|
fd2207
|
1 |
package com.jcdm.quartz.task; |
懒 |
2 |
|
1e3074
|
3 |
import cn.hutool.core.collection.CollUtil; |
55b0cb
|
4 |
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling; |
懒 |
5 |
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService; |
04b8ef
|
6 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
Y |
7 |
import com.jcdm.main.da.passingStationCollection.service.impl.DaPassingStationCollectionServiceImpl; |
1e3074
|
8 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
W |
9 |
import com.jcdm.main.om.productionOrde.service.impl.OmProductionOrdeInfoServiceImpl; |
55b0cb
|
10 |
import com.jcdm.main.webservice.service.ReceivingServices; |
懒 |
11 |
import org.springframework.beans.factory.annotation.Autowired; |
fd2207
|
12 |
import org.springframework.stereotype.Component; |
懒 |
13 |
import com.jcdm.common.utils.StringUtils; |
1a444b
|
14 |
import org.slf4j.Logger; |
Y |
15 |
import org.slf4j.LoggerFactory; |
55b0cb
|
16 |
|
1e3074
|
17 |
import javax.annotation.Resource; |
55b0cb
|
18 |
import java.util.List; |
1e3074
|
19 |
import java.util.Map; |
W |
20 |
import java.util.stream.Collectors; |
fd2207
|
21 |
|
懒 |
22 |
/** |
|
23 |
* 定时任务调度测试 |
|
24 |
* |
|
25 |
* @author jc |
|
26 |
*/ |
|
27 |
@Component("ryTask") |
|
28 |
public class RyTask |
|
29 |
{ |
04b8ef
|
30 |
@Autowired |
Y |
31 |
private DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl; |
|
32 |
@Autowired |
|
33 |
private IBsOrderSchedulingService bsOrderSchedulingService; |
1e3074
|
34 |
|
W |
35 |
@Resource |
|
36 |
private OmProductionOrdeInfoServiceImpl omProductionOrdeInfoService; |
|
37 |
|
|
38 |
|
1a444b
|
39 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
fd2207
|
40 |
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) |
懒 |
41 |
{ |
|
42 |
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); |
|
43 |
} |
|
44 |
|
|
45 |
public void ryParams(String params) |
|
46 |
{ |
|
47 |
System.out.println("执行有参方法:" + params); |
|
48 |
} |
|
49 |
|
|
50 |
public void ryNoParams() |
|
51 |
{ |
1e3074
|
52 |
logger.info("执行定时任务开始"); |
04b8ef
|
53 |
String a=passingStationCollectionServiceImpl.SelectSN("88","OP010"); |
1e3074
|
54 |
BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
W |
55 |
bsOrderScheduling.setRemarks("1"); |
|
56 |
List<BsOrderScheduling> bsOrderSchedulingList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
|
57 |
if (CollUtil.isNotEmpty(bsOrderSchedulingList)){ |
|
58 |
Map<String, List<BsOrderScheduling>> map = bsOrderSchedulingList.stream().collect(Collectors.groupingBy(BsOrderScheduling::getOrderNo)); |
|
59 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
60 |
for (String s : map.keySet()) { |
|
61 |
List<BsOrderScheduling> bsOrderSchedulings = map.get(s); |
|
62 |
if (CollUtil.isNotEmpty(bsOrderSchedulings)){ |
|
63 |
BsOrderScheduling scheduling = bsOrderSchedulings.get(0); |
|
64 |
int size = bsOrderSchedulings.size(); |
|
65 |
omProductionOrdeInfo.setPlanQty((long)size); |
|
66 |
omProductionOrdeInfo.setActualQty((long)0); |
|
67 |
omProductionOrdeInfo.setWorkOrderNo(s); |
|
68 |
omProductionOrdeInfo.setProductCode(scheduling.getModel()); |
|
69 |
omProductionOrdeInfo.setOrderStatus("2"); |
|
70 |
omProductionOrdeInfo.setTypeZ(scheduling.getModel()); |
|
71 |
omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo); |
|
72 |
logger.info("插入工单,{}",s); |
|
73 |
} |
|
74 |
} |
|
75 |
for (BsOrderScheduling scheduling : bsOrderSchedulingList) { |
|
76 |
scheduling.setRemarks("0"); |
49ca7c
|
77 |
scheduling.setProductionStatus("1"); |
1e3074
|
78 |
bsOrderSchedulingService.updateBsOrderScheduling(scheduling); |
W |
79 |
} |
|
80 |
|
|
81 |
} |
04b8ef
|
82 |
System.out.println("执行过程返回:" + a); |
1e3074
|
83 |
logger.info("定时任务执行结束"); |
fd2207
|
84 |
} |
55b0cb
|
85 |
|
282556
|
86 |
String url = "http://podqapp.cfmoto.com.cn:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_BC_001_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; |
55b0cb
|
87 |
public void workReportingTasks(){ |
懒 |
88 |
report10(); |
|
89 |
report20(); |
|
90 |
} |
|
91 |
|
|
92 |
public void report10(){ |
|
93 |
BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
|
94 |
bsOrderScheduling.setReport10("0"); |
|
95 |
List<BsOrderScheduling> bsOrderSchedulings = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
5030f3
|
96 |
String status=""; |
Y |
97 |
String ev_meassage=""; |
51b05b
|
98 |
if (CollUtil.isNotEmpty(bsOrderSchedulings)){ |
W |
99 |
BsOrderScheduling orderScheduling = bsOrderSchedulings.get(0); |
5030f3
|
100 |
try { |
Y |
101 |
String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0010")); |
|
102 |
ev_meassage=ReceivingServices.xmlToJSON1(xmlResult); |
|
103 |
status = ReceivingServices.xmlToJSON3(xmlResult); |
|
104 |
} catch (Exception e) { |
|
105 |
status="3"; |
|
106 |
} |
|
107 |
if(status.equals("1")) { |
55b0cb
|
108 |
orderScheduling.setReport10("1"); |
懒 |
109 |
int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); |
5030f3
|
110 |
logger.info("{}合箱报工成功",orderScheduling.getOrderNo()); |
Y |
111 |
}else { |
|
112 |
if(StringUtils.isEmpty(orderScheduling.getSpareField1())){ |
|
113 |
orderScheduling.setSpareField1("1"); |
|
114 |
bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); |
|
115 |
}else{ |
|
116 |
if(Integer.valueOf(orderScheduling.getSpareField1())+1>=3) { |
|
117 |
//累计报工异常超过3次 |
|
118 |
orderScheduling.setReport10("3"); |
|
119 |
orderScheduling.setSpareField1(String.valueOf(Integer.valueOf(orderScheduling.getSpareField1()) + 1)); |
|
120 |
}else { |
|
121 |
orderScheduling.setSpareField1(String.valueOf(Integer.valueOf(orderScheduling.getSpareField1()) + 1)); |
|
122 |
} |
|
123 |
bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); |
|
124 |
} |
|
125 |
if(status.equals("3")) |
|
126 |
logger.info("{}合箱报工因为网络原因,报工失败!",orderScheduling.getOrderNo()); |
|
127 |
else |
|
128 |
logger.info("{}合箱报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage); |
55b0cb
|
129 |
} |
懒 |
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
public void report20(){ |
|
134 |
BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
|
135 |
bsOrderScheduling.setReport20("0"); |
|
136 |
List<BsOrderScheduling> bsOrderSchedulings = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
5030f3
|
137 |
String status=""; |
Y |
138 |
String ev_meassage=""; |
51b05b
|
139 |
if (CollUtil.isNotEmpty(bsOrderSchedulings)){ |
W |
140 |
BsOrderScheduling orderScheduling = bsOrderSchedulings.get(0); |
5030f3
|
141 |
try { |
Y |
142 |
String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0020")); |
|
143 |
ev_meassage=ReceivingServices.xmlToJSON1(xmlResult); |
|
144 |
status = ReceivingServices.xmlToJSON3(xmlResult); |
|
145 |
} catch (Exception e) { |
|
146 |
status="3"; |
|
147 |
} |
55b0cb
|
148 |
if(status.equals("1")){ |
1a444b
|
149 |
orderScheduling.setReport20("1"); |
55b0cb
|
150 |
int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); |
5030f3
|
151 |
logger.info("{}总装报工成功",orderScheduling.getOrderNo()); |
Y |
152 |
}else { |
|
153 |
if(StringUtils.isEmpty(orderScheduling.getSpareField2())){ |
|
154 |
orderScheduling.setSpareField2("1"); |
|
155 |
bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); |
|
156 |
}else{ |
|
157 |
if(Integer.valueOf(orderScheduling.getSpareField2())+1>=3) { |
|
158 |
//累计报工异常超过3次 |
|
159 |
orderScheduling.setReport20("3"); |
|
160 |
orderScheduling.setSpareField2(String.valueOf(Integer.valueOf(orderScheduling.getSpareField2()) + 1)); |
|
161 |
}else{ |
|
162 |
orderScheduling.setSpareField2(String.valueOf(Integer.valueOf(orderScheduling.getSpareField2()) + 1)); |
|
163 |
} |
|
164 |
bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); |
|
165 |
if(status.equals("3")) |
|
166 |
logger.info("{}总装报工因为网络原因,报工失败!",orderScheduling.getOrderNo()); |
|
167 |
else |
|
168 |
logger.info("{}总装报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage); |
|
169 |
} |
55b0cb
|
170 |
} |
懒 |
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
public static String getProductionPlanInformationXml(String orderNo,String location){ |
|
175 |
String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + |
|
176 |
" <soapenv:Header/>\n" + |
|
177 |
" <soapenv:Body>\n" + |
|
178 |
" <urn:ZPP_BC_001>\n" + |
|
179 |
" <IV_AUFNR>"+orderNo+"</IV_AUFNR>\n" + |
|
180 |
" <IV_VORNR>"+location+"</IV_VORNR>\n" + |
|
181 |
" <IV_LMNGA>1</IV_LMNGA>\n" + |
|
182 |
" <IV_XMNGA>0</IV_XMNGA> \n" + |
|
183 |
" <IV_STATU>1</IV_STATU> \n" + |
|
184 |
" </urn:ZPP_BC_001>\n" + |
|
185 |
" </soapenv:Body>\n" + |
|
186 |
"</soapenv:Envelope>"; |
d4f437
|
187 |
//logger.info("{}",content); |
55b0cb
|
188 |
return content; |
懒 |
189 |
} |
fd2207
|
190 |
} |