guns-vip-main/src/main/java/cn/stylefeng/guns/modular/kb/greaseBoard/GreaseBoardController.java
@@ -3,11 +3,13 @@ import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; import cn.stylefeng.guns.modular.gm.greaseManage.entity.GreaseManage; 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.modular.kb.utils.IPUtil; import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; import cn.stylefeng.guns.modular.sc.kanbanConf.model.params.KanbanConfParam; import cn.stylefeng.guns.modular.sc.kanbanConf.service.KanbanConfService; import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.kernel.model.response.ResponseData; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -154,6 +156,26 @@ return ResponseData.success(list); } @ResponseBody @CrossOrigin @RequestMapping("/testhandleOilState") public long handleOilState(){ SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); String currentDate = format.format(new Date()); GreaseManageParam param = new GreaseManageParam(); param.setLocationCode("OP050"); List<GreaseManageResult> list = greaseManageService.findListBySpec(param); if(list.size()>0) { String duaDate = list.get(0).getDuaDate(); // long daysBetween = Long.parseLong(getRemainder(currentDate,duaDate)); // long daysBetween = ChronoUnit.DAYS.between(date1, date2); // return daysBetween; } return 0; } public static String boldText(String param){ return "<span style='font-size: 20px' class='colorRed'>"+param+"</span>"; } @@ -173,7 +195,7 @@ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); LocalDate localDate1 = LocalDate.parse(currentDate, dateFormatter); LocalDate localDate2 = LocalDate.parse(tableDate, dateFormatter); long days = ChronoUnit.DAYS.between(localDate2, localDate1); long days = ChronoUnit.DAYS.between(localDate1, localDate2); return String.valueOf(days); } guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.java
@@ -8,6 +8,9 @@ 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; @@ -19,6 +22,10 @@ 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; @@ -68,7 +75,7 @@ handleFinsh(); } } handleOilState(); }else{ logger.info("BOP030工位与PLC断开,请检查PLC或网络是否异常!"); } @@ -82,6 +89,34 @@ } } 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(); guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/DOP020/impl/DOP020ServerInterfaceImpl.java
@@ -22,7 +22,9 @@ 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; @@ -86,7 +88,6 @@ } } } public void handleOilState(){ GreaseManageParam param = new GreaseManageParam(); GreaseManageService greaseManageService = opc.greaseManageService; @@ -94,20 +95,27 @@ List<GreaseManageResult> list = greaseManageService.findListBySpec(param); if(list.size()>0) { String duaDate = list.get(0).getDuaDate(); LocalDate date1 = LocalDate.parse(duaDate); // 第一个日期 LocalDate date2 = LocalDate.now(); // 当前日期(或者指定其他日期) long daysBetween = ChronoUnit.DAYS.between(date1, date2); SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); String currentDate = format.format(new Date()); long daysBetween = getRemainder(currentDate,duaDate); if(daysBetween>0){ OPCUnit.write(opc.getOP050_OIL_STATE(), "false"); //写油脂状态 OPCUnit.write(opc.getDOP020_OIL_STATE(), "false"); //写油脂状态 }else{ OPCUnit.write(opc.getOP050_OIL_STATE(), "true"); //写油脂状态 OPCUnit.write(opc.getDOP020_OIL_STATE(), "true"); //写油脂状态 } logger.info("到期日期:"+date1+"当前日期:"+date1+"剩余天数::"+daysBetween); 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(); guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP030/impl/EOP030ServerInterfaceImpl.java
@@ -74,7 +74,6 @@ } } handleOilState(); }else{ logger.info("EOP030工位与PLC断开,请检查PLC或网络是否异常!"); } @@ -88,26 +87,6 @@ } } 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(); LocalDate date1 = LocalDate.parse(duaDate); // 第一个日期 LocalDate date2 = LocalDate.now(); // 当前日期(或者指定其他日期) long daysBetween = ChronoUnit.DAYS.between(date1, date2); if(daysBetween>0){ OPCUnit.write(opc.getOP050_OIL_STATE(), "false"); //写油脂状态 }else{ OPCUnit.write(opc.getOP050_OIL_STATE(), "true"); //写油脂状态 } logger.info("到期日期:"+date1+"当前日期:"+date1+"剩余天数::"+daysBetween); } } //PC读工单 public void handleOrder() { guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP050/impl/OP050ServerInterfaceImpl.java
@@ -22,7 +22,9 @@ 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; @@ -97,20 +99,26 @@ List<GreaseManageResult> list = greaseManageService.findListBySpec(param); if(list.size()>0) { String duaDate = list.get(0).getDuaDate(); LocalDate date1 = LocalDate.parse(duaDate); // 第一个日期 LocalDate date2 = LocalDate.now(); // 当前日期(或者指定其他日期) long daysBetween = ChronoUnit.DAYS.between(date1, date2); SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); String currentDate = format.format(new Date()); long daysBetween = getRemainder(currentDate,duaDate); if(daysBetween>0){ OPCUnit.write(opc.getOP050_OIL_STATE(), "false"); //写油脂状态 }else{ OPCUnit.write(opc.getOP050_OIL_STATE(), "true"); //写油脂状态 } logger.info("到期日期:"+date1+"当前日期:"+date1+"剩余天数::"+daysBetween); 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();