| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @Description: andon_order |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-11 |
| | | * @Version: V1.0 |
| | | */ |
| | | /** |
| | | * @Description: andon_order |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-11 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="andon_order") |
| | | @RestController |
| | | @RequestMapping("/AndonOrder/andonOrder") |
| | | @Slf4j |
| | | public class AndonOrderController extends JeecgController<AndonOrder, IAndonOrderService> { |
| | | @Autowired |
| | | private IAndonOrderService andonOrderService; |
| | | @Autowired |
| | | private IAndonOrderService andonOrderService; |
| | | |
| | | /** |
| | | * ç¨åºå¼å« |
| | | * |
| | | * @param andonOrder |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å®ç¯å·¥å-ç¨åºå¼å«") |
| | | @ApiOperation(value = "å®ç¯å·¥å-ç¨åºå¼å«", notes = "å®ç¯å·¥å-ç¨åºå¼å«") |
| | | @PostMapping(value = "/procedureCall") |
| | | public Result<?> procedureCall(@RequestBody AndonOrder andonOrder) { |
| | | andonOrderService.procedureCall(andonOrder); |
| | | return Result.OK("å¼å«æåï¼"); |
| | | } |
| | | /** |
| | | * ç¨åºå¼å« |
| | | * |
| | | * @param andonOrder |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å®ç¯å·¥å-ç¨åºå¼å«") |
| | | @ApiOperation(value = "å®ç¯å·¥å-ç¨åºå¼å«", notes = "å®ç¯å·¥å-ç¨åºå¼å«") |
| | | @PostMapping(value = "/procedureCall") |
| | | public Result<?> procedureCall(@RequestBody AndonOrder andonOrder) { |
| | | andonOrderService.procedureCall(andonOrder); |
| | | return Result.OK("å¼å«æåï¼"); |
| | | } |
| | | } |
| | |
| | | package org.jeecg.modules.mdc.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import lombok.Data; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Description: andon_order |
| | |
| | | @TableField(exist = false) |
| | | private Set<TmpEquipmentAlarm> tmpEquipmentAlarmSet; |
| | | |
| | | public MdcEquipmentRunningSection() { |
| | | } |
| | | |
| | | public MdcEquipmentRunningSection(Integer status, String equipmentId, Date startTime, Date endTime, Long startLong, Long endLong) { |
| | | this.status = status; |
| | | this.equipmentId = equipmentId; |
| | | this.startTime = startTime; |
| | | this.endTime = endTime; |
| | | this.startLong = startLong; |
| | | this.endLong = endLong; |
| | | } |
| | | } |
| | |
| | | mdcEquipmentStatisticalInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | mdcEquipmentStatisticalInfoMonth.setTheMonth(date); |
| | | if (mdcEquipmentStatisticalDto != null) { |
| | | mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); |
| | | mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); |
| | | mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); |
| | | mdcEquipmentStatisticalInfoMonth.setFaultLong(mdcEquipmentStatisticalDto.getFaultLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setFaultRate(mdcEquipmentStatisticalDto.getFaultRate()); |
| | | mdcEquipmentStatisticalInfoMonth.setRemoveFaultRate(mdcEquipmentStatisticalDto.getRemoveFaultRate()); |
| | | mdcEquipmentStatisticalInfoMonth.setRemoveFaultRunLong(mdcEquipmentStatisticalDto.getRemoveFaultRunLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong() == null ? 0 : mdcEquipmentStatisticalDto.getCloseLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong() == null ? 0 : mdcEquipmentStatisticalDto.getErrorLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong() == null ? 0 : mdcEquipmentStatisticalDto.getOpenLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong() == null ? 0 : mdcEquipmentStatisticalDto.getProcessLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong() == null ? 0 : mdcEquipmentStatisticalDto.getWaitLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong() == null || mdcEquipmentStatisticalDto.getDayNum() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); |
| | | mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong() == null || mdcEquipmentStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); |
| | | mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong() == null || mdcEquipmentStatisticalDto.getDayNum() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); |
| | | mdcEquipmentStatisticalInfoMonth.setFaultLong(mdcEquipmentStatisticalDto.getFaultLong() == null ? 0 : mdcEquipmentStatisticalDto.getFaultLong().intValue()); |
| | | mdcEquipmentStatisticalInfoMonth.setFaultRate(mdcEquipmentStatisticalDto.getFaultRate() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getFaultRate()); |
| | | mdcEquipmentStatisticalInfoMonth.setRemoveFaultRate(mdcEquipmentStatisticalDto.getRemoveFaultRate() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getRemoveFaultRate()); |
| | | mdcEquipmentStatisticalInfoMonth.setRemoveFaultRunLong(mdcEquipmentStatisticalDto.getRemoveFaultRunLong() == null ? 0 : mdcEquipmentStatisticalDto.getRemoveFaultRunLong().intValue()); |
| | | } |
| | | mdcEquipmentStatisticalInfoMonthList.add(mdcEquipmentStatisticalInfoMonth); |
| | | // step.3 æ±æ»ç次å©ç¨çæ°æ® |
| | |
| | | mdcEquipmentShiftInfoMonth.setTheMonth(date); |
| | | mdcEquipmentShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_1); |
| | | if (mdcEquipmentShiftStatisticalDto != null) { |
| | | mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); |
| | | mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); |
| | | mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); |
| | | mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getCloseLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getTotalLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getOpenLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getErrorLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getWaitLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getProcessLong().intValue()); |
| | | mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong() == null || mdcEquipmentShiftStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); |
| | | mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong() == null || mdcEquipmentShiftStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); |
| | | mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getOpenLong() == null || mdcEquipmentShiftStatisticalDto.getTotalLong() == null ? BigDecimal.ZERO : (mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); |
| | | } else { |
| | | mdcEquipmentShiftInfoMonth.setCloseLong(0); |
| | | mdcEquipmentShiftInfoMonth.setTotalLong(0); |
| | | mdcEquipmentShiftInfoMonth.setOpenLong(0); |
| | | mdcEquipmentShiftInfoMonth.setErrorLong(0); |
| | | mdcEquipmentShiftInfoMonth.setWaitLong(0); |
| | | mdcEquipmentShiftInfoMonth.setProcessLong(0); |
| | | mdcEquipmentShiftInfoMonth.setUtilizationRate(BigDecimal.ZERO); |
| | | mdcEquipmentShiftInfoMonth.setStartRate(BigDecimal.ZERO); |
| | | mdcEquipmentShiftInfoMonth.setOpenRate(BigDecimal.ZERO); |
| | | } |
| | | mdcEquipmentStatisticalShiftInfoMonthList.add(mdcEquipmentShiftInfoMonth); |
| | | // step.4 æ±æ»åçæ¬¡å©ç¨çæ°æ® |
| | |
| | | equipmentStatisticalShiftInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | equipmentStatisticalShiftInfoMonth.setTheMonth(date); |
| | | equipmentStatisticalShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_2); |
| | | equipmentStatisticalShiftInfoMonth.setCloseLong(equipmentStatisticalDto.getCloseLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setTotalLong(equipmentStatisticalDto.getTotalLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setOpenLong(equipmentStatisticalDto.getOpenLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setErrorLong(equipmentStatisticalDto.getErrorLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setWaitLong(equipmentStatisticalDto.getWaitLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setProcessLong(equipmentStatisticalDto.getProcessLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setUtilizationRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); |
| | | equipmentStatisticalShiftInfoMonth.setStartRate(equipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); |
| | | equipmentStatisticalShiftInfoMonth.setOpenRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getOpenLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); |
| | | equipmentStatisticalShiftInfoMonth.setCloseLong(equipmentStatisticalDto.getCloseLong() == null ? 0 : equipmentStatisticalDto.getCloseLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setTotalLong(equipmentStatisticalDto.getTotalLong() == null ? 0 : equipmentStatisticalDto.getTotalLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setOpenLong(equipmentStatisticalDto.getOpenLong() == null ? 0 : equipmentStatisticalDto.getOpenLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setErrorLong(equipmentStatisticalDto.getErrorLong() == null ? 0 : equipmentStatisticalDto.getErrorLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setWaitLong(equipmentStatisticalDto.getWaitLong() == null ? 0 : equipmentStatisticalDto.getWaitLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setProcessLong(equipmentStatisticalDto.getProcessLong() == null ? 0 : equipmentStatisticalDto.getProcessLong().intValue()); |
| | | equipmentStatisticalShiftInfoMonth.setUtilizationRate(equipmentStatisticalDto.getTotalLong() == null || equipmentStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); |
| | | equipmentStatisticalShiftInfoMonth.setStartRate(equipmentStatisticalDto.getOpenLong() == null || equipmentStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (equipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); |
| | | equipmentStatisticalShiftInfoMonth.setOpenRate(equipmentStatisticalDto.getTotalLong() == null || equipmentStatisticalDto.getOpenLong() == null ? BigDecimal.ZERO : (equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getOpenLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); |
| | | mdcEquipmentStatisticalShiftInfoMonthList.add(equipmentStatisticalShiftInfoMonth); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.job; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.modules.mdc.service.IMdcOverallEquipmentEfficiencyService; |
| | | import org.jeecg.modules.mdc.util.ThrowableUtil; |
| | | import org.jeecg.modules.quartz.entity.QuartzJob; |
| | | import org.jeecg.modules.quartz.entity.SysQuartzLog; |
| | | import org.jeecg.modules.quartz.service.IQuartzJobService; |
| | | import org.jeecg.modules.quartz.service.ISysQuartzLogService; |
| | | import org.jeecg.modules.system.service.ISysAnnouncementService; |
| | | import org.quartz.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: 宿¶è®¡ç®è®¾å¤ç»¼åæçOEEä»»å¡ |
| | | * @author: LiuS |
| | | * @create: 2023-07-24 10:26 |
| | | */ |
| | | @PersistJobDataAfterExecution |
| | | @DisallowConcurrentExecution |
| | | @Slf4j |
| | | public class RunningOverallEquipmentEfficiencyJob implements Job { |
| | | |
| | | /** |
| | | * è¥åæ°åéåä¿®æ¹ QuartzJobControllerä¸ä¹é对åºä¿®æ¹ æ¶é´ï¼ yyyyMMdd ä¾ï¼ 20230414 |
| | | */ |
| | | private String parameter; |
| | | |
| | | public void setParameter(String parameter) { |
| | | this.parameter = parameter; |
| | | } |
| | | |
| | | @Resource |
| | | private IQuartzJobService quartzJobService; |
| | | |
| | | @Resource |
| | | private ISysAnnouncementService sysAnnouncementService; |
| | | |
| | | @Resource |
| | | private ISysQuartzLogService sysQuartzLogService; |
| | | |
| | | @Resource |
| | | private IMdcOverallEquipmentEfficiencyService mdcOverallEquipmentEfficiencyService; |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { |
| | | SysQuartzLog quartzLog = new SysQuartzLog(); |
| | | quartzLog.setCreateTime(new Date()); |
| | | List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); |
| | | if (byJobClassName != null && !byJobClassName.isEmpty()) { |
| | | quartzLog.setJobId(byJobClassName.get(0).getId()); |
| | | } |
| | | quartzLog.setParams(this.parameter); |
| | | log.info("宿¶è®¡ç®è®¾å¤ç»¼åæçOEEä»»å¡ RunningOverallEquipmentEfficiencyJob start! æ¶é´:" + DateUtils.now(), this.parameter); |
| | | long startTime = System.currentTimeMillis(); |
| | | try { |
| | | mdcOverallEquipmentEfficiencyService.runningOverallEquipmentEfficiency(this.parameter); |
| | | quartzLog.setIsSuccess(0); |
| | | } catch (Exception e) { |
| | | quartzLog.setIsSuccess(-1); |
| | | quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); |
| | | // åéæ¶æ¯éç¥ |
| | | sysAnnouncementService.jobSendMessage("宿¶ç»è®¡æ®µæ¶é´ä»»å¡", quartzLog.getExceptionDetail()); |
| | | } |
| | | long endTime = System.currentTimeMillis(); |
| | | quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); |
| | | sysQuartzLogService.save(quartzLog); |
| | | } |
| | | |
| | | } |
| | |
| | | * @create: 2023-04-12 16:39 |
| | | */ |
| | | public interface EquipmentAlarmMapper extends BaseMapper<EquipmentAlarm> { |
| | | |
| | | List<EquipmentAlarm> equAlarmList(@Param("equipmentIdList") List<String> equipmentIdList); |
| | | |
| | | } |
| | |
| | | public interface MdcAlarmInfoMapper extends BaseMapper<MdcAlarmInfo> { |
| | | |
| | | MdcAlarmInfo findAlarmContent(@Param("alarmNo") String alarmNo, @Param("equipmentId") String equipmentId); |
| | | |
| | | } |
| | |
| | | package org.jeecg.modules.mdc.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.jeecg.modules.mdc.vo.EquFaultRecord; |
| | | |
| | | import java.util.List; |
| | |
| | | import org.jeecg.modules.mdc.dto.MdcAlarmListDto; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentWaitSectionDto; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; |
| | | import org.jeecg.modules.mdc.vo.EquFaultRecord; |
| | | import org.jeecg.modules.mdc.vo.MdcAlarmAnalyzeQueryVo; |
| | | |
| | | import java.util.Date; |
| | |
| | | List<Integer> getDataList(@Param("equipmentId") String equipmentId, @Param("date") Date date); |
| | | |
| | | List<MdcEquipmentWaitSectionDto> findWaitList(@Param("date") String date); |
| | | |
| | | List<EquFaultRecord> findFaultList(@Param("equipmentId") String equipmentId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); |
| | | |
| | | MdcEquipmentRunningSection getFirstRecord(); |
| | | } |
| | |
| | | WHERE |
| | | t2.equipment_id = #{equipmentId} AND t1.alarm_code = #{alarmNo} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id |
| | | WHERE |
| | | t1.reason_id != '' |
| | | AND t1.the_date BETWEEN #{start} AND #{end} |
| | | AND t1.equipment_id IN |
| | | <foreach collection="equipmentIdList" item="equipmentId" index="index" open="(" close=")" separator=","> |
| | | #{ equipmentId } |
| | | </foreach> |
| | | AND t1.the_date BETWEEN #{start} AND #{end} |
| | | AND t1.equipment_id IN |
| | | <foreach collection="equipmentIdList" item="equipmentId" index="index" open="(" close=")" separator=","> |
| | | #{ equipmentId } |
| | | </foreach> |
| | | GROUP BY |
| | | t2.downtime_description |
| | | </select> |
| | |
| | | t2.downtime_description downtimeDescription |
| | | FROM mdc_downtime t1 LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id |
| | | ${ew.customSqlSegment} |
| | | ORDER BY t1.equipment_id DESC, t1.start_date ASC |
| | | ORDER BY t1.create_time DESC |
| | | </select> |
| | | </mapper> |
| | |
| | | t1.open_long / 86400 openRate, |
| | | t1.open_long openLong, |
| | | t1.wait_long waitLong, |
| | | t1.close_long closeLong |
| | | t1.close_long closeLong, |
| | | COALESCE(t3.fault_long, 0) faultLong, |
| | | COALESCE(t3.fault_rate, 0) faultRate, |
| | | COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong |
| | | FROM |
| | | mdc_equipment t2 |
| | | LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id |
| | | LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date |
| | | WHERE |
| | | t1.the_date <= #{ vo.endTime } |
| | | AND t1.the_date >= #{ vo.startTime } |
| | |
| | | equipment_id, start_time DESC |
| | | </select> |
| | | |
| | | <select id="findFaultList" resultType="org.jeecg.modules.mdc.vo.EquFaultRecord"> |
| | | SELECT |
| | | t3.equipment_code equipmentId, |
| | | t1.fault_start_time startTime, |
| | | t2.actual_end_time endTime |
| | | FROM |
| | | eam_report_repair t1 |
| | | LEFT JOIN eam_repair_order t2 ON t2.report_id = t1.id |
| | | LEFT JOIN eam_equipment t3 ON t1.equipment_id = t3.id |
| | | WHERE |
| | | ( |
| | | ( t1.fault_start_time BETWEEN #{startTime} AND #{endTime} ) |
| | | OR ( t2.actual_end_time BETWEEN #{startTime} AND #{endTime} ) |
| | | OR ( t1.fault_start_time < #{startTime} AND t2.actual_end_time IS NULL ) |
| | | ) |
| | | AND t3.equipment_code = #{equipmentId} |
| | | AND t1.report_status != 'ABOLISH' |
| | | </select> |
| | | |
| | | <select id="getFirstRecord" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection"> |
| | | SELECT TOP 1 * FROM mdc_equipment_running_section ORDER BY start_time |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | |
| | | <select id="findByEquIdsAndMonth" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> |
| | | SELECT |
| | | AVG(open_long) openLong, |
| | | AVG(close_long) closeLong, |
| | | AVG(wait_long) waitLong, |
| | | AVG(process_long) processLong, |
| | | AVG(error_long) errorLong |
| | | AVG(open_long) openLong, |
| | | AVG(close_long) closeLong, |
| | | AVG(wait_long) waitLong, |
| | | AVG(process_long) processLong, |
| | | AVG(error_long) errorLong |
| | | FROM |
| | | mdc_equipment_statistical_info |
| | | mdc_equipment_statistical_info |
| | | WHERE |
| | | equipment_id IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | | AND the_date LIKE CONCAT(#{month}, '%') |
| | | equipment_id IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | | AND the_date LIKE CONCAT(#{month}, '%') |
| | | </select> |
| | | |
| | | <select id="findByEquipmentAndDate" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> |
| | | SELECT |
| | | * |
| | | * |
| | | FROM |
| | | mdc_equipment_statistical_info |
| | | mdc_equipment_statistical_info |
| | | WHERE |
| | | equipment_id IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | |
| | | |
| | | <select id="findByEquIdAndMonth" resultType="java.math.BigDecimal"> |
| | | SELECT |
| | | AVG(oee) |
| | | AVG(oee) |
| | | FROM |
| | | mdc_oee_info |
| | | mdc_oee_info |
| | | WHERE |
| | | the_date LIKE CONCAT(#{month}, '%') |
| | | AND equipment_id IN |
| | | the_date LIKE CONCAT(#{month}, '%') |
| | | AND equipment_id IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | |
| | | a.EquipmentID equipmentId, |
| | | me.equipment_name equipmentName, |
| | | me.equipment_type equipmentType, |
| | | me.equipment_image equipmentImage, |
| | | CASE |
| | | |
| | | WHEN repair.count > 0 THEN |
| | | '5' ELSE a.Oporation |
| | | END AS equipmentStatus, |
| | | met.equipment_type_pictures equipmentImage, |
| | | a.Oporation equipmentStatus, |
| | | mew.coordinate_left coordinateLeft, |
| | | mew.coordinate_top coordinateTop, |
| | | mew.vw vw, |
| | |
| | | INNER JOIN mdc_equipment_type met ON me.equipment_type = met.equipment_type_name |
| | | AND a.CollectTime= b.maxgdtime |
| | | AND mew.workshop_id = #{ workshopId } |
| | | LEFT JOIN ( |
| | | SELECT |
| | | e1.equipment_code, |
| | | COUNT(1) COUNT |
| | | FROM |
| | | eam_report_repair r1 |
| | | INNER JOIN eam_equipment e1 ON e1.id = r1.equipment_id |
| | | WHERE |
| | | r1.report_status NOT IN ('COMPLETE', 'ABOLISH') |
| | | GROUP BY |
| | | e1.equipment_code) repair ON repair.equipment_code = me.equipment_id |
| | | </select> |
| | | |
| | | <select id="listByUser" resultType="org.jeecg.modules.mdc.entity.MdcWorkshopInfo"> |
| | |
| | | package org.jeecg.modules.mdc.service; |
| | | |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; |
| | | |
| | | /** |
| | | * @Description: æ
éç表 |
| | |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.constant.WebsocketConst; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.board.vo.EquAndon; |
| | | import org.jeecg.modules.mdc.dto.MdcEquProDto; |
| | | import org.jeecg.modules.mdc.entity.AndonOrder; |
| | |
| | | import org.jeecg.modules.message.websocket.WebSocket; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import org.jeecg.modules.mdc.service.IEquipmentAlarmService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | public MdcAlarmInfo findAlarmContent(String alarmNo, String equipmentId) { |
| | | return this.baseMapper.findAlarmContent(alarmNo, equipmentId); |
| | | } |
| | | |
| | | } |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.entity.Equipment; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; |
| | | import org.jeecg.modules.mdc.entity.MdcSystemParameters; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentFaultInfoMapper; |
| | | import org.jeecg.modules.mdc.service.IEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentFaultInfoService; |
| | |
| | | import org.jeecg.modules.mdc.vo.EquFaultRecord; |
| | | import org.jeecg.modules.mdc.vo.TimeInterval; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | } |
| | | map.put(key, equFaultRecords); |
| | | }); |
| | | } else { |
| | | map.forEach((key, value1) -> { |
| | | MdcEquipmentFaultInfo equFaultRecords = value1; |
| | | List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); |
| | | if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { |
| | | // æ¶é´ä¿®æ£ |
| | | if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { |
| | | mdcEquipmentRunningSections.get(0).setStartTime(start); |
| | | } |
| | | if (mdcEquipmentRunningSections.size() > 1) { |
| | | if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { |
| | | mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); |
| | | } |
| | | } else { |
| | | if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { |
| | | mdcEquipmentRunningSections.get(0).setEndTime(end); |
| | | } |
| | | } |
| | | List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); |
| | | |
| | | if (!collect.isEmpty()) { |
| | | long totalProcessingTime = 0; |
| | | for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { |
| | | totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); |
| | | } |
| | | equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); |
| | | // 计ç®å»é¤æ
éæ¶é¿çå©ç¨ç |
| | | BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); |
| | | equFaultRecords.setRemoveFaultRate(removeFaultRate); |
| | | } |
| | | } |
| | | map.put(key, equFaultRecords); |
| | | }); |
| | | } |
| | | if (!map.isEmpty()) { |
| | | this.saveBatch(new ArrayList<>(map.values())); |
| | |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.util.TimeFieldUtils; |
| | | import org.jeecg.modules.mdc.vo.EquFaultRecord; |
| | | import org.jeecg.modules.mdc.vo.MdcAlarmAnalyzeQueryVo; |
| | | import org.jeecg.modules.mdc.vo.MdcEquipmentRunningSectionVo; |
| | | import org.jeecg.modules.mdc.vo.TimeInterval; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 设å¤è¿è¡æ¶æ®µç¶æè¡¨ |
| | |
| | | List<MdcEquipmentRunningSection> running = loadEquipmentRunningTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr()); |
| | | //æ¥è¯¢æ¥è¦æ°æ® |
| | | List<MdcEquipmentRunningSection> errs = loadEquipmentErrorTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr()); |
| | | //æ¥è¯¢æ
éæ°æ® |
| | | List<MdcEquipmentRunningSection> faults = loadEquipmentFaultTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr()); |
| | | Equipment equip = equipmentService.getOne(new LambdaQueryWrapper<Equipment>().eq(Equipment::getEquipmentid, equipmentRunningSectionVo.getEquipmentId())); |
| | | if (!running.isEmpty()) { |
| | | MdcEquipmentRunningSectionDto dto; |
| | |
| | | } |
| | | } |
| | | } |
| | | // Set<TmpEquipmentAlarm> set = entity.getTmpEquipmentAlarmSet(); |
| | | // if (entity.getStatus() == 22 && set != null && !set.isEmpty()) { |
| | | // Iterator<TmpEquipmentAlarm> iterator = entity.getTmpEquipmentAlarmSet().iterator(); |
| | | // //è·åæ¥è¦ç¼å·ç¸åçæ¥è¦ä¿¡æ¯ |
| | | // while (iterator.hasNext()) { |
| | | // TmpEquipmentAlarm next = iterator.next(); |
| | | // if (StringUtils.isNotBlank(next.getAlarmNo()) && next.getAlarmNo().equals(entity.getStatus())) { |
| | | // dto.setAlarmContent(next.getAlarmContent()); |
| | | // } |
| | | // } |
| | | // } |
| | | dtos.add(dto); |
| | | } |
| | | } |
| | | |
| | | List<MdcEquipmentRunningSectionDto> result = new ArrayList<>(); |
| | | |
| | | //åå¹¶ç¸åç¶ææ°æ® |
| | | for (int i = 0; i < dtos.size() - 1; i++) { |
| | | MdcEquipmentRunningSectionDto mdcEquipmentRunningSectionDto = dtos.get(i); |
| | |
| | | result.addAll(dtos); |
| | | } |
| | | |
| | | if (faults != null && !faults.isEmpty()) { |
| | | MdcEquipmentRunningSectionDto dto; |
| | | for (MdcEquipmentRunningSection entity : faults) { |
| | | dto = new MdcEquipmentRunningSectionDto(); |
| | | BeanUtils.copyProperties(entity, dto); |
| | | result.add(dto); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private List<MdcEquipmentRunningSection> loadEquipmentFaultTrace(String equipmentId, String collectTimeStr) { |
| | | List<MdcEquipmentRunningSection> result = new ArrayList<>(); |
| | | Date startTime = DateUtils.getShortDate(collectTimeStr); |
| | | Date now = DateUtils.removeTime(DateUtils.getNow()); |
| | | long second = DateUtils.differentSecond(startTime, now); |
| | | Date endTime = DateUtils.plusTime(startTime, 1); |
| | | if (collectTimeStr.equals(LocalDate.now().toString())) { |
| | | endTime = DateUtils.getNow(); |
| | | } |
| | | if (second < 0) { |
| | | return Collections.emptyList(); |
| | | } else { |
| | | List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultList(equipmentId, startTime, endTime); |
| | | if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) { |
| | | |
| | | // ä¿®æ£è®°å½æ¶é´ |
| | | List<EquFaultRecord> correctedRecords = correctRecordTimes(equFaultRecordList, DateUtils.convertToLocalDateTime(startTime), DateUtils.convertToLocalDateTime(endTime)); |
| | | |
| | | // æå¼å§æ¶é´æåº |
| | | correctedRecords.sort(Comparator.comparing(EquFaultRecord::getStartTime)); |
| | | |
| | | // åå¹¶éå æ¶é´æ®µ |
| | | List<TimeInterval> mergedIntervals = mergeIntervals(correctedRecords); |
| | | |
| | | for (TimeInterval mergedInterval : mergedIntervals) { |
| | | MdcEquipmentRunningSection mdcEquipmentRunningSection = new MdcEquipmentRunningSection(25, equipmentId, DateUtils.convertToDate(mergedInterval.getStart()), DateUtils.convertToDate(mergedInterval.getEnd()), DateUtils.convertToDate(mergedInterval.getStart()).getTime(), DateUtils.convertToDate(mergedInterval.getEnd()).getTime()); |
| | | mdcEquipmentRunningSection.setDuration(DateUtils.differentSecond(mdcEquipmentRunningSection.getStartTime(), mdcEquipmentRunningSection.getEndTime())); |
| | | result.add(mdcEquipmentRunningSection); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private static List<EquFaultRecord> correctRecordTimes(List<EquFaultRecord> records, LocalDateTime startTime, LocalDateTime endTime) { |
| | | return records.stream() |
| | | .map(record -> { |
| | | LocalDateTime recordStart = DateUtils.convertToLocalDateTime(record.getStartTime()); |
| | | LocalDateTime recordEnd = record.getEndTime() != null ? |
| | | DateUtils.convertToLocalDateTime(record.getEndTime()) : null; |
| | | |
| | | // ä¿®æ£å¼å§æ¶é´ |
| | | LocalDateTime correctedStart = recordStart.isBefore(startTime) ? |
| | | startTime : recordStart; |
| | | |
| | | // ä¿®æ£ç»ææ¶é´ |
| | | LocalDateTime correctedEnd = recordEnd == null || recordEnd.isAfter(endTime) ? |
| | | endTime : recordEnd; |
| | | |
| | | // å建修æ£åçè®°å½ |
| | | return new EquFaultRecord( |
| | | record.getEquipmentId(), |
| | | DateUtils.convertToDate(correctedStart), |
| | | DateUtils.convertToDate(correctedEnd) |
| | | ); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private static List<TimeInterval> mergeIntervals(List<EquFaultRecord> records) { |
| | | List<TimeInterval> intervals = records.stream() |
| | | .map(record -> new TimeInterval( |
| | | DateUtils.convertToLocalDateTime(record.getStartTime()), |
| | | DateUtils.convertToLocalDateTime(record.getEndTime()))) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if (intervals.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | List<TimeInterval> merged = new ArrayList<>(); |
| | | TimeInterval current = intervals.get(0); |
| | | |
| | | for (int i = 1; i < intervals.size(); i++) { |
| | | TimeInterval next = intervals.get(i); |
| | | if (next.getStart().isBefore(current.getEnd()) || next.getStart().equals(current.getEnd())) { |
| | | // æéå ï¼åå¹¶åºé´ |
| | | current.setEnd(current.getEnd().isAfter(next.getEnd()) ? current.getEnd() : next.getEnd()); |
| | | } else { |
| | | // æ éå ï¼æ·»å å½ååºé´å¹¶æ´æ°å½ååºé´ |
| | | merged.add(current); |
| | | current = next; |
| | | } |
| | | } |
| | | merged.add(current); // æ·»å æåä¸ä¸ªåºé´ |
| | | |
| | | return merged; |
| | | } |
| | | |
| | | /** |
| | |
| | | //è·årunningè¿è¡çæ¥å¿è®°å½ |
| | | List<MdcEquipmentRunningSection> list = this.equipmentRunningTracesLog(equipment.getEquipmentid()); |
| | | if (list != null && !list.isEmpty()) { |
| | | // List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //æ·»å ç¨åºå· |
| | | this.ergodicTrim(list); |
| | | super.saveBatch(list); |
| | | List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //æ·»å ç¨åºå· |
| | | this.ergodicTrim(equipList); |
| | | super.saveBatch(equipList); |
| | | } |
| | | //è·åæ¥è¦çæ¥å¿è®°å½ |
| | | List<MdcEquipmentRunningSection> errorList = this.equipmentRunningTracesErrorLog(equipment.getEquipmentid()); |
| | |
| | | Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>(); |
| | | List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>(); |
| | | List<MdcEquipmentRunningSectionDto> waring = new ArrayList<>(); |
| | | List<MdcEquipmentRunningSectionDto> fault = new ArrayList<>(); |
| | | //è¿è¡ |
| | | List<MdcEquipmentRunningSection> running = loadEquipmentRunningTrace(equipmentRunningSectionVo.getEquipmentId(), date); |
| | | //æ¥è¦ |
| | | List<MdcEquipmentRunningSection> errs = loadEquipmentErrorTrace(equipmentRunningSectionVo.getEquipmentId(), date); |
| | | //æ
é |
| | | List<MdcEquipmentRunningSection> faults = loadEquipmentFaultTrace(equipmentRunningSectionVo.getEquipmentId(), date); |
| | | |
| | | if (running != null && !running.isEmpty()) { |
| | | MdcEquipmentRunningSectionDto dto; |
| | |
| | | map.put("waring", null); |
| | | } |
| | | |
| | | if (!faults.isEmpty()) { |
| | | MdcEquipmentRunningSectionDto dto; |
| | | for (MdcEquipmentRunningSection mdcEquipmentRunningSection : faults) { |
| | | dto = new MdcEquipmentRunningSectionDto(); |
| | | BeanUtils.copyProperties(mdcEquipmentRunningSection, dto); |
| | | fault.add(dto); |
| | | } |
| | | } else { |
| | | map.put("fault", null); |
| | | } |
| | | |
| | | map.put("normal", normal); |
| | | map.put("waring", waring); |
| | | map.put("fault", fault); |
| | | |
| | | return map; |
| | | } |
| | |
| | | entity.setModuleType("MDC"); |
| | | entity.setWebapiInfo(data.toString()); |
| | | //åç»è¿è¡å
¶ä»ä¸å¡å
³è |
| | | JsonMapper mapper = new JsonMapper(); |
| | | // JsonMapper mapper = new JsonMapper(); |
| | | service.save(entity); |
| | | try { |
| | | service.saveTableAutomationOne(data); |
| | | } catch (Exception e) { |
| | | log.error("JSON parsing error: {}", e.getMessage()); |
| | | return Result.error("æ°æ®å¼å¸¸", e.getMessage()); |
| | | } |
| | | service.save(entity); |
| | | return Result.OK("æ¥æ¶æå"); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.util.JdbcUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.common.util.RedisUtil; |
| | | import org.jeecg.modules.msi.webapi.entity.MsiWebapiJsonEntity; |
| | | import org.jeecg.modules.msi.webapi.mapper.MsiWebapiJsonMapper; |
| | | import org.jeecg.modules.msi.webapi.service.IMsiWebapiJsonService; |
| | |
| | | import org.springframework.jdbc.datasource.DataSourceUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.jetbrains.annotations.NotNull; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.sql.Statement; |
| | |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class MsiWebapiJsonServiceImpl extends ServiceImpl<MsiWebapiJsonMapper, MsiWebapiJsonEntity> implements IMsiWebapiJsonService { |
| | | |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | private final static String ZDHKEY = "ZDHKEY_"; |
| | | |
| | | /** |
| | | * è§£æåæ¡æ°æ®ä¿åå°å表 |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveTableAutomationOne(List<MachineEquipentInfo> data) { |
| | | if (data ==null || data.isEmpty()) { |
| | | if (data == null || data.isEmpty()) { |
| | | return false; |
| | | } |
| | | List<String> listStatus = new ArrayList<>(); |
| | | List<String> listParameter = new ArrayList<>(); |
| | | |
| | | // ç¨äºè®°å½å䏿¡è®°å½çç¶æå¼ |
| | | String prevRunningStatus = null; |
| | | |
| | | for (MachineEquipentInfo machineInfo : data) { |
| | | System.out.println(machineInfo); |
| | | // log.info("æ¥æ¶èªå¨åæ°æ®ï¼" + machineInfo); |
| | | |
| | | // è·åå½åè®°å½çrunningStatuså¼ |
| | | String currentRunningStatus = null; |
| | |
| | | } |
| | | } |
| | | |
| | | // 妿å½åç¶æä¸å䏿¡ç¸åï¼åè·³è¿ |
| | | if (currentRunningStatus != null && currentRunningStatus.equals(prevRunningStatus)) { |
| | | continue; |
| | | } |
| | | // è·åå䏿¡ç¶æ |
| | | if (redisUtil.hasKey(ZDHKEY + machineInfo.getMachineNo())) { |
| | | String prevRunningStatus = (String) redisUtil.get(ZDHKEY + machineInfo.getMachineNo()); |
| | | |
| | | // æ´æ°å䏿¡è®°å½çç¶æå¼ |
| | | prevRunningStatus = currentRunningStatus; |
| | | // 妿å½åç¶æä¸å䏿¡ç¸åï¼ååªåå
¥åè¡¨æ°æ® |
| | | if (currentRunningStatus != null && currentRunningStatus.equals(prevRunningStatus)) { |
| | | String parameter = listSqlParameter(machineInfo); |
| | | if (parameter != null && !parameter.equals("")) { |
| | | listParameter.add(parameter); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | // æ´æ°å䏿¡è®°å½çç¶æå¼ |
| | | redisUtil.set(ZDHKEY + machineInfo.getMachineNo(), currentRunningStatus); |
| | | } else { |
| | | if (currentRunningStatus != null) { |
| | | redisUtil.set(ZDHKEY + machineInfo.getMachineNo(), currentRunningStatus); |
| | | } |
| | | } |
| | | |
| | | // çæSQL |
| | | String stutus = listSqls(machineInfo); |
| | | if (stutus != null && !stutus.equals("")) { |
| | | listStatus.add(stutus); |
| | | } |
| | | |
| | | String parameter = listSqlParameter(machineInfo); |
| | | if (parameter != null && !parameter.equals("")) { |
| | | listParameter.add(parameter); |
| | | } |
| | | |
| | | } |
| | | // æ§è¡ç¶ææ°æ®SQL |
| | | try { |
| | |
| | | |
| | | /** |
| | | * æ¹éæ§è¡SQLè¯å¥ |
| | | * |
| | | * @param sqlList SQLè¯å¥å表 |
| | | * @throws SQLException |
| | | */ |
| | |
| | | |
| | | |
| | | /** |
| | | * æå
¥å°EquipmentLog |
| | | * æå
¥å°è®¾å¤å表 |
| | | * |
| | | * @param machineInfo |
| | | * @return |
| | | */ |
| | | public String listSqlParameter(MachineEquipentInfo machineInfo) { |
| | | String listSqls = null; |
| | | List<DetailedListVo> itemList = machineInfo.getItemList(); |
| | | Map<String ,DetailedListVo> itemMap = new HashMap<String ,DetailedListVo>(); |
| | | for (DetailedListVo item: itemList) { |
| | | itemMap.put(item.getItemName(),item); |
| | | Map<String, DetailedListVo> itemMap = new HashMap<String, DetailedListVo>(); |
| | | for (DetailedListVo item : itemList) { |
| | | itemMap.put(item.getItemName(), item); |
| | | } |
| | | String sql = "insert into "; |
| | | sql = sql + "ZDH_" + machineInfo.getMachineNo() + " "; |
| | | sql = sql + "(EquipmentID,EquipmentName,CollectTime,runningStatus,spindleSpeed,feedRatio,runDuration,spindleDuration,progName,progStatus,toolNo) values ( "; |
| | | //EquipmentID |
| | | if (machineInfo.getMachineNo() == null || machineInfo.getMachineNo().equals("")) { |
| | | if (machineInfo.getMachineNo() == null || machineInfo.getMachineNo().equals("")) { |
| | | return null; |
| | | } else { |
| | | sql = sql + "'" + machineInfo.getMachineNo() + "', "; |
| | |
| | | //CollectTime |
| | | // å设 endTime æ¯ "MM/dd/yyyy HH:mm:ss" æ ¼å¼çå符串 |
| | | if (machineInfo.getEndTime() != null && !machineInfo.getEndTime().isEmpty()) { |
| | | try { |
| | | // 1. å°å符串解æä¸º Date 对象 |
| | | SimpleDateFormat inputFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); |
| | | Date endDate = inputFormat.parse(machineInfo.getEndTime()); |
| | | |
| | | // 2. å° Date æ ¼å¼åä¸ºç®æ SQL æ ¼å¼ï¼å¦ "yyyy-MM-dd HH:mm:ss"ï¼ |
| | | SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | sql = sql + "'" + outputFormat.format(endDate) + "', "; |
| | | } catch (ParseException e) { |
| | | // å¤çè§£æå¤±è´¥çæ
åµï¼å¦æ¥å¿è®°å½ææåºå¼å¸¸ï¼ |
| | | throw new RuntimeException("Invalid end time format: " + machineInfo.getEndTime(), e); |
| | | } |
| | | sql = getTime(machineInfo, sql); |
| | | } else { |
| | | // 妿 endTime 为 null æç©ºï¼ä½¿ç¨å½åæ¶é´ |
| | | sql = sql + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "', "; |
| | |
| | | //feedRatio |
| | | if (itemMap.containsKey("feedRatio")) { |
| | | sql = sql + "'" + itemMap.get("feedRatio").getItemValue() + "', "; |
| | | }else { |
| | | } else { |
| | | sql = sql + "NULL, "; |
| | | } |
| | | //runDuration |
| | |
| | | } |
| | | |
| | | sql = sql + "); \n"; |
| | | if (StringUtils.isBlank(listSqls) ) { |
| | | if (StringUtils.isBlank(listSqls)) { |
| | | listSqls = sql; |
| | | } else { |
| | | listSqls += sql; |
| | |
| | | |
| | | |
| | | /** |
| | | * æå
¥å°EquipmentLog |
| | | * æå
¥å°EquipmentLog |
| | | * |
| | | * @param machineInfo |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | sql = sql + null + ", "; |
| | | if (machineInfo.getEndTime() != null) { |
| | | |
| | | sql = sql + "'" + DateUtils.formattedDate(machineInfo.getEndTime(),DateUtils.STR_DD_MM_YYYY,DateUtils.STR_DATE_TIME_SMALL) + "', "; |
| | | sql = getTime(machineInfo, sql); |
| | | } else { |
| | | return null; |
| | | } |
| | | Map<String ,DetailedListVo> itemMap = new HashMap<String ,DetailedListVo>(); |
| | | for (DetailedListVo item: itemList) { |
| | | itemMap.put(item.getItemName(),item); |
| | | Map<String, DetailedListVo> itemMap = new HashMap<String, DetailedListVo>(); |
| | | for (DetailedListVo item : itemList) { |
| | | itemMap.put(item.getItemName(), item); |
| | | } |
| | | if (itemMap.containsKey("runningStatus")) { |
| | | int oporation = 0; |
| | | switch (itemMap.get("runningStatus").getItemValue()) { |
| | | case "0" : oporation =0;break; |
| | | case "1" : oporation =2;break; |
| | | case "2" : oporation =3;break; |
| | | case "3" : oporation =2;break; |
| | | case "4" : oporation =2;break; |
| | | case "10" : oporation =2;break; |
| | | case "13" : oporation =2;break; |
| | | case "14" : oporation =2;break; |
| | | case "10001" : oporation =2;break; |
| | | default: break; |
| | | case "0": |
| | | oporation = 0; |
| | | break; |
| | | case "1": |
| | | oporation = 2; |
| | | break; |
| | | case "2": |
| | | oporation = 3; |
| | | break; |
| | | case "3": |
| | | oporation = 2; |
| | | break; |
| | | case "4": |
| | | oporation = 2; |
| | | break; |
| | | case "10": |
| | | oporation = 2; |
| | | break; |
| | | case "13": |
| | | oporation = 2; |
| | | break; |
| | | case "14": |
| | | oporation = 2; |
| | | break; |
| | | case "10001": |
| | | oporation = 2; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | sql = sql + " " + oporation + ", "; |
| | | sql = sql + " " + oporation + ", "; |
| | | } else { |
| | | return null; |
| | | } |
| | | sql = sql + null + " ); \n"; |
| | | if (StringUtils.isBlank(listSqls) ) { |
| | | sql = sql + null + " ); \n"; |
| | | if (StringUtils.isBlank(listSqls)) { |
| | | listSqls = sql; |
| | | } |
| | | return listSqls; |
| | | } |
| | | |
| | | @NotNull |
| | | private String getTime(MachineEquipentInfo machineInfo, String sql) { |
| | | try { |
| | | // 1. å°å符串解æä¸º Date 对象 |
| | | SimpleDateFormat inputFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); |
| | | Date endDate = inputFormat.parse(machineInfo.getEndTime()); |
| | | |
| | | // 2. å° Date æ ¼å¼åä¸ºç®æ SQL æ ¼å¼ï¼å¦ "yyyy-MM-dd HH:mm:ss"ï¼ |
| | | SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | sql = sql + "'" + outputFormat.format(endDate) + "', "; |
| | | } catch (ParseException e) { |
| | | // å¤çè§£æå¤±è´¥çæ
åµï¼å¦æ¥å¿è®°å½ææåºå¼å¸¸ï¼ |
| | | throw new RuntimeException("Invalid end time format: " + machineInfo.getEndTime(), e); |
| | | } |
| | | return sql; |
| | | } |
| | | } |