lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/AndonOrderController.java
@@ -1,18 +1,24 @@ package org.jeecg.modules.mdc.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.modules.mdc.entity.AndonOrder; import org.jeecg.modules.mdc.service.IAndonOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; /** * @Description: andon_order @@ -22,11 +28,61 @@ */ @Api(tags="andon_order") @RestController @RequestMapping("/AndonOrder/andonOrder") @RequestMapping("/mdc/andonOrder") @Slf4j public class AndonOrderController extends JeecgController<AndonOrder, IAndonOrderService> { @Autowired private IAndonOrderService andonOrderService; /** * å页å表æ¥è¯¢ * * @param andonOrder * @param pageNo * @param pageSize * @param req * @return */ @AutoLog(value = "å®ç¯-å页å表æ¥è¯¢") @ApiOperation(value="å®ç¯-å页å表æ¥è¯¢", notes="å®ç¯-å页å表æ¥è¯¢") @GetMapping(value = "/list") public Result<?> queryPageList(AndonOrder andonOrder, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { QueryWrapper<AndonOrder> queryWrapper = QueryGenerator.initQueryWrapper(andonOrder, req.getParameterMap()); Page<AndonOrder> page = new Page<AndonOrder>(pageNo, pageSize); IPage<AndonOrder> pageList = andonOrderService.page(page, queryWrapper); return Result.OK(pageList); } /** * æ·»å * * @param andonOrder * @return */ @AutoLog(value = "å®ç¯-æ·»å ") @ApiOperation(value="å®ç¯-æ·»å ", notes="å®ç¯-æ·»å ") @PostMapping(value = "/add") public Result<?> add(@RequestBody AndonOrder andonOrder) { andonOrderService.save(andonOrder); return Result.OK("æ·»å æåï¼"); } /** * éè¿idæ¥è¯¢ * * @param id * @return */ @AutoLog(value = "å®ç¯-éè¿idæ¥è¯¢") @ApiOperation(value="å®ç¯-éè¿idæ¥è¯¢", notes="å®ç¯-éè¿idæ¥è¯¢") @GetMapping(value = "/queryById") public Result<?> queryById(@RequestParam(name="id",required=true) String id) { AndonOrder andonOrder = andonOrderService.getById(id); return Result.OK(andonOrder); } /** * ç¨åºå¼å« @@ -41,4 +97,6 @@ andonOrderService.procedureCall(andonOrder); return Result.OK("å¼å«æåï¼"); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/AndonOrder.java
@@ -1,25 +1,23 @@ 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 @@ -65,6 +63,7 @@ */ @Excel(name = "å®ç¯äºº", width = 15) @ApiModelProperty(value = "å®ç¯äºº") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") private String operator; /** * å¼å«åå @@ -85,6 +84,7 @@ */ @Excel(name = "ååºäºº", width = 15) @ApiModelProperty(value = "ååºäºº") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") private String responder; /** * ååºæ¶é´ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentRunningSection.java
@@ -100,15 +100,4 @@ @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; } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java
@@ -101,18 +101,18 @@ 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 æ±æ»ç次å©ç¨çæ°æ® @@ -122,15 +122,25 @@ 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 æ±æ»åçæ¬¡å©ç¨çæ°æ® @@ -141,15 +151,15 @@ 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); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ImportXmlToDataJob.java
ÎļþÒÑɾ³ý lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOverallEquipmentEfficiencyJob.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,74 @@ 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); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentAlarmMapper.java
@@ -11,5 +11,7 @@ * @create: 2023-04-12 16:39 */ public interface EquipmentAlarmMapper extends BaseMapper<EquipmentAlarm> { List<EquipmentAlarm> equAlarmList(@Param("equipmentIdList") List<String> equipmentIdList); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcAlarmInfoMapper.java
@@ -13,4 +13,5 @@ public interface MdcAlarmInfoMapper extends BaseMapper<MdcAlarmInfo> { MdcAlarmInfo findAlarmContent(@Param("alarmNo") String alarmNo, @Param("equipmentId") String equipmentId); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java
@@ -1,8 +1,8 @@ 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; lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java
@@ -5,7 +5,6 @@ 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; @@ -79,8 +78,6 @@ 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(); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcAlarmInfoMapper.xml
@@ -11,4 +11,5 @@ WHERE t2.equipment_id = #{equipmentId} AND t1.alarm_code = #{alarmNo} </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeOperatorMapper.xml
@@ -9,6 +9,6 @@ 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> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml
@@ -69,10 +69,14 @@ 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 } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
@@ -188,28 +188,7 @@ 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> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOeeInfoMapper.xml
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcWorkshopInfoMapper.xml
@@ -9,12 +9,8 @@ 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, @@ -28,17 +24,6 @@ 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"> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java
@@ -1,7 +1,7 @@ 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: æ éç表 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java
@@ -2,18 +2,14 @@ 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; @@ -25,7 +21,6 @@ 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; @@ -88,6 +83,7 @@ andonOrderWebSocketVo.setPersonResponsible(user.getRealname()); andonOrderWebSocketVo.setRepairTime(StringPool.EMPTY); andonOrderWebSocketVo.setFaultInfo(StringPool.EMPTY); andonOrderWebSocketVo.setType("open"); andonOrderWebSocketVo.setPlantName(equipmentIdToProductionIdMap != null && equipmentIdToProductionIdMap.containsKey(order.getEquipmentId()) ? equipmentIdToProductionIdMap.get(order.getEquipmentId()).getProductionName() : null); andonOrderWebSocketVoList.add(andonOrderWebSocketVo); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentAlarmServiceImpl.java
@@ -7,7 +7,6 @@ import org.jeecg.modules.mdc.service.IEquipmentAlarmService; import org.springframework.stereotype.Service; import java.util.Collections; import java.util.Date; import java.util.List; lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcAlarmInfoServiceImpl.java
@@ -19,4 +19,5 @@ public MdcAlarmInfo findAlarmContent(String alarmNo, String equipmentId) { return this.baseMapper.findAlarmContent(alarmNo, equipmentId); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java
@@ -1,8 +1,12 @@ 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; @@ -12,17 +16,12 @@ 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; @@ -177,6 +176,39 @@ } 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())); lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
@@ -13,20 +13,15 @@ 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: 设å¤è¿è¡æ¶æ®µç¶æè¡¨ @@ -69,8 +64,6 @@ 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; @@ -107,12 +100,22 @@ } } } // 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); @@ -138,105 +141,7 @@ 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; } /** @@ -615,9 +520,9 @@ //è·å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()); @@ -850,13 +755,10 @@ 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; @@ -880,20 +782,8 @@ 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; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java
ÎļþÒÑɾ³ý lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/AndonOrderWebSocketVo.java
@@ -49,4 +49,9 @@ * æå±åæ¿ */ private String plantName; /** * ç±»åï¼openãcloseï¼ */ private String type; } lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java
@@ -42,14 +42,14 @@ 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("æ¥æ¶æå"); } lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java
@@ -3,8 +3,10 @@ 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; @@ -15,7 +17,9 @@ 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; @@ -24,13 +28,20 @@ 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 */ @@ -42,11 +53,8 @@ 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; @@ -57,23 +65,38 @@ } } // 妿å½åç¶æä¸å䏿¡ç¸åï¼åè·³è¿ // è·åå䏿¡ç¶æ if (redisUtil.hasKey(ZDHKEY + machineInfo.getMachineNo())) { String prevRunningStatus = (String) redisUtil.get(ZDHKEY + machineInfo.getMachineNo()); // 妿å½åç¶æä¸å䏿¡ç¸åï¼ååªåå ¥åè¡¨æ°æ® if (currentRunningStatus != null && currentRunningStatus.equals(prevRunningStatus)) { String parameter = listSqlParameter(machineInfo); if (parameter != null && !parameter.equals("")) { listParameter.add(parameter); } continue; } // æ´æ°å䏿¡è®°å½çç¶æå¼ prevRunningStatus = currentRunningStatus; 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 { @@ -91,6 +114,7 @@ /** * æ¹éæ§è¡SQLè¯å¥ * * @param sqlList SQLè¯å¥å表 * @throws SQLException */ @@ -126,7 +150,8 @@ /** * æå ¥å°EquipmentLog * æå ¥å°è®¾å¤å表 * * @param machineInfo * @return */ @@ -151,18 +176,7 @@ //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()) + "', "; @@ -228,6 +242,7 @@ /** * æå ¥å°EquipmentLog * * @param machineInfo * @return */ @@ -242,8 +257,7 @@ } 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; } @@ -254,16 +268,35 @@ 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 + ", "; } else { @@ -275,4 +308,21 @@ } 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; } }