春风项目四线(合箱线、总装线)
wujian
2024-07-24 49ca7cac33b124324250f307b12ce84370daa2f3
提交 | 用户 | 时间
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="";
55b0cb 98         for (BsOrderScheduling orderScheduling : bsOrderSchedulings) {
5030f3 99             try {
Y 100                 String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0010"));
101                 ev_meassage=ReceivingServices.xmlToJSON1(xmlResult);
102                 status = ReceivingServices.xmlToJSON3(xmlResult);
103             } catch (Exception e) {
104                 status="3";
105             }
106             if(status.equals("1")) {
55b0cb 107                 orderScheduling.setReport10("1");
108                 int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
5030f3 109                 logger.info("{}合箱报工成功",orderScheduling.getOrderNo());
Y 110             }else {
111                 if(StringUtils.isEmpty(orderScheduling.getSpareField1())){
112                     orderScheduling.setSpareField1("1");
113                     bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
114                 }else{
115                     if(Integer.valueOf(orderScheduling.getSpareField1())+1>=3) {
116                         //累计报工异常超过3次
117                         orderScheduling.setReport10("3");
118                         orderScheduling.setSpareField1(String.valueOf(Integer.valueOf(orderScheduling.getSpareField1()) + 1));
119                     }else {
120                         orderScheduling.setSpareField1(String.valueOf(Integer.valueOf(orderScheduling.getSpareField1()) + 1));
121                     }
122                     bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
123                 }
124                 if(status.equals("3"))
125                     logger.info("{}合箱报工因为网络原因,报工失败!",orderScheduling.getOrderNo());
126                 else
127                     logger.info("{}合箱报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage);
55b0cb 128             }
129         }
130     }
131
132     public void report20(){
133         BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
134         bsOrderScheduling.setReport20("0");
135         List<BsOrderScheduling> bsOrderSchedulings = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
5030f3 136         String status="";
Y 137         String ev_meassage="";
55b0cb 138         for (BsOrderScheduling orderScheduling : bsOrderSchedulings) {
5030f3 139             try {
Y 140                 String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0020"));
141                 ev_meassage=ReceivingServices.xmlToJSON1(xmlResult);
142                 status = ReceivingServices.xmlToJSON3(xmlResult);
143             } catch (Exception e) {
144                 status="3";
145             }
55b0cb 146             if(status.equals("1")){
1a444b 147                 orderScheduling.setReport20("1");
55b0cb 148                 int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
5030f3 149                 logger.info("{}总装报工成功",orderScheduling.getOrderNo());
Y 150             }else {
151                 if(StringUtils.isEmpty(orderScheduling.getSpareField2())){
152                     orderScheduling.setSpareField2("1");
153                     bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
154                 }else{
155                     if(Integer.valueOf(orderScheduling.getSpareField2())+1>=3) {
156                         //累计报工异常超过3次
157                         orderScheduling.setReport20("3");
158                         orderScheduling.setSpareField2(String.valueOf(Integer.valueOf(orderScheduling.getSpareField2()) + 1));
159                     }else{
160                         orderScheduling.setSpareField2(String.valueOf(Integer.valueOf(orderScheduling.getSpareField2()) + 1));
161                     }
162                     bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
163                     if(status.equals("3"))
164                         logger.info("{}总装报工因为网络原因,报工失败!",orderScheduling.getOrderNo());
165                     else
166                         logger.info("{}总装报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage);
167                 }
55b0cb 168             }
169         }
170     }
171
172     public static String getProductionPlanInformationXml(String orderNo,String location){
173         String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" +
174                 "   <soapenv:Header/>\n" +
175                 "   <soapenv:Body>\n" +
176                 "      <urn:ZPP_BC_001>\n" +
177                 "         <IV_AUFNR>"+orderNo+"</IV_AUFNR>\n" +
178                 "          <IV_VORNR>"+location+"</IV_VORNR>\n" +
179                 "           <IV_LMNGA>1</IV_LMNGA>\n" +
180                 "           <IV_XMNGA>0</IV_XMNGA>   \n" +
181                 "         <IV_STATU>1</IV_STATU>  \n" +
182                 "      </urn:ZPP_BC_001>\n" +
183                 "   </soapenv:Body>\n" +
184                 "</soapenv:Envelope>";
d4f437 185         //logger.info("{}",content);
55b0cb 186         return content;
187     }
fd2207 188 }