| | |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.model.params.GreaseManageParam; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.model.result.GreaseManageResult; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | import org.openscada.opc.lib.da.Group; |
| | | import org.openscada.opc.lib.da.Item; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | handleFinsh(); |
| | | } |
| | | } |
| | | |
| | | handleOilState(); |
| | | }else{ |
| | | logger.info("BOP030工位与PLC断开,请检查PLC或网络是否异常!"); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void handleOilState(){ |
| | | GreaseManageParam param = new GreaseManageParam(); |
| | | GreaseManageService greaseManageService = opc.greaseManageService; |
| | | param.setLocationCode(LOCATION_CODE); |
| | | List<GreaseManageResult> list = greaseManageService.findListBySpec(param); |
| | | if(list.size()>0) { |
| | | String duaDate = list.get(0).getDuaDate(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String currentDate = format.format(new Date()); |
| | | long daysBetween = getRemainder(currentDate,duaDate); |
| | | if(daysBetween>0){ |
| | | OPCUnit.write(opc.getBOP030_OIL_STATE(), "false"); //写油脂状态 |
| | | }else{ |
| | | OPCUnit.write(opc.getBOP030_OIL_STATE(), "true"); //写油脂状态 |
| | | } |
| | | logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween); |
| | | } |
| | | } |
| | | |
| | | public static long getRemainder(String currentDate,String tableDate){ |
| | | DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | LocalDate localDate1 = LocalDate.parse(currentDate, dateFormatter); |
| | | LocalDate localDate2 = LocalDate.parse(tableDate, dateFormatter); |
| | | long days = ChronoUnit.DAYS.between(localDate1, localDate2); |
| | | return days; |
| | | } |
| | | |
| | | //PC读工单 |
| | | public void handleOrder() { |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |