提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.plcserver.server.BOP010.impl; |
懒 |
2 |
|
|
3 |
|
|
4 |
import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
|
5 |
import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
|
6 |
import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
|
7 |
import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
|
8 |
import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
|
9 |
import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
|
10 |
import cn.stylefeng.guns.modular.dq.materialTraceability.model.result.MaterialTraceabilityResult; |
|
11 |
import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
|
12 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
|
13 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
|
14 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
|
15 |
import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
|
16 |
import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
|
17 |
import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
|
18 |
import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.params.SerialNumbersConfParam; |
|
19 |
import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.result.SerialNumbersConfResult; |
|
20 |
import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
|
21 |
import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
|
22 |
import cn.stylefeng.guns.plcserver.opc.OPCComm; |
|
23 |
import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
|
24 |
import cn.stylefeng.guns.plcserver.opc.unit.qrCode; |
|
25 |
import cn.stylefeng.guns.plcserver.server.BOP010.BOP010ServerInterface; |
|
26 |
import cn.stylefeng.guns.plcserver.tool.DateTool; |
|
27 |
import cn.stylefeng.guns.plcserver.tool.LogUtil; |
|
28 |
import org.apache.commons.lang3.StringUtils; |
|
29 |
import org.apache.log4j.Logger; |
|
30 |
import org.openscada.opc.lib.da.Group; |
|
31 |
|
|
32 |
import java.util.Date; |
|
33 |
import java.util.List; |
|
34 |
import java.util.Random; |
|
35 |
|
|
36 |
|
|
37 |
public class BOP010ServerInterfaceImpl implements BOP010ServerInterface { |
|
38 |
|
|
39 |
private static Logger logger; |
|
40 |
LogUtil logUtil = new LogUtil(); |
|
41 |
static { |
|
42 |
logger = Logger.getLogger(BOP010ServerInterfaceImpl.class); |
|
43 |
} |
|
44 |
|
|
45 |
private OPCComm opc = OPCComm.getInstance(); |
|
46 |
private static Date IN_TIME = null; |
|
47 |
private static String S_ORDER_CODE = "";//工单编号 |
|
48 |
private static String S_PRODUCT_CODE = "";//产品编号 |
|
49 |
private static String S_PRODUCT_TYPE= "";//产品类型 |
|
50 |
private static String S_PRODUCT_CODE_OLD = "";//产品编号 |
|
51 |
private static String S_SFC_CODE = "";//总成编码 |
|
52 |
private static String S_RIGHT_CODE = "";//右壳体编码 |
|
53 |
private static String PRODUCTION_LINE = "BOP";//产线号 |
|
54 |
private static String LOCATION_CODE = "BOP010";//工位号 |
|
55 |
private static String GROUP_NAME = "BOP010_P";//工位号 |
|
56 |
private static List list = null; |
|
57 |
private static Group group = null; |
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
@Override |
|
63 |
public void monitor() { |
|
64 |
String ecpStr = "";//异常记录标记 |
|
65 |
try{ |
|
66 |
|
|
67 |
if(GlobalVariable.BOP010_F_HEART_BEAT) { |
|
68 |
|
|
69 |
//PC读工单 |
|
70 |
String isPLCStart = OPCUnit.read(opc.getBOP010_J_PLC_START());//PLC开始 |
|
71 |
if(isPLCStart.equals("true")){ |
|
72 |
|
|
73 |
String isFinish = OPCUnit.read(opc.getBOP010_J_PC_WRITE_ORDER());//PC下发工单完成 |
|
74 |
|
|
75 |
if(isFinish.equals("false")){ |
|
76 |
String isRepair = OPCUnit.read(opc.getBOP010_P_REPAIR());//是否返修 |
|
77 |
if(isRepair.equals("true")){ |
|
78 |
handleRepair(); |
|
79 |
}else{ |
|
80 |
handleOrder(); |
|
81 |
} |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
|
|
86 |
//PC完成 |
|
87 |
String isPLCFinish = OPCUnit.read(opc.getBOP010_J_PLC_FINISH());//PLC完成 |
|
88 |
if(isPLCFinish.equals("true")){ |
|
89 |
String isFinish = OPCUnit.read(opc.getBOP010_J_PC_FINISH());//PC操作完成 |
|
90 |
if(isFinish.equals("false")){ |
|
91 |
handleFinsh(); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
}else{ |
|
97 |
logger.info("BOP010工位与PLC断开,请检查PLC或网络是否异常!"); |
|
98 |
} |
|
99 |
|
|
100 |
}catch (Exception e) { |
|
101 |
ecpStr ="出现异常:" + logUtil.getTrace(e); |
|
102 |
}finally { |
|
103 |
if(!"".equals(ecpStr)){ |
|
104 |
logger.info(ecpStr+"\r\n"); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
public void handleRepair() { |
|
110 |
RepairManageInfoParam repairManageInfoParam = new RepairManageInfoParam(); |
|
111 |
repairManageInfoParam.setLocationCode(LOCATION_CODE); |
|
112 |
repairManageInfoParam.setManageType("2"); |
|
113 |
repairManageInfoParam.setUpPlc("0"); |
|
114 |
RepairManageInfoService repairManageInfoService = opc.repairManageInfoService; |
|
115 |
List<RepairManageInfoResult> list = repairManageInfoService.findListBySpec(repairManageInfoParam); |
|
116 |
if(list.size()>0) { |
|
117 |
RepairManageInfoResult result = list.get(0); |
|
118 |
|
|
119 |
//自动生成唯一码 |
|
120 |
Random random = new Random(System.currentTimeMillis()); |
|
121 |
S_SFC_CODE = "BOP" + random.nextLong(); |
|
122 |
|
|
123 |
|
|
124 |
S_ORDER_CODE = result.getWorkOrderNo(); |
|
125 |
S_PRODUCT_CODE = result.getProductCode(); |
|
126 |
S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
|
127 |
String repairLocation = result.getPoorLocationCode();// |
|
128 |
|
|
129 |
//根据工位编码查询工位表中配置的返修工位号 |
|
130 |
LocationInfoParam param = new LocationInfoParam(); |
|
131 |
param.setLocationCode(repairLocation); |
|
132 |
LocationInfoService locationInfoService = opc.locationInfoService; |
|
133 |
List<LocationInfoResult> results = locationInfoService.findListBySpec(param); |
|
134 |
if(results.size()>0) { |
|
135 |
LocationInfoResult r = results.get(0); |
|
136 |
String repairLocationNo = r.getSpareField2(); |
|
137 |
if(null != repairLocationNo && "" != repairLocationNo){ |
|
138 |
OPCUnit.write(opc.getBOP010_S_ORDER_CODE(),S_ORDER_CODE); //工单编号 |
|
139 |
OPCUnit.write(opc.getBOP010_S_PRODUCT_CODE(), S_PRODUCT_TYPE); //产品编号 |
|
140 |
OPCUnit.write(opc.getBOP010_S_SFC_CODE(), S_SFC_CODE); //总成编码 |
|
141 |
OPCUnit.write(opc.getBOP010_P_REPAIR_LOCATION(), repairLocationNo); //返修工位号 |
|
142 |
OPCUnit.write(opc.getBOP010_J_PC_WRITE_ORDER(), "true"); //PC下发工单完成 |
|
143 |
|
|
144 |
//更新为已经返修上线 |
|
145 |
Long id = result.getId(); |
|
146 |
repairManageInfoParam.setId(id); |
|
147 |
repairManageInfoParam.setUpPlc("1"); |
|
148 |
repairManageInfoService.update(repairManageInfoParam); |
|
149 |
|
|
150 |
}else{ |
|
151 |
logger.info("BOP010工位,handleRepair 请查询"+repairLocation+"工位是否配置返修工位号!"); |
|
152 |
} |
|
153 |
}else{ |
|
154 |
logger.info("BOP010工位,handleRepair 无法查询到"+repairLocation+"工位!"); |
|
155 |
} |
|
156 |
} |
|
157 |
} |
|
158 |
//PC下发工单 |
|
159 |
public void handleOrder() { |
|
160 |
|
|
161 |
IN_TIME = DateTool.getLocalTimeForDate(); |
|
162 |
ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
|
163 |
param.setProductionLine("");//产线 |
|
164 |
param.setOrderStatus("3");//工单状态 |
|
165 |
|
|
166 |
ProductionOrdeInfoService productionOrdeInfoService = opc.productionOrdeInfoService; |
|
167 |
List<ProductionOrdeInfoResult> list = productionOrdeInfoService.findListBySpec(param); |
|
168 |
|
|
169 |
if(list.size()>0) { |
|
170 |
ProductionOrdeInfoResult result = list.get(0); |
|
171 |
|
|
172 |
S_ORDER_CODE = result.getWorkOrderNo(); |
|
173 |
S_PRODUCT_CODE = result.getMaterialCode(); |
|
174 |
S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
|
175 |
|
|
176 |
//自动生成唯一码 |
|
177 |
Random random = new Random(System.currentTimeMillis()); |
|
178 |
S_SFC_CODE = "BOP" + random.nextLong(); |
|
179 |
|
|
180 |
|
|
181 |
OPCUnit.write(opc.getBOP010_S_ORDER_CODE(),S_ORDER_CODE); //工单编号 |
|
182 |
OPCUnit.write(opc.getBOP010_S_PRODUCT_CODE(), S_PRODUCT_TYPE); //产品类型 |
|
183 |
OPCUnit.write(opc.getBOP010_S_SFC_CODE(), S_SFC_CODE); //总成编码 |
|
184 |
// OPCUnit.write(opc.getBOP010_S_RIGHT_CODE(), S_RIGHT_CODE); //右壳体编码 |
|
185 |
OPCUnit.write(opc.getBOP010_S_NUMBER(), result.getPlanQty().toString()); //计划数量 |
|
186 |
|
|
187 |
OPCUnit.write(opc.getBOP010_J_PC_WRITE_ORDER(), "true"); //PC下发工单完成 |
|
188 |
logger.info("BOP010工位,handleOrder PC处理完成!2"); |
|
189 |
}else{ |
|
190 |
logger.info("BOP010工位没有可执行的工单,请联系工单管理员下发该产线的工单!"); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
|
|
195 |
//PC完成 |
|
196 |
public void handleFinsh() { |
|
197 |
|
|
198 |
if("".equals(S_ORDER_CODE)){ |
|
199 |
IN_TIME = DateTool.getLocalTimeForDate(); |
|
200 |
S_ORDER_CODE = OPCUnit.read(opc.getBOP010_S_ORDER_CODE());//工单编号 |
|
201 |
S_PRODUCT_TYPE = OPCUnit.read(opc.getBOP010_S_PRODUCT_CODE());//产品编号 |
|
202 |
S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
|
203 |
S_SFC_CODE = OPCUnit.read(opc.getBOP010_S_SFC_CODE());//总成编码 |
|
204 |
} |
|
205 |
|
|
206 |
//处理过站信息 |
|
207 |
String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getBOP010_S_PRODUCT_STATE_CODE()); |
|
208 |
PassingStationCollectionParam param = new PassingStationCollectionParam(); |
|
209 |
param.setWorkOrderNo(S_ORDER_CODE); |
|
210 |
param.setProductCode(S_PRODUCT_CODE); |
|
211 |
param.setSfcCode(S_SFC_CODE); |
|
212 |
param.setProductionLine(PRODUCTION_LINE); |
|
213 |
param.setLocationCode(LOCATION_CODE); |
|
214 |
param.setInboundTime(IN_TIME); |
|
215 |
param.setOutboundTime(DateTool.getLocalTimeForDate()); |
|
216 |
param.setOutRsSign(S_PRODUCT_STATE_CODE);//出站是否合格 |
|
217 |
PassingStationCollectionService passingStationCollectionService = opc.passingStationCollectionService; |
|
218 |
passingStationCollectionService.add(param); |
|
219 |
|
|
220 |
//写完成 |
|
221 |
OPCUnit.write(opc.getBOP010_J_PC_FINISH(), "true"); //PC完成 |
|
222 |
|
|
223 |
logger.info("BOP010工位,handleFinsh PC处理完成!"); |
|
224 |
} |
|
225 |
|
|
226 |
|
|
227 |
} |